8011578: -Dnashorn.unstable.relink.threshold=1 causes tests to fail.

Sat, 20 Apr 2013 08:54:13 -0300

author
jlaskey
date
Sat, 20 Apr 2013 08:54:13 -0300
changeset 212
e599a1cad89a
parent 211
3a209cbd1d8f
child 213
ead94bc57939

8011578: -Dnashorn.unstable.relink.threshold=1 causes tests to fail.
Reviewed-by: sundar, lagergren
Contributed-by: james.laskey@oracle.com

src/jdk/nashorn/internal/runtime/FindProperty.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/ScriptObject.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/WithObject.java file | annotate | diff | comparison | revisions
test/script/basic/JDK-8011578.js file | annotate | diff | comparison | revisions
test/script/basic/JDK-8011578.js.EXPECTED file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/internal/runtime/FindProperty.java	Fri Apr 19 16:11:16 2013 +0200
     1.2 +++ b/src/jdk/nashorn/internal/runtime/FindProperty.java	Sat Apr 20 08:54:13 2013 -0300
     1.3 @@ -105,6 +105,22 @@
     1.4      }
     1.5  
     1.6      /**
     1.7 +     * Return the appropriate receiver for a getter.
     1.8 +     * @return appropriate receiver
     1.9 +     */
    1.10 +    public ScriptObject getGetterReceiver() {
    1.11 +        return property != null && property.hasGetterFunction() ? self : prototype;
    1.12 +    }
    1.13 +
    1.14 +   /**
    1.15 +     * Return the appropriate receiver for a setter.
    1.16 +     * @return appropriate receiver
    1.17 +     */
    1.18 +    public ScriptObject getSetterReceiver() {
    1.19 +        return property != null && property.hasSetterFunction() ? self : prototype;
    1.20 +    }
    1.21 +
    1.22 +    /**
    1.23       * Return the property that was found
    1.24       * @return property
    1.25       */
     2.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java	Fri Apr 19 16:11:16 2013 +0200
     2.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java	Sat Apr 20 08:54:13 2013 -0300
     2.3 @@ -901,7 +901,7 @@
     2.4          final MethodHandle getter = find.getGetter(int.class);
     2.5          if (getter != null) {
     2.6              try {
     2.7 -                return (int)getter.invokeExact((Object)find.getOwner());
     2.8 +                return (int)getter.invokeExact((Object)find.getGetterReceiver());
     2.9              } catch (final Error|RuntimeException e) {
    2.10                  throw e;
    2.11              } catch (final Throwable e) {
    2.12 @@ -916,7 +916,7 @@
    2.13          final MethodHandle getter = find.getGetter(long.class);
    2.14          if (getter != null) {
    2.15              try {
    2.16 -                return (long)getter.invokeExact((Object)find.getOwner());
    2.17 +                return (long)getter.invokeExact((Object)find.getGetterReceiver());
    2.18              } catch (final Error|RuntimeException e) {
    2.19                  throw e;
    2.20              } catch (final Throwable e) {
    2.21 @@ -931,7 +931,7 @@
    2.22          final MethodHandle getter = find.getGetter(double.class);
    2.23          if (getter != null) {
    2.24              try {
    2.25 -                return (double)getter.invokeExact((Object)find.getOwner());
    2.26 +                return (double)getter.invokeExact((Object)find.getGetterReceiver());
    2.27              } catch (final Error|RuntimeException e) {
    2.28                  throw e;
    2.29              } catch (final Throwable e) {
    2.30 @@ -953,7 +953,7 @@
    2.31          final MethodHandle getter = find.getGetter(Object.class);
    2.32          if (getter != null) {
    2.33              try {
    2.34 -                return getter.invokeExact((Object)find.getOwner());
    2.35 +                return getter.invokeExact((Object)find.getGetterReceiver());
    2.36              } catch (final Error|RuntimeException e) {
    2.37                  throw e;
    2.38              } catch (final Throwable e) {
    2.39 @@ -1679,12 +1679,7 @@
    2.40       * @return GuardedInvocation to be invoked at call site.
    2.41       */
    2.42      protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) {
    2.43 -        final String name = desc.getNameToken(2);
    2.44 -
    2.45 -        if (request.isCallSiteUnstable()) {
    2.46 -            return findMegaMorphicGetMethod(desc, name);
    2.47 -        }
    2.48 -
    2.49 +        final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
    2.50          final FindProperty find = findProperty(name, true);
    2.51  
    2.52          MethodHandle methodHandle;
    2.53 @@ -1700,6 +1695,10 @@
    2.54              throw new AssertionError(); // never invoked with any other operation
    2.55          }
    2.56  
    2.57 +        if (request.isCallSiteUnstable()) {
    2.58 +            return findMegaMorphicGetMethod(desc, name);
    2.59 +        }
    2.60 +
    2.61          final Class<?> returnType = desc.getMethodType().returnType();
    2.62          final Property property = find.getProperty();
    2.63          methodHandle = find.getGetter(returnType);
    2.64 @@ -1727,7 +1726,9 @@
    2.65      }
    2.66  
    2.67      private static GuardedInvocation findMegaMorphicGetMethod(final CallSiteDescriptor desc, final String name) {
    2.68 -        final GuardedInvocation inv = findGetIndexMethod(desc.getMethodType().insertParameterTypes(1, Object.class));
    2.69 +        final MethodType mhType = desc.getMethodType().insertParameterTypes(1, Object.class);
    2.70 +        final GuardedInvocation inv = findGetIndexMethod(mhType);
    2.71 +
    2.72          return inv.replaceMethods(MH.insertArguments(inv.getInvocation(), 1, name), inv.getGuard());
    2.73      }
    2.74  
    2.75 @@ -1890,8 +1891,8 @@
    2.76      }
    2.77  
    2.78      private static GuardedInvocation findMegaMorphicSetMethod(final CallSiteDescriptor desc, final String name) {
    2.79 -        final GuardedInvocation inv = findSetIndexMethod(desc.getMethodType().insertParameterTypes(1, Object.class),
    2.80 -                NashornCallSiteDescriptor.isStrict(desc));
    2.81 +        final MethodType type = desc.getMethodType().insertParameterTypes(1, Object.class);
    2.82 +        final GuardedInvocation inv = findSetIndexMethod(type, NashornCallSiteDescriptor.isStrict(desc)).asType(type);
    2.83          return inv.replaceMethods(MH.insertArguments(inv.getInvocation(), 1, name), inv.getGuard());
    2.84      }
    2.85  
    2.86 @@ -1949,7 +1950,7 @@
    2.87       * @return GuardedInvocation to be invoked at call site.
    2.88       */
    2.89      public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) {
    2.90 -        final String name = desc.getNameToken(2);
    2.91 +        final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
    2.92          final FindProperty find = findProperty(NO_SUCH_PROPERTY_NAME, true);
    2.93          final boolean scopeAccess = isScope() && NashornCallSiteDescriptor.isScope(desc);
    2.94  
    2.95 @@ -1973,6 +1974,24 @@
    2.96  
    2.97          return createEmptyGetter(desc, name);
    2.98      }
    2.99 +    /**
   2.100 +     * Invoke fall back if a property is not found.
   2.101 +     * @param name Name of property.
   2.102 +     * @return Result from call.
   2.103 +     */
   2.104 +    private Object invokeNoSuchProperty(final String name) {
   2.105 +        final FindProperty find = findProperty(NO_SUCH_PROPERTY_NAME, true);
   2.106 +
   2.107 +        if (find != null) {
   2.108 +            final Object func = getObjectValue(find);
   2.109 +
   2.110 +            if (func instanceof ScriptFunction) {
   2.111 +                return ScriptRuntime.apply((ScriptFunction)func, this, name);
   2.112 +            }
   2.113 +        }
   2.114 +
   2.115 +        return UNDEFINED;
   2.116 +    }
   2.117  
   2.118      private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final String name) {
   2.119          return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()), getMap().getProtoGetSwitchPoint(name), NashornGuards.getMapGuard(getMap()));
   2.120 @@ -2239,310 +2258,158 @@
   2.121             setArray(getArray().shrink(newLength));
   2.122             getArray().setLength(newLength);
   2.123         }
   2.124 -   }
   2.125 +    }
   2.126 +
   2.127 +    private int getInt(final int index, final String key) {
   2.128 +        for (ScriptObject object = this; object != null; object = object.getProto()) {
   2.129 +            final ArrayData array = object.getArray();
   2.130 +
   2.131 +            if (array.has(index)) {
   2.132 +                return array.getInt(index);
   2.133 +            }
   2.134 +
   2.135 +            final FindProperty find = object.findProperty(key, false);
   2.136 +
   2.137 +            if (find != null) {
   2.138 +                return getIntValue(new FindProperty(this, find.getOwner(), find.getProperty()));
   2.139 +            }
   2.140 +        }
   2.141 +
   2.142 +        return JSType.toInt32(invokeNoSuchProperty(key));
   2.143 +    }
   2.144  
   2.145      @Override
   2.146      public int getInt(final Object key) {
   2.147 -        final int index = getArrayIndexNoThrow(key);
   2.148 -
   2.149 -        if (getArray().has(index)) {
   2.150 -            return getArray().getInt(index);
   2.151 -        }
   2.152 -
   2.153 -        final FindProperty find = findProperty(convertKey(key), false);
   2.154 -
   2.155 -        if (find != null) {
   2.156 -            return getIntValue(find);
   2.157 -        }
   2.158 -
   2.159 -        final ScriptObject proto = this.getProto();
   2.160 -
   2.161 -        return proto != null ? proto.getInt(key) : 0;
   2.162 +        return getInt(getArrayIndexNoThrow(key), convertKey(key));
   2.163      }
   2.164  
   2.165      @Override
   2.166      public int getInt(final double key) {
   2.167 -        final int index = getArrayIndexNoThrow(key);
   2.168 -
   2.169 -        if (getArray().has(index)) {
   2.170 -            return getArray().getInt(index);
   2.171 -        }
   2.172 -
   2.173 -        final FindProperty find = findProperty(convertKey(key), false);
   2.174 -
   2.175 -        if (find != null) {
   2.176 -            return getIntValue(find);
   2.177 -        }
   2.178 -
   2.179 -        final ScriptObject proto = this.getProto();
   2.180 -
   2.181 -        return proto != null ? proto.getInt(key) : 0;
   2.182 +        return getInt(getArrayIndexNoThrow(key), convertKey(key));
   2.183      }
   2.184  
   2.185      @Override
   2.186      public int getInt(final long key) {
   2.187 -        final int index = getArrayIndexNoThrow(key);
   2.188 -
   2.189 -        if (getArray().has(index)) {
   2.190 -            return getArray().getInt(index);
   2.191 -        }
   2.192 -
   2.193 -        final FindProperty find = findProperty(convertKey(key), false);
   2.194 -
   2.195 -        if (find != null) {
   2.196 -            return getIntValue(find);
   2.197 -        }
   2.198 -
   2.199 -        final ScriptObject proto = this.getProto();
   2.200 -
   2.201 -        return proto != null ? proto.getInt(key) : 0;
   2.202 +        return getInt(getArrayIndexNoThrow(key), convertKey(key));
   2.203      }
   2.204  
   2.205      @Override
   2.206      public int getInt(final int key) {
   2.207 -        final int index = getArrayIndexNoThrow(key);
   2.208 -
   2.209 -        if (getArray().has(index)) {
   2.210 -            return getArray().getInt(index);
   2.211 +        return getInt(getArrayIndexNoThrow(key), convertKey(key));
   2.212 +    }
   2.213 +
   2.214 +    private long getLong(final int index, final String key) {
   2.215 +        for (ScriptObject object = this; object != null; object = object.getProto()) {
   2.216 +            final ArrayData array = object.getArray();
   2.217 +
   2.218 +            if (array.has(index)) {
   2.219 +                return array.getLong(index);
   2.220 +            }
   2.221 +
   2.222 +            final FindProperty find = object.findProperty(key, false);
   2.223 +
   2.224 +            if (find != null) {
   2.225 +                return getLongValue(new FindProperty(this, find.getOwner(), find.getProperty()));
   2.226 +            }
   2.227          }
   2.228  
   2.229 -        final FindProperty find = findProperty(convertKey(key), false);
   2.230 -
   2.231 -        if (find != null) {
   2.232 -            return getIntValue(find);
   2.233 -        }
   2.234 -
   2.235 -        final ScriptObject proto = this.getProto();
   2.236 -
   2.237 -        return proto != null ? proto.getInt(key) : 0;
   2.238 +        return JSType.toLong(invokeNoSuchProperty(key));
   2.239      }
   2.240  
   2.241      @Override
   2.242      public long getLong(final Object key) {
   2.243 -        final int index = getArrayIndexNoThrow(key);
   2.244 -
   2.245 -        if (getArray().has(index)) {
   2.246 -            return getArray().getLong(index);
   2.247 -        }
   2.248 -
   2.249 -        final FindProperty find = findProperty(convertKey(key), false);
   2.250 -
   2.251 -        if (find != null) {
   2.252 -            return getLongValue(find);
   2.253 -        }
   2.254 -
   2.255 -        final ScriptObject proto = this.getProto();
   2.256 -
   2.257 -        return proto != null ? proto.getLong(key) : 0L;
   2.258 +        return getLong(getArrayIndexNoThrow(key), convertKey(key));
   2.259      }
   2.260  
   2.261      @Override
   2.262      public long getLong(final double key) {
   2.263 -        final int index = getArrayIndexNoThrow(key);
   2.264 -
   2.265 -        if (getArray().has(index)) {
   2.266 -            return getArray().getLong(index);
   2.267 -        }
   2.268 -
   2.269 -        final FindProperty find = findProperty(convertKey(key), false);
   2.270 -
   2.271 -        if (find != null) {
   2.272 -            return getLongValue(find);
   2.273 -        }
   2.274 -
   2.275 -        final ScriptObject proto = this.getProto();
   2.276 -
   2.277 -        return proto != null ? proto.getLong(key) : 0L;
   2.278 +        return getLong(getArrayIndexNoThrow(key), convertKey(key));
   2.279      }
   2.280  
   2.281      @Override
   2.282      public long getLong(final long key) {
   2.283 -        final int index = getArrayIndexNoThrow(key);
   2.284 -
   2.285 -        if (getArray().has(index)) {
   2.286 -            return getArray().getLong(index);
   2.287 -        }
   2.288 -
   2.289 -        final FindProperty find = findProperty(convertKey(key), false);
   2.290 -
   2.291 -        if (find != null) {
   2.292 -            return getLongValue(find);
   2.293 -        }
   2.294 -
   2.295 -        final ScriptObject proto = this.getProto();
   2.296 -
   2.297 -        return proto != null ? proto.getLong(key) : 0L;
   2.298 +        return getLong(getArrayIndexNoThrow(key), convertKey(key));
   2.299      }
   2.300  
   2.301      @Override
   2.302      public long getLong(final int key) {
   2.303 -        final int index = getArrayIndexNoThrow(key);
   2.304 -
   2.305 -        if (getArray().has(index)) {
   2.306 -            return getArray().getLong(index);
   2.307 +        return getLong(getArrayIndexNoThrow(key), convertKey(key));
   2.308 +    }
   2.309 +
   2.310 +    private double getDouble(final int index, final String key) {
   2.311 +        for (ScriptObject object = this; object != null; object = object.getProto()) {
   2.312 +            final ArrayData array = object.getArray();
   2.313 +
   2.314 +            if (array.has(index)) {
   2.315 +                return array.getDouble(index);
   2.316 +            }
   2.317 +
   2.318 +            final FindProperty find = object.findProperty(key, false);
   2.319 +
   2.320 +            if (find != null) {
   2.321 +                return getDoubleValue(new FindProperty(this, find.getOwner(), find.getProperty()));
   2.322 +            }
   2.323          }
   2.324  
   2.325 -        final FindProperty find = findProperty(convertKey(key), false);
   2.326 -
   2.327 -        if (find != null) {
   2.328 -            return getLongValue(find);
   2.329 -        }
   2.330 -
   2.331 -        final ScriptObject proto = this.getProto();
   2.332 -
   2.333 -        return proto != null ? proto.getLong(key) : 0L;
   2.334 +        return JSType.toNumber(invokeNoSuchProperty(key));
   2.335      }
   2.336  
   2.337      @Override
   2.338      public double getDouble(final Object key) {
   2.339 -        final int index = getArrayIndexNoThrow(key);
   2.340 -
   2.341 -        if (getArray().has(index)) {
   2.342 -            return getArray().getDouble(index);
   2.343 -        }
   2.344 -
   2.345 -        final FindProperty find = findProperty(convertKey(key), false);
   2.346 -
   2.347 -        if (find != null) {
   2.348 -            return getDoubleValue(find);
   2.349 -        }
   2.350 -
   2.351 -        final ScriptObject proto = this.getProto();
   2.352 -
   2.353 -        return proto != null ? proto.getDouble(key) : Double.NaN;
   2.354 +        return getDouble(getArrayIndexNoThrow(key), convertKey(key));
   2.355      }
   2.356  
   2.357      @Override
   2.358      public double getDouble(final double key) {
   2.359 -        final int index = getArrayIndexNoThrow(key);
   2.360 -
   2.361 -        if (getArray().has(index)) {
   2.362 -            return getArray().getDouble(index);
   2.363 -        }
   2.364 -
   2.365 -        final FindProperty find = findProperty(convertKey(key), false);
   2.366 -
   2.367 -        if (find != null) {
   2.368 -            return getDoubleValue(find);
   2.369 -        }
   2.370 -
   2.371 -        final ScriptObject proto = this.getProto();
   2.372 -
   2.373 -        return proto != null ? proto.getDouble(key) : Double.NaN;
   2.374 +        return getDouble(getArrayIndexNoThrow(key), convertKey(key));
   2.375      }
   2.376  
   2.377      @Override
   2.378      public double getDouble(final long key) {
   2.379 -        final int index = getArrayIndexNoThrow(key);
   2.380 -
   2.381 -        if (getArray().has(index)) {
   2.382 -            return getArray().getDouble(index);
   2.383 -        }
   2.384 -
   2.385 -        final FindProperty find = findProperty(convertKey(key), false);
   2.386 -
   2.387 -        if (find != null) {
   2.388 -            return getDoubleValue(find);
   2.389 -        }
   2.390 -
   2.391 -        final ScriptObject proto = this.getProto();
   2.392 -
   2.393 -        return proto != null ? proto.getDouble(key) : Double.NaN;
   2.394 +        return getDouble(getArrayIndexNoThrow(key), convertKey(key));
   2.395      }
   2.396  
   2.397      @Override
   2.398      public double getDouble(final int key) {
   2.399 -        final int index = getArrayIndexNoThrow(key);
   2.400 -
   2.401 -        if (getArray().has(index)) {
   2.402 -            return getArray().getDouble(index);
   2.403 +        return getDouble(getArrayIndexNoThrow(key), convertKey(key));
   2.404 +    }
   2.405 +
   2.406 +    private Object get(final int index, final String key) {
   2.407 +        for (ScriptObject object = this; object != null; object = object.getProto()) {
   2.408 +            final ArrayData array = object.getArray();
   2.409 +
   2.410 +            if (array.has(index)) {
   2.411 +                return array.getObject(index);
   2.412 +            }
   2.413 +
   2.414 +            final FindProperty find = object.findProperty(key, false);
   2.415 +
   2.416 +            if (find != null) {
   2.417 +                return getObjectValue(new FindProperty(this, find.getOwner(), find.getProperty()));
   2.418 +            }
   2.419          }
   2.420  
   2.421 -        final FindProperty find = findProperty(convertKey(key), false);
   2.422 -
   2.423 -        if (find != null) {
   2.424 -            return getDoubleValue(find);
   2.425 -        }
   2.426 -
   2.427 -        final ScriptObject proto = this.getProto();
   2.428 -
   2.429 -        return proto != null ? proto.getDouble(key) : Double.NaN;
   2.430 +        return invokeNoSuchProperty(key);
   2.431      }
   2.432  
   2.433      @Override
   2.434      public Object get(final Object key) {
   2.435 -        final int index = getArrayIndexNoThrow(key);
   2.436 -
   2.437 -        if (getArray().has(index)) {
   2.438 -            return getArray().getObject(index);
   2.439 -        }
   2.440 -
   2.441 -        final FindProperty find = findProperty(convertKey(key), false);
   2.442 -
   2.443 -        if (find != null) {
   2.444 -            return getObjectValue(find);
   2.445 -        }
   2.446 -
   2.447 -        final ScriptObject proto = this.getProto();
   2.448 -
   2.449 -        return proto != null ? proto.get(key) : UNDEFINED;
   2.450 +        return get(getArrayIndexNoThrow(key), convertKey(key));
   2.451      }
   2.452  
   2.453      @Override
   2.454      public Object get(final double key) {
   2.455 -        final int index = getArrayIndexNoThrow(key);
   2.456 -
   2.457 -        if (getArray().has(index)) {
   2.458 -            return getArray().getObject(index);
   2.459 -        }
   2.460 -
   2.461 -        final FindProperty find = findProperty(convertKey(key), false);
   2.462 -
   2.463 -        if (find != null) {
   2.464 -            return getObjectValue(find);
   2.465 -        }
   2.466 -
   2.467 -        final ScriptObject proto = this.getProto();
   2.468 -
   2.469 -        return proto != null ? proto.get(key) : UNDEFINED;
   2.470 +        return get(getArrayIndexNoThrow(key), convertKey(key));
   2.471      }
   2.472  
   2.473      @Override
   2.474      public Object get(final long key) {
   2.475 -        final int index = getArrayIndexNoThrow(key);
   2.476 -
   2.477 -        if (getArray().has(index)) {
   2.478 -            return getArray().getObject(index);
   2.479 -        }
   2.480 -
   2.481 -        final FindProperty find = findProperty(convertKey(key), false);
   2.482 -
   2.483 -        if (find != null) {
   2.484 -            return getObjectValue(find);
   2.485 -        }
   2.486 -
   2.487 -        final ScriptObject proto = this.getProto();
   2.488 -
   2.489 -        return proto != null ? proto.get(key) : UNDEFINED;
   2.490 +        return get(getArrayIndexNoThrow(key), convertKey(key));
   2.491      }
   2.492  
   2.493      @Override
   2.494      public Object get(final int key) {
   2.495 -        final int index = getArrayIndexNoThrow(key);
   2.496 -
   2.497 -        if (getArray().has(index)) {
   2.498 -            return getArray().getObject(index);
   2.499 -        }
   2.500 -
   2.501 -        final FindProperty find = findProperty(convertKey(key), false);
   2.502 -
   2.503 -        if (find != null) {
   2.504 -            return getObjectValue(find);
   2.505 -        }
   2.506 -
   2.507 -        final ScriptObject proto = this.getProto();
   2.508 -
   2.509 -        return proto != null ? proto.get(key) : UNDEFINED;
   2.510 +        return get(getArrayIndexNoThrow(key), convertKey(key));
   2.511      }
   2.512  
   2.513      /**
   2.514 @@ -2613,8 +2480,6 @@
   2.515              f = null;
   2.516          }
   2.517  
   2.518 -        MethodHandle setter;
   2.519 -
   2.520          if (f != null) {
   2.521              if (!f.getProperty().isWritable()) {
   2.522                  if (strict) {
   2.523 @@ -2624,9 +2489,9 @@
   2.524                  return;
   2.525              }
   2.526  
   2.527 -            setter = f.getSetter(Object.class, strict); //TODO specfields
   2.528              try {
   2.529 -                setter.invokeExact((Object)f.getOwner(), value);
   2.530 +                final MethodHandle setter = f.getSetter(Object.class, strict); //TODO specfields
   2.531 +                setter.invokeExact((Object)f.getSetterReceiver(), value);
   2.532              } catch (final Error|RuntimeException e) {
   2.533                  throw e;
   2.534              } catch (final Throwable e) {
     3.1 --- a/src/jdk/nashorn/internal/runtime/WithObject.java	Fri Apr 19 16:11:16 2013 +0200
     3.2 +++ b/src/jdk/nashorn/internal/runtime/WithObject.java	Sat Apr 20 08:54:13 2013 -0300
     3.3 @@ -252,7 +252,11 @@
     3.4      }
     3.5  
     3.6      private static GuardedInvocation fixScopeCallSite(final GuardedInvocation link) {
     3.7 -        return link.replaceMethods(filter(link.getInvocation(), WITHSCOPEFILTER), filterGuard(link, WITHSCOPEFILTER));
     3.8 +        // The receiver may be an object or a ScriptObject.
     3.9 +        final MethodType invType = link.getInvocation().type();
    3.10 +        final MethodType newInvType = invType.changeParameterType(0, WITHSCOPEFILTER.type().returnType());
    3.11 +        final GuardedInvocation newLink = link.asType(newInvType);
    3.12 +        return link.replaceMethods(filter(newLink.getInvocation(), WITHSCOPEFILTER), filterGuard(newLink, WITHSCOPEFILTER));
    3.13      }
    3.14  
    3.15      private static MethodHandle filterGuard(final GuardedInvocation link, final MethodHandle filter) {
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/script/basic/JDK-8011578.js	Sat Apr 20 08:54:13 2013 -0300
     4.3 @@ -0,0 +1,42 @@
     4.4 +/*
     4.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + * 
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.
    4.11 + * 
    4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.15 + * version 2 for more details (a copy is included in the LICENSE file that
    4.16 + * accompanied this code).
    4.17 + * 
    4.18 + * You should have received a copy of the GNU General Public License version
    4.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.21 + * 
    4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    4.23 + * or visit www.oracle.com if you need additional information or have any
    4.24 + * questions.
    4.25 + */
    4.26 +
    4.27 +/**
    4.28 + * JDK-8011578 : -Dnashorn.unstable.relink.threshold=1 causes tests to fail.
    4.29 + *
    4.30 + * @test
    4.31 + * @option -Dnashorn.unstable.relink.threshold=1
    4.32 + * @run
    4.33 + */
    4.34 +
    4.35 +load(__DIR__ + "NASHORN-296.js");
    4.36 +load(__DIR__ + "NASHORN-691.js");
    4.37 +load(__DIR__ + "calllink.js");
    4.38 +load(__DIR__ + "nosuchproperty.js");
    4.39 +
    4.40 +__noSuchProperty__ = function(x) {
    4.41 +    print(x);
    4.42 +    return x;
    4.43 +}
    4.44 +
    4.45 +print(this["find"]);
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/script/basic/JDK-8011578.js.EXPECTED	Sat Apr 20 08:54:13 2013 -0300
     5.3 @@ -0,0 +1,22 @@
     5.4 +o.foo = 33
     5.5 +o.foo = 44
     5.6 +o.foo = 3
     5.7 +o.foo = hello
     5.8 +obj1.func called
     5.9 +obj2.func called
    5.10 +no such method: func
    5.11 +obj4's prototype func called
    5.12 +MyConstructor.prototype.func
    5.13 +MyConstructor.prototype.func
    5.14 +obj1.func called
    5.15 +obj2.func called
    5.16 +new obj3.func called
    5.17 +new obj4.func called
    5.18 +all new MyConstructor.prototype.func
    5.19 +all new MyConstructor.prototype.func
    5.20 +obj.__noSuchProperty__ for foo
    5.21 +new obj.__noSuchProperty__ for foo
    5.22 +proto.__noSuchProperty__ for foo
    5.23 +new proto.__noSuchProperty__ for foo
    5.24 +find
    5.25 +find

mercurial