diff options
author | Ian Rogers <irogers@google.com> | 2014-07-09 18:00:50 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2014-07-09 18:00:50 -0700 |
commit | 8ab25ef11aed383bf7d3aa96e95f777972d1b58f (patch) | |
tree | 905b37556c225ab44e94f39292bbc558d7506376 | |
parent | bcb3b29095817ce8987d8310d4db87271f5114ad (diff) | |
download | art-8ab25ef11aed383bf7d3aa96e95f777972d1b58f.zip art-8ab25ef11aed383bf7d3aa96e95f777972d1b58f.tar.gz art-8ab25ef11aed383bf7d3aa96e95f777972d1b58f.tar.bz2 |
Move another field away from android_atomic_cas.
Change-Id: If63aa2811e06ec401a601286a3bacb62a0da96ad
-rw-r--r-- | runtime/trace.cc | 8 | ||||
-rw-r--r-- | runtime/trace.h | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/runtime/trace.cc b/runtime/trace.cc index 032a566..a522e88 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -459,7 +459,7 @@ Trace::Trace(File* trace_file, int buffer_size, int flags, bool sampling_enabled } // Update current offset. - cur_offset_ = kTraceHeaderLength; + cur_offset_.StoreRelaxed(kTraceHeaderLength); } static void DumpBuf(uint8_t* buf, size_t buf_size, ProfilerClockSource clock_source) @@ -480,7 +480,7 @@ void Trace::FinishTracing() { // Compute elapsed time. uint64_t elapsed = MicroTime() - start_time_; - size_t final_offset = cur_offset_; + size_t final_offset = cur_offset_.LoadRelaxed(); uint32_t clock_overhead_ns = GetClockOverheadNanoSeconds(this); if ((flags_ & kTraceCountAllocs) != 0) { @@ -623,13 +623,13 @@ void Trace::LogMethodTraceEvent(Thread* thread, mirror::ArtMethod* method, int32_t new_offset; int32_t old_offset; do { - old_offset = cur_offset_; + old_offset = cur_offset_.LoadRelaxed(); new_offset = old_offset + GetRecordSize(clock_source_); if (new_offset > buffer_size_) { overflow_ = true; return; } - } while (android_atomic_release_cas(old_offset, new_offset, &cur_offset_) != 0); + } while (cur_offset_.CompareExchangeWeakSequentiallyConsistent(old_offset, new_offset) != 0); TraceAction action = kTraceMethodEnter; switch (event) { diff --git a/runtime/trace.h b/runtime/trace.h index 3f5d80a..9c8d35b 100644 --- a/runtime/trace.h +++ b/runtime/trace.h @@ -23,6 +23,7 @@ #include <string> #include <vector> +#include "atomic.h" #include "base/macros.h" #include "globals.h" #include "instrumentation.h" @@ -166,7 +167,7 @@ class Trace FINAL : public instrumentation::InstrumentationListener { const uint64_t start_time_; // Offset into buf_. - volatile int32_t cur_offset_; + AtomicInteger cur_offset_; // Did we overflow the buffer recording traces? bool overflow_; |