diff options
| author | 2016-03-16 21:07:31 +0000 | |
|---|---|---|
| committer | 2016-03-16 21:07:31 +0000 | |
| commit | 6f1b7ecf61a7be88bcbb259726e99a78a7235d15 (patch) | |
| tree | 5b7a34b9ee466a2950744b16a39b8421a6d3cec2 | |
| parent | 932e6bf238a00ae9813e91acb7249cb063fab205 (diff) | |
| parent | 50e933188d993c6eb67560db1fcad67ba1d182e1 (diff) | |
Merge "Fix race in AllocEntrypointsInstrumented"
| -rw-r--r-- | runtime/instrumentation.cc | 5 | ||||
| -rw-r--r-- | runtime/instrumentation.h | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index b107b72b55..a0c6bfbd83 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -83,7 +83,8 @@ Instrumentation::Instrumentation() deoptimized_methods_lock_("deoptimized methods lock"), deoptimization_enabled_(false), interpreter_handler_table_(kMainHandlerTable), - quick_alloc_entry_points_instrumentation_counter_(0) { + quick_alloc_entry_points_instrumentation_counter_(0), + alloc_entrypoints_instrumented_(false) { } void Instrumentation::InstallStubsForClass(mirror::Class* klass) { @@ -642,10 +643,12 @@ void Instrumentation::SetEntrypointsInstrumented(bool instrumented) { MutexLock mu(self, *Locks::runtime_shutdown_lock_); SetQuickAllocEntryPointsInstrumented(instrumented); ResetQuickAllocEntryPoints(); + alloc_entrypoints_instrumented_ = instrumented; } else { MutexLock mu(self, *Locks::runtime_shutdown_lock_); SetQuickAllocEntryPointsInstrumented(instrumented); ResetQuickAllocEntryPoints(); + alloc_entrypoints_instrumented_ = instrumented; } } diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h index b3cdb410f3..d07f47bf29 100644 --- a/runtime/instrumentation.h +++ b/runtime/instrumentation.h @@ -422,7 +422,7 @@ class Instrumentation { // Does not hold lock, used to check if someone changed from not instrumented to instrumented // during a GC suspend point. bool AllocEntrypointsInstrumented() const SHARED_REQUIRES(Locks::mutator_lock_) { - return quick_alloc_entry_points_instrumentation_counter_ > 0; + return alloc_entrypoints_instrumented_; } private: @@ -579,6 +579,12 @@ class Instrumentation { // Greater than 0 if quick alloc entry points instrumented. size_t quick_alloc_entry_points_instrumentation_counter_; + + // alloc_entrypoints_instrumented_ is only updated with all the threads suspended, this is done + // to prevent races with the GC where the GC relies on thread suspension only see + // alloc_entrypoints_instrumented_ change during suspend points. + bool alloc_entrypoints_instrumented_; + friend class InstrumentationTest; // For GetCurrentInstrumentationLevel and ConfigureStubs. DISALLOW_COPY_AND_ASSIGN(Instrumentation); |