--- old/src/share/vm/gc_implementation/shenandoah/shenandoahFreeSet.cpp 2019-11-11 16:09:54.784343006 +0100 +++ new/src/share/vm/gc_implementation/shenandoah/shenandoahFreeSet.cpp 2019-11-11 16:09:54.697343010 +0100 @@ -25,6 +25,7 @@ #include "gc_implementation/shenandoah/shenandoahFreeSet.hpp" #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp" +#include "gc_implementation/shenandoah/shenandoahTraversalGC.hpp" ShenandoahFreeSet::ShenandoahFreeSet(ShenandoahHeap* heap,size_t max_regions) : _heap(heap), @@ -175,6 +176,15 @@ // Record actual allocation size req.set_actual_size(size); + + if (req.is_gc_alloc() && _heap->is_concurrent_traversal_in_progress()) { + // Traversal needs to traverse through GC allocs. Adjust TAMS to the new top + // so that these allocations appear below TAMS, and thus get traversed. + // See top of shenandoahTraversal.cpp for an explanation. + _heap->marking_context()->capture_top_at_mark_start(r); + _heap->traversal_gc()->traversal_set()->add_region_check_for_duplicates(r); + OrderAccess::fence(); + } } if (result == NULL || has_no_alloc_capacity(r)) {