提交 edafa3be 编写于 作者: T twisti

7085404: JSR 292: VolatileCallSites should have push notification too

Reviewed-by: never, kvn
上级 7689f3c9
...@@ -3744,26 +3744,20 @@ bool GraphBuilder::for_invokedynamic_inline(ciMethod* callee) { ...@@ -3744,26 +3744,20 @@ bool GraphBuilder::for_invokedynamic_inline(ciMethod* callee) {
ciCallSite* call_site = stream()->get_call_site(); ciCallSite* call_site = stream()->get_call_site();
ciMethodHandle* method_handle = call_site->get_target(); ciMethodHandle* method_handle = call_site->get_target();
// Inline constant and mutable call sites. We don't inline // Set the callee to have access to the class and signature in the
// volatile call sites optimistically since they are specified // MethodHandleCompiler.
// to change their value often and that would result in a lot of method_handle->set_callee(callee);
// deoptimizations and recompiles. method_handle->set_caller(method());
if (call_site->is_constant_call_site() || call_site->is_mutable_call_site()) {
// Set the callee to have access to the class and signature in the // Get an adapter for the MethodHandle.
// MethodHandleCompiler. ciMethod* method_handle_adapter = method_handle->get_invokedynamic_adapter();
method_handle->set_callee(callee); if (method_handle_adapter != NULL) {
method_handle->set_caller(method()); if (try_inline(method_handle_adapter, /*holder_known=*/ true)) {
// Add a dependence for invalidation of the optimization.
// Get an adapter for the MethodHandle. if (!call_site->is_constant_call_site()) {
ciMethod* method_handle_adapter = method_handle->get_invokedynamic_adapter(); dependency_recorder()->assert_call_site_target_value(call_site, method_handle);
if (method_handle_adapter != NULL) {
if (try_inline(method_handle_adapter, /*holder_known=*/ true)) {
// Add a dependence for invalidation of the optimization.
if (!call_site->is_constant_call_site()) {
dependency_recorder()->assert_call_site_target_value(call_site, method_handle);
}
return true;
} }
return true;
} }
} }
return false; return false;
......
...@@ -175,7 +175,9 @@ public: ...@@ -175,7 +175,9 @@ public:
bool is_volatile () { return flags().is_volatile(); } bool is_volatile () { return flags().is_volatile(); }
bool is_transient () { return flags().is_transient(); } bool is_transient () { return flags().is_transient(); }
bool is_call_site_target() { return ((holder() == CURRENT_ENV->CallSite_klass()) && (name() == ciSymbol::target_name())); } bool is_call_site_target() {
return (holder()->is_subclass_of(CURRENT_ENV->CallSite_klass()) && (name() == ciSymbol::target_name()));
}
// Debugging output // Debugging output
void print(); void print();
......
...@@ -555,7 +555,7 @@ IRT_ENTRY(void, InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecode ...@@ -555,7 +555,7 @@ IRT_ENTRY(void, InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecode
assert(method_handle->is_a(SystemDictionary::MethodHandle_klass()), "must be"); assert(method_handle->is_a(SystemDictionary::MethodHandle_klass()), "must be");
{ {
// Walk all nmethods depending on CallSite // Walk all nmethods depending on this call site.
MutexLocker mu(Compile_lock, thread); MutexLocker mu(Compile_lock, thread);
Universe::flush_dependents_on(call_site, method_handle); Universe::flush_dependents_on(call_site, method_handle);
} }
......
...@@ -726,7 +726,6 @@ CallGenerator* CallGenerator::for_method_handle_inline(Node* method_handle, JVMS ...@@ -726,7 +726,6 @@ CallGenerator* CallGenerator::for_method_handle_inline(Node* method_handle, JVMS
CallGenerator* CallGenerator::for_invokedynamic_inline(ciCallSite* call_site, JVMState* jvms, CallGenerator* CallGenerator::for_invokedynamic_inline(ciCallSite* call_site, JVMState* jvms,
ciMethod* caller, ciMethod* callee, ciCallProfile profile) { ciMethod* caller, ciMethod* callee, ciCallProfile profile) {
assert(call_site->is_constant_call_site() || call_site->is_mutable_call_site(), "must be");
ciMethodHandle* method_handle = call_site->get_target(); ciMethodHandle* method_handle = call_site->get_target();
// Set the callee to have access to the class and signature in the // Set the callee to have access to the class and signature in the
...@@ -742,7 +741,7 @@ CallGenerator* CallGenerator::for_invokedynamic_inline(ciCallSite* call_site, JV ...@@ -742,7 +741,7 @@ CallGenerator* CallGenerator::for_invokedynamic_inline(ciCallSite* call_site, JV
CallGenerator* cg = C->call_generator(target_method, -1, false, jvms, true, PROB_ALWAYS); CallGenerator* cg = C->call_generator(target_method, -1, false, jvms, true, PROB_ALWAYS);
if (cg != NULL && cg->is_inline()) { if (cg != NULL && cg->is_inline()) {
// Add a dependence for invalidation of the optimization. // Add a dependence for invalidation of the optimization.
if (call_site->is_mutable_call_site()) { if (!call_site->is_constant_call_site()) {
C->dependencies()->assert_call_site_target_value(call_site, method_handle); C->dependencies()->assert_call_site_target_value(call_site, method_handle);
} }
return cg; return cg;
......
...@@ -136,15 +136,9 @@ CallGenerator* Compile::call_generator(ciMethod* call_method, int vtable_index, ...@@ -136,15 +136,9 @@ CallGenerator* Compile::call_generator(ciMethod* call_method, int vtable_index,
str.force_bci(jvms->bci()); // Set the stream to the invokedynamic bci. str.force_bci(jvms->bci()); // Set the stream to the invokedynamic bci.
ciCallSite* call_site = str.get_call_site(); ciCallSite* call_site = str.get_call_site();
// Inline constant and mutable call sites. We don't inline CallGenerator* cg = CallGenerator::for_invokedynamic_inline(call_site, jvms, caller, call_method, profile);
// volatile call sites optimistically since they are specified if (cg != NULL) {
// to change their value often and that would result in a lot of return cg;
// deoptimizations and recompiles.
if (call_site->is_constant_call_site() || call_site->is_mutable_call_site()) {
CallGenerator* cg = CallGenerator::for_invokedynamic_inline(call_site, jvms, caller, call_method, profile);
if (cg != NULL) {
return cg;
}
} }
// If something failed, generate a normal dynamic call. // If something failed, generate a normal dynamic call.
return CallGenerator::for_dynamic_call(call_method); return CallGenerator::for_dynamic_call(call_method);
......
...@@ -100,11 +100,11 @@ void Parse::do_field_access(bool is_get, bool is_field) { ...@@ -100,11 +100,11 @@ void Parse::do_field_access(bool is_get, bool is_field) {
} }
} }
// Deoptimize on putfield writes to CallSite.target // Deoptimize on putfield writes to call site target field.
if (!is_get && field->is_call_site_target()) { if (!is_get && field->is_call_site_target()) {
uncommon_trap(Deoptimization::Reason_unhandled, uncommon_trap(Deoptimization::Reason_unhandled,
Deoptimization::Action_reinterpret, Deoptimization::Action_reinterpret,
NULL, "put to CallSite.target field"); NULL, "put to call site target field");
return; return;
} }
......
...@@ -302,6 +302,19 @@ UNSAFE_ENTRY(void, Unsafe_SetObjectVolatile(JNIEnv *env, jobject unsafe, jobject ...@@ -302,6 +302,19 @@ UNSAFE_ENTRY(void, Unsafe_SetObjectVolatile(JNIEnv *env, jobject unsafe, jobject
UnsafeWrapper("Unsafe_SetObjectVolatile"); UnsafeWrapper("Unsafe_SetObjectVolatile");
oop x = JNIHandles::resolve(x_h); oop x = JNIHandles::resolve(x_h);
oop p = JNIHandles::resolve(obj); oop p = JNIHandles::resolve(obj);
// Catch VolatileCallSite.target stores (via
// CallSite.setTargetVolatile) and check call site dependencies.
if ((offset == java_lang_invoke_CallSite::target_offset_in_bytes()) && p->is_a(SystemDictionary::CallSite_klass())) {
oop call_site = p;
oop method_handle = x;
assert(call_site ->is_a(SystemDictionary::CallSite_klass()), "must be");
assert(method_handle->is_a(SystemDictionary::MethodHandle_klass()), "must be");
{
// Walk all nmethods depending on this call site.
MutexLocker mu(Compile_lock, thread);
Universe::flush_dependents_on(call_site, method_handle);
}
}
void* addr = index_oop_from_field_offset_long(p, offset); void* addr = index_oop_from_field_offset_long(p, offset);
OrderAccess::release(); OrderAccess::release();
if (UseCompressedOops) { if (UseCompressedOops) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册