Skip to content

Commit 643969a

Browse files
committed
8255822: Zero: improve build-time JVMTI handling
Reviewed-by: dholmes, ihse
1 parent 6ae5e5b commit 643969a

File tree

6 files changed

+60
-183
lines changed

6 files changed

+60
-183
lines changed

make/hotspot/gensrc/GensrcJvmti.gmk

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,6 @@ $(eval $(call SetupJvmtiGeneration, jvmti.h, jvmtiH.xsl, \
106106
$(eval $(call SetupJvmtiGeneration, jvmti.html, jvmti.xsl, \
107107
-PARAM majorversion $(VERSION_FEATURE)))
108108

109-
JVMTI_BC_SRCDIR := $(TOPDIR)/src/hotspot/share/interpreter/zero
110-
111-
ifeq ($(call check-jvm-feature, zero), true)
112-
$(eval $(call SetupXslTransform, bytecodeInterpreterWithChecks.cpp, \
113-
XML_FILE := $(JVMTI_BC_SRCDIR)/bytecodeInterpreterWithChecks.xml, \
114-
XSL_FILE := $(JVMTI_BC_SRCDIR)/bytecodeInterpreterWithChecks.xsl, \
115-
OUTPUT_DIR := $(JVMTI_OUTPUTDIR), \
116-
DEPS := $(JVMTI_BC_SRCDIR)/bytecodeInterpreter.cpp, \
117-
))
118-
endif
119-
120109
################################################################################
121110
# Copy jvmti.h to include dir
122111

src/hotspot/cpu/zero/zeroInterpreter_zero.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ void ZeroInterpreter::initialize_code() {
7070

7171
// Allow c++ interpreter to do one initialization now that switches are set, etc.
7272
BytecodeInterpreter start_msg(BytecodeInterpreter::initialize);
73-
if (JvmtiExport::can_post_interpreter_events())
74-
BytecodeInterpreter::runWithChecks(&start_msg);
75-
else
76-
BytecodeInterpreter::run(&start_msg);
73+
if (JvmtiExport::can_post_interpreter_events()) {
74+
BytecodeInterpreter::run<true>(&start_msg);
75+
} else {
76+
BytecodeInterpreter::run<false>(&start_msg);
77+
}
7778
}
7879

7980
void ZeroInterpreter::invoke_method(Method* method, address entry_point, TRAPS) {
@@ -169,10 +170,11 @@ void ZeroInterpreter::main_loop(int recurse, TRAPS) {
169170
thread->set_last_Java_frame();
170171

171172
// Call the interpreter
172-
if (JvmtiExport::can_post_interpreter_events())
173-
BytecodeInterpreter::runWithChecks(istate);
174-
else
175-
BytecodeInterpreter::run(istate);
173+
if (JvmtiExport::can_post_interpreter_events()) {
174+
BytecodeInterpreter::run<true>(istate);
175+
} else {
176+
BytecodeInterpreter::run<false>(istate);
177+
}
176178
fixup_after_potential_safepoint();
177179

178180
// Clear the frame anchor

src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp

Lines changed: 49 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "runtime/sharedRuntime.hpp"
5353
#include "runtime/threadCritical.hpp"
5454
#include "utilities/exceptions.hpp"
55+
#include "utilities/macros.hpp"
5556

5657
// no precompiled headers
5758

@@ -153,7 +154,7 @@
153154
#endif
154155

155156
#undef DEBUGGER_SINGLE_STEP_NOTIFY
156-
#ifdef VM_JVMTI
157+
#if INCLUDE_JVMTI
157158
/* NOTE: (kbr) This macro must be called AFTER the PC has been
158159
incremented. JvmtiExport::at_single_stepping_point() may cause a
159160
breakpoint opcode to get inserted at the current PC to allow the
@@ -163,33 +164,31 @@
163164
to get the current opcode. This will override any other prefetching
164165
that might have occurred.
165166
*/
166-
#define DEBUGGER_SINGLE_STEP_NOTIFY() \
167-
{ \
168-
if (_jvmti_interp_events) { \
169-
if (JvmtiExport::should_post_single_step()) { \
170-
DECACHE_STATE(); \
171-
SET_LAST_JAVA_FRAME(); \
172-
ThreadInVMfromJava trans(THREAD); \
173-
JvmtiExport::at_single_stepping_point(THREAD, \
174-
istate->method(), \
175-
pc); \
176-
RESET_LAST_JAVA_FRAME(); \
177-
CACHE_STATE(); \
178-
if (THREAD->has_pending_popframe() && \
179-
!THREAD->pop_frame_in_process()) { \
180-
goto handle_Pop_Frame; \
181-
} \
182-
if (THREAD->jvmti_thread_state() && \
183-
THREAD->jvmti_thread_state()->is_earlyret_pending()) { \
184-
goto handle_Early_Return; \
185-
} \
186-
opcode = *pc; \
187-
} \
188-
} \
167+
#define DEBUGGER_SINGLE_STEP_NOTIFY() \
168+
{ \
169+
if (JVMTI_ENABLED && JvmtiExport::should_post_single_step()) { \
170+
DECACHE_STATE(); \
171+
SET_LAST_JAVA_FRAME(); \
172+
ThreadInVMfromJava trans(THREAD); \
173+
JvmtiExport::at_single_stepping_point(THREAD, \
174+
istate->method(), \
175+
pc); \
176+
RESET_LAST_JAVA_FRAME(); \
177+
CACHE_STATE(); \
178+
if (THREAD->has_pending_popframe() && \
179+
!THREAD->pop_frame_in_process()) { \
180+
goto handle_Pop_Frame; \
181+
} \
182+
if (THREAD->jvmti_thread_state() && \
183+
THREAD->jvmti_thread_state()->is_earlyret_pending()) { \
184+
goto handle_Early_Return; \
185+
} \
186+
opcode = *pc; \
187+
} \
189188
}
190189
#else
191190
#define DEBUGGER_SINGLE_STEP_NOTIFY()
192-
#endif
191+
#endif // INCLUDE_JVMTI
193192

194193
/*
195194
* CONTINUE - Macro for executing the next opcode.
@@ -387,22 +386,18 @@
387386

388387
/*
389388
* BytecodeInterpreter::run(interpreterState istate)
390-
* BytecodeInterpreter::runWithChecks(interpreterState istate)
391389
*
392390
* The real deal. This is where byte codes actually get interpreted.
393391
* Basically it's a big while loop that iterates until we return from
394392
* the method passed in.
395-
*
396-
* The runWithChecks is used if JVMTI is enabled.
397-
*
398393
*/
399-
#if defined(VM_JVMTI)
400-
void
401-
BytecodeInterpreter::runWithChecks(interpreterState istate) {
402-
#else
403-
void
404-
BytecodeInterpreter::run(interpreterState istate) {
405-
#endif
394+
395+
// Instantiate two variants of the method for future linking.
396+
template void BytecodeInterpreter::run<true>(interpreterState istate);
397+
template void BytecodeInterpreter::run<false>(interpreterState istate);
398+
399+
template<bool JVMTI_ENABLED>
400+
void BytecodeInterpreter::run(interpreterState istate) {
406401

407402
// In order to simplify some tests based on switches set at runtime
408403
// we invoke the interpreter a single time after switches are enabled
@@ -417,9 +412,6 @@ BytecodeInterpreter::run(interpreterState istate) {
417412
if (checkit && *c_addr != c_value) {
418413
os::breakpoint();
419414
}
420-
#ifdef VM_JVMTI
421-
static bool _jvmti_interp_events = 0;
422-
#endif
423415

424416
#ifdef ASSERT
425417
if (istate->_msg != initialize) {
@@ -555,9 +547,6 @@ BytecodeInterpreter::run(interpreterState istate) {
555547
switch (istate->msg()) {
556548
case initialize: {
557549
if (initialized++) ShouldNotReachHere(); // Only one initialize call.
558-
#ifdef VM_JVMTI
559-
_jvmti_interp_events = JvmtiExport::can_post_interpreter_events();
560-
#endif
561550
return;
562551
}
563552
break;
@@ -667,17 +656,13 @@ BytecodeInterpreter::run(interpreterState istate) {
667656
}
668657
THREAD->clr_do_not_unlock();
669658

670-
// Notify jvmti
671-
#ifdef VM_JVMTI
672-
if (_jvmti_interp_events) {
673-
// Whenever JVMTI puts a thread in interp_only_mode, method
674-
// entry/exit events are sent for that thread to track stack depth.
675-
if (THREAD->is_interp_only_mode()) {
676-
CALL_VM(InterpreterRuntime::post_method_entry(THREAD),
677-
handle_exception);
678-
}
659+
// Notify jvmti.
660+
// Whenever JVMTI puts a thread in interp_only_mode, method
661+
// entry/exit events are sent for that thread to track stack depth.
662+
if (JVMTI_ENABLED && THREAD->is_interp_only_mode()) {
663+
CALL_VM(InterpreterRuntime::post_method_entry(THREAD),
664+
handle_exception);
679665
}
680-
#endif /* VM_JVMTI */
681666

682667
goto run;
683668
}
@@ -1800,8 +1785,7 @@ BytecodeInterpreter::run(interpreterState istate) {
18001785
cache = cp->entry_at(index);
18011786
}
18021787

1803-
#ifdef VM_JVMTI
1804-
if (_jvmti_interp_events) {
1788+
if (JVMTI_ENABLED) {
18051789
int *count_addr;
18061790
oop obj;
18071791
// Check to see if a field modification watch has been set
@@ -1820,7 +1804,6 @@ BytecodeInterpreter::run(interpreterState istate) {
18201804
handle_exception);
18211805
}
18221806
}
1823-
#endif /* VM_JVMTI */
18241807

18251808
oop obj;
18261809
if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) {
@@ -1898,8 +1881,7 @@ BytecodeInterpreter::run(interpreterState istate) {
18981881
cache = cp->entry_at(index);
18991882
}
19001883

1901-
#ifdef VM_JVMTI
1902-
if (_jvmti_interp_events) {
1884+
if (JVMTI_ENABLED) {
19031885
int *count_addr;
19041886
oop obj;
19051887
// Check to see if a field modification watch has been set
@@ -1925,7 +1907,6 @@ BytecodeInterpreter::run(interpreterState istate) {
19251907
handle_exception);
19261908
}
19271909
}
1928-
#endif /* VM_JVMTI */
19291910

19301911
// QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases
19311912
// out so c++ compiler has a chance for constant prop to fold everything possible away.
@@ -2404,11 +2385,9 @@ BytecodeInterpreter::run(interpreterState istate) {
24042385
if (callee != NULL) {
24052386
istate->set_callee(callee);
24062387
istate->set_callee_entry_point(callee->from_interpreted_entry());
2407-
#ifdef VM_JVMTI
2408-
if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
2388+
if (JVMTI_ENABLED && THREAD->is_interp_only_mode()) {
24092389
istate->set_callee_entry_point(callee->interpreter_entry());
24102390
}
2411-
#endif /* VM_JVMTI */
24122391
istate->set_bcp_advance(5);
24132392
UPDATE_PC_AND_RETURN(0); // I'll be back...
24142393
}
@@ -2466,11 +2445,9 @@ BytecodeInterpreter::run(interpreterState istate) {
24662445

24672446
istate->set_callee(callee);
24682447
istate->set_callee_entry_point(callee->from_interpreted_entry());
2469-
#ifdef VM_JVMTI
2470-
if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
2448+
if (JVMTI_ENABLED && THREAD->is_interp_only_mode()) {
24712449
istate->set_callee_entry_point(callee->interpreter_entry());
24722450
}
2473-
#endif /* VM_JVMTI */
24742451
istate->set_bcp_advance(5);
24752452
UPDATE_PC_AND_RETURN(0); // I'll be back...
24762453
}
@@ -2536,11 +2513,9 @@ BytecodeInterpreter::run(interpreterState istate) {
25362513

25372514
istate->set_callee(callee);
25382515
istate->set_callee_entry_point(callee->from_interpreted_entry());
2539-
#ifdef VM_JVMTI
2540-
if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
2516+
if (JVMTI_ENABLED && THREAD->is_interp_only_mode()) {
25412517
istate->set_callee_entry_point(callee->interpreter_entry());
25422518
}
2543-
#endif /* VM_JVMTI */
25442519
istate->set_bcp_advance(3);
25452520
UPDATE_PC_AND_RETURN(0); // I'll be back...
25462521
}
@@ -2963,25 +2938,16 @@ BytecodeInterpreter::run(interpreterState istate) {
29632938
// (with this note) in anticipation of changing the vm and the tests
29642939
// simultaneously.
29652940

2966-
2967-
//
29682941
suppress_exit_event = suppress_exit_event || illegal_state_oop() != NULL;
29692942

2943+
// Whenever JVMTI puts a thread in interp_only_mode, method
2944+
// entry/exit events are sent for that thread to track stack depth.
29702945

2971-
2972-
#ifdef VM_JVMTI
2973-
if (_jvmti_interp_events) {
2974-
// Whenever JVMTI puts a thread in interp_only_mode, method
2975-
// entry/exit events are sent for that thread to track stack depth.
2976-
if ( !suppress_exit_event && THREAD->is_interp_only_mode() ) {
2977-
{
2978-
// Prevent any HandleMarkCleaner from freeing our live handles
2979-
HandleMark __hm(THREAD);
2980-
CALL_VM_NOCHECK(InterpreterRuntime::post_method_exit(THREAD));
2981-
}
2982-
}
2983-
}
2984-
#endif /* VM_JVMTI */
2946+
if (JVMTI_ENABLED && !suppress_exit_event && THREAD->is_interp_only_mode()) {
2947+
// Prevent any HandleMarkCleaner from freeing our live handles
2948+
HandleMark __hm(THREAD);
2949+
CALL_VM_NOCHECK(InterpreterRuntime::post_method_exit(THREAD));
2950+
}
29852951

29862952
//
29872953
// See if we are returning any exception
@@ -3032,13 +2998,6 @@ BytecodeInterpreter::run(interpreterState istate) {
30322998
return;
30332999
}
30343000

3035-
/*
3036-
* All the code following this point is only produced once and is not present
3037-
* in the JVMTI version of the interpreter
3038-
*/
3039-
3040-
#ifndef VM_JVMTI
3041-
30423001
// This constructor should only be used to contruct the object to signal
30433002
// interpreter initialization. All other instances should be created by
30443003
// the frame manager.
@@ -3169,5 +3128,3 @@ extern "C" {
31693128
}
31703129
}
31713130
#endif // PRODUCT
3172-
3173-
#endif // JVMTI

src/hotspot/share/interpreter/zero/bytecodeInterpreter.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,8 @@ static void dup2_x1(intptr_t *tos); /* insert top 2 slots three down */
503503
static void dup2_x2(intptr_t *tos); /* insert top 2 slots four down */
504504
static void swap(intptr_t *tos); /* swap top two elements */
505505

506-
// umm don't like this method modifies its object
507-
508-
// The Interpreter used when
506+
template<bool JVMTI_ENABLED>
509507
static void run(interpreterState istate);
510-
// The interpreter used if JVMTI needs interpreter events
511-
static void runWithChecks(interpreterState istate);
512508

513509
static void astore(intptr_t* topOfStack, int stack_offset,
514510
intptr_t* locals, int locals_offset);

src/hotspot/share/interpreter/zero/bytecodeInterpreterWithChecks.xml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)