diff options
| -rw-r--r-- | runtime/gc/heap.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 33f849adf3..01c4c62307 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -47,6 +47,7 @@ #include "gc/collector/semi_space.h" #include "gc/collector/sticky_mark_sweep.h" #include "gc/reference_processor.h" +#include "gc/scoped_gc_critical_section.h" #include "gc/space/bump_pointer_space.h" #include "gc/space/dlmalloc_space-inl.h" #include "gc/space/image_space.h" @@ -1423,6 +1424,8 @@ void Heap::Trim(Thread* self) { // Deflate the monitors, this can cause a pause but shouldn't matter since we don't care // about pauses. ScopedTrace trace("Deflating monitors"); + // Avoid race conditions on the lock word for CC. + ScopedGCCriticalSection gcs(self, kGcCauseTrim, kCollectorTypeHeapTrim); ScopedSuspendAll ssa(__FUNCTION__); uint64_t start_time = NanoTime(); size_t count = runtime->GetMonitorList()->DeflateMonitors(); |