8015796: Race condition in RuntimeCallsites
authorjlaskey
Mon, 03 Jun 2013 11:16:33 -0300
changeset 17975 2fd9facd0169
parent 17974 a2818f17324e
child 17976 5615a31822a1
8015796: Race condition in RuntimeCallsites Reviewed-by: lagergren, attila Contributed-by: james.laskey@oracle.com
nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java
--- a/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java	Mon Jun 03 08:34:29 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java	Mon Jun 03 11:16:33 2013 -0300
@@ -59,12 +59,10 @@
 public final class RuntimeCallSite extends MutableCallSite {
     static final Call BOOTSTRAP = staticCallNoLookup(Bootstrap.class, "runtimeBootstrap", CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class);
 
-    private static final MethodHandle NEXT = findOwnMH("next",  MethodHandle.class);
+    private static final MethodHandle NEXT = findOwnMH("next",  MethodHandle.class, String.class);
 
     private final RuntimeNode.Request request;
 
-    private String name;
-
     /**
      * A specialized runtime node, i.e. on where we know at least one more specific type than object
      */
@@ -203,7 +201,6 @@
      */
     public RuntimeCallSite(final MethodType type, final String name) {
         super(type);
-        this.name    = name;
         this.request = Request.valueOf(name.substring(0, name.indexOf(SpecializedRuntimeNode.REQUEST_SEPARATOR)));
         setTarget(makeMethod(name));
     }
@@ -292,7 +289,7 @@
                 mh = MH.explicitCastArguments(mh, type());
             }
 
-            final MethodHandle fallback = MH.foldArguments(MethodHandles.exactInvoker(type()), MH.bindTo(NEXT, this));
+            final MethodHandle fallback = MH.foldArguments(MethodHandles.exactInvoker(type()), MH.insertArguments(NEXT, 0, this, requestName));
 
             MethodHandle guard;
             if (type().parameterType(0).isPrimitive()) {
@@ -338,18 +335,12 @@
      *
      * @return next wider specialization method for this RuntimeCallSite
      */
-    public MethodHandle next() {
-        this.name = nextName(name);
-        final MethodHandle next = makeMethod(name);
+   public MethodHandle next(final String name) {
+        final MethodHandle next = makeMethod(nextName(name));
         setTarget(next);
         return next;
     }
 
-    @Override
-    public String toString() {
-        return super.toString() + " " + name;
-    }
-
     /** Method cache */
     private static final Map<String, MethodHandle> METHODS;