--- old/src/hotspot/share/gc/shared/collectedHeap.cpp 2017-10-31 13:44:20.135672433 -0700 +++ new/src/hotspot/share/gc/shared/collectedHeap.cpp 2017-10-31 13:44:19.807673744 -0700 @@ -291,13 +291,13 @@ void CollectedHeap::sample_allocation(Thread* thread, HeapWord* obj, - size_t size, size_t fix_sample_rate) { + size_t size, size_t overflowed_words) { // Object is allocated, sample it now. HeapMonitoring::object_alloc_do_sample(thread, reinterpret_cast(obj), size * HeapWordSize); // Pick a next sample in this case, we allocated right. - thread->tlab().pick_next_sample(fix_sample_rate); + thread->tlab().pick_next_sample(overflowed_words); } HeapWord* CollectedHeap::allocate_sampled_object(Thread* thread, size_t size) { @@ -309,7 +309,7 @@ HeapWord* CollectedHeap::allocate_from_tlab_slow(Klass* klass, Thread* thread, size_t size) { // In case the tlab changes, remember if this one wanted a sample. - bool should_sample = thread->tlab().should_sample() && HeapMonitoring::enabled(); + bool should_sample = HeapMonitoring::enabled() && thread->tlab().should_sample(); HeapWord* obj = NULL; if (should_sample) { @@ -320,10 +320,10 @@ // If we did allocate in this tlab, sample it. Otherwise, we wait for the // new tlab's first allocation at the end of this method. if (obj != NULL) { - // Fix sample rate by removing the extra bytes allocated in this last + // Fix sample rate by removing the extra words allocated in this last // sample. - size_t fix_sample_rate = thread->tlab().top() - tlab_old_end; - sample_allocation(thread, obj, size, fix_sample_rate); + size_t overflowed_words = pointer_delta(thread->tlab().top(), tlab_old_end); + sample_allocation(thread, obj, size, overflowed_words); return obj; } }