From cf7f19135f0e273f7b0136315633c2abfc715343 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Wed, 22 Oct 2014 22:06:39 -0700 Subject: [PATCH] C++11 related clean-up of DISALLOW_.. Move DISALLOW_COPY_AND_ASSIGN to delete functions. By no having declarations with no definitions this prompts better warning messages so deal with these by correcting the code. Add a DISALLOW_ALLOCATION and use for ValueObject and mirror::Object. Make X86 assembly operand types ValueObjects to fix compilation errors. Tidy the use of iostream and ostream. Avoid making cutils a dependency via mutex-inl.h for tests that link against libart. Push tracing dependencies into appropriate files and mutex.cc. x86 32-bit host symbols size is increased for libarttest, avoid copying this in run-test 115 by using symlinks and remove this test's higher than normal ulimit. Fix the RunningOnValgrind test in RosAllocSpace to not use GetHeap as it returns NULL when the heap is under construction by Runtime. Change-Id: Ia246f7ac0c11f73072b30d70566a196e9b78472b --- compiler/driver/compiler_driver.cc | 4 --- compiler/driver/compiler_driver.h | 10 ------ compiler/optimizing/graph_visualizer.h | 2 ++ compiler/optimizing/nodes.h | 2 +- compiler/optimizing/ssa_liveness_analysis.h | 1 + compiler/utils/assembler_test.h | 13 +++----- compiler/utils/x86/assembler_x86.h | 11 ++---- compiler/utils/x86_64/assembler_x86_64.h | 10 ++---- compiler/utils/x86_64/assembler_x86_64_test.cc | 4 +-- dex2oat/dex2oat.cc | 6 ++-- disassembler/disassembler.cc | 2 +- disassembler/disassembler_arm.cc | 2 +- disassembler/disassembler_arm64.cc | 2 +- disassembler/disassembler_mips.cc | 2 +- disassembler/disassembler_x86.cc | 5 +-- runtime/arch/stub_test.cc | 2 +- runtime/base/logging.h | 2 +- runtime/base/macros.h | 26 +++++++++------ runtime/base/mutex-inl.h | 44 ++---------------------- runtime/base/mutex.cc | 46 ++++++++++++++++++++++++++ runtime/base/mutex.h | 3 ++ runtime/base/stringpiece.cc | 2 +- runtime/base/value_object.h | 12 ++----- runtime/check_reference_map_visitor.h | 2 +- runtime/class_linker.cc | 3 +- runtime/debugger.cc | 4 +-- runtime/dex_instruction_visitor_test.cc | 1 - runtime/dex_method_iterator_test.cc | 2 +- runtime/gc/allocator/rosalloc.cc | 2 +- runtime/gc/collector/garbage_collector.cc | 3 ++ runtime/gc/collector/mark_sweep.cc | 3 ++ runtime/gc/heap.h | 3 -- runtime/gc/space/malloc_space.h | 2 +- runtime/gc/space/rosalloc_space.cc | 8 +++-- runtime/indirect_reference_table.cc | 10 +++--- runtime/interpreter/interpreter_common.h | 1 + runtime/mirror/object.h | 1 + runtime/offsets.cc | 2 +- runtime/offsets.h | 3 +- runtime/profiler.cc | 2 +- runtime/quick_exception_handler.cc | 3 +- runtime/signal_catcher.cc | 2 +- runtime/trace.cc | 3 ++ sigchainlib/sigchain_dummy.cc | 5 +-- test/115-native-bridge/run | 4 +-- test/Android.libarttest.mk | 7 +--- test/Android.libnativebridgetest.mk | 2 +- test/run-test | 3 -- 48 files changed, 142 insertions(+), 152 deletions(-) diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 452868870..a60c5bc98 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -347,15 +347,11 @@ CompilerDriver::CompilerDriver(const CompilerOptions* compiler_options, image_(image), image_classes_(image_classes), thread_count_(thread_count), - start_ns_(0), stats_(new AOTCompilationStats), dump_stats_(dump_stats), dump_passes_(dump_passes), timings_logger_(timer), - compiler_library_(nullptr), compiler_context_(nullptr), - compiler_enable_auto_elf_loading_(nullptr), - compiler_get_method_code_addr_(nullptr), support_boot_image_fixup_(instruction_set != kMips), dedupe_code_("dedupe code"), dedupe_src_mapping_table_("dedupe source mapping table"), diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 3d59ef1e8..0796f4878 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -503,7 +503,6 @@ class CompilerDriver { std::unique_ptr> image_classes_; size_t thread_count_; - uint64_t start_ns_; class AOTCompilationStats; std::unique_ptr stats_; @@ -516,8 +515,6 @@ class CompilerDriver { typedef void (*CompilerCallbackFn)(CompilerDriver& driver); typedef MutexLock* (*CompilerMutexLockFn)(CompilerDriver& driver); - void* compiler_library_; - typedef void (*DexToDexCompilerFn)(CompilerDriver& driver, const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, @@ -533,13 +530,6 @@ class CompilerDriver { // Arena pool used by the compiler. ArenaPool arena_pool_; - typedef void (*CompilerEnableAutoElfLoadingFn)(CompilerDriver& driver); - CompilerEnableAutoElfLoadingFn compiler_enable_auto_elf_loading_; - - typedef const void* (*CompilerGetMethodCodeAddrFn) - (const CompilerDriver& driver, const CompiledMethod* cm, const mirror::ArtMethod* method); - CompilerGetMethodCodeAddrFn compiler_get_method_code_addr_; - bool support_boot_image_fixup_; // DeDuplication data structures, these own the corresponding byte arrays. diff --git a/compiler/optimizing/graph_visualizer.h b/compiler/optimizing/graph_visualizer.h index 05984a080..4d8bec242 100644 --- a/compiler/optimizing/graph_visualizer.h +++ b/compiler/optimizing/graph_visualizer.h @@ -17,6 +17,8 @@ #ifndef ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_ #define ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_ +#include + #include "base/value_object.h" namespace art { diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 9b7ff88b6..e9b6b4177 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2123,7 +2123,7 @@ class HGraphVisitor : public ValueObject { #undef DECLARE_VISIT_INSTRUCTION private: - HGraph* graph_; + HGraph* const graph_; DISALLOW_COPY_AND_ASSIGN(HGraphVisitor); }; diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h index 8f718480b..7dda4f61d 100644 --- a/compiler/optimizing/ssa_liveness_analysis.h +++ b/compiler/optimizing/ssa_liveness_analysis.h @@ -32,6 +32,7 @@ class BlockInfo : public ArenaObject { live_in_(allocator, number_of_ssa_values, false), live_out_(allocator, number_of_ssa_values, false), kill_(allocator, number_of_ssa_values, false) { + UNUSED(block_); live_in_.ClearAllBits(); live_out_.ClearAllBits(); kill_.ClearAllBits(); diff --git a/compiler/utils/assembler_test.h b/compiler/utils/assembler_test.h index 5bfa462d7..91237ae91 100644 --- a/compiler/utils/assembler_test.h +++ b/compiler/utils/assembler_test.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -118,9 +117,8 @@ class AssemblerTest : public testing::Test { std::vector imms = CreateImmediateValues(imm_bytes); for (auto reg : registers) { for (int64_t imm : imms) { - Imm* new_imm = CreateImmediate(imm); - (assembler_.get()->*f)(*reg, *new_imm); - delete new_imm; + Imm new_imm = CreateImmediate(imm); + (assembler_.get()->*f)(*reg, new_imm); std::string base = fmt; size_t reg_index = base.find("{reg}"); @@ -154,9 +152,8 @@ class AssemblerTest : public testing::Test { std::string str; std::vector imms = CreateImmediateValues(imm_bytes); for (int64_t imm : imms) { - Imm* new_imm = CreateImmediate(imm); - (assembler_.get()->*f)(*new_imm); - delete new_imm; + Imm new_imm = CreateImmediate(imm); + (assembler_.get()->*f)(new_imm); std::string base = fmt; size_t imm_index = base.find("{imm}"); @@ -333,7 +330,7 @@ class AssemblerTest : public testing::Test { } // Create an immediate from the specific value. - virtual Imm* CreateImmediate(int64_t imm_value) = 0; + virtual Imm CreateImmediate(int64_t imm_value) = 0; private: // Driver() assembles and compares the results. If the results are not equal and we have a diff --git a/compiler/utils/x86/assembler_x86.h b/compiler/utils/x86/assembler_x86.h index c7eada34f..b5bf31bbd 100644 --- a/compiler/utils/x86/assembler_x86.h +++ b/compiler/utils/x86/assembler_x86.h @@ -29,7 +29,7 @@ namespace art { namespace x86 { -class Immediate { +class Immediate : public ValueObject { public: explicit Immediate(int32_t value) : value_(value) {} @@ -47,7 +47,7 @@ class Immediate { }; -class Operand { +class Operand : public ValueObject { public: uint8_t mod() const { return (encoding_at(0) >> 6) & 3; @@ -129,8 +129,6 @@ class Operand { } friend class X86Assembler; - - DISALLOW_COPY_AND_ASSIGN(Operand); }; @@ -168,7 +166,6 @@ class Address : public Operand { } } - Address(Register index, ScaleFactor scale, int32_t disp) { CHECK_NE(index, ESP); // Illegal addressing mode. SetModRM(0, ESP); @@ -205,14 +202,12 @@ class Address : public Operand { private: Address() {} - - DISALLOW_COPY_AND_ASSIGN(Address); }; class X86Assembler FINAL : public Assembler { public: - explicit X86Assembler() {} + explicit X86Assembler() : cfi_cfa_offset_(0), cfi_pc_(0) {} virtual ~X86Assembler() {} /* diff --git a/compiler/utils/x86_64/assembler_x86_64.h b/compiler/utils/x86_64/assembler_x86_64.h index 7e5859cc4..92b81ec2e 100644 --- a/compiler/utils/x86_64/assembler_x86_64.h +++ b/compiler/utils/x86_64/assembler_x86_64.h @@ -36,7 +36,7 @@ namespace x86_64 { // // Note: As we support cross-compilation, the value type must be int64_t. Please be aware of // conversion rules in expressions regarding negation, especially size_t on 32b. -class Immediate { +class Immediate : public ValueObject { public: explicit Immediate(int64_t value) : value_(value) {} @@ -54,12 +54,10 @@ class Immediate { private: const int64_t value_; - - DISALLOW_COPY_AND_ASSIGN(Immediate); }; -class Operand { +class Operand : public ValueObject { public: uint8_t mod() const { return (encoding_at(0) >> 6) & 3; @@ -157,8 +155,6 @@ class Operand { } friend class X86_64Assembler; - - DISALLOW_COPY_AND_ASSIGN(Operand); }; @@ -247,8 +243,6 @@ class Address : public Operand { private: Address() {} - - DISALLOW_COPY_AND_ASSIGN(Address); }; diff --git a/compiler/utils/x86_64/assembler_x86_64_test.cc b/compiler/utils/x86_64/assembler_x86_64_test.cc index 37a09328f..18c5cbcbc 100644 --- a/compiler/utils/x86_64/assembler_x86_64_test.cc +++ b/compiler/utils/x86_64/assembler_x86_64_test.cc @@ -72,8 +72,8 @@ class AssemblerX86_64Test : public AssemblerTest #endif +#define ATRACE_TAG ATRACE_TAG_DALVIK +#include "cutils/trace.h" + #include "base/dumpable.h" #include "base/stl_util.h" #include "base/stringpiece.h" @@ -1238,8 +1241,7 @@ static int dex2oat(int argc, char** argv) { #ifdef ART_SEA_IR_MODE true, #endif - verbose_methods.empty() ? nullptr : &verbose_methods - )); // NOLINT(whitespace/parens) + verbose_methods.empty() ? nullptr : &verbose_methods)); // Done with usage checks, enable watchdog if requested WatchDog watch_dog(watch_dog_enabled); diff --git a/disassembler/disassembler.cc b/disassembler/disassembler.cc index c97bf64c5..bf68204d7 100644 --- a/disassembler/disassembler.cc +++ b/disassembler/disassembler.cc @@ -16,7 +16,7 @@ #include "disassembler.h" -#include +#include #include "base/logging.h" #include "base/stringprintf.h" diff --git a/disassembler/disassembler_arm.cc b/disassembler/disassembler_arm.cc index 9caae9c48..ee652b34f 100644 --- a/disassembler/disassembler_arm.cc +++ b/disassembler/disassembler_arm.cc @@ -18,7 +18,7 @@ #include -#include +#include #include #include "base/logging.h" diff --git a/disassembler/disassembler_arm64.cc b/disassembler/disassembler_arm64.cc index fc1065aff..229ac9755 100644 --- a/disassembler/disassembler_arm64.cc +++ b/disassembler/disassembler_arm64.cc @@ -18,7 +18,7 @@ #include -#include +#include #include "base/logging.h" #include "base/stringprintf.h" diff --git a/disassembler/disassembler_mips.cc b/disassembler/disassembler_mips.cc index c06492a3f..97c06f178 100644 --- a/disassembler/disassembler_mips.cc +++ b/disassembler/disassembler_mips.cc @@ -16,7 +16,7 @@ #include "disassembler_mips.h" -#include +#include #include #include "base/logging.h" diff --git a/disassembler/disassembler_x86.cc b/disassembler/disassembler_x86.cc index ce1452022..e12559f01 100644 --- a/disassembler/disassembler_x86.cc +++ b/disassembler/disassembler_x86.cc @@ -16,13 +16,14 @@ #include "disassembler_x86.h" -#include +#include + +#include #include #include "base/logging.h" #include "base/stringprintf.h" #include "thread.h" -#include namespace art { namespace x86 { diff --git a/runtime/arch/stub_test.cc b/runtime/arch/stub_test.cc index ea586b854..c5a0f6c23 100644 --- a/runtime/arch/stub_test.cc +++ b/runtime/arch/stub_test.cc @@ -1148,7 +1148,7 @@ TEST_F(StubTest, AllocObjectArray) { // For some reason this does not work, as the type_idx is artificial and outside what the // resolved types of c_obj allow... - if (false) { + if ((false)) { // Use an arbitrary method from c to use as referrer size_t result = Invoke3(static_cast(c->GetDexTypeIndex()), // type_idx reinterpret_cast(c_obj->GetVirtualMethod(0)), // arbitrary diff --git a/runtime/base/logging.h b/runtime/base/logging.h index 5e8e99402..baa83e35a 100644 --- a/runtime/base/logging.h +++ b/runtime/base/logging.h @@ -17,8 +17,8 @@ #ifndef ART_RUNTIME_BASE_LOGGING_H_ #define ART_RUNTIME_BASE_LOGGING_H_ -#include #include +#include #include "base/macros.h" diff --git a/runtime/base/macros.h b/runtime/base/macros.h index c80d35e42..febea61b8 100644 --- a/runtime/base/macros.h +++ b/runtime/base/macros.h @@ -68,22 +68,28 @@ struct CompileAssert { #define ART_FRIEND_TEST(test_set_name, individual_test)\ friend class test_set_name##_##individual_test##_Test -// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions. -// It goes in the private: declarations in a class. +// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions. It goes in the private: +// declarations in a class. #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&) + TypeName(const TypeName&) = delete; \ + void operator=(const TypeName&) = delete -// A macro to disallow all the implicit constructors, namely the -// default constructor, copy constructor and operator= functions. +// A macro to disallow all the implicit constructors, namely the default constructor, copy +// constructor and operator= functions. // -// This should be used in the private: declarations for a class -// that wants to prevent anyone from instantiating it. This is -// especially useful for classes containing only static methods. +// This should be used in the private: declarations for a class that wants to prevent anyone from +// instantiating it. This is especially useful for classes containing only static methods. #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ - TypeName(); \ + TypeName() = delete; \ DISALLOW_COPY_AND_ASSIGN(TypeName) +// A macro to disallow new and delete operators for a class. It goes in the private: declarations. +#define DISALLOW_ALLOCATION() \ + public: \ + ALWAYS_INLINE void operator delete(void*, size_t) { UNREACHABLE(); } \ + private: \ + void* operator new(size_t) = delete + // The arraysize(arr) macro returns the # of elements in an array arr. // The expression is a compile-time constant, and therefore can be // used in defining new arrays, for example. If you use arraysize on diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h index f70db35f1..e066787bf 100644 --- a/runtime/base/mutex-inl.h +++ b/runtime/base/mutex-inl.h @@ -21,11 +21,8 @@ #include "mutex.h" -#define ATRACE_TAG ATRACE_TAG_DALVIK - -#include "cutils/trace.h" - #include "base/stringprintf.h" +#include "base/value_object.h" #include "runtime.h" #include "thread.h" @@ -44,35 +41,6 @@ static inline int futex(volatile int *uaddr, int op, int val, const struct times } #endif // ART_USE_FUTEXES -class ScopedContentionRecorder { - public: - ScopedContentionRecorder(BaseMutex* mutex, uint64_t blocked_tid, uint64_t owner_tid) - : mutex_(kLogLockContentions ? mutex : NULL), - blocked_tid_(kLogLockContentions ? blocked_tid : 0), - owner_tid_(kLogLockContentions ? owner_tid : 0), - start_nano_time_(kLogLockContentions ? NanoTime() : 0) { - if (ATRACE_ENABLED()) { - std::string msg = StringPrintf("Lock contention on %s (owner tid: %" PRIu64 ")", - mutex->GetName(), owner_tid); - ATRACE_BEGIN(msg.c_str()); - } - } - - ~ScopedContentionRecorder() { - ATRACE_END(); - if (kLogLockContentions) { - uint64_t end_nano_time = NanoTime(); - mutex_->RecordContention(blocked_tid_, owner_tid_, end_nano_time - start_nano_time_); - } - } - - private: - BaseMutex* const mutex_; - const uint64_t blocked_tid_; - const uint64_t owner_tid_; - const uint64_t start_nano_time_; -}; - static inline uint64_t SafeGetTid(const Thread* self) { if (self != NULL) { return static_cast(self->GetTid()); @@ -158,15 +126,7 @@ inline void ReaderWriterMutex::SharedLock(Thread* self) { // Add as an extra reader. done = state_.CompareExchangeWeakAcquire(cur_state, cur_state + 1); } else { - // Owner holds it exclusively, hang up. - ScopedContentionRecorder scr(this, GetExclusiveOwnerTid(), SafeGetTid(self)); - ++num_pending_readers_; - if (futex(state_.Address(), FUTEX_WAIT, cur_state, NULL, NULL, 0) != 0) { - if (errno != EAGAIN) { - PLOG(FATAL) << "futex wait failed for " << name_; - } - } - --num_pending_readers_; + HandleSharedLockContention(self, cur_state); } } while (!done); #else diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc index 1d373497e..6362a989a 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -19,8 +19,12 @@ #include #include +#define ATRACE_TAG ATRACE_TAG_DALVIK +#include "cutils/trace.h" + #include "atomic.h" #include "base/logging.h" +#include "base/value_object.h" #include "mutex-inl.h" #include "runtime.h" #include "scoped_thread_state_change.h" @@ -106,6 +110,36 @@ class ScopedAllMutexesLock FINAL { const BaseMutex* const mutex_; }; +// Scoped class that generates events at the beginning and end of lock contention. +class ScopedContentionRecorder FINAL : public ValueObject { + public: + ScopedContentionRecorder(BaseMutex* mutex, uint64_t blocked_tid, uint64_t owner_tid) + : mutex_(kLogLockContentions ? mutex : NULL), + blocked_tid_(kLogLockContentions ? blocked_tid : 0), + owner_tid_(kLogLockContentions ? owner_tid : 0), + start_nano_time_(kLogLockContentions ? NanoTime() : 0) { + if (ATRACE_ENABLED()) { + std::string msg = StringPrintf("Lock contention on %s (owner tid: %" PRIu64 ")", + mutex->GetName(), owner_tid); + ATRACE_BEGIN(msg.c_str()); + } + } + + ~ScopedContentionRecorder() { + ATRACE_END(); + if (kLogLockContentions) { + uint64_t end_nano_time = NanoTime(); + mutex_->RecordContention(blocked_tid_, owner_tid_, end_nano_time - start_nano_time_); + } + } + + private: + BaseMutex* const mutex_; + const uint64_t blocked_tid_; + const uint64_t owner_tid_; + const uint64_t start_nano_time_; +}; + BaseMutex::BaseMutex(const char* name, LockLevel level) : level_(level), name_(name) { if (kLogLockContentions) { ScopedAllMutexesLock mu(this); @@ -612,6 +646,18 @@ bool ReaderWriterMutex::ExclusiveLockWithTimeout(Thread* self, int64_t ms, int32 } #endif +void ReaderWriterMutex::HandleSharedLockContention(Thread* self, int32_t cur_state) { + // Owner holds it exclusively, hang up. + ScopedContentionRecorder scr(this, GetExclusiveOwnerTid(), SafeGetTid(self)); + ++num_pending_readers_; + if (futex(state_.Address(), FUTEX_WAIT, cur_state, NULL, NULL, 0) != 0) { + if (errno != EAGAIN) { + PLOG(FATAL) << "futex wait failed for " << name_; + } + } + --num_pending_readers_; +} + bool ReaderWriterMutex::SharedTryLock(Thread* self) { DCHECK(self == NULL || self == Thread::Current()); #if ART_USE_FUTEXES diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h index 516fa07b6..25fdd59f8 100644 --- a/runtime/base/mutex.h +++ b/runtime/base/mutex.h @@ -360,6 +360,9 @@ class LOCKABLE ReaderWriterMutex : public BaseMutex { virtual void Dump(std::ostream& os) const; private: + // Out-of-inline path for handling contention for a SharedLock. + void HandleSharedLockContention(Thread* self, int32_t cur_state); + #if ART_USE_FUTEXES // -1 implies held exclusive, +ve shared held by state_ many owners. AtomicInteger state_; diff --git a/runtime/base/stringpiece.cc b/runtime/base/stringpiece.cc index 824ee4863..2570bad85 100644 --- a/runtime/base/stringpiece.cc +++ b/runtime/base/stringpiece.cc @@ -16,7 +16,7 @@ #include "stringpiece.h" -#include +#include #include #include "logging.h" diff --git a/runtime/base/value_object.h b/runtime/base/value_object.h index ee0e2a0dc..8c752a923 100644 --- a/runtime/base/value_object.h +++ b/runtime/base/value_object.h @@ -17,19 +17,13 @@ #ifndef ART_RUNTIME_BASE_VALUE_OBJECT_H_ #define ART_RUNTIME_BASE_VALUE_OBJECT_H_ -#include "base/logging.h" +#include "base/macros.h" namespace art { class ValueObject { - public: - void* operator new(size_t size) { - LOG(FATAL) << "UNREACHABLE"; - abort(); - } - void operator delete(void*, size_t) { - LOG(FATAL) << "UNREACHABLE"; - } + private: + DISALLOW_ALLOCATION(); }; } // namespace art diff --git a/runtime/check_reference_map_visitor.h b/runtime/check_reference_map_visitor.h index 8c2293f86..9d2d59c9a 100644 --- a/runtime/check_reference_map_visitor.h +++ b/runtime/check_reference_map_visitor.h @@ -37,7 +37,7 @@ class CheckReferenceMapVisitor : public StackVisitor { CHECK_EQ(GetDexPc(), DexFile::kDexNoIndex); } - if (!m || m->IsNative() || m->IsRuntimeMethod() || IsShadowFrame()) { + if (m == nullptr || m->IsNative() || m->IsRuntimeMethod() || IsShadowFrame()) { return true; } diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index bbbb9e0b8..f6717fb00 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -17,6 +17,7 @@ #include "class_linker.h" #include +#include #include #include #include @@ -5110,7 +5111,7 @@ bool ClassLinker::LinkFields(Thread* self, Handle klass, bool is_ bool seen_non_ref = false; for (size_t i = 0; i < num_fields; i++) { mirror::ArtField* field = fields->Get(i); - if (false) { // enable to debug field layout + if ((false)) { // enable to debug field layout LOG(INFO) << "LinkFields: " << (is_static ? "static" : "instance") << " class=" << PrettyClass(klass.Get()) << " field=" << PrettyField(field) diff --git a/runtime/debugger.cc b/runtime/debugger.cc index b676c62ee..18bbc3813 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -4116,7 +4116,6 @@ class HeapChunkContext { HeapChunkContext(bool merge, bool native) : buf_(16384 - 16), type_(0), - merge_(merge), chunk_overhead_(0) { Reset(); if (native) { @@ -4327,7 +4326,6 @@ class HeapChunkContext { void* startOfNextMemoryChunk_; size_t totalAllocationUnits_; uint32_t type_; - bool merge_; bool needHeader_; size_t chunk_overhead_; @@ -4678,7 +4676,7 @@ static const char* GetMethodSourceFile(mirror::ArtMethod* method) * between the contents of these tables. */ jbyteArray Dbg::GetRecentAllocations() { - if (false) { + if ((false)) { DumpRecentAllocations(); } diff --git a/runtime/dex_instruction_visitor_test.cc b/runtime/dex_instruction_visitor_test.cc index c5e63eb06..5273084a9 100644 --- a/runtime/dex_instruction_visitor_test.cc +++ b/runtime/dex_instruction_visitor_test.cc @@ -16,7 +16,6 @@ #include "dex_instruction_visitor.h" -#include #include #include "gtest/gtest.h" diff --git a/runtime/dex_method_iterator_test.cc b/runtime/dex_method_iterator_test.cc index b2b713808..c6f333f67 100644 --- a/runtime/dex_method_iterator_test.cc +++ b/runtime/dex_method_iterator_test.cc @@ -38,7 +38,7 @@ TEST_F(DexMethodIteratorTest, Basic) { const DexFile& dex_file = it.GetDexFile(); InvokeType invoke_type = it.GetInvokeType(); uint32_t method_idx = it.GetMemberIndex(); - if (false) { + if ((false)) { LOG(INFO) << invoke_type << " " << PrettyMethod(method_idx, dex_file); } it.Next(); diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc index 804c98a99..fa531a7c6 100644 --- a/runtime/gc/allocator/rosalloc.cc +++ b/runtime/gc/allocator/rosalloc.cc @@ -1144,7 +1144,7 @@ static constexpr bool kReadPageMapEntryWithoutLockInBulkFree = true; size_t RosAlloc::BulkFree(Thread* self, void** ptrs, size_t num_ptrs) { size_t freed_bytes = 0; - if (false) { + if ((false)) { // Used only to test Free() as GC uses only BulkFree(). for (size_t i = 0; i < num_ptrs; ++i) { freed_bytes += FreeInternal(self, ptrs[i]); diff --git a/runtime/gc/collector/garbage_collector.cc b/runtime/gc/collector/garbage_collector.cc index 4148e9c0b..9e6a8003f 100644 --- a/runtime/gc/collector/garbage_collector.cc +++ b/runtime/gc/collector/garbage_collector.cc @@ -18,6 +18,9 @@ #include "garbage_collector.h" +#define ATRACE_TAG ATRACE_TAG_DALVIK +#include "cutils/trace.h" + #include "base/dumpable.h" #include "base/histogram-inl.h" #include "base/logging.h" diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index 942b556a7..83da0639e 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -21,6 +21,9 @@ #include #include +#define ATRACE_TAG ATRACE_TAG_DALVIK +#include "cutils/trace.h" + #include "base/bounded_fifo.h" #include "base/logging.h" #include "base/macros.h" diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index ba85c55c9..ff1e38b91 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -601,9 +601,6 @@ class Heap { void RemoveRememberedSet(space::Space* space); bool IsCompilingBoot() const; - bool RunningOnValgrind() const { - return running_on_valgrind_; - } bool HasImageSpace() const; ReferenceProcessor* GetReferenceProcessor() { diff --git a/runtime/gc/space/malloc_space.h b/runtime/gc/space/malloc_space.h index 723011610..cfde46003 100644 --- a/runtime/gc/space/malloc_space.h +++ b/runtime/gc/space/malloc_space.h @@ -19,7 +19,7 @@ #include "space.h" -#include +#include #include #include diff --git a/runtime/gc/space/rosalloc_space.cc b/runtime/gc/space/rosalloc_space.cc index d25694ad2..161eba9c1 100644 --- a/runtime/gc/space/rosalloc_space.cc +++ b/runtime/gc/space/rosalloc_space.cc @@ -17,6 +17,9 @@ #include "rosalloc_space-inl.h" +#define ATRACE_TAG ATRACE_TAG_DALVIK +#include "cutils/trace.h" + #include "gc/accounting/card_table.h" #include "gc/accounting/space_bitmap-inl.h" #include "gc/heap.h" @@ -73,8 +76,9 @@ RosAllocSpace* RosAllocSpace::CreateFromMemMap(MemMap* mem_map, const std::strin uint8_t* begin = mem_map->Begin(); // TODO: Fix RosAllocSpace to support valgrind. There is currently some issues with // AllocationSize caused by redzones. b/12944686 - if (false && Runtime::Current()->GetHeap()->RunningOnValgrind()) { - LOG(FATAL) << "Unimplemented"; + if (Runtime::Current()->RunningOnValgrind()) { + UNIMPLEMENTED(FATAL); + UNREACHABLE(); } else { return new RosAllocSpace(name, mem_map, rosalloc, begin, end, begin + capacity, growth_limit, can_move_objects, starting_size, initial_size, low_memory_mode); diff --git a/runtime/indirect_reference_table.cc b/runtime/indirect_reference_table.cc index c1455fd0b..4d177a32d 100644 --- a/runtime/indirect_reference_table.cc +++ b/runtime/indirect_reference_table.cc @@ -126,7 +126,7 @@ IndirectRef IndirectReferenceTable::Add(uint32_t cookie, mirror::Object* obj) { } table_[index].Add(obj); result = ToIndirectRef(index); - if (false) { + if ((false)) { LOG(INFO) << "+++ added at " << ExtractIndex(result) << " top=" << segment_state_.parts.topIndex << " holes=" << segment_state_.parts.numHoles; } @@ -193,7 +193,7 @@ bool IndirectReferenceTable::Remove(uint32_t cookie, IndirectRef iref) { int numHoles = segment_state_.parts.numHoles - prevState.parts.numHoles; if (numHoles != 0) { while (--topIndex > bottomIndex && numHoles != 0) { - if (false) { + if ((false)) { LOG(INFO) << "+++ checking for hole at " << topIndex - 1 << " (cookie=" << cookie << ") val=" << table_[topIndex - 1].GetReference()->Read(); @@ -201,7 +201,7 @@ bool IndirectReferenceTable::Remove(uint32_t cookie, IndirectRef iref) { if (!table_[topIndex - 1].GetReference()->IsNull()) { break; } - if (false) { + if ((false)) { LOG(INFO) << "+++ ate hole at " << (topIndex - 1); } numHoles--; @@ -210,7 +210,7 @@ bool IndirectReferenceTable::Remove(uint32_t cookie, IndirectRef iref) { segment_state_.parts.topIndex = topIndex; } else { segment_state_.parts.topIndex = topIndex-1; - if (false) { + if ((false)) { LOG(INFO) << "+++ ate last entry " << topIndex - 1; } } @@ -228,7 +228,7 @@ bool IndirectReferenceTable::Remove(uint32_t cookie, IndirectRef iref) { *table_[idx].GetReference() = GcRoot(nullptr); segment_state_.parts.numHoles++; - if (false) { + if ((false)) { LOG(INFO) << "+++ left hole at " << idx << ", holes=" << segment_state_.parts.numHoles; } } diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h index f8858d09f..fa03fc7fa 100644 --- a/runtime/interpreter/interpreter_common.h +++ b/runtime/interpreter/interpreter_common.h @@ -21,6 +21,7 @@ #include +#include #include #include "base/logging.h" diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h index 1bbcf8ef1..b2b24209c 100644 --- a/runtime/mirror/object.h +++ b/runtime/mirror/object.h @@ -478,6 +478,7 @@ class MANAGED LOCKABLE Object { friend struct art::ObjectOffsets; // for verifying offset information friend class CopyObjectVisitor; // for CopyObject(). friend class CopyClassVisitor; // for CopyObject(). + DISALLOW_ALLOCATION(); DISALLOW_IMPLICIT_CONSTRUCTORS(Object); }; diff --git a/runtime/offsets.cc b/runtime/offsets.cc index 369140176..f59ed881a 100644 --- a/runtime/offsets.cc +++ b/runtime/offsets.cc @@ -16,7 +16,7 @@ #include "offsets.h" -#include // NOLINT +#include namespace art { diff --git a/runtime/offsets.h b/runtime/offsets.h index 72a6b0f31..9d5063f3e 100644 --- a/runtime/offsets.h +++ b/runtime/offsets.h @@ -17,7 +17,8 @@ #ifndef ART_RUNTIME_OFFSETS_H_ #define ART_RUNTIME_OFFSETS_H_ -#include // NOLINT +#include + #include "globals.h" namespace art { diff --git a/runtime/profiler.cc b/runtime/profiler.cc index 1d06d352a..e39919500 100644 --- a/runtime/profiler.cc +++ b/runtime/profiler.cc @@ -97,7 +97,7 @@ static void GetSample(Thread* thread, void* arg) SHARED_LOCKS_REQUIRED(Locks::mu switch (profile_options.GetProfileType()) { case kProfilerMethod: { mirror::ArtMethod* method = thread->GetCurrentMethod(nullptr); - if (false && method == nullptr) { + if ((false) && method == nullptr) { LOG(INFO) << "No current method available"; std::ostringstream os; thread->Dump(os); diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc index 8e578374c..c58735a94 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -300,7 +300,7 @@ class InstrumentationStackVisitor : public StackVisitor { InstrumentationStackVisitor(Thread* self, bool is_deoptimization, size_t frame_depth) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : StackVisitor(self, nullptr), - self_(self), frame_depth_(frame_depth), + frame_depth_(frame_depth), instrumentation_frames_to_pop_(0) { CHECK_NE(frame_depth_, kInvalidFrameDepth); } @@ -324,7 +324,6 @@ class InstrumentationStackVisitor : public StackVisitor { } private: - Thread* const self_; const size_t frame_depth_; size_t instrumentation_frames_to_pop_; diff --git a/runtime/signal_catcher.cc b/runtime/signal_catcher.cc index 6d6783678..d4ec80372 100644 --- a/runtime/signal_catcher.cc +++ b/runtime/signal_catcher.cc @@ -133,7 +133,7 @@ void SignalCatcher::HandleSigQuit() { runtime->DumpForSigQuit(os); - if (false) { + if ((false)) { std::string maps; if (ReadFileToString("/proc/self/maps", &maps)) { os << "/proc/self/maps:\n" << maps; diff --git a/runtime/trace.cc b/runtime/trace.cc index 91a37fdda..b3158a48a 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -18,6 +18,9 @@ #include +#define ATRACE_TAG ATRACE_TAG_DALVIK +#include "cutils/trace.h" + #include "base/stl_util.h" #include "base/unix_file/fd_file.h" #include "class_linker.h" diff --git a/sigchainlib/sigchain_dummy.cc b/sigchainlib/sigchain_dummy.cc index fbc8c3fb5..17bfe8f72 100644 --- a/sigchainlib/sigchain_dummy.cc +++ b/sigchainlib/sigchain_dummy.cc @@ -14,6 +14,9 @@ * limitations under the License. */ +#include +#include + #ifdef HAVE_ANDROID_OS #include #else @@ -21,8 +24,6 @@ #include #endif -#include - #include "sigchain.h" static void log(const char* format, ...) { diff --git a/test/115-native-bridge/run b/test/115-native-bridge/run index e475cd6b8..32a9975c4 100644 --- a/test/115-native-bridge/run +++ b/test/115-native-bridge/run @@ -18,9 +18,9 @@ ARGS=${@} # Use libnativebridgetest as a native bridge, start NativeBridgeMain (Main is JniTest main file). LIBPATH=$(echo ${ARGS} | sed -r 's/.*Djava.library.path=([^ ]*) .*/\1/') -cp ${LIBPATH}/libnativebridgetest.so . +ln -s ${LIBPATH}/libnativebridgetest.so . touch libarttest.so -cp ${LIBPATH}/libarttest.so libarttest2.so +ln -s ${LIBPATH}/libarttest.so libarttest2.so # pwd likely has /, so it's a pain to put that into a sed rule. LEFT=$(echo ${ARGS} | sed -r 's/-Djava.library.path.*//') diff --git a/test/Android.libarttest.mk b/test/Android.libarttest.mk index fd9503896..55de1f3f3 100644 --- a/test/Android.libarttest.mk +++ b/test/Android.libarttest.mk @@ -58,8 +58,7 @@ define build-libarttest ifeq ($$(art_target_or_host),target) $(call set-target-local-clang-vars) $(call set-target-local-cflags-vars,debug) - LOCAL_SHARED_LIBRARIES += libdl libcutils - LOCAL_STATIC_LIBRARIES := libgtest + LOCAL_SHARED_LIBRARIES += libdl LOCAL_MULTILIB := both LOCAL_MODULE_PATH_32 := $(ART_TARGET_TEST_OUT)/$(ART_TARGET_ARCH_32) LOCAL_MODULE_PATH_64 := $(ART_TARGET_TEST_OUT)/$(ART_TARGET_ARCH_64) @@ -68,11 +67,7 @@ define build-libarttest else # host LOCAL_CLANG := $(ART_HOST_CLANG) LOCAL_CFLAGS := $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS) - LOCAL_STATIC_LIBRARIES := libcutils LOCAL_LDLIBS := $(ART_HOST_LDLIBS) -ldl -lpthread - ifeq ($(HOST_OS),linux) - LOCAL_LDLIBS += -lrt - endif LOCAL_IS_HOST_MODULE := true LOCAL_MULTILIB := both include $(BUILD_HOST_SHARED_LIBRARY) diff --git a/test/Android.libnativebridgetest.mk b/test/Android.libnativebridgetest.mk index 5e2493c8b..1b20e6965 100644 --- a/test/Android.libnativebridgetest.mk +++ b/test/Android.libnativebridgetest.mk @@ -51,7 +51,7 @@ define build-libnativebridgetest ifeq ($$(art_target_or_host),target) $(call set-target-local-clang-vars) $(call set-target-local-cflags-vars,debug) - LOCAL_SHARED_LIBRARIES += libdl libcutils + LOCAL_SHARED_LIBRARIES += libdl LOCAL_STATIC_LIBRARIES := libgtest LOCAL_MULTILIB := both LOCAL_MODULE_PATH_32 := $(ART_TARGET_TEST_OUT)/$(ART_TARGET_ARCH_32) diff --git a/test/run-test b/test/run-test index 73ffc3129..2ef3ab189 100755 --- a/test/run-test +++ b/test/run-test @@ -469,9 +469,6 @@ if echo "$test_dir" | grep 089; then file_size_limit=5120 elif echo "$test_dir" | grep 083; then file_size_limit=5120 -elif echo "$test_dir" | grep 115; then -# Native bridge test copies libarttest.so into its directory, which needs 2MB already. - file_size_limit=5120 fi if ! ulimit -S "$file_size_limit"; then echo "ulimit file size setting failed" -- 2.11.0