diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 82db0c37e0731f17770cf85b84447fd5bf5a7644..bf892425c82f866b1dcfeeae6e55c180a650b7c7 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -2279,7 +2279,8 @@ G1CollectedHeap::do_collection_pause_at_safepoint(HeapRegion* popular_region) { assert(Thread::current() == VMThread::vm_thread(), "should be in vm thread"); guarantee(!is_gc_active(), "collection is not reentrant"); assert(regions_accounted_for(), "Region leakage!"); - ++_gc_time_stamp; + + increment_gc_time_stamp(); if (g1_policy()->in_young_gc_mode()) { assert(check_young_list_well_formed(), diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index 4cc1db22d50478a53880bad6e82c514631d6edc1..b47a983d970eecaaa73133aee69e368a8c814753 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -247,7 +247,7 @@ private: NumberSeq _pop_obj_rc_at_copy; void print_popularity_summary_info() const; - unsigned _gc_time_stamp; + volatile unsigned _gc_time_stamp; size_t* _surviving_young_words; @@ -653,6 +653,12 @@ public: void reset_gc_time_stamp() { _gc_time_stamp = 0; + OrderAccess::fence(); + } + + void increment_gc_time_stamp() { + ++_gc_time_stamp; + OrderAccess::fence(); } void iterate_dirty_card_closure(bool concurrent, int worker_i); diff --git a/src/share/vm/gc_implementation/g1/heapRegion.cpp b/src/share/vm/gc_implementation/g1/heapRegion.cpp index 05435f54c1448e3b64c8a26c8066c1cc5e182e9b..824adbf874e318a9cb8726da3630eb0b644c0f15 100644 --- a/src/share/vm/gc_implementation/g1/heapRegion.cpp +++ b/src/share/vm/gc_implementation/g1/heapRegion.cpp @@ -793,8 +793,8 @@ void G1OffsetTableContigSpace::set_saved_mark() { // will pick up the right saved_mark_word() as the high water mark // of the region. Either way, the behaviour will be correct. ContiguousSpace::set_saved_mark(); - OrderAccess::release_store_ptr((volatile intptr_t*) &_gc_time_stamp, - (intptr_t) curr_gc_time_stamp); + _gc_time_stamp = curr_gc_time_stamp; + OrderAccess::fence(); } }