[9] RFR (XS): C2: continuous CallSite relinkage eventually disables compilation for a method

John Rose john.r.rose at oracle.com
Thu Jan 26 23:05:54 UTC 2017


On Jan 26, 2017, at 12:44 PM, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote:
> 
> What about moving the check to nmethod::make_not_entrant()?
> 
> http://cr.openjdk.java.net/~vlivanov/8173338/webrev.01

Looks good.

Suggest renaming _failure_inc_decompile_count to _inc_decompile_count_on_failure
so you can just remove the explanatory comment in ciEnv.hpp.

I prefer the .01 version with the pre-lock check in make_not_entrant.

Actually it would be even cleaner to put the pre-lock check in
the same method that uses the lock, make_not_entrant_or_zombie.

diff --git a/src/share/vm/code/nmethod.cpp b/src/share/vm/code/nmethod.cpp
--- a/src/share/vm/code/nmethod.cpp
+++ b/src/share/vm/code/nmethod.cpp
@@ -1146,6 +1146,14 @@
   assert(state == zombie || state == not_entrant, "must be zombie or not_entrant");
   assert(!is_zombie(), "should not already be a zombie");
 
+  if (_state == state) {
+    // Avoid taking the lock if already in required state.
+    // This is safe from races because the state is an end-state,
+    // which the nmethod cannot back out of once entered.
+    // No need for fencing either.
+    return false;
+  }
+
   // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below.
   nmethodLocker nml(this);
   methodHandle the_method(method());



More information about the hotspot-compiler-dev mailing list