diff src/share/vm/prims/unsafe.cpp @ 3901:aa67216400d3

7085404: JSR 292: VolatileCallSites should have push notification too Reviewed-by: never, kvn
author twisti
date Fri, 02 Sep 2011 00:36:18 -0700
parents 19241ae0d839
children e6b1331a51d2
line wrap: on
line diff
--- a/src/share/vm/prims/unsafe.cpp	Thu Sep 01 01:31:25 2011 -0700
+++ b/src/share/vm/prims/unsafe.cpp	Fri Sep 02 00:36:18 2011 -0700
@@ -302,6 +302,19 @@
   UnsafeWrapper("Unsafe_SetObjectVolatile");
   oop x = JNIHandles::resolve(x_h);
   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);
   OrderAccess::release();
   if (UseCompressedOops) {