8153292: AllocateInstancePrefetchLines>AllocatePrefetchLines can trigger out-of-heap prefetching

Set the size of the reserved TLAB area to the MAX of both flags.

Reviewed-by: kvn, thartmann
This commit is contained in:
Zoltan Majo 2016-04-21 09:21:48 +02:00
parent 04dd07454a
commit 1af5fe07a0

View file

@ -112,11 +112,14 @@ void VM_Version::initialize() {
FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256); FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256);
} }
if (AllocatePrefetchInstr == 1) { if (AllocatePrefetchInstr == 1) {
// Need a space at the end of TLAB for BIS since it // Need extra space at the end of TLAB for BIS, otherwise prefetching
// will fault when accessing memory outside of heap. // instructions will fault (due to accessing memory outside of heap).
// The amount of space is the max of the number of lines to
// prefetch for array and for instance allocations. (Extra space must be
// reserved to accomodate both types of allocations.)
// +1 for rounding up to next cache line, +1 to be safe // +1 for rounding up to next cache line, +1 to be safe
int lines = AllocatePrefetchLines + 2; int lines = MAX2(AllocatePrefetchLines, AllocateInstancePrefetchLines) + 2;
int step_size = AllocatePrefetchStepSize; int step_size = AllocatePrefetchStepSize;
int distance = AllocatePrefetchDistance; int distance = AllocatePrefetchDistance;
_reserve_for_allocation_prefetch = (distance + step_size*lines)/(int)HeapWordSize; _reserve_for_allocation_prefetch = (distance + step_size*lines)/(int)HeapWordSize;