8144020: Remove long as an internal numeric type

Fri, 22 Jan 2016 16:18:19 +0100

author
hannesw
date
Fri, 22 Jan 2016 16:18:19 +0100
changeset 1720
c09b105e7be5
parent 1719
95b8a01d3b52
child 1721
bfc671539e50

8144020: Remove long as an internal numeric type
Reviewed-by: attila, mhaupt

src/jdk/nashorn/internal/codegen/CodeGenerator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/FieldObjectCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/FoldConstants.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/MethodEmitter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/ObjectCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/SpillObjectCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/TypeEvaluator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/types/IntType.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/types/LongType.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/types/Type.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/BinaryNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/LiteralNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/Symbol.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/Global.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeArguments.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeArray.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeFloat32Array.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeFloat64Array.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeInt16Array.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeInt32Array.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeInt8Array.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeJSAdapter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeString.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeUint16Array.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeUint32Array.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeUint8Array.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/parser/JSONParser.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/parser/Lexer.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/AccessorProperty.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/DebuggerSupport.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/DefaultPropertyAccess.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/FindProperty.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/GlobalFunctions.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/JSType.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/OptimisticReturnFilters.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/Property.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/PropertyAccess.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/ScriptObject.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/UserAccessorProperty.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/ArrayData.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/DeletedArrayFilter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/DeletedRangeArrayFilter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/FrozenArrayFilter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/LengthNotWritableFilter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/NonExtensibleArrayFilter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/arrays/UndefinedArrayFilter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/linker/Bootstrap.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java file | annotate | diff | comparison | revisions
test/script/basic/JDK-8062799.js file | annotate | diff | comparison | revisions
test/script/basic/JDK-8062799.js.EXPECTED file | annotate | diff | comparison | revisions
test/script/basic/JDK-8144020.js file | annotate | diff | comparison | revisions
test/script/basic/JDK-8144131.js file | annotate | diff | comparison | revisions
test/script/nosecurity/JDK-8067215.js file | annotate | diff | comparison | revisions
test/src/jdk/nashorn/api/javaaccess/test/NumberAccessTest.java file | annotate | diff | comparison | revisions
test/src/jdk/nashorn/api/javaaccess/test/NumberBoxingTest.java file | annotate | diff | comparison | revisions
test/src/jdk/nashorn/test/models/LongProvider.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Tue Jan 19 18:56:23 2016 +0100
     1.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri Jan 22 16:18:19 2016 +0100
     1.3 @@ -188,8 +188,6 @@
     1.4  
     1.5      private static final Call ENSURE_INT = CompilerConstants.staticCallNoLookup(OptimisticReturnFilters.class,
     1.6              "ensureInt", int.class, Object.class, int.class);
     1.7 -    private static final Call ENSURE_LONG = CompilerConstants.staticCallNoLookup(OptimisticReturnFilters.class,
     1.8 -            "ensureLong", long.class, Object.class, int.class);
     1.9      private static final Call ENSURE_NUMBER = CompilerConstants.staticCallNoLookup(OptimisticReturnFilters.class,
    1.10              "ensureNumber", double.class, Object.class, int.class);
    1.11  
    1.12 @@ -1720,7 +1718,7 @@
    1.13          enterStatement(expressionStatement);
    1.14  
    1.15          loadAndDiscard(expressionStatement.getExpression());
    1.16 -        assert method.getStackSize() == 0;
    1.17 +        assert method.getStackSize() == 0 : "stack not empty in " + expressionStatement;
    1.18  
    1.19          return false;
    1.20      }
    1.21 @@ -2235,7 +2233,7 @@
    1.22       * @param arrayType        the type of the array, e.g. ARRAY_NUMBER or ARRAY_OBJECT
    1.23       */
    1.24      private void loadArray(final ArrayLiteralNode arrayLiteralNode, final ArrayType arrayType) {
    1.25 -        assert arrayType == Type.INT_ARRAY || arrayType == Type.LONG_ARRAY || arrayType == Type.NUMBER_ARRAY || arrayType == Type.OBJECT_ARRAY;
    1.26 +        assert arrayType == Type.INT_ARRAY || arrayType == Type.NUMBER_ARRAY || arrayType == Type.OBJECT_ARRAY;
    1.27  
    1.28          final Expression[]     nodes    = arrayLiteralNode.getValue();
    1.29          final Object           presets  = arrayLiteralNode.getPresets();
    1.30 @@ -2383,20 +2381,9 @@
    1.31                  method.convert(Type.OBJECT);
    1.32              } else if(!resultBounds.canBeNarrowerThan(Type.NUMBER)) {
    1.33                  method.load(((Integer)value).doubleValue());
    1.34 -            } else if(!resultBounds.canBeNarrowerThan(Type.LONG)) {
    1.35 -                method.load(((Integer)value).longValue());
    1.36              } else {
    1.37                  method.load((Integer)value);
    1.38              }
    1.39 -        } else if (value instanceof Long) {
    1.40 -            if(!resultBounds.canBeNarrowerThan(Type.OBJECT)) {
    1.41 -                method.load((Long)value);
    1.42 -                method.convert(Type.OBJECT);
    1.43 -            } else if(!resultBounds.canBeNarrowerThan(Type.NUMBER)) {
    1.44 -                method.load(((Long)value).doubleValue());
    1.45 -            } else {
    1.46 -                method.load((Long)value);
    1.47 -            }
    1.48          } else if (value instanceof Double) {
    1.49              if(!resultBounds.canBeNarrowerThan(Type.OBJECT)) {
    1.50                  method.load((Double)value);
    1.51 @@ -3647,8 +3634,6 @@
    1.52              private void loadMinusOne() {
    1.53                  if (type.isInteger()) {
    1.54                      method.load(isIncrement ? 1 : -1);
    1.55 -                } else if (type.isLong()) {
    1.56 -                    method.load(isIncrement ? 1L : -1L);
    1.57                  } else {
    1.58                      method.load(isIncrement ? 1.0 : -1.0);
    1.59                  }
    1.60 @@ -4030,23 +4015,66 @@
    1.61      }
    1.62  
    1.63      private void loadASSIGN_SHR(final BinaryNode binaryNode) {
    1.64 -        new BinarySelfAssignment(binaryNode) {
    1.65 +        new SelfModifyingStore<BinaryNode>(binaryNode, binaryNode.lhs()) {
    1.66              @Override
    1.67 -            protected void op() {
    1.68 -                doSHR();
    1.69 -            }
    1.70 -
    1.71 +            protected void evaluate() {
    1.72 +                new OptimisticOperation(assignNode, new TypeBounds(Type.INT, Type.NUMBER)) {
    1.73 +                    @Override
    1.74 +                    void loadStack() {
    1.75 +                        assert assignNode.getWidestOperandType() == Type.INT;
    1.76 +                        if (isRhsZero(binaryNode)) {
    1.77 +                            loadExpressionAsType(binaryNode.lhs(), Type.INT);
    1.78 +                        } else {
    1.79 +                            loadBinaryOperands(binaryNode.lhs(), binaryNode.rhs(), TypeBounds.INT, true, false);
    1.80 +                            method.shr();
    1.81 +                        }
    1.82 +                    }
    1.83 +
    1.84 +                    @Override
    1.85 +                    void consumeStack() {
    1.86 +                        if (isOptimistic(binaryNode)) {
    1.87 +                            toUint32Optimistic(binaryNode.getProgramPoint());
    1.88 +                        } else {
    1.89 +                            toUint32Double();
    1.90 +                        }
    1.91 +                    }
    1.92 +                }.emit(getOptimisticIgnoreCountForSelfModifyingExpression(binaryNode.lhs()));
    1.93 +                method.convert(assignNode.getType());
    1.94 +            }
    1.95          }.store();
    1.96      }
    1.97  
    1.98 -    private void doSHR() {
    1.99 -        // TODO: make SHR optimistic
   1.100 -        method.shr();
   1.101 -        toUint();
   1.102 -    }
   1.103 -
   1.104 -    private void toUint() {
   1.105 -        JSType.TO_UINT32_I.invoke(method);
   1.106 +    private void doSHR(final BinaryNode binaryNode) {
   1.107 +        new OptimisticOperation(binaryNode, new TypeBounds(Type.INT, Type.NUMBER)) {
   1.108 +            @Override
   1.109 +            void loadStack() {
   1.110 +                if (isRhsZero(binaryNode)) {
   1.111 +                    loadExpressionAsType(binaryNode.lhs(), Type.INT);
   1.112 +                } else {
   1.113 +                    loadBinaryOperands(binaryNode);
   1.114 +                    method.shr();
   1.115 +                }
   1.116 +            }
   1.117 +
   1.118 +            @Override
   1.119 +            void consumeStack() {
   1.120 +                if (isOptimistic(binaryNode)) {
   1.121 +                    toUint32Optimistic(binaryNode.getProgramPoint());
   1.122 +                } else {
   1.123 +                    toUint32Double();
   1.124 +                }
   1.125 +            }
   1.126 +        }.emit();
   1.127 +
   1.128 +    }
   1.129 +
   1.130 +    private void toUint32Optimistic(final int programPoint) {
   1.131 +        method.load(programPoint);
   1.132 +        JSType.TO_UINT32_OPTIMISTIC.invoke(method);
   1.133 +    }
   1.134 +
   1.135 +    private void toUint32Double() {
   1.136 +        JSType.TO_UINT32_DOUBLE.invoke(method);
   1.137      }
   1.138  
   1.139      private void loadASSIGN_SUB(final BinaryNode binaryNode) {
   1.140 @@ -4084,7 +4112,7 @@
   1.141                              // Non-optimistic, non-FP subtraction or multiplication. Allow them to overflow.
   1.142                              operandBounds = new TypeBounds(Type.narrowest(node.getWidestOperandType(),
   1.143                                      numericBounds.widest), Type.NUMBER);
   1.144 -                            forceConversionSeparation = node.getWidestOperationType().narrowerThan(numericBounds.widest);
   1.145 +                            forceConversionSeparation = true;
   1.146                          }
   1.147                      }
   1.148                      loadBinaryOperands(node.lhs(), node.rhs(), operandBounds, false, forceConversionSeparation);
   1.149 @@ -4186,14 +4214,7 @@
   1.150      }
   1.151  
   1.152      private void loadSHR(final BinaryNode binaryNode) {
   1.153 -        // Optimize x >>> 0 to (uint)x
   1.154 -        if (isRhsZero(binaryNode)) {
   1.155 -            loadExpressionAsType(binaryNode.lhs(), Type.INT);
   1.156 -            toUint();
   1.157 -        } else {
   1.158 -            loadBinaryOperands(binaryNode);
   1.159 -            doSHR();
   1.160 -        }
   1.161 +        doSHR(binaryNode);
   1.162      }
   1.163  
   1.164      private void loadSUB(final BinaryNode binaryNode, final TypeBounds resultBounds) {
   1.165 @@ -4464,6 +4485,7 @@
   1.166                          }
   1.167                      } else {
   1.168                          final Type storeType = assignNode.getType();
   1.169 +                        assert storeType != Type.LONG;
   1.170                          if (symbol.hasSlotFor(storeType)) {
   1.171                              // Only emit a convert for a store known to be live; converts for dead stores can
   1.172                              // give us an unnecessary ClassCastException.
   1.173 @@ -4848,8 +4870,6 @@
   1.174                      method.load(optimistic.getProgramPoint());
   1.175                      if(optimisticType.isInteger()) {
   1.176                          method.invoke(ENSURE_INT);
   1.177 -                    } else if(optimisticType.isLong()) {
   1.178 -                        method.invoke(ENSURE_LONG);
   1.179                      } else if(optimisticType.isNumber()) {
   1.180                          method.invoke(ENSURE_NUMBER);
   1.181                      } else {
     2.1 --- a/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Tue Jan 19 18:56:23 2016 +0100
     2.2 +++ b/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Fri Jan 22 16:18:19 2016 +0100
     2.3 @@ -167,8 +167,7 @@
     2.4          assert fieldName.equals(getFieldName(fieldIndex, PRIMITIVE_FIELD_TYPE)) || fieldType.isObject() :    key + " object keys must store to L*-fields";
     2.5          assert fieldName.equals(getFieldName(fieldIndex, Type.OBJECT))          || fieldType.isPrimitive() : key + " primitive keys must store to J*-fields";
     2.6  
     2.7 -        loadTuple(method, tuple);
     2.8 -
     2.9 +        loadTuple(method, tuple, true);
    2.10          method.putField(fieldClass, fieldName, fieldDesc);
    2.11      }
    2.12  
    2.13 @@ -180,11 +179,7 @@
    2.14       * @param tuple  Tuple to store.
    2.15       */
    2.16      private void putSlot(final MethodEmitter method, final long index, final MapTuple<T> tuple) {
    2.17 -        if (JSType.isRepresentableAsInt(index)) {
    2.18 -            method.load((int)index);
    2.19 -        } else {
    2.20 -            method.load(index);
    2.21 -        }
    2.22 +        loadIndex(method, index);
    2.23          loadTuple(method, tuple, false); //we don't pack array like objects
    2.24          method.dynamicSetIndex(callSiteFlags);
    2.25      }
     3.1 --- a/src/jdk/nashorn/internal/codegen/FoldConstants.java	Tue Jan 19 18:56:23 2016 +0100
     3.2 +++ b/src/jdk/nashorn/internal/codegen/FoldConstants.java	Fri Jan 22 16:18:19 2016 +0100
     3.3 @@ -307,9 +307,7 @@
     3.4              final Type widest = Type.widest(lhs.getType(), rhs.getType());
     3.5  
     3.6              boolean isInteger = widest.isInteger();
     3.7 -            boolean isLong    = widest.isLong();
     3.8 -
     3.9 -            double value;
    3.10 +            final double value;
    3.11  
    3.12              switch (parent.tokenType()) {
    3.13              case DIV:
    3.14 @@ -336,7 +334,8 @@
    3.15                  value = lhs.getNumber() - rhs.getNumber();
    3.16                  break;
    3.17              case SHR:
    3.18 -                return LiteralNode.newInstance(token, finish, JSType.toUint32(lhs.getInt32() >>> rhs.getInt32()));
    3.19 +                final long result = JSType.toUint32(lhs.getInt32() >>> rhs.getInt32());
    3.20 +                return LiteralNode.newInstance(token, finish, JSType.isRepresentableAsInt(result) ? (int) result : (double) result);
    3.21              case SAR:
    3.22                  return LiteralNode.newInstance(token, finish, lhs.getInt32() >> rhs.getInt32());
    3.23              case SHL:
    3.24 @@ -368,12 +367,9 @@
    3.25              }
    3.26  
    3.27              isInteger &= JSType.isStrictlyRepresentableAsInt(value);
    3.28 -            isLong    &= JSType.isStrictlyRepresentableAsLong(value);
    3.29  
    3.30              if (isInteger) {
    3.31                  return LiteralNode.newInstance(token, finish, (int)value);
    3.32 -            } else if (isLong) {
    3.33 -                return LiteralNode.newInstance(token, finish, (long)value);
    3.34              }
    3.35  
    3.36              return LiteralNode.newInstance(token, finish, value);
     4.1 --- a/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java	Tue Jan 19 18:56:23 2016 +0100
     4.2 +++ b/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java	Fri Jan 22 16:18:19 2016 +0100
     4.3 @@ -131,7 +131,6 @@
     4.4          UNDEFINED(Type.UNDEFINED),
     4.5          BOOLEAN(Type.BOOLEAN),
     4.6          INT(Type.INT),
     4.7 -        LONG(Type.LONG),
     4.8          DOUBLE(Type.NUMBER),
     4.9          OBJECT(Type.OBJECT);
    4.10  
    4.11 @@ -272,12 +271,9 @@
    4.12      }
    4.13  
    4.14      private static class SymbolConversions {
    4.15 -        private static byte I2L = 1 << 0;
    4.16 -        private static byte I2D = 1 << 1;
    4.17 -        private static byte I2O = 1 << 2;
    4.18 -        private static byte L2D = 1 << 3;
    4.19 -        private static byte L2O = 1 << 4;
    4.20 -        private static byte D2O = 1 << 5;
    4.21 +        private static final byte I2D = 1 << 0;
    4.22 +        private static final byte I2O = 1 << 1;
    4.23 +        private static final byte D2O = 1 << 2;
    4.24  
    4.25          private byte conversions;
    4.26  
    4.27 @@ -288,9 +284,6 @@
    4.28              case INT:
    4.29              case BOOLEAN:
    4.30                  switch (to) {
    4.31 -                case LONG:
    4.32 -                    recordConversion(I2L);
    4.33 -                    return;
    4.34                  case DOUBLE:
    4.35                      recordConversion(I2D);
    4.36                      return;
    4.37 @@ -301,18 +294,6 @@
    4.38                      illegalConversion(from, to);
    4.39                      return;
    4.40                  }
    4.41 -            case LONG:
    4.42 -                switch (to) {
    4.43 -                case DOUBLE:
    4.44 -                    recordConversion(L2D);
    4.45 -                    return;
    4.46 -                case OBJECT:
    4.47 -                    recordConversion(L2O);
    4.48 -                    return;
    4.49 -                default:
    4.50 -                    illegalConversion(from, to);
    4.51 -                    return;
    4.52 -                }
    4.53              case DOUBLE:
    4.54                  if(to == LvarType.OBJECT) {
    4.55                      recordConversion(D2O);
    4.56 @@ -340,26 +321,15 @@
    4.57                  if(hasConversion(D2O)) {
    4.58                      symbol.setHasSlotFor(Type.NUMBER);
    4.59                  }
    4.60 -                if(hasConversion(L2O)) {
    4.61 -                    symbol.setHasSlotFor(Type.LONG);
    4.62 -                }
    4.63                  if(hasConversion(I2O)) {
    4.64                      symbol.setHasSlotFor(Type.INT);
    4.65                  }
    4.66              }
    4.67              if(symbol.hasSlotFor(Type.NUMBER)) {
    4.68 -                if(hasConversion(L2D)) {
    4.69 -                    symbol.setHasSlotFor(Type.LONG);
    4.70 -                }
    4.71                  if(hasConversion(I2D)) {
    4.72                      symbol.setHasSlotFor(Type.INT);
    4.73                  }
    4.74              }
    4.75 -            if(symbol.hasSlotFor(Type.LONG)) {
    4.76 -                if(hasConversion(I2L)) {
    4.77 -                    symbol.setHasSlotFor(Type.INT);
    4.78 -                }
    4.79 -            }
    4.80          }
    4.81      }
    4.82  
    4.83 @@ -378,7 +348,7 @@
    4.84          if(lvarType != null) {
    4.85              return lvarType;
    4.86          }
    4.87 -        assert type.isObject();
    4.88 +        assert type.isObject() : "Unsupported primitive type: " + type;
    4.89          return LvarType.OBJECT;
    4.90      }
    4.91      private static LvarType widestLvarType(final LvarType t1, final LvarType t2) {
     5.1 --- a/src/jdk/nashorn/internal/codegen/MethodEmitter.java	Tue Jan 19 18:56:23 2016 +0100
     5.2 +++ b/src/jdk/nashorn/internal/codegen/MethodEmitter.java	Fri Jan 22 16:18:19 2016 +0100
     5.3 @@ -543,7 +543,6 @@
     5.4          } else {
     5.5              assert false : type + " cannot be packed!";
     5.6          }
     5.7 -        //all others are nops, objects aren't packed
     5.8      }
     5.9  
    5.10      /**
     6.1 --- a/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java	Tue Jan 19 18:56:23 2016 +0100
     6.2 +++ b/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java	Fri Jan 22 16:18:19 2016 +0100
     6.3 @@ -41,7 +41,6 @@
     6.4  import static jdk.nashorn.internal.runtime.JSType.GET_UNDEFINED;
     6.5  import static jdk.nashorn.internal.runtime.JSType.TYPE_DOUBLE_INDEX;
     6.6  import static jdk.nashorn.internal.runtime.JSType.TYPE_INT_INDEX;
     6.7 -import static jdk.nashorn.internal.runtime.JSType.TYPE_LONG_INDEX;
     6.8  import static jdk.nashorn.internal.runtime.JSType.TYPE_OBJECT_INDEX;
     6.9  import static jdk.nashorn.internal.runtime.JSType.TYPE_UNDEFINED_INDEX;
    6.10  import static jdk.nashorn.internal.runtime.JSType.getAccessorTypeIndex;
    6.11 @@ -535,8 +534,6 @@
    6.12          switch (getAccessorTypeIndex(forType)) {
    6.13          case TYPE_INT_INDEX:
    6.14              return MH.explicitCastArguments(primitiveGetter, primitiveGetter.type().changeReturnType(int.class));
    6.15 -        case TYPE_LONG_INDEX:
    6.16 -            return primitiveGetter;
    6.17          case TYPE_DOUBLE_INDEX:
    6.18              return MH.filterReturnValue(primitiveGetter, UNPACK_DOUBLE);
    6.19          case TYPE_OBJECT_INDEX:
    6.20 @@ -623,7 +620,7 @@
    6.21          }
    6.22  
    6.23          assert !isOptimistic;
    6.24 -            //freely coerce the result to whatever you asked for, this is e.g. Object->int for a & b
    6.25 +        // freely coerce the result to whatever you asked for, this is e.g. Object->int for a & b
    6.26          final MethodHandle tgetter = getterForType(forType, primitiveGetter, objectGetter);
    6.27          if (fti == TYPE_OBJECT_INDEX) {
    6.28              if (fti != ti) {
    6.29 @@ -638,22 +635,10 @@
    6.30          case TYPE_INT_INDEX: {
    6.31              return MH.asType(tgetter, tgetterType.changeReturnType(type));
    6.32          }
    6.33 -        case TYPE_LONG_INDEX:
    6.34 -            switch (ti) {
    6.35 -            case TYPE_INT_INDEX:
    6.36 -                //get int while an int, truncating cast of long value
    6.37 -                return MH.filterReturnValue(tgetter, JSType.TO_INT32_L.methodHandle);
    6.38 -            case TYPE_LONG_INDEX:
    6.39 -                return primitiveGetter;
    6.40 -            default:
    6.41 -                return MH.asType(tgetter, tgetterType.changeReturnType(type));
    6.42 -            }
    6.43          case TYPE_DOUBLE_INDEX:
    6.44              switch (ti) {
    6.45              case TYPE_INT_INDEX:
    6.46                  return MH.filterReturnValue(tgetter, JSType.TO_INT32_D.methodHandle);
    6.47 -            case TYPE_LONG_INDEX:
    6.48 -                return MH.explicitCastArguments(tgetter, tgetterType.changeReturnType(type));
    6.49              case TYPE_DOUBLE_INDEX:
    6.50                  assert tgetterType.returnType() == double.class;
    6.51                  return tgetter;
    6.52 @@ -734,12 +719,9 @@
    6.53  
    6.54          switch (fti) {
    6.55          case TYPE_INT_INDEX:
    6.56 -        case TYPE_LONG_INDEX:
    6.57              switch (ti) {
    6.58              case TYPE_INT_INDEX:
    6.59                  return MH.asType(primitiveSetter, pmt.changeParameterType(1, int.class));
    6.60 -            case TYPE_LONG_INDEX:
    6.61 -                return primitiveSetter;
    6.62              case TYPE_DOUBLE_INDEX:
    6.63                  return MH.filterArguments(primitiveSetter, 1, PACK_DOUBLE);
    6.64              default:
     7.1 --- a/src/jdk/nashorn/internal/codegen/ObjectCreator.java	Tue Jan 19 18:56:23 2016 +0100
     7.2 +++ b/src/jdk/nashorn/internal/codegen/ObjectCreator.java	Fri Jan 22 16:18:19 2016 +0100
     7.3 @@ -29,6 +29,7 @@
     7.4  
     7.5  import java.util.List;
     7.6  import jdk.nashorn.internal.codegen.types.Type;
     7.7 +import jdk.nashorn.internal.runtime.JSType;
     7.8  import jdk.nashorn.internal.runtime.PropertyMap;
     7.9  import jdk.nashorn.internal.runtime.ScriptObject;
    7.10  
    7.11 @@ -156,15 +157,15 @@
    7.12  
    7.13      MethodEmitter loadTuple(final MethodEmitter method, final MapTuple<T> tuple, final boolean pack) {
    7.14          loadValue(tuple.value, tuple.type);
    7.15 -        if (pack && codegen.useDualFields() && tuple.isPrimitive()) {
    7.16 +        if (!codegen.useDualFields() || !tuple.isPrimitive()) {
    7.17 +            method.convert(Type.OBJECT);
    7.18 +        } else if (pack) {
    7.19              method.pack();
    7.20 -        } else {
    7.21 -            method.convert(Type.OBJECT);
    7.22          }
    7.23          return method;
    7.24      }
    7.25  
    7.26 -    MethodEmitter loadTuple(final MethodEmitter method, final MapTuple<T> tuple) {
    7.27 -        return loadTuple(method, tuple, true);
    7.28 +    MethodEmitter loadIndex(final MethodEmitter method, final long index) {
    7.29 +        return JSType.isRepresentableAsInt(index) ? method.load((int) index) : method.load((double) index);
    7.30      }
    7.31  }
     8.1 --- a/src/jdk/nashorn/internal/codegen/SpillObjectCreator.java	Tue Jan 19 18:56:23 2016 +0100
     8.2 +++ b/src/jdk/nashorn/internal/codegen/SpillObjectCreator.java	Fri Jan 22 16:18:19 2016 +0100
     8.3 @@ -109,8 +109,6 @@
     8.4                          //avoid blowing up the array if we can
     8.5                          if (constantValue instanceof Integer) {
     8.6                              arrayData = arrayData.set(index, ((Integer)constantValue).intValue(), false);
     8.7 -                        } else if (constantValue instanceof Long) {
     8.8 -                            arrayData = arrayData.set(index, ((Long)constantValue).longValue(), false);
     8.9                          } else if (constantValue instanceof Double) {
    8.10                              arrayData = arrayData.set(index, ((Double)constantValue).doubleValue(), false);
    8.11                          } else {
    8.12 @@ -169,12 +167,12 @@
    8.13                  final int index = ArrayIndex.getArrayIndex(tuple.key);
    8.14                  assert ArrayIndex.isValidArrayIndex(index);
    8.15                  method.dup();
    8.16 -                method.load(ArrayIndex.toLongIndex(index));
    8.17 -                loadTuple(method, tuple);
    8.18 +                loadIndex(method, ArrayIndex.toLongIndex(index));
    8.19 +                loadTuple(method, tuple, false);
    8.20                  method.dynamicSetIndex(callSiteFlags);
    8.21              } else {
    8.22                  method.dup();
    8.23 -                loadTuple(method, tuple);
    8.24 +                loadTuple(method, tuple, false);
    8.25                  method.dynamicSet(property.getKey(), codegen.getCallSiteFlags(), false);
    8.26              }
    8.27          }
     9.1 --- a/src/jdk/nashorn/internal/codegen/TypeEvaluator.java	Tue Jan 19 18:56:23 2016 +0100
     9.2 +++ b/src/jdk/nashorn/internal/codegen/TypeEvaluator.java	Fri Jan 22 16:18:19 2016 +0100
     9.3 @@ -239,7 +239,7 @@
     9.4                              // currently deoptimize all the way to Object.
     9.5                              return Type.OBJECT;
     9.6                          }
     9.7 -                        assert returnType == Type.INT || returnType == Type.LONG || returnType == Type.NUMBER || returnType == Type.OBJECT;
     9.8 +                        assert returnType == Type.INT || returnType == Type.NUMBER || returnType == Type.OBJECT;
     9.9                          return returnType;
    9.10                      }
    9.11                  }
    10.1 --- a/src/jdk/nashorn/internal/codegen/types/IntType.java	Tue Jan 19 18:56:23 2016 +0100
    10.2 +++ b/src/jdk/nashorn/internal/codegen/types/IntType.java	Fri Jan 22 16:18:19 2016 +0100
    10.3 @@ -72,7 +72,7 @@
    10.4  
    10.5      @Override
    10.6      public Type nextWider() {
    10.7 -        return LONG;
    10.8 +        return NUMBER;
    10.9      }
   10.10  
   10.11      @Override
    11.1 --- a/src/jdk/nashorn/internal/codegen/types/LongType.java	Tue Jan 19 18:56:23 2016 +0100
    11.2 +++ b/src/jdk/nashorn/internal/codegen/types/LongType.java	Fri Jan 22 16:18:19 2016 +0100
    11.3 @@ -28,20 +28,11 @@
    11.4  import static jdk.internal.org.objectweb.asm.Opcodes.L2D;
    11.5  import static jdk.internal.org.objectweb.asm.Opcodes.L2I;
    11.6  import static jdk.internal.org.objectweb.asm.Opcodes.LADD;
    11.7 -import static jdk.internal.org.objectweb.asm.Opcodes.LAND;
    11.8 -import static jdk.internal.org.objectweb.asm.Opcodes.LCMP;
    11.9  import static jdk.internal.org.objectweb.asm.Opcodes.LCONST_0;
   11.10  import static jdk.internal.org.objectweb.asm.Opcodes.LCONST_1;
   11.11  import static jdk.internal.org.objectweb.asm.Opcodes.LLOAD;
   11.12 -import static jdk.internal.org.objectweb.asm.Opcodes.LMUL;
   11.13 -import static jdk.internal.org.objectweb.asm.Opcodes.LOR;
   11.14  import static jdk.internal.org.objectweb.asm.Opcodes.LRETURN;
   11.15 -import static jdk.internal.org.objectweb.asm.Opcodes.LSHL;
   11.16 -import static jdk.internal.org.objectweb.asm.Opcodes.LSHR;
   11.17  import static jdk.internal.org.objectweb.asm.Opcodes.LSTORE;
   11.18 -import static jdk.internal.org.objectweb.asm.Opcodes.LSUB;
   11.19 -import static jdk.internal.org.objectweb.asm.Opcodes.LUSHR;
   11.20 -import static jdk.internal.org.objectweb.asm.Opcodes.LXOR;
   11.21  import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup;
   11.22  import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_LONG;
   11.23  import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
   11.24 @@ -53,7 +44,7 @@
   11.25  /**
   11.26   * Type class: LONG
   11.27   */
   11.28 -class LongType extends BitwiseType {
   11.29 +class LongType extends Type {
   11.30      private static final long serialVersionUID = 1L;
   11.31  
   11.32      private static final CompilerConstants.Call VALUE_OF = staticCallNoLookup(Long.class, "valueOf", Long.class, long.class);
   11.33 @@ -82,12 +73,6 @@
   11.34      }
   11.35  
   11.36      @Override
   11.37 -    public Type cmp(final MethodVisitor method) {
   11.38 -        method.visitInsn(LCMP);
   11.39 -        return INT;
   11.40 -    }
   11.41 -
   11.42 -    @Override
   11.43      public Type load(final MethodVisitor method, final int slot) {
   11.44          assert slot != -1;
   11.45          method.visitVarInsn(LLOAD, slot);
   11.46 @@ -149,88 +134,6 @@
   11.47      }
   11.48  
   11.49      @Override
   11.50 -    public Type sub(final MethodVisitor method, final int programPoint) {
   11.51 -        if(programPoint == INVALID_PROGRAM_POINT) {
   11.52 -            method.visitInsn(LSUB);
   11.53 -        } else {
   11.54 -            method.visitInvokeDynamicInsn("lsub", "(JJ)J", MATHBOOTSTRAP, programPoint);
   11.55 -        }
   11.56 -        return LONG;
   11.57 -    }
   11.58 -
   11.59 -    @Override
   11.60 -    public Type mul(final MethodVisitor method, final int programPoint) {
   11.61 -        if(programPoint == INVALID_PROGRAM_POINT) {
   11.62 -            method.visitInsn(LMUL);
   11.63 -        } else {
   11.64 -            method.visitInvokeDynamicInsn("lmul", "(JJ)J", MATHBOOTSTRAP, programPoint);
   11.65 -        }
   11.66 -        return LONG;
   11.67 -    }
   11.68 -
   11.69 -    @Override
   11.70 -    public Type div(final MethodVisitor method, final int programPoint) {
   11.71 -        if (programPoint == INVALID_PROGRAM_POINT) {
   11.72 -            JSType.DIV_ZERO_LONG.invoke(method);
   11.73 -        } else {
   11.74 -            method.visitInvokeDynamicInsn("ldiv", "(JJ)J", MATHBOOTSTRAP, programPoint);
   11.75 -        }
   11.76 -        return LONG;
   11.77 -    }
   11.78 -
   11.79 -    @Override
   11.80 -    public Type rem(final MethodVisitor method, final int programPoint) {
   11.81 -        if (programPoint == INVALID_PROGRAM_POINT) {
   11.82 -            JSType.REM_ZERO_LONG.invoke(method);
   11.83 -        } else {
   11.84 -            method.visitInvokeDynamicInsn("lrem", "(JJ)J", MATHBOOTSTRAP, programPoint);
   11.85 -        }
   11.86 -        return LONG;
   11.87 -    }
   11.88 -
   11.89 -    @Override
   11.90 -    public Type shr(final MethodVisitor method) {
   11.91 -        method.visitInsn(LUSHR);
   11.92 -        return LONG;
   11.93 -    }
   11.94 -
   11.95 -    @Override
   11.96 -    public Type sar(final MethodVisitor method) {
   11.97 -        method.visitInsn(LSHR);
   11.98 -        return LONG;
   11.99 -    }
  11.100 -
  11.101 -    @Override
  11.102 -    public Type shl(final MethodVisitor method) {
  11.103 -        method.visitInsn(LSHL);
  11.104 -        return LONG;
  11.105 -    }
  11.106 -
  11.107 -    @Override
  11.108 -    public Type and(final MethodVisitor method) {
  11.109 -        method.visitInsn(LAND);
  11.110 -        return LONG;
  11.111 -    }
  11.112 -
  11.113 -    @Override
  11.114 -    public Type or(final MethodVisitor method) {
  11.115 -        method.visitInsn(LOR);
  11.116 -        return LONG;
  11.117 -    }
  11.118 -
  11.119 -    @Override
  11.120 -    public Type xor(final MethodVisitor method) {
  11.121 -        method.visitInsn(LXOR);
  11.122 -        return LONG;
  11.123 -    }
  11.124 -
  11.125 -    @Override
  11.126 -    public Type neg(final MethodVisitor method, final int programPoint) {
  11.127 -        method.visitInvokeDynamicInsn("lneg", "(J)J", MATHBOOTSTRAP, programPoint);
  11.128 -        return LONG;
  11.129 -    }
  11.130 -
  11.131 -    @Override
  11.132      public void _return(final MethodVisitor method) {
  11.133          method.visitInsn(LRETURN);
  11.134      }
  11.135 @@ -246,9 +149,4 @@
  11.136          method.visitInsn(LCONST_0);
  11.137          return LONG;
  11.138      }
  11.139 -
  11.140 -    @Override
  11.141 -    public Type cmp(final MethodVisitor method, final boolean isCmpG) {
  11.142 -        return cmp(method);
  11.143 -    }
  11.144  }
    12.1 --- a/src/jdk/nashorn/internal/codegen/types/Type.java	Tue Jan 19 18:56:23 2016 +0100
    12.2 +++ b/src/jdk/nashorn/internal/codegen/types/Type.java	Fri Jan 22 16:18:19 2016 +0100
    12.3 @@ -921,7 +921,7 @@
    12.4      /**
    12.5       * This is the long singleton, used for all long types
    12.6       */
    12.7 -    public static final BitwiseType LONG = putInCache(new LongType());
    12.8 +    public static final Type LONG = putInCache(new LongType());
    12.9  
   12.10      /**
   12.11       * A string singleton
    13.1 --- a/src/jdk/nashorn/internal/ir/BinaryNode.java	Tue Jan 19 18:56:23 2016 +0100
    13.2 +++ b/src/jdk/nashorn/internal/ir/BinaryNode.java	Fri Jan 22 16:18:19 2016 +0100
    13.3 @@ -70,7 +70,9 @@
    13.4                  TokenType.ASSIGN_DIV,
    13.5                  TokenType.ASSIGN_MOD,
    13.6                  TokenType.ASSIGN_MUL,
    13.7 -                TokenType.ASSIGN_SUB
    13.8 +                TokenType.ASSIGN_SUB,
    13.9 +                TokenType.SHR,
   13.10 +                TokenType.ASSIGN_SHR
   13.11              })));
   13.12  
   13.13      /**
   13.14 @@ -196,9 +198,7 @@
   13.15                  return Type.CHARSEQUENCE;
   13.16              }
   13.17              final Type widestOperandType = Type.widest(undefinedToNumber(booleanToInt(lhsType)), undefinedToNumber(booleanToInt(rhsType)));
   13.18 -            if(widestOperandType == Type.INT) {
   13.19 -                return Type.LONG;
   13.20 -            } else if (widestOperandType.isNumeric()) {
   13.21 +            if (widestOperandType.isNumeric()) {
   13.22                  return Type.NUMBER;
   13.23              }
   13.24              // We pretty much can't know what it will be statically. Must presume OBJECT conservatively, as we can end
   13.25 @@ -210,7 +210,7 @@
   13.26          }
   13.27          case SHR:
   13.28          case ASSIGN_SHR:
   13.29 -            return Type.LONG;
   13.30 +            return Type.NUMBER;
   13.31          case ASSIGN_SAR:
   13.32          case ASSIGN_SHL:
   13.33          case BIT_AND:
   13.34 @@ -239,10 +239,6 @@
   13.35              if(lhsType == Type.BOOLEAN && rhsType == Type.BOOLEAN) {
   13.36                  return Type.INT;
   13.37              }
   13.38 -            final Type widestOperandType = Type.widest(booleanToInt(lhsType), booleanToInt(rhsType));
   13.39 -            if(widestOperandType == Type.INT) {
   13.40 -                return Type.LONG;
   13.41 -            }
   13.42              return Type.NUMBER;
   13.43          }
   13.44          case VOID: {
   13.45 @@ -565,6 +561,9 @@
   13.46          if(type == null) {
   13.47              return widest;
   13.48          }
   13.49 +        if (tokenType() == TokenType.ASSIGN_SHR || tokenType() == TokenType.SHR) {
   13.50 +            return type;
   13.51 +        }
   13.52          return Type.narrowest(widest, Type.widest(type, Type.widest(lhs.getType(), rhs.getType())));
   13.53      }
   13.54  
    14.1 --- a/src/jdk/nashorn/internal/ir/LiteralNode.java	Tue Jan 19 18:56:23 2016 +0100
    14.2 +++ b/src/jdk/nashorn/internal/ir/LiteralNode.java	Fri Jan 22 16:18:19 2016 +0100
    14.3 @@ -364,8 +364,6 @@
    14.4          private static Type numberGetType(final Number number) {
    14.5              if (number instanceof Integer) {
    14.6                  return Type.INT;
    14.7 -            } else if (number instanceof Long) {
    14.8 -                return Type.LONG;
    14.9              } else if (number instanceof Double) {
   14.10                  return Type.NUMBER;
   14.11              } else {
   14.12 @@ -396,6 +394,7 @@
   14.13       * @return the new literal node
   14.14       */
   14.15      public static LiteralNode<Number> newInstance(final long token, final int finish, final Number value) {
   14.16 +        assert !(value instanceof Long);
   14.17          return new NumberLiteralNode(token, finish, value);
   14.18      }
   14.19  
   14.20 @@ -748,8 +747,6 @@
   14.21                  assert !elementType.isUnknown();
   14.22                  if (elementType.isInteger()) {
   14.23                      return presetIntArray(value, postsets);
   14.24 -                } else if (elementType.isLong()) {
   14.25 -                    return presetLongArray(value, postsets);
   14.26                  } else if (elementType.isNumeric()) {
   14.27                      return presetDoubleArray(value, postsets);
   14.28                  } else {
   14.29 @@ -818,8 +815,6 @@
   14.30          private static ArrayType getArrayType(final Type elementType) {
   14.31              if (elementType.isInteger()) {
   14.32                  return Type.INT_ARRAY;
   14.33 -            } else if (elementType.isLong()) {
   14.34 -                return Type.LONG_ARRAY;
   14.35              } else if (elementType.isNumeric()) {
   14.36                  return Type.NUMBER_ARRAY;
   14.37              } else {
   14.38 @@ -854,8 +849,6 @@
   14.39          private boolean presetsMatchElementType() {
   14.40              if (elementType == Type.INT) {
   14.41                  return presets instanceof int[];
   14.42 -            } else if (elementType == Type.LONG) {
   14.43 -                return presets instanceof long[];
   14.44              } else if (elementType == Type.NUMBER) {
   14.45                  return presets instanceof double[];
   14.46              } else {
    15.1 --- a/src/jdk/nashorn/internal/ir/Symbol.java	Tue Jan 19 18:56:23 2016 +0100
    15.2 +++ b/src/jdk/nashorn/internal/ir/Symbol.java	Fri Jan 22 16:18:19 2016 +0100
    15.3 @@ -82,14 +82,12 @@
    15.4      public static final int HAS_SLOT                = 1 << 10;
    15.5      /** Is this symbol known to store an int value ? */
    15.6      public static final int HAS_INT_VALUE           = 1 << 11;
    15.7 -    /** Is this symbol known to store a long value ? */
    15.8 -    public static final int HAS_LONG_VALUE          = 1 << 12;
    15.9      /** Is this symbol known to store a double value ? */
   15.10 -    public static final int HAS_DOUBLE_VALUE        = 1 << 13;
   15.11 +    public static final int HAS_DOUBLE_VALUE        = 1 << 12;
   15.12      /** Is this symbol known to store an object value ? */
   15.13 -    public static final int HAS_OBJECT_VALUE        = 1 << 14;
   15.14 +    public static final int HAS_OBJECT_VALUE        = 1 << 13;
   15.15      /** Is this symbol seen a declaration? Used for block scoped LET and CONST symbols only. */
   15.16 -    public static final int HAS_BEEN_DECLARED       = 1 << 15;
   15.17 +    public static final int HAS_BEEN_DECLARED       = 1 << 14;
   15.18  
   15.19      /** Null or name identifying symbol. */
   15.20      private final String name;
   15.21 @@ -256,7 +254,6 @@
   15.22       */
   15.23      public int slotCount() {
   15.24          return ((flags & HAS_INT_VALUE)    == 0 ? 0 : 1) +
   15.25 -               ((flags & HAS_LONG_VALUE)   == 0 ? 0 : 2) +
   15.26                 ((flags & HAS_DOUBLE_VALUE) == 0 ? 0 : 2) +
   15.27                 ((flags & HAS_OBJECT_VALUE) == 0 ? 0 : 1);
   15.28      }
   15.29 @@ -278,7 +275,6 @@
   15.30                  append("slot=").
   15.31                  append(firstSlot).append(' ');
   15.32              if((flags & HAS_INT_VALUE) != 0) { sb.append('I'); }
   15.33 -            if((flags & HAS_LONG_VALUE) != 0) { sb.append('J'); }
   15.34              if((flags & HAS_DOUBLE_VALUE) != 0) { sb.append('D'); }
   15.35              if((flags & HAS_OBJECT_VALUE) != 0) { sb.append('O'); }
   15.36              sb.append(')');
   15.37 @@ -573,11 +569,6 @@
   15.38              return typeSlot;
   15.39          }
   15.40          typeSlot += ((flags & HAS_INT_VALUE) == 0 ? 0 : 1);
   15.41 -        if(type.isLong()) {
   15.42 -            assert (flags & HAS_LONG_VALUE) != 0;
   15.43 -            return typeSlot;
   15.44 -        }
   15.45 -        typeSlot += ((flags & HAS_LONG_VALUE) == 0 ? 0 : 2);
   15.46          if(type.isNumber()) {
   15.47              assert (flags & HAS_DOUBLE_VALUE) != 0;
   15.48              return typeSlot;
   15.49 @@ -595,8 +586,6 @@
   15.50      public boolean hasSlotFor(final Type type) {
   15.51          if(type.isBoolean() || type.isInteger()) {
   15.52              return (flags & HAS_INT_VALUE) != 0;
   15.53 -        } else if(type.isLong()) {
   15.54 -            return (flags & HAS_LONG_VALUE) != 0;
   15.55          } else if(type.isNumber()) {
   15.56              return (flags & HAS_DOUBLE_VALUE) != 0;
   15.57          }
   15.58 @@ -611,8 +600,6 @@
   15.59      public void setHasSlotFor(final Type type) {
   15.60          if(type.isBoolean() || type.isInteger()) {
   15.61              setFlag(HAS_INT_VALUE);
   15.62 -        } else if(type.isLong()) {
   15.63 -            setFlag(HAS_LONG_VALUE);
   15.64          } else if(type.isNumber()) {
   15.65              setFlag(HAS_DOUBLE_VALUE);
   15.66          } else {
    16.1 --- a/src/jdk/nashorn/internal/objects/Global.java	Tue Jan 19 18:56:23 2016 +0100
    16.2 +++ b/src/jdk/nashorn/internal/objects/Global.java	Fri Jan 22 16:18:19 2016 +0100
    16.3 @@ -1096,8 +1096,6 @@
    16.4              return new NativeArray(ArrayData.allocate((Object[])obj), this);
    16.5          } else if (obj instanceof double[]) { // extension
    16.6              return new NativeArray(ArrayData.allocate((double[])obj), this);
    16.7 -        } else if (obj instanceof long[]) {
    16.8 -            return new NativeArray(ArrayData.allocate((long[])obj), this);
    16.9          } else if (obj instanceof int[]) {
   16.10              return new NativeArray(ArrayData.allocate((int[]) obj), this);
   16.11          } else if (obj instanceof ArrayData) {
   16.12 @@ -1965,16 +1963,6 @@
   16.13      }
   16.14  
   16.15      /**
   16.16 -     * Allocate a new long array.
   16.17 -     *
   16.18 -     * @param initial number values.
   16.19 -     * @return the new array
   16.20 -     */
   16.21 -    public static NativeArray allocate(final long[] initial) {
   16.22 -        return new NativeArray(ArrayData.allocate(initial));
   16.23 -    }
   16.24 -
   16.25 -    /**
   16.26       * Allocate a new integer array.
   16.27       *
   16.28       * @param initial number values.
   16.29 @@ -2263,7 +2251,6 @@
   16.30                      new Specialization[] {
   16.31                      new Specialization(GlobalFunctions.PARSEINT_Z),
   16.32                      new Specialization(GlobalFunctions.PARSEINT_I),
   16.33 -                    new Specialization(GlobalFunctions.PARSEINT_J),
   16.34                      new Specialization(GlobalFunctions.PARSEINT_OI),
   16.35                      new Specialization(GlobalFunctions.PARSEINT_O) });
   16.36          this.parseFloat = ScriptFunction.createBuiltin("parseFloat", GlobalFunctions.PARSEFLOAT);
    17.1 --- a/src/jdk/nashorn/internal/objects/NativeArguments.java	Tue Jan 19 18:56:23 2016 +0100
    17.2 +++ b/src/jdk/nashorn/internal/objects/NativeArguments.java	Fri Jan 22 16:18:19 2016 +0100
    17.3 @@ -128,12 +128,6 @@
    17.4      }
    17.5  
    17.6      @Override
    17.7 -    public boolean delete(final long key, final boolean strict) {
    17.8 -        final int index = ArrayIndex.getArrayIndex(key);
    17.9 -        return isMapped(index) ? deleteMapped(index, strict) : super.delete(key, strict);
   17.10 -    }
   17.11 -
   17.12 -    @Override
   17.13      public boolean delete(final double key, final boolean strict) {
   17.14          final int index = ArrayIndex.getArrayIndex(key);
   17.15          return isMapped(index) ? deleteMapped(index, strict) : super.delete(key, strict);
    18.1 --- a/src/jdk/nashorn/internal/objects/NativeArray.java	Tue Jan 19 18:56:23 2016 +0100
    18.2 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java	Fri Jan 22 16:18:19 2016 +0100
    18.3 @@ -100,20 +100,38 @@
    18.4      }
    18.5  
    18.6      NativeArray(final long length) {
    18.7 -        // TODO assert valid index in long before casting
    18.8 -        this(ArrayData.allocate((int)length));
    18.9 +        this(ArrayData.allocate(length));
   18.10      }
   18.11  
   18.12      NativeArray(final int[] array) {
   18.13          this(ArrayData.allocate(array));
   18.14      }
   18.15  
   18.16 -    NativeArray(final long[] array) {
   18.17 +    NativeArray(final double[] array) {
   18.18          this(ArrayData.allocate(array));
   18.19      }
   18.20  
   18.21 -    NativeArray(final double[] array) {
   18.22 -        this(ArrayData.allocate(array));
   18.23 +    NativeArray(final long[] array) {
   18.24 +        this(ArrayData.allocate(array.length));
   18.25 +
   18.26 +        ArrayData arrayData = this.getArray();
   18.27 +        Class<?> widest = int.class;
   18.28 +
   18.29 +        for (int index = 0; index < array.length; index++) {
   18.30 +            final long value = array[index];
   18.31 +
   18.32 +            if (widest == int.class && JSType.isRepresentableAsInt(value)) {
   18.33 +                arrayData = arrayData.set(index, (int) value, false);
   18.34 +            } else if (widest != Object.class && JSType.isRepresentableAsDouble(value)) {
   18.35 +                arrayData = arrayData.set(index, (double) value, false);
   18.36 +                widest = double.class;
   18.37 +            } else {
   18.38 +                arrayData = arrayData.set(index, (Object) value, false);
   18.39 +                widest = Object.class;
   18.40 +            }
   18.41 +        }
   18.42 +
   18.43 +        this.setArray(arrayData);
   18.44      }
   18.45  
   18.46      NativeArray(final Object[] array) {
   18.47 @@ -188,7 +206,7 @@
   18.48                  @Override
   18.49                  public MethodHandle call() {
   18.50                      return Bootstrap.createDynamicInvoker("dyn:call", rtype, Object.class, Object.class, Object.class,
   18.51 -                        long.class, Object.class);
   18.52 +                        double.class, Object.class);
   18.53                  }
   18.54              });
   18.55      }
   18.56 @@ -219,7 +237,7 @@
   18.57                      @Override
   18.58                      public MethodHandle call() {
   18.59                          return Bootstrap.createDynamicInvoker("dyn:call", Object.class, Object.class,
   18.60 -                             Undefined.class, Object.class, Object.class, long.class, Object.class);
   18.61 +                             Undefined.class, Object.class, Object.class, double.class, Object.class);
   18.62                      }
   18.63                  });
   18.64      }
   18.65 @@ -255,8 +273,9 @@
   18.66  
   18.67      @Override
   18.68      public Object getLength() {
   18.69 -        final long length = JSType.toUint32(getArray().length());
   18.70 -        if (length < Integer.MAX_VALUE) {
   18.71 +        final long length = getArray().length();
   18.72 +        assert length >= 0L;
   18.73 +        if (length <= Integer.MAX_VALUE) {
   18.74              return (int)length;
   18.75          }
   18.76          return length;
   18.77 @@ -454,7 +473,13 @@
   18.78      @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
   18.79      public static Object length(final Object self) {
   18.80          if (isArray(self)) {
   18.81 -            return JSType.toUint32(((ScriptObject) self).getArray().length());
   18.82 +            final long length = ((ScriptObject) self).getArray().length();
   18.83 +            assert length >= 0L;
   18.84 +            // Cast to the narrowest supported numeric type to help optimistic type calculator
   18.85 +            if (length <= Integer.MAX_VALUE) {
   18.86 +                return (int) length;
   18.87 +            }
   18.88 +            return (double) length;
   18.89          }
   18.90  
   18.91          return 0;
   18.92 @@ -1562,7 +1587,7 @@
   18.93              private final MethodHandle everyInvoker = getEVERY_CALLBACK_INVOKER();
   18.94  
   18.95              @Override
   18.96 -            protected boolean forEach(final Object val, final long i) throws Throwable {
   18.97 +            protected boolean forEach(final Object val, final double i) throws Throwable {
   18.98                  return result = (boolean)everyInvoker.invokeExact(callbackfn, thisArg, val, i, self);
   18.99              }
  18.100          }.apply();
  18.101 @@ -1582,7 +1607,7 @@
  18.102              private final MethodHandle someInvoker = getSOME_CALLBACK_INVOKER();
  18.103  
  18.104              @Override
  18.105 -            protected boolean forEach(final Object val, final long i) throws Throwable {
  18.106 +            protected boolean forEach(final Object val, final double i) throws Throwable {
  18.107                  return !(result = (boolean)someInvoker.invokeExact(callbackfn, thisArg, val, i, self));
  18.108              }
  18.109          }.apply();
  18.110 @@ -1602,7 +1627,7 @@
  18.111              private final MethodHandle forEachInvoker = getFOREACH_CALLBACK_INVOKER();
  18.112  
  18.113              @Override
  18.114 -            protected boolean forEach(final Object val, final long i) throws Throwable {
  18.115 +            protected boolean forEach(final Object val, final double i) throws Throwable {
  18.116                  forEachInvoker.invokeExact(callbackfn, thisArg, val, i, self);
  18.117                  return true;
  18.118              }
  18.119 @@ -1623,7 +1648,7 @@
  18.120              private final MethodHandle mapInvoker = getMAP_CALLBACK_INVOKER();
  18.121  
  18.122              @Override
  18.123 -            protected boolean forEach(final Object val, final long i) throws Throwable {
  18.124 +            protected boolean forEach(final Object val, final double i) throws Throwable {
  18.125                  final Object r = mapInvoker.invokeExact(callbackfn, thisArg, val, i, self);
  18.126                  result.defineOwnProperty(ArrayIndex.getArrayIndex(index), r);
  18.127                  return true;
  18.128 @@ -1653,7 +1678,7 @@
  18.129              private final MethodHandle filterInvoker = getFILTER_CALLBACK_INVOKER();
  18.130  
  18.131              @Override
  18.132 -            protected boolean forEach(final Object val, final long i) throws Throwable {
  18.133 +            protected boolean forEach(final Object val, final double i) throws Throwable {
  18.134                  if ((boolean)filterInvoker.invokeExact(callbackfn, thisArg, val, i, self)) {
  18.135                      result.defineOwnProperty(ArrayIndex.getArrayIndex(to++), val);
  18.136                  }
  18.137 @@ -1685,7 +1710,7 @@
  18.138              private final MethodHandle reduceInvoker = getREDUCE_CALLBACK_INVOKER();
  18.139  
  18.140              @Override
  18.141 -            protected boolean forEach(final Object val, final long i) throws Throwable {
  18.142 +            protected boolean forEach(final Object val, final double i) throws Throwable {
  18.143                  // TODO: why can't I declare the second arg as Undefined.class?
  18.144                  result = reduceInvoker.invokeExact(callbackfn, ScriptRuntime.UNDEFINED, result, val, i, self);
  18.145                  return true;
    19.1 --- a/src/jdk/nashorn/internal/objects/NativeFloat32Array.java	Tue Jan 19 18:56:23 2016 +0100
    19.2 +++ b/src/jdk/nashorn/internal/objects/NativeFloat32Array.java	Fri Jan 22 16:18:19 2016 +0100
    19.3 @@ -124,7 +124,7 @@
    19.4  
    19.5          @Override
    19.6          public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) {
    19.7 -            if (returnType == int.class || returnType == long.class) {
    19.8 +            if (returnType == int.class) {
    19.9                  return null;
   19.10              }
   19.11              return getContinuousElementGetter(getClass(), GET_ELEM, returnType, programPoint);
   19.12 @@ -136,11 +136,6 @@
   19.13          }
   19.14  
   19.15          @Override
   19.16 -        public long getLong(final int index) {
   19.17 -            return (long)getDouble(index);
   19.18 -        }
   19.19 -
   19.20 -        @Override
   19.21          public double getDouble(final int index) {
   19.22              return getElem(index);
   19.23          }
   19.24 @@ -166,11 +161,6 @@
   19.25          }
   19.26  
   19.27          @Override
   19.28 -        public ArrayData set(final int index, final long value, final boolean strict) {
   19.29 -            return set(index, (double)value, strict);
   19.30 -        }
   19.31 -
   19.32 -        @Override
   19.33          public ArrayData set(final int index, final double value, final boolean strict) {
   19.34              setElem(index, value);
   19.35              return this;
    20.1 --- a/src/jdk/nashorn/internal/objects/NativeFloat64Array.java	Tue Jan 19 18:56:23 2016 +0100
    20.2 +++ b/src/jdk/nashorn/internal/objects/NativeFloat64Array.java	Fri Jan 22 16:18:19 2016 +0100
    20.3 @@ -124,7 +124,7 @@
    20.4  
    20.5          @Override
    20.6          public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) {
    20.7 -            if (returnType == int.class || returnType == long.class) {
    20.8 +            if (returnType == int.class) {
    20.9                  return null;
   20.10              }
   20.11              return getContinuousElementGetter(getClass(), GET_ELEM, returnType, programPoint);
   20.12 @@ -136,11 +136,6 @@
   20.13          }
   20.14  
   20.15          @Override
   20.16 -        public long getLong(final int index) {
   20.17 -            return (long)getDouble(index);
   20.18 -        }
   20.19 -
   20.20 -        @Override
   20.21          public double getDouble(final int index) {
   20.22              return getElem(index);
   20.23          }
   20.24 @@ -166,11 +161,6 @@
   20.25          }
   20.26  
   20.27          @Override
   20.28 -        public ArrayData set(final int index, final long value, final boolean strict) {
   20.29 -            return set(index, (double)value, strict);
   20.30 -        }
   20.31 -
   20.32 -        @Override
   20.33          public ArrayData set(final int index, final double value, final boolean strict) {
   20.34              setElem(index, value);
   20.35              return this;
    21.1 --- a/src/jdk/nashorn/internal/objects/NativeInt16Array.java	Tue Jan 19 18:56:23 2016 +0100
    21.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt16Array.java	Fri Jan 22 16:18:19 2016 +0100
    21.3 @@ -134,16 +134,6 @@
    21.4          }
    21.5  
    21.6          @Override
    21.7 -        public long getLong(final int index) {
    21.8 -            return getInt(index);
    21.9 -        }
   21.10 -
   21.11 -        @Override
   21.12 -        public long getLongOptimistic(final int index, final int programPoint) {
   21.13 -            return getElem(index);
   21.14 -        }
   21.15 -
   21.16 -        @Override
   21.17          public double getDouble(final int index) {
   21.18              return getInt(index);
   21.19          }
   21.20 @@ -170,11 +160,6 @@
   21.21          }
   21.22  
   21.23          @Override
   21.24 -        public ArrayData set(final int index, final long value, final boolean strict) {
   21.25 -            return set(index, (int)value, strict);
   21.26 -        }
   21.27 -
   21.28 -        @Override
   21.29          public ArrayData set(final int index, final double value, final boolean strict) {
   21.30              return set(index, (int)value, strict);
   21.31          }
    22.1 --- a/src/jdk/nashorn/internal/objects/NativeInt32Array.java	Tue Jan 19 18:56:23 2016 +0100
    22.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt32Array.java	Fri Jan 22 16:18:19 2016 +0100
    22.3 @@ -133,16 +133,6 @@
    22.4          }
    22.5  
    22.6          @Override
    22.7 -        public long getLong(final int index) {
    22.8 -            return getInt(index);
    22.9 -        }
   22.10 -
   22.11 -        @Override
   22.12 -        public long getLongOptimistic(final int index, final int programPoint) {
   22.13 -            return getElem(index);
   22.14 -        }
   22.15 -
   22.16 -        @Override
   22.17          public double getDouble(final int index) {
   22.18              return getInt(index);
   22.19          }
   22.20 @@ -169,11 +159,6 @@
   22.21          }
   22.22  
   22.23          @Override
   22.24 -        public ArrayData set(final int index, final long value, final boolean strict) {
   22.25 -            return set(index, (int)value, strict);
   22.26 -        }
   22.27 -
   22.28 -        @Override
   22.29          public ArrayData set(final int index, final double value, final boolean strict) {
   22.30              return set(index, (int)value, strict);
   22.31          }
    23.1 --- a/src/jdk/nashorn/internal/objects/NativeInt8Array.java	Tue Jan 19 18:56:23 2016 +0100
    23.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt8Array.java	Fri Jan 22 16:18:19 2016 +0100
    23.3 @@ -132,16 +132,6 @@
    23.4          }
    23.5  
    23.6          @Override
    23.7 -        public long getLong(final int index) {
    23.8 -            return getInt(index);
    23.9 -        }
   23.10 -
   23.11 -        @Override
   23.12 -        public long getLongOptimistic(final int index, final int programPoint) {
   23.13 -            return getElem(index);
   23.14 -        }
   23.15 -
   23.16 -        @Override
   23.17          public double getDouble(final int index) {
   23.18              return getInt(index);
   23.19          }
   23.20 @@ -168,11 +158,6 @@
   23.21          }
   23.22  
   23.23          @Override
   23.24 -        public ArrayData set(final int index, final long value, final boolean strict) {
   23.25 -            return set(index, (int)value, strict);
   23.26 -        }
   23.27 -
   23.28 -        @Override
   23.29          public ArrayData set(final int index, final double value, final boolean strict) {
   23.30              return set(index, (int)value, strict);
   23.31          }
    24.1 --- a/src/jdk/nashorn/internal/objects/NativeJSAdapter.java	Tue Jan 19 18:56:23 2016 +0100
    24.2 +++ b/src/jdk/nashorn/internal/objects/NativeJSAdapter.java	Fri Jan 22 16:18:19 2016 +0100
    24.3 @@ -179,36 +179,11 @@
    24.4      }
    24.5  
    24.6      @Override
    24.7 -    public int getInt(final long key, final int programPoint) {
    24.8 -        return (overrides && super.hasOwnProperty(key)) ? super.getInt(key, programPoint) : callAdapteeInt(programPoint, __get__, key);
    24.9 -    }
   24.10 -
   24.11 -    @Override
   24.12      public int getInt(final int key, final int programPoint) {
   24.13          return (overrides && super.hasOwnProperty(key)) ? super.getInt(key, programPoint) : callAdapteeInt(programPoint, __get__, key);
   24.14      }
   24.15  
   24.16      @Override
   24.17 -    public long getLong(final Object key, final int programPoint) {
   24.18 -        return (overrides && super.hasOwnProperty(key)) ? super.getLong(key, programPoint) : callAdapteeLong(programPoint, __get__, key);
   24.19 -    }
   24.20 -
   24.21 -    @Override
   24.22 -    public long getLong(final double key, final int programPoint) {
   24.23 -        return (overrides && super.hasOwnProperty(key)) ? super.getLong(key, programPoint) : callAdapteeLong(programPoint, __get__, key);
   24.24 -    }
   24.25 -
   24.26 -    @Override
   24.27 -    public long getLong(final long key, final int programPoint) {
   24.28 -        return (overrides && super.hasOwnProperty(key)) ? super.getLong(key, programPoint) : callAdapteeLong(programPoint, __get__, key);
   24.29 -    }
   24.30 -
   24.31 -    @Override
   24.32 -    public long getLong(final int key, final int programPoint) {
   24.33 -        return (overrides && super.hasOwnProperty(key)) ? super.getLong(key, programPoint) : callAdapteeLong(programPoint, __get__, key);
   24.34 -    }
   24.35 -
   24.36 -    @Override
   24.37      public double getDouble(final Object key, final int programPoint) {
   24.38          return (overrides && super.hasOwnProperty(key)) ? super.getDouble(key, programPoint) : callAdapteeDouble(programPoint, __get__, key);
   24.39      }
   24.40 @@ -219,11 +194,6 @@
   24.41      }
   24.42  
   24.43      @Override
   24.44 -    public double getDouble(final long key, final int programPoint) {
   24.45 -        return (overrides && super.hasOwnProperty(key)) ? super.getDouble(key, programPoint) : callAdapteeDouble(programPoint, __get__, key);
   24.46 -    }
   24.47 -
   24.48 -    @Override
   24.49      public double getDouble(final int key, final int programPoint) {
   24.50          return (overrides && super.hasOwnProperty(key)) ? super.getDouble(key, programPoint) : callAdapteeDouble(programPoint, __get__, key);
   24.51      }
   24.52 @@ -239,11 +209,6 @@
   24.53      }
   24.54  
   24.55      @Override
   24.56 -    public Object get(final long key) {
   24.57 -        return (overrides && super.hasOwnProperty(key)) ? super.get(key) : callAdaptee(__get__, key);
   24.58 -    }
   24.59 -
   24.60 -    @Override
   24.61      public Object get(final int key) {
   24.62          return (overrides && super.hasOwnProperty(key)) ? super.get(key) : callAdaptee(__get__, key);
   24.63      }
   24.64 @@ -258,15 +223,6 @@
   24.65      }
   24.66  
   24.67      @Override
   24.68 -    public void set(final Object key, final long value, final int flags) {
   24.69 -        if (overrides && super.hasOwnProperty(key)) {
   24.70 -            super.set(key, value, flags);
   24.71 -        } else {
   24.72 -            callAdaptee(__put__, key, value, flags);
   24.73 -        }
   24.74 -    }
   24.75 -
   24.76 -    @Override
   24.77      public void set(final Object key, final double value, final int flags) {
   24.78          if (overrides && super.hasOwnProperty(key)) {
   24.79              super.set(key, value, flags);
   24.80 @@ -294,15 +250,6 @@
   24.81      }
   24.82  
   24.83      @Override
   24.84 -    public void set(final double key, final long value, final int flags) {
   24.85 -        if (overrides && super.hasOwnProperty(key)) {
   24.86 -            super.set(key, value, flags);
   24.87 -        } else {
   24.88 -            callAdaptee(__put__, key, value, flags);
   24.89 -        }
   24.90 -    }
   24.91 -
   24.92 -    @Override
   24.93      public void set(final double key, final double value, final int flags) {
   24.94          if (overrides && super.hasOwnProperty(key)) {
   24.95              super.set(key, value, flags);
   24.96 @@ -321,42 +268,6 @@
   24.97      }
   24.98  
   24.99      @Override
  24.100 -    public void set(final long key, final int value, final int flags) {
  24.101 -        if (overrides && super.hasOwnProperty(key)) {
  24.102 -            super.set(key, value, flags);
  24.103 -        } else {
  24.104 -            callAdaptee(__put__, key, value, flags);
  24.105 -        }
  24.106 -    }
  24.107 -
  24.108 -    @Override
  24.109 -    public void set(final long key, final long value, final int flags) {
  24.110 -        if (overrides && super.hasOwnProperty(key)) {
  24.111 -            super.set(key, value, flags);
  24.112 -        } else {
  24.113 -            callAdaptee(__put__, key, value, flags);
  24.114 -        }
  24.115 -    }
  24.116 -
  24.117 -    @Override
  24.118 -    public void set(final long key, final double value, final int flags) {
  24.119 -        if (overrides && super.hasOwnProperty(key)) {
  24.120 -            super.set(key, value, flags);
  24.121 -        } else {
  24.122 -            callAdaptee(__put__, key, value, flags);
  24.123 -        }
  24.124 -    }
  24.125 -
  24.126 -    @Override
  24.127 -    public void set(final long key, final Object value, final int flags) {
  24.128 -        if (overrides && super.hasOwnProperty(key)) {
  24.129 -            super.set(key, value, flags);
  24.130 -        } else {
  24.131 -            callAdaptee(__put__, key, value, flags);
  24.132 -        }
  24.133 -    }
  24.134 -
  24.135 -    @Override
  24.136      public void set(final int key, final int value, final int flags) {
  24.137          if (overrides && super.hasOwnProperty(key)) {
  24.138              super.set(key, value, flags);
  24.139 @@ -366,15 +277,6 @@
  24.140      }
  24.141  
  24.142      @Override
  24.143 -    public void set(final int key, final long value, final int flags) {
  24.144 -        if (overrides && super.hasOwnProperty(key)) {
  24.145 -            super.set(key, value, flags);
  24.146 -        } else {
  24.147 -            callAdaptee(__put__, key, value, flags);
  24.148 -        }
  24.149 -    }
  24.150 -
  24.151 -    @Override
  24.152      public void set(final int key, final double value, final int flags) {
  24.153          if (overrides && super.hasOwnProperty(key)) {
  24.154              super.set(key, value, flags);
  24.155 @@ -411,15 +313,6 @@
  24.156      }
  24.157  
  24.158      @Override
  24.159 -    public boolean has(final long key) {
  24.160 -        if (overrides && super.hasOwnProperty(key)) {
  24.161 -            return true;
  24.162 -        }
  24.163 -
  24.164 -        return JSType.toBoolean(callAdaptee(Boolean.FALSE, __has__, key));
  24.165 -    }
  24.166 -
  24.167 -    @Override
  24.168      public boolean has(final double key) {
  24.169          if (overrides && super.hasOwnProperty(key)) {
  24.170              return true;
  24.171 @@ -438,15 +331,6 @@
  24.172      }
  24.173  
  24.174      @Override
  24.175 -    public boolean delete(final long key, final boolean strict) {
  24.176 -        if (overrides && super.hasOwnProperty(key)) {
  24.177 -            return super.delete(key, strict);
  24.178 -        }
  24.179 -
  24.180 -        return JSType.toBoolean(callAdaptee(Boolean.TRUE, __delete__, key, strict));
  24.181 -    }
  24.182 -
  24.183 -    @Override
  24.184      public boolean delete(final double key, final boolean strict) {
  24.185          if (overrides && super.hasOwnProperty(key)) {
  24.186              return super.delete(key, strict);
  24.187 @@ -663,10 +547,6 @@
  24.188          return JSType.toNumberMaybeOptimistic(callAdaptee(name, args), programPoint);
  24.189      }
  24.190  
  24.191 -    private long callAdapteeLong(final int programPoint, final String name, final Object... args) {
  24.192 -        return JSType.toLongMaybeOptimistic(callAdaptee(name, args), programPoint);
  24.193 -    }
  24.194 -
  24.195      private int callAdapteeInt(final int programPoint, final String name, final Object... args) {
  24.196          return JSType.toInt32MaybeOptimistic(callAdaptee(name, args), programPoint);
  24.197      }
    25.1 --- a/src/jdk/nashorn/internal/objects/NativeString.java	Tue Jan 19 18:56:23 2016 +0100
    25.2 +++ b/src/jdk/nashorn/internal/objects/NativeString.java	Fri Jan 22 16:18:19 2016 +0100
    25.3 @@ -221,14 +221,6 @@
    25.4      }
    25.5  
    25.6      @Override
    25.7 -    public Object get(final long key) {
    25.8 -        if (key >= 0 && key < value.length()) {
    25.9 -            return String.valueOf(value.charAt((int)key));
   25.10 -        }
   25.11 -        return super.get(key);
   25.12 -    }
   25.13 -
   25.14 -    @Override
   25.15      public Object get(final int key) {
   25.16          if (key >= 0 && key < value.length()) {
   25.17              return String.valueOf(value.charAt(key));
   25.18 @@ -247,36 +239,11 @@
   25.19      }
   25.20  
   25.21      @Override
   25.22 -    public int getInt(final long key, final int programPoint) {
   25.23 -        return JSType.toInt32MaybeOptimistic(get(key), programPoint);
   25.24 -    }
   25.25 -
   25.26 -    @Override
   25.27      public int getInt(final int key, final int programPoint) {
   25.28          return JSType.toInt32MaybeOptimistic(get(key), programPoint);
   25.29      }
   25.30  
   25.31      @Override
   25.32 -    public long getLong(final Object key, final int programPoint) {
   25.33 -        return JSType.toLongMaybeOptimistic(get(key), programPoint);
   25.34 -    }
   25.35 -
   25.36 -    @Override
   25.37 -    public long getLong(final double key, final int programPoint) {
   25.38 -        return JSType.toLongMaybeOptimistic(get(key), programPoint);
   25.39 -    }
   25.40 -
   25.41 -    @Override
   25.42 -    public long getLong(final long key, final int programPoint) {
   25.43 -        return JSType.toLongMaybeOptimistic(get(key), programPoint);
   25.44 -    }
   25.45 -
   25.46 -    @Override
   25.47 -    public long getLong(final int key, final int programPoint) {
   25.48 -        return JSType.toLongMaybeOptimistic(get(key), programPoint);
   25.49 -    }
   25.50 -
   25.51 -    @Override
   25.52      public double getDouble(final Object key, final int programPoint) {
   25.53          return JSType.toNumberMaybeOptimistic(get(key), programPoint);
   25.54      }
   25.55 @@ -287,11 +254,6 @@
   25.56      }
   25.57  
   25.58      @Override
   25.59 -    public double getDouble(final long key, final int programPoint) {
   25.60 -        return JSType.toNumberMaybeOptimistic(get(key), programPoint);
   25.61 -    }
   25.62 -
   25.63 -    @Override
   25.64      public double getDouble(final int key, final int programPoint) {
   25.65          return JSType.toNumberMaybeOptimistic(get(key), programPoint);
   25.66      }
   25.67 @@ -309,12 +271,6 @@
   25.68      }
   25.69  
   25.70      @Override
   25.71 -    public boolean has(final long key) {
   25.72 -        final int index = ArrayIndex.getArrayIndex(key);
   25.73 -        return isValidStringIndex(index) || super.has(key);
   25.74 -    }
   25.75 -
   25.76 -    @Override
   25.77      public boolean has(final double key) {
   25.78          final int index = ArrayIndex.getArrayIndex(key);
   25.79          return isValidStringIndex(index) || super.has(key);
   25.80 @@ -333,12 +289,6 @@
   25.81      }
   25.82  
   25.83      @Override
   25.84 -    public boolean hasOwnProperty(final long key) {
   25.85 -        final int index = ArrayIndex.getArrayIndex(key);
   25.86 -        return isValidStringIndex(index) || super.hasOwnProperty(key);
   25.87 -    }
   25.88 -
   25.89 -    @Override
   25.90      public boolean hasOwnProperty(final double key) {
   25.91          final int index = ArrayIndex.getArrayIndex(key);
   25.92          return isValidStringIndex(index) || super.hasOwnProperty(key);
   25.93 @@ -350,12 +300,6 @@
   25.94      }
   25.95  
   25.96      @Override
   25.97 -    public boolean delete(final long key, final boolean strict) {
   25.98 -        final int index = ArrayIndex.getArrayIndex(key);
   25.99 -        return checkDeleteIndex(index, strict)? false : super.delete(key, strict);
  25.100 -    }
  25.101 -
  25.102 -    @Override
  25.103      public boolean delete(final double key, final boolean strict) {
  25.104          final int index = ArrayIndex.getArrayIndex(key);
  25.105          return checkDeleteIndex(index, strict)? false : super.delete(key, strict);
    26.1 --- a/src/jdk/nashorn/internal/objects/NativeUint16Array.java	Tue Jan 19 18:56:23 2016 +0100
    26.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint16Array.java	Fri Jan 22 16:18:19 2016 +0100
    26.3 @@ -138,16 +138,6 @@
    26.4          }
    26.5  
    26.6          @Override
    26.7 -        public long getLong(final int index) {
    26.8 -            return getInt(index);
    26.9 -        }
   26.10 -
   26.11 -        @Override
   26.12 -        public long getLongOptimistic(final int index, final int programPoint) {
   26.13 -            return getElem(index);
   26.14 -        }
   26.15 -
   26.16 -        @Override
   26.17          public double getDouble(final int index) {
   26.18              return getInt(index);
   26.19          }
   26.20 @@ -174,11 +164,6 @@
   26.21          }
   26.22  
   26.23          @Override
   26.24 -        public ArrayData set(final int index, final long value, final boolean strict) {
   26.25 -            return set(index, (int)value, strict);
   26.26 -        }
   26.27 -
   26.28 -        @Override
   26.29          public ArrayData set(final int index, final double value, final boolean strict) {
   26.30              return set(index, (int)value, strict);
   26.31          }
    27.1 --- a/src/jdk/nashorn/internal/objects/NativeUint32Array.java	Tue Jan 19 18:56:23 2016 +0100
    27.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint32Array.java	Fri Jan 22 16:18:19 2016 +0100
    27.3 @@ -32,6 +32,7 @@
    27.4  import java.nio.ByteBuffer;
    27.5  import java.nio.ByteOrder;
    27.6  import java.nio.IntBuffer;
    27.7 +import jdk.nashorn.internal.codegen.types.Type;
    27.8  import jdk.nashorn.internal.objects.annotations.Attribute;
    27.9  import jdk.nashorn.internal.objects.annotations.Constructor;
   27.10  import jdk.nashorn.internal.objects.annotations.Function;
   27.11 @@ -41,6 +42,7 @@
   27.12  import jdk.nashorn.internal.runtime.JSType;
   27.13  import jdk.nashorn.internal.runtime.PropertyMap;
   27.14  import jdk.nashorn.internal.runtime.ScriptObject;
   27.15 +import jdk.nashorn.internal.runtime.UnwarrantedOptimismException;
   27.16  import jdk.nashorn.internal.runtime.arrays.ArrayData;
   27.17  import jdk.nashorn.internal.runtime.arrays.TypedArrayData;
   27.18  
   27.19 @@ -78,7 +80,7 @@
   27.20  
   27.21      private static final class Uint32ArrayData extends TypedArrayData<IntBuffer> {
   27.22  
   27.23 -        private static final MethodHandle GET_ELEM = specialCall(MethodHandles.lookup(), Uint32ArrayData.class, "getElem", long.class, int.class).methodHandle();
   27.24 +        private static final MethodHandle GET_ELEM = specialCall(MethodHandles.lookup(), Uint32ArrayData.class, "getElem", double.class, int.class).methodHandle();
   27.25          private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint32ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle();
   27.26  
   27.27          private Uint32ArrayData(final IntBuffer nb, final int start, final int end) {
   27.28 @@ -103,14 +105,18 @@
   27.29              return getContinuousElementGetter(getClass(), GET_ELEM, returnType, programPoint);
   27.30          }
   27.31  
   27.32 -        private long getElem(final int index) {
   27.33 +        private int getRawElem(final int index) {
   27.34              try {
   27.35 -                return JSType.toUint32(nb.get(index));
   27.36 +                return nb.get(index);
   27.37              } catch (final IndexOutOfBoundsException e) {
   27.38                  throw new ClassCastException(); //force relink - this works for unoptimistic too
   27.39              }
   27.40          }
   27.41  
   27.42 +        private double getElem(final int index) {
   27.43 +            return JSType.toUint32(getRawElem(index));
   27.44 +        }
   27.45 +
   27.46          private void setElem(final int index, final int elem) {
   27.47              try {
   27.48                  if (index < nb.limit()) {
   27.49 @@ -128,42 +134,37 @@
   27.50  
   27.51          @Override
   27.52          public Class<?> getElementType() {
   27.53 -            return long.class;
   27.54 +            return double.class;
   27.55          }
   27.56  
   27.57          @Override
   27.58          public Class<?> getBoxedElementType() {
   27.59 -            return Integer.class;
   27.60 +            return Double.class;
   27.61          }
   27.62  
   27.63          @Override
   27.64          public int getInt(final int index) {
   27.65 -            return (int)getLong(index);
   27.66 +            return getRawElem(index);
   27.67          }
   27.68  
   27.69          @Override
   27.70 -        public long getLong(final int index) {
   27.71 +        public int getIntOptimistic(final int index, final int programPoint) {
   27.72 +            return JSType.toUint32Optimistic(getRawElem(index), programPoint);
   27.73 +        }
   27.74 +
   27.75 +        @Override
   27.76 +        public double getDouble(final int index) {
   27.77              return getElem(index);
   27.78          }
   27.79  
   27.80          @Override
   27.81 -        public long getLongOptimistic(final int index, final int programPoint) {
   27.82 +        public double getDoubleOptimistic(final int index, final int programPoint) {
   27.83              return getElem(index);
   27.84          }
   27.85  
   27.86          @Override
   27.87 -        public double getDouble(final int index) {
   27.88 -            return getLong(index);
   27.89 -        }
   27.90 -
   27.91 -        @Override
   27.92 -        public double getDoubleOptimistic(final int index, final int programPoint) {
   27.93 -            return getLong(index);
   27.94 -        }
   27.95 -
   27.96 -        @Override
   27.97          public Object getObject(final int index) {
   27.98 -            return getLong(index);
   27.99 +            return getElem(index);
  27.100          }
  27.101  
  27.102          @Override
  27.103 @@ -178,11 +179,6 @@
  27.104          }
  27.105  
  27.106          @Override
  27.107 -        public ArrayData set(final int index, final long value, final boolean strict) {
  27.108 -            return set(index, (int)value, strict);
  27.109 -        }
  27.110 -
  27.111 -        @Override
  27.112          public ArrayData set(final int index, final double value, final boolean strict) {
  27.113              return set(index, (int)value, strict);
  27.114          }
    28.1 --- a/src/jdk/nashorn/internal/objects/NativeUint8Array.java	Tue Jan 19 18:56:23 2016 +0100
    28.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint8Array.java	Fri Jan 22 16:18:19 2016 +0100
    28.3 @@ -138,16 +138,6 @@
    28.4          }
    28.5  
    28.6          @Override
    28.7 -        public long getLong(final int index) {
    28.8 -            return getInt(index);
    28.9 -        }
   28.10 -
   28.11 -        @Override
   28.12 -        public long getLongOptimistic(final int index, final int programPoint) {
   28.13 -            return getElem(index);
   28.14 -        }
   28.15 -
   28.16 -        @Override
   28.17          public double getDouble(final int index) {
   28.18              return getInt(index);
   28.19          }
   28.20 @@ -174,11 +164,6 @@
   28.21          }
   28.22  
   28.23          @Override
   28.24 -        public ArrayData set(final int index, final long value, final boolean strict) {
   28.25 -            return set(index, (int)value, strict);
   28.26 -        }
   28.27 -
   28.28 -        @Override
   28.29          public ArrayData set(final int index, final double value, final boolean strict) {
   28.30              return set(index, (int)value, strict);
   28.31          }
    29.1 --- a/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Tue Jan 19 18:56:23 2016 +0100
    29.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Fri Jan 22 16:18:19 2016 +0100
    29.3 @@ -168,16 +168,6 @@
    29.4          }
    29.5  
    29.6          @Override
    29.7 -        public long getLong(final int index) {
    29.8 -            return getInt(index);
    29.9 -        }
   29.10 -
   29.11 -        @Override
   29.12 -        public long getLongOptimistic(final int index, final int programPoint) {
   29.13 -            return getElem(index);
   29.14 -        }
   29.15 -
   29.16 -        @Override
   29.17          public double getDouble(final int index) {
   29.18              return getInt(index);
   29.19          }
   29.20 @@ -204,11 +194,6 @@
   29.21          }
   29.22  
   29.23          @Override
   29.24 -        public ArrayData set(final int index, final long value, final boolean strict) {
   29.25 -            return set(index, (int)value, strict);
   29.26 -        }
   29.27 -
   29.28 -        @Override
   29.29          public ArrayData set(final int index, final double value, final boolean strict) {
   29.30              return set(index, rint(value), strict);
   29.31          }
    30.1 --- a/src/jdk/nashorn/internal/parser/JSONParser.java	Tue Jan 19 18:56:23 2016 +0100
    30.2 +++ b/src/jdk/nashorn/internal/parser/JSONParser.java	Fri Jan 22 16:18:19 2016 +0100
    30.3 @@ -293,8 +293,6 @@
    30.4      private static Class<?> getType(final Object value) {
    30.5          if (value instanceof Integer) {
    30.6              return int.class;
    30.7 -        } else if (value instanceof Long) {
    30.8 -            return long.class;
    30.9          } else if (value instanceof Double) {
   30.10              return double.class;
   30.11          } else {
   30.12 @@ -477,8 +475,6 @@
   30.13          final double d = Double.parseDouble(source.substring(start, pos));
   30.14          if (JSType.isRepresentableAsInt(d)) {
   30.15              return (int) d;
   30.16 -        } else if (JSType.isRepresentableAsLong(d)) {
   30.17 -            return (long) d;
   30.18          }
   30.19          return d;
   30.20      }
    31.1 --- a/src/jdk/nashorn/internal/parser/Lexer.java	Tue Jan 19 18:56:23 2016 +0100
    31.2 +++ b/src/jdk/nashorn/internal/parser/Lexer.java	Fri Jan 22 16:18:19 2016 +0100
    31.3 @@ -1042,11 +1042,7 @@
    31.4       */
    31.5      private static Number valueOf(final String valueString, final int radix) throws NumberFormatException {
    31.6          try {
    31.7 -            final long value = Long.parseLong(valueString, radix);
    31.8 -            if(value >= MIN_INT_L && value <= MAX_INT_L) {
    31.9 -                return Integer.valueOf((int)value);
   31.10 -            }
   31.11 -            return Long.valueOf(value);
   31.12 +            return Integer.parseInt(valueString, radix);
   31.13          } catch (final NumberFormatException e) {
   31.14              if (radix == 10) {
   31.15                  return Double.valueOf(valueString);
   31.16 @@ -1655,8 +1651,6 @@
   31.17              //yet we don't want e.g. 1e6 to be a double unnecessarily
   31.18              if (JSType.isStrictlyRepresentableAsInt(value)) {
   31.19                  return (int)value;
   31.20 -            } else if (JSType.isStrictlyRepresentableAsLong(value)) {
   31.21 -                return (long)value;
   31.22              }
   31.23              return value;
   31.24          case STRING:
    32.1 --- a/src/jdk/nashorn/internal/runtime/AccessorProperty.java	Tue Jan 19 18:56:23 2016 +0100
    32.2 +++ b/src/jdk/nashorn/internal/runtime/AccessorProperty.java	Fri Jan 22 16:18:19 2016 +0100
    32.3 @@ -221,7 +221,7 @@
    32.4  
    32.5          assert setterType == null || setterType == getterType;
    32.6  
    32.7 -        if (getterType == int.class || getterType == long.class) {
    32.8 +        if (getterType == int.class) {
    32.9              primitiveGetter = MH.asType(getter, Lookup.GET_PRIMITIVE_TYPE);
   32.10              primitiveSetter = setter == null ? null : MH.asType(setter, Lookup.SET_PRIMITIVE_TYPE);
   32.11          } else if (getterType == double.class) {
   32.12 @@ -400,17 +400,6 @@
   32.13          }
   32.14       }
   32.15  
   32.16 -    @Override
   32.17 -    public long getLongValue(final ScriptObject self, final ScriptObject owner) {
   32.18 -        try {
   32.19 -            return (long)getGetter(long.class).invokeExact((Object)self);
   32.20 -        } catch (final Error | RuntimeException e) {
   32.21 -            throw e;
   32.22 -        } catch (final Throwable e) {
   32.23 -            throw new RuntimeException(e);
   32.24 -        }
   32.25 -    }
   32.26 -
   32.27       @Override
   32.28       public double getDoubleValue(final ScriptObject self, final ScriptObject owner) {
   32.29          try {
   32.30 @@ -453,21 +442,6 @@
   32.31       * @param self  owner
   32.32       * @param value value
   32.33       */
   32.34 -    protected final void invokeSetter(final ScriptObject self, final long value) {
   32.35 -        try {
   32.36 -            getSetter(long.class, self.getMap()).invokeExact((Object)self, value);
   32.37 -        } catch (final Error | RuntimeException e) {
   32.38 -            throw e;
   32.39 -        } catch (final Throwable e) {
   32.40 -            throw new RuntimeException(e);
   32.41 -        }
   32.42 -    }
   32.43 -
   32.44 -    /**
   32.45 -     * Invoke setter for this property with a value
   32.46 -     * @param self  owner
   32.47 -     * @param value value
   32.48 -     */
   32.49      protected final void invokeSetter(final ScriptObject self, final double value) {
   32.50          try {
   32.51              getSetter(double.class, self.getMap()).invokeExact((Object)self, value);
   32.52 @@ -500,12 +474,6 @@
   32.53      }
   32.54  
   32.55      @Override
   32.56 -    public void setValue(final ScriptObject self, final ScriptObject owner, final long value, final boolean strict)  {
   32.57 -        assert isConfigurable() || isWritable() : getKey() + " is not writable or configurable";
   32.58 -        invokeSetter(self, value);
   32.59 -    }
   32.60 -
   32.61 -    @Override
   32.62      public void setValue(final ScriptObject self, final ScriptObject owner, final double value, final boolean strict)  {
   32.63          assert isConfigurable() || isWritable() : getKey() + " is not writable or configurable";
   32.64          invokeSetter(self, value);
   32.65 @@ -533,7 +501,6 @@
   32.66          final int i = getAccessorTypeIndex(type);
   32.67  
   32.68          assert type == int.class ||
   32.69 -                type == long.class ||
   32.70                  type == double.class ||
   32.71                  type == Object.class :
   32.72                  "invalid getter type " + type + " for " + getKey();
    33.1 --- a/src/jdk/nashorn/internal/runtime/DebuggerSupport.java	Tue Jan 19 18:56:23 2016 +0100
    33.2 +++ b/src/jdk/nashorn/internal/runtime/DebuggerSupport.java	Fri Jan 22 16:18:19 2016 +0100
    33.3 @@ -239,7 +239,7 @@
    33.4  
    33.5          if (ScriptObject.isArray(object)) {
    33.6              sb.append('[');
    33.7 -            final long length = object.getLong("length", INVALID_PROGRAM_POINT);
    33.8 +            final long length = (long) object.getDouble("length", INVALID_PROGRAM_POINT);
    33.9  
   33.10              for (long i = 0; i < length; i++) {
   33.11                  if (object.has(i)) {
    34.1 --- a/src/jdk/nashorn/internal/runtime/DefaultPropertyAccess.java	Tue Jan 19 18:56:23 2016 +0100
    34.2 +++ b/src/jdk/nashorn/internal/runtime/DefaultPropertyAccess.java	Fri Jan 22 16:18:19 2016 +0100
    34.3 @@ -44,36 +44,11 @@
    34.4      }
    34.5  
    34.6      @Override
    34.7 -    public int getInt(final long key, final int programPoint) {
    34.8 -        return getInt(JSType.toObject(key), programPoint);
    34.9 -    }
   34.10 -
   34.11 -    @Override
   34.12      public int getInt(final int key, final int programPoint) {
   34.13          return getInt(JSType.toObject(key), programPoint);
   34.14      }
   34.15  
   34.16      @Override
   34.17 -    public long getLong(final Object key, final int programPoint) {
   34.18 -        return JSType.toLong(get(key));
   34.19 -    }
   34.20 -
   34.21 -    @Override
   34.22 -    public long getLong(final double key, final int programPoint) {
   34.23 -        return getLong(JSType.toObject(key), programPoint);
   34.24 -    }
   34.25 -
   34.26 -    @Override
   34.27 -    public long getLong(final long key, final int programPoint) {
   34.28 -        return getLong(JSType.toObject(key), programPoint);
   34.29 -    }
   34.30 -
   34.31 -    @Override
   34.32 -    public long getLong(final int key, final int programPoint) {
   34.33 -        return getLong(JSType.toObject(key), programPoint);
   34.34 -    }
   34.35 -
   34.36 -    @Override
   34.37      public double getDouble(final Object key, final int programPoint) {
   34.38          return JSType.toNumber(get(key));
   34.39      }
   34.40 @@ -84,11 +59,6 @@
   34.41      }
   34.42  
   34.43      @Override
   34.44 -    public double getDouble(final long key, final int programPoint) {
   34.45 -        return getDouble(JSType.toObject(key), programPoint);
   34.46 -    }
   34.47 -
   34.48 -    @Override
   34.49      public double getDouble(final int key, final int programPoint) {
   34.50          return getDouble(JSType.toObject(key), programPoint);
   34.51      }
   34.52 @@ -102,11 +72,6 @@
   34.53      }
   34.54  
   34.55      @Override
   34.56 -    public Object get(final long key) {
   34.57 -        return get(JSType.toObject(key));
   34.58 -    }
   34.59 -
   34.60 -    @Override
   34.61      public Object get(final int key) {
   34.62          return get(JSType.toObject(key));
   34.63      }
   34.64 @@ -117,11 +82,6 @@
   34.65      }
   34.66  
   34.67      @Override
   34.68 -    public void set(final double key, final long value, final int flags) {
   34.69 -        set(JSType.toObject(key), JSType.toObject(value), flags);
   34.70 -    }
   34.71 -
   34.72 -    @Override
   34.73      public void set(final double key, final double value, final int flags) {
   34.74          set(JSType.toObject(key), JSType.toObject(value), flags);
   34.75      }
   34.76 @@ -132,36 +92,11 @@
   34.77      }
   34.78  
   34.79      @Override
   34.80 -    public void set(final long key, final int value, final int flags) {
   34.81 -        set(JSType.toObject(key), JSType.toObject(value), flags);
   34.82 -    }
   34.83 -
   34.84 -    @Override
   34.85 -    public void set(final long key, final long value, final int flags) {
   34.86 -        set(JSType.toObject(key), JSType.toObject(value), flags);
   34.87 -    }
   34.88 -
   34.89 -    @Override
   34.90 -    public void set(final long key, final double value, final int flags) {
   34.91 -        set(JSType.toObject(key), JSType.toObject(value), flags);
   34.92 -    }
   34.93 -
   34.94 -    @Override
   34.95 -    public void set(final long key, final Object value, final int flags) {
   34.96 -        set(JSType.toObject(key), value, flags);
   34.97 -    }
   34.98 -
   34.99 -    @Override
  34.100      public void set(final int key, final int value, final int flags) {
  34.101          set(JSType.toObject(key), JSType.toObject(value), flags);
  34.102      }
  34.103  
  34.104      @Override
  34.105 -    public void set(final int key, final long value, final int flags) {
  34.106 -        set(JSType.toObject(key), JSType.toObject(value), flags);
  34.107 -    }
  34.108 -
  34.109 -    @Override
  34.110      public void set(final int key, final double value, final int flags) {
  34.111          set(JSType.toObject(key), JSType.toObject(value), flags);
  34.112      }
  34.113 @@ -177,11 +112,6 @@
  34.114      }
  34.115  
  34.116      @Override
  34.117 -    public void set(final Object key, final long value, final int flags) {
  34.118 -        set(key, JSType.toObject(value), flags);
  34.119 -    }
  34.120 -
  34.121 -    @Override
  34.122      public void set(final Object key, final double value, final int flags) {
  34.123          set(key, JSType.toObject(value), flags);
  34.124      }
  34.125 @@ -198,11 +128,6 @@
  34.126      }
  34.127  
  34.128      @Override
  34.129 -    public boolean has(final long key) {
  34.130 -        return has(JSType.toObject(key));
  34.131 -    }
  34.132 -
  34.133 -    @Override
  34.134      public boolean has(final double key) {
  34.135          return has(JSType.toObject(key));
  34.136      }
  34.137 @@ -213,11 +138,6 @@
  34.138      }
  34.139  
  34.140      @Override
  34.141 -    public boolean hasOwnProperty(final long key) {
  34.142 -        return hasOwnProperty(JSType.toObject(key));
  34.143 -    }
  34.144 -
  34.145 -    @Override
  34.146      public boolean hasOwnProperty(final double key) {
  34.147          return hasOwnProperty(JSType.toObject(key));
  34.148      }
  34.149 @@ -231,11 +151,6 @@
  34.150      }
  34.151  
  34.152      @Override
  34.153 -    public boolean delete(final long key, final boolean strict) {
  34.154 -        return delete(JSType.toObject(key), strict);
  34.155 -    }
  34.156 -
  34.157 -    @Override
  34.158      public boolean delete(final double key, final boolean strict) {
  34.159          return delete(JSType.toObject(key), strict);
  34.160      }
    35.1 --- a/src/jdk/nashorn/internal/runtime/FindProperty.java	Tue Jan 19 18:56:23 2016 +0100
    35.2 +++ b/src/jdk/nashorn/internal/runtime/FindProperty.java	Fri Jan 22 16:18:19 2016 +0100
    35.3 @@ -218,13 +218,6 @@
    35.4       * Get the property value from self as object.
    35.5       * @return the property value
    35.6       */
    35.7 -    public long getLongValue() {
    35.8 -        return property.getLongValue(getGetterReceiver(), getOwner());
    35.9 -    }
   35.10 -    /**
   35.11 -     * Get the property value from self as object.
   35.12 -     * @return the property value
   35.13 -     */
   35.14      public double getDoubleValue() {
   35.15          return property.getDoubleValue(getGetterReceiver(), getOwner());
   35.16      }
   35.17 @@ -252,16 +245,6 @@
   35.18       * @param value the new value
   35.19       * @param strict strict flag
   35.20       */
   35.21 -    public void setValue(final long value, final boolean strict) {
   35.22 -        property.setValue(getSetterReceiver(), getOwner(), value, strict);
   35.23 -    }
   35.24 -
   35.25 -    /**
   35.26 -     * Set the property value in self.
   35.27 -     *
   35.28 -     * @param value the new value
   35.29 -     * @param strict strict flag
   35.30 -     */
   35.31      public void setValue(final double value, final boolean strict) {
   35.32          property.setValue(getSetterReceiver(), getOwner(), value, strict);
   35.33      }
    36.1 --- a/src/jdk/nashorn/internal/runtime/GlobalFunctions.java	Tue Jan 19 18:56:23 2016 +0100
    36.2 +++ b/src/jdk/nashorn/internal/runtime/GlobalFunctions.java	Fri Jan 22 16:18:19 2016 +0100
    36.3 @@ -48,9 +48,6 @@
    36.4      /** ParseInt - identity for ints */
    36.5      public static final MethodHandle PARSEINT_I = MH.dropArguments(MH.identity(int.class), 0, Object.class);
    36.6  
    36.7 -    /** ParseInt - identity for longs */
    36.8 -    public static final MethodHandle PARSEINT_J = MH.dropArguments(MH.identity(long.class), 0, Object.class);
    36.9 -
   36.10      /** Methodhandle (specialized) to implementation of ECMA 15.1.2.2, parseInt */
   36.11      public static final MethodHandle PARSEINT_O = findOwnMH("parseInt", double.class, Object.class, Object.class);
   36.12  
    37.1 --- a/src/jdk/nashorn/internal/runtime/JSType.java	Tue Jan 19 18:56:23 2016 +0100
    37.2 +++ b/src/jdk/nashorn/internal/runtime/JSType.java	Fri Jan 22 16:18:19 2016 +0100
    37.3 @@ -115,14 +115,14 @@
    37.4      public static final Call TO_INT32_D = staticCall(JSTYPE_LOOKUP, JSType.class, "toInt32", int.class, double.class);
    37.5  
    37.6      /** JavaScript compliant conversion function from int to uint32 */
    37.7 -    public static final Call TO_UINT32_I = staticCall(JSTYPE_LOOKUP, JSType.class, "toUint32", long.class, int.class);
    37.8 +    public static final Call TO_UINT32_OPTIMISTIC = staticCall(JSTYPE_LOOKUP, JSType.class, "toUint32Optimistic", int.class, int.class, int.class);
    37.9 +
   37.10 +    /** JavaScript compliant conversion function from int to uint32 */
   37.11 +    public static final Call TO_UINT32_DOUBLE = staticCall(JSTYPE_LOOKUP, JSType.class, "toUint32Double", double.class, int.class);
   37.12  
   37.13      /** JavaScript compliant conversion function from Object to uint32 */
   37.14      public static final Call TO_UINT32 = staticCall(JSTYPE_LOOKUP, JSType.class, "toUint32", long.class, Object.class);
   37.15  
   37.16 -    /** JavaScript compliant conversion function from Object to long with type check */
   37.17 -    public static final Call TO_LONG_OPTIMISTIC = staticCall(JSTYPE_LOOKUP, JSType.class, "toLongOptimistic", long.class, Object.class, int.class);
   37.18 -
   37.19      /** JavaScript compliant conversion function from number to uint32 */
   37.20      public static final Call TO_UINT32_D = staticCall(JSTYPE_LOOKUP, JSType.class, "toUint32", long.class, double.class);
   37.21  
   37.22 @@ -168,36 +168,6 @@
   37.23      /** Negate exact exact wrapper for potentially overflowing integer operations */
   37.24      public static final Call NEGATE_EXACT         = staticCall(JSTYPE_LOOKUP, JSType.class, "negateExact", int.class, int.class, int.class);
   37.25  
   37.26 -    /** Add exact wrapper for potentially overflowing long operations */
   37.27 -    public static final Call ADD_EXACT_LONG       = staticCall(JSTYPE_LOOKUP, JSType.class, "addExact", long.class, long.class, long.class, int.class);
   37.28 -
   37.29 -    /** Sub exact wrapper for potentially overflowing long operations */
   37.30 -    public static final Call SUB_EXACT_LONG       = staticCall(JSTYPE_LOOKUP, JSType.class, "subExact", long.class, long.class, long.class, int.class);
   37.31 -
   37.32 -    /** Multiply exact wrapper for potentially overflowing long operations */
   37.33 -    public static final Call MUL_EXACT_LONG       = staticCall(JSTYPE_LOOKUP, JSType.class, "mulExact", long.class, long.class, long.class, int.class);
   37.34 -
   37.35 -    /** Div exact wrapper for potentially integer division that turns into float point */
   37.36 -    public static final Call DIV_EXACT_LONG       = staticCall(JSTYPE_LOOKUP, JSType.class, "divExact", long.class, long.class, long.class, int.class);
   37.37 -
   37.38 -    /** Div zero wrapper for long division that handles (0/0) &gt;&gt;&gt; 0 == 0 */
   37.39 -    public static final Call DIV_ZERO_LONG        = staticCall(JSTYPE_LOOKUP, JSType.class, "divZero", long.class, long.class, long.class);
   37.40 -
   37.41 -    /** Mod zero wrapper for long division that handles (0%0) &gt;&gt;&gt; 0 == 0 */
   37.42 -    public static final Call REM_ZERO_LONG       = staticCall(JSTYPE_LOOKUP, JSType.class, "remZero", long.class, long.class, long.class);
   37.43 -
   37.44 -    /** Mod exact wrapper for potentially integer remainders that turns into float point */
   37.45 -    public static final Call REM_EXACT_LONG       = staticCall(JSTYPE_LOOKUP, JSType.class, "remExact", long.class, long.class, long.class, int.class);
   37.46 -
   37.47 -    /** Decrement exact wrapper for potentially overflowing long operations */
   37.48 -    public static final Call DECREMENT_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "decrementExact",  long.class, long.class, int.class);
   37.49 -
   37.50 -    /** Increment exact wrapper for potentially overflowing long operations */
   37.51 -    public static final Call INCREMENT_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "incrementExact",  long.class, long.class, int.class);
   37.52 -
   37.53 -    /** Negate exact exact wrapper for potentially overflowing long operations */
   37.54 -    public static final Call NEGATE_EXACT_LONG    = staticCall(JSTYPE_LOOKUP, JSType.class, "negateExact",     long.class, long.class, int.class);
   37.55 -
   37.56      /** Method handle to convert a JS Object to a Java array. */
   37.57      public static final Call TO_JAVA_ARRAY = staticCall(JSTYPE_LOOKUP, JSType.class, "toJavaArray", Object.class, Object.class, Class.class);
   37.58  
   37.59 @@ -211,7 +181,6 @@
   37.60      private static final List<Type> ACCESSOR_TYPES = Collections.unmodifiableList(
   37.61              Arrays.asList(
   37.62                  Type.INT,
   37.63 -                Type.LONG,
   37.64                  Type.NUMBER,
   37.65                  Type.OBJECT));
   37.66  
   37.67 @@ -219,17 +188,14 @@
   37.68      public static final int TYPE_UNDEFINED_INDEX = -1;
   37.69      /** table index for integer type - hard coded so it can be used in switches at compile time */
   37.70      public static final int TYPE_INT_INDEX    = 0; //getAccessorTypeIndex(int.class);
   37.71 -    /** table index for long type - hard coded so it can be used in switches at compile time */
   37.72 -    public static final int TYPE_LONG_INDEX   = 1; //getAccessorTypeIndex(long.class);
   37.73      /** table index for double type - hard coded so it can be used in switches at compile time */
   37.74 -    public static final int TYPE_DOUBLE_INDEX = 2; //getAccessorTypeIndex(double.class);
   37.75 +    public static final int TYPE_DOUBLE_INDEX = 1; //getAccessorTypeIndex(double.class);
   37.76      /** table index for object type - hard coded so it can be used in switches at compile time */
   37.77 -    public static final int TYPE_OBJECT_INDEX = 3; //getAccessorTypeIndex(Object.class);
   37.78 +    public static final int TYPE_OBJECT_INDEX = 2; //getAccessorTypeIndex(Object.class);
   37.79  
   37.80      /** object conversion quickies with JS semantics - used for return value and parameter filter */
   37.81      public static final List<MethodHandle> CONVERT_OBJECT = toUnmodifiableList(
   37.82          JSType.TO_INT32.methodHandle(),
   37.83 -        JSType.TO_UINT32.methodHandle(),
   37.84          JSType.TO_NUMBER.methodHandle(),
   37.85          null
   37.86      );
   37.87 @@ -240,7 +206,6 @@
   37.88       */
   37.89      public static final List<MethodHandle> CONVERT_OBJECT_OPTIMISTIC = toUnmodifiableList(
   37.90          JSType.TO_INT32_OPTIMISTIC.methodHandle(),
   37.91 -        JSType.TO_LONG_OPTIMISTIC.methodHandle(),
   37.92          JSType.TO_NUMBER_OPTIMISTIC.methodHandle(),
   37.93          null
   37.94      );
   37.95 @@ -252,13 +217,16 @@
   37.96      /** The value of Undefined cast to a double */
   37.97      public static final double UNDEFINED_DOUBLE = Double.NaN;
   37.98  
   37.99 +    // Minimum and maximum range between which every long value can be precisely represented as a double.
  37.100 +    private static final long MAX_PRECISE_DOUBLE = 1L << 53;
  37.101 +    private static final long MIN_PRECISE_DOUBLE = -MAX_PRECISE_DOUBLE;
  37.102 +
  37.103      /**
  37.104       * Method handles for getters that return undefined coerced
  37.105       * to the appropriate type
  37.106       */
  37.107      public static final List<MethodHandle> GET_UNDEFINED = toUnmodifiableList(
  37.108          MH.constant(int.class, UNDEFINED_INT),
  37.109 -        MH.constant(long.class, UNDEFINED_LONG),
  37.110          MH.constant(double.class, UNDEFINED_DOUBLE),
  37.111          MH.constant(Object.class, Undefined.getUndefined())
  37.112      );
  37.113 @@ -416,7 +384,7 @@
  37.114  
  37.115      /**
  37.116       * Returns true if double number can be represented as a long. Note that it returns true for negative
  37.117 -     * zero. If you need to exclude negative zero, use {@link #isStrictlyRepresentableAsLong(double)}.
  37.118 +     * zero.
  37.119       *
  37.120       * @param number a double to inspect
  37.121       * @return true for long representable doubles
  37.122 @@ -426,29 +394,12 @@
  37.123      }
  37.124  
  37.125      /**
  37.126 -     * Returns true if double number can be represented as a long. Note that it returns false for negative
  37.127 -     * zero. If you don't need to distinguish negative zero, use {@link #isRepresentableAsLong(double)}.
  37.128 -     *
  37.129 -     * @param number a double to inspect
  37.130 -     *
  37.131 -     * @return true for long representable doubles
  37.132 +     * Returns true if long number can be represented as double without loss of precision.
  37.133 +     * @param number a long number
  37.134 +     * @return true if the double representation does not lose precision
  37.135       */
  37.136 -    public static boolean isStrictlyRepresentableAsLong(final double number) {
  37.137 -        return isRepresentableAsLong(number) && isNotNegativeZero(number);
  37.138 -    }
  37.139 -
  37.140 -    /**
  37.141 -     * Returns true if Object can be represented as a long
  37.142 -     *
  37.143 -     * @param obj an object to inspect
  37.144 -     *
  37.145 -     * @return true for long representable objects
  37.146 -     */
  37.147 -    public static boolean isRepresentableAsLong(final Object obj) {
  37.148 -        if (obj instanceof Number) {
  37.149 -            return isRepresentableAsLong(((Number)obj).doubleValue());
  37.150 -        }
  37.151 -        return false;
  37.152 +    public static boolean isRepresentableAsDouble(final long number) {
  37.153 +        return MAX_PRECISE_DOUBLE >= number && number >= MIN_PRECISE_DOUBLE;
  37.154      }
  37.155  
  37.156      /**
  37.157 @@ -628,22 +579,6 @@
  37.158      }
  37.159  
  37.160      /**
  37.161 -     * Check whether a string is representable as a JavaScript number
  37.162 -     *
  37.163 -     * @param str  a string
  37.164 -     *
  37.165 -     * @return     true if string can be represented as a number
  37.166 -     */
  37.167 -    public static boolean isNumber(final String str) {
  37.168 -        try {
  37.169 -            Double.parseDouble(str);
  37.170 -            return true;
  37.171 -        } catch (final NumberFormatException e) {
  37.172 -            return false;
  37.173 -        }
  37.174 -    }
  37.175 -
  37.176 -    /**
  37.177       * Returns true if object represents a primitive JavaScript string value.
  37.178       * @param obj the object
  37.179       * @return true if the object represents a primitive JavaScript string value.
  37.180 @@ -1009,35 +944,6 @@
  37.181      }
  37.182  
  37.183      /**
  37.184 -     * Optimistic long conversion - throws UnwarrantedOptimismException if double or Object
  37.185 -     *
  37.186 -     * @param obj           object to convert
  37.187 -     * @param programPoint  program point
  37.188 -     * @return long
  37.189 -     */
  37.190 -    public static long toLongOptimistic(final Object obj, final int programPoint) {
  37.191 -        if (obj != null) {
  37.192 -            final Class<?> clz = obj.getClass();
  37.193 -            if (clz == Long.class || clz == Integer.class) {
  37.194 -                return ((Number)obj).longValue();
  37.195 -            }
  37.196 -        }
  37.197 -        throw new UnwarrantedOptimismException(obj, programPoint);
  37.198 -    }
  37.199 -
  37.200 -    /**
  37.201 -     * Object to int conversion that delegates to either {@link #toLong(Object)} or to
  37.202 -     * {@link #toLongOptimistic(Object, int)} depending on whether the program point is valid or not.
  37.203 -     * @param obj the object to convert
  37.204 -     * @param programPoint the program point; can be invalid.
  37.205 -     * @return the value converted to long
  37.206 -     * @throws UnwarrantedOptimismException if the value can't be represented as long and the program point is valid.
  37.207 -     */
  37.208 -    public static long toLongMaybeOptimistic(final Object obj, final int programPoint) {
  37.209 -        return UnwarrantedOptimismException.isValid(programPoint) ? toLongOptimistic(obj, programPoint) : toLong(obj);
  37.210 -    }
  37.211 -
  37.212 -    /**
  37.213       * JavaScript compliant Object to int32 conversion
  37.214       * See ECMA 9.5 ToInt32
  37.215       *
  37.216 @@ -1074,10 +980,6 @@
  37.217          return UnwarrantedOptimismException.isValid(programPoint) ? toInt32Optimistic(obj, programPoint) : toInt32(obj);
  37.218      }
  37.219  
  37.220 -    // Minimum and maximum range between which every long value can be precisely represented as a double.
  37.221 -    private static final long MAX_PRECISE_DOUBLE = 1L << 53;
  37.222 -    private static final long MIN_PRECISE_DOUBLE = -MAX_PRECISE_DOUBLE;
  37.223 -
  37.224      /**
  37.225       * JavaScript compliant long to int32 conversion
  37.226       *
  37.227 @@ -1130,6 +1032,29 @@
  37.228      }
  37.229  
  37.230      /**
  37.231 +     * Optimistic JavaScript compliant int to uint32 conversion
  37.232 +     * @param num an int
  37.233 +     * @param pp the program point
  37.234 +     * @return the uint32 value if it can be represented by an int
  37.235 +     * @throws UnwarrantedOptimismException if uint32 value cannot be represented by an int
  37.236 +     */
  37.237 +    public static int toUint32Optimistic(final int num, final int pp) {
  37.238 +        if (num >= 0) {
  37.239 +            return num;
  37.240 +        }
  37.241 +        throw new UnwarrantedOptimismException(toUint32Double(num), pp, Type.NUMBER);
  37.242 +    }
  37.243 +
  37.244 +    /**
  37.245 +     * JavaScript compliant int to uint32 conversion with double return type
  37.246 +     * @param num an int
  37.247 +     * @return the uint32 value as double
  37.248 +     */
  37.249 +    public static double toUint32Double(final int num) {
  37.250 +        return (double) toUint32(num);
  37.251 +    }
  37.252 +
  37.253 +    /**
  37.254       * JavaScript compliant Object to uint16 conversion
  37.255       * ECMA 9.7 ToUint16: (Unsigned 16 Bit Integer)
  37.256       *
  37.257 @@ -1453,26 +1378,6 @@
  37.258          try {
  37.259              return Math.addExact(x, y);
  37.260          } catch (final ArithmeticException e) {
  37.261 -            throw new UnwarrantedOptimismException((long)x + (long)y, programPoint);
  37.262 -        }
  37.263 -    }
  37.264 -
  37.265 -    /**
  37.266 -     * Wrapper for addExact
  37.267 -     *
  37.268 -     * Catches ArithmeticException and rethrows as UnwarrantedOptimismException
  37.269 -     * containing the result and the program point of the failure
  37.270 -     *
  37.271 -     * @param x first term
  37.272 -     * @param y second term
  37.273 -     * @param programPoint program point id
  37.274 -     * @return the result
  37.275 -     * @throws UnwarrantedOptimismException if overflow occurs
  37.276 -     */
  37.277 -    public static long addExact(final long x, final long y, final int programPoint) throws UnwarrantedOptimismException {
  37.278 -        try {
  37.279 -            return Math.addExact(x, y);
  37.280 -        } catch (final ArithmeticException e) {
  37.281              throw new UnwarrantedOptimismException((double)x + (double)y, programPoint);
  37.282          }
  37.283      }
  37.284 @@ -1493,26 +1398,6 @@
  37.285          try {
  37.286              return Math.subtractExact(x, y);
  37.287          } catch (final ArithmeticException e) {
  37.288 -            throw new UnwarrantedOptimismException((long)x - (long)y, programPoint);
  37.289 -        }
  37.290 -    }
  37.291 -
  37.292 -    /**
  37.293 -     * Wrapper for subExact
  37.294 -     *
  37.295 -     * Catches ArithmeticException and rethrows as UnwarrantedOptimismException
  37.296 -     * containing the result and the program point of the failure
  37.297 -     *
  37.298 -     * @param x first term
  37.299 -     * @param y second term
  37.300 -     * @param programPoint program point id
  37.301 -     * @return the result
  37.302 -     * @throws UnwarrantedOptimismException if overflow occurs
  37.303 -     */
  37.304 -    public static long subExact(final long x, final long y, final int programPoint) throws UnwarrantedOptimismException {
  37.305 -        try {
  37.306 -            return Math.subtractExact(x, y);
  37.307 -        } catch (final ArithmeticException e) {
  37.308              throw new UnwarrantedOptimismException((double)x - (double)y, programPoint);
  37.309          }
  37.310      }
  37.311 @@ -1533,26 +1418,6 @@
  37.312          try {
  37.313              return Math.multiplyExact(x, y);
  37.314          } catch (final ArithmeticException e) {
  37.315 -            throw new UnwarrantedOptimismException((long)x * (long)y, programPoint);
  37.316 -        }
  37.317 -    }
  37.318 -
  37.319 -    /**
  37.320 -     * Wrapper for mulExact
  37.321 -     *
  37.322 -     * Catches ArithmeticException and rethrows as UnwarrantedOptimismException
  37.323 -     * containing the result and the program point of the failure
  37.324 -     *
  37.325 -     * @param x first term
  37.326 -     * @param y second term
  37.327 -     * @param programPoint program point id
  37.328 -     * @return the result
  37.329 -     * @throws UnwarrantedOptimismException if overflow occurs
  37.330 -     */
  37.331 -    public static long mulExact(final long x, final long y, final int programPoint) throws UnwarrantedOptimismException {
  37.332 -        try {
  37.333 -            return Math.multiplyExact(x, y);
  37.334 -        } catch (final ArithmeticException e) {
  37.335              throw new UnwarrantedOptimismException((double)x * (double)y, programPoint);
  37.336          }
  37.337      }
  37.338 @@ -1624,71 +1489,6 @@
  37.339      }
  37.340  
  37.341      /**
  37.342 -     * Wrapper for divExact. Throws UnwarrantedOptimismException if the result of the division can't be represented as
  37.343 -     * long.
  37.344 -     *
  37.345 -     * @param x first term
  37.346 -     * @param y second term
  37.347 -     * @param programPoint program point id
  37.348 -     * @return the result
  37.349 -     * @throws UnwarrantedOptimismException if the result of the division can't be represented as long.
  37.350 -     */
  37.351 -    public static long divExact(final long x, final long y, final int programPoint) throws UnwarrantedOptimismException {
  37.352 -        final long res;
  37.353 -        try {
  37.354 -            res = x / y;
  37.355 -        } catch (final ArithmeticException e) {
  37.356 -            assert y == 0L; // Only div by zero anticipated
  37.357 -            throw new UnwarrantedOptimismException(x > 0L ? Double.POSITIVE_INFINITY : x < 0L ? Double.NEGATIVE_INFINITY : Double.NaN, programPoint);
  37.358 -        }
  37.359 -        final long rem = x % y;
  37.360 -        if (rem == 0L) {
  37.361 -            return res;
  37.362 -        }
  37.363 -        throw new UnwarrantedOptimismException((double)x / (double)y, programPoint);
  37.364 -    }
  37.365 -
  37.366 -    /**
  37.367 -     * Implements long division but allows {@code x / 0} to be represented as 0. Useful when division of two longs
  37.368 -     * is coerced to long.
  37.369 -     * @param x the dividend
  37.370 -     * @param y the divisor
  37.371 -     * @return the result
  37.372 -     */
  37.373 -    public static long divZero(final long x, final long y) {
  37.374 -        return y == 0L ? 0L : x / y;
  37.375 -    }
  37.376 -
  37.377 -    /**
  37.378 -     * Implements long remainder but allows {@code x % 0} to be represented as 0. Useful when remainder of two longs
  37.379 -     * is coerced to long.
  37.380 -     * @param x the dividend
  37.381 -     * @param y the divisor
  37.382 -     * @return the remainder
  37.383 -     */
  37.384 -    public static long remZero(final long x, final long y) {
  37.385 -        return y == 0L ? 0L : x % y;
  37.386 -    }
  37.387 -
  37.388 -    /**
  37.389 -     * Wrapper for modExact. Throws UnwarrantedOptimismException if the modulo can't be represented as int.
  37.390 -     *
  37.391 -     * @param x first term
  37.392 -     * @param y second term
  37.393 -     * @param programPoint program point id
  37.394 -     * @return the result
  37.395 -     * @throws UnwarrantedOptimismException if the modulo can't be represented as int.
  37.396 -     */
  37.397 -    public static long remExact(final long x, final long y, final int programPoint) throws UnwarrantedOptimismException {
  37.398 -        try {
  37.399 -            return x % y;
  37.400 -        } catch (final ArithmeticException e) {
  37.401 -            assert y == 0L; // Only mod by zero anticipated
  37.402 -            throw new UnwarrantedOptimismException(Double.NaN, programPoint);
  37.403 -        }
  37.404 -    }
  37.405 -
  37.406 -    /**
  37.407       * Wrapper for decrementExact
  37.408       *
  37.409       * Catches ArithmeticException and rethrows as UnwarrantedOptimismException
  37.410 @@ -1703,26 +1503,7 @@
  37.411          try {
  37.412              return Math.decrementExact(x);
  37.413          } catch (final ArithmeticException e) {
  37.414 -            throw new UnwarrantedOptimismException((long)x - 1, programPoint);
  37.415 -        }
  37.416 -    }
  37.417 -
  37.418 -    /**
  37.419 -     * Wrapper for decrementExact
  37.420 -     *
  37.421 -     * Catches ArithmeticException and rethrows as UnwarrantedOptimismException
  37.422 -     * containing the result and the program point of the failure
  37.423 -     *
  37.424 -     * @param x number to negate
  37.425 -     * @param programPoint program point id
  37.426 -     * @return the result
  37.427 -     * @throws UnwarrantedOptimismException if overflow occurs
  37.428 -     */
  37.429 -    public static long decrementExact(final long x, final int programPoint) throws UnwarrantedOptimismException {
  37.430 -        try {
  37.431 -            return Math.decrementExact(x);
  37.432 -        } catch (final ArithmeticException e) {
  37.433 -            throw new UnwarrantedOptimismException((double)x - 1L, programPoint);
  37.434 +            throw new UnwarrantedOptimismException((double)x - 1, programPoint);
  37.435          }
  37.436      }
  37.437  
  37.438 @@ -1741,26 +1522,7 @@
  37.439          try {
  37.440              return Math.incrementExact(x);
  37.441          } catch (final ArithmeticException e) {
  37.442 -            throw new UnwarrantedOptimismException((long)x + 1, programPoint);
  37.443 -        }
  37.444 -    }
  37.445 -
  37.446 -    /**
  37.447 -     * Wrapper for incrementExact
  37.448 -     *
  37.449 -     * Catches ArithmeticException and rethrows as UnwarrantedOptimismException
  37.450 -     * containing the result and the program point of the failure
  37.451 -     *
  37.452 -     * @param x the number to increment
  37.453 -     * @param programPoint program point id
  37.454 -     * @return the result
  37.455 -     * @throws UnwarrantedOptimismException if overflow occurs
  37.456 -     */
  37.457 -    public static long incrementExact(final long x, final int programPoint) throws UnwarrantedOptimismException {
  37.458 -        try {
  37.459 -            return Math.incrementExact(x);
  37.460 -        } catch (final ArithmeticException e) {
  37.461 -            throw new UnwarrantedOptimismException((double)x + 1L, programPoint);
  37.462 +            throw new UnwarrantedOptimismException((double)x + 1, programPoint);
  37.463          }
  37.464      }
  37.465  
  37.466 @@ -1782,28 +1544,6 @@
  37.467              }
  37.468              return Math.negateExact(x);
  37.469          } catch (final ArithmeticException e) {
  37.470 -            throw new UnwarrantedOptimismException(-(long)x, programPoint);
  37.471 -        }
  37.472 -    }
  37.473 -
  37.474 -    /**
  37.475 -     * Wrapper for negateExact
  37.476 -     *
  37.477 -     * Catches ArithmeticException and rethrows as UnwarrantedOptimismException
  37.478 -     * containing the result and the program point of the failure
  37.479 -     *
  37.480 -     * @param x the number to negate
  37.481 -     * @param programPoint program point id
  37.482 -     * @return the result
  37.483 -     * @throws UnwarrantedOptimismException if overflow occurs
  37.484 -     */
  37.485 -    public static long negateExact(final long x, final int programPoint) throws UnwarrantedOptimismException {
  37.486 -        try {
  37.487 -            if (x == 0L) {
  37.488 -                throw new UnwarrantedOptimismException(-0.0, programPoint);
  37.489 -            }
  37.490 -            return Math.negateExact(x);
  37.491 -        } catch (final ArithmeticException e) {
  37.492              throw new UnwarrantedOptimismException(-(double)x, programPoint);
  37.493          }
  37.494      }
  37.495 @@ -1835,8 +1575,6 @@
  37.496              return TYPE_UNDEFINED_INDEX;
  37.497          } else if (type == int.class) {
  37.498              return TYPE_INT_INDEX;
  37.499 -        } else if (type == long.class) {
  37.500 -            return TYPE_LONG_INDEX;
  37.501          } else if (type == double.class) {
  37.502              return TYPE_DOUBLE_INDEX;
  37.503          } else if (!type.isPrimitive()) {
  37.504 @@ -1937,8 +1675,6 @@
  37.505      public static Class<?> getBoxedClass(final Class<?> clazz) {
  37.506          if (clazz == int.class) {
  37.507              return Integer.class;
  37.508 -        } else if (clazz == long.class) {
  37.509 -            return Long.class;
  37.510          } else if (clazz == double.class) {
  37.511              return Double.class;
  37.512          }
  37.513 @@ -1956,8 +1692,6 @@
  37.514          if (o != null) {
  37.515              if (o.getClass() == Integer.class) {
  37.516                  return MH.constant(int.class, ((Integer)o).intValue());
  37.517 -            } else if (o.getClass() == Long.class) {
  37.518 -                return MH.constant(long.class, ((Long)o).longValue());
  37.519              } else if (o.getClass() == Double.class) {
  37.520                  return MH.constant(double.class, ((Double)o).doubleValue());
  37.521              }
  37.522 @@ -1975,8 +1709,6 @@
  37.523              return Object.class;
  37.524          } else if (o.getClass() == Integer.class) {
  37.525              return int.class;
  37.526 -        } else if (o.getClass() == Long.class) {
  37.527 -            return long.class;
  37.528          } else if (o.getClass() == Double.class) {
  37.529              return double.class;
  37.530          } else {
    38.1 --- a/src/jdk/nashorn/internal/runtime/OptimisticReturnFilters.java	Tue Jan 19 18:56:23 2016 +0100
    38.2 +++ b/src/jdk/nashorn/internal/runtime/OptimisticReturnFilters.java	Fri Jan 22 16:18:19 2016 +0100
    38.3 @@ -43,52 +43,42 @@
    38.4   */
    38.5  public final class OptimisticReturnFilters {
    38.6      private static final MethodHandle[] ENSURE_INT;
    38.7 -    private static final MethodHandle[] ENSURE_LONG;
    38.8      private static final MethodHandle[] ENSURE_NUMBER;
    38.9  
   38.10 +    // These extend the type index constants in JSType
   38.11 +    private static final int VOID_TYPE_INDEX;
   38.12      private static final int BOOLEAN_TYPE_INDEX;
   38.13      private static final int CHAR_TYPE_INDEX;
   38.14 +    private static final int LONG_TYPE_INDEX;
   38.15      private static final int FLOAT_TYPE_INDEX;
   38.16 -    private static final int VOID_TYPE_INDEX;
   38.17  
   38.18      static {
   38.19          final MethodHandle INT_DOUBLE = findOwnMH("ensureInt", int.class, double.class, int.class);
   38.20          ENSURE_INT = new MethodHandle[] {
   38.21                  null,
   38.22 -                findOwnMH("ensureInt", int.class, long.class, int.class),
   38.23                  INT_DOUBLE,
   38.24                  findOwnMH("ensureInt", int.class, Object.class, int.class),
   38.25                  findOwnMH("ensureInt", int.class, int.class),
   38.26                  findOwnMH("ensureInt", int.class, boolean.class, int.class),
   38.27                  findOwnMH("ensureInt", int.class, char.class, int.class),
   38.28 +                findOwnMH("ensureInt", int.class, long.class, int.class),
   38.29                  INT_DOUBLE.asType(INT_DOUBLE.type().changeParameterType(0, float.class)),
   38.30          };
   38.31  
   38.32 -        VOID_TYPE_INDEX = ENSURE_INT.length - 4;
   38.33 -        BOOLEAN_TYPE_INDEX = ENSURE_INT.length - 3;
   38.34 -        CHAR_TYPE_INDEX = ENSURE_INT.length - 2;
   38.35 +        VOID_TYPE_INDEX = ENSURE_INT.length - 5;
   38.36 +        BOOLEAN_TYPE_INDEX = ENSURE_INT.length - 4;
   38.37 +        CHAR_TYPE_INDEX = ENSURE_INT.length - 3;
   38.38 +        LONG_TYPE_INDEX = ENSURE_INT.length - 2;
   38.39          FLOAT_TYPE_INDEX = ENSURE_INT.length - 1;
   38.40  
   38.41 -        final MethodHandle LONG_DOUBLE = findOwnMH("ensureLong", long.class, double.class, int.class);
   38.42 -        ENSURE_LONG = new MethodHandle[] {
   38.43 -                null,
   38.44 -                null,
   38.45 -                LONG_DOUBLE,
   38.46 -                findOwnMH("ensureLong", long.class, Object.class, int.class),
   38.47 -                ENSURE_INT[VOID_TYPE_INDEX].asType(ENSURE_INT[VOID_TYPE_INDEX].type().changeReturnType(long.class)),
   38.48 -                ENSURE_INT[BOOLEAN_TYPE_INDEX].asType(ENSURE_INT[BOOLEAN_TYPE_INDEX].type().changeReturnType(long.class)),
   38.49 -                ENSURE_INT[CHAR_TYPE_INDEX].asType(ENSURE_INT[CHAR_TYPE_INDEX].type().changeReturnType(long.class)),
   38.50 -                LONG_DOUBLE.asType(LONG_DOUBLE.type().changeParameterType(0, float.class)),
   38.51 -            };
   38.52 -
   38.53          ENSURE_NUMBER = new MethodHandle[] {
   38.54                  null,
   38.55                  null,
   38.56 -                null,
   38.57                  findOwnMH("ensureNumber", double.class, Object.class, int.class),
   38.58                  ENSURE_INT[VOID_TYPE_INDEX].asType(ENSURE_INT[VOID_TYPE_INDEX].type().changeReturnType(double.class)),
   38.59                  ENSURE_INT[BOOLEAN_TYPE_INDEX].asType(ENSURE_INT[BOOLEAN_TYPE_INDEX].type().changeReturnType(double.class)),
   38.60                  ENSURE_INT[CHAR_TYPE_INDEX].asType(ENSURE_INT[CHAR_TYPE_INDEX].type().changeReturnType(double.class)),
   38.61 +                findOwnMH("ensureNumber", double.class, long.class, int.class),
   38.62                  null
   38.63          };
   38.64      }
   38.65 @@ -136,8 +126,6 @@
   38.66          final int provableTypeIndex = getProvableTypeIndex(provable);
   38.67          if (actual == int.class) {
   38.68              guard = ENSURE_INT[provableTypeIndex];
   38.69 -        } else if (actual == long.class) {
   38.70 -            guard = ENSURE_LONG[provableTypeIndex];
   38.71          } else if (actual == double.class) {
   38.72              guard = ENSURE_NUMBER[provableTypeIndex];
   38.73          } else {
   38.74 @@ -167,6 +155,8 @@
   38.75              return 0; // never needs a guard, as it's assignable to int
   38.76          } else if(provable == char.class) {
   38.77              return CHAR_TYPE_INDEX;
   38.78 +        } else if(provable == long.class) {
   38.79 +            return LONG_TYPE_INDEX;
   38.80          } else if(provable == float.class) {
   38.81              return FLOAT_TYPE_INDEX;
   38.82          }
   38.83 @@ -179,7 +169,7 @@
   38.84          if (JSType.isRepresentableAsInt(arg)) {
   38.85              return (int)arg;
   38.86          }
   38.87 -        throw new UnwarrantedOptimismException(arg, programPoint);
   38.88 +        throw UnwarrantedOptimismException.createNarrowest(arg, programPoint);
   38.89      }
   38.90  
   38.91      @SuppressWarnings("unused")
   38.92 @@ -187,7 +177,7 @@
   38.93          if (JSType.isStrictlyRepresentableAsInt(arg)) {
   38.94              return (int)arg;
   38.95          }
   38.96 -        throw new UnwarrantedOptimismException(arg, programPoint);
   38.97 +        throw new UnwarrantedOptimismException(arg, programPoint, Type.NUMBER);
   38.98      }
   38.99  
  38.100      /**
  38.101 @@ -210,7 +200,7 @@
  38.102                  return (int)d;
  38.103              }
  38.104          }
  38.105 -        throw new UnwarrantedOptimismException(arg, programPoint);
  38.106 +        throw UnwarrantedOptimismException.createNarrowest(arg, programPoint);
  38.107      }
  38.108  
  38.109      private static boolean isPrimitiveNumberWrapper(final Object obj) {
  38.110 @@ -238,51 +228,29 @@
  38.111          throw new UnwarrantedOptimismException(ScriptRuntime.UNDEFINED, programPoint, Type.OBJECT);
  38.112      }
  38.113  
  38.114 -    private static long ensureLong(final double arg, final int programPoint) {
  38.115 -        if (JSType.isStrictlyRepresentableAsLong(arg)) {
  38.116 -            return (long)arg;
  38.117 +    @SuppressWarnings("unused")
  38.118 +    private static double ensureNumber(final long arg, final int programPoint) {
  38.119 +        if (JSType.isRepresentableAsDouble(arg)) {
  38.120 +            return (double) arg;
  38.121          }
  38.122 -        throw new UnwarrantedOptimismException(arg, programPoint);
  38.123 +        throw new UnwarrantedOptimismException(arg, programPoint, Type.OBJECT);
  38.124      }
  38.125  
  38.126      /**
  38.127 -     * Returns the argument value as a long. If the argument is not a wrapper for a primitive numeric type
  38.128 -     * with a value that can be exactly represented as a long, throw an {@link UnwarrantedOptimismException}.
  38.129 -     * This method is only public so that generated script code can use it. See {code CodeGenerator.ENSURE_LONG}.
  38.130 -     * @param arg the original argument.
  38.131 -     * @param programPoint the program point used in the exception
  38.132 -     * @return the value of the argument as a long.
  38.133 -     * @throws UnwarrantedOptimismException if the argument is not a wrapper for a primitive numeric type with
  38.134 -     * a value that can be exactly represented as a long
  38.135 -     */
  38.136 -    public static long ensureLong(final Object arg, final int programPoint) {
  38.137 -        if (arg != null) {
  38.138 -            final Class<?> c = arg.getClass();
  38.139 -            if (c == Long.class) {
  38.140 -                // Must check for Long separately, as Long.doubleValue() isn't precise.
  38.141 -                return ((Long)arg).longValue();
  38.142 -            } else if (c == Integer.class || c == Double.class || c == Float.class || c == Short.class ||
  38.143 -                    c == Byte.class) {
  38.144 -                return ensureLong(((Number)arg).doubleValue(), programPoint);
  38.145 -            }
  38.146 -        }
  38.147 -        throw new UnwarrantedOptimismException(arg, programPoint);
  38.148 -    }
  38.149 -
  38.150 -    /**
  38.151 -     * Returns the argument value as a double. If the argument is not a a wrapper for a primitive numeric type
  38.152 -     * throw an {@link UnwarrantedOptimismException}.This method is only public so that generated script code
  38.153 -     * can use it. See {code CodeGenerator.ENSURE_NUMBER}.
  38.154 +     * Returns the argument value as a double. If the argument is not a wrapper for a primitive numeric type
  38.155 +     * that can be represented as double throw an {@link UnwarrantedOptimismException}.
  38.156 +     * This method is only public so that generated script code can use it. See {code CodeGenerator.ENSURE_NUMBER}.
  38.157       * @param arg the original argument.
  38.158       * @param programPoint the program point used in the exception
  38.159       * @return the value of the argument as a double.
  38.160       * @throws UnwarrantedOptimismException if the argument is not a wrapper for a primitive numeric type.
  38.161       */
  38.162      public static double ensureNumber(final Object arg, final int programPoint) {
  38.163 -        if (isPrimitiveNumberWrapper(arg)) {
  38.164 -            return ((Number)arg).doubleValue();
  38.165 +        if (isPrimitiveNumberWrapper(arg)
  38.166 +                && (arg.getClass() != Long.class || JSType.isRepresentableAsDouble((Long) arg))) {
  38.167 +            return ((Number) arg).doubleValue();
  38.168          }
  38.169 -        throw new UnwarrantedOptimismException(arg, programPoint);
  38.170 +        throw new UnwarrantedOptimismException(arg, programPoint, Type.OBJECT);
  38.171      }
  38.172  
  38.173      private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    39.1 --- a/src/jdk/nashorn/internal/runtime/Property.java	Tue Jan 19 18:56:23 2016 +0100
    39.2 +++ b/src/jdk/nashorn/internal/runtime/Property.java	Fri Jan 22 16:18:19 2016 +0100
    39.3 @@ -450,16 +450,6 @@
    39.4       * @param owner the owner of the property
    39.5       * @return  the property value
    39.6       */
    39.7 -    public abstract long getLongValue(final ScriptObject self, final ScriptObject owner);
    39.8 -
    39.9 -    /**
   39.10 -     * get the Object value of this property from {@code owner}. This allows to bypass creation of the
   39.11 -     * getter MethodHandle for spill and user accessor properties.
   39.12 -     *
   39.13 -     * @param self the this object
   39.14 -     * @param owner the owner of the property
   39.15 -     * @return  the property value
   39.16 -     */
   39.17      public abstract double getDoubleValue(final ScriptObject self, final ScriptObject owner);
   39.18  
   39.19      /**
   39.20 @@ -492,17 +482,6 @@
   39.21       * @param value the new property value
   39.22       * @param strict is this a strict setter?
   39.23       */
   39.24 -    public abstract void setValue(final ScriptObject self, final ScriptObject owner, final long value, final boolean strict);
   39.25 -
   39.26 -    /**
   39.27 -     * Set the value of this property in {@code owner}. This allows to bypass creation of the
   39.28 -     * setter MethodHandle for spill and user accessor properties.
   39.29 -     *
   39.30 -     * @param self the this object
   39.31 -     * @param owner the owner object
   39.32 -     * @param value the new property value
   39.33 -     * @param strict is this a strict setter?
   39.34 -     */
   39.35      public abstract void setValue(final ScriptObject self, final ScriptObject owner, final double value, final boolean strict);
   39.36  
   39.37      /**
   39.38 @@ -593,8 +572,6 @@
   39.39              return "undef";
   39.40          } else if (type == int.class) {
   39.41              return "i";
   39.42 -        } else if (type == long.class) {
   39.43 -            return "j";
   39.44          } else if (type == double.class) {
   39.45              return "d";
   39.46          } else {
    40.1 --- a/src/jdk/nashorn/internal/runtime/PropertyAccess.java	Tue Jan 19 18:56:23 2016 +0100
    40.2 +++ b/src/jdk/nashorn/internal/runtime/PropertyAccess.java	Fri Jan 22 16:18:19 2016 +0100
    40.3 @@ -57,49 +57,9 @@
    40.4       * @param programPoint or INVALID_PROGRAM_POINT if pessimistic
    40.5       * @return the value
    40.6       */
    40.7 -    public int getInt(long key, int programPoint);
    40.8 -
    40.9 -    /**
   40.10 -     * Get the value for a given key and return it as an int
   40.11 -     * @param key the key
   40.12 -     * @param programPoint or INVALID_PROGRAM_POINT if pessimistic
   40.13 -     * @return the value
   40.14 -     */
   40.15      public int getInt(int key, int programPoint);
   40.16  
   40.17      /**
   40.18 -     * Get the value for a given key and return it as a long
   40.19 -     * @param key the key
   40.20 -     * @param programPoint or INVALID_PROGRAM_POINT if pessimistic
   40.21 -     * @return the value
   40.22 -     */
   40.23 -    public long getLong(Object key, int programPoint);
   40.24 -
   40.25 -    /**
   40.26 -     * Get the value for a given key and return it as a long
   40.27 -     * @param key the key
   40.28 -     * @param programPoint or INVALID_PROGRAM_POINT if pessimistic
   40.29 -     * @return the value
   40.30 -     */
   40.31 -    public long getLong(double key, int programPoint);
   40.32 -
   40.33 -    /**
   40.34 -     * Get the value for a given key and return it as a long
   40.35 -     * @param key the key
   40.36 -     * @param programPoint or INVALID_PROGRAM_POINT if pessimistic
   40.37 -     * @return the value
   40.38 -     */
   40.39 -    public long getLong(long key, int programPoint);
   40.40 -
   40.41 -    /**
   40.42 -     * Get the value for a given key and return it as a long
   40.43 -     * @param key the key
   40.44 -     * @param programPoint or INVALID_PROGRAM_POINT if pessimistic
   40.45 -     * @return the value
   40.46 -     */
   40.47 -    public long getLong(int key, int programPoint);
   40.48 -
   40.49 -    /**
   40.50       * Get the value for a given key and return it as a double
   40.51       * @param key the key
   40.52       * @param programPoint or INVALID_PROGRAM_POINT if pessimistic
   40.53 @@ -121,14 +81,6 @@
   40.54       * @param programPoint or INVALID_PROGRAM_POINT if pessimistic
   40.55       * @return the value
   40.56       */
   40.57 -    public double getDouble(long key, int programPoint);
   40.58 -
   40.59 -    /**
   40.60 -     * Get the value for a given key and return it as a double
   40.61 -     * @param key the key
   40.62 -     * @param programPoint or INVALID_PROGRAM_POINT if pessimistic
   40.63 -     * @return the value
   40.64 -     */
   40.65      public double getDouble(int key, int programPoint);
   40.66  
   40.67      /**
   40.68 @@ -150,13 +102,6 @@
   40.69       * @param key the key
   40.70       * @return the value
   40.71       */
   40.72 -    public Object get(long key);
   40.73 -
   40.74 -    /**
   40.75 -     * Get the value for a given key and return it as an Object
   40.76 -     * @param key the key
   40.77 -     * @return the value
   40.78 -     */
   40.79      public Object get(int key);
   40.80  
   40.81      /**
   40.82 @@ -173,14 +118,6 @@
   40.83       * @param value   the value
   40.84       * @param flags   call site flags
   40.85       */
   40.86 -    public void set(Object key, long value, int flags);
   40.87 -
   40.88 -    /**
   40.89 -     * Set the value of a given key
   40.90 -     * @param key     the key
   40.91 -     * @param value   the value
   40.92 -     * @param flags   call site flags
   40.93 -     */
   40.94      public void set(Object key, double value, int flags);
   40.95  
   40.96      /**
   40.97 @@ -205,14 +142,6 @@
   40.98       * @param value   the value
   40.99       * @param flags   call site flags
  40.100       */
  40.101 -    public void set(double key, long value, int flags);
  40.102 -
  40.103 -    /**
  40.104 -     * Set the value of a given key
  40.105 -     * @param key     the key
  40.106 -     * @param value   the value
  40.107 -     * @param flags   call site flags
  40.108 -     */
  40.109      public void set(double key, double value, int flags);
  40.110  
  40.111      /**
  40.112 @@ -229,38 +158,6 @@
  40.113       * @param value   the value
  40.114       * @param flags   call site flags
  40.115       */
  40.116 -    public void set(long key, int value, int flags);
  40.117 -
  40.118 -    /**
  40.119 -     * Set the value of a given key
  40.120 -     * @param key     the key
  40.121 -     * @param value   the value
  40.122 -     * @param flags   call site flags
  40.123 -     */
  40.124 -    public void set(long key, long value, int flags);
  40.125 -
  40.126 -    /**
  40.127 -     * Set the value of a given key
  40.128 -     * @param key     the key
  40.129 -     * @param value   the value
  40.130 -     * @param flags   call site flags
  40.131 -     */
  40.132 -    public void set(long key, double value, int flags);
  40.133 -
  40.134 -    /**
  40.135 -     * Set the value of a given key
  40.136 -     * @param key     the key
  40.137 -     * @param value   the value
  40.138 -     * @param flags   call site flags
  40.139 -     */
  40.140 -    public void set(long key, Object value, int flags);
  40.141 -
  40.142 -    /**
  40.143 -     * Set the value of a given key
  40.144 -     * @param key     the key
  40.145 -     * @param value   the value
  40.146 -     * @param flags   call site flags
  40.147 -     */
  40.148      public void set(int key, int value, int flags);
  40.149  
  40.150      /**
  40.151 @@ -269,14 +166,6 @@
  40.152       * @param value   the value
  40.153       * @param flags   call site flags
  40.154       */
  40.155 -    public void set(int key, long value, int flags);
  40.156 -
  40.157 -    /**
  40.158 -     * Set the value of a given key
  40.159 -     * @param key     the key
  40.160 -     * @param value   the value
  40.161 -     * @param flags   call site flags
  40.162 -     */
  40.163      public void set(int key, double value, int flags);
  40.164  
  40.165      /**
  40.166 @@ -306,13 +195,6 @@
  40.167       * @param key the key
  40.168       * @return true if key exists
  40.169       */
  40.170 -    public boolean has(long key);
  40.171 -
  40.172 -    /**
  40.173 -     * Check if the given key exists anywhere in the proto chain
  40.174 -     * @param key the key
  40.175 -     * @return true if key exists
  40.176 -     */
  40.177      public boolean has(double key);
  40.178  
  40.179      /**
  40.180 @@ -334,13 +216,6 @@
  40.181       * @param key the key
  40.182       * @return true if key exists
  40.183       */
  40.184 -    public boolean hasOwnProperty(long key);
  40.185 -
  40.186 -    /**
  40.187 -     * Check if the given key exists directly in the implementor
  40.188 -     * @param key the key
  40.189 -     * @return true if key exists
  40.190 -     */
  40.191      public boolean hasOwnProperty(double key);
  40.192  
  40.193      /**
  40.194 @@ -357,14 +232,6 @@
  40.195       * @param strict are we in strict mode
  40.196       * @return true if deletion succeeded, false otherwise
  40.197       */
  40.198 -    public boolean delete(long key, boolean strict);
  40.199 -
  40.200 -    /**
  40.201 -     * Delete a property with the given key from the implementor
  40.202 -     * @param key    the key
  40.203 -     * @param strict are we in strict mode
  40.204 -     * @return true if deletion succeeded, false otherwise
  40.205 -     */
  40.206      public boolean delete(double key, boolean strict);
  40.207  
  40.208      /**
    41.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java	Tue Jan 19 18:56:23 2016 +0100
    41.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java	Fri Jan 22 16:18:19 2016 +0100
    41.3 @@ -33,7 +33,6 @@
    41.4  import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
    41.5  import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_DOUBLE;
    41.6  import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_INT;
    41.7 -import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_LONG;
    41.8  import static jdk.nashorn.internal.runtime.PropertyDescriptor.CONFIGURABLE;
    41.9  import static jdk.nashorn.internal.runtime.PropertyDescriptor.ENUMERABLE;
   41.10  import static jdk.nashorn.internal.runtime.PropertyDescriptor.GET;
   41.11 @@ -186,7 +185,6 @@
   41.12  
   41.13      static final MethodHandle[] SET_SLOW = new MethodHandle[] {
   41.14          findOwnMH_V("set", void.class, Object.class, int.class, int.class),
   41.15 -        findOwnMH_V("set", void.class, Object.class, long.class, int.class),
   41.16          findOwnMH_V("set", void.class, Object.class, double.class, int.class),
   41.17          findOwnMH_V("set", void.class, Object.class, Object.class, int.class)
   41.18      };
   41.19 @@ -1086,21 +1084,6 @@
   41.20          return UNDEFINED_INT;
   41.21      }
   41.22  
   41.23 -    private static long getLongValue(final FindProperty find, final int programPoint) {
   41.24 -        final MethodHandle getter = find.getGetter(long.class, programPoint, null);
   41.25 -        if (getter != null) {
   41.26 -            try {
   41.27 -                return (long)getter.invokeExact((Object)find.getGetterReceiver());
   41.28 -            } catch (final Error|RuntimeException e) {
   41.29 -                throw e;
   41.30 -            } catch (final Throwable e) {
   41.31 -                throw new RuntimeException(e);
   41.32 -            }
   41.33 -        }
   41.34 -
   41.35 -        return UNDEFINED_LONG;
   41.36 -    }
   41.37 -
   41.38      private static double getDoubleValue(final FindProperty find, final int programPoint) {
   41.39          final MethodHandle getter = find.getGetter(double.class, programPoint, null);
   41.40          if (getter != null) {
   41.41 @@ -2768,18 +2751,6 @@
   41.42      }
   41.43  
   41.44      @Override
   41.45 -    public int getInt(final long key, final int programPoint) {
   41.46 -        final int       index = getArrayIndex(key);
   41.47 -        final ArrayData array = getArray();
   41.48 -
   41.49 -        if (array.has(index)) {
   41.50 -            return isValid(programPoint) ? array.getIntOptimistic(index, programPoint) : array.getInt(index);
   41.51 -        }
   41.52 -
   41.53 -        return getInt(index, JSType.toString(key), programPoint);
   41.54 -    }
   41.55 -
   41.56 -    @Override
   41.57      public int getInt(final int key, final int programPoint) {
   41.58          final int       index = getArrayIndex(key);
   41.59          final ArrayData array = getArray();
   41.60 @@ -2791,88 +2762,6 @@
   41.61          return getInt(index, JSType.toString(key), programPoint);
   41.62      }
   41.63  
   41.64 -    private long getLong(final int index, final String key, final int programPoint) {
   41.65 -        if (isValidArrayIndex(index)) {
   41.66 -            for (ScriptObject object = this; ; ) {
   41.67 -                if (object.getMap().containsArrayKeys()) {
   41.68 -                    final FindProperty find = object.findProperty(key, false, this);
   41.69 -                    if (find != null) {
   41.70 -                        return getLongValue(find, programPoint);
   41.71 -                    }
   41.72 -                }
   41.73 -
   41.74 -                if ((object = object.getProto()) == null) {
   41.75 -                    break;
   41.76 -                }
   41.77 -
   41.78 -                final ArrayData array = object.getArray();
   41.79 -
   41.80 -                if (array.has(index)) {
   41.81 -                    return isValid(programPoint) ?
   41.82 -                        array.getLongOptimistic(index, programPoint) :
   41.83 -                        array.getLong(index);
   41.84 -                }
   41.85 -            }
   41.86 -        } else {
   41.87 -            final FindProperty find = findProperty(key, true);
   41.88 -
   41.89 -            if (find != null) {
   41.90 -                return getLongValue(find, programPoint);
   41.91 -            }
   41.92 -        }
   41.93 -
   41.94 -        return JSType.toLong(invokeNoSuchProperty(key, false, programPoint));
   41.95 -    }
   41.96 -
   41.97 -    @Override
   41.98 -    public long getLong(final Object key, final int programPoint) {
   41.99 -        final Object    primitiveKey = JSType.toPrimitive(key, String.class);
  41.100 -        final int       index        = getArrayIndex(primitiveKey);
  41.101 -        final ArrayData array        = getArray();
  41.102 -
  41.103 -        if (array.has(index)) {
  41.104 -            return isValid(programPoint) ? array.getLongOptimistic(index, programPoint) : array.getLong(index);
  41.105 -        }
  41.106 -
  41.107 -        return getLong(index, JSType.toString(primitiveKey), programPoint);
  41.108 -    }
  41.109 -
  41.110 -    @Override
  41.111 -    public long getLong(final double key, final int programPoint) {
  41.112 -        final int       index = getArrayIndex(key);
  41.113 -        final ArrayData array = getArray();
  41.114 -
  41.115 -        if (array.has(index)) {
  41.116 -            return isValid(programPoint) ? array.getLongOptimistic(index, programPoint) : array.getLong(index);
  41.117 -        }
  41.118 -
  41.119 -        return getLong(index, JSType.toString(key), programPoint);
  41.120 -    }
  41.121 -
  41.122 -    @Override
  41.123 -    public long getLong(final long key, final int programPoint) {
  41.124 -        final int       index = getArrayIndex(key);
  41.125 -        final ArrayData array = getArray();
  41.126 -
  41.127 -        if (array.has(index)) {
  41.128 -            return isValid(programPoint) ? array.getLongOptimistic(index, programPoint) : array.getLong(index);
  41.129 -        }
  41.130 -
  41.131 -        return getLong(index, JSType.toString(key), programPoint);
  41.132 -    }
  41.133 -
  41.134 -    @Override
  41.135 -    public long getLong(final int key, final int programPoint) {
  41.136 -        final int       index = getArrayIndex(key);
  41.137 -        final ArrayData array = getArray();
  41.138 -
  41.139 -        if (array.has(index)) {
  41.140 -            return isValid(programPoint) ? array.getLongOptimistic(key, programPoint) : array.getLong(key);
  41.141 -        }
  41.142 -
  41.143 -        return getLong(index, JSType.toString(key), programPoint);
  41.144 -    }
  41.145 -
  41.146      private double getDouble(final int index, final String key, final int programPoint) {
  41.147          if (isValidArrayIndex(index)) {
  41.148              for (ScriptObject object = this; ; ) {
  41.149 @@ -2932,18 +2821,6 @@
  41.150      }
  41.151  
  41.152      @Override
  41.153 -    public double getDouble(final long key, final int programPoint) {
  41.154 -        final int       index = getArrayIndex(key);
  41.155 -        final ArrayData array = getArray();
  41.156 -
  41.157 -        if (array.has(index)) {
  41.158 -            return isValid(programPoint) ? array.getDoubleOptimistic(index, programPoint) : array.getDouble(index);
  41.159 -        }
  41.160 -
  41.161 -        return getDouble(index, JSType.toString(key), programPoint);
  41.162 -    }
  41.163 -
  41.164 -    @Override
  41.165      public double getDouble(final int key, final int programPoint) {
  41.166          final int       index = getArrayIndex(key);
  41.167          final ArrayData array = getArray();
  41.168 @@ -3013,18 +2890,6 @@
  41.169      }
  41.170  
  41.171      @Override
  41.172 -    public Object get(final long key) {
  41.173 -        final int index = getArrayIndex(key);
  41.174 -        final ArrayData array = getArray();
  41.175 -
  41.176 -        if (array.has(index)) {
  41.177 -            return array.getObject(index);
  41.178 -        }
  41.179 -
  41.180 -        return get(index, JSType.toString(key));
  41.181 -    }
  41.182 -
  41.183 -    @Override
  41.184      public Object get(final int key) {
  41.185          final int index = getArrayIndex(key);
  41.186          final ArrayData array = getArray();
  41.187 @@ -3107,15 +2972,6 @@
  41.188          }
  41.189      }
  41.190  
  41.191 -    private void doesNotHave(final int index, final long value, final int callSiteFlags) {
  41.192 -        final long oldLength = getArray().length();
  41.193 -        final long longIndex = ArrayIndex.toLongIndex(index);
  41.194 -        if (!doesNotHaveCheckArrayKeys(longIndex, value, callSiteFlags) && !doesNotHaveEnsureLength(longIndex, oldLength, callSiteFlags)) {
  41.195 -            final boolean strict = isStrictFlag(callSiteFlags);
  41.196 -            setArray(getArray().set(index, value, strict).safeDelete(oldLength, longIndex - 1, strict));
  41.197 -        }
  41.198 -    }
  41.199 -
  41.200      private void doesNotHave(final int index, final double value, final int callSiteFlags) {
  41.201          final long oldLength = getArray().length();
  41.202          final long longIndex = ArrayIndex.toLongIndex(index);
  41.203 @@ -3222,7 +3078,7 @@
  41.204      }
  41.205  
  41.206      @Override
  41.207 -    public void set(final Object key, final long value, final int callSiteFlags) {
  41.208 +    public void set(final Object key, final double value, final int callSiteFlags) {
  41.209          final Object primitiveKey = JSType.toPrimitive(key, String.class);
  41.210          final int    index        = getArrayIndex(primitiveKey);
  41.211  
  41.212 @@ -3242,7 +3098,7 @@
  41.213      }
  41.214  
  41.215      @Override
  41.216 -    public void set(final Object key, final double value, final int callSiteFlags) {
  41.217 +    public void set(final Object key, final Object value, final int callSiteFlags) {
  41.218          final Object primitiveKey = JSType.toPrimitive(key, String.class);
  41.219          final int    index        = getArrayIndex(primitiveKey);
  41.220  
  41.221 @@ -3258,13 +3114,12 @@
  41.222          }
  41.223  
  41.224          final String propName = JSType.toString(primitiveKey);
  41.225 -        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  41.226 +        setObject(findProperty(propName, true), callSiteFlags, propName, value);
  41.227      }
  41.228  
  41.229      @Override
  41.230 -    public void set(final Object key, final Object value, final int callSiteFlags) {
  41.231 -        final Object primitiveKey = JSType.toPrimitive(key, String.class);
  41.232 -        final int    index        = getArrayIndex(primitiveKey);
  41.233 +    public void set(final double key, final int value, final int callSiteFlags) {
  41.234 +        final int index = getArrayIndex(key);
  41.235  
  41.236          if (isValidArrayIndex(index)) {
  41.237              final ArrayData data = getArray();
  41.238 @@ -3277,12 +3132,12 @@
  41.239              return;
  41.240          }
  41.241  
  41.242 -        final String propName = JSType.toString(primitiveKey);
  41.243 -        setObject(findProperty(propName, true), callSiteFlags, propName, value);
  41.244 +        final String propName = JSType.toString(key);
  41.245 +        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  41.246      }
  41.247  
  41.248      @Override
  41.249 -    public void set(final double key, final int value, final int callSiteFlags) {
  41.250 +    public void set(final double key, final double value, final int callSiteFlags) {
  41.251          final int index = getArrayIndex(key);
  41.252  
  41.253          if (isValidArrayIndex(index)) {
  41.254 @@ -3301,44 +3156,6 @@
  41.255      }
  41.256  
  41.257      @Override
  41.258 -    public void set(final double key, final long value, final int callSiteFlags) {
  41.259 -        final int index = getArrayIndex(key);
  41.260 -
  41.261 -        if (isValidArrayIndex(index)) {
  41.262 -            final ArrayData data = getArray();
  41.263 -            if (data.has(index)) {
  41.264 -                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
  41.265 -            } else {
  41.266 -                doesNotHave(index, value, callSiteFlags);
  41.267 -            }
  41.268 -
  41.269 -            return;
  41.270 -        }
  41.271 -
  41.272 -        final String propName = JSType.toString(key);
  41.273 -        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  41.274 -    }
  41.275 -
  41.276 -    @Override
  41.277 -    public void set(final double key, final double value, final int callSiteFlags) {
  41.278 -        final int index = getArrayIndex(key);
  41.279 -
  41.280 -        if (isValidArrayIndex(index)) {
  41.281 -            final ArrayData data = getArray();
  41.282 -            if (data.has(index)) {
  41.283 -                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
  41.284 -            } else {
  41.285 -                doesNotHave(index, value, callSiteFlags);
  41.286 -            }
  41.287 -
  41.288 -            return;
  41.289 -        }
  41.290 -
  41.291 -        final String propName = JSType.toString(key);
  41.292 -        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  41.293 -    }
  41.294 -
  41.295 -    @Override
  41.296      public void set(final double key, final Object value, final int callSiteFlags) {
  41.297          final int index = getArrayIndex(key);
  41.298  
  41.299 @@ -3358,82 +3175,6 @@
  41.300      }
  41.301  
  41.302      @Override
  41.303 -    public void set(final long key, final int value, final int callSiteFlags) {
  41.304 -        final int index = getArrayIndex(key);
  41.305 -
  41.306 -        if (isValidArrayIndex(index)) {
  41.307 -            final ArrayData data = getArray();
  41.308 -            if (data.has(index)) {
  41.309 -                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
  41.310 -            } else {
  41.311 -                doesNotHave(index, value, callSiteFlags);
  41.312 -            }
  41.313 -
  41.314 -            return;
  41.315 -        }
  41.316 -
  41.317 -        final String propName = JSType.toString(key);
  41.318 -        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  41.319 -    }
  41.320 -
  41.321 -    @Override
  41.322 -    public void set(final long key, final long value, final int callSiteFlags) {
  41.323 -        final int index = getArrayIndex(key);
  41.324 -
  41.325 -        if (isValidArrayIndex(index)) {
  41.326 -            final ArrayData data = getArray();
  41.327 -            if (data.has(index)) {
  41.328 -                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
  41.329 -            } else {
  41.330 -                doesNotHave(index, value, callSiteFlags);
  41.331 -            }
  41.332 -
  41.333 -            return;
  41.334 -        }
  41.335 -
  41.336 -        final String propName = JSType.toString(key);
  41.337 -        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  41.338 -    }
  41.339 -
  41.340 -    @Override
  41.341 -    public void set(final long key, final double value, final int callSiteFlags) {
  41.342 -        final int index = getArrayIndex(key);
  41.343 -
  41.344 -        if (isValidArrayIndex(index)) {
  41.345 -            final ArrayData data = getArray();
  41.346 -            if (data.has(index)) {
  41.347 -                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
  41.348 -            } else {
  41.349 -                doesNotHave(index, value, callSiteFlags);
  41.350 -            }
  41.351 -
  41.352 -            return;
  41.353 -        }
  41.354 -
  41.355 -        final String propName = JSType.toString(key);
  41.356 -        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  41.357 -    }
  41.358 -
  41.359 -    @Override
  41.360 -    public void set(final long key, final Object value, final int callSiteFlags) {
  41.361 -        final int index = getArrayIndex(key);
  41.362 -
  41.363 -        if (isValidArrayIndex(index)) {
  41.364 -            final ArrayData data = getArray();
  41.365 -            if (data.has(index)) {
  41.366 -                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
  41.367 -            } else {
  41.368 -                doesNotHave(index, value, callSiteFlags);
  41.369 -            }
  41.370 -
  41.371 -            return;
  41.372 -        }
  41.373 -
  41.374 -        final String propName = JSType.toString(key);
  41.375 -        setObject(findProperty(propName, true), callSiteFlags, propName, value);
  41.376 -    }
  41.377 -
  41.378 -    @Override
  41.379      public void set(final int key, final int value, final int callSiteFlags) {
  41.380          final int index = getArrayIndex(key);
  41.381          if (isValidArrayIndex(index)) {
  41.382 @@ -3451,7 +3192,7 @@
  41.383      }
  41.384  
  41.385      @Override
  41.386 -    public void set(final int key, final long value, final int callSiteFlags) {
  41.387 +    public void set(final int key, final double value, final int callSiteFlags) {
  41.388          final int index = getArrayIndex(key);
  41.389  
  41.390          if (isValidArrayIndex(index)) {
  41.391 @@ -3470,7 +3211,7 @@
  41.392      }
  41.393  
  41.394      @Override
  41.395 -    public void set(final int key, final double value, final int callSiteFlags) {
  41.396 +    public void set(final int key, final Object value, final int callSiteFlags) {
  41.397          final int index = getArrayIndex(key);
  41.398  
  41.399          if (isValidArrayIndex(index)) {
  41.400 @@ -3485,25 +3226,6 @@
  41.401          }
  41.402  
  41.403          final String propName = JSType.toString(key);
  41.404 -        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
  41.405 -    }
  41.406 -
  41.407 -    @Override
  41.408 -    public void set(final int key, final Object value, final int callSiteFlags) {
  41.409 -        final int index = getArrayIndex(key);
  41.410 -
  41.411 -        if (isValidArrayIndex(index)) {
  41.412 -            final ArrayData data = getArray();
  41.413 -            if (data.has(index)) {
  41.414 -                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
  41.415 -            } else {
  41.416 -                doesNotHave(index, value, callSiteFlags);
  41.417 -            }
  41.418 -
  41.419 -            return;
  41.420 -        }
  41.421 -
  41.422 -        final String propName = JSType.toString(key);
  41.423          setObject(findProperty(propName, true), callSiteFlags, propName, value);
  41.424      }
  41.425  
  41.426 @@ -3521,12 +3243,6 @@
  41.427      }
  41.428  
  41.429      @Override
  41.430 -    public boolean has(final long key) {
  41.431 -        final int index = getArrayIndex(key);
  41.432 -        return isValidArrayIndex(index) ? hasArrayProperty(index) : hasProperty(JSType.toString(key), true);
  41.433 -    }
  41.434 -
  41.435 -    @Override
  41.436      public boolean has(final int key) {
  41.437          final int index = getArrayIndex(key);
  41.438          return isValidArrayIndex(index) ? hasArrayProperty(index) : hasProperty(JSType.toString(key), true);
  41.439 @@ -3559,12 +3275,6 @@
  41.440      }
  41.441  
  41.442      @Override
  41.443 -    public boolean hasOwnProperty(final long key) {
  41.444 -        final int index = getArrayIndex(key);
  41.445 -        return isValidArrayIndex(index) ? hasOwnArrayProperty(index) : hasProperty(JSType.toString(key), false);
  41.446 -    }
  41.447 -
  41.448 -    @Override
  41.449      public boolean hasOwnProperty(final double key) {
  41.450          final int index = getArrayIndex(key);
  41.451          return isValidArrayIndex(index) ? hasOwnArrayProperty(index) : hasProperty(JSType.toString(key), false);
  41.452 @@ -3590,22 +3300,6 @@
  41.453      }
  41.454  
  41.455      @Override
  41.456 -    public boolean delete(final long key, final boolean strict) {
  41.457 -        final int index = getArrayIndex(key);
  41.458 -        final ArrayData array = getArray();
  41.459 -
  41.460 -        if (array.has(index)) {
  41.461 -            if (array.canDelete(index, strict)) {
  41.462 -                setArray(array.delete(index));
  41.463 -                return true;
  41.464 -            }
  41.465 -            return false;
  41.466 -        }
  41.467 -
  41.468 -        return deleteObject(JSType.toObject(key), strict);
  41.469 -    }
  41.470 -
  41.471 -    @Override
  41.472      public boolean delete(final double key, final boolean strict) {
  41.473          final int index = getArrayIndex(key);
  41.474          final ArrayData array = getArray();
    42.1 --- a/src/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java	Tue Jan 19 18:56:23 2016 +0100
    42.2 +++ b/src/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java	Fri Jan 22 16:18:19 2016 +0100
    42.3 @@ -49,7 +49,10 @@
    42.4      private final Type   returnType;
    42.5  
    42.6      /**
    42.7 -     * Constructor
    42.8 +     * Constructor without explicit return type. The return type is determined statically from the class of
    42.9 +     * the return value, and only canonical internal number representations are recognized. Use
   42.10 +     * {@link #createNarrowest} if you want to handle float and long values as numbers instead of objects.
   42.11 +     *
   42.12       * @param returnValue actual return value from the too narrow operation
   42.13       * @param programPoint program point where unwarranted optimism was detected
   42.14       */
   42.15 @@ -58,7 +61,7 @@
   42.16      }
   42.17  
   42.18      /**
   42.19 -     * Check if a program point is valid
   42.20 +     * Check if a program point is valid.
   42.21       * @param programPoint the program point
   42.22       * @return true if valid
   42.23       */
   42.24 @@ -70,8 +73,6 @@
   42.25      private static Type getReturnType(final Object v) {
   42.26          if (v instanceof Double) {
   42.27              return Type.NUMBER;
   42.28 -        } else if (v instanceof Long) {
   42.29 -            return Type.LONG;
   42.30          }
   42.31          assert !(v instanceof Integer) : v + " is an int"; // Can't have an unwarranted optimism exception with int
   42.32          return Type.OBJECT;
   42.33 @@ -97,6 +98,22 @@
   42.34      }
   42.35  
   42.36      /**
   42.37 +     * Create an {@code UnwarrantedOptimismException} with the given return value and program point, narrowing
   42.38 +     * the type to {@code number} if the value is a float or a long that can be represented as double.
   42.39 +     *
   42.40 +     * @param returnValue the return value
   42.41 +     * @param programPoint the program point
   42.42 +     * @return the exception
   42.43 +     */
   42.44 +    public static UnwarrantedOptimismException createNarrowest(final Object returnValue, final int programPoint) {
   42.45 +        if (returnValue instanceof Float
   42.46 +                || (returnValue instanceof Long && JSType.isRepresentableAsDouble((Long) returnValue))) {
   42.47 +            return new UnwarrantedOptimismException(((Number) returnValue).doubleValue(), programPoint, Type.NUMBER);
   42.48 +        }
   42.49 +        return new UnwarrantedOptimismException(returnValue, programPoint);
   42.50 +    }
   42.51 +
   42.52 +    /**
   42.53       * Get the return value. This is a destructive readout, after the method is invoked the return value is null'd out.
   42.54       * @return return value
   42.55       */
    43.1 --- a/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java	Tue Jan 19 18:56:23 2016 +0100
    43.2 +++ b/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java	Fri Jan 22 16:18:19 2016 +0100
    43.3 @@ -71,13 +71,11 @@
    43.4      /** Getter method handle */
    43.5      private final static MethodHandle INVOKE_OBJECT_GETTER = findOwnMH_S("invokeObjectGetter", Object.class, Accessors.class, MethodHandle.class, Object.class);
    43.6      private final static MethodHandle INVOKE_INT_GETTER  = findOwnMH_S("invokeIntGetter", int.class, Accessors.class, MethodHandle.class, int.class, Object.class);
    43.7 -    private final static MethodHandle INVOKE_LONG_GETTER  = findOwnMH_S("invokeLongGetter", long.class, Accessors.class, MethodHandle.class, int.class, Object.class);
    43.8      private final static MethodHandle INVOKE_NUMBER_GETTER  = findOwnMH_S("invokeNumberGetter", double.class, Accessors.class, MethodHandle.class, int.class, Object.class);
    43.9  
   43.10      /** Setter method handle */
   43.11      private final static MethodHandle INVOKE_OBJECT_SETTER = findOwnMH_S("invokeObjectSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, Object.class);
   43.12      private final static MethodHandle INVOKE_INT_SETTER = findOwnMH_S("invokeIntSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, int.class);
   43.13 -    private final static MethodHandle INVOKE_LONG_SETTER = findOwnMH_S("invokeLongSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, long.class);
   43.14      private final static MethodHandle INVOKE_NUMBER_SETTER = findOwnMH_S("invokeNumberSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, double.class);
   43.15  
   43.16      private static final Object OBJECT_GETTER_INVOKER_KEY = new Object();
   43.17 @@ -188,11 +186,6 @@
   43.18      }
   43.19  
   43.20      @Override
   43.21 -    public long getLongValue(final ScriptObject self, final ScriptObject owner) {
   43.22 -        return (long)getObjectValue(self, owner);
   43.23 -    }
   43.24 -
   43.25 -    @Override
   43.26      public double getDoubleValue(final ScriptObject self, final ScriptObject owner) {
   43.27          return (double)getObjectValue(self, owner);
   43.28      }
   43.29 @@ -214,11 +207,6 @@
   43.30      }
   43.31  
   43.32      @Override
   43.33 -    public void setValue(final ScriptObject self, final ScriptObject owner, final long value, final boolean strict) {
   43.34 -        setValue(self, owner, (Object) value, strict);
   43.35 -    }
   43.36 -
   43.37 -    @Override
   43.38      public void setValue(final ScriptObject self, final ScriptObject owner, final double value, final boolean strict) {
   43.39          setValue(self, owner, (Object) value, strict);
   43.40      }
   43.41 @@ -244,8 +232,6 @@
   43.42      public MethodHandle getOptimisticGetter(final Class<?> type, final int programPoint) {
   43.43          if (type == int.class) {
   43.44              return INVOKE_INT_GETTER;
   43.45 -        } else if (type == long.class) {
   43.46 -            return INVOKE_LONG_GETTER;
   43.47          } else if (type == double.class) {
   43.48              return INVOKE_NUMBER_GETTER;
   43.49          } else {
   43.50 @@ -269,8 +255,6 @@
   43.51      public MethodHandle getSetter(final Class<?> type, final PropertyMap currentMap) {
   43.52          if (type == int.class) {
   43.53              return INVOKE_INT_SETTER;
   43.54 -        } else if (type == long.class) {
   43.55 -            return INVOKE_LONG_SETTER;
   43.56          } else if (type == double.class) {
   43.57              return INVOKE_NUMBER_SETTER;
   43.58          } else {
   43.59 @@ -320,16 +304,6 @@
   43.60      }
   43.61  
   43.62      @SuppressWarnings("unused")
   43.63 -    private static long invokeLongGetter(final Accessors gs, final MethodHandle invoker, final int programPoint, final Object self) throws Throwable {
   43.64 -        final Object func = gs.getter;
   43.65 -        if (func instanceof ScriptFunction) {
   43.66 -            return (long) invoker.invokeExact(func, self);
   43.67 -        }
   43.68 -
   43.69 -        throw new UnwarrantedOptimismException(UNDEFINED, programPoint);
   43.70 -    }
   43.71 -
   43.72 -    @SuppressWarnings("unused")
   43.73      private static double invokeNumberGetter(final Accessors gs, final MethodHandle invoker, final int programPoint, final Object self) throws Throwable {
   43.74          final Object func = gs.getter;
   43.75          if (func instanceof ScriptFunction) {
   43.76 @@ -360,16 +334,6 @@
   43.77      }
   43.78  
   43.79      @SuppressWarnings("unused")
   43.80 -    private static void invokeLongSetter(final Accessors gs, final MethodHandle invoker, final String name, final Object self, final long value) throws Throwable {
   43.81 -        final Object func = gs.setter;
   43.82 -        if (func instanceof ScriptFunction) {
   43.83 -            invoker.invokeExact(func, self, value);
   43.84 -        } else if (name != null) {
   43.85 -            throw typeError("property.has.no.setter", name, ScriptRuntime.safeToString(self));
   43.86 -        }
   43.87 -    }
   43.88 -
   43.89 -    @SuppressWarnings("unused")
   43.90      private static void invokeNumberSetter(final Accessors gs, final MethodHandle invoker, final String name, final Object self, final double value) throws Throwable {
   43.91          final Object func = gs.setter;
   43.92          if (func instanceof ScriptFunction) {
    44.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java	Tue Jan 19 18:56:23 2016 +0100
    44.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java	Fri Jan 22 16:18:19 2016 +0100
    44.3 @@ -52,9 +52,6 @@
    44.4      /** Minimum chunk size for underlying arrays */
    44.5      protected static final int CHUNK_SIZE = 32;
    44.6  
    44.7 -    /** Mask for getting a chunk */
    44.8 -    protected static final int CHUNK_MASK = CHUNK_SIZE - 1;
    44.9 -
   44.10      /** Untouched data - still link callsites as IntArrayData, but expands to
   44.11       *  a proper ArrayData when we try to write to it */
   44.12      public static final ArrayData EMPTY_ARRAY = new UntouchedArrayData();
   44.13 @@ -164,11 +161,6 @@
   44.14          }
   44.15  
   44.16          @Override
   44.17 -        public ArrayData set(final int index, final long value, final boolean strict) {
   44.18 -            return toRealArrayData(index).set(index, value, strict);
   44.19 -        }
   44.20 -
   44.21 -        @Override
   44.22          public ArrayData set(final int index, final double value, final boolean strict) {
   44.23              return toRealArrayData(index).set(index, value, strict);
   44.24          }
   44.25 @@ -179,11 +171,6 @@
   44.26          }
   44.27  
   44.28          @Override
   44.29 -        public long getLong(final int index) {
   44.30 -            throw new ArrayIndexOutOfBoundsException(index); //empty
   44.31 -        }
   44.32 -
   44.33 -        @Override
   44.34          public double getDouble(final int index) {
   44.35              throw new ArrayIndexOutOfBoundsException(index); //empty
   44.36          }
   44.37 @@ -288,13 +275,13 @@
   44.38       * @param length the initial length
   44.39       * @return ArrayData
   44.40       */
   44.41 -    public static ArrayData allocate(final int length) {
   44.42 -        if (length == 0) {
   44.43 +    public static ArrayData allocate(final long length) {
   44.44 +        if (length == 0L) {
   44.45              return new IntArrayData();
   44.46          } else if (length >= SparseArrayData.MAX_DENSE_LENGTH) {
   44.47              return new SparseArrayData(EMPTY_ARRAY, length);
   44.48          } else {
   44.49 -            return new DeletedRangeArrayFilter(new IntArrayData(length), 0, length - 1);
   44.50 +            return new DeletedRangeArrayFilter(new IntArrayData((int) length), 0, length - 1);
   44.51          }
   44.52      }
   44.53  
   44.54 @@ -309,8 +296,6 @@
   44.55  
   44.56          if (clazz == int[].class) {
   44.57              return new IntArrayData((int[])array, ((int[])array).length);
   44.58 -        } else if (clazz == long[].class) {
   44.59 -            return new LongArrayData((long[])array, ((long[])array).length);
   44.60          } else if (clazz == double[].class) {
   44.61              return new NumberArrayData((double[])array, ((double[])array).length);
   44.62          } else {
   44.63 @@ -334,16 +319,6 @@
   44.64       * @param array the array to use for initial elements
   44.65       * @return the ArrayData
   44.66       */
   44.67 -    public static ArrayData allocate(final long[] array) {
   44.68 -        return new LongArrayData(array, array.length);
   44.69 -    }
   44.70 -
   44.71 -    /**
   44.72 -     * Allocate an ArrayData wrapping a given array
   44.73 -     *
   44.74 -     * @param array the array to use for initial elements
   44.75 -     * @return the ArrayData
   44.76 -     */
   44.77      public static ArrayData allocate(final double[] array) {
   44.78          return new NumberArrayData(array, array.length);
   44.79      }
   44.80 @@ -537,16 +512,6 @@
   44.81      public abstract ArrayData set(final int index, final int value, final boolean strict);
   44.82  
   44.83      /**
   44.84 -     * Set a long value at a given index
   44.85 -     *
   44.86 -     * @param index the index
   44.87 -     * @param value the value
   44.88 -     * @param strict are we in strict mode
   44.89 -     * @return new array data (or same)
   44.90 -     */
   44.91 -    public abstract ArrayData set(final int index, final long value, final boolean strict);
   44.92 -
   44.93 -    /**
   44.94       * Set an double value at a given index
   44.95       *
   44.96       * @param index the index
   44.97 @@ -609,26 +574,6 @@
   44.98      }
   44.99  
  44.100      /**
  44.101 -     * Get a long value from a given index
  44.102 -     *
  44.103 -     * @param index the index
  44.104 -     * @return the value
  44.105 -     */
  44.106 -    public abstract long getLong(final int index);
  44.107 -
  44.108 -    /**
  44.109 -     * Get optimistic long - default is that it's impossible. Overridden
  44.110 -     * by arrays that actually represents longs or narrower
  44.111 -     *
  44.112 -     * @param index        the index
  44.113 -     * @param programPoint program point
  44.114 -     * @return the value
  44.115 -     */
  44.116 -    public long getLongOptimistic(final int index, final int programPoint) {
  44.117 -        throw new UnwarrantedOptimismException(getObject(index), programPoint, getOptimisticType());
  44.118 -    }
  44.119 -
  44.120 -    /**
  44.121       * Get a double value from a given index
  44.122       *
  44.123       * @param index the index
  44.124 @@ -821,12 +766,8 @@
  44.125                  return Object.class;
  44.126              }
  44.127              final Class<?> itemClass = item.getClass();
  44.128 -            if (itemClass == Long.class) {
  44.129 +            if (itemClass == Double.class || itemClass == Float.class || itemClass == Long.class) {
  44.130                  if (widest == Integer.class) {
  44.131 -                    widest = Long.class;
  44.132 -                }
  44.133 -            } else if (itemClass == Double.class || itemClass == Float.class) {
  44.134 -                if (widest == Integer.class || widest == Long.class) {
  44.135                      widest = Double.class;
  44.136                  }
  44.137              } else if (itemClass != Integer.class && itemClass != Short.class && itemClass != Byte.class) {
    45.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java	Tue Jan 19 18:56:23 2016 +0100
    45.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java	Fri Jan 22 16:18:19 2016 +0100
    45.3 @@ -109,13 +109,6 @@
    45.4      }
    45.5  
    45.6      @Override
    45.7 -    public ArrayData set(final int index, final long value, final boolean strict) {
    45.8 -        underlying = underlying.set(index, value, strict);
    45.9 -        setLength(underlying.length());
   45.10 -        return this;
   45.11 -    }
   45.12 -
   45.13 -    @Override
   45.14      public ArrayData set(final int index, final double value, final boolean strict) {
   45.15          underlying = underlying.set(index, value, strict);
   45.16          setLength(underlying.length());
   45.17 @@ -150,16 +143,6 @@
   45.18      }
   45.19  
   45.20      @Override
   45.21 -    public long getLong(final int index) {
   45.22 -        return underlying.getLong(index);
   45.23 -    }
   45.24 -
   45.25 -    @Override
   45.26 -    public long getLongOptimistic(final int index, final int programPoint) {
   45.27 -        return underlying.getLongOptimistic(index, programPoint);
   45.28 -    }
   45.29 -
   45.30 -    @Override
   45.31      public double getDouble(final int index) {
   45.32          return underlying.getDouble(index);
   45.33      }
    46.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java	Tue Jan 19 18:56:23 2016 +0100
    46.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java	Fri Jan 22 16:18:19 2016 +0100
    46.3 @@ -122,12 +122,6 @@
    46.4      }
    46.5  
    46.6      @Override
    46.7 -    public ArrayData set(final int index, final long value, final boolean strict) {
    46.8 -        buf.put(index, (byte)value);
    46.9 -        return this;
   46.10 -    }
   46.11 -
   46.12 -    @Override
   46.13      public ArrayData set(final int index, final double value, final boolean strict) {
   46.14          buf.put(index, (byte)value);
   46.15          return this;
   46.16 @@ -139,11 +133,6 @@
   46.17      }
   46.18  
   46.19      @Override
   46.20 -    public long getLong(final int index) {
   46.21 -        return 0x0ff & buf.get(index);
   46.22 -    }
   46.23 -
   46.24 -    @Override
   46.25      public double getDouble(final int index) {
   46.26          return 0x0ff & buf.get(index);
   46.27      }
    47.1 --- a/src/jdk/nashorn/internal/runtime/arrays/DeletedArrayFilter.java	Tue Jan 19 18:56:23 2016 +0100
    47.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/DeletedArrayFilter.java	Fri Jan 22 16:18:19 2016 +0100
    47.3 @@ -120,12 +120,6 @@
    47.4      }
    47.5  
    47.6      @Override
    47.7 -    public ArrayData set(final int index, final long value, final boolean strict) {
    47.8 -        deleted.clear(ArrayIndex.toLongIndex(index));
    47.9 -        return super.set(index, value, strict);
   47.10 -    }
   47.11 -
   47.12 -    @Override
   47.13      public ArrayData set(final int index, final double value, final boolean strict) {
   47.14          deleted.clear(ArrayIndex.toLongIndex(index));
   47.15          return super.set(index, value, strict);
    48.1 --- a/src/jdk/nashorn/internal/runtime/arrays/DeletedRangeArrayFilter.java	Tue Jan 19 18:56:23 2016 +0100
    48.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/DeletedRangeArrayFilter.java	Fri Jan 22 16:18:19 2016 +0100
    48.3 @@ -163,24 +163,6 @@
    48.4      }
    48.5  
    48.6      @Override
    48.7 -    public ArrayData set(final int index, final long value, final boolean strict) {
    48.8 -        final long longIndex = ArrayIndex.toLongIndex(index);
    48.9 -        if (longIndex < lo || longIndex > hi) {
   48.10 -            return super.set(index, value, strict);
   48.11 -        } else if (longIndex > lo && longIndex < hi) {
   48.12 -            return getDeletedArrayFilter().set(index, value, strict);
   48.13 -        }
   48.14 -        if (longIndex == lo) {
   48.15 -            lo++;
   48.16 -        } else {
   48.17 -            assert longIndex == hi;
   48.18 -            hi--;
   48.19 -        }
   48.20 -
   48.21 -        return isEmpty() ? getUnderlying().set(index, value, strict) : super.set(index, value, strict);
   48.22 -    }
   48.23 -
   48.24 -    @Override
   48.25      public ArrayData set(final int index, final double value, final boolean strict) {
   48.26          final long longIndex = ArrayIndex.toLongIndex(index);
   48.27          if (longIndex < lo || longIndex > hi) {
    49.1 --- a/src/jdk/nashorn/internal/runtime/arrays/FrozenArrayFilter.java	Tue Jan 19 18:56:23 2016 +0100
    49.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/FrozenArrayFilter.java	Fri Jan 22 16:18:19 2016 +0100
    49.3 @@ -57,14 +57,6 @@
    49.4      }
    49.5  
    49.6      @Override
    49.7 -    public ArrayData set(final int index, final long value, final boolean strict) {
    49.8 -        if (strict) {
    49.9 -            throw typeError("cant.set.property", Integer.toString(index), "frozen array");
   49.10 -        }
   49.11 -        return this;
   49.12 -    }
   49.13 -
   49.14 -    @Override
   49.15      public ArrayData set(final int index, final double value, final boolean strict) {
   49.16          if (strict) {
   49.17              throw typeError("cant.set.property", Integer.toString(index), "frozen array");
    50.1 --- a/src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java	Tue Jan 19 18:56:23 2016 +0100
    50.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java	Fri Jan 22 16:18:19 2016 +0100
    50.3 @@ -156,22 +156,6 @@
    50.4          return darray;
    50.5      }
    50.6  
    50.7 -    private long[] toLongArray() {
    50.8 -        assert length() <= array.length : "length exceeds internal array size";
    50.9 -        final int len = (int)length();
   50.10 -        final long[] larray = new long[array.length];
   50.11 -
   50.12 -        for (int index = 0; index < len; index++) {
   50.13 -            larray[index] = array[index];
   50.14 -        }
   50.15 -
   50.16 -        return larray;
   50.17 -    }
   50.18 -
   50.19 -    private LongArrayData convertToLong() {
   50.20 -        return new LongArrayData(toLongArray(), (int)length());
   50.21 -    }
   50.22 -
   50.23      private NumberArrayData convertToDouble() {
   50.24          return new NumberArrayData(toDoubleArray(), (int)length());
   50.25      }
   50.26 @@ -184,8 +168,6 @@
   50.27      public ArrayData convert(final Class<?> type) {
   50.28          if (type == Integer.class || type == Byte.class || type == Short.class) {
   50.29              return this;
   50.30 -        } else if (type == Long.class) {
   50.31 -            return convertToLong();
   50.32          } else if (type == Double.class || type == Float.class) {
   50.33              return convertToDouble();
   50.34          } else {
   50.35 @@ -253,17 +235,6 @@
   50.36      }
   50.37  
   50.38      @Override
   50.39 -    public ArrayData set(final int index, final long value, final boolean strict) {
   50.40 -        if (JSType.isRepresentableAsInt(value)) {
   50.41 -            array[index] = JSType.toInt32(value);
   50.42 -            setLength(Math.max(index + 1, length()));
   50.43 -            return this;
   50.44 -        }
   50.45 -
   50.46 -        return convert(Long.class).set(index, value, strict);
   50.47 -    }
   50.48 -
   50.49 -    @Override
   50.50      public ArrayData set(final int index, final double value, final boolean strict) {
   50.51          if (JSType.isRepresentableAsInt(value)) {
   50.52              array[index] = (int)(long)value;
   50.53 @@ -285,16 +256,6 @@
   50.54      }
   50.55  
   50.56      @Override
   50.57 -    public long getLong(final int index) {
   50.58 -        return array[index];
   50.59 -    }
   50.60 -
   50.61 -    @Override
   50.62 -    public long getLongOptimistic(final int index, final int programPoint) {
   50.63 -        return array[index];
   50.64 -    }
   50.65 -
   50.66 -    @Override
   50.67      public double getDouble(final int index) {
   50.68          return array[index];
   50.69      }
    51.1 --- a/src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java	Tue Jan 19 18:56:23 2016 +0100
    51.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java	Fri Jan 22 16:18:19 2016 +0100
    51.3 @@ -130,6 +130,6 @@
    51.4       *
    51.5       * @throws Throwable if invocation throws an exception/error
    51.6       */
    51.7 -    protected abstract boolean forEach(final Object val, final long i) throws Throwable;
    51.8 +    protected abstract boolean forEach(final Object val, final double i) throws Throwable;
    51.9  
   51.10  }
    52.1 --- a/src/jdk/nashorn/internal/runtime/arrays/LengthNotWritableFilter.java	Tue Jan 19 18:56:23 2016 +0100
    52.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/LengthNotWritableFilter.java	Fri Jan 22 16:18:19 2016 +0100
    52.3 @@ -91,22 +91,6 @@
    52.4      }
    52.5  
    52.6      @Override
    52.7 -    public long getLong(final int index) {
    52.8 -        if (index >= length()) {
    52.9 -            return JSType.toLong(get(index));
   52.10 -        }
   52.11 -        return underlying.getLong(index);
   52.12 -    }
   52.13 -
   52.14 -    @Override
   52.15 -    public long getLongOptimistic(final int index, final int programPoint) {
   52.16 -        if (index >= length()) {
   52.17 -            return JSType.toLongOptimistic(get(index), programPoint);
   52.18 -        }
   52.19 -        return underlying.getLongOptimistic(index, programPoint);
   52.20 -    }
   52.21 -
   52.22 -    @Override
   52.23      public double getDouble(final int index) {
   52.24          if (index >= length()) {
   52.25              return JSType.toNumber(get(index));
   52.26 @@ -149,15 +133,6 @@
   52.27      }
   52.28  
   52.29      @Override
   52.30 -    public ArrayData set(final int index, final long value, final boolean strict) {
   52.31 -        if (checkAdd(index, value)) {
   52.32 -            return this;
   52.33 -        }
   52.34 -        underlying = underlying.set(index, value, strict);
   52.35 -        return this;
   52.36 -    }
   52.37 -
   52.38 -    @Override
   52.39      public ArrayData set(final int index, final double value, final boolean strict) {
   52.40          if (checkAdd(index, value)) {
   52.41              return this;
    53.1 --- a/src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java	Tue Jan 19 18:56:23 2016 +0100
    53.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.3 @@ -1,406 +0,0 @@
    53.4 -/*
    53.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    53.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    53.7 - *
    53.8 - * This code is free software; you can redistribute it and/or modify it
    53.9 - * under the terms of the GNU General Public License version 2 only, as
   53.10 - * published by the Free Software Foundation.  Oracle designates this
   53.11 - * particular file as subject to the "Classpath" exception as provided
   53.12 - * by Oracle in the LICENSE file that accompanied this code.
   53.13 - *
   53.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   53.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   53.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   53.17 - * version 2 for more details (a copy is included in the LICENSE file that
   53.18 - * accompanied this code).
   53.19 - *
   53.20 - * You should have received a copy of the GNU General Public License version
   53.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   53.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   53.23 - *
   53.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   53.25 - * or visit www.oracle.com if you need additional information or have any
   53.26 - * questions.
   53.27 - */
   53.28 -
   53.29 -package jdk.nashorn.internal.runtime.arrays;
   53.30 -
   53.31 -import static jdk.nashorn.internal.codegen.CompilerConstants.specialCall;
   53.32 -import static jdk.nashorn.internal.lookup.Lookup.MH;
   53.33 -
   53.34 -import java.lang.invoke.MethodHandle;
   53.35 -import java.lang.invoke.MethodHandles;
   53.36 -import java.util.Arrays;
   53.37 -import jdk.nashorn.internal.runtime.JSType;
   53.38 -import jdk.nashorn.internal.runtime.ScriptRuntime;
   53.39 -
   53.40 -/**
   53.41 - * Implementation of {@link ArrayData} as soon as a long has been
   53.42 - * written to the array
   53.43 - */
   53.44 -final class LongArrayData extends ContinuousArrayData implements IntOrLongElements {
   53.45 -    /**
   53.46 -     * The wrapped array
   53.47 -     */
   53.48 -    private long[] array;
   53.49 -
   53.50 -    /**
   53.51 -     * Constructor
   53.52 -     * @param array an int array
   53.53 -     * @param length a length, not necessarily array.length
   53.54 -     */
   53.55 -    LongArrayData(final long array[], final int length) {
   53.56 -        super(length);
   53.57 -        assert array.length >= length;
   53.58 -        this.array = array;
   53.59 -    }
   53.60 -
   53.61 -    @Override
   53.62 -    public final Class<?> getElementType() {
   53.63 -        return long.class;
   53.64 -    }
   53.65 -
   53.66 -    @Override
   53.67 -    public final Class<?> getBoxedElementType() {
   53.68 -        return Long.class;
   53.69 -    }
   53.70 -
   53.71 -    @Override
   53.72 -    public final ContinuousArrayData widest(final ContinuousArrayData otherData) {
   53.73 -        return otherData instanceof IntElements ? this : otherData;
   53.74 -    }
   53.75 -
   53.76 -    @Override
   53.77 -    public final int getElementWeight() {
   53.78 -        return 2;
   53.79 -    }
   53.80 -
   53.81 -    @Override
   53.82 -    public LongArrayData copy() {
   53.83 -        return new LongArrayData(array.clone(), (int)length());
   53.84 -    }
   53.85 -
   53.86 -    @Override
   53.87 -    public Object[] asObjectArray() {
   53.88 -        return toObjectArray(true);
   53.89 -    }
   53.90 -
   53.91 -    private Object[] toObjectArray(final boolean trim) {
   53.92 -        assert length() <= array.length : "length exceeds internal array size";
   53.93 -        final int len = (int)length();
   53.94 -        final Object[] oarray = new Object[trim ? len : array.length];
   53.95 -
   53.96 -        for (int index = 0; index < len; index++) {
   53.97 -            oarray[index] = Long.valueOf(array[index]);
   53.98 -        }
   53.99 -
  53.100 -        return oarray;
  53.101 -    }
  53.102 -
  53.103 -    @Override
  53.104 -    public Object asArrayOfType(final Class<?> componentType) {
  53.105 -        if (componentType == long.class) {
  53.106 -            final int len = (int)length();
  53.107 -            return array.length == len ? array.clone() : Arrays.copyOf(array, len);
  53.108 -        }
  53.109 -        return super.asArrayOfType(componentType);
  53.110 -    }
  53.111 -
  53.112 -    private double[] toDoubleArray() {
  53.113 -        assert length() <= array.length : "length exceeds internal array size";
  53.114 -        final int len = (int)length();
  53.115 -        final double[] darray = new double[array.length];
  53.116 -
  53.117 -        for (int index = 0; index < len; index++) {
  53.118 -            darray[index] = array[index];
  53.119 -        }
  53.120 -
  53.121 -        return darray;
  53.122 -    }
  53.123 -
  53.124 -    @Override
  53.125 -    public ContinuousArrayData convert(final Class<?> type) {
  53.126 -        if (type == Integer.class || type == Long.class || type == Byte.class || type == Short.class) {
  53.127 -            return this;
  53.128 -        }
  53.129 -        final int len = (int)length();
  53.130 -        if (type == Double.class || type == Float.class) {
  53.131 -            return new NumberArrayData(toDoubleArray(), len);
  53.132 -        }
  53.133 -        return new ObjectArrayData(toObjectArray(false), len);
  53.134 -    }
  53.135 -
  53.136 -    @Override
  53.137 -    public void shiftLeft(final int by) {
  53.138 -        System.arraycopy(array, by, array, 0, array.length - by);
  53.139 -    }
  53.140 -
  53.141 -    @Override
  53.142 -    public ArrayData shiftRight(final int by) {
  53.143 -        final ArrayData newData = ensure(by + length() - 1);
  53.144 -        if (newData != this) {
  53.145 -            newData.shiftRight(by);
  53.146 -            return newData;
  53.147 -        }
  53.148 -        System.arraycopy(array, 0, array, by, array.length - by);
  53.149 -
  53.150 -        return this;
  53.151 -    }
  53.152 -
  53.153 -    @Override
  53.154 -    public ArrayData ensure(final long safeIndex) {
  53.155 -        if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH) {
  53.156 -            return new SparseArrayData(this, safeIndex + 1);
  53.157 -        }
  53.158 -        final int alen = array.length;
  53.159 -        if (safeIndex >= alen) {
  53.160 -            final int newLength = ArrayData.nextSize((int)safeIndex);
  53.161 -            array = Arrays.copyOf(array, newLength);
  53.162 -        }
  53.163 -        if (safeIndex >= length()) {
  53.164 -            setLength(safeIndex + 1);
  53.165 -        }
  53.166 -        return this;
  53.167 -    }
  53.168 -
  53.169 -    @Override
  53.170 -    public ArrayData shrink(final long newLength) {
  53.171 -        Arrays.fill(array, (int)newLength, array.length, 0L);
  53.172 -        return this;
  53.173 -    }
  53.174 -
  53.175 -    @Override
  53.176 -    public ArrayData set(final int index, final Object value, final boolean strict) {
  53.177 -        if (value instanceof Long || value instanceof Integer ||
  53.178 -            value instanceof Byte || value instanceof Short) {
  53.179 -            return set(index, ((Number)value).longValue(), strict);
  53.180 -        } else if (value == ScriptRuntime.UNDEFINED) {
  53.181 -            return new UndefinedArrayFilter(this).set(index, value, strict);
  53.182 -        }
  53.183 -
  53.184 -        final ArrayData newData = convert(value == null ? Object.class : value.getClass());
  53.185 -        return newData.set(index, value, strict);
  53.186 -    }
  53.187 -
  53.188 -    @Override
  53.189 -    public ArrayData set(final int index, final int value, final boolean strict) {
  53.190 -        array[index] = value;
  53.191 -        setLength(Math.max(index + 1, length()));
  53.192 -        return this;
  53.193 -    }
  53.194 -
  53.195 -    @Override
  53.196 -    public ArrayData set(final int index, final long value, final boolean strict) {
  53.197 -        array[index] = value;
  53.198 -        setLength(Math.max(index + 1, length()));
  53.199 -        return this;
  53.200 -    }
  53.201 -
  53.202 -    @Override
  53.203 -    public ArrayData set(final int index, final double value, final boolean strict) {
  53.204 -        if (JSType.isRepresentableAsLong(value)) {
  53.205 -            array[index] = (long)value;
  53.206 -            setLength(Math.max(index + 1, length()));
  53.207 -            return this;
  53.208 -        }
  53.209 -        return convert(Double.class).set(index, value, strict);
  53.210 -    }
  53.211 -
  53.212 -    private static final MethodHandle HAS_GET_ELEM = specialCall(MethodHandles.lookup(), LongArrayData.class, "getElem", long.class, int.class).methodHandle();
  53.213 -    private static final MethodHandle SET_ELEM     = specialCall(MethodHandles.lookup(), LongArrayData.class, "setElem", void.class, int.class, long.class).methodHandle();
  53.214 -
  53.215 -    @SuppressWarnings("unused")
  53.216 -    private long getElem(final int index) {
  53.217 -        if (has(index)) {
  53.218 -            return array[index];
  53.219 -        }
  53.220 -        throw new ClassCastException();
  53.221 -    }
  53.222 -
  53.223 -    @SuppressWarnings("unused")
  53.224 -    private void setElem(final int index, final long elem) {
  53.225 -        if (hasRoomFor(index)) {
  53.226 -            array[index] = elem;
  53.227 -            return;
  53.228 -        }
  53.229 -        throw new ClassCastException();
  53.230 -    }
  53.231 -
  53.232 -    @Override
  53.233 -    public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) {
  53.234 -        if (returnType == int.class) {
  53.235 -            return null;
  53.236 -        }
  53.237 -        return getContinuousElementGetter(HAS_GET_ELEM, returnType, programPoint);
  53.238 -    }
  53.239 -
  53.240 -    @Override
  53.241 -    public MethodHandle getElementSetter(final Class<?> elementType) {
  53.242 -        return elementType == int.class || elementType == long.class ? getContinuousElementSetter(MH.asType(SET_ELEM, SET_ELEM.type().changeParameterType(2, elementType)), elementType) : null;
  53.243 -    }
  53.244 -
  53.245 -    @Override
  53.246 -    public int getInt(final int index) {
  53.247 -        return JSType.toInt32(array[index]);
  53.248 -    }
  53.249 -
  53.250 -    @Override
  53.251 -    public long getLong(final int index) {
  53.252 -        return array[index];
  53.253 -    }
  53.254 -
  53.255 -    @Override
  53.256 -    public long getLongOptimistic(final int index, final int programPoint) {
  53.257 -        return array[index];
  53.258 -    }
  53.259 -
  53.260 -    @Override
  53.261 -    public double getDouble(final int index) {
  53.262 -        return array[index];
  53.263 -    }
  53.264 -
  53.265 -    @Override
  53.266 -    public double getDoubleOptimistic(final int index, final int programPoint) {
  53.267 -        return array[index];
  53.268 -    }
  53.269 -
  53.270 -    @Override
  53.271 -    public Object getObject(final int index) {
  53.272 -        return array[index];
  53.273 -    }
  53.274 -
  53.275 -    @Override
  53.276 -    public boolean has(final int index) {
  53.277 -        return 0 <= index && index < length();
  53.278 -    }
  53.279 -
  53.280 -    @Override
  53.281 -    public ArrayData delete(final int index) {
  53.282 -        return new DeletedRangeArrayFilter(this, index, index);
  53.283 -    }
  53.284 -
  53.285 -    @Override
  53.286 -    public ArrayData delete(final long fromIndex, final long toIndex) {
  53.287 -        return new DeletedRangeArrayFilter(this, fromIndex, toIndex);
  53.288 -    }
  53.289 -
  53.290 -    @Override
  53.291 -    public Object pop() {
  53.292 -        final int len = (int)length();
  53.293 -        if (len == 0) {
  53.294 -            return ScriptRuntime.UNDEFINED;
  53.295 -        }
  53.296 -
  53.297 -        final int newLength = len - 1;
  53.298 -        final long elem = array[newLength];
  53.299 -        array[newLength] = 0;
  53.300 -        setLength(newLength);
  53.301 -
  53.302 -        return elem;
  53.303 -    }
  53.304 -
  53.305 -    @Override
  53.306 -    public ArrayData slice(final long from, final long to) {
  53.307 -        final long start     = from < 0 ? from + length() : from;
  53.308 -        final long newLength = to - start;
  53.309 -        return new LongArrayData(Arrays.copyOfRange(array, (int)from, (int)to), (int)newLength);
  53.310 -    }
  53.311 -
  53.312 -    @Override
  53.313 -    public ArrayData fastSplice(final int start, final int removed, final int added) throws UnsupportedOperationException {
  53.314 -        final long oldLength = length();
  53.315 -        final long newLength = oldLength - removed + added;
  53.316 -        if (newLength > SparseArrayData.MAX_DENSE_LENGTH && newLength > array.length) {
  53.317 -            throw new UnsupportedOperationException();
  53.318 -        }
  53.319 -        final ArrayData returnValue = removed == 0 ?
  53.320 -                EMPTY_ARRAY : new LongArrayData(Arrays.copyOfRange(array, start, start + removed), removed);
  53.321 -
  53.322 -        if (newLength != oldLength) {
  53.323 -            final long[] newArray;
  53.324 -
  53.325 -            if (newLength > array.length) {
  53.326 -                newArray = new long[ArrayData.nextSize((int)newLength)];
  53.327 -                System.arraycopy(array, 0, newArray, 0, start);
  53.328 -            } else {
  53.329 -                newArray = array;
  53.330 -            }
  53.331 -
  53.332 -            System.arraycopy(array, start + removed, newArray, start + added, (int)(oldLength - start - removed));
  53.333 -            array = newArray;
  53.334 -            setLength(newLength);
  53.335 -        }
  53.336 -
  53.337 -        return returnValue;
  53.338 -    }
  53.339 -
  53.340 -    @Override
  53.341 -    public long fastPush(final int arg) {
  53.342 -        return fastPush((long)arg);
  53.343 -    }
  53.344 -
  53.345 -    @Override
  53.346 -    public long fastPush(final long arg) {
  53.347 -        final int len = (int)length();
  53.348 -        if (len == array.length) {
  53.349 -            array = Arrays.copyOf(array, nextSize(len));
  53.350 -        }
  53.351 -        array[len] = arg;
  53.352 -        return increaseLength();
  53.353 -    }
  53.354 -
  53.355 -    @Override
  53.356 -    public long fastPopLong() {
  53.357 -        if (length() == 0) {
  53.358 -            throw new ClassCastException(); //undefined result
  53.359 -        }
  53.360 -        final int newLength = (int)decreaseLength();
  53.361 -        final long elem = array[newLength];
  53.362 -        array[newLength] = 0;
  53.363 -        return elem;
  53.364 -    }
  53.365 -
  53.366 -    @Override
  53.367 -    public double fastPopDouble() {
  53.368 -        return fastPopLong();
  53.369 -   }
  53.370 -
  53.371 -    @Override
  53.372 -    public Object fastPopObject() {
  53.373 -        return fastPopLong();
  53.374 -    }
  53.375 -
  53.376 -    @Override
  53.377 -    public ContinuousArrayData fastConcat(final ContinuousArrayData otherData) {
  53.378 -        final int   otherLength = (int)otherData.length();
  53.379 -        final int   thisLength  = (int)length();
  53.380 -        assert otherLength > 0 && thisLength > 0;
  53.381 -
  53.382 -        final long[] otherArray  = ((LongArrayData)otherData).array;
  53.383 -        final int    newLength   = otherLength + thisLength;
  53.384 -        final long[] newArray   = new long[ArrayData.alignUp(newLength)];
  53.385 -
  53.386 -        System.arraycopy(array, 0, newArray, 0, thisLength);
  53.387 -        System.arraycopy(otherArray, 0, newArray, thisLength, otherLength);
  53.388 -
  53.389 -        return new LongArrayData(newArray, newLength);
  53.390 -    }
  53.391 -
  53.392 -    @Override
  53.393 -    public String toString() {
  53.394 -        assert length() <= array.length : length() + " > " + array.length;
  53.395 -
  53.396 -        final StringBuilder sb = new StringBuilder(getClass().getSimpleName()).
  53.397 -                append(": [");
  53.398 -        final int len = (int)length();
  53.399 -        for (int i = 0; i < len; i++) {
  53.400 -            sb.append(array[i]).append('L'); //make sure L suffix is on elements, to discriminate this from IntArrayData.toString()
  53.401 -            if (i + 1 < len) {
  53.402 -                sb.append(", ");
  53.403 -            }
  53.404 -        }
  53.405 -        sb.append(']');
  53.406 -
  53.407 -        return sb.toString();
  53.408 -    }
  53.409 -}
    54.1 --- a/src/jdk/nashorn/internal/runtime/arrays/NonExtensibleArrayFilter.java	Tue Jan 19 18:56:23 2016 +0100
    54.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/NonExtensibleArrayFilter.java	Fri Jan 22 16:18:19 2016 +0100
    54.3 @@ -51,14 +51,6 @@
    54.4      }
    54.5  
    54.6      @Override
    54.7 -    public ArrayData set(final int index, final long value, final boolean strict) {
    54.8 -        if (has(index)) {
    54.9 -            return underlying.set(index, value, strict);
   54.10 -        }
   54.11 -        return extensionCheck(strict, index);
   54.12 -    }
   54.13 -
   54.14 -    @Override
   54.15      public ArrayData set(final int index, final double value, final boolean strict) {
   54.16          if (has(index)) {
   54.17              return underlying.set(index, value, strict);
    55.1 --- a/src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java	Tue Jan 19 18:56:23 2016 +0100
    55.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java	Fri Jan 22 16:18:19 2016 +0100
    55.3 @@ -179,13 +179,6 @@
    55.4      }
    55.5  
    55.6      @Override
    55.7 -    public ArrayData set(final int index, final long value, final boolean strict) {
    55.8 -        array[index] = value;
    55.9 -        setLength(Math.max(index + 1, length()));
   55.10 -        return this;
   55.11 -    }
   55.12 -
   55.13 -    @Override
   55.14      public ArrayData set(final int index, final double value, final boolean strict) {
   55.15          array[index] = value;
   55.16          setLength(Math.max(index + 1, length()));
   55.17 @@ -214,7 +207,7 @@
   55.18  
   55.19      @Override
   55.20      public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) {
   55.21 -        if (returnType == int.class || returnType == long.class) {
   55.22 +        if (returnType == int.class) {
   55.23              return null;
   55.24          }
   55.25          return getContinuousElementGetter(HAS_GET_ELEM, returnType, programPoint);
   55.26 @@ -231,11 +224,6 @@
   55.27      }
   55.28  
   55.29      @Override
   55.30 -    public long getLong(final int index) {
   55.31 -        return (long)array[index];
   55.32 -    }
   55.33 -
   55.34 -    @Override
   55.35      public double getDouble(final int index) {
   55.36          return array[index];
   55.37      }
    56.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java	Tue Jan 19 18:56:23 2016 +0100
    56.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java	Fri Jan 22 16:18:19 2016 +0100
    56.3 @@ -150,13 +150,6 @@
    56.4      }
    56.5  
    56.6      @Override
    56.7 -    public ArrayData set(final int index, final long value, final boolean strict) {
    56.8 -        array[index] = value;
    56.9 -        setLength(Math.max(index + 1, length()));
   56.10 -        return this;
   56.11 -    }
   56.12 -
   56.13 -    @Override
   56.14      public ArrayData set(final int index, final double value, final boolean strict) {
   56.15          array[index] = value;
   56.16          setLength(Math.max(index + 1, length()));
   56.17 @@ -216,11 +209,6 @@
   56.18      }
   56.19  
   56.20      @Override
   56.21 -    public long getLong(final int index) {
   56.22 -        return JSType.toLong(array[index]);
   56.23 -    }
   56.24 -
   56.25 -    @Override
   56.26      public double getDouble(final int index) {
   56.27          return JSType.toNumber(array[index]);
   56.28      }
    57.1 --- a/src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java	Tue Jan 19 18:56:23 2016 +0100
    57.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java	Fri Jan 22 16:18:19 2016 +0100
    57.3 @@ -195,21 +195,6 @@
    57.4      }
    57.5  
    57.6      @Override
    57.7 -    public ArrayData set(final int index, final long value, final boolean strict) {
    57.8 -        if (index >= 0 && index < maxDenseLength) {
    57.9 -            final long oldLength = underlying.length();
   57.10 -            ensure(index);
   57.11 -            underlying = underlying.set(index, value, strict).safeDelete(oldLength, index - 1, strict);
   57.12 -            setLength(Math.max(underlying.length(), length()));
   57.13 -        } else {
   57.14 -            final Long longIndex = indexToKey(index);
   57.15 -            sparseMap.put(longIndex, value);
   57.16 -            setLength(Math.max(longIndex + 1, length()));
   57.17 -        }
   57.18 -        return this;
   57.19 -    }
   57.20 -
   57.21 -    @Override
   57.22      public ArrayData set(final int index, final double value, final boolean strict) {
   57.23          if (index >= 0 && index < maxDenseLength) {
   57.24              final long oldLength = underlying.length();
   57.25 @@ -258,22 +243,6 @@
   57.26      }
   57.27  
   57.28      @Override
   57.29 -    public long getLong(final int index) {
   57.30 -        if (index >= 0 && index < maxDenseLength) {
   57.31 -            return underlying.getLong(index);
   57.32 -        }
   57.33 -        return JSType.toLong(sparseMap.get(indexToKey(index)));
   57.34 -    }
   57.35 -
   57.36 -    @Override
   57.37 -    public long getLongOptimistic(final int index, final int programPoint) {
   57.38 -        if (index >= 0 && index < maxDenseLength) {
   57.39 -            return underlying.getLongOptimistic(index, programPoint);
   57.40 -        }
   57.41 -        return JSType.toLongOptimistic(sparseMap.get(indexToKey(index)), programPoint);
   57.42 -    }
   57.43 -
   57.44 -    @Override
   57.45      public double getDouble(final int index) {
   57.46          if (index >= 0 && index < maxDenseLength) {
   57.47              return underlying.getDouble(index);
    58.1 --- a/src/jdk/nashorn/internal/runtime/arrays/UndefinedArrayFilter.java	Tue Jan 19 18:56:23 2016 +0100
    58.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/UndefinedArrayFilter.java	Fri Jan 22 16:18:19 2016 +0100
    58.3 @@ -128,13 +128,6 @@
    58.4      }
    58.5  
    58.6      @Override
    58.7 -    public ArrayData set(final int index, final long value, final boolean strict) {
    58.8 -        undefined.clear(index);
    58.9 -
   58.10 -        return super.set(index, value, strict);
   58.11 -    }
   58.12 -
   58.13 -    @Override
   58.14      public ArrayData set(final int index, final double value, final boolean strict) {
   58.15          undefined.clear(index);
   58.16  
   58.17 @@ -160,24 +153,6 @@
   58.18      }
   58.19  
   58.20      @Override
   58.21 -    public long getLong(final int index) {
   58.22 -        if (undefined.isSet(index)) {
   58.23 -            return 0L;
   58.24 -        }
   58.25 -
   58.26 -        return super.getLong(index);
   58.27 -    }
   58.28 -
   58.29 -    @Override
   58.30 -    public long getLongOptimistic(final int index, final int programPoint) {
   58.31 -        if (undefined.isSet(index)) {
   58.32 -            throw new UnwarrantedOptimismException(UNDEFINED, programPoint);
   58.33 -        }
   58.34 -
   58.35 -        return super.getLongOptimistic(index, programPoint);
   58.36 -    }
   58.37 -
   58.38 -    @Override
   58.39      public double getDouble(final int index) {
   58.40          if (undefined.isSet(index)) {
   58.41              return Double.NaN;
    59.1 --- a/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java	Tue Jan 19 18:56:23 2016 +0100
    59.2 +++ b/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java	Fri Jan 22 16:18:19 2016 +0100
    59.3 @@ -215,7 +215,7 @@
    59.4       *
    59.5       * @return callsite for a math intrinsic node
    59.6       */
    59.7 -    public static CallSite mathBootstrap(final MethodHandles.Lookup lookup, final String name, final MethodType type, final int programPoint) {
    59.8 +    public static CallSite mathBootstrap(final Lookup lookup, final String name, final MethodType type, final int programPoint) {
    59.9          final MethodHandle mh;
   59.10          switch (name) {
   59.11          case "iadd":
   59.12 @@ -236,24 +236,6 @@
   59.13          case "ineg":
   59.14              mh = JSType.NEGATE_EXACT.methodHandle();
   59.15              break;
   59.16 -        case "ladd":
   59.17 -            mh = JSType.ADD_EXACT_LONG.methodHandle();
   59.18 -            break;
   59.19 -        case "lsub":
   59.20 -            mh = JSType.SUB_EXACT_LONG.methodHandle();
   59.21 -            break;
   59.22 -        case "lmul":
   59.23 -            mh = JSType.MUL_EXACT_LONG.methodHandle();
   59.24 -            break;
   59.25 -        case "ldiv":
   59.26 -            mh = JSType.DIV_EXACT_LONG.methodHandle();
   59.27 -            break;
   59.28 -        case "lrem":
   59.29 -            mh = JSType.REM_EXACT_LONG.methodHandle();
   59.30 -            break;
   59.31 -        case "lneg":
   59.32 -            mh = JSType.NEGATE_EXACT_LONG.methodHandle();
   59.33 -            break;
   59.34          default:
   59.35              throw new AssertionError("unsupported math intrinsic");
   59.36          }
    60.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java	Tue Jan 19 18:56:23 2016 +0100
    60.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java	Fri Jan 22 16:18:19 2016 +0100
    60.3 @@ -141,8 +141,9 @@
    60.4      }
    60.5  
    60.6      /**
    60.7 -     * Main part of the implementation of {@link GuardingTypeConverterFactory#convertToType(Class, Class)} that doesn't
    60.8 -     * care about adapting the method signature; that's done by the invoking method. Returns conversion from Object to String/number/boolean (JS primitive types).
    60.9 +     * Main part of the implementation of {@link GuardingTypeConverterFactory#convertToType} that doesn't
   60.10 +     * care about adapting the method signature; that's done by the invoking method. Returns conversion
   60.11 +     * from Object to String/number/boolean (JS primitive types).
   60.12       * @param sourceType the source type
   60.13       * @param targetType the target type
   60.14       * @return a guarded invocation that converts from the source type to the target type.
    61.1 --- a/test/script/basic/JDK-8062799.js	Tue Jan 19 18:56:23 2016 +0100
    61.2 +++ b/test/script/basic/JDK-8062799.js	Fri Jan 22 16:18:19 2016 +0100
    61.3 @@ -33,67 +33,46 @@
    61.4      
    61.5      var b = true;
    61.6      var i = 1;
    61.7 -    var l = 4294967296;
    61.8      var d = 2.1;
    61.9      var o = "foo";
   61.10  
   61.11      print(inspect(b || b, "b || b"));
   61.12      print(inspect(b || i, "b || i"));
   61.13 -    print(inspect(b || l, "b || l"));
   61.14      print(inspect(b || d, "b || d"));
   61.15      print(inspect(b || o, "b || o"));
   61.16          
   61.17      print(inspect(i || b, "i || b"));
   61.18      print(inspect(i || i, "i || i"));
   61.19 -    print(inspect(i || l, "i || l"));
   61.20      print(inspect(i || d, "i || d"));
   61.21      print(inspect(i || o, "i || o"));
   61.22  
   61.23 -    print(inspect(l || b, "l || b"));
   61.24 -    print(inspect(l || i, "l || i"));
   61.25 -    print(inspect(l || l, "l || l"));
   61.26 -    print(inspect(l || d, "l || d"));
   61.27 -    print(inspect(l || o, "l || o"));
   61.28 -
   61.29      print(inspect(d || b, "d || b"));
   61.30      print(inspect(d || i, "d || i"));
   61.31 -    print(inspect(d || l, "d || l"));
   61.32      print(inspect(d || d, "d || d"));
   61.33      print(inspect(d || o, "d || o"));
   61.34  
   61.35      print(inspect(o || b, "o || b"));
   61.36      print(inspect(o || i, "o || i"));
   61.37 -    print(inspect(o || l, "o || l"));
   61.38      print(inspect(o || d, "o || d"));
   61.39      print(inspect(o || o, "o || o"));
   61.40  
   61.41      print(inspect(b && b, "b && b"));
   61.42      print(inspect(b && i, "b && i"));
   61.43 -    print(inspect(b && l, "b && l"));
   61.44      print(inspect(b && d, "b && d"));
   61.45      print(inspect(b && o, "b && o"));
   61.46          
   61.47      print(inspect(i && b, "i && b"));
   61.48      print(inspect(i && i, "i && i"));
   61.49 -    print(inspect(i && l, "i && l"));
   61.50      print(inspect(i && d, "i && d"));
   61.51      print(inspect(i && o, "i && o"));
   61.52  
   61.53 -    print(inspect(l && b, "l && b"));
   61.54 -    print(inspect(l && i, "l && i"));
   61.55 -    print(inspect(l && l, "l && l"));
   61.56 -    print(inspect(l && d, "l && d"));
   61.57 -    print(inspect(l && o, "l && o"));
   61.58 -
   61.59      print(inspect(d && b, "d && b"));
   61.60      print(inspect(d && i, "d && i"));
   61.61 -    print(inspect(d && l, "d && l"));
   61.62      print(inspect(d && d, "d && d"));
   61.63      print(inspect(d && o, "d && o"));
   61.64  
   61.65      print(inspect(o && b, "o && b"));
   61.66      print(inspect(o && i, "o && i"));
   61.67 -    print(inspect(o && l, "o && l"));
   61.68      print(inspect(o && d, "o && d"));
   61.69      print(inspect(o && o, "o && o"));
   61.70  })();
    62.1 --- a/test/script/basic/JDK-8062799.js.EXPECTED	Tue Jan 19 18:56:23 2016 +0100
    62.2 +++ b/test/script/basic/JDK-8062799.js.EXPECTED	Fri Jan 22 16:18:19 2016 +0100
    62.3 @@ -1,50 +1,32 @@
    62.4  b || b: boolean
    62.5  b || i: boolean
    62.6 -b || l: boolean
    62.7  b || d: boolean
    62.8  b || o: boolean
    62.9  i || b: int
   62.10  i || i: int
   62.11 -i || l: long
   62.12  i || d: double
   62.13  i || o: int
   62.14 -l || b: long
   62.15 -l || i: long
   62.16 -l || l: long
   62.17 -l || d: double
   62.18 -l || o: long
   62.19  d || b: double
   62.20  d || i: double
   62.21 -d || l: double
   62.22  d || d: double
   62.23  d || o: double
   62.24  o || b: object
   62.25  o || i: object
   62.26 -o || l: object
   62.27  o || d: object
   62.28  o || o: object
   62.29  b && b: boolean
   62.30  b && i: int
   62.31 -b && l: long
   62.32  b && d: double
   62.33  b && o: object
   62.34  i && b: boolean
   62.35  i && i: int
   62.36 -i && l: long
   62.37  i && d: double
   62.38  i && o: object
   62.39 -l && b: boolean
   62.40 -l && i: long
   62.41 -l && l: long
   62.42 -l && d: double
   62.43 -l && o: object
   62.44  d && b: boolean
   62.45  d && i: double
   62.46 -d && l: double
   62.47  d && d: double
   62.48  d && o: object
   62.49  o && b: boolean
   62.50  o && i: int
   62.51 -o && l: long
   62.52  o && d: double
   62.53  o && o: object
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/test/script/basic/JDK-8144020.js	Fri Jan 22 16:18:19 2016 +0100
    63.3 @@ -0,0 +1,126 @@
    63.4 +/*
    63.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
    63.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    63.7 + * 
    63.8 + * This code is free software; you can redistribute it and/or modify it
    63.9 + * under the terms of the GNU General Public License version 2 only, as
   63.10 + * published by the Free Software Foundation.
   63.11 + * 
   63.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   63.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   63.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   63.15 + * version 2 for more details (a copy is included in the LICENSE file that
   63.16 + * accompanied this code).
   63.17 + * 
   63.18 + * You should have received a copy of the GNU General Public License version
   63.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   63.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   63.21 + * 
   63.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   63.23 + * or visit www.oracle.com if you need additional information or have any
   63.24 + * questions.
   63.25 + */
   63.26 +
   63.27 +/**
   63.28 + * JDK-8144020: Remove long as an internal numeric type
   63.29 + *
   63.30 + * @test
   63.31 + * @run
   63.32 + */
   63.33 +
   63.34 +var LongProvider = Java.type("jdk.nashorn.test.models.LongProvider");
   63.35 +var Long = Java.type("java.lang.Long");
   63.36 +var LongClass = Long.class;
   63.37 +var Integer = Java.type("java.lang.Integer");
   63.38 +var Double = Java.type("java.lang.Double");
   63.39 +
   63.40 +var INT      = "3";
   63.41 +var DOUBLE   = "5.5";
   63.42 +var MAX_LONG = "9223372036854775807";
   63.43 +var MIN_LONG = "-9223372036854775808";
   63.44 +var BIG_LONG = "281474976710655"; // can be represented as double
   63.45 +var NEG_LONG = "-281474976710656"; // can be represented as double
   63.46 +var SMALL_LONG = "13";
   63.47 +
   63.48 +// Make sure we can pass longs from and to Java without losing precision
   63.49 +LongProvider.checkLong(LongProvider.getLong(MAX_LONG), MAX_LONG);
   63.50 +LongProvider.checkLong(LongProvider.getLong(MIN_LONG), MIN_LONG);
   63.51 +LongProvider.checkLong(LongProvider.getLong(BIG_LONG), BIG_LONG);
   63.52 +LongProvider.checkLong(LongProvider.getLong(NEG_LONG), NEG_LONG);
   63.53 +LongProvider.checkLong(LongProvider.getLong(SMALL_LONG), SMALL_LONG);
   63.54 +
   63.55 +// a polymorphic function that can return various number types
   63.56 +function getNumber(str) {
   63.57 +    switch (str) {
   63.58 +        case INT:    return +INT;
   63.59 +        case DOUBLE: return +DOUBLE;
   63.60 +        default:     return Long.parseLong(str);
   63.61 +    }
   63.62 +}
   63.63 +
   63.64 +function compareValue(n, str) {
   63.65 +    switch (str) {
   63.66 +        case INT:    return Integer.compare(n, Integer.parseInt(str) == 0);
   63.67 +        case DOUBLE: return Double.compare(n, Double.parseDouble(str) == 0);
   63.68 +        default:     return Long.compare(n, Long.parseLong(str) == 0);
   63.69 +    }
   63.70 +}
   63.71 +
   63.72 +// Call a a function with a sequence of values. The purpose of this is that we can handle
   63.73 +// longs without losing precision in the presence of optimistic deoptimization, cached callsites, etc.
   63.74 +function testSequence(fn, values) {
   63.75 +    for (var i in values) {
   63.76 +        fn(values[i]);
   63.77 +    }
   63.78 +}
   63.79 +
   63.80 +// We need to use "fresh" (unlinked and un-deoptimized) functions for each of the test runs.
   63.81 +testSequence(function(str) {
   63.82 +    var n = getNumber(str);
   63.83 +    Assert.assertTrue(compareValue(n, str));
   63.84 +}, [INT, BIG_LONG, MIN_LONG]);
   63.85 +
   63.86 +testSequence(function(str) {
   63.87 +    var n = getNumber(str);
   63.88 +    Assert.assertTrue(compareValue(n, str));
   63.89 +}, [INT, MAX_LONG]);
   63.90 +
   63.91 +testSequence(function(str) {
   63.92 +    var n = getNumber(str);
   63.93 +    Assert.assertTrue(compareValue(n, str));
   63.94 +}, [INT, DOUBLE, NEG_LONG]);
   63.95 +
   63.96 +testSequence(function(str) {
   63.97 +    var n = getNumber(str);
   63.98 +    Assert.assertTrue(compareValue(n, str));
   63.99 +}, [DOUBLE, MAX_LONG]);
  63.100 +
  63.101 +testSequence(function(str) {
  63.102 +    var n = getNumber(str);
  63.103 +    Assert.assertTrue(compareValue(n, str));
  63.104 +}, [DOUBLE, SMALL_LONG, MAX_LONG]);
  63.105 +
  63.106 +testSequence(function(str) {
  63.107 +    var n = getNumber(str);
  63.108 +    Assert.assertTrue(compareValue(n, str));
  63.109 +}, [INT, DOUBLE, NEG_LONG, MAX_LONG]);
  63.110 +
  63.111 +testSequence(function(str) {
  63.112 +    var n = getNumber(str);
  63.113 +    Assert.assertTrue(compareValue(n, str));
  63.114 +}, [DOUBLE, MAX_LONG, DOUBLE, INT]);
  63.115 +
  63.116 +// Make sure long arrays make it through Java.from and Java.to without losing precision
  63.117 +var longArrayType = Java.type("long[]");
  63.118 +for (var i = 0; i < 3; i++) {
  63.119 +    LongProvider.checkLongArray(Java.to(Java.from(LongProvider.getLongArray(i)), longArrayType), i);
  63.120 +}
  63.121 +
  63.122 +l = Long.parseLong(BIG_LONG);
  63.123 +Assert.assertTrue(l >>> 8 === 0xffffff);
  63.124 +Assert.assertTrue(l << 8 === -0x100);
  63.125 +Assert.assertTrue(l + 1 === 0x1000000000000);
  63.126 +Assert.assertTrue(l - 1 === 0xfffffffffffe);
  63.127 +
  63.128 +Assert.assertEquals(LongProvider.getLong(MAX_LONG).getClass(), LongClass);
  63.129 +Assert.assertEquals(LongProvider.getLong(MIN_LONG).getClass(), LongClass);
    64.1 --- a/test/script/basic/JDK-8144131.js	Tue Jan 19 18:56:23 2016 +0100
    64.2 +++ b/test/script/basic/JDK-8144131.js	Fri Jan 22 16:18:19 2016 +0100
    64.3 @@ -30,12 +30,9 @@
    64.4  
    64.5  var doubleArray = [97912312397.234, -182374983434.56];
    64.6  var doubleArrayResults = [-871935411, -1986357002];
    64.7 -var longArray = [0x7fffffff8c102ebc, -0x7fffffffe9dfec18];
    64.8 -var longArrayResults = [-1945096192, 371201024];
    64.9  
   64.10 -// Make sure arrays use double and long array data
   64.11 +// Make sure array uses double array data
   64.12  Assert.assertEquals(doubleArray[0].getClass(), java.lang.Double.class);
   64.13 -Assert.assertEquals(longArray[0].getClass(), java.lang.Long.class);
   64.14  
   64.15  function testBinaryOp(array, index, expected) {
   64.16      Assert.assertEquals(array[index] & 0xffffffff, expected);
   64.17 @@ -44,7 +41,4 @@
   64.18  for (var i = 0; i < doubleArray.length; i++) {
   64.19      testBinaryOp(doubleArray, i, doubleArrayResults[i]);
   64.20  }
   64.21 -for (var i = 0; i < longArray.length; i++) {
   64.22 -    testBinaryOp(longArray, i, longArrayResults[i]);
   64.23 -}
   64.24  
    65.1 --- a/test/script/nosecurity/JDK-8067215.js	Tue Jan 19 18:56:23 2016 +0100
    65.2 +++ b/test/script/nosecurity/JDK-8067215.js	Fri Jan 22 16:18:19 2016 +0100
    65.3 @@ -32,7 +32,6 @@
    65.4  
    65.5  var intType    = Java.type("int");
    65.6  var doubleType = Java.type("double");
    65.7 -var longType   = Java.type("long");
    65.8  var objectType = Java.type("java.lang.Object");
    65.9  
   65.10  var Context = Java.type("jdk.nashorn.internal.runtime.Context");
   65.11 @@ -58,7 +57,6 @@
   65.12          }
   65.13          if (prop.getType() != getExpectedType(obj[key])) {
   65.14              throw new Error("Wrong property type: " + prop.getType() + " // " + getExpectedType(obj[key]));
   65.15 -
   65.16          }
   65.17      }
   65.18  }
   65.19 @@ -67,14 +65,8 @@
   65.20      if (!dualFields) {
   65.21          return objectType.class;
   65.22      }
   65.23 -    if (JSType.isRepresentableAsInt(value)) {
   65.24 -        return intType.class;
   65.25 -    }
   65.26 -    if (JSType.isRepresentableAsLong(value)) {
   65.27 -        return longType.class;
   65.28 -    }
   65.29 -    if (JSType.isNumber(value)) {
   65.30 -        return doubleType.class;
   65.31 +    if (typeof value === "number") {
   65.32 +        return JSType.isRepresentableAsInt(value) ? intType.class : doubleType.class;
   65.33      }
   65.34      return objectType.class;
   65.35  }
    66.1 --- a/test/src/jdk/nashorn/api/javaaccess/test/NumberAccessTest.java	Tue Jan 19 18:56:23 2016 +0100
    66.2 +++ b/test/src/jdk/nashorn/api/javaaccess/test/NumberAccessTest.java	Fri Jan 22 16:18:19 2016 +0100
    66.3 @@ -143,7 +143,7 @@
    66.4      @Test
    66.5      public void accessStaticFinalFieldLong() throws ScriptException {
    66.6          e.eval("var psf_long = SharedObject.publicStaticFinalLong;");
    66.7 -        assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long"));
    66.8 +        assertEquals(SharedObject.publicStaticFinalLong, ((Number) e.get("psf_long")).longValue());
    66.9          e.eval("SharedObject.publicStaticFinalLong = 120;");
   66.10          assertEquals(8333333333333L, SharedObject.publicStaticFinalLong);
   66.11      }
    67.1 --- a/test/src/jdk/nashorn/api/javaaccess/test/NumberBoxingTest.java	Tue Jan 19 18:56:23 2016 +0100
    67.2 +++ b/test/src/jdk/nashorn/api/javaaccess/test/NumberBoxingTest.java	Fri Jan 22 16:18:19 2016 +0100
    67.3 @@ -70,7 +70,7 @@
    67.4      @Test
    67.5      public void accessFieldLongBoxing() throws ScriptException {
    67.6          e.eval("var p_long = o.publicLongBox;");
    67.7 -        assertEquals(o.publicLongBox, e.get("p_long"));
    67.8 +        assertEquals(o.publicLongBox.longValue(), ((Number) e.get("p_long")).longValue());
    67.9          e.eval("o.publicLongBox = 12;");
   67.10          assertEquals(Long.valueOf(12), o.publicLongBox);
   67.11      }
   67.12 @@ -78,7 +78,7 @@
   67.13      @Test
   67.14      public void accessStaticFieldLongBoxing() throws ScriptException {
   67.15          e.eval("var ps_long = SharedObject.publicStaticLongBox;");
   67.16 -        assertEquals(SharedObject.publicStaticLongBox, e.get("ps_long"));
   67.17 +        assertEquals(SharedObject.publicStaticLongBox.longValue(), ((Number) e.get("ps_long")).longValue());
   67.18          e.eval("SharedObject.publicStaticLongBox = 120;");
   67.19          assertEquals(120L, SharedObject.publicStaticLongBox.longValue());
   67.20      }
   67.21 @@ -86,7 +86,7 @@
   67.22      @Test
   67.23      public void accessFinalFieldLongBoxing() throws ScriptException {
   67.24          e.eval("var pf_long = o.publicFinalLongBox;");
   67.25 -        assertEquals(o.publicFinalLongBox, e.get("pf_long"));
   67.26 +        assertEquals(o.publicFinalLongBox.longValue(), ((Number) e.get("pf_long")).longValue());
   67.27          e.eval("o.publicFinalLongBox = 120;");
   67.28          assertEquals(Long.valueOf(9377333334L), o.publicFinalLongBox);
   67.29      }
   67.30 @@ -94,7 +94,7 @@
   67.31      @Test
   67.32      public void accessStaticFinalFieldLongBoxing() throws ScriptException {
   67.33          e.eval("var psf_long = SharedObject.publicStaticFinalLong;");
   67.34 -        assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long"));
   67.35 +        assertEquals(SharedObject.publicStaticFinalLong, ((Number) e.get("psf_long")).longValue());
   67.36          e.eval("SharedObject.publicStaticFinalLong = 120;");
   67.37          assertEquals(8333333333333L, SharedObject.publicStaticFinalLong);
   67.38      }
    68.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.2 +++ b/test/src/jdk/nashorn/test/models/LongProvider.java	Fri Jan 22 16:18:19 2016 +0100
    68.3 @@ -0,0 +1,63 @@
    68.4 +/*
    68.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
    68.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    68.7 + *
    68.8 + * This code is free software; you can redistribute it and/or modify it
    68.9 + * under the terms of the GNU General Public License version 2 only, as
   68.10 + * published by the Free Software Foundation.  Oracle designates this
   68.11 + * particular file as subject to the "Classpath" exception as provided
   68.12 + * by Oracle in the LICENSE file that accompanied this code.
   68.13 + *
   68.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   68.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   68.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   68.17 + * version 2 for more details (a copy is included in the LICENSE file that
   68.18 + * accompanied this code).
   68.19 + *
   68.20 + * You should have received a copy of the GNU General Public License version
   68.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   68.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   68.23 + *
   68.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   68.25 + * or visit www.oracle.com if you need additional information or have any
   68.26 + * questions.
   68.27 + */
   68.28 +
   68.29 +package jdk.nashorn.test.models;
   68.30 +
   68.31 +import java.util.Arrays;
   68.32 +
   68.33 +/**
   68.34 + * A class that returns and receives longs.
   68.35 + */
   68.36 +@SuppressWarnings("javadoc")
   68.37 +public class LongProvider {
   68.38 +
   68.39 +    final static long[][] arrays = {
   68.40 +            {1L, 2L, 3L},
   68.41 +            {1L, 1L << 30, 1L << 50, 4L},
   68.42 +            {1L, Long.MAX_VALUE, Long.MIN_VALUE, 4L}
   68.43 +    };
   68.44 +
   68.45 +    public static long getLong(final String str) {
   68.46 +        final long l = Long.parseLong(str);
   68.47 +        checkLong(l, str);
   68.48 +        return l;
   68.49 +    }
   68.50 +
   68.51 +    public static long[] getLongArray(final int n) {
   68.52 +        return arrays[n];
   68.53 +    }
   68.54 +
   68.55 +    public static void checkLong(final long value, final String str) {
   68.56 +        if (!Long.toString(value).equals(str)) {
   68.57 +            throw new RuntimeException("Wrong value. Expected " + str + ", got " + value);
   68.58 +        }
   68.59 +    }
   68.60 +
   68.61 +    public static void checkLongArray(final long[] array, final int n) {
   68.62 +        if (!Arrays.equals(array, arrays[n])) {
   68.63 +            throw new RuntimeException("Arrays don't match: " + Arrays.toString(array) + ", " + Arrays.toString(arrays[n]));
   68.64 +        }
   68.65 +    }
   68.66 +}

mercurial