changeset 321:2df08f4c531d

8015796: Race condition in RuntimeCallsites Reviewed-by: lagergren, attila Contributed-by: james.laskey@oracle.com
author jlaskey
date Mon, 03 Jun 2013 11:16:33 -0300
parents 08a8fda6c0bf
children 0946c8a60f39
files src/jdk/nashorn/internal/codegen/RuntimeCallSite.java
diffstat 1 files changed, 4 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java	Mon Jun 03 08:34:29 2013 -0300
+++ b/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;