Skip to content

Commit 4f881ba

Browse files
committed
8258652: Assert in JvmtiThreadState::cur_stack_depth() can noticeably slow down debugging single stepping
Reviewed-by: sspitsyn, dholmes, amenkov
1 parent d18d26e commit 4f881ba

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/hotspot/share/prims/jvmtiThreadState.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -282,9 +282,14 @@ int JvmtiThreadState::cur_stack_depth() {
282282
if (!is_interp_only_mode() || _cur_stack_depth == UNKNOWN_STACK_DEPTH) {
283283
_cur_stack_depth = count_frames();
284284
} else {
285-
// heavy weight assert
286-
assert(_cur_stack_depth == count_frames(),
287-
"cur_stack_depth out of sync");
285+
#ifdef ASSERT
286+
if (EnableJVMTIStackDepthAsserts) {
287+
// heavy weight assert
288+
jint num_frames = count_frames();
289+
assert(_cur_stack_depth == num_frames, "cur_stack_depth out of sync _cur_stack_depth: %d num_frames: %d",
290+
_cur_stack_depth, num_frames);
291+
}
292+
#endif
288293
}
289294
return _cur_stack_depth;
290295
}

src/hotspot/share/runtime/globals.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,9 @@ const intx ObjectAlignmentInBytes = 8;
18051805
notproduct(bool, UseDebuggerErgo2, false, \
18061806
"Debugging Only: Limit the number of spawned JVM threads") \
18071807
\
1808+
notproduct(bool, EnableJVMTIStackDepthAsserts, true, \
1809+
"Enable JVMTI asserts related to stack depth checks") \
1810+
\
18081811
/* flags for performance data collection */ \
18091812
\
18101813
product(bool, UsePerfData, true, \

0 commit comments

Comments
 (0)