hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
changeset 7411 afcfb75ccae1
parent 7397 5b173b4ca846
child 7913 dd096a83bdbb
child 7889 02144432d0e1
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Thu Dec 02 05:45:54 2010 -0800
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Sat Dec 04 00:09:05 2010 -0500
@@ -1193,9 +1193,20 @@
       method->set_signature_handler(_handlers->at(handler_index));
     }
   }
+#ifdef ASSERT
+  int handler_index, fingerprint_index;
+  {
+    // '_handlers' and '_fingerprints' are 'GrowableArray's and are NOT synchronized
+    // in any way if accessed from multiple threads. To avoid races with another
+    // thread which may change the arrays in the above, mutex protected block, we
+    // have to protect this read access here with the same mutex as well!
+    MutexLocker mu(SignatureHandlerLibrary_lock);
+    handler_index = _handlers->find(method->signature_handler());
+    fingerprint_index = _fingerprints->find(Fingerprinter(method).fingerprint());
+  }
   assert(method->signature_handler() == Interpreter::slow_signature_handler() ||
-         _handlers->find(method->signature_handler()) == _fingerprints->find(Fingerprinter(method).fingerprint()),
-         "sanity check");
+         handler_index == fingerprint_index, "sanity check");
+#endif
 }