Skip to content

Commit 8345178

Browse files
Mandy Chungpull[bot]
authored andcommitted
8316305: Initial buffer size of StackWalker is too small caused by JDK-8285447
Reviewed-by: bchristi
1 parent 3f1238c commit 8345178

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/java.base/share/classes/java/lang/StackStreamFactory.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -550,16 +550,15 @@ protected void initFrameBuffer() {
550550
protected int batchSize(int lastBatchSize) {
551551
if (lastBatchSize == 0) {
552552
// First batch, use estimateDepth if not exceed the large batch size
553-
int initialBatchSize = Math.max(walker.estimateDepth()+RESERVED_ELEMENTS, MIN_BATCH_SIZE);
554-
return Math.min(initialBatchSize, LARGE_BATCH_SIZE);
553+
return walker.estimateDepth() == 0
554+
? SMALL_BATCH
555+
: Math.min(walker.estimateDepth() + RESERVED_ELEMENTS, LARGE_BATCH_SIZE);
555556
} else {
556557
// expand only if last batch was full and the buffer size <= 32
557558
// to minimize the number of unneeded frames decoded.
558-
if (lastBatchSize > BATCH_SIZE || !frameBuffer.isFull()) {
559-
return lastBatchSize;
560-
} else {
561-
return Math.min(lastBatchSize*2, BATCH_SIZE);
562-
}
559+
return (lastBatchSize > BATCH_SIZE || !frameBuffer.isFull())
560+
? lastBatchSize
561+
: Math.min(lastBatchSize*2, BATCH_SIZE);
563562
}
564563
}
565564

0 commit comments

Comments
 (0)