Skip to content

Commit 13c176b

Browse files
mur47x111Doug Simon
authored and
Doug Simon
committedAug 25, 2020
8252058: [JVMCI] Rework setting is_method_handle_invoke flag in jvmciCodeInstaller
Reviewed-by: kvn, dlong
1 parent afce1f4 commit 13c176b

6 files changed

+45
-17
lines changed
 

‎src/hotspot/share/code/compiledMethod.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2020, 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
@@ -330,7 +330,7 @@ class CompiledMethod : public CodeBlob {
330330
// Deopt
331331
// Return true is the PC is one would expect if the frame is being deopted.
332332
inline bool is_deopt_pc(address pc);
333-
bool is_deopt_mh_entry(address pc) { return pc == deopt_mh_handler_begin(); }
333+
inline bool is_deopt_mh_entry(address pc);
334334
inline bool is_deopt_entry(address pc);
335335

336336
virtual bool can_convert_to_zombie() = 0;

‎src/hotspot/share/code/compiledMethod.inline.hpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2020, 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
@@ -41,6 +41,14 @@ inline bool CompiledMethod::is_deopt_entry(address pc) {
4141
;
4242
}
4343

44+
inline bool CompiledMethod::is_deopt_mh_entry(address pc) {
45+
return pc == deopt_mh_handler_begin()
46+
#if INCLUDE_JVMCI
47+
|| (is_compiled_by_jvmci() && pc == (deopt_mh_handler_begin() + NativeCall::instruction_size))
48+
#endif
49+
;
50+
}
51+
4452
// -----------------------------------------------------------------------------
4553
// CompiledMethod::get_deopt_original_pc
4654
//

‎src/hotspot/share/jvmci/jvmciCodeInstaller.cpp

+21-8
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(JVMCIObject de
10431043
return objects;
10441044
}
10451045

1046-
void CodeInstaller::record_scope(jint pc_offset, JVMCIObject debug_info, ScopeMode scope_mode, bool return_oop, JVMCI_TRAPS) {
1046+
void CodeInstaller::record_scope(jint pc_offset, JVMCIObject debug_info, ScopeMode scope_mode, bool is_mh_invoke, bool return_oop, JVMCI_TRAPS) {
10471047
JVMCIObject position = jvmci_env()->get_DebugInfo_bytecodePosition(debug_info);
10481048
if (position.is_null()) {
10491049
// Stubs do not record scope info, just oop maps
@@ -1056,7 +1056,7 @@ void CodeInstaller::record_scope(jint pc_offset, JVMCIObject debug_info, ScopeMo
10561056
} else {
10571057
objectMapping = NULL;
10581058
}
1059-
record_scope(pc_offset, position, scope_mode, objectMapping, return_oop, JVMCI_CHECK);
1059+
record_scope(pc_offset, position, scope_mode, objectMapping, is_mh_invoke, return_oop, JVMCI_CHECK);
10601060
}
10611061

10621062
int CodeInstaller::map_jvmci_bci(int bci) {
@@ -1079,7 +1079,7 @@ int CodeInstaller::map_jvmci_bci(int bci) {
10791079
return bci;
10801080
}
10811081

1082-
void CodeInstaller::record_scope(jint pc_offset, JVMCIObject position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, bool return_oop, JVMCI_TRAPS) {
1082+
void CodeInstaller::record_scope(jint pc_offset, JVMCIObject position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, bool is_mh_invoke, bool return_oop, JVMCI_TRAPS) {
10831083
JVMCIObject frame;
10841084
if (scope_mode == CodeInstaller::FullFrame) {
10851085
if (!jvmci_env()->isa_BytecodeFrame(position)) {
@@ -1089,7 +1089,7 @@ void CodeInstaller::record_scope(jint pc_offset, JVMCIObject position, ScopeMode
10891089
}
10901090
JVMCIObject caller_frame = jvmci_env()->get_BytecodePosition_caller(position);
10911091
if (caller_frame.is_non_null()) {
1092-
record_scope(pc_offset, caller_frame, scope_mode, objects, return_oop, JVMCI_CHECK);
1092+
record_scope(pc_offset, caller_frame, scope_mode, objects, is_mh_invoke, return_oop, JVMCI_CHECK);
10931093
}
10941094

10951095
JVMCIObject hotspot_method = jvmci_env()->get_BytecodePosition_method(position);
@@ -1181,7 +1181,7 @@ void CodeInstaller::record_scope(jint pc_offset, JVMCIObject position, ScopeMode
11811181
throw_exception = jvmci_env()->get_BytecodeFrame_rethrowException(frame) == JNI_TRUE;
11821182
}
11831183

1184-
_debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, return_oop,
1184+
_debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, is_mh_invoke, return_oop,
11851185
locals_token, expressions_token, monitors_token);
11861186
}
11871187

@@ -1236,9 +1236,19 @@ void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, JVMCIObject si
12361236
OopMap *map = create_oop_map(debug_info, JVMCI_CHECK);
12371237
_debug_recorder->add_safepoint(next_pc_offset, map);
12381238

1239-
bool return_oop = hotspot_method.is_non_null() && jvmci_env()->asMethod(hotspot_method)->is_returning_oop();
1240-
1241-
record_scope(next_pc_offset, debug_info, CodeInstaller::FullFrame, return_oop, JVMCI_CHECK);
1239+
if (hotspot_method.is_non_null()) {
1240+
Method *method = jvmci_env()->asMethod(hotspot_method);
1241+
vmIntrinsics::ID iid = method->intrinsic_id();
1242+
bool is_mh_invoke = false;
1243+
if (jvmci_env()->get_site_Call_direct(site)) {
1244+
is_mh_invoke = !method->is_static() && (iid == vmIntrinsics::_compiledLambdaForm ||
1245+
(MethodHandles::is_signature_polymorphic(iid) && MethodHandles::is_signature_polymorphic_intrinsic(iid)));
1246+
}
1247+
bool return_oop = method->is_returning_oop();
1248+
record_scope(next_pc_offset, debug_info, CodeInstaller::FullFrame, is_mh_invoke, return_oop, JVMCI_CHECK);
1249+
} else {
1250+
record_scope(next_pc_offset, debug_info, CodeInstaller::FullFrame, JVMCI_CHECK);
1251+
}
12421252
}
12431253

12441254
if (foreign_call.is_non_null()) {
@@ -1347,6 +1357,9 @@ void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, JVMCIObject si
13471357
case DEOPT_HANDLER_ENTRY:
13481358
_offsets.set_value(CodeOffsets::Deopt, pc_offset);
13491359
break;
1360+
case DEOPT_MH_HANDLER_ENTRY:
1361+
_offsets.set_value(CodeOffsets::DeoptMH, pc_offset);
1362+
break;
13501363
case FRAME_COMPLETE:
13511364
_offsets.set_value(CodeOffsets::Frame_Complete, pc_offset);
13521365
break;

‎src/hotspot/share/jvmci/jvmciCodeInstaller.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2020, 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
@@ -159,6 +159,7 @@ class CodeInstaller : public StackObj {
159159
CRC_TABLE_ADDRESS,
160160
LOG_OF_HEAP_REGION_GRAIN_BYTES,
161161
INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED,
162+
DEOPT_MH_HANDLER_ENTRY,
162163
INVOKE_INVALID = -1
163164
};
164165

@@ -297,11 +298,11 @@ class CodeInstaller : public StackObj {
297298

298299
int map_jvmci_bci(int bci);
299300

300-
void record_scope(jint pc_offset, JVMCIObject debug_info, ScopeMode scope_mode, bool return_oop, JVMCI_TRAPS);
301+
void record_scope(jint pc_offset, JVMCIObject debug_info, ScopeMode scope_mode, bool is_mh_invoke, bool return_oop, JVMCI_TRAPS);
301302
void record_scope(jint pc_offset, JVMCIObject debug_info, ScopeMode scope_mode, JVMCI_TRAPS) {
302-
record_scope(pc_offset, debug_info, scope_mode, false /* return_oop */, JVMCIENV);
303+
record_scope(pc_offset, debug_info, scope_mode, false /* is_mh_invoke */, false /* return_oop */, JVMCIENV);
303304
}
304-
void record_scope(jint pc_offset, JVMCIObject position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, bool return_oop, JVMCI_TRAPS);
305+
void record_scope(jint pc_offset, JVMCIObject position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, bool is_mh_invoke, bool return_oop, JVMCI_TRAPS);
305306
void record_object_value(ObjectValue* sv, JVMCIObject value, GrowableArray<ScopeValue*>* objects, JVMCI_TRAPS);
306307

307308
GrowableArray<ScopeValue*>* record_virtual_objects(JVMCIObject debug_info, JVMCI_TRAPS);

‎src/hotspot/share/jvmci/jvmciJavaClasses.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2020, 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
@@ -175,6 +175,7 @@
175175
end_class \
176176
start_class(site_Call, jdk_vm_ci_code_site_Call) \
177177
object_field(site_Call, target, "Ljdk/vm/ci/meta/InvokeTarget;") \
178+
boolean_field(site_Call, direct) \
178179
end_class \
179180
start_class(site_DataPatch, jdk_vm_ci_code_site_DataPatch) \
180181
object_field(site_DataPatch, reference, "Ljdk/vm/ci/code/site/Reference;") \

‎src/hotspot/share/jvmci/vmStructs_jvmci.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,14 @@
471471
declare_constant(CodeInstaller::CRC_TABLE_ADDRESS) \
472472
declare_constant(CodeInstaller::LOG_OF_HEAP_REGION_GRAIN_BYTES) \
473473
declare_constant(CodeInstaller::INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED) \
474+
declare_constant(CodeInstaller::DEOPT_MH_HANDLER_ENTRY) \
474475
declare_constant(CodeInstaller::INVOKE_INVALID) \
475476
\
477+
declare_constant(vmIntrinsics::FIRST_MH_SIG_POLY) \
478+
declare_constant(vmIntrinsics::LAST_MH_SIG_POLY) \
479+
declare_constant(vmIntrinsics::_invokeGeneric) \
480+
declare_constant(vmIntrinsics::_compiledLambdaForm) \
481+
\
476482
declare_constant(CollectedHeap::Serial) \
477483
declare_constant(CollectedHeap::Parallel) \
478484
declare_constant(CollectedHeap::G1) \
@@ -966,4 +972,3 @@ void jvmci_vmStructs_init() {
966972
JVMCIVMStructs::init();
967973
}
968974
#endif // ASSERT
969-

0 commit comments

Comments
 (0)
Please sign in to comment.