8329134: Reconsider TLAB zapping
Reviewed-by: stefank, rkennke
This commit is contained in:
parent
4a14cba2f1
commit
5698f7ad29
@ -316,18 +316,15 @@ HeapWord* MemAllocator::mem_allocate_inside_tlab_slow(Allocation& allocation) co
|
|||||||
PTR_FORMAT " min: " SIZE_FORMAT ", desired: " SIZE_FORMAT,
|
PTR_FORMAT " min: " SIZE_FORMAT ", desired: " SIZE_FORMAT,
|
||||||
p2i(mem), min_tlab_size, new_tlab_size);
|
p2i(mem), min_tlab_size, new_tlab_size);
|
||||||
|
|
||||||
|
// ...and clear or zap just allocated TLAB, if needed.
|
||||||
if (ZeroTLAB) {
|
if (ZeroTLAB) {
|
||||||
// ..and clear it.
|
|
||||||
Copy::zero_to_words(mem, allocation._allocated_tlab_size);
|
Copy::zero_to_words(mem, allocation._allocated_tlab_size);
|
||||||
} else {
|
} else if (ZapTLAB) {
|
||||||
// ...and zap just allocated object.
|
|
||||||
#ifdef ASSERT
|
|
||||||
// Skip mangling the space corresponding to the object header to
|
// Skip mangling the space corresponding to the object header to
|
||||||
// ensure that the returned space is not considered parsable by
|
// ensure that the returned space is not considered parsable by
|
||||||
// any concurrent GC thread.
|
// any concurrent GC thread.
|
||||||
size_t hdr_size = oopDesc::header_size();
|
size_t hdr_size = oopDesc::header_size();
|
||||||
Copy::fill_to_words(mem + hdr_size, allocation._allocated_tlab_size - hdr_size, badHeapWordVal);
|
Copy::fill_to_words(mem + hdr_size, allocation._allocated_tlab_size - hdr_size, badHeapWordVal);
|
||||||
#endif // ASSERT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tlab.fill(mem, mem + _word_size, allocation._allocated_tlab_size);
|
tlab.fill(mem, mem + _word_size, allocation._allocated_tlab_size);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -39,14 +39,8 @@ inline HeapWord* ThreadLocalAllocBuffer::allocate(size_t size) {
|
|||||||
invariants();
|
invariants();
|
||||||
HeapWord* obj = top();
|
HeapWord* obj = top();
|
||||||
if (pointer_delta(end(), obj) >= size) {
|
if (pointer_delta(end(), obj) >= size) {
|
||||||
// successful thread-local allocation
|
// Successful thread-local allocation.
|
||||||
#ifdef ASSERT
|
|
||||||
// Skip mangling the space corresponding to the object header to
|
|
||||||
// ensure that the returned space is not considered parsable by
|
|
||||||
// any concurrent GC thread.
|
|
||||||
size_t hdr_size = oopDesc::header_size();
|
|
||||||
Copy::fill_to_words(obj + hdr_size, size - hdr_size, badHeapWordVal);
|
|
||||||
#endif // ASSERT
|
|
||||||
// This addition is safe because we know that top is
|
// This addition is safe because we know that top is
|
||||||
// at least size below end, so the add can't wrap.
|
// at least size below end, so the add can't wrap.
|
||||||
set_top(obj + size);
|
set_top(obj + size);
|
||||||
|
@ -878,18 +878,15 @@ HeapWord* ShenandoahHeap::allocate_from_gclab_slow(Thread* thread, size_t size)
|
|||||||
|
|
||||||
assert (size <= actual_size, "allocation should fit");
|
assert (size <= actual_size, "allocation should fit");
|
||||||
|
|
||||||
|
// ...and clear or zap just allocated TLAB, if needed.
|
||||||
if (ZeroTLAB) {
|
if (ZeroTLAB) {
|
||||||
// ..and clear it.
|
|
||||||
Copy::zero_to_words(gclab_buf, actual_size);
|
Copy::zero_to_words(gclab_buf, actual_size);
|
||||||
} else {
|
} else if (ZapTLAB) {
|
||||||
// ...and zap just allocated object.
|
|
||||||
#ifdef ASSERT
|
|
||||||
// Skip mangling the space corresponding to the object header to
|
// Skip mangling the space corresponding to the object header to
|
||||||
// ensure that the returned space is not considered parsable by
|
// ensure that the returned space is not considered parsable by
|
||||||
// any concurrent GC thread.
|
// any concurrent GC thread.
|
||||||
size_t hdr_size = oopDesc::header_size();
|
size_t hdr_size = oopDesc::header_size();
|
||||||
Copy::fill_to_words(gclab_buf + hdr_size, actual_size - hdr_size, badHeapWordVal);
|
Copy::fill_to_words(gclab_buf + hdr_size, actual_size - hdr_size, badHeapWordVal);
|
||||||
#endif // ASSERT
|
|
||||||
}
|
}
|
||||||
gclab->set_buf(gclab_buf, actual_size);
|
gclab->set_buf(gclab_buf, actual_size);
|
||||||
return gclab->allocate(size);
|
return gclab->allocate(size);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -1991,11 +1991,9 @@ run:
|
|||||||
size_t obj_size = ik->size_helper();
|
size_t obj_size = ik->size_helper();
|
||||||
HeapWord* result = THREAD->tlab().allocate(obj_size);
|
HeapWord* result = THREAD->tlab().allocate(obj_size);
|
||||||
if (result != nullptr) {
|
if (result != nullptr) {
|
||||||
// Initialize object field block:
|
// Initialize object field block.
|
||||||
// - if TLAB is pre-zeroed, we can skip this path
|
if (!ZeroTLAB) {
|
||||||
// - in debug mode, ThreadLocalAllocBuffer::allocate mangles
|
// The TLAB was not pre-zeroed, we need to clear the memory here.
|
||||||
// this area, and we still need to initialize it
|
|
||||||
if (DEBUG_ONLY(true ||) !ZeroTLAB) {
|
|
||||||
size_t hdr_size = oopDesc::header_size();
|
size_t hdr_size = oopDesc::header_size();
|
||||||
Copy::fill_to_words(result + hdr_size, obj_size - hdr_size, 0);
|
Copy::fill_to_words(result + hdr_size, obj_size - hdr_size, 0);
|
||||||
}
|
}
|
||||||
|
@ -483,6 +483,9 @@ const int ObjectAlignmentInBytes = 8;
|
|||||||
develop(bool, ZapFillerObjects, trueInDebug, \
|
develop(bool, ZapFillerObjects, trueInDebug, \
|
||||||
"Zap filler objects") \
|
"Zap filler objects") \
|
||||||
\
|
\
|
||||||
|
develop(bool, ZapTLAB, trueInDebug, \
|
||||||
|
"Zap allocated TLABs") \
|
||||||
|
\
|
||||||
product(bool, ExecutingUnitTests, false, \
|
product(bool, ExecutingUnitTests, false, \
|
||||||
"Whether the JVM is running unit tests or not") \
|
"Whether the JVM is running unit tests or not") \
|
||||||
\
|
\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user