From e429756625ca67ba5540171b9da93a8f60e30d93 Mon Sep 17 00:00:00 2001 From: pliden Date: Mon, 17 Mar 2014 15:18:38 +0100 Subject: [PATCH] 8036672: G1: alloc_purpose in copy_to_survivor_space() used incorrectly Reviewed-by: brutisso, tschatzl --- src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 4c18d9c28..6273d2401 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -4743,6 +4743,12 @@ oop G1ParScanThreadState::copy_to_survivor_space(oop const old) { oop forward_ptr = old->forward_to_atomic(obj); if (forward_ptr == NULL) { Copy::aligned_disjoint_words((HeapWord*) old, obj_ptr, word_sz); + + // alloc_purpose is just a hint to allocate() above, recheck the type of region + // we actually allocated from and update alloc_purpose accordingly + HeapRegion* to_region = _g1h->heap_region_containing_raw(obj_ptr); + alloc_purpose = to_region->is_young() ? GCAllocForSurvived : GCAllocForTenured; + if (g1p->track_object_age(alloc_purpose)) { // We could simply do obj->incr_age(). However, this causes a // performance issue. obj->incr_age() will first check whether -- GitLab