Skip to content

Commit b2b4ee2

Browse files
pronpchilano
authored andcommitted
8287233: Crash in Continuation.enterSpecial: stop: tried to execute native method as non-native
Reviewed-by: dholmes, pchilanomate
1 parent 168b226 commit b2b4ee2

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/hotspot/share/interpreter/linkResolver.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,12 +1086,11 @@ void LinkResolver::resolve_static_call(CallInfo& result,
10861086
resolved_method = linktime_resolve_static_method(new_info, CHECK);
10871087
}
10881088

1089-
if (resolved_method->is_continuation_enter_intrinsic()) {
1090-
if (!resolved_method->has_compiled_code()) {
1091-
methodHandle mh(THREAD, resolved_method);
1092-
// Generate a compiled form of the enterSpecial intrinsic.
1093-
AdapterHandlerLibrary::create_native_wrapper(mh);
1094-
}
1089+
if (resolved_method->is_continuation_enter_intrinsic()
1090+
&& resolved_method->from_interpreted_entry() == NULL) { // does a load_acquire
1091+
methodHandle mh(THREAD, resolved_method);
1092+
// Generate a compiled form of the enterSpecial intrinsic.
1093+
AdapterHandlerLibrary::create_native_wrapper(mh);
10951094
}
10961095

10971096
// setup result

src/hotspot/share/oops/method.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,12 @@ void Method::link_method(const methodHandle& h_method, TRAPS) {
12361236
(void) make_adapters(h_method, CHECK);
12371237

12381238
// ONLY USE the h_method now as make_adapter may have blocked
1239+
1240+
if (h_method->is_continuation_enter_intrinsic()) {
1241+
// the entry points to this method will be set in set_code, called when first resolving this method
1242+
_from_interpreted_entry = NULL;
1243+
_from_compiled_entry = NULL;
1244+
}
12391245
}
12401246

12411247
address Method::make_adapters(const methodHandle& mh, TRAPS) {
@@ -1317,12 +1323,16 @@ void Method::set_code(const methodHandle& mh, CompiledMethod *code) {
13171323
OrderAccess::storestore();
13181324
mh->_from_compiled_entry = code->verified_entry_point();
13191325
OrderAccess::storestore();
1320-
// Instantly compiled code can execute.
1321-
if (!mh->is_method_handle_intrinsic())
1322-
mh->_from_interpreted_entry = mh->get_i2c_entry();
1326+
13231327
if (mh->is_continuation_enter_intrinsic()) {
1324-
// this is the entry used when we're in interpreter-only mode; see InterpreterMacroAssembler::jump_from_interpreted
1328+
assert(mh->_from_interpreted_entry == NULL, "initialized incorrectly"); // see link_method
1329+
1330+
// This is the entry used when we're in interpreter-only mode; see InterpreterMacroAssembler::jump_from_interpreted
13251331
mh->_i2i_entry = mh->get_i2c_entry();
1332+
// This must come last, as it is what's tested in LinkResolver::resolve_static_call
1333+
Atomic::release_store(&mh->_from_interpreted_entry , mh->get_i2c_entry());
1334+
} else if (!mh->is_method_handle_intrinsic()) {
1335+
// Instantly compiled code can execute.
13261336
mh->_from_interpreted_entry = mh->get_i2c_entry();
13271337
}
13281338
}

0 commit comments

Comments
 (0)