diff options
| author | Andreas Gampe <agampe@google.com> | 2014-11-03 21:36:10 -0800 |
|---|---|---|
| committer | Andreas Gampe <agampe@google.com> | 2014-11-04 18:40:08 -0800 |
| commit | 277ccbd200ea43590dfc06a93ae184a765327ad0 (patch) | |
| tree | d89712e93da5fb2748989353c9ee071102cf3f33 /runtime | |
| parent | ad17d41841ba1fb177fb0bf175ec0e9f5e1412b3 (diff) | |
| download | android_art-277ccbd200ea43590dfc06a93ae184a765327ad0.tar.gz android_art-277ccbd200ea43590dfc06a93ae184a765327ad0.tar.bz2 android_art-277ccbd200ea43590dfc06a93ae184a765327ad0.zip | |
ART: More warnings
Enable -Wno-conversion-null, -Wredundant-decls and -Wshadow in general,
and -Wunused-but-set-parameter for GCC builds.
Change-Id: I81bbdd762213444673c65d85edae594a523836e5
Diffstat (limited to 'runtime')
109 files changed, 1171 insertions, 365 deletions
diff --git a/runtime/arch/arm/entrypoints_init_arm.cc b/runtime/arch/arm/entrypoints_init_arm.cc index 24e9b1d3e4..d7d13c2223 100644 --- a/runtime/arch/arm/entrypoints_init_arm.cc +++ b/runtime/arch/arm/entrypoints_init_arm.cc @@ -21,7 +21,6 @@ #include "entrypoints/quick/quick_entrypoints.h" #include "entrypoints/entrypoint_utils.h" #include "entrypoints/math_entrypoints.h" -#include "entrypoints/runtime_asm_entrypoints.h" #include "interpreter/interpreter.h" namespace art { @@ -124,9 +123,12 @@ extern "C" void art_quick_throw_no_such_method(int32_t method_idx); extern "C" void art_quick_throw_null_pointer_exception(); extern "C" void art_quick_throw_stack_overflow(void*); -// Generic JNI downcall +// Generic JNI downcall. extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*); +// JNI resolution. +extern "C" void* art_jni_dlsym_lookup_stub(JNIEnv*, jobject); + void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints, PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) { // Interpreter diff --git a/runtime/arch/memcmp16.cc b/runtime/arch/memcmp16.cc index 5a3e73eebc..813df2f1d7 100644 --- a/runtime/arch/memcmp16.cc +++ b/runtime/arch/memcmp16.cc @@ -19,6 +19,7 @@ // This linked against by assembly stubs, only. #pragma GCC diagnostic ignored "-Wunused-function" +int32_t memcmp16_generic_static(const uint16_t* s0, const uint16_t* s1, size_t count); int32_t memcmp16_generic_static(const uint16_t* s0, const uint16_t* s1, size_t count) { for (size_t i = 0; i < count; i++) { if (s0[i] != s1[i]) { diff --git a/runtime/arch/stub_test.cc b/runtime/arch/stub_test.cc index b0928f8cfa..0fcd297497 100644 --- a/runtime/arch/stub_test.cc +++ b/runtime/arch/stub_test.cc @@ -732,17 +732,17 @@ static void TestUnlockObject(StubTest* test) NO_THREAD_SAFETY_ANALYSIS { EXPECT_EQ(LockWord::LockState::kFatLocked, iter_state); } } else { - bool lock; // Whether to lock or unlock in this step. + bool take_lock; // Whether to lock or unlock in this step. if (counts[index] == 0) { - lock = true; + take_lock = true; } else if (counts[index] == kThinLockLoops) { - lock = false; + take_lock = false; } else { // Randomly. - lock = r.next() % 2 == 0; + take_lock = r.next() % 2 == 0; } - if (lock) { + if (take_lock) { test->Invoke3(reinterpret_cast<size_t>(objects[index].Get()), 0U, 0U, art_quick_lock_object, self); counts[index]++; @@ -1779,8 +1779,8 @@ static void TestFields(Thread* self, StubTest* test, Primitive::Type test_type) Handle<mirror::ObjectArray<mirror::ArtField>> fields(hs.NewHandle(c.Get()->GetSFields())); int32_t num_fields = fields->GetLength(); for (int32_t i = 0; i < num_fields; ++i) { - StackHandleScope<1> hs(self); - Handle<mirror::ArtField> f(hs.NewHandle(fields->Get(i))); + StackHandleScope<1> hs2(self); + Handle<mirror::ArtField> f(hs2.NewHandle(fields->Get(i))); Primitive::Type type = f->GetTypeAsPrimitiveType(); switch (type) { @@ -1834,8 +1834,8 @@ static void TestFields(Thread* self, StubTest* test, Primitive::Type test_type) Handle<mirror::ObjectArray<mirror::ArtField>> fields(hs.NewHandle(c.Get()->GetIFields())); int32_t num_fields = fields->GetLength(); for (int32_t i = 0; i < num_fields; ++i) { - StackHandleScope<1> hs(self); - Handle<mirror::ArtField> f(hs.NewHandle(fields->Get(i))); + StackHandleScope<1> hs2(self); + Handle<mirror::ArtField> f(hs2.NewHandle(fields->Get(i))); Primitive::Type type = f->GetTypeAsPrimitiveType(); switch (type) { diff --git a/runtime/base/macros.h b/runtime/base/macros.h index 90cf951ca2..88b99a183a 100644 --- a/runtime/base/macros.h +++ b/runtime/base/macros.h @@ -41,28 +41,6 @@ #define FINAL #endif -// The COMPILE_ASSERT macro can be used to verify that a compile time -// expression is true. For example, you could use it to verify the -// size of a static array: -// -// COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES, -// content_type_names_incorrect_size); -// -// or to make sure a struct is smaller than a certain size: -// -// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); -// -// The second argument to the macro is the name of the variable. If -// the expression is false, most compilers will issue a warning/error -// containing the name of the variable. - -template <bool> -struct CompileAssert { -}; - -#define COMPILE_ASSERT(expr, msg) \ - typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] // NOLINT - // Declare a friend relationship in a class with a test. Used rather that FRIEND_TEST to avoid // globally importing gtest/gtest.h into the main ART header files. #define ART_FRIEND_TEST(test_set_name, individual_test)\ diff --git a/runtime/base/stringpiece.h b/runtime/base/stringpiece.h index b8de308057..d793bb6153 100644 --- a/runtime/base/stringpiece.h +++ b/runtime/base/stringpiece.h @@ -67,8 +67,8 @@ class StringPiece { ptr_ = nullptr; length_ = 0; } - void set(const char* data, size_type len) { - ptr_ = data; + void set(const char* data_in, size_type len) { + ptr_ = data_in; length_ = len; } void set(const char* str) { @@ -79,8 +79,8 @@ class StringPiece { length_ = 0; } } - void set(const void* data, size_type len) { - ptr_ = reinterpret_cast<const char*>(data); + void set(const void* data_in, size_type len) { + ptr_ = reinterpret_cast<const char*>(data_in); length_ = len; } diff --git a/runtime/check_jni.cc b/runtime/check_jni.cc index ef5ccb6af9..fe5b765a3a 100644 --- a/runtime/check_jni.cc +++ b/runtime/check_jni.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "jni_internal.h" +#include "check_jni.h" #include <sys/mman.h> #include <zlib.h> @@ -27,6 +27,7 @@ #include "field_helper.h" #include "gc/space/space.h" #include "java_vm_ext.h" +#include "jni_internal.h" #include "mirror/art_field-inl.h" #include "mirror/art_method-inl.h" #include "mirror/class-inl.h" diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 08efb70ede..eeb65f94e1 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -173,7 +173,7 @@ struct FieldGapsComparator { typedef std::priority_queue<FieldGap, std::vector<FieldGap>, FieldGapsComparator> FieldGaps; // Adds largest aligned gaps to queue of gaps. -void AddFieldGap(uint32_t gap_start, uint32_t gap_end, FieldGaps* gaps) { +static void AddFieldGap(uint32_t gap_start, uint32_t gap_end, FieldGaps* gaps) { DCHECK(gaps != nullptr); uint32_t current_offset = gap_start; @@ -817,7 +817,6 @@ static bool LoadMultiDexFilesFromOatFile(const OatFile* oat_file, if (oat_dex_file == nullptr) { if (i == 0 && generated) { - std::string error_msg; error_msg = StringPrintf("\nFailed to find dex file '%s' (checksum 0x%x) in generated out " " file'%s'", dex_location, next_location_checksum, oat_file->GetLocation().c_str()); @@ -1193,11 +1192,11 @@ bool ClassLinker::VerifyOatAndDexFileChecksums(const OatFile* oat_file, if (oat_dex_file == nullptr) { *error_msg = StringPrintf("oat file '%s' does not contain contents for '%s' with checksum 0x%x", oat_file->GetLocation().c_str(), dex_location, dex_location_checksum); - for (const OatFile::OatDexFile* oat_dex_file : oat_file->GetOatDexFiles()) { + for (const OatFile::OatDexFile* oat_dex_file_in : oat_file->GetOatDexFiles()) { *error_msg += StringPrintf("\noat file '%s' contains contents for '%s' with checksum 0x%x", oat_file->GetLocation().c_str(), - oat_dex_file->GetDexFileLocation().c_str(), - oat_dex_file->GetDexFileLocationChecksum()); + oat_dex_file_in->GetDexFileLocation().c_str(), + oat_dex_file_in->GetDexFileLocationChecksum()); } return false; } @@ -1673,8 +1672,8 @@ void ClassLinker::InitFromImage() { CHECK_EQ(oat_file.GetOatHeader().GetDexFileCount(), static_cast<uint32_t>(dex_caches->GetLength())); for (int32_t i = 0; i < dex_caches->GetLength(); i++) { - StackHandleScope<1> hs(self); - Handle<mirror::DexCache> dex_cache(hs.NewHandle(dex_caches->Get(i))); + StackHandleScope<1> hs2(self); + Handle<mirror::DexCache> dex_cache(hs2.NewHandle(dex_caches->Get(i))); const std::string& dex_file_location(dex_cache->GetLocation()->ToModifiedUtf8()); const OatFile::OatDexFile* oat_dex_file = oat_file.GetOatDexFile(dex_file_location.c_str(), nullptr); @@ -2041,8 +2040,8 @@ mirror::Class* ClassLinker::EnsureResolved(Thread* self, const char* descriptor, typedef std::pair<const DexFile*, const DexFile::ClassDef*> ClassPathEntry; // Search a collection of DexFiles for a descriptor -ClassPathEntry FindInClassPath(const char* descriptor, - const std::vector<const DexFile*>& class_path) { +static ClassPathEntry FindInClassPath(const char* descriptor, + const std::vector<const DexFile*>& class_path) { for (size_t i = 0; i != class_path.size(); ++i) { const DexFile* dex_file = class_path[i]; const DexFile::ClassDef* dex_class_def = dex_file->FindClassDef(descriptor); @@ -2118,12 +2117,12 @@ mirror::Class* ClassLinker::FindClassInPathClassLoader(ScopedObjectAccessAlready LOG(WARNING) << "Null DexFile::mCookie for " << descriptor; break; } - for (const DexFile* dex_file : *dex_files) { - const DexFile::ClassDef* dex_class_def = dex_file->FindClassDef(descriptor); + for (const DexFile* cp_dex_file : *dex_files) { + const DexFile::ClassDef* dex_class_def = cp_dex_file->FindClassDef(descriptor); if (dex_class_def != nullptr) { - RegisterDexFile(*dex_file); + RegisterDexFile(*cp_dex_file); mirror::Class* klass = - DefineClass(self, descriptor, class_loader, *dex_file, *dex_class_def); + DefineClass(self, descriptor, class_loader, *cp_dex_file, *dex_class_def); if (klass == nullptr) { CHECK(self->IsExceptionPending()) << descriptor; self->ClearException(); @@ -2206,9 +2205,9 @@ mirror::Class* ClassLinker::FindClass(Thread* self, const char* descriptor, } } else { ScopedObjectAccessUnchecked soa(self); - mirror::Class* klass = FindClassInPathClassLoader(soa, self, descriptor, class_loader); - if (klass != nullptr) { - return klass; + mirror::Class* cp_klass = FindClassInPathClassLoader(soa, self, descriptor, class_loader); + if (cp_klass != nullptr) { + return cp_klass; } ScopedLocalRef<jobject> class_loader_object(soa.Env(), soa.AddLocalReference<jobject>(class_loader.Get())); @@ -2453,17 +2452,18 @@ const OatFile::OatMethod ClassLinker::FindOatMethodFor(mirror::ArtMethod* method // by search for its position in the declared virtual methods. oat_method_index = declaring_class->NumDirectMethods(); size_t end = declaring_class->NumVirtualMethods(); - bool found = false; + bool found_virtual = false; for (size_t i = 0; i < end; i++) { // Check method index instead of identity in case of duplicate method definitions. if (method->GetDexMethodIndex() == declaring_class->GetVirtualMethod(i)->GetDexMethodIndex()) { - found = true; + found_virtual = true; break; } oat_method_index++; } - CHECK(found) << "Didn't find oat method index for virtual method: " << PrettyMethod(method); + CHECK(found_virtual) << "Didn't find oat method index for virtual method: " + << PrettyMethod(method); } DCHECK_EQ(oat_method_index, GetOatMethodIndexFromMethodIndex(*declaring_class->GetDexCache()->GetDexFile(), @@ -2472,10 +2472,9 @@ const OatFile::OatMethod ClassLinker::FindOatMethodFor(mirror::ArtMethod* method OatFile::OatClass oat_class = FindOatClass(*declaring_class->GetDexCache()->GetDexFile(), declaring_class->GetDexClassDefIndex(), found); - if (!found) { + if (!(*found)) { return OatFile::OatMethod::Invalid(); } - *found = true; return oat_class.GetOatMethod(oat_method_index); } @@ -3213,9 +3212,9 @@ mirror::Class* ClassLinker::CreateArrayClass(Thread* self, const char* descripto new_class->SetClassLoader(component_type->GetClassLoader()); new_class->SetStatus(mirror::Class::kStatusLoaded, self); { - StackHandleScope<mirror::Class::kImtSize> hs(self, - Runtime::Current()->GetImtUnimplementedMethod()); - new_class->PopulateEmbeddedImtAndVTable(&hs); + StackHandleScope<mirror::Class::kImtSize> hs2(self, + Runtime::Current()->GetImtUnimplementedMethod()); + new_class->PopulateEmbeddedImtAndVTable(&hs2); } new_class->SetStatus(mirror::Class::kStatusInitialized, self); // don't need to set new_class->SetObjectSize(..) @@ -3343,8 +3342,8 @@ mirror::Class* ClassLinker::UpdateClass(const char* descriptor, mirror::Class* k for (auto it = class_table_.lower_bound(hash), end = class_table_.end(); it != end && it->first == hash; ++it) { - mirror::Class* klass = it->second.Read(); - if (klass == existing) { + mirror::Class* klass_from_table = it->second.Read(); + if (klass_from_table == existing) { class_table_.erase(it); break; } @@ -3560,7 +3559,7 @@ void ClassLinker::VerifyClass(Thread* self, Handle<mirror::Class> klass) { Handle<mirror::Class> super(hs.NewHandle(klass->GetSuperClass())); if (super.Get() != nullptr) { // Acquire lock to prevent races on verifying the super class. - ObjectLock<mirror::Class> lock(self, super); + ObjectLock<mirror::Class> super_lock(self, super); if (!super->IsVerified() && !super->IsErroneous()) { VerifyClass(self, super); @@ -3865,10 +3864,10 @@ mirror::Class* ClassLinker::CreateProxyClass(ScopedObjectAccessAlreadyRunnable& klass->SetVirtualMethods(virtuals); } for (size_t i = 0; i < num_virtual_methods; ++i) { - StackHandleScope<1> hs(self); + StackHandleScope<1> hs2(self); mirror::ObjectArray<mirror::ArtMethod>* decoded_methods = soa.Decode<mirror::ObjectArray<mirror::ArtMethod>*>(methods); - Handle<mirror::ArtMethod> prototype(hs.NewHandle(decoded_methods->Get(i))); + Handle<mirror::ArtMethod> prototype(hs2.NewHandle(decoded_methods->Get(i))); mirror::ArtMethod* clone = CreateProxyMethod(self, klass, prototype); if (UNLIKELY(clone == nullptr)) { CHECK(self->IsExceptionPending()); // OOME. @@ -3917,11 +3916,11 @@ mirror::Class* ClassLinker::CreateProxyClass(ScopedObjectAccessAlreadyRunnable& CHECK(klass->GetIFields() == nullptr); CheckProxyConstructor(klass->GetDirectMethod(0)); for (size_t i = 0; i < num_virtual_methods; ++i) { - StackHandleScope<2> hs(self); + StackHandleScope<2> hs2(self); mirror::ObjectArray<mirror::ArtMethod>* decoded_methods = soa.Decode<mirror::ObjectArray<mirror::ArtMethod>*>(methods); - Handle<mirror::ArtMethod> prototype(hs.NewHandle(decoded_methods->Get(i))); - Handle<mirror::ArtMethod> virtual_method(hs.NewHandle(klass->GetVirtualMethod(i))); + Handle<mirror::ArtMethod> prototype(hs2.NewHandle(decoded_methods->Get(i))); + Handle<mirror::ArtMethod> virtual_method(hs2.NewHandle(klass->GetVirtualMethod(i))); CheckProxyMethod(virtual_method, prototype); } @@ -4238,8 +4237,8 @@ bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass, DCHECK(field_it.HasNextStaticField()); CHECK(can_init_statics); for ( ; value_it.HasNext(); value_it.Next(), field_it.Next()) { - StackHandleScope<1> hs(self); - Handle<mirror::ArtField> field(hs.NewHandle( + StackHandleScope<1> hs2(self); + Handle<mirror::ArtField> field(hs2.NewHandle( ResolveField(dex_file, field_it.GetMemberIndex(), dex_cache, class_loader, true))); if (Runtime::Current()->IsActiveTransaction()) { value_it.ReadValueToField<true>(field); @@ -5033,7 +5032,7 @@ bool ClassLinker::LinkInterfaceMethods(Thread* self, Handle<mirror::Class> klass self->AllowThreadSuspension(); size_t num_methods = iftable->GetInterface(i)->NumVirtualMethods(); if (num_methods > 0) { - StackHandleScope<2> hs(self); + StackHandleScope<2> hs2(self); const bool is_super = i < super_ifcount; const bool super_interface = is_super && extend_super_iftable; Handle<mirror::ObjectArray<mirror::ArtMethod>> method_array; @@ -5043,13 +5042,13 @@ bool ClassLinker::LinkInterfaceMethods(Thread* self, Handle<mirror::Class> klass DCHECK(if_table != nullptr); DCHECK(if_table->GetMethodArray(i) != nullptr); // If we are working on a super interface, try extending the existing method array. - method_array = hs.NewHandle(if_table->GetMethodArray(i)->Clone(self)-> + method_array = hs2.NewHandle(if_table->GetMethodArray(i)->Clone(self)-> AsObjectArray<mirror::ArtMethod>()); // We are overwriting a super class interface, try to only virtual methods instead of the // whole vtable. - input_array = hs.NewHandle(klass->GetVirtualMethods()); + input_array = hs2.NewHandle(klass->GetVirtualMethods()); } else { - method_array = hs.NewHandle(AllocArtMethodArray(self, num_methods)); + method_array = hs2.NewHandle(AllocArtMethodArray(self, num_methods)); // A new interface, we need the whole vtable incase a new interface method is implemented // in the whole superclass. input_array = vtable; @@ -5172,9 +5171,9 @@ bool ClassLinker::LinkInterfaceMethods(Thread* self, Handle<mirror::Class> klass } if (kIsDebugBuild) { - mirror::ObjectArray<mirror::ArtMethod>* vtable = klass->GetVTableDuringLinking(); - for (int i = 0; i < vtable->GetLength(); ++i) { - CHECK(vtable->GetWithoutChecks(i) != nullptr); + mirror::ObjectArray<mirror::ArtMethod>* check_vtable = klass->GetVTableDuringLinking(); + for (int i = 0; i < check_vtable->GetLength(); ++i) { + CHECK(check_vtable->GetWithoutChecks(i) != nullptr); } } @@ -5320,7 +5319,7 @@ bool ClassLinker::LinkFields(Thread* self, Handle<mirror::Class> klass, bool is_ << " class=" << PrettyClass(klass.Get()) << " field=" << PrettyField(field) << " offset=" - << field->GetField32(MemberOffset(mirror::ArtField::OffsetOffset())); + << field->GetField32(mirror::ArtField::OffsetOffset()); } Primitive::Type type = field->GetTypeAsPrimitiveType(); bool is_primitive = type != Primitive::kPrimNot; diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 88e6265df5..70807da22e 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -374,8 +374,8 @@ struct CheckOffset { template <typename T> struct CheckOffsets { - CheckOffsets(bool is_static, const char* class_descriptor) - : is_static(is_static), class_descriptor(class_descriptor) {} + CheckOffsets(bool is_static_in, const char* class_descriptor_in) + : is_static(is_static_in), class_descriptor(class_descriptor_in) {} bool is_static; std::string class_descriptor; std::vector<CheckOffset> offsets; diff --git a/runtime/debugger.cc b/runtime/debugger.cc index a9663bba51..584743b9c7 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -1146,7 +1146,7 @@ void Dbg::GetClassList(std::vector<JDWP::RefTypeId>* classes) { // the primitive types). // Returns a newly-allocated buffer full of RefTypeId values. struct ClassListCreator { - explicit ClassListCreator(std::vector<JDWP::RefTypeId>* classes) : classes(classes) { + explicit ClassListCreator(std::vector<JDWP::RefTypeId>* classes_in) : classes(classes_in) { } static bool Visit(mirror::Class* c, void* arg) { @@ -1386,7 +1386,6 @@ JDWP::JdwpError Dbg::SetArrayElements(JDWP::ObjectId array_id, int offset, int c mirror::ObjectArray<mirror::Object>* oa = dst->AsObjectArray<mirror::Object>(); for (int i = 0; i < count; ++i) { JDWP::ObjectId id = request->ReadObjectId(); - JDWP::JdwpError error; mirror::Object* o = gRegistry->Get<mirror::Object*>(id, &error); if (error != JDWP::ERR_NONE) { return error; @@ -2291,8 +2290,8 @@ void Dbg::GetThreads(mirror::Object* thread_group, std::vector<JDWP::ObjectId>* static int GetStackDepth(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { struct CountStackDepthVisitor : public StackVisitor { - explicit CountStackDepthVisitor(Thread* thread) - : StackVisitor(thread, nullptr), depth(0) {} + explicit CountStackDepthVisitor(Thread* thread_in) + : StackVisitor(thread_in, nullptr), depth(0) {} // TODO: Enable annotalysis. We know lock is held in constructor, but abstraction confuses // annotalysis. @@ -2330,10 +2329,11 @@ JDWP::JdwpError Dbg::GetThreadFrames(JDWP::ObjectId thread_id, size_t start_fram size_t frame_count, JDWP::ExpandBuf* buf) { class GetFrameVisitor : public StackVisitor { public: - GetFrameVisitor(Thread* thread, size_t start_frame, size_t frame_count, JDWP::ExpandBuf* buf) + GetFrameVisitor(Thread* thread, size_t start_frame_in, size_t frame_count_in, + JDWP::ExpandBuf* buf_in) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : StackVisitor(thread, nullptr), depth_(0), - start_frame_(start_frame), frame_count_(frame_count), buf_(buf) { + start_frame_(start_frame_in), frame_count_(frame_count_in), buf_(buf_in) { expandBufAdd4BE(buf_, frame_count_); } @@ -2453,9 +2453,9 @@ void Dbg::SuspendSelf() { } struct GetThisVisitor : public StackVisitor { - GetThisVisitor(Thread* thread, Context* context, JDWP::FrameId frame_id) + GetThisVisitor(Thread* thread, Context* context, JDWP::FrameId frame_id_in) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) - : StackVisitor(thread, context), this_object(nullptr), frame_id(frame_id) {} + : StackVisitor(thread, context), this_object(nullptr), frame_id(frame_id_in) {} // TODO: Enable annotalysis. We know lock is held in constructor, but abstraction confuses // annotalysis. @@ -3421,15 +3421,15 @@ JDWP::JdwpError Dbg::ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize // struct DebugCallbackContext { - explicit DebugCallbackContext(SingleStepControl* single_step_control, int32_t line_number, + explicit DebugCallbackContext(SingleStepControl* single_step_control_cb, int32_t line_number_cb, const DexFile::CodeItem* code_item) - : single_step_control_(single_step_control), line_number_(line_number), code_item_(code_item), - last_pc_valid(false), last_pc(0) { + : single_step_control_(single_step_control_cb), line_number_(line_number_cb), + code_item_(code_item), last_pc_valid(false), last_pc(0) { } - static bool Callback(void* raw_context, uint32_t address, uint32_t line_number) { + static bool Callback(void* raw_context, uint32_t address, uint32_t line_number_cb) { DebugCallbackContext* context = reinterpret_cast<DebugCallbackContext*>(raw_context); - if (static_cast<int32_t>(line_number) == context->line_number_) { + if (static_cast<int32_t>(line_number_cb) == context->line_number_) { if (!context->last_pc_valid) { // Everything from this address until the next line change is ours. context->last_pc = address; @@ -4484,9 +4484,9 @@ void Dbg::SetAllocTrackingEnabled(bool enable) { } struct AllocRecordStackVisitor : public StackVisitor { - AllocRecordStackVisitor(Thread* thread, AllocRecord* record) + AllocRecordStackVisitor(Thread* thread, AllocRecord* record_in) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) - : StackVisitor(thread, nullptr), record(record), depth(0) {} + : StackVisitor(thread, nullptr), record(record_in), depth(0) {} // TODO: Enable annotalysis. We know lock is held in constructor, but abstraction confuses // annotalysis. diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc index 761441eae6..16bc33f76a 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -39,7 +39,6 @@ #include "mirror/string.h" #include "os.h" #include "safe_map.h" -#include "ScopedFd.h" #include "handle_scope-inl.h" #include "thread.h" #include "utf-inl.h" @@ -47,6 +46,11 @@ #include "well_known_classes.h" #include "zip_archive.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#include "ScopedFd.h" +#pragma GCC diagnostic pop + namespace art { const uint8_t DexFile::kDexMagic[] = { 'd', 'e', 'x', '\n' }; @@ -454,8 +458,8 @@ const DexFile::ClassDef* DexFile::FindClassDef(const char* descriptor) const { index = new Index(num_class_defs); for (uint32_t i = 0; i < num_class_defs; ++i) { const ClassDef& class_def = GetClassDef(i); - const char* descriptor = GetClassDescriptor(class_def); - index->insert(std::make_pair(descriptor, &class_def)); + const char* class_descriptor = GetClassDescriptor(class_def); + index->insert(std::make_pair(class_descriptor, &class_def)); } // Sanity check the index still doesn't exist, only 1 thread should build it. CHECK(class_def_index_.LoadSequentiallyConsistent() == nullptr); diff --git a/runtime/elf_file.cc b/runtime/elf_file.cc index fb53271157..b6cf921f2c 100644 --- a/runtime/elf_file.cc +++ b/runtime/elf_file.cc @@ -60,6 +60,7 @@ extern "C" { // GDB will place breakpoint into this function. // To prevent GCC from inlining or removing it we place noinline attribute // and inline assembler statement inside. + void __attribute__((noinline)) __jit_debug_register_code(); void __attribute__((noinline)) __jit_debug_register_code() { __asm__(""); } @@ -2396,22 +2397,22 @@ bool ElfFileImpl<Elf_Ehdr, Elf_Phdr, Elf_Shdr, Elf_Word, Elf_Shdr* sh = GetSectionHeader(i); CHECK(sh != nullptr); if (sh->sh_type == SHT_REL) { - for (uint32_t i = 0; i < GetRelNum(*sh); i++) { - Elf_Rel& rel = GetRel(*sh, i); + for (uint32_t j = 0; j < GetRelNum(*sh); j++) { + Elf_Rel& rel = GetRel(*sh, j); if (DEBUG_FIXUP) { LOG(INFO) << StringPrintf("In %s moving Elf_Rel[%d] from 0x%" PRIx64 " to 0x%" PRIx64, - GetFile().GetPath().c_str(), i, + GetFile().GetPath().c_str(), j, static_cast<uint64_t>(rel.r_offset), static_cast<uint64_t>(rel.r_offset + base_address)); } rel.r_offset += base_address; } } else if (sh->sh_type == SHT_RELA) { - for (uint32_t i = 0; i < GetRelaNum(*sh); i++) { - Elf_Rela& rela = GetRela(*sh, i); + for (uint32_t j = 0; j < GetRelaNum(*sh); j++) { + Elf_Rela& rela = GetRela(*sh, j); if (DEBUG_FIXUP) { LOG(INFO) << StringPrintf("In %s moving Elf_Rela[%d] from 0x%" PRIx64 " to 0x%" PRIx64, - GetFile().GetPath().c_str(), i, + GetFile().GetPath().c_str(), j, static_cast<uint64_t>(rela.r_offset), static_cast<uint64_t>(rela.r_offset + base_address)); } diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc index 2cebd6e7a2..4f61707040 100644 --- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -521,8 +521,8 @@ extern "C" uint64_t artQuickToInterpreterBridge(mirror::ArtMethod* method, Threa MethodHelper mh(hs.NewHandle(method)); if (mh.Get()->IsStatic() && !mh.Get()->GetDeclaringClass()->IsInitialized()) { // Ensure static method's class is initialized. - StackHandleScope<1> hs(self); - Handle<mirror::Class> h_class(hs.NewHandle(mh.Get()->GetDeclaringClass())); + StackHandleScope<1> hs2(self); + Handle<mirror::Class> h_class(hs2.NewHandle(mh.Get()->GetDeclaringClass())); if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(self, h_class, true, true)) { DCHECK(Thread::Current()->IsExceptionPending()) << PrettyMethod(mh.Get()); self->PopManagedStackFragment(fragment); diff --git a/runtime/gc/accounting/heap_bitmap-inl.h b/runtime/gc/accounting/heap_bitmap-inl.h index c67542f484..34c15c7f8b 100644 --- a/runtime/gc/accounting/heap_bitmap-inl.h +++ b/runtime/gc/accounting/heap_bitmap-inl.h @@ -40,9 +40,9 @@ inline bool HeapBitmap::Test(const mirror::Object* obj) { if (LIKELY(bitmap != nullptr)) { return bitmap->Test(obj); } - for (const auto& bitmap : large_object_bitmaps_) { - if (LIKELY(bitmap->HasAddress(obj))) { - return bitmap->Test(obj); + for (const auto& lo_bitmap : large_object_bitmaps_) { + if (LIKELY(lo_bitmap->HasAddress(obj))) { + return lo_bitmap->Test(obj); } } LOG(FATAL) << "Invalid object " << obj; @@ -55,9 +55,9 @@ inline void HeapBitmap::Clear(const mirror::Object* obj) { bitmap->Clear(obj); return; } - for (const auto& bitmap : large_object_bitmaps_) { - if (LIKELY(bitmap->HasAddress(obj))) { - bitmap->Clear(obj); + for (const auto& lo_bitmap : large_object_bitmaps_) { + if (LIKELY(lo_bitmap->HasAddress(obj))) { + lo_bitmap->Clear(obj); } } LOG(FATAL) << "Invalid object " << obj; @@ -70,9 +70,9 @@ inline bool HeapBitmap::Set(const mirror::Object* obj, const LargeObjectSetVisit return bitmap->Set(obj); } visitor(obj); - for (const auto& bitmap : large_object_bitmaps_) { - if (LIKELY(bitmap->HasAddress(obj))) { - return bitmap->Set(obj); + for (const auto& lo_bitmap : large_object_bitmaps_) { + if (LIKELY(lo_bitmap->HasAddress(obj))) { + return lo_bitmap->Set(obj); } } LOG(FATAL) << "Invalid object " << obj; @@ -87,9 +87,9 @@ inline bool HeapBitmap::AtomicTestAndSet(const mirror::Object* obj, return bitmap->AtomicTestAndSet(obj); } visitor(obj); - for (const auto& bitmap : large_object_bitmaps_) { - if (LIKELY(bitmap->HasAddress(obj))) { - return bitmap->AtomicTestAndSet(obj); + for (const auto& lo_bitmap : large_object_bitmaps_) { + if (LIKELY(lo_bitmap->HasAddress(obj))) { + return lo_bitmap->AtomicTestAndSet(obj); } } LOG(FATAL) << "Invalid object " << obj; diff --git a/runtime/gc/allocator/dlmalloc.cc b/runtime/gc/allocator/dlmalloc.cc index acff52d50d..8558f96730 100644 --- a/runtime/gc/allocator/dlmalloc.cc +++ b/runtime/gc/allocator/dlmalloc.cc @@ -19,8 +19,8 @@ #include "base/logging.h" // ART specific morecore implementation defined in space.cc. +static void* art_heap_morecore(void* m, intptr_t increment); #define MORECORE(x) art_heap_morecore(m, x) -extern "C" void* art_heap_morecore(void* m, intptr_t increment); // Custom heap error handling. #define PROCEED_ON_ERROR 0 @@ -31,12 +31,16 @@ static void art_heap_usage_error(const char* function, void* p); // Ugly inclusion of C file so that ART specific #defines configure dlmalloc for our use for // mspaces (regular dlmalloc is still declared in bionic). +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wredundant-decls" #pragma GCC diagnostic ignored "-Wempty-body" #pragma GCC diagnostic ignored "-Wstrict-aliasing" #include "../../../bionic/libc/upstream-dlmalloc/malloc.c" -#pragma GCC diagnostic warning "-Wstrict-aliasing" -#pragma GCC diagnostic warning "-Wempty-body" +#pragma GCC diagnostic pop +static void* art_heap_morecore(void* m, intptr_t increment) { + return ::art::gc::allocator::ArtDlMallocMoreCore(m, increment); +} static void art_heap_corruption(const char* function) { LOG(::art::FATAL) << "Corrupt heap detected in: " << function; diff --git a/runtime/gc/allocator/dlmalloc.h b/runtime/gc/allocator/dlmalloc.h index c7ecbc83ce..0e91a4372c 100644 --- a/runtime/gc/allocator/dlmalloc.h +++ b/runtime/gc/allocator/dlmalloc.h @@ -17,6 +17,8 @@ #ifndef ART_RUNTIME_GC_ALLOCATOR_DLMALLOC_H_ #define ART_RUNTIME_GC_ALLOCATOR_DLMALLOC_H_ +#include <cstdint> + // Configure dlmalloc for mspaces. // Avoid a collision with one used in llvm. #undef HAVE_MMAP @@ -28,7 +30,10 @@ #define ONLY_MSPACES 1 #define MALLOC_INSPECT_ALL 1 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wredundant-decls" #include "../../bionic/libc/upstream-dlmalloc/malloc.h" +#pragma GCC diagnostic pop #ifdef HAVE_ANDROID_OS // Define dlmalloc routines from bionic that cannot be included directly because of redefining @@ -47,4 +52,16 @@ extern "C" void DlmallocMadviseCallback(void* start, void* end, size_t used_byte extern "C" void DlmallocBytesAllocatedCallback(void* start, void* end, size_t used_bytes, void* arg); extern "C" void DlmallocObjectsAllocatedCallback(void* start, void* end, size_t used_bytes, void* arg); +namespace art { +namespace gc { +namespace allocator { + +// Callback from dlmalloc when it needs to increase the footprint. Must be implemented somewhere +// else (currently dlmalloc_space.cc). +void* ArtDlMallocMoreCore(void* mspace, intptr_t increment); + +} // namespace allocator +} // namespace gc +} // namespace art + #endif // ART_RUNTIME_GC_ALLOCATOR_DLMALLOC_H_ diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc index f5e2fed9d7..f9d6a512ce 100644 --- a/runtime/gc/allocator/rosalloc.cc +++ b/runtime/gc/allocator/rosalloc.cc @@ -31,8 +31,6 @@ namespace art { namespace gc { namespace allocator { -extern "C" void* art_heap_rosalloc_morecore(RosAlloc* rosalloc, intptr_t increment); - static constexpr bool kUsePrefetchDuringAllocRun = true; static constexpr bool kPrefetchNewRunDataByZeroing = false; static constexpr size_t kPrefetchStride = 64; @@ -179,7 +177,7 @@ void* RosAlloc::AllocPages(Thread* self, size_t num_pages, uint8_t page_map_type page_map_size_ = new_num_of_pages; DCHECK_LE(page_map_size_, max_page_map_size_); free_page_run_size_map_.resize(new_num_of_pages); - art_heap_rosalloc_morecore(this, increment); + ArtRosAllocMoreCore(this, increment); if (last_free_page_run_size > 0) { // There was a free page run at the end. Expand its size. DCHECK_EQ(last_free_page_run_size, last_free_page_run->ByteSize(this)); @@ -745,7 +743,7 @@ size_t RosAlloc::FreeFromRun(Thread* self, void* ptr, Run* run) { const size_t idx = run->size_bracket_idx_; const size_t bracket_size = bracketSizes[idx]; bool run_was_full = false; - MutexLock mu(self, *size_bracket_locks_[idx]); + MutexLock brackets_mu(self, *size_bracket_locks_[idx]); if (kIsDebugBuild) { run_was_full = run->IsFull(); } @@ -785,7 +783,7 @@ size_t RosAlloc::FreeFromRun(Thread* self, void* ptr, Run* run) { DCHECK(full_runs_[idx].find(run) == full_runs_[idx].end()); run->ZeroHeader(); { - MutexLock mu(self, lock_); + MutexLock lock_mu(self, lock_); FreePages(self, run, true); } } else { @@ -1243,7 +1241,7 @@ size_t RosAlloc::BulkFree(Thread* self, void** ptrs, size_t num_ptrs) { run->to_be_bulk_freed_ = false; #endif size_t idx = run->size_bracket_idx_; - MutexLock mu(self, *size_bracket_locks_[idx]); + MutexLock brackets_mu(self, *size_bracket_locks_[idx]); if (run->IsThreadLocal()) { DCHECK_LT(run->size_bracket_idx_, kNumThreadLocalSizeBrackets); DCHECK(non_full_runs_[idx].find(run) == non_full_runs_[idx].end()); @@ -1303,7 +1301,7 @@ size_t RosAlloc::BulkFree(Thread* self, void** ptrs, size_t num_ptrs) { } if (!run_was_current) { run->ZeroHeader(); - MutexLock mu(self, lock_); + MutexLock lock_mu(self, lock_); FreePages(self, run, true); } } else { @@ -1521,7 +1519,7 @@ bool RosAlloc::Trim() { page_map_size_ = new_num_of_pages; free_page_run_size_map_.resize(new_num_of_pages); DCHECK_EQ(free_page_run_size_map_.size(), new_num_of_pages); - art_heap_rosalloc_morecore(this, -(static_cast<intptr_t>(decrement))); + ArtRosAllocMoreCore(this, -(static_cast<intptr_t>(decrement))); if (kTraceRosAlloc) { LOG(INFO) << "RosAlloc::Trim() : decreased the footprint from " << footprint_ << " to " << new_footprint; @@ -1737,14 +1735,14 @@ void RosAlloc::AssertThreadLocalRunsAreRevoked(Thread* thread) { void RosAlloc::AssertAllThreadLocalRunsAreRevoked() { if (kIsDebugBuild) { Thread* self = Thread::Current(); - MutexLock mu(self, *Locks::runtime_shutdown_lock_); - MutexLock mu2(self, *Locks::thread_list_lock_); + MutexLock shutdown_mu(self, *Locks::runtime_shutdown_lock_); + MutexLock thread_list_mu(self, *Locks::thread_list_lock_); std::list<Thread*> thread_list = Runtime::Current()->GetThreadList()->GetList(); for (Thread* t : thread_list) { AssertThreadLocalRunsAreRevoked(t); } for (size_t idx = 0; idx < kNumThreadLocalSizeBrackets; ++idx) { - MutexLock mu(self, *size_bracket_locks_[idx]); + MutexLock brackets_mu(self, *size_bracket_locks_[idx]); CHECK_EQ(current_runs_[idx], dedicated_full_run_); } } @@ -1873,11 +1871,11 @@ void RosAlloc::Verify() { Thread* self = Thread::Current(); CHECK(Locks::mutator_lock_->IsExclusiveHeld(self)) << "The mutator locks isn't exclusively locked at " << __PRETTY_FUNCTION__; - MutexLock mu(self, *Locks::thread_list_lock_); + MutexLock thread_list_mu(self, *Locks::thread_list_lock_); ReaderMutexLock wmu(self, bulk_free_lock_); std::vector<Run*> runs; { - MutexLock mu(self, lock_); + MutexLock lock_mu(self, lock_); size_t pm_end = page_map_size_; size_t i = 0; while (i < pm_end) { @@ -1968,7 +1966,7 @@ void RosAlloc::Verify() { std::list<Thread*> threads = Runtime::Current()->GetThreadList()->GetList(); for (Thread* thread : threads) { for (size_t i = 0; i < kNumThreadLocalSizeBrackets; ++i) { - MutexLock mu(self, *size_bracket_locks_[i]); + MutexLock brackets_mu(self, *size_bracket_locks_[i]); Run* thread_local_run = reinterpret_cast<Run*>(thread->GetRosAllocRun(i)); CHECK(thread_local_run != nullptr); CHECK(thread_local_run->IsThreadLocal()); @@ -1977,7 +1975,7 @@ void RosAlloc::Verify() { } } for (size_t i = 0; i < kNumOfSizeBrackets; i++) { - MutexLock mu(self, *size_bracket_locks_[i]); + MutexLock brackets_mu(self, *size_bracket_locks_[i]); Run* current_run = current_runs_[i]; CHECK(current_run != nullptr); if (current_run != dedicated_full_run_) { diff --git a/runtime/gc/allocator/rosalloc.h b/runtime/gc/allocator/rosalloc.h index a2f8342fd8..2a0bf10d90 100644 --- a/runtime/gc/allocator/rosalloc.h +++ b/runtime/gc/allocator/rosalloc.h @@ -616,6 +616,10 @@ class RosAlloc { }; std::ostream& operator<<(std::ostream& os, const RosAlloc::PageMapKind& rhs); +// Callback from rosalloc when it needs to increase the footprint. Must be implemented somewhere +// else (currently rosalloc_space.cc). +void* ArtRosAllocMoreCore(allocator::RosAlloc* rosalloc, intptr_t increment); + } // namespace allocator } // namespace gc } // namespace art diff --git a/runtime/gc/collector/mark_compact.cc b/runtime/gc/collector/mark_compact.cc index 6691b0f4fc..b2482acaf5 100644 --- a/runtime/gc/collector/mark_compact.cc +++ b/runtime/gc/collector/mark_compact.cc @@ -239,7 +239,7 @@ void MarkCompact::UpdateAndMarkModUnion() { accounting::ModUnionTable* table = heap_->FindModUnionTableFromSpace(space); if (table != nullptr) { // TODO: Improve naming. - TimingLogger::ScopedTiming t( + TimingLogger::ScopedTiming t2( space->IsZygoteSpace() ? "UpdateAndMarkZygoteModUnionTable" : "UpdateAndMarkImageModUnionTable", GetTimings()); table->UpdateAndMarkReferences(MarkHeapReferenceCallback, this); @@ -348,7 +348,7 @@ void MarkCompact::UpdateReferences() { accounting::ModUnionTable* table = heap_->FindModUnionTableFromSpace(space); if (table != nullptr) { // TODO: Improve naming. - TimingLogger::ScopedTiming t( + TimingLogger::ScopedTiming t2( space->IsZygoteSpace() ? "UpdateZygoteModUnionTableReferences" : "UpdateImageModUnionTableReferences", GetTimings()); @@ -538,7 +538,7 @@ void MarkCompact::Sweep(bool swap_bitmaps) { if (!ShouldSweepSpace(alloc_space)) { continue; } - TimingLogger::ScopedTiming t( + TimingLogger::ScopedTiming t2( alloc_space->IsZygoteSpace() ? "SweepZygoteSpace" : "SweepAllocSpace", GetTimings()); RecordFree(alloc_space->Sweep(swap_bitmaps)); } diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index e3966e3081..6ad44e6a75 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -667,10 +667,10 @@ class MarkStackTask : public Task { Object* obj = nullptr; if (kUseMarkStackPrefetch) { while (mark_stack_pos_ != 0 && prefetch_fifo.size() < kFifoSize) { - Object* obj = mark_stack_[--mark_stack_pos_]; - DCHECK(obj != nullptr); - __builtin_prefetch(obj); - prefetch_fifo.push_back(obj); + Object* mark_stack_obj = mark_stack_[--mark_stack_pos_]; + DCHECK(mark_stack_obj != nullptr); + __builtin_prefetch(mark_stack_obj); + prefetch_fifo.push_back(mark_stack_obj); } if (UNLIKELY(prefetch_fifo.empty())) { break; @@ -928,7 +928,7 @@ void MarkSweep::ReMarkRoots() { kVisitRootFlagStopLoggingNewRoots | kVisitRootFlagClearRootLog)); if (kVerifyRootsMarked) { - TimingLogger::ScopedTiming t("(Paused)VerifyRoots", GetTimings()); + TimingLogger::ScopedTiming t2("(Paused)VerifyRoots", GetTimings()); Runtime::Current()->VisitRoots(VerifyRootMarked, this); } } @@ -1057,7 +1057,7 @@ void MarkSweep::SweepArray(accounting::ObjectStack* allocations, bool swap_bitma // if needed. if (!mark_bitmap->Test(obj)) { if (chunk_free_pos >= kSweepArrayChunkFreeSize) { - TimingLogger::ScopedTiming t("FreeList", GetTimings()); + TimingLogger::ScopedTiming t2("FreeList", GetTimings()); freed.objects += chunk_free_pos; freed.bytes += alloc_space->FreeList(self, chunk_free_pos, chunk_free_buffer); chunk_free_pos = 0; @@ -1069,7 +1069,7 @@ void MarkSweep::SweepArray(accounting::ObjectStack* allocations, bool swap_bitma } } if (chunk_free_pos > 0) { - TimingLogger::ScopedTiming t("FreeList", GetTimings()); + TimingLogger::ScopedTiming t2("FreeList", GetTimings()); freed.objects += chunk_free_pos; freed.bytes += alloc_space->FreeList(self, chunk_free_pos, chunk_free_buffer); chunk_free_pos = 0; @@ -1099,10 +1099,10 @@ void MarkSweep::SweepArray(accounting::ObjectStack* allocations, bool swap_bitma } } { - TimingLogger::ScopedTiming t("RecordFree", GetTimings()); + TimingLogger::ScopedTiming t2("RecordFree", GetTimings()); RecordFree(freed); RecordFreeLOS(freed_los); - t.NewTiming("ResetStack"); + t2.NewTiming("ResetStack"); allocations->Reset(); } sweep_array_free_buffer_mem_map_->MadviseDontNeedAndZero(); @@ -1218,10 +1218,10 @@ void MarkSweep::ProcessMarkStack(bool paused) { Object* obj = NULL; if (kUseMarkStackPrefetch) { while (!mark_stack_->IsEmpty() && prefetch_fifo.size() < kFifoSize) { - Object* obj = mark_stack_->PopBack(); - DCHECK(obj != NULL); - __builtin_prefetch(obj); - prefetch_fifo.push_back(obj); + Object* mark_stack_obj = mark_stack_->PopBack(); + DCHECK(mark_stack_obj != NULL); + __builtin_prefetch(mark_stack_obj); + prefetch_fifo.push_back(mark_stack_obj); } if (prefetch_fifo.empty()) { break; diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc index e141b6f4ab..cb9f111058 100644 --- a/runtime/gc/collector/semi_space.cc +++ b/runtime/gc/collector/semi_space.cc @@ -224,7 +224,7 @@ void SemiSpace::MarkingPhase() { // Need to do this before the checkpoint since we don't want any threads to add references to // the live stack during the recursive mark. if (kUseThreadLocalAllocationStack) { - TimingLogger::ScopedTiming t("RevokeAllThreadLocalAllocationStacks", GetTimings()); + TimingLogger::ScopedTiming t2("RevokeAllThreadLocalAllocationStacks", GetTimings()); heap_->RevokeAllThreadLocalAllocationStacks(self_); } heap_->SwapStacks(self_); @@ -368,7 +368,7 @@ void SemiSpace::MarkReachableObjects() { CHECK_EQ(is_large_object_space_immune_, collect_from_space_only_); space::LargeObjectSpace* los = GetHeap()->GetLargeObjectsSpace(); if (is_large_object_space_immune_ && los != nullptr) { - TimingLogger::ScopedTiming t("VisitLargeObjects", GetTimings()); + TimingLogger::ScopedTiming t2("VisitLargeObjects", GetTimings()); DCHECK(collect_from_space_only_); // Delay copying the live set to the marked set until here from // BindBitmaps() as the large objects on the allocation stack may diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 9fd9a2b377..06cd326d84 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -599,8 +599,8 @@ void Heap::DumpObject(std::ostream& stream, mirror::Object* obj) { } } // Unprotect all the spaces. - for (const auto& space : continuous_spaces_) { - mprotect(space->Begin(), space->Capacity(), PROT_READ | PROT_WRITE); + for (const auto& con_space : continuous_spaces_) { + mprotect(con_space->Begin(), con_space->Capacity(), PROT_READ | PROT_WRITE); } stream << "Object " << obj; if (space != nullptr) { @@ -1266,12 +1266,12 @@ mirror::Object* Heap::AllocateInternalWithGc(Thread* self, AllocatorType allocat continue; } // Attempt to run the collector, if we succeed, re-try the allocation. - const bool gc_ran = + const bool plan_gc_ran = CollectGarbageInternal(gc_type, kGcCauseForAlloc, false) != collector::kGcTypeNone; if (was_default_allocator && allocator != GetCurrentAllocator()) { return nullptr; } - if (gc_ran) { + if (plan_gc_ran) { // Did we free sufficient memory for the allocation to succeed? mirror::Object* ptr = TryToAllocate<true, false>(self, allocator, alloc_size, bytes_allocated, usable_size); @@ -1532,7 +1532,7 @@ HomogeneousSpaceCompactResult Heap::PerformHomogeneousSpaceCompact() { ScopedThreadStateChange tsc(self, kWaitingPerformingGc); Locks::mutator_lock_->AssertNotHeld(self); { - ScopedThreadStateChange tsc(self, kWaitingForGcToComplete); + ScopedThreadStateChange tsc2(self, kWaitingForGcToComplete); MutexLock mu(self, *gc_complete_lock_); // Ensure there is only one GC at a time. WaitForGcToCompleteLocked(kGcCauseHomogeneousSpaceCompact, self); @@ -1604,7 +1604,7 @@ void Heap::TransitionCollector(CollectorType collector_type) { // compacting_gc_disable_count_, this should rarely occurs). for (;;) { { - ScopedThreadStateChange tsc(self, kWaitingForGcToComplete); + ScopedThreadStateChange tsc2(self, kWaitingForGcToComplete); MutexLock mu(self, *gc_complete_lock_); // Ensure there is only one GC at a time. WaitForGcToCompleteLocked(kGcCauseCollectorTransition, self); @@ -2079,7 +2079,7 @@ collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type, GcCaus bool compacting_gc; { gc_complete_lock_->AssertNotHeld(self); - ScopedThreadStateChange tsc(self, kWaitingForGcToComplete); + ScopedThreadStateChange tsc2(self, kWaitingForGcToComplete); MutexLock mu(self, *gc_complete_lock_); // Ensure there is only one GC at a time. WaitForGcToCompleteLocked(gc_cause, self); @@ -2646,15 +2646,15 @@ void Heap::ProcessCards(TimingLogger* timings, bool use_rem_sets) { if (table != nullptr) { const char* name = space->IsZygoteSpace() ? "ZygoteModUnionClearCards" : "ImageModUnionClearCards"; - TimingLogger::ScopedTiming t(name, timings); + TimingLogger::ScopedTiming t2(name, timings); table->ClearCards(); } else if (use_rem_sets && rem_set != nullptr) { DCHECK(collector::SemiSpace::kUseRememberedSet && collector_type_ == kCollectorTypeGSS) << static_cast<int>(collector_type_); - TimingLogger::ScopedTiming t("AllocSpaceRemSetClearCards", timings); + TimingLogger::ScopedTiming t2("AllocSpaceRemSetClearCards", timings); rem_set->ClearCards(); } else if (space->GetType() != space::kSpaceTypeBumpPointerSpace) { - TimingLogger::ScopedTiming t("AllocSpaceClearCards", timings); + TimingLogger::ScopedTiming t2("AllocSpaceClearCards", timings); // No mod union table for the AllocSpace. Age the cards so that the GC knows that these cards // were dirty before the GC started. // TODO: Need to use atomic for the case where aged(cleaning thread) -> dirty(other thread) @@ -2676,7 +2676,7 @@ void Heap::PreGcVerificationPaused(collector::GarbageCollector* gc) { TimingLogger* const timings = current_gc_iteration_.GetTimings(); TimingLogger::ScopedTiming t(__FUNCTION__, timings); if (verify_pre_gc_heap_) { - TimingLogger::ScopedTiming t("(Paused)PreGcVerifyHeapReferences", timings); + TimingLogger::ScopedTiming t2("(Paused)PreGcVerifyHeapReferences", timings); ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_); size_t failures = VerifyHeapReferences(); if (failures > 0) { @@ -2686,7 +2686,7 @@ void Heap::PreGcVerificationPaused(collector::GarbageCollector* gc) { } // Check that all objects which reference things in the live stack are on dirty cards. if (verify_missing_card_marks_) { - TimingLogger::ScopedTiming t("(Paused)PreGcVerifyMissingCardMarks", timings); + TimingLogger::ScopedTiming t2("(Paused)PreGcVerifyMissingCardMarks", timings); ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_); SwapStacks(self); // Sort the live stack so that we can quickly binary search it later. @@ -2695,7 +2695,7 @@ void Heap::PreGcVerificationPaused(collector::GarbageCollector* gc) { SwapStacks(self); } if (verify_mod_union_table_) { - TimingLogger::ScopedTiming t("(Paused)PreGcVerifyModUnionTables", timings); + TimingLogger::ScopedTiming t2("(Paused)PreGcVerifyModUnionTables", timings); ReaderMutexLock reader_lock(self, *Locks::heap_bitmap_lock_); for (const auto& table_pair : mod_union_tables_) { accounting::ModUnionTable* mod_union_table = table_pair.second; @@ -2727,7 +2727,7 @@ void Heap::PreSweepingGcVerification(collector::GarbageCollector* gc) { // Called before sweeping occurs since we want to make sure we are not going so reclaim any // reachable objects. if (verify_pre_sweeping_heap_) { - TimingLogger::ScopedTiming t("(Paused)PostSweepingVerifyHeapReferences", timings); + TimingLogger::ScopedTiming t2("(Paused)PostSweepingVerifyHeapReferences", timings); CHECK_NE(self->GetState(), kRunnable); WriterMutexLock mu(self, *Locks::heap_bitmap_lock_); // Swapping bound bitmaps does nothing. @@ -2760,7 +2760,7 @@ void Heap::PostGcVerificationPaused(collector::GarbageCollector* gc) { RosAllocVerification(timings, "(Paused)PostGcRosAllocVerification"); } if (verify_post_gc_heap_) { - TimingLogger::ScopedTiming t("(Paused)PostGcVerifyHeapReferences", timings); + TimingLogger::ScopedTiming t2("(Paused)PostGcVerifyHeapReferences", timings); ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_); size_t failures = VerifyHeapReferences(); if (failures > 0) { diff --git a/runtime/gc/heap_test.cc b/runtime/gc/heap_test.cc index 3106b4c913..73196b20a2 100644 --- a/runtime/gc/heap_test.cc +++ b/runtime/gc/heap_test.cc @@ -48,8 +48,8 @@ TEST_F(HeapTest, GarbageCollectClassLinkerInit) { Handle<mirror::Class> c( hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/Object;"))); for (size_t i = 0; i < 1024; ++i) { - StackHandleScope<1> hs(soa.Self()); - Handle<mirror::ObjectArray<mirror::Object>> array(hs.NewHandle( + StackHandleScope<1> hs2(soa.Self()); + Handle<mirror::ObjectArray<mirror::Object>> array(hs2.NewHandle( mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(), c.Get(), 2048))); for (size_t j = 0; j < 2048; ++j) { mirror::String* string = mirror::String::AllocFromModifiedUtf8(soa.Self(), "hello, world!"); diff --git a/runtime/gc/reference_processor.cc b/runtime/gc/reference_processor.cc index bfaa2bb0cc..012f9f91f5 100644 --- a/runtime/gc/reference_processor.cc +++ b/runtime/gc/reference_processor.cc @@ -143,7 +143,7 @@ void ReferenceProcessor::ProcessReferences(bool concurrent, TimingLogger* timing soft_reference_queue_.ClearWhiteReferences(&cleared_references_, is_marked_callback, arg); weak_reference_queue_.ClearWhiteReferences(&cleared_references_, is_marked_callback, arg); { - TimingLogger::ScopedTiming t(concurrent ? "EnqueueFinalizerReferences" : + TimingLogger::ScopedTiming t2(concurrent ? "EnqueueFinalizerReferences" : "(Paused)EnqueueFinalizerReferences", timings); if (concurrent) { StartPreservingReferences(self); diff --git a/runtime/gc/space/bump_pointer_space.cc b/runtime/gc/space/bump_pointer_space.cc index 0a55b52c08..04b09e9969 100644 --- a/runtime/gc/space/bump_pointer_space.cc +++ b/runtime/gc/space/bump_pointer_space.cc @@ -188,11 +188,11 @@ void BumpPointerSpace::Walk(ObjectCallback* callback, void* arg) { size_t block_size = header->size_; pos += sizeof(BlockHeader); // Skip the header so that we know where the objects mirror::Object* obj = reinterpret_cast<mirror::Object*>(pos); - const mirror::Object* end = reinterpret_cast<const mirror::Object*>(pos + block_size); - CHECK_LE(reinterpret_cast<const uint8_t*>(end), End()); + const mirror::Object* end_obj = reinterpret_cast<const mirror::Object*>(pos + block_size); + CHECK_LE(reinterpret_cast<const uint8_t*>(end_obj), End()); // We don't know how many objects are allocated in the current block. When we hit a null class // assume its the end. TODO: Have a thread update the header when it flushes the block? - while (obj < end && obj->GetClass() != nullptr) { + while (obj < end_obj && obj->GetClass() != nullptr) { callback(obj, arg); obj = GetNextObject(obj); } diff --git a/runtime/gc/space/dlmalloc_space.cc b/runtime/gc/space/dlmalloc_space.cc index 445c720d4c..3072c23bf3 100644 --- a/runtime/gc/space/dlmalloc_space.cc +++ b/runtime/gc/space/dlmalloc_space.cc @@ -213,27 +213,6 @@ size_t DlMallocSpace::FreeList(Thread* self, size_t num_ptrs, mirror::Object** p } } -// Callback from dlmalloc when it needs to increase the footprint -extern "C" void* art_heap_morecore(void* mspace, intptr_t increment) { - Heap* heap = Runtime::Current()->GetHeap(); - DlMallocSpace* dlmalloc_space = heap->GetDlMallocSpace(); - // Support for multiple DlMalloc provided by a slow path. - if (UNLIKELY(dlmalloc_space == nullptr || dlmalloc_space->GetMspace() != mspace)) { - dlmalloc_space = nullptr; - for (space::ContinuousSpace* space : heap->GetContinuousSpaces()) { - if (space->IsDlMallocSpace()) { - DlMallocSpace* cur_dlmalloc_space = space->AsDlMallocSpace(); - if (cur_dlmalloc_space->GetMspace() == mspace) { - dlmalloc_space = cur_dlmalloc_space; - break; - } - } - } - CHECK(dlmalloc_space != nullptr) << "Couldn't find DlmMallocSpace with mspace=" << mspace; - } - return dlmalloc_space->MoreCore(increment); -} - size_t DlMallocSpace::Trim() { MutexLock mu(Thread::Current(), lock_); // Trim to release memory at the end of the space. @@ -330,5 +309,31 @@ void DlMallocSpace::LogFragmentationAllocFailure(std::ostream& os, size_t failed } } // namespace space + +namespace allocator { + +// Implement the dlmalloc morecore callback. +void* ArtDlMallocMoreCore(void* mspace, intptr_t increment) { + Heap* heap = Runtime::Current()->GetHeap(); + ::art::gc::space::DlMallocSpace* dlmalloc_space = heap->GetDlMallocSpace(); + // Support for multiple DlMalloc provided by a slow path. + if (UNLIKELY(dlmalloc_space == nullptr || dlmalloc_space->GetMspace() != mspace)) { + dlmalloc_space = nullptr; + for (space::ContinuousSpace* space : heap->GetContinuousSpaces()) { + if (space->IsDlMallocSpace()) { + ::art::gc::space::DlMallocSpace* cur_dlmalloc_space = space->AsDlMallocSpace(); + if (cur_dlmalloc_space->GetMspace() == mspace) { + dlmalloc_space = cur_dlmalloc_space; + break; + } + } + } + CHECK(dlmalloc_space != nullptr) << "Couldn't find DlmMallocSpace with mspace=" << mspace; + } + return dlmalloc_space->MoreCore(increment); +} + +} // namespace allocator + } // namespace gc } // namespace art diff --git a/runtime/gc/space/rosalloc_space.cc b/runtime/gc/space/rosalloc_space.cc index 161eba9c1d..ff8b570a02 100644 --- a/runtime/gc/space/rosalloc_space.cc +++ b/runtime/gc/space/rosalloc_space.cc @@ -228,15 +228,6 @@ size_t RosAllocSpace::FreeList(Thread* self, size_t num_ptrs, mirror::Object** p return bytes_freed; } -// Callback from rosalloc when it needs to increase the footprint -extern "C" void* art_heap_rosalloc_morecore(allocator::RosAlloc* rosalloc, intptr_t increment) { - Heap* heap = Runtime::Current()->GetHeap(); - RosAllocSpace* rosalloc_space = heap->GetRosAllocSpace(rosalloc); - DCHECK(rosalloc_space != nullptr); - DCHECK_EQ(rosalloc_space->GetRosAlloc(), rosalloc); - return rosalloc_space->MoreCore(increment); -} - size_t RosAllocSpace::Trim() { VLOG(heap) << "RosAllocSpace::Trim() "; { @@ -367,5 +358,19 @@ void RosAllocSpace::Clear() { } } // namespace space + +namespace allocator { + +// Callback from rosalloc when it needs to increase the footprint. +void* ArtRosAllocMoreCore(allocator::RosAlloc* rosalloc, intptr_t increment) { + Heap* heap = Runtime::Current()->GetHeap(); + art::gc::space::RosAllocSpace* rosalloc_space = heap->GetRosAllocSpace(rosalloc); + DCHECK(rosalloc_space != nullptr); + DCHECK_EQ(rosalloc_space->GetRosAlloc(), rosalloc); + return rosalloc_space->MoreCore(increment); +} + +} // namespace allocator + } // namespace gc } // namespace art diff --git a/runtime/gc/space/space.cc b/runtime/gc/space/space.cc index b233805e4c..486d79ad1b 100644 --- a/runtime/gc/space/space.cc +++ b/runtime/gc/space/space.cc @@ -133,8 +133,8 @@ void ContinuousMemMapAllocSpace::SwapBitmaps() { mark_bitmap_->SetName(temp_name); } -AllocSpace::SweepCallbackContext::SweepCallbackContext(bool swap_bitmaps, space::Space* space) - : swap_bitmaps(swap_bitmaps), space(space), self(Thread::Current()) { +AllocSpace::SweepCallbackContext::SweepCallbackContext(bool swap_bitmaps_in, space::Space* space_in) + : swap_bitmaps(swap_bitmaps_in), space(space_in), self(Thread::Current()) { } } // namespace space diff --git a/runtime/instruction_set.h b/runtime/instruction_set.h index 529fa0c05f..84a3e80636 100644 --- a/runtime/instruction_set.h +++ b/runtime/instruction_set.h @@ -370,7 +370,8 @@ static inline constexpr TwoWordReturn GetTwoWordFailureValue() { // Use the lower 32b for the method pointer and the upper 32b for the code pointer. static inline TwoWordReturn GetTwoWordSuccessValue(uintptr_t hi, uintptr_t lo) { - uint32_t lo32 = static_cast<uint32_t>(lo); + static_assert(sizeof(uint32_t) == sizeof(uintptr_t), "Unexpected size difference"); + uint32_t lo32 = lo; uint64_t hi64 = static_cast<uint64_t>(hi); return ((hi64 << 32) | lo32); } diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index 160e8c36a3..003e1601ce 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -177,8 +177,9 @@ void Instrumentation::InstallStubsForMethod(mirror::ArtMethod* method) { static void InstrumentationInstallStack(Thread* thread, void* arg) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { struct InstallStackVisitor : public StackVisitor { - InstallStackVisitor(Thread* thread, Context* context, uintptr_t instrumentation_exit_pc) - : StackVisitor(thread, context), instrumentation_stack_(thread->GetInstrumentationStack()), + InstallStackVisitor(Thread* thread_in, Context* context, uintptr_t instrumentation_exit_pc) + : StackVisitor(thread_in, context), + instrumentation_stack_(thread_in->GetInstrumentationStack()), instrumentation_exit_pc_(instrumentation_exit_pc), reached_existing_instrumentation_frames_(false), instrumentation_stack_depth_(0), last_return_pc_(0) { @@ -316,12 +317,12 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) static void InstrumentationRestoreStack(Thread* thread, void* arg) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { struct RestoreStackVisitor : public StackVisitor { - RestoreStackVisitor(Thread* thread, uintptr_t instrumentation_exit_pc, + RestoreStackVisitor(Thread* thread_in, uintptr_t instrumentation_exit_pc, Instrumentation* instrumentation) - : StackVisitor(thread, NULL), thread_(thread), + : StackVisitor(thread_in, NULL), thread_(thread_in), instrumentation_exit_pc_(instrumentation_exit_pc), instrumentation_(instrumentation), - instrumentation_stack_(thread->GetInstrumentationStack()), + instrumentation_stack_(thread_in->GetInstrumentationStack()), frames_removed_(0) {} virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { diff --git a/runtime/intern_table.cc b/runtime/intern_table.cc index 89586b0982..95186c6ad6 100644 --- a/runtime/intern_table.cc +++ b/runtime/intern_table.cc @@ -192,9 +192,9 @@ mirror::String* InternTable::LookupStringFromImage(mirror::String* s) const DexFile::StringId* string_id = dex_file->FindStringId(utf8.c_str()); if (string_id != NULL) { uint32_t string_idx = dex_file->GetIndexForStringId(*string_id); - mirror::String* image = dex_cache->GetResolvedString(string_idx); - if (image != NULL) { - return image; + mirror::String* image_string = dex_cache->GetResolvedString(string_idx); + if (image_string != NULL) { + return image_string; } } } diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index 44e2029329..18de133147 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -315,7 +315,7 @@ enum InterpreterImplKind { kSwitchImpl, // Switch-based interpreter implementation. kComputedGotoImplKind // Computed-goto-based interpreter implementation. }; -std::ostream& operator<<(std::ostream& os, const InterpreterImplKind& rhs) { +static std::ostream& operator<<(std::ostream& os, const InterpreterImplKind& rhs) { os << ((rhs == kSwitchImpl) ? "Switch-based interpreter" : "Computed-goto-based interpreter"); return os; } diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc index 5c77b96a5f..eb80c307f6 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -855,12 +855,12 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper* mh, // Special managed code cut-out to allow field lookup in a un-started runtime that'd fail // going the reflective Dex way. Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass(); - String* name = shadow_frame->GetVRegReference(arg_offset + 1)->AsString(); + String* name2 = shadow_frame->GetVRegReference(arg_offset + 1)->AsString(); ArtField* found = NULL; ObjectArray<ArtField>* fields = klass->GetIFields(); for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { ArtField* f = fields->Get(i); - if (name->Equals(f->GetName())) { + if (name2->Equals(f->GetName())) { found = f; } } @@ -868,14 +868,14 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper* mh, fields = klass->GetSFields(); for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { ArtField* f = fields->Get(i); - if (name->Equals(f->GetName())) { + if (name2->Equals(f->GetName())) { found = f; } } } CHECK(found != NULL) << "Failed to find field in Class.getDeclaredField in un-started runtime. name=" - << name->ToModifiedUtf8() << " class=" << PrettyDescriptor(klass); + << name2->ToModifiedUtf8() << " class=" << PrettyDescriptor(klass); // TODO: getDeclaredField calls GetType once the field is found to ensure a // NoClassDefFoundError is thrown if the field's type cannot be resolved. Class* jlr_Field = self->DecodeJObject(WellKnownClasses::java_lang_reflect_Field)->AsClass(); diff --git a/runtime/jdwp/jdwp_adb.cc b/runtime/jdwp/jdwp_adb.cc index fe91bb6d47..df7d068922 100644 --- a/runtime/jdwp/jdwp_adb.cc +++ b/runtime/jdwp/jdwp_adb.cc @@ -84,13 +84,13 @@ struct JdwpAdbState : public JdwpNetStateBase { shutting_down_ = true; int control_sock = this->control_sock_; - int clientSock = this->clientSock; + int local_clientSock = this->clientSock; /* clear these out so it doesn't wake up and try to reuse them */ this->control_sock_ = this->clientSock = -1; - if (clientSock != -1) { - shutdown(clientSock, SHUT_RDWR); + if (local_clientSock != -1) { + shutdown(local_clientSock, SHUT_RDWR); } if (control_sock != -1) { diff --git a/runtime/jdwp/jdwp_bits.h b/runtime/jdwp/jdwp_bits.h index 9f80cbe307..f9cf9ca0d9 100644 --- a/runtime/jdwp/jdwp_bits.h +++ b/runtime/jdwp/jdwp_bits.h @@ -68,7 +68,7 @@ static inline void AppendUtf16BE(std::vector<uint8_t>& bytes, const uint16_t* ch // @deprecated static inline void Set1(uint8_t* buf, uint8_t val) { - *buf = (uint8_t)(val); + *buf = val; } // @deprecated diff --git a/runtime/jdwp/jdwp_event.cc b/runtime/jdwp/jdwp_event.cc index d1229b28a8..44f713ca96 100644 --- a/runtime/jdwp/jdwp_event.cc +++ b/runtime/jdwp/jdwp_event.cc @@ -138,7 +138,7 @@ static bool NeedsFullDeoptimization(JdwpEventKind eventKind) { } } -uint32_t GetInstrumentationEventFor(JdwpEventKind eventKind) { +static uint32_t GetInstrumentationEventFor(JdwpEventKind eventKind) { switch (eventKind) { case EK_BREAKPOINT: case EK_SINGLE_STEP: diff --git a/runtime/jdwp/jdwp_socket.cc b/runtime/jdwp/jdwp_socket.cc index 4a80957b11..e8c08561d0 100644 --- a/runtime/jdwp/jdwp_socket.cc +++ b/runtime/jdwp/jdwp_socket.cc @@ -170,20 +170,20 @@ static JdwpSocketState* SocketStartup(JdwpState* state, uint16_t port, bool prob * for an open port.) */ void JdwpSocketState::Shutdown() { - int listenSock = this->listenSock; - int clientSock = this->clientSock; + int local_listenSock = this->listenSock; + int local_clientSock = this->clientSock; /* clear these out so it doesn't wake up and try to reuse them */ this->listenSock = this->clientSock = -1; /* "shutdown" dislodges blocking read() and accept() calls */ - if (listenSock != -1) { - shutdown(listenSock, SHUT_RDWR); - close(listenSock); + if (local_listenSock != -1) { + shutdown(local_listenSock, SHUT_RDWR); + close(local_listenSock); } - if (clientSock != -1) { - shutdown(clientSock, SHUT_RDWR); - close(clientSock); + if (local_clientSock != -1) { + shutdown(local_clientSock, SHUT_RDWR); + close(local_clientSock); } WakePipe(); diff --git a/runtime/jdwp/object_registry.cc b/runtime/jdwp/object_registry.cc index bf72c7b619..91239944fe 100644 --- a/runtime/jdwp/object_registry.cc +++ b/runtime/jdwp/object_registry.cc @@ -214,10 +214,10 @@ void ObjectRegistry::DisposeObject(JDWP::ObjectId id, uint32_t reference_count) // Erase the object from the maps. Note object may be null if it's // a weak ref and the GC has cleared it. int32_t hash_code = entry->identity_hash_code; - for (auto it = object_to_entry_.lower_bound(hash_code), end = object_to_entry_.end(); - it != end && it->first == hash_code; ++it) { - if (entry == it->second) { - object_to_entry_.erase(it); + for (auto inner_it = object_to_entry_.lower_bound(hash_code), end = object_to_entry_.end(); + inner_it != end && inner_it->first == hash_code; ++inner_it) { + if (entry == inner_it->second) { + object_to_entry_.erase(inner_it); break; } } diff --git a/runtime/jni_env_ext.cc b/runtime/jni_env_ext.cc index 180e3d7865..b2d3835405 100644 --- a/runtime/jni_env_ext.cc +++ b/runtime/jni_env_ext.cc @@ -28,9 +28,9 @@ static constexpr size_t kMonitorsMax = 4096; // Arbitrary sanity check. static constexpr size_t kLocalsInitial = 64; // Arbitrary. -JNIEnvExt::JNIEnvExt(Thread* self, JavaVMExt* vm) - : self(self), - vm(vm), +JNIEnvExt::JNIEnvExt(Thread* self_in, JavaVMExt* vm_in) + : self(self_in), + vm(vm_in), local_ref_cookie(IRT_FIRST_SEGMENT), locals(kLocalsInitial, kLocalsMax, kLocal), check_jni(false), diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index dd66af72f7..67e52cbef9 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -196,8 +196,8 @@ static jfieldID FindFieldID(const ScopedObjectAccess& soa, jclass jni_class, con // Failed to find type from the signature of the field. DCHECK(soa.Self()->IsExceptionPending()); ThrowLocation throw_location; - StackHandleScope<1> hs(soa.Self()); - Handle<mirror::Throwable> cause(hs.NewHandle(soa.Self()->GetException(&throw_location))); + StackHandleScope<1> hs2(soa.Self()); + Handle<mirror::Throwable> cause(hs2.NewHandle(soa.Self()->GetException(&throw_location))); soa.Self()->ClearException(); std::string temp; soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/NoSuchFieldError;", diff --git a/runtime/lock_word-inl.h b/runtime/lock_word-inl.h index cf6f83cb62..c52578f8a2 100644 --- a/runtime/lock_word-inl.h +++ b/runtime/lock_word-inl.h @@ -34,13 +34,13 @@ inline uint32_t LockWord::ThinLockCount() const { inline Monitor* LockWord::FatLockMonitor() const { DCHECK_EQ(GetState(), kFatLocked); - MonitorId mon_id = static_cast<MonitorId>(value_ & ~(kStateMask << kStateShift)); + MonitorId mon_id = value_ & ~(kStateMask << kStateShift); return MonitorPool::MonitorFromMonitorId(mon_id); } inline size_t LockWord::ForwardingAddress() const { DCHECK_EQ(GetState(), kForwardingAddress); - return static_cast<size_t>(value_ << kStateSize); + return value_ << kStateSize; } inline LockWord::LockWord() : value_(0) { diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc index 51aba9c374..8303f845a8 100644 --- a/runtime/mem_map.cc +++ b/runtime/mem_map.cc @@ -28,7 +28,12 @@ #endif #include "base/stringprintf.h" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" #include "ScopedFd.h" +#pragma GCC diagnostic pop + #include "thread-inl.h" #include "utils.h" diff --git a/runtime/mem_map.h b/runtime/mem_map.h index df1222c39d..9b003aa66c 100644 --- a/runtime/mem_map.h +++ b/runtime/mem_map.h @@ -175,6 +175,7 @@ class MemMap { friend class MemMapTest; // To allow access to base_begin_ and base_size_. }; std::ostream& operator<<(std::ostream& os, const MemMap& mem_map); +std::ostream& operator<<(std::ostream& os, const MemMap::Maps& mem_maps); } // namespace art diff --git a/runtime/memory_region.h b/runtime/memory_region.h index 4eb6d47537..b3820be26c 100644 --- a/runtime/memory_region.h +++ b/runtime/memory_region.h @@ -32,7 +32,7 @@ namespace art { class MemoryRegion FINAL : public ValueObject { public: MemoryRegion() : pointer_(nullptr), size_(0) {} - MemoryRegion(void* pointer, uintptr_t size) : pointer_(pointer), size_(size) {} + MemoryRegion(void* pointer_in, uintptr_t size_in) : pointer_(pointer_in), size_(size_in) {} void* pointer() const { return pointer_; } size_t size() const { return size_; } @@ -78,10 +78,10 @@ class MemoryRegion FINAL : public ValueObject { void CopyFrom(size_t offset, const MemoryRegion& from) const; // Compute a sub memory region based on an existing one. - MemoryRegion Subregion(uintptr_t offset, uintptr_t size) const { - CHECK_GE(this->size(), size); - CHECK_LE(offset, this->size() - size); - return MemoryRegion(reinterpret_cast<void*>(start() + offset), size); + MemoryRegion Subregion(uintptr_t offset, uintptr_t size_in) const { + CHECK_GE(this->size(), size_in); + CHECK_LE(offset, this->size() - size_in); + return MemoryRegion(reinterpret_cast<void*>(start() + offset), size_in); } // Compute an extended memory region based on an existing one. diff --git a/runtime/mirror/array.cc b/runtime/mirror/array.cc index 636be3346a..b92f01797a 100644 --- a/runtime/mirror/array.cc +++ b/runtime/mirror/array.cc @@ -58,8 +58,8 @@ static Array* RecursiveCreateMultiArray(Thread* self, if (current_dimension + 1 < dimensions->GetLength()) { // Create a new sub-array in every element of the array. for (int32_t i = 0; i < array_length; i++) { - StackHandleScope<1> hs(self); - Handle<mirror::Class> h_component_type(hs.NewHandle(array_class->GetComponentType())); + StackHandleScope<1> hs2(self); + Handle<mirror::Class> h_component_type(hs2.NewHandle(array_class->GetComponentType())); Array* sub_array = RecursiveCreateMultiArray(self, h_component_type, current_dimension + 1, dimensions); if (UNLIKELY(sub_array == nullptr)) { diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index 61bfe41ae6..566505911b 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -628,8 +628,8 @@ ArtField* Class::FindStaticField(Thread* self, Handle<Class> klass, const String HandleWrapper<mirror::Class> h_k(hs.NewHandleWrapper(&k)); // Is this field in any of this class' interfaces? for (uint32_t i = 0; i < h_k->NumDirectInterfaces(); ++i) { - StackHandleScope<1> hs(self); - Handle<mirror::Class> interface(hs.NewHandle(GetDirectInterface(self, h_k, i))); + StackHandleScope<1> hs2(self); + Handle<mirror::Class> interface(hs2.NewHandle(GetDirectInterface(self, h_k, i))); f = FindStaticField(self, interface, name, type); if (f != nullptr) { return f; @@ -652,8 +652,8 @@ ArtField* Class::FindStaticField(Thread* self, Handle<Class> klass, const DexCac HandleWrapper<mirror::Class> h_k(hs.NewHandleWrapper(&k)); // Is this field in any of this class' interfaces? for (uint32_t i = 0; i < h_k->NumDirectInterfaces(); ++i) { - StackHandleScope<1> hs(self); - Handle<mirror::Class> interface(hs.NewHandle(GetDirectInterface(self, h_k, i))); + StackHandleScope<1> hs2(self); + Handle<mirror::Class> interface(hs2.NewHandle(GetDirectInterface(self, h_k, i))); f = FindStaticField(self, interface, dex_cache, dex_field_idx); if (f != nullptr) { return f; @@ -680,8 +680,8 @@ ArtField* Class::FindField(Thread* self, Handle<Class> klass, const StringPiece& StackHandleScope<1> hs(self); HandleWrapper<mirror::Class> h_k(hs.NewHandleWrapper(&k)); for (uint32_t i = 0; i < h_k->NumDirectInterfaces(); ++i) { - StackHandleScope<1> hs(self); - Handle<mirror::Class> interface(hs.NewHandle(GetDirectInterface(self, h_k, i))); + StackHandleScope<1> hs2(self); + Handle<mirror::Class> interface(hs2.NewHandle(GetDirectInterface(self, h_k, i))); f = interface->FindStaticField(self, interface, name, type); if (f != nullptr) { return f; diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 5020ced396..0439428983 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -543,7 +543,7 @@ void Monitor::Notify(Thread* self) { thread->SetWaitNext(nullptr); // Check to see if the thread is still waiting. - MutexLock mu(self, *thread->GetWaitMutex()); + MutexLock wait_mu(self, *thread->GetWaitMutex()); if (thread->GetWaitMonitor() != nullptr) { thread->GetWaitConditionVariable()->Signal(self); return; @@ -992,12 +992,12 @@ void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::O for (size_t i = 0; i < monitor_enter_dex_pcs.size(); ++i) { // The verifier works in terms of the dex pcs of the monitor-enter instructions. // We want the registers used by those instructions (so we can read the values out of them). - uint32_t dex_pc = monitor_enter_dex_pcs[i]; - uint16_t monitor_enter_instruction = code_item->insns_[dex_pc]; + uint32_t monitor_dex_pc = monitor_enter_dex_pcs[i]; + uint16_t monitor_enter_instruction = code_item->insns_[monitor_dex_pc]; // Quick sanity check. if ((monitor_enter_instruction & 0xff) != Instruction::MONITOR_ENTER) { - LOG(FATAL) << "expected monitor-enter @" << dex_pc << "; was " + LOG(FATAL) << "expected monitor-enter @" << monitor_dex_pc << "; was " << reinterpret_cast<void*>(monitor_enter_instruction); } diff --git a/runtime/monitor_test.cc b/runtime/monitor_test.cc index 704e0410a5..adc7848ae0 100644 --- a/runtime/monitor_test.cc +++ b/runtime/monitor_test.cc @@ -341,8 +341,7 @@ static void CommonWaitSetup(MonitorTest* test, ClassLinker* class_linker, uint64 // Wake the watchdog. { - Thread* self = Thread::Current(); - ScopedObjectAccess soa(self); + ScopedObjectAccess soa(Thread::Current()); test->watchdog_object_.Get()->MonitorEnter(self); // Lock the object. test->watchdog_object_.Get()->NotifyAll(self); // Wake up waiting parties. diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc index 2d038cfc46..012e03e051 100644 --- a/runtime/native/dalvik_system_DexFile.cc +++ b/runtime/native/dalvik_system_DexFile.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "dalvik_system_DexFile.h" + #include <algorithm> #include <set> #include <fcntl.h> @@ -43,13 +45,17 @@ #include "profiler.h" #include "runtime.h" #include "scoped_thread_state_change.h" -#include "ScopedFd.h" #include "ScopedLocalRef.h" #include "ScopedUtfChars.h" #include "utils.h" #include "well_known_classes.h" #include "zip_archive.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#include "ScopedFd.h" +#pragma GCC diagnostic pop + namespace art { // A smart pointer that provides read-only access to a Java string's UTF chars. diff --git a/runtime/native/dalvik_system_DexFile.h b/runtime/native/dalvik_system_DexFile.h new file mode 100644 index 0000000000..487df05b34 --- /dev/null +++ b/runtime/native/dalvik_system_DexFile.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_DALVIK_SYSTEM_DEXFILE_H_ +#define ART_RUNTIME_NATIVE_DALVIK_SYSTEM_DEXFILE_H_ + +#include <jni.h> + +namespace art { + +void register_dalvik_system_DexFile(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_DALVIK_SYSTEM_DEXFILE_H_ diff --git a/runtime/native/dalvik_system_VMDebug.cc b/runtime/native/dalvik_system_VMDebug.cc index ceff2065ba..6c82eb22bd 100644 --- a/runtime/native/dalvik_system_VMDebug.cc +++ b/runtime/native/dalvik_system_VMDebug.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "dalvik_system_VMDebug.h" + #include <string.h> #include <unistd.h> diff --git a/runtime/native/dalvik_system_VMDebug.h b/runtime/native/dalvik_system_VMDebug.h new file mode 100644 index 0000000000..b7eb8a8379 --- /dev/null +++ b/runtime/native/dalvik_system_VMDebug.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_DALVIK_SYSTEM_VMDEBUG_H_ +#define ART_RUNTIME_NATIVE_DALVIK_SYSTEM_VMDEBUG_H_ + +#include <jni.h> + +namespace art { + +void register_dalvik_system_VMDebug(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_DALVIK_SYSTEM_VMDEBUG_H_ diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc index e1ceb8c864..fdba43ed8b 100644 --- a/runtime/native/dalvik_system_VMRuntime.cc +++ b/runtime/native/dalvik_system_VMRuntime.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "dalvik_system_VMRuntime.h" + #include <limits.h> #include "ScopedUtfChars.h" @@ -38,7 +40,11 @@ #include "scoped_thread_state_change.h" #include "thread.h" #include "thread_list.h" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" #include "toStringArray.h" +#pragma GCC diagnostic pop namespace art { @@ -386,26 +392,26 @@ static void PreloadDexCachesStatsFilled(DexCacheStats* filled) const DexFile* dex_file = boot_class_path[i]; CHECK(dex_file != NULL); mirror::DexCache* dex_cache = linker->FindDexCache(*dex_file); - for (size_t i = 0; i < dex_cache->NumStrings(); i++) { - mirror::String* string = dex_cache->GetResolvedString(i); + for (size_t j = 0; j < dex_cache->NumStrings(); j++) { + mirror::String* string = dex_cache->GetResolvedString(j); if (string != NULL) { filled->num_strings++; } } - for (size_t i = 0; i < dex_cache->NumResolvedTypes(); i++) { - mirror::Class* klass = dex_cache->GetResolvedType(i); + for (size_t j = 0; j < dex_cache->NumResolvedTypes(); j++) { + mirror::Class* klass = dex_cache->GetResolvedType(j); if (klass != NULL) { filled->num_types++; } } - for (size_t i = 0; i < dex_cache->NumResolvedFields(); i++) { - mirror::ArtField* field = dex_cache->GetResolvedField(i); + for (size_t j = 0; j < dex_cache->NumResolvedFields(); j++) { + mirror::ArtField* field = dex_cache->GetResolvedField(j); if (field != NULL) { filled->num_fields++; } } - for (size_t i = 0; i < dex_cache->NumResolvedMethods(); i++) { - mirror::ArtMethod* method = dex_cache->GetResolvedMethod(i); + for (size_t j = 0; j < dex_cache->NumResolvedMethods(); j++) { + mirror::ArtMethod* method = dex_cache->GetResolvedMethod(j); if (method != NULL) { filled->num_methods++; } @@ -450,14 +456,14 @@ static void VMRuntime_preloadDexCaches(JNIEnv* env, jobject) { Handle<mirror::DexCache> dex_cache(hs.NewHandle(linker->FindDexCache(*dex_file))); if (kPreloadDexCachesStrings) { - for (size_t i = 0; i < dex_cache->NumStrings(); i++) { - PreloadDexCachesResolveString(dex_cache, i, strings); + for (size_t j = 0; j < dex_cache->NumStrings(); j++) { + PreloadDexCachesResolveString(dex_cache, j, strings); } } if (kPreloadDexCachesTypes) { - for (size_t i = 0; i < dex_cache->NumResolvedTypes(); i++) { - PreloadDexCachesResolveType(soa.Self(), dex_cache.Get(), i); + for (size_t j = 0; j < dex_cache->NumResolvedTypes(); j++) { + PreloadDexCachesResolveType(soa.Self(), dex_cache.Get(), j); } } diff --git a/runtime/native/dalvik_system_VMRuntime.h b/runtime/native/dalvik_system_VMRuntime.h new file mode 100644 index 0000000000..795caa5ec6 --- /dev/null +++ b/runtime/native/dalvik_system_VMRuntime.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_DALVIK_SYSTEM_VMRUNTIME_H_ +#define ART_RUNTIME_NATIVE_DALVIK_SYSTEM_VMRUNTIME_H_ + +#include <jni.h> + +namespace art { + +void register_dalvik_system_VMRuntime(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_DALVIK_SYSTEM_VMRUNTIME_H_ diff --git a/runtime/native/dalvik_system_VMStack.cc b/runtime/native/dalvik_system_VMStack.cc index eef1c46c1f..e396dad5c3 100644 --- a/runtime/native/dalvik_system_VMStack.cc +++ b/runtime/native/dalvik_system_VMStack.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "dalvik_system_VMStack.h" + #include "jni_internal.h" #include "nth_caller_visitor.h" #include "mirror/art_method-inl.h" @@ -87,8 +89,10 @@ static jobject VMStack_getCallingClassLoader(JNIEnv* env, jclass) { static jobject VMStack_getClosestUserClassLoader(JNIEnv* env, jclass, jobject javaBootstrap, jobject javaSystem) { struct ClosestUserClassLoaderVisitor : public StackVisitor { - ClosestUserClassLoaderVisitor(Thread* thread, mirror::Object* bootstrap, mirror::Object* system) - : StackVisitor(thread, NULL), bootstrap(bootstrap), system(system), class_loader(NULL) {} + ClosestUserClassLoaderVisitor(Thread* thread, mirror::Object* bootstrap_in, + mirror::Object* system_in) + : StackVisitor(thread, NULL), bootstrap(bootstrap_in), system(system_in), + class_loader(NULL) {} bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(class_loader == NULL); diff --git a/runtime/native/dalvik_system_VMStack.h b/runtime/native/dalvik_system_VMStack.h new file mode 100644 index 0000000000..5638f99ec1 --- /dev/null +++ b/runtime/native/dalvik_system_VMStack.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_DALVIK_SYSTEM_VMSTACK_H_ +#define ART_RUNTIME_NATIVE_DALVIK_SYSTEM_VMSTACK_H_ + +#include <jni.h> + +namespace art { + +void register_dalvik_system_VMStack(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_DALVIK_SYSTEM_VMSTACK_H_ diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc index adc7c4f410..09669543a8 100644 --- a/runtime/native/dalvik_system_ZygoteHooks.cc +++ b/runtime/native/dalvik_system_ZygoteHooks.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "dalvik_system_ZygoteHooks.h" + #include <stdlib.h> #include "debugger.h" diff --git a/runtime/native/dalvik_system_ZygoteHooks.h b/runtime/native/dalvik_system_ZygoteHooks.h new file mode 100644 index 0000000000..ca0658d318 --- /dev/null +++ b/runtime/native/dalvik_system_ZygoteHooks.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_DALVIK_SYSTEM_ZYGOTEHOOKS_H_ +#define ART_RUNTIME_NATIVE_DALVIK_SYSTEM_ZYGOTEHOOKS_H_ + +#include <jni.h> + +namespace art { + +void register_dalvik_system_ZygoteHooks(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_DALVIK_SYSTEM_ZYGOTEHOOKS_H_ diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index b11cbdfb92..1ea75f386f 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_Class.h" + #include "class_linker.h" #include "dex_file-inl.h" #include "jni_internal.h" diff --git a/runtime/native/java_lang_Class.h b/runtime/native/java_lang_Class.h new file mode 100644 index 0000000000..8f769c39e9 --- /dev/null +++ b/runtime/native/java_lang_Class.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_CLASS_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_CLASS_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_Class(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_CLASS_H_ diff --git a/runtime/native/java_lang_DexCache.cc b/runtime/native/java_lang_DexCache.cc index c1c6c26047..27eae46236 100644 --- a/runtime/native/java_lang_DexCache.cc +++ b/runtime/native/java_lang_DexCache.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_DexCache.h" + #include "dex_file.h" #include "jni_internal.h" #include "mirror/dex_cache.h" diff --git a/runtime/native/java_lang_DexCache.h b/runtime/native/java_lang_DexCache.h new file mode 100644 index 0000000000..b1c1f5e72c --- /dev/null +++ b/runtime/native/java_lang_DexCache.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_DEXCACHE_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_DEXCACHE_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_DexCache(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_DEXCACHE_H_ diff --git a/runtime/native/java_lang_Object.cc b/runtime/native/java_lang_Object.cc index 4768f48d9c..49cacdf156 100644 --- a/runtime/native/java_lang_Object.cc +++ b/runtime/native/java_lang_Object.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_Object.h" + #include "jni_internal.h" #include "mirror/object-inl.h" #include "scoped_fast_native_object_access.h" diff --git a/runtime/native/java_lang_Object.h b/runtime/native/java_lang_Object.h new file mode 100644 index 0000000000..c860571904 --- /dev/null +++ b/runtime/native/java_lang_Object.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_OBJECT_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_OBJECT_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_Object(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_OBJECT_H_ diff --git a/runtime/native/java_lang_Runtime.cc b/runtime/native/java_lang_Runtime.cc index f9a1cee2d8..dc0cb7bad6 100644 --- a/runtime/native/java_lang_Runtime.cc +++ b/runtime/native/java_lang_Runtime.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_Runtime.h" + #include <dlfcn.h> #include <limits.h> #include <unistd.h> diff --git a/runtime/native/java_lang_Runtime.h b/runtime/native/java_lang_Runtime.h new file mode 100644 index 0000000000..ceda06bde9 --- /dev/null +++ b/runtime/native/java_lang_Runtime.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_RUNTIME_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_RUNTIME_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_Runtime(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_RUNTIME_H_ diff --git a/runtime/native/java_lang_String.cc b/runtime/native/java_lang_String.cc index d6b47ebc87..4ea2546e30 100644 --- a/runtime/native/java_lang_String.cc +++ b/runtime/native/java_lang_String.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_String.h" + #include "common_throws.h" #include "jni_internal.h" #include "mirror/string-inl.h" diff --git a/runtime/native/java_lang_String.h b/runtime/native/java_lang_String.h new file mode 100644 index 0000000000..357eb3daf9 --- /dev/null +++ b/runtime/native/java_lang_String.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_STRING_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_STRING_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_String(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_STRING_H_ diff --git a/runtime/native/java_lang_System.cc b/runtime/native/java_lang_System.cc index 43681a70fd..f79be56aeb 100644 --- a/runtime/native/java_lang_System.cc +++ b/runtime/native/java_lang_System.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_System.h" + #include "common_throws.h" #include "gc/accounting/card_table-inl.h" #include "jni_internal.h" diff --git a/runtime/native/java_lang_System.h b/runtime/native/java_lang_System.h new file mode 100644 index 0000000000..e371fa5db4 --- /dev/null +++ b/runtime/native/java_lang_System.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_SYSTEM_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_SYSTEM_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_System(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_SYSTEM_H_ diff --git a/runtime/native/java_lang_Thread.cc b/runtime/native/java_lang_Thread.cc index c0c72651de..0722a2485d 100644 --- a/runtime/native/java_lang_Thread.cc +++ b/runtime/native/java_lang_Thread.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_Thread.h" + #include "common_throws.h" #include "debugger.h" #include "jni_internal.h" diff --git a/runtime/native/java_lang_Thread.h b/runtime/native/java_lang_Thread.h new file mode 100644 index 0000000000..7700ce29a8 --- /dev/null +++ b/runtime/native/java_lang_Thread.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_THREAD_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_THREAD_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_Thread(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_THREAD_H_ diff --git a/runtime/native/java_lang_Throwable.cc b/runtime/native/java_lang_Throwable.cc index 3ed4cfe100..cb8a86918f 100644 --- a/runtime/native/java_lang_Throwable.cc +++ b/runtime/native/java_lang_Throwable.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_Throwable.h" + #include "jni_internal.h" #include "scoped_fast_native_object_access.h" #include "thread.h" diff --git a/runtime/native/java_lang_Throwable.h b/runtime/native/java_lang_Throwable.h new file mode 100644 index 0000000000..f9aea84abe --- /dev/null +++ b/runtime/native/java_lang_Throwable.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_THROWABLE_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_THROWABLE_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_Throwable(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_THROWABLE_H_ diff --git a/runtime/native/java_lang_VMClassLoader.cc b/runtime/native/java_lang_VMClassLoader.cc index f6a46bde88..45563d299c 100644 --- a/runtime/native/java_lang_VMClassLoader.cc +++ b/runtime/native/java_lang_VMClassLoader.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_VMClassLoader.h" + #include "class_linker.h" #include "jni_internal.h" #include "mirror/class_loader.h" diff --git a/runtime/native/java_lang_VMClassLoader.h b/runtime/native/java_lang_VMClassLoader.h new file mode 100644 index 0000000000..bf8d94f5a9 --- /dev/null +++ b/runtime/native/java_lang_VMClassLoader.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_VMCLASSLOADER_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_VMCLASSLOADER_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_VMClassLoader(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_VMCLASSLOADER_H_ diff --git a/runtime/native/java_lang_ref_FinalizerReference.cc b/runtime/native/java_lang_ref_FinalizerReference.cc index ad48ec0a11..0532c359a0 100644 --- a/runtime/native/java_lang_ref_FinalizerReference.cc +++ b/runtime/native/java_lang_ref_FinalizerReference.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_ref_FinalizerReference.h" + #include "gc/heap.h" #include "gc/reference_processor.h" #include "jni_internal.h" diff --git a/runtime/native/java_lang_ref_FinalizerReference.h b/runtime/native/java_lang_ref_FinalizerReference.h new file mode 100644 index 0000000000..848a7aded6 --- /dev/null +++ b/runtime/native/java_lang_ref_FinalizerReference.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REF_FINALIZERREFERENCE_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_REF_FINALIZERREFERENCE_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_ref_FinalizerReference(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REF_FINALIZERREFERENCE_H_ diff --git a/runtime/native/java_lang_ref_Reference.cc b/runtime/native/java_lang_ref_Reference.cc index 4f04d60232..d2320591b1 100644 --- a/runtime/native/java_lang_ref_Reference.cc +++ b/runtime/native/java_lang_ref_Reference.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_ref_Reference.h" + #include "gc/heap.h" #include "gc/reference_processor.h" #include "jni_internal.h" diff --git a/runtime/native/java_lang_ref_Reference.h b/runtime/native/java_lang_ref_Reference.h new file mode 100644 index 0000000000..0cbf11646d --- /dev/null +++ b/runtime/native/java_lang_ref_Reference.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REF_REFERENCE_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_REF_REFERENCE_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_ref_Reference(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REF_REFERENCE_H_ diff --git a/runtime/native/java_lang_reflect_Array.cc b/runtime/native/java_lang_reflect_Array.cc index 763a6645b9..1ffcbdfd5e 100644 --- a/runtime/native/java_lang_reflect_Array.cc +++ b/runtime/native/java_lang_reflect_Array.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_reflect_Array.h" + #include "class_linker-inl.h" #include "common_throws.h" #include "dex_file-inl.h" diff --git a/runtime/native/java_lang_reflect_Array.h b/runtime/native/java_lang_reflect_Array.h new file mode 100644 index 0000000000..805bf7992a --- /dev/null +++ b/runtime/native/java_lang_reflect_Array.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_ARRAY_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_ARRAY_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_reflect_Array(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_ARRAY_H_ diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc index 0542aeb98a..3121a90d09 100644 --- a/runtime/native/java_lang_reflect_Constructor.cc +++ b/runtime/native/java_lang_reflect_Constructor.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_reflect_Constructor.h" + #include "class_linker.h" #include "jni_internal.h" #include "mirror/art_method.h" diff --git a/runtime/native/java_lang_reflect_Constructor.h b/runtime/native/java_lang_reflect_Constructor.h new file mode 100644 index 0000000000..7baae978e6 --- /dev/null +++ b/runtime/native/java_lang_reflect_Constructor.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_CONSTRUCTOR_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_CONSTRUCTOR_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_reflect_Constructor(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_CONSTRUCTOR_H_ diff --git a/runtime/native/java_lang_reflect_Field.cc b/runtime/native/java_lang_reflect_Field.cc index 1f07336779..a0426205c2 100644 --- a/runtime/native/java_lang_reflect_Field.cc +++ b/runtime/native/java_lang_reflect_Field.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_reflect_Field.h" + #include "class_linker.h" #include "class_linker-inl.h" #include "common_throws.h" diff --git a/runtime/native/java_lang_reflect_Field.h b/runtime/native/java_lang_reflect_Field.h new file mode 100644 index 0000000000..1739711de8 --- /dev/null +++ b/runtime/native/java_lang_reflect_Field.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_FIELD_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_FIELD_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_reflect_Field(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_FIELD_H_ diff --git a/runtime/native/java_lang_reflect_Method.cc b/runtime/native/java_lang_reflect_Method.cc index f029b16746..9859746563 100644 --- a/runtime/native/java_lang_reflect_Method.cc +++ b/runtime/native/java_lang_reflect_Method.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_reflect_Method.h" + #include "class_linker.h" #include "jni_internal.h" #include "mirror/art_method.h" diff --git a/runtime/native/java_lang_reflect_Method.h b/runtime/native/java_lang_reflect_Method.h new file mode 100644 index 0000000000..3a93cd05d9 --- /dev/null +++ b/runtime/native/java_lang_reflect_Method.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_METHOD_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_METHOD_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_reflect_Method(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_METHOD_H_ diff --git a/runtime/native/java_lang_reflect_Proxy.cc b/runtime/native/java_lang_reflect_Proxy.cc index 07d670d51a..baf8b24207 100644 --- a/runtime/native/java_lang_reflect_Proxy.cc +++ b/runtime/native/java_lang_reflect_Proxy.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_lang_reflect_Proxy.h" + #include "class_linker.h" #include "jni_internal.h" #include "mirror/class_loader.h" diff --git a/runtime/native/java_lang_reflect_Proxy.h b/runtime/native/java_lang_reflect_Proxy.h new file mode 100644 index 0000000000..e25f0f76b6 --- /dev/null +++ b/runtime/native/java_lang_reflect_Proxy.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_PROXY_H_ +#define ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_PROXY_H_ + +#include <jni.h> + +namespace art { + +void register_java_lang_reflect_Proxy(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_PROXY_H_ diff --git a/runtime/native/java_util_concurrent_atomic_AtomicLong.cc b/runtime/native/java_util_concurrent_atomic_AtomicLong.cc index bf92e1230d..04f0ba0c19 100644 --- a/runtime/native/java_util_concurrent_atomic_AtomicLong.cc +++ b/runtime/native/java_util_concurrent_atomic_AtomicLong.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "java_util_concurrent_atomic_AtomicLong.h" + #include "atomic.h" #include "jni_internal.h" diff --git a/runtime/native/java_util_concurrent_atomic_AtomicLong.h b/runtime/native/java_util_concurrent_atomic_AtomicLong.h new file mode 100644 index 0000000000..990dc861ff --- /dev/null +++ b/runtime/native/java_util_concurrent_atomic_AtomicLong.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_H_ +#define ART_RUNTIME_NATIVE_JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_H_ + +#include <jni.h> + +namespace art { + +void register_java_util_concurrent_atomic_AtomicLong(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_H_ diff --git a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmServer.cc b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmServer.cc index 8b2aecbbb1..0ab29799a0 100644 --- a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmServer.cc +++ b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmServer.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "org_apache_harmony_dalvik_ddmc_DdmServer.h" + #include "base/logging.h" #include "debugger.h" #include "jni_internal.h" diff --git a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmServer.h b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmServer.h new file mode 100644 index 0000000000..9a4645c1aa --- /dev/null +++ b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmServer.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_ORG_APACHE_HARMONY_DALVIK_DDMC_DDMSERVER_H_ +#define ART_RUNTIME_NATIVE_ORG_APACHE_HARMONY_DALVIK_DDMC_DDMSERVER_H_ + +#include <jni.h> + +namespace art { + +void register_org_apache_harmony_dalvik_ddmc_DdmServer(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_ORG_APACHE_HARMONY_DALVIK_DDMC_DDMSERVER_H_ diff --git a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc index 45ef9ae727..b74430f237 100644 --- a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc +++ b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "org_apache_harmony_dalvik_ddmc_DdmVmInternal.h" + #include "base/logging.h" #include "base/mutex.h" #include "debugger.h" diff --git a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.h b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.h new file mode 100644 index 0000000000..736e4c8793 --- /dev/null +++ b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_ORG_APACHE_HARMONY_DALVIK_DDMC_DDMVMINTERNAL_H_ +#define ART_RUNTIME_NATIVE_ORG_APACHE_HARMONY_DALVIK_DDMC_DDMVMINTERNAL_H_ + +#include <jni.h> + +namespace art { + +void register_org_apache_harmony_dalvik_ddmc_DdmVmInternal(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_ORG_APACHE_HARMONY_DALVIK_DDMC_DDMVMINTERNAL_H_ diff --git a/runtime/native/sun_misc_Unsafe.cc b/runtime/native/sun_misc_Unsafe.cc index 65dece04e6..17ebdff996 100644 --- a/runtime/native/sun_misc_Unsafe.cc +++ b/runtime/native/sun_misc_Unsafe.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "sun_misc_Unsafe.h" + #include "gc/accounting/card_table-inl.h" #include "jni_internal.h" #include "mirror/array.h" diff --git a/runtime/native/sun_misc_Unsafe.h b/runtime/native/sun_misc_Unsafe.h new file mode 100644 index 0000000000..93194f4fad --- /dev/null +++ b/runtime/native/sun_misc_Unsafe.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_NATIVE_SUN_MISC_UNSAFE_H_ +#define ART_RUNTIME_NATIVE_SUN_MISC_UNSAFE_H_ + +#include <jni.h> + +namespace art { + +void register_sun_misc_Unsafe(JNIEnv* env); + +} // namespace art + +#endif // ART_RUNTIME_NATIVE_SUN_MISC_UNSAFE_H_ diff --git a/runtime/native_bridge_art_interface.cc b/runtime/native_bridge_art_interface.cc index f598e27d7b..59922b8c07 100644 --- a/runtime/native_bridge_art_interface.cc +++ b/runtime/native_bridge_art_interface.cc @@ -25,7 +25,7 @@ namespace art { -const char* GetMethodShorty(JNIEnv* env, jmethodID mid) { +static const char* GetMethodShorty(JNIEnv* env, jmethodID mid) { ScopedObjectAccess soa(env); StackHandleScope<1> scope(soa.Self()); mirror::ArtMethod* m = soa.DecodeMethod(mid); @@ -33,7 +33,7 @@ const char* GetMethodShorty(JNIEnv* env, jmethodID mid) { return mh.GetShorty(); } -uint32_t GetNativeMethodCount(JNIEnv* env, jclass clazz) { +static uint32_t GetNativeMethodCount(JNIEnv* env, jclass clazz) { if (clazz == nullptr) return 0; @@ -56,8 +56,8 @@ uint32_t GetNativeMethodCount(JNIEnv* env, jclass clazz) { return native_method_count; } -uint32_t GetNativeMethods(JNIEnv* env, jclass clazz, JNINativeMethod* methods, - uint32_t method_count) { +static uint32_t GetNativeMethods(JNIEnv* env, jclass clazz, JNINativeMethod* methods, + uint32_t method_count) { if ((clazz == nullptr) || (methods == nullptr)) { return 0; } @@ -121,6 +121,8 @@ void PreInitializeNativeBridge(std::string dir) { LOG(WARNING) << "Could not create mount namespace."; } android::PreInitializeNativeBridge(dir.c_str(), GetInstructionSetString(kRuntimeISA)); +#else + UNUSED(dir); #endif } diff --git a/runtime/nth_caller_visitor.h b/runtime/nth_caller_visitor.h index 374a80ea28..a851f21e29 100644 --- a/runtime/nth_caller_visitor.h +++ b/runtime/nth_caller_visitor.h @@ -26,9 +26,9 @@ class Thread; // Walks up the stack 'n' callers, when used with Thread::WalkStack. struct NthCallerVisitor : public StackVisitor { - NthCallerVisitor(Thread* thread, size_t n, bool include_runtime_and_upcalls = false) - : StackVisitor(thread, NULL), n(n), include_runtime_and_upcalls_(include_runtime_and_upcalls), - count(0), caller(NULL) {} + NthCallerVisitor(Thread* thread, size_t n_in, bool include_runtime_and_upcalls = false) + : StackVisitor(thread, NULL), n(n_in), + include_runtime_and_upcalls_(include_runtime_and_upcalls), count(0), caller(NULL) {} bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { mirror::ArtMethod* m = GetMethod(); diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc index e3bd541f27..1a97c357fa 100644 --- a/runtime/parsed_options.cc +++ b/runtime/parsed_options.cc @@ -504,35 +504,35 @@ bool ParsedOptions::Parse(const RuntimeOptions& options, bool ignore_unrecognize } else if (StartsWith(option, "-verbose:")) { std::vector<std::string> verbose_options; Split(option.substr(strlen("-verbose:")), ',', &verbose_options); - for (size_t i = 0; i < verbose_options.size(); ++i) { - if (verbose_options[i] == "class") { + for (size_t j = 0; j < verbose_options.size(); ++j) { + if (verbose_options[j] == "class") { gLogVerbosity.class_linker = true; - } else if (verbose_options[i] == "compiler") { + } else if (verbose_options[j] == "compiler") { gLogVerbosity.compiler = true; - } else if (verbose_options[i] == "gc") { + } else if (verbose_options[j] == "gc") { gLogVerbosity.gc = true; - } else if (verbose_options[i] == "heap") { + } else if (verbose_options[j] == "heap") { gLogVerbosity.heap = true; - } else if (verbose_options[i] == "jdwp") { + } else if (verbose_options[j] == "jdwp") { gLogVerbosity.jdwp = true; - } else if (verbose_options[i] == "jni") { + } else if (verbose_options[j] == "jni") { gLogVerbosity.jni = true; - } else if (verbose_options[i] == "monitor") { + } else if (verbose_options[j] == "monitor") { gLogVerbosity.monitor = true; - } else if (verbose_options[i] == "profiler") { + } else if (verbose_options[j] == "profiler") { gLogVerbosity.profiler = true; - } else if (verbose_options[i] == "signals") { + } else if (verbose_options[j] == "signals") { gLogVerbosity.signals = true; - } else if (verbose_options[i] == "startup") { + } else if (verbose_options[j] == "startup") { gLogVerbosity.startup = true; - } else if (verbose_options[i] == "third-party-jni") { + } else if (verbose_options[j] == "third-party-jni") { gLogVerbosity.third_party_jni = true; - } else if (verbose_options[i] == "threads") { + } else if (verbose_options[j] == "threads") { gLogVerbosity.threads = true; - } else if (verbose_options[i] == "verifier") { + } else if (verbose_options[j] == "verifier") { gLogVerbosity.verifier = true; } else { - Usage("Unknown -verbose option %s\n", verbose_options[i].c_str()); + Usage("Unknown -verbose option %s\n", verbose_options[j].c_str()); return false; } } diff --git a/runtime/reflection_test.cc b/runtime/reflection_test.cc index f8e0f47130..eca1800c16 100644 --- a/runtime/reflection_test.cc +++ b/runtime/reflection_test.cc @@ -115,8 +115,8 @@ class ReflectionTest : public CommonCompilerTest { *receiver = nullptr; } else { // Ensure class is initialized before allocating object - StackHandleScope<1> hs(self); - Handle<mirror::Class> h_class(hs.NewHandle(c)); + StackHandleScope<1> hs2(self); + Handle<mirror::Class> h_class(hs2.NewHandle(c)); bool initialized = class_linker_->EnsureInitialized(self, h_class, true, true); CHECK(initialized); *receiver = c->AllocObject(self); diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 4ac9634158..1cda29bcd2 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -69,6 +69,31 @@ #include "mirror/throwable.h" #include "monitor.h" #include "native_bridge_art_interface.h" +#include "native/dalvik_system_DexFile.h" +#include "native/dalvik_system_VMDebug.h" +#include "native/dalvik_system_VMRuntime.h" +#include "native/dalvik_system_VMStack.h" +#include "native/dalvik_system_ZygoteHooks.h" +#include "native/java_lang_Class.h" +#include "native/java_lang_DexCache.h" +#include "native/java_lang_Object.h" +#include "native/java_lang_ref_FinalizerReference.h" +#include "native/java_lang_reflect_Array.h" +#include "native/java_lang_reflect_Constructor.h" +#include "native/java_lang_reflect_Field.h" +#include "native/java_lang_reflect_Method.h" +#include "native/java_lang_reflect_Proxy.h" +#include "native/java_lang_ref_Reference.h" +#include "native/java_lang_Runtime.h" +#include "native/java_lang_String.h" +#include "native/java_lang_System.h" +#include "native/java_lang_Thread.h" +#include "native/java_lang_Throwable.h" +#include "native/java_lang_VMClassLoader.h" +#include "native/java_util_concurrent_atomic_AtomicLong.h" +#include "native/org_apache_harmony_dalvik_ddmc_DdmServer.h" +#include "native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.h" +#include "native/sun_misc_Unsafe.h" #include "parsed_options.h" #include "oat_file.h" #include "os.h" @@ -344,7 +369,7 @@ bool Runtime::Create(const RuntimeOptions& options, bool ignore_unrecognized) { return true; } -jobject CreateSystemClassLoader() { +static jobject CreateSystemClassLoader() { if (Runtime::Current()->UseCompileTimeClassPath()) { return NULL; } @@ -388,9 +413,9 @@ std::string Runtime::GetPatchoatExecutable() const { if (!patchoat_executable_.empty()) { return patchoat_executable_; } - std::string patchoat_executable_(GetAndroidRoot()); - patchoat_executable_ += (kIsDebugBuild ? "/bin/patchoatd" : "/bin/patchoat"); - return patchoat_executable_; + std::string patchoat_executable(GetAndroidRoot()); + patchoat_executable += (kIsDebugBuild ? "/bin/patchoatd" : "/bin/patchoat"); + return patchoat_executable; } std::string Runtime::GetCompilerExecutable() const { @@ -969,34 +994,31 @@ jobject Runtime::GetSystemClassLoader() const { } void Runtime::RegisterRuntimeNativeMethods(JNIEnv* env) { -#define REGISTER(FN) extern void FN(JNIEnv*); FN(env) - // Register Throwable first so that registration of other native methods can throw exceptions - REGISTER(register_java_lang_Throwable); - REGISTER(register_dalvik_system_DexFile); - REGISTER(register_dalvik_system_VMDebug); - REGISTER(register_dalvik_system_VMRuntime); - REGISTER(register_dalvik_system_VMStack); - REGISTER(register_dalvik_system_ZygoteHooks); - REGISTER(register_java_lang_Class); - REGISTER(register_java_lang_DexCache); - REGISTER(register_java_lang_Object); - REGISTER(register_java_lang_Runtime); - REGISTER(register_java_lang_String); - REGISTER(register_java_lang_System); - REGISTER(register_java_lang_Thread); - REGISTER(register_java_lang_VMClassLoader); - REGISTER(register_java_lang_ref_FinalizerReference); - REGISTER(register_java_lang_ref_Reference); - REGISTER(register_java_lang_reflect_Array); - REGISTER(register_java_lang_reflect_Constructor); - REGISTER(register_java_lang_reflect_Field); - REGISTER(register_java_lang_reflect_Method); - REGISTER(register_java_lang_reflect_Proxy); - REGISTER(register_java_util_concurrent_atomic_AtomicLong); - REGISTER(register_org_apache_harmony_dalvik_ddmc_DdmServer); - REGISTER(register_org_apache_harmony_dalvik_ddmc_DdmVmInternal); - REGISTER(register_sun_misc_Unsafe); -#undef REGISTER + register_dalvik_system_DexFile(env); + register_dalvik_system_VMDebug(env); + register_dalvik_system_VMRuntime(env); + register_dalvik_system_VMStack(env); + register_dalvik_system_ZygoteHooks(env); + register_java_lang_Class(env); + register_java_lang_DexCache(env); + register_java_lang_Object(env); + register_java_lang_ref_FinalizerReference(env); + register_java_lang_reflect_Array(env); + register_java_lang_reflect_Constructor(env); + register_java_lang_reflect_Field(env); + register_java_lang_reflect_Method(env); + register_java_lang_reflect_Proxy(env); + register_java_lang_ref_Reference(env); + register_java_lang_Runtime(env); + register_java_lang_String(env); + register_java_lang_System(env); + register_java_lang_Thread(env); + register_java_lang_Throwable(env); + register_java_lang_VMClassLoader(env); + register_java_util_concurrent_atomic_AtomicLong(env); + register_org_apache_harmony_dalvik_ddmc_DdmServer(env); + register_org_apache_harmony_dalvik_ddmc_DdmVmInternal(env); + register_sun_misc_Unsafe(env); } void Runtime::DumpForSigQuit(std::ostream& os) { diff --git a/runtime/stack.cc b/runtime/stack.cc index 0adf0313ff..44086096f0 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -409,8 +409,8 @@ void StackVisitor::SetReturnPc(uintptr_t new_ret_pc) { size_t StackVisitor::ComputeNumFrames(Thread* thread) { struct NumFramesVisitor : public StackVisitor { - explicit NumFramesVisitor(Thread* thread) - : StackVisitor(thread, NULL), frames(0) {} + explicit NumFramesVisitor(Thread* thread_in) + : StackVisitor(thread_in, NULL), frames(0) {} bool VisitFrame() OVERRIDE { frames++; @@ -461,8 +461,8 @@ bool StackVisitor::GetNextMethodAndDexPc(mirror::ArtMethod** next_method, uint32 void StackVisitor::DescribeStack(Thread* thread) { struct DescribeStackVisitor : public StackVisitor { - explicit DescribeStackVisitor(Thread* thread) - : StackVisitor(thread, NULL) {} + explicit DescribeStackVisitor(Thread* thread_in) + : StackVisitor(thread_in, NULL) {} bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { LOG(INFO) << "Frame Id=" << GetFrameId() << " " << DescribeLocation(); diff --git a/runtime/thread.cc b/runtime/thread.cc index da82c766f0..7d24562389 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -837,10 +837,11 @@ void Thread::DumpState(std::ostream& os) const { } struct StackDumpVisitor : public StackVisitor { - StackDumpVisitor(std::ostream& os, Thread* thread, Context* context, bool can_allocate) + StackDumpVisitor(std::ostream& os_in, Thread* thread_in, Context* context, bool can_allocate_in) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) - : StackVisitor(thread, context), os(os), thread(thread), can_allocate(can_allocate), - last_method(nullptr), last_line_number(0), repetition_count(0), frame_count(0) { + : StackVisitor(thread_in, context), os(os_in), thread(thread_in), + can_allocate(can_allocate_in), last_method(nullptr), last_line_number(0), + repetition_count(0), frame_count(0) { } virtual ~StackDumpVisitor() { @@ -2151,7 +2152,6 @@ class ReferenceMapVisitor : public StackVisitor { const VmapTable vmap_table(m->GetVmapTable(code_pointer)); QuickMethodFrameInfo frame_info = m->GetQuickFrameInfo(code_pointer); // For all dex registers in the bitmap - StackReference<mirror::ArtMethod>* cur_quick_frame = GetCurrentQuickFrame(); DCHECK(cur_quick_frame != nullptr); for (size_t reg = 0; reg < num_regs; ++reg) { // Does this register hold a reference? diff --git a/runtime/thread.h b/runtime/thread.h index c243413fed..89aee04e5d 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -1193,7 +1193,6 @@ class ScopedAssertNoThreadSuspension { }; std::ostream& operator<<(std::ostream& os, const Thread& thread); -std::ostream& operator<<(std::ostream& os, const ThreadState& state); } // namespace art diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc index e3ef4eb26e..2181e29259 100644 --- a/runtime/thread_list.cc +++ b/runtime/thread_list.cc @@ -515,7 +515,7 @@ Thread* ThreadList::SuspendThreadByPeer(jobject peer, bool request_suspension, // than request thread suspension, to avoid potential cycles in threads requesting each other // suspend. ScopedObjectAccess soa(self); - MutexLock mu(self, *Locks::thread_list_lock_); + MutexLock thread_list_mu(self, *Locks::thread_list_lock_); thread = Thread::FromManagedThread(soa, peer); if (thread == nullptr) { ThreadSuspendByPeerWarning(self, WARNING, "No such thread for suspend", peer); @@ -528,7 +528,7 @@ Thread* ThreadList::SuspendThreadByPeer(jobject peer, bool request_suspension, } VLOG(threads) << "SuspendThreadByPeer found thread: " << *thread; { - MutexLock mu(self, *Locks::thread_suspend_count_lock_); + MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); if (request_suspension) { thread->ModifySuspendCount(self, +1, debug_suspension); request_suspension = false; @@ -588,7 +588,7 @@ Thread* ThreadList::SuspendThreadByThreadId(uint32_t thread_id, bool debug_suspe // than request thread suspension, to avoid potential cycles in threads requesting each other // suspend. ScopedObjectAccess soa(self); - MutexLock mu(self, *Locks::thread_list_lock_); + MutexLock thread_list_mu(self, *Locks::thread_list_lock_); Thread* thread = nullptr; for (const auto& it : list_) { if (it->GetThreadId() == thread_id) { @@ -606,7 +606,7 @@ Thread* ThreadList::SuspendThreadByThreadId(uint32_t thread_id, bool debug_suspe VLOG(threads) << "SuspendThreadByThreadId found thread: " << *thread; DCHECK(Contains(thread)); { - MutexLock mu(self, *Locks::thread_suspend_count_lock_); + MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); if (suspended_thread == nullptr) { thread->ModifySuspendCount(self, +1, debug_suspension); suspended_thread = thread; @@ -662,9 +662,9 @@ void ThreadList::SuspendAllForDebugger() { VLOG(threads) << *self << " SuspendAllForDebugger starting..."; { - MutexLock mu(self, *Locks::thread_list_lock_); + MutexLock thread_list_mu(self, *Locks::thread_list_lock_); { - MutexLock mu(self, *Locks::thread_suspend_count_lock_); + MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); // Update global suspend all state for attaching threads. DCHECK_GE(suspend_all_count_, debug_suspend_all_count_); ++suspend_all_count_; @@ -769,9 +769,9 @@ void ThreadList::ResumeAllForDebugger() { Locks::mutator_lock_->AssertNotExclusiveHeld(self); { - MutexLock mu(self, *Locks::thread_list_lock_); + MutexLock thread_list_mu(self, *Locks::thread_list_lock_); { - MutexLock mu(self, *Locks::thread_suspend_count_lock_); + MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); // Update global suspend all state for attaching threads. DCHECK_GE(suspend_all_count_, debug_suspend_all_count_); needs_resume = (debug_suspend_all_count_ > 0); diff --git a/runtime/thread_pool.cc b/runtime/thread_pool.cc index a7f2ecdd81..587eb320cd 100644 --- a/runtime/thread_pool.cc +++ b/runtime/thread_pool.cc @@ -89,8 +89,9 @@ ThreadPool::ThreadPool(const char* name, size_t num_threads) max_active_workers_(num_threads) { Thread* self = Thread::Current(); while (GetThreadCount() < num_threads) { - const std::string name = StringPrintf("%s worker thread %zu", name_.c_str(), GetThreadCount()); - threads_.push_back(new ThreadPoolWorker(this, name, ThreadPoolWorker::kDefaultStackSize)); + const std::string worker_name = StringPrintf("%s worker thread %zu", name_.c_str(), + GetThreadCount()); + threads_.push_back(new ThreadPoolWorker(this, worker_name, ThreadPoolWorker::kDefaultStackSize)); } // Wait for all of the threads to attach. creation_barier_.Wait(self); @@ -279,8 +280,9 @@ WorkStealingThreadPool::WorkStealingThreadPool(const char* name, size_t num_thre work_steal_lock_("work stealing lock"), steal_index_(0) { while (GetThreadCount() < num_threads) { - const std::string name = StringPrintf("Work stealing worker %zu", GetThreadCount()); - threads_.push_back(new WorkStealingWorker(this, name, ThreadPoolWorker::kDefaultStackSize)); + const std::string worker_name = StringPrintf("Work stealing worker %zu", GetThreadCount()); + threads_.push_back(new WorkStealingWorker(this, worker_name, + ThreadPoolWorker::kDefaultStackSize)); } } diff --git a/runtime/utils.cc b/runtime/utils.cc index 9c94f6cb01..11c610bf7f 100644 --- a/runtime/utils.cc +++ b/runtime/utils.cc @@ -1109,8 +1109,8 @@ std::string GetSchedulerGroupName(pid_t tid) { Split(cgroup_lines[i], ':', &cgroup_fields); std::vector<std::string> cgroups; Split(cgroup_fields[1], ',', &cgroups); - for (size_t i = 0; i < cgroups.size(); ++i) { - if (cgroups[i] == "cpu") { + for (size_t j = 0; j < cgroups.size(); ++j) { + if (cgroups[j] == "cpu") { return cgroup_fields[2].substr(1); // Skip the leading slash. } } diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 7380a50a5a..2be47d17d0 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -1191,11 +1191,6 @@ std::ostream& MethodVerifier::DumpFailures(std::ostream& os) { return os; } -extern "C" void MethodVerifierGdbDump(MethodVerifier* v) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - v->Dump(std::cerr); -} - void MethodVerifier::Dump(std::ostream& os) { if (code_item_ == nullptr) { os << "Native method\n"; |
