8007215: Varargs broken for the case of passing more than the arg limit arguments.

Mon, 04 Feb 2013 16:20:05 +0100

author
lagergren
date
Mon, 04 Feb 2013 16:20:05 +0100
changeset 66
bee7c8a45a04
parent 65
bb86bf840f9f
child 67
6f58c28c4faa

8007215: Varargs broken for the case of passing more than the arg limit arguments.
Reviewed-by: jlaskey, attila

src/jdk/nashorn/api/scripting/NashornException.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/api/scripting/NashornScriptEngine.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/CodeGenerator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/FunctionSignature.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/MethodEmitter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/RuntimeCallSite.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/SharedScopeCall.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/Global.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/ECMAException.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/ScriptFunction.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/ScriptObject.java file | annotate | diff | comparison | revisions
test/script/basic/JDK-8007215.js file | annotate | diff | comparison | revisions
test/script/basic/JDK-8007215.js.EXPECTED file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/api/scripting/NashornException.java	Mon Feb 04 15:59:44 2013 +0100
     1.2 +++ b/src/jdk/nashorn/api/scripting/NashornException.java	Mon Feb 04 16:20:05 2013 +0100
     1.3 @@ -44,7 +44,7 @@
     1.4      // script column number
     1.5      private int         column;
     1.6  
     1.7 -    // script source name used for "engine.js"
     1.8 +    /** script source name used for "engine.js" */
     1.9      protected static final String ENGINE_SCRIPT_SOURCE_NAME = "nashorn:engine/resources/engine.js";
    1.10  
    1.11      /**
     2.1 --- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Mon Feb 04 15:59:44 2013 +0100
     2.2 +++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Mon Feb 04 16:20:05 2013 +0100
     2.3 @@ -26,7 +26,6 @@
     2.4  package jdk.nashorn.api.scripting;
     2.5  
     2.6  import static jdk.nashorn.internal.runtime.ECMAErrors.referenceError;
     2.7 -import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
     2.8  import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
     2.9  
    2.10  import java.io.IOException;
     3.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Mon Feb 04 15:59:44 2013 +0100
     3.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Mon Feb 04 16:20:05 2013 +0100
     3.3 @@ -490,15 +490,15 @@
     3.4          return null;
     3.5      }
     3.6  
     3.7 -    private MethodEmitter loadArgs(final List<Node> args) {
     3.8 +    private int loadArgs(final List<Node> args) {
     3.9          return loadArgs(args, null, false, args.size());
    3.10      }
    3.11  
    3.12 -    private MethodEmitter loadArgs(final List<Node> args, final String signature, final boolean isVarArg, final int argCount) {
    3.13 +    private int loadArgs(final List<Node> args, final String signature, final boolean isVarArg, final int argCount) {
    3.14          // arg have already been converted to objects here.
    3.15          if (isVarArg || argCount > LinkerCallSite.ARGLIMIT) {
    3.16              loadArgsArray(args);
    3.17 -            return method;
    3.18 +            return 1;
    3.19          }
    3.20  
    3.21          // pad with undefined if size is too short. argCount is the real number of args
    3.22 @@ -520,7 +520,7 @@
    3.23              n++;
    3.24          }
    3.25  
    3.26 -        return method;
    3.27 +        return argCount;
    3.28      }
    3.29  
    3.30      @Override
    3.31 @@ -556,9 +556,8 @@
    3.32                  load(node);
    3.33                  method.convert(Type.OBJECT); // foo() makes no sense if foo == 3
    3.34                  // ScriptFunction will see CALLSITE_SCOPE and will bind scope accordingly.
    3.35 -                method.loadNull();
    3.36 -                loadArgs(args);
    3.37 -                method.dynamicCall(callNode.getType(), args.size(), flags);
    3.38 +                method.loadNull(); //the 'this'
    3.39 +                method.dynamicCall(callNode.getType(), 2 + loadArgs(args), flags);
    3.40              }
    3.41  
    3.42              private void evalCall(final IdentNode node, final int flags) {
    3.43 @@ -597,8 +596,7 @@
    3.44                  // This is some scope 'eval' or global eval replaced by user
    3.45                  // but not the built-in ECMAScript 'eval' function call
    3.46                  method.loadNull();
    3.47 -                loadArgs(args);
    3.48 -                method.dynamicCall(callNode.getType(), args.size(), flags);
    3.49 +                method.dynamicCall(callNode.getType(), 2 + loadArgs(args), flags);
    3.50  
    3.51                  method.label(eval_done);
    3.52              }
    3.53 @@ -638,8 +636,7 @@
    3.54                  method.dup();
    3.55                  method.dynamicGet(node.getType(), node.getProperty().getName(), getCallSiteFlags(), true);
    3.56                  method.swap();
    3.57 -                loadArgs(args);
    3.58 -                method.dynamicCall(callNode.getType(), args.size(), getCallSiteFlags());
    3.59 +                method.dynamicCall(callNode.getType(), 2 + loadArgs(args), getCallSiteFlags());
    3.60                  assert method.peekType().equals(callNode.getType());
    3.61  
    3.62                  return null;
    3.63 @@ -682,8 +679,7 @@
    3.64                  }
    3.65                  method.dynamicGetIndex(node.getType(), getCallSiteFlags(), true);
    3.66                  method.swap();
    3.67 -                loadArgs(args);
    3.68 -                method.dynamicCall(callNode.getType(), args.size(), getCallSiteFlags());
    3.69 +                method.dynamicCall(callNode.getType(), 2 + loadArgs(args), getCallSiteFlags());
    3.70                  assert method.peekType().equals(callNode.getType());
    3.71  
    3.72                  return null;
    3.73 @@ -695,9 +691,7 @@
    3.74                  load(function);
    3.75                  method.convert(Type.OBJECT); //TODO, e.g. booleans can be used as functions
    3.76                  method.loadNull(); // ScriptFunction will figure out the correct this when it sees CALLSITE_SCOPE
    3.77 -
    3.78 -                loadArgs(args);
    3.79 -                method.dynamicCall(callNode.getType(), args.size(), getCallSiteFlags() | CALLSITE_SCOPE);
    3.80 +                method.dynamicCall(callNode.getType(), 2 + loadArgs(args), getCallSiteFlags() | CALLSITE_SCOPE);
    3.81                  assert method.peekType().equals(callNode.getType());
    3.82  
    3.83                  return null;
    3.84 @@ -1611,7 +1605,7 @@
    3.85          // Get the request arguments.
    3.86          final List<Node> args = runtimeNode.getArgs();
    3.87  
    3.88 -        if (nullCheck(runtimeNode, args, new FunctionSignature(false, runtimeNode.getType(), args).toString())) {
    3.89 +        if (nullCheck(runtimeNode, args, new FunctionSignature(false, false, runtimeNode.getType(), args).toString())) {
    3.90              return null;
    3.91          }
    3.92  
    3.93 @@ -1628,6 +1622,7 @@
    3.94              runtimeNode.getRequest().toString(),
    3.95              new FunctionSignature(
    3.96                  false,
    3.97 +                false,
    3.98                  runtimeNode.getType(),
    3.99                  runtimeNode.getArgs().size()).toString());
   3.100          method.convert(runtimeNode.getType());
   3.101 @@ -2292,10 +2287,7 @@
   3.102          // Load function reference.
   3.103          load(callNode.getFunction()).convert(Type.OBJECT); // must detect type error
   3.104  
   3.105 -        // Load arguments.
   3.106 -        loadArgs(args);
   3.107 -
   3.108 -        method.dynamicNew(args.size(), getCallSiteFlags());
   3.109 +        method.dynamicNew(1 + loadArgs(args), getCallSiteFlags());
   3.110          method.store(unaryNode.getSymbol());
   3.111  
   3.112          return null;
   3.113 @@ -2884,7 +2876,10 @@
   3.114          final Label  falseLabel = new Label("ternary_false");
   3.115          final Label  exitLabel  = new Label("ternary_exit");
   3.116  
   3.117 -        final Type widest = Type.widest(rhs.getType(), third.getType());
   3.118 +        Type widest = Type.widest(rhs.getType(), third.getType());
   3.119 +        if (rhs.getType().isArray() || third.getType().isArray()) { //loadArray creates a Java array type on the stack, calls global allocate, which creates a native array type
   3.120 +            widest = Type.OBJECT;
   3.121 +        }
   3.122  
   3.123          load(lhs);
   3.124          assert lhs.getType().isBoolean() : "lhs in ternary must be boolean";
   3.125 @@ -3159,7 +3154,6 @@
   3.126          }
   3.127  
   3.128          private void epilogue() {
   3.129 -            final Symbol targetSymbol = target.getSymbol();
   3.130              final FunctionNode currentFunction = getCurrentFunctionNode();
   3.131  
   3.132              /**
   3.133 @@ -3176,7 +3170,7 @@
   3.134                  @Override
   3.135                  protected Node enterDefault(Node node) {
   3.136                      throw new AssertionError("Unexpected node " + node + " in store epilogue");
   3.137 -                };
   3.138 +                }
   3.139  
   3.140                  @Override
   3.141                  public Node enter(final UnaryNode node) {
   3.142 @@ -3261,7 +3255,7 @@
   3.143  
   3.144      private MethodEmitter globalAllocateArray(final ArrayType type) {
   3.145          //make sure the native array is treated as an array type
   3.146 -        return method.invokeStatic(Compiler.GLOBAL_OBJECT, "allocate", methodDescriptor(Object.class, type.getTypeClass()), type);
   3.147 +        return method.invokeStatic(Compiler.GLOBAL_OBJECT, "allocate", "(" + type.getDescriptor() + ")Ljdk/nashorn/internal/objects/NativeArray;");
   3.148      }
   3.149  
   3.150      private MethodEmitter globalIsEval() {
     4.1 --- a/src/jdk/nashorn/internal/codegen/FunctionSignature.java	Mon Feb 04 15:59:44 2013 +0100
     4.2 +++ b/src/jdk/nashorn/internal/codegen/FunctionSignature.java	Mon Feb 04 16:20:05 2013 +0100
     4.3 @@ -54,19 +54,6 @@
     4.4       *
     4.5       * Create a FunctionSignature given arguments as AST Nodes
     4.6       *
     4.7 -     * @param hasSelf does the function have a self slot?
     4.8 -     * @param retType what is the return type
     4.9 -     * @param args    argument list of AST Nodes
    4.10 -     */
    4.11 -    public FunctionSignature(final boolean hasSelf, final Type retType, final List<? extends Node> args) {
    4.12 -        this(hasSelf, false, retType, FunctionSignature.typeArray(args));
    4.13 -    }
    4.14 -
    4.15 -    /**
    4.16 -     * Constructor
    4.17 -     *
    4.18 -     * Create a FunctionSignature given arguments as AST Nodes
    4.19 -     *
    4.20       * @param hasSelf   does the function have a self slot?
    4.21       * @param hasCallee does the function need a callee variable
    4.22       * @param retType   what is the return type
    4.23 @@ -82,11 +69,12 @@
    4.24       * Create a FunctionSignature given arguments as AST Nodes
    4.25       *
    4.26       * @param hasSelf does the function have a self slot?
    4.27 +     * @param hasCallee does the function need a callee variable
    4.28       * @param retType what is the return type
    4.29       * @param nArgs   number of arguments
    4.30       */
    4.31 -    public FunctionSignature(final boolean hasSelf, final Type retType, final int nArgs) {
    4.32 -        this(hasSelf, false, retType, FunctionSignature.objectArgs(nArgs));
    4.33 +    public FunctionSignature(final boolean hasSelf, final boolean hasCallee, final Type retType, final int nArgs) {
    4.34 +        this(hasSelf, hasCallee, retType, FunctionSignature.objectArgs(nArgs));
    4.35      }
    4.36  
    4.37      /**
    4.38 @@ -99,7 +87,7 @@
    4.39       * @param retType   what is the return type
    4.40       * @param argTypes  argument list of AST Nodes
    4.41       */
    4.42 -    public FunctionSignature(final boolean hasSelf, final boolean hasCallee, final Type retType, final Type... argTypes) {
    4.43 +    private FunctionSignature(final boolean hasSelf, final boolean hasCallee, final Type retType, final Type... argTypes) {
    4.44          final boolean isVarArg;
    4.45  
    4.46          int count = 1;
     5.1 --- a/src/jdk/nashorn/internal/codegen/MethodEmitter.java	Mon Feb 04 15:59:44 2013 +0100
     5.2 +++ b/src/jdk/nashorn/internal/codegen/MethodEmitter.java	Mon Feb 04 16:20:05 2013 +0100
     5.3 @@ -1759,23 +1759,19 @@
     5.4       *
     5.5       * @return function signature for stack contents
     5.6       */
     5.7 -    private String getDynamicSignature(final Type returnType, final int argCount, final boolean hasSelf) {
     5.8 -        final Iterator<Type> iter     = stack.iterator();
     5.9 -        final Type[]         argTypes = new Type[argCount];
    5.10 +    private String getDynamicSignature(final Type returnType, final int argCount) {
    5.11 +        final Iterator<Type> iter       = stack.iterator();
    5.12 +        final Type[]         paramTypes = new Type[argCount];
    5.13  
    5.14          for (int i = argCount - 1; i >= 0; i--) {
    5.15 -            argTypes[i] = iter.next();
    5.16 +            paramTypes[i] = iter.next();
    5.17 +        }
    5.18 +        final String descriptor = Type.getMethodDescriptor(returnType, paramTypes);
    5.19 +        for (int i = 0; i < argCount; i++) {
    5.20 +            popType(paramTypes[argCount - i - 1]);
    5.21          }
    5.22  
    5.23 -        final FunctionSignature sig = new FunctionSignature(hasSelf, false, returnType, argTypes);
    5.24 -        for (int i = 0; i < argCount; i++) {
    5.25 -            popType(argTypes[argCount - i - 1]);
    5.26 -        }
    5.27 -        for (int i = 0 ; i < sig.size() - argTypes.length; i++) {
    5.28 -            popType(Type.OBJECT);
    5.29 -        }
    5.30 -
    5.31 -        return sig.toString();
    5.32 +        return descriptor;
    5.33      }
    5.34  
    5.35      /**
    5.36 @@ -1788,7 +1784,7 @@
    5.37       */
    5.38      public MethodEmitter dynamicNew(final int argCount, final int flags) {
    5.39          debug("dynamic_new", "argcount=" + argCount);
    5.40 -        final String signature = getDynamicSignature(Type.OBJECT, argCount, true);
    5.41 +        final String signature = getDynamicSignature(Type.OBJECT, argCount);
    5.42          method.visitInvokeDynamicInsn("dyn:new", signature, LINKERBOOTSTRAP, flags);
    5.43          pushType(Type.OBJECT); //TODO fix result type
    5.44          return this;
    5.45 @@ -1805,7 +1801,7 @@
    5.46       */
    5.47      public MethodEmitter dynamicCall(final Type returnType, final int argCount, final int flags) {
    5.48          debug("dynamic_call", "args=" + argCount, "returnType=" + returnType);
    5.49 -        final String signature = getDynamicSignature(returnType, argCount + 1, true);
    5.50 +        final String signature = getDynamicSignature(returnType, argCount); // +1 because the function itself is the 1st parameter for dynamic calls (what you call - call target)
    5.51          debug("   signature", signature);
    5.52          method.visitInvokeDynamicInsn("dyn:call", signature, LINKERBOOTSTRAP, flags);
    5.53          pushType(returnType);
    5.54 @@ -1824,7 +1820,7 @@
    5.55       */
    5.56      public MethodEmitter dynamicRuntimeCall(final String name, final Type returnType, final RuntimeNode.Request request) {
    5.57          debug("dynamic_runtime_call", name, "args=" + request.getArity(), "returnType=" + returnType);
    5.58 -        final String signature = getDynamicSignature(returnType, request.getArity(), false);
    5.59 +        final String signature = getDynamicSignature(returnType, request.getArity());
    5.60          debug("   signature", signature);
    5.61          method.visitInvokeDynamicInsn(name, signature, RUNTIMEBOOTSTRAP);
    5.62          pushType(returnType);
    5.63 @@ -2198,6 +2194,11 @@
    5.64                          sb.append("this");
    5.65                      } else if (t.isObject()) {
    5.66                          String desc = t.getDescriptor();
    5.67 +                        int i;
    5.68 +                        for (i = 0; desc.charAt(i) == '[' && i < desc.length(); i++) {
    5.69 +                            sb.append('[');
    5.70 +                        }
    5.71 +                        desc = desc.substring(i);
    5.72                          final int slash = desc.lastIndexOf('/');
    5.73                          if (slash != -1) {
    5.74                              desc = desc.substring(slash + 1, desc.length() - 1);
     6.1 --- a/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java	Mon Feb 04 15:59:44 2013 +0100
     6.2 +++ b/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java	Mon Feb 04 16:20:05 2013 +0100
     6.3 @@ -327,17 +327,21 @@
     6.4                      }
     6.5                  }
     6.6                  addcheck = MH.explicitCastArguments(addcheck, type().changeReturnType(boolean.class));
     6.7 -                guard    = MH.guardWithTest(guard, addcheck,
     6.8 +                guard    = MH.guardWithTest(upcastGuard(guard), addcheck,
     6.9                                  MH.dropArguments(MH.constant(boolean.class, false), 0, type().parameterArray()));
    6.10              }
    6.11  
    6.12 -            return MH.guardWithTest(guard, mh, fallback);
    6.13 +            return MH.guardWithTest(upcastGuard(guard), mh, fallback);
    6.14          }
    6.15  
    6.16          // generic fallback
    6.17          return MH.explicitCastArguments(Lookup.filterReturnType(GENERIC_METHODS.get(request.name()), type().returnType()), type());
    6.18      }
    6.19  
    6.20 +    private MethodHandle upcastGuard(final MethodHandle guard) {
    6.21 +        return MH.asType(guard, type().changeReturnType(boolean.class));
    6.22 +    }
    6.23 +
    6.24      /**
    6.25       * This is public just so that the generated specialization code can
    6.26       * use it to get the next wider typed method
     7.1 --- a/src/jdk/nashorn/internal/codegen/SharedScopeCall.java	Mon Feb 04 15:59:44 2013 +0100
     7.2 +++ b/src/jdk/nashorn/internal/codegen/SharedScopeCall.java	Mon Feb 04 16:20:05 2013 +0100
     7.3 @@ -163,7 +163,7 @@
     7.4                      slot++;
     7.5                  }
     7.6              }
     7.7 -            method.dynamicCall(returnType, paramTypes.length, flags);
     7.8 +            method.dynamicCall(returnType, 2 + paramTypes.length, flags);
     7.9          }
    7.10  
    7.11          method._return(returnType);
     8.1 --- a/src/jdk/nashorn/internal/objects/Global.java	Mon Feb 04 15:59:44 2013 +0100
     8.2 +++ b/src/jdk/nashorn/internal/objects/Global.java	Mon Feb 04 16:20:05 2013 +0100
     8.3 @@ -1158,7 +1158,7 @@
     8.4       * @param initial object values.
     8.5       * @return the new array
     8.6       */
     8.7 -    public static Object allocate(final Object[] initial) {
     8.8 +    public static NativeArray allocate(final Object[] initial) {
     8.9          return new NativeArray(initial);
    8.10      }
    8.11  
    8.12 @@ -1168,7 +1168,7 @@
    8.13       * @param initial number values.
    8.14       * @return the new array
    8.15       */
    8.16 -    public static Object allocate(final double[] initial) {
    8.17 +    public static NativeArray allocate(final double[] initial) {
    8.18          return new NativeArray(initial);
    8.19      }
    8.20  
    8.21 @@ -1178,7 +1178,7 @@
    8.22       * @param initial number values.
    8.23       * @return the new array
    8.24       */
    8.25 -    public static Object allocate(final long[] initial) {
    8.26 +    public static NativeArray allocate(final long[] initial) {
    8.27          return new NativeArray(initial);
    8.28      }
    8.29  
    8.30 @@ -1188,7 +1188,7 @@
    8.31       * @param initial number values.
    8.32       * @return the new array
    8.33       */
    8.34 -    public static Object allocate(final int[] initial) {
    8.35 +    public static NativeArray allocate(final int[] initial) {
    8.36          return new NativeArray(initial);
    8.37      }
    8.38  
     9.1 --- a/src/jdk/nashorn/internal/runtime/ECMAException.java	Mon Feb 04 15:59:44 2013 +0100
     9.2 +++ b/src/jdk/nashorn/internal/runtime/ECMAException.java	Mon Feb 04 16:20:05 2013 +0100
     9.3 @@ -31,7 +31,6 @@
     9.4  
     9.5  import javax.script.ScriptException;
     9.6  import jdk.nashorn.api.scripting.NashornException;
     9.7 -import jdk.nashorn.api.scripting.NashornScriptEngine;
     9.8  import jdk.nashorn.internal.codegen.CompilerConstants.Call;
     9.9  import jdk.nashorn.internal.codegen.CompilerConstants.FieldAccess;
    9.10  import jdk.nashorn.internal.scripts.JS$;
    10.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunction.java	Mon Feb 04 15:59:44 2013 +0100
    10.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunction.java	Mon Feb 04 16:20:05 2013 +0100
    10.3 @@ -721,7 +721,15 @@
    10.4          return hasCalleeParameter() ? MH.bindTo(bound, this) : bound;
    10.5      }
    10.6  
    10.7 +    /**
    10.8 +     * Check whether the ScriptFunction has callee parameter
    10.9 +     * @return true if callee parameter
   10.10 +     */
   10.11      protected abstract boolean hasCalleeParameter();
   10.12 +
   10.13 +    /**
   10.14 +     * Flag ScriptFunction as needing a callee parameter
   10.15 +     */
   10.16      protected abstract void setHasCalleeParameter();
   10.17  
   10.18      /**
    11.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java	Mon Feb 04 15:59:44 2013 +0100
    11.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java	Mon Feb 04 16:20:05 2013 +0100
    11.3 @@ -86,7 +86,6 @@
    11.4   * </ul>
    11.5   */
    11.6  
    11.7 -
    11.8  public abstract class ScriptObject extends PropertyListenerManager implements PropertyAccess {
    11.9  
   11.10      /** Search fall back routine name for "no such method" */
   11.11 @@ -1710,7 +1709,6 @@
   11.12  
   11.13          if (methodHandle != null) {
   11.14              assert methodHandle.type().returnType().equals(returnType);
   11.15 -            final ScriptFunction getter = find.getGetterFunction();
   11.16              if (find.isSelf()) {
   11.17                  return new GuardedInvocation(methodHandle, ObjectClassGenerator.OBJECT_FIELDS_ONLY &&
   11.18                          NashornCallSiteDescriptor.isFastScope(desc) && !property.canChangeType() ? null : guard);
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/script/basic/JDK-8007215.js	Mon Feb 04 16:20:05 2013 +0100
    12.3 @@ -0,0 +1,52 @@
    12.4 +/*
    12.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + * 
    12.8 + * This code is free software; you can redistribute it and/or modify it
    12.9 + * under the terms of the GNU General Public License version 2 only, as
   12.10 + * published by the Free Software Foundation.
   12.11 + * 
   12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.15 + * version 2 for more details (a copy is included in the LICENSE file that
   12.16 + * accompanied this code).
   12.17 + * 
   12.18 + * You should have received a copy of the GNU General Public License version
   12.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.21 + * 
   12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.23 + * or visit www.oracle.com if you need additional information or have any
   12.24 + * questions.
   12.25 + */
   12.26 +
   12.27 +/**
   12.28 + * Varargs based on too many parameters broke. Regression test.
   12.29 + * 
   12.30 + * @test
   12.31 + * @run
   12.32 + */
   12.33 +
   12.34 +function f() {
   12.35 +    var sum = 0;
   12.36 +    for (var i = 0; i < arguments.length; i++) {
   12.37 +	var a = arguments[i];
   12.38 +	sum += a;
   12.39 +    }
   12.40 +    return sum;
   12.41 +} 
   12.42 +
   12.43 +var res;
   12.44 +
   12.45 +res = f(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249);
   12.46 +
   12.47 +print(res);
   12.48 +
   12.49 +res = f(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250);
   12.50 +
   12.51 +print(res);
   12.52 +
   12.53 +res = f(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251);
   12.54 +
   12.55 +print(res);
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/script/basic/JDK-8007215.js.EXPECTED	Mon Feb 04 16:20:05 2013 +0100
    13.3 @@ -0,0 +1,3 @@
    13.4 +31125
    13.5 +31375
    13.6 +31626

mercurial