Fri, 05 Feb 2016 23:32:52 -0800
Merge
.hgtags | file | annotate | diff | comparison | revisions | |
src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Tue Jan 26 11:36:10 2016 -0800 1.2 +++ b/.hgtags Fri Feb 05 23:32:52 2016 -0800 1.3 @@ -521,8 +521,26 @@ 1.4 e48d06eeff82bea512cea44fa14d59b88067ef83 jdk8u72-b14 1.5 769b21d1b85cfb57c11c89bbc8f185f9e520df66 jdk8u72-b15 1.6 c90794ad4d12eeeae5d9bbfce65fa0043a313548 jdk8u72-b31 1.7 +e9b46178f2e35d9ed2cd5b2f7279cf5e4e954222 jdk8u73-b00 1.8 +eeb5306edb7a0140117fe346782cce19c4c562a7 jdk8u73-b01 1.9 +955689d050b9f3f61b90ca063fe13704a82f5394 jdk8u73-b02 1.10 +2a36c3c61f905c5b389ae1d62f446e57f96be3a2 jdk8u74-b00 1.11 +ae6c74c1197afcbd83d393aa6f96221d759022a2 jdk8u74-b01 1.12 +3107cf87696f0516d6f5fa7cdc416069e2800d02 jdk8u74-b02 1.13 +4608bbcc94f73059680acd0f486744ff26485ee9 jdk8u74-b31 1.14 +c90794ad4d12eeeae5d9bbfce65fa0043a313548 jdk8u72-b31 1.15 c7eddafb2ee2cc9d62f20c4d821ccac03bd4617d jdk8u75-b00 1.16 69fa156c1ebe6a8d6587147967e8e27f6de37d99 jdk8u75-b01 1.17 9cce1ba325c4bd8e922380c911d1a9ace79d6717 jdk8u75-b02 1.18 541de42b57098a5009055cc92f1139473e32f19d jdk8u75-b03 1.19 +16d657d6cb22e832139a1cbc2ec23a5cf9db8985 jdk8u75-b04 1.20 +dfa12474455fa6f4c48a6dee986c24db257161ad jdk8u75-b05 1.21 +1f85973e9533f7c9b1bae1e00b76a2184c5eed4c jdk8u75-b06 1.22 +9ff5c21813330147bf08389b3992534780c93247 jdk8u76-b00 1.23 +b7bbed8b05dd50c27050c7e10e20d25329dcd32b jdk8u76-b01 1.24 +4c1aa7b8c43c6fd38f9c13a6df2264378dd6a873 jdk8u76-b02 1.25 +07db58f99673790d5139e8497552ac331e0824f5 jdk8u76-b03 1.26 +068c584278637dae589e7d648c265149e80c8a24 jdk8u76-b04 1.27 +b31ba749a22e9dce7637e709122e1138b01e8b66 jdk8u76-b05 1.28 +0d5cfd0fc8192fd4569300135f81f5f2b7a7bd90 jdk8u76-b06 1.29 16d657d6cb22e832139a1cbc2ec23a5cf9db8985 jdk8u81-b00
2.1 --- a/make/build.xml Tue Jan 26 11:36:10 2016 -0800 2.2 +++ b/make/build.xml Fri Feb 05 23:32:52 2016 -0800 2.3 @@ -356,6 +356,13 @@ 2.4 permission java.util.PropertyPermission "nashorn.test.*", "read"; 2.5 }; 2.6 2.7 +grant codeBase "file:/${basedir}/test/script/basic/apply_to_call/*" { 2.8 + permission java.io.FilePermission "${basedir}/test/script/-", "read"; 2.9 + permission java.io.FilePermission "$${user.dir}", "read"; 2.10 + permission java.util.PropertyPermission "user.dir", "read"; 2.11 + permission java.util.PropertyPermission "nashorn.test.*", "read"; 2.12 +}; 2.13 + 2.14 grant codeBase "file:/${basedir}/test/script/basic/parser/*" { 2.15 permission java.io.FilePermission "${basedir}/test/script/-", "read"; 2.16 permission java.io.FilePermission "$${user.dir}", "read";
3.1 --- a/src/jdk/internal/dynalink/beans/AbstractJavaLinker.java Tue Jan 26 11:36:10 2016 -0800 3.2 +++ b/src/jdk/internal/dynalink/beans/AbstractJavaLinker.java Fri Feb 05 23:32:52 2016 -0800 3.3 @@ -782,7 +782,7 @@ 3.4 */ 3.5 @SuppressWarnings("unused") 3.6 private Object getPropertyGetterHandle(final Object id) { 3.7 - return propertyGetters.get(id); 3.8 + return propertyGetters.get(String.valueOf(id)); 3.9 } 3.10 3.11 // Type is MethodHandle(BeanLinker, MethodType, LinkerServices, Object, String, Object), of which the two "Object"
4.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java Tue Jan 26 11:36:10 2016 -0800 4.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java Fri Feb 05 23:32:52 2016 -0800 4.3 @@ -188,8 +188,6 @@ 4.4 4.5 private static final Call ENSURE_INT = CompilerConstants.staticCallNoLookup(OptimisticReturnFilters.class, 4.6 "ensureInt", int.class, Object.class, int.class); 4.7 - private static final Call ENSURE_LONG = CompilerConstants.staticCallNoLookup(OptimisticReturnFilters.class, 4.8 - "ensureLong", long.class, Object.class, int.class); 4.9 private static final Call ENSURE_NUMBER = CompilerConstants.staticCallNoLookup(OptimisticReturnFilters.class, 4.10 "ensureNumber", double.class, Object.class, int.class); 4.11 4.12 @@ -1720,7 +1718,7 @@ 4.13 enterStatement(expressionStatement); 4.14 4.15 loadAndDiscard(expressionStatement.getExpression()); 4.16 - assert method.getStackSize() == 0; 4.17 + assert method.getStackSize() == 0 : "stack not empty in " + expressionStatement; 4.18 4.19 return false; 4.20 } 4.21 @@ -2235,7 +2233,7 @@ 4.22 * @param arrayType the type of the array, e.g. ARRAY_NUMBER or ARRAY_OBJECT 4.23 */ 4.24 private void loadArray(final ArrayLiteralNode arrayLiteralNode, final ArrayType arrayType) { 4.25 - assert arrayType == Type.INT_ARRAY || arrayType == Type.LONG_ARRAY || arrayType == Type.NUMBER_ARRAY || arrayType == Type.OBJECT_ARRAY; 4.26 + assert arrayType == Type.INT_ARRAY || arrayType == Type.NUMBER_ARRAY || arrayType == Type.OBJECT_ARRAY; 4.27 4.28 final Expression[] nodes = arrayLiteralNode.getValue(); 4.29 final Object presets = arrayLiteralNode.getPresets(); 4.30 @@ -2383,20 +2381,9 @@ 4.31 method.convert(Type.OBJECT); 4.32 } else if(!resultBounds.canBeNarrowerThan(Type.NUMBER)) { 4.33 method.load(((Integer)value).doubleValue()); 4.34 - } else if(!resultBounds.canBeNarrowerThan(Type.LONG)) { 4.35 - method.load(((Integer)value).longValue()); 4.36 } else { 4.37 method.load((Integer)value); 4.38 } 4.39 - } else if (value instanceof Long) { 4.40 - if(!resultBounds.canBeNarrowerThan(Type.OBJECT)) { 4.41 - method.load((Long)value); 4.42 - method.convert(Type.OBJECT); 4.43 - } else if(!resultBounds.canBeNarrowerThan(Type.NUMBER)) { 4.44 - method.load(((Long)value).doubleValue()); 4.45 - } else { 4.46 - method.load((Long)value); 4.47 - } 4.48 } else if (value instanceof Double) { 4.49 if(!resultBounds.canBeNarrowerThan(Type.OBJECT)) { 4.50 method.load((Double)value); 4.51 @@ -3647,8 +3634,6 @@ 4.52 private void loadMinusOne() { 4.53 if (type.isInteger()) { 4.54 method.load(isIncrement ? 1 : -1); 4.55 - } else if (type.isLong()) { 4.56 - method.load(isIncrement ? 1L : -1L); 4.57 } else { 4.58 method.load(isIncrement ? 1.0 : -1.0); 4.59 } 4.60 @@ -4030,23 +4015,66 @@ 4.61 } 4.62 4.63 private void loadASSIGN_SHR(final BinaryNode binaryNode) { 4.64 - new BinarySelfAssignment(binaryNode) { 4.65 + new SelfModifyingStore<BinaryNode>(binaryNode, binaryNode.lhs()) { 4.66 @Override 4.67 - protected void op() { 4.68 - doSHR(); 4.69 - } 4.70 - 4.71 + protected void evaluate() { 4.72 + new OptimisticOperation(assignNode, new TypeBounds(Type.INT, Type.NUMBER)) { 4.73 + @Override 4.74 + void loadStack() { 4.75 + assert assignNode.getWidestOperandType() == Type.INT; 4.76 + if (isRhsZero(binaryNode)) { 4.77 + loadExpressionAsType(binaryNode.lhs(), Type.INT); 4.78 + } else { 4.79 + loadBinaryOperands(binaryNode.lhs(), binaryNode.rhs(), TypeBounds.INT, true, false); 4.80 + method.shr(); 4.81 + } 4.82 + } 4.83 + 4.84 + @Override 4.85 + void consumeStack() { 4.86 + if (isOptimistic(binaryNode)) { 4.87 + toUint32Optimistic(binaryNode.getProgramPoint()); 4.88 + } else { 4.89 + toUint32Double(); 4.90 + } 4.91 + } 4.92 + }.emit(getOptimisticIgnoreCountForSelfModifyingExpression(binaryNode.lhs())); 4.93 + method.convert(assignNode.getType()); 4.94 + } 4.95 }.store(); 4.96 } 4.97 4.98 - private void doSHR() { 4.99 - // TODO: make SHR optimistic 4.100 - method.shr(); 4.101 - toUint(); 4.102 - } 4.103 - 4.104 - private void toUint() { 4.105 - JSType.TO_UINT32_I.invoke(method); 4.106 + private void doSHR(final BinaryNode binaryNode) { 4.107 + new OptimisticOperation(binaryNode, new TypeBounds(Type.INT, Type.NUMBER)) { 4.108 + @Override 4.109 + void loadStack() { 4.110 + if (isRhsZero(binaryNode)) { 4.111 + loadExpressionAsType(binaryNode.lhs(), Type.INT); 4.112 + } else { 4.113 + loadBinaryOperands(binaryNode); 4.114 + method.shr(); 4.115 + } 4.116 + } 4.117 + 4.118 + @Override 4.119 + void consumeStack() { 4.120 + if (isOptimistic(binaryNode)) { 4.121 + toUint32Optimistic(binaryNode.getProgramPoint()); 4.122 + } else { 4.123 + toUint32Double(); 4.124 + } 4.125 + } 4.126 + }.emit(); 4.127 + 4.128 + } 4.129 + 4.130 + private void toUint32Optimistic(final int programPoint) { 4.131 + method.load(programPoint); 4.132 + JSType.TO_UINT32_OPTIMISTIC.invoke(method); 4.133 + } 4.134 + 4.135 + private void toUint32Double() { 4.136 + JSType.TO_UINT32_DOUBLE.invoke(method); 4.137 } 4.138 4.139 private void loadASSIGN_SUB(final BinaryNode binaryNode) { 4.140 @@ -4084,7 +4112,7 @@ 4.141 // Non-optimistic, non-FP subtraction or multiplication. Allow them to overflow. 4.142 operandBounds = new TypeBounds(Type.narrowest(node.getWidestOperandType(), 4.143 numericBounds.widest), Type.NUMBER); 4.144 - forceConversionSeparation = node.getWidestOperationType().narrowerThan(numericBounds.widest); 4.145 + forceConversionSeparation = true; 4.146 } 4.147 } 4.148 loadBinaryOperands(node.lhs(), node.rhs(), operandBounds, false, forceConversionSeparation); 4.149 @@ -4186,14 +4214,7 @@ 4.150 } 4.151 4.152 private void loadSHR(final BinaryNode binaryNode) { 4.153 - // Optimize x >>> 0 to (uint)x 4.154 - if (isRhsZero(binaryNode)) { 4.155 - loadExpressionAsType(binaryNode.lhs(), Type.INT); 4.156 - toUint(); 4.157 - } else { 4.158 - loadBinaryOperands(binaryNode); 4.159 - doSHR(); 4.160 - } 4.161 + doSHR(binaryNode); 4.162 } 4.163 4.164 private void loadSUB(final BinaryNode binaryNode, final TypeBounds resultBounds) { 4.165 @@ -4464,6 +4485,7 @@ 4.166 } 4.167 } else { 4.168 final Type storeType = assignNode.getType(); 4.169 + assert storeType != Type.LONG; 4.170 if (symbol.hasSlotFor(storeType)) { 4.171 // Only emit a convert for a store known to be live; converts for dead stores can 4.172 // give us an unnecessary ClassCastException. 4.173 @@ -4848,8 +4870,6 @@ 4.174 method.load(optimistic.getProgramPoint()); 4.175 if(optimisticType.isInteger()) { 4.176 method.invoke(ENSURE_INT); 4.177 - } else if(optimisticType.isLong()) { 4.178 - method.invoke(ENSURE_LONG); 4.179 } else if(optimisticType.isNumber()) { 4.180 method.invoke(ENSURE_NUMBER); 4.181 } else {
5.1 --- a/src/jdk/nashorn/internal/codegen/Compiler.java Tue Jan 26 11:36:10 2016 -0800 5.2 +++ b/src/jdk/nashorn/internal/codegen/Compiler.java Fri Feb 05 23:32:52 2016 -0800 5.3 @@ -46,6 +46,7 @@ 5.4 import java.util.Map; 5.5 import java.util.Set; 5.6 import java.util.TreeMap; 5.7 +import java.util.concurrent.TimeUnit; 5.8 import java.util.concurrent.atomic.AtomicInteger; 5.9 import java.util.function.Consumer; 5.10 import java.util.logging.Level; 5.11 @@ -683,7 +684,7 @@ 5.12 5.13 if (time > 0L && timeLogger != null) { 5.14 assert env.isTimingEnabled(); 5.15 - sb.append(" in ").append(time).append(" ms"); 5.16 + sb.append(" in ").append(TimeUnit.NANOSECONDS.toMillis(time)).append(" ms"); 5.17 } 5.18 log.info(sb); 5.19 }
6.1 --- a/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java Tue Jan 26 11:36:10 2016 -0800 6.2 +++ b/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java Fri Feb 05 23:32:52 2016 -0800 6.3 @@ -167,8 +167,7 @@ 6.4 assert fieldName.equals(getFieldName(fieldIndex, PRIMITIVE_FIELD_TYPE)) || fieldType.isObject() : key + " object keys must store to L*-fields"; 6.5 assert fieldName.equals(getFieldName(fieldIndex, Type.OBJECT)) || fieldType.isPrimitive() : key + " primitive keys must store to J*-fields"; 6.6 6.7 - loadTuple(method, tuple); 6.8 - 6.9 + loadTuple(method, tuple, true); 6.10 method.putField(fieldClass, fieldName, fieldDesc); 6.11 } 6.12 6.13 @@ -180,11 +179,7 @@ 6.14 * @param tuple Tuple to store. 6.15 */ 6.16 private void putSlot(final MethodEmitter method, final long index, final MapTuple<T> tuple) { 6.17 - if (JSType.isRepresentableAsInt(index)) { 6.18 - method.load((int)index); 6.19 - } else { 6.20 - method.load(index); 6.21 - } 6.22 + loadIndex(method, index); 6.23 loadTuple(method, tuple, false); //we don't pack array like objects 6.24 method.dynamicSetIndex(callSiteFlags); 6.25 }
7.1 --- a/src/jdk/nashorn/internal/codegen/FoldConstants.java Tue Jan 26 11:36:10 2016 -0800 7.2 +++ b/src/jdk/nashorn/internal/codegen/FoldConstants.java Fri Feb 05 23:32:52 2016 -0800 7.3 @@ -234,6 +234,8 @@ 7.4 case ADD: 7.5 if (rhsInteger) { 7.6 literalNode = LiteralNode.newInstance(token, finish, rhs.getInt32()); 7.7 + } else if (rhsType.isLong()) { 7.8 + literalNode = LiteralNode.newInstance(token, finish, rhs.getLong()); 7.9 } else { 7.10 literalNode = LiteralNode.newInstance(token, finish, rhs.getNumber()); 7.11 } 7.12 @@ -241,6 +243,8 @@ 7.13 case SUB: 7.14 if (rhsInteger && rhs.getInt32() != 0) { // @see test/script/basic/minuszero.js 7.15 literalNode = LiteralNode.newInstance(token, finish, -rhs.getInt32()); 7.16 + } else if (rhsType.isLong() && rhs.getLong() != 0L) { 7.17 + literalNode = LiteralNode.newInstance(token, finish, -rhs.getLong()); 7.18 } else { 7.19 literalNode = LiteralNode.newInstance(token, finish, -rhs.getNumber()); 7.20 } 7.21 @@ -303,9 +307,7 @@ 7.22 final Type widest = Type.widest(lhs.getType(), rhs.getType()); 7.23 7.24 boolean isInteger = widest.isInteger(); 7.25 - boolean isLong = widest.isLong(); 7.26 - 7.27 - double value; 7.28 + final double value; 7.29 7.30 switch (parent.tokenType()) { 7.31 case DIV: 7.32 @@ -332,7 +334,8 @@ 7.33 value = lhs.getNumber() - rhs.getNumber(); 7.34 break; 7.35 case SHR: 7.36 - return LiteralNode.newInstance(token, finish, JSType.toUint32(lhs.getInt32() >>> rhs.getInt32())); 7.37 + final long result = JSType.toUint32(lhs.getInt32() >>> rhs.getInt32()); 7.38 + return LiteralNode.newInstance(token, finish, JSType.toNarrowestNumber(result)); 7.39 case SAR: 7.40 return LiteralNode.newInstance(token, finish, lhs.getInt32() >> rhs.getInt32()); 7.41 case SHL: 7.42 @@ -364,12 +367,9 @@ 7.43 } 7.44 7.45 isInteger &= JSType.isStrictlyRepresentableAsInt(value); 7.46 - isLong &= JSType.isStrictlyRepresentableAsLong(value); 7.47 7.48 if (isInteger) { 7.49 return LiteralNode.newInstance(token, finish, (int)value); 7.50 - } else if (isLong) { 7.51 - return LiteralNode.newInstance(token, finish, (long)value); 7.52 } 7.53 7.54 return LiteralNode.newInstance(token, finish, value);
8.1 --- a/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java Tue Jan 26 11:36:10 2016 -0800 8.2 +++ b/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java Fri Feb 05 23:32:52 2016 -0800 8.3 @@ -131,7 +131,6 @@ 8.4 UNDEFINED(Type.UNDEFINED), 8.5 BOOLEAN(Type.BOOLEAN), 8.6 INT(Type.INT), 8.7 - LONG(Type.LONG), 8.8 DOUBLE(Type.NUMBER), 8.9 OBJECT(Type.OBJECT); 8.10 8.11 @@ -272,12 +271,9 @@ 8.12 } 8.13 8.14 private static class SymbolConversions { 8.15 - private static byte I2L = 1 << 0; 8.16 - private static byte I2D = 1 << 1; 8.17 - private static byte I2O = 1 << 2; 8.18 - private static byte L2D = 1 << 3; 8.19 - private static byte L2O = 1 << 4; 8.20 - private static byte D2O = 1 << 5; 8.21 + private static final byte I2D = 1 << 0; 8.22 + private static final byte I2O = 1 << 1; 8.23 + private static final byte D2O = 1 << 2; 8.24 8.25 private byte conversions; 8.26 8.27 @@ -288,9 +284,6 @@ 8.28 case INT: 8.29 case BOOLEAN: 8.30 switch (to) { 8.31 - case LONG: 8.32 - recordConversion(I2L); 8.33 - return; 8.34 case DOUBLE: 8.35 recordConversion(I2D); 8.36 return; 8.37 @@ -301,18 +294,6 @@ 8.38 illegalConversion(from, to); 8.39 return; 8.40 } 8.41 - case LONG: 8.42 - switch (to) { 8.43 - case DOUBLE: 8.44 - recordConversion(L2D); 8.45 - return; 8.46 - case OBJECT: 8.47 - recordConversion(L2O); 8.48 - return; 8.49 - default: 8.50 - illegalConversion(from, to); 8.51 - return; 8.52 - } 8.53 case DOUBLE: 8.54 if(to == LvarType.OBJECT) { 8.55 recordConversion(D2O); 8.56 @@ -340,26 +321,15 @@ 8.57 if(hasConversion(D2O)) { 8.58 symbol.setHasSlotFor(Type.NUMBER); 8.59 } 8.60 - if(hasConversion(L2O)) { 8.61 - symbol.setHasSlotFor(Type.LONG); 8.62 - } 8.63 if(hasConversion(I2O)) { 8.64 symbol.setHasSlotFor(Type.INT); 8.65 } 8.66 } 8.67 if(symbol.hasSlotFor(Type.NUMBER)) { 8.68 - if(hasConversion(L2D)) { 8.69 - symbol.setHasSlotFor(Type.LONG); 8.70 - } 8.71 if(hasConversion(I2D)) { 8.72 symbol.setHasSlotFor(Type.INT); 8.73 } 8.74 } 8.75 - if(symbol.hasSlotFor(Type.LONG)) { 8.76 - if(hasConversion(I2L)) { 8.77 - symbol.setHasSlotFor(Type.INT); 8.78 - } 8.79 - } 8.80 } 8.81 } 8.82 8.83 @@ -378,7 +348,7 @@ 8.84 if(lvarType != null) { 8.85 return lvarType; 8.86 } 8.87 - assert type.isObject(); 8.88 + assert type.isObject() : "Unsupported primitive type: " + type; 8.89 return LvarType.OBJECT; 8.90 } 8.91 private static LvarType widestLvarType(final LvarType t1, final LvarType t2) {
9.1 --- a/src/jdk/nashorn/internal/codegen/MethodEmitter.java Tue Jan 26 11:36:10 2016 -0800 9.2 +++ b/src/jdk/nashorn/internal/codegen/MethodEmitter.java Fri Feb 05 23:32:52 2016 -0800 9.3 @@ -543,7 +543,6 @@ 9.4 } else { 9.5 assert false : type + " cannot be packed!"; 9.6 } 9.7 - //all others are nops, objects aren't packed 9.8 } 9.9 9.10 /**
10.1 --- a/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Tue Jan 26 11:36:10 2016 -0800 10.2 +++ b/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Fri Feb 05 23:32:52 2016 -0800 10.3 @@ -41,7 +41,6 @@ 10.4 import static jdk.nashorn.internal.runtime.JSType.GET_UNDEFINED; 10.5 import static jdk.nashorn.internal.runtime.JSType.TYPE_DOUBLE_INDEX; 10.6 import static jdk.nashorn.internal.runtime.JSType.TYPE_INT_INDEX; 10.7 -import static jdk.nashorn.internal.runtime.JSType.TYPE_LONG_INDEX; 10.8 import static jdk.nashorn.internal.runtime.JSType.TYPE_OBJECT_INDEX; 10.9 import static jdk.nashorn.internal.runtime.JSType.TYPE_UNDEFINED_INDEX; 10.10 import static jdk.nashorn.internal.runtime.JSType.getAccessorTypeIndex; 10.11 @@ -535,8 +534,6 @@ 10.12 switch (getAccessorTypeIndex(forType)) { 10.13 case TYPE_INT_INDEX: 10.14 return MH.explicitCastArguments(primitiveGetter, primitiveGetter.type().changeReturnType(int.class)); 10.15 - case TYPE_LONG_INDEX: 10.16 - return primitiveGetter; 10.17 case TYPE_DOUBLE_INDEX: 10.18 return MH.filterReturnValue(primitiveGetter, UNPACK_DOUBLE); 10.19 case TYPE_OBJECT_INDEX: 10.20 @@ -623,7 +620,7 @@ 10.21 } 10.22 10.23 assert !isOptimistic; 10.24 - //freely coerce the result to whatever you asked for, this is e.g. Object->int for a & b 10.25 + // freely coerce the result to whatever you asked for, this is e.g. Object->int for a & b 10.26 final MethodHandle tgetter = getterForType(forType, primitiveGetter, objectGetter); 10.27 if (fti == TYPE_OBJECT_INDEX) { 10.28 if (fti != ti) { 10.29 @@ -638,22 +635,10 @@ 10.30 case TYPE_INT_INDEX: { 10.31 return MH.asType(tgetter, tgetterType.changeReturnType(type)); 10.32 } 10.33 - case TYPE_LONG_INDEX: 10.34 - switch (ti) { 10.35 - case TYPE_INT_INDEX: 10.36 - //get int while an int, truncating cast of long value 10.37 - return MH.filterReturnValue(tgetter, JSType.TO_INT32_L.methodHandle); 10.38 - case TYPE_LONG_INDEX: 10.39 - return primitiveGetter; 10.40 - default: 10.41 - return MH.asType(tgetter, tgetterType.changeReturnType(type)); 10.42 - } 10.43 case TYPE_DOUBLE_INDEX: 10.44 switch (ti) { 10.45 case TYPE_INT_INDEX: 10.46 return MH.filterReturnValue(tgetter, JSType.TO_INT32_D.methodHandle); 10.47 - case TYPE_LONG_INDEX: 10.48 - return MH.explicitCastArguments(tgetter, tgetterType.changeReturnType(type)); 10.49 case TYPE_DOUBLE_INDEX: 10.50 assert tgetterType.returnType() == double.class; 10.51 return tgetter; 10.52 @@ -734,12 +719,9 @@ 10.53 10.54 switch (fti) { 10.55 case TYPE_INT_INDEX: 10.56 - case TYPE_LONG_INDEX: 10.57 switch (ti) { 10.58 case TYPE_INT_INDEX: 10.59 return MH.asType(primitiveSetter, pmt.changeParameterType(1, int.class)); 10.60 - case TYPE_LONG_INDEX: 10.61 - return primitiveSetter; 10.62 case TYPE_DOUBLE_INDEX: 10.63 return MH.filterArguments(primitiveSetter, 1, PACK_DOUBLE); 10.64 default:
11.1 --- a/src/jdk/nashorn/internal/codegen/ObjectCreator.java Tue Jan 26 11:36:10 2016 -0800 11.2 +++ b/src/jdk/nashorn/internal/codegen/ObjectCreator.java Fri Feb 05 23:32:52 2016 -0800 11.3 @@ -29,6 +29,7 @@ 11.4 11.5 import java.util.List; 11.6 import jdk.nashorn.internal.codegen.types.Type; 11.7 +import jdk.nashorn.internal.runtime.JSType; 11.8 import jdk.nashorn.internal.runtime.PropertyMap; 11.9 import jdk.nashorn.internal.runtime.ScriptObject; 11.10 11.11 @@ -156,15 +157,15 @@ 11.12 11.13 MethodEmitter loadTuple(final MethodEmitter method, final MapTuple<T> tuple, final boolean pack) { 11.14 loadValue(tuple.value, tuple.type); 11.15 - if (pack && codegen.useDualFields() && tuple.isPrimitive()) { 11.16 + if (!codegen.useDualFields() || !tuple.isPrimitive()) { 11.17 + method.convert(Type.OBJECT); 11.18 + } else if (pack) { 11.19 method.pack(); 11.20 - } else { 11.21 - method.convert(Type.OBJECT); 11.22 } 11.23 return method; 11.24 } 11.25 11.26 - MethodEmitter loadTuple(final MethodEmitter method, final MapTuple<T> tuple) { 11.27 - return loadTuple(method, tuple, true); 11.28 + MethodEmitter loadIndex(final MethodEmitter method, final long index) { 11.29 + return JSType.isRepresentableAsInt(index) ? method.load((int) index) : method.load((double) index); 11.30 } 11.31 }
12.1 --- a/src/jdk/nashorn/internal/codegen/SpillObjectCreator.java Tue Jan 26 11:36:10 2016 -0800 12.2 +++ b/src/jdk/nashorn/internal/codegen/SpillObjectCreator.java Fri Feb 05 23:32:52 2016 -0800 12.3 @@ -109,8 +109,6 @@ 12.4 //avoid blowing up the array if we can 12.5 if (constantValue instanceof Integer) { 12.6 arrayData = arrayData.set(index, ((Integer)constantValue).intValue(), false); 12.7 - } else if (constantValue instanceof Long) { 12.8 - arrayData = arrayData.set(index, ((Long)constantValue).longValue(), false); 12.9 } else if (constantValue instanceof Double) { 12.10 arrayData = arrayData.set(index, ((Double)constantValue).doubleValue(), false); 12.11 } else { 12.12 @@ -169,12 +167,12 @@ 12.13 final int index = ArrayIndex.getArrayIndex(tuple.key); 12.14 assert ArrayIndex.isValidArrayIndex(index); 12.15 method.dup(); 12.16 - method.load(ArrayIndex.toLongIndex(index)); 12.17 - loadTuple(method, tuple); 12.18 + loadIndex(method, ArrayIndex.toLongIndex(index)); 12.19 + loadTuple(method, tuple, false); 12.20 method.dynamicSetIndex(callSiteFlags); 12.21 } else { 12.22 method.dup(); 12.23 - loadTuple(method, tuple); 12.24 + loadTuple(method, tuple, false); 12.25 method.dynamicSet(property.getKey(), codegen.getCallSiteFlags(), false); 12.26 } 12.27 }
13.1 --- a/src/jdk/nashorn/internal/codegen/TypeEvaluator.java Tue Jan 26 11:36:10 2016 -0800 13.2 +++ b/src/jdk/nashorn/internal/codegen/TypeEvaluator.java Fri Feb 05 23:32:52 2016 -0800 13.3 @@ -239,7 +239,7 @@ 13.4 // currently deoptimize all the way to Object. 13.5 return Type.OBJECT; 13.6 } 13.7 - assert returnType == Type.INT || returnType == Type.LONG || returnType == Type.NUMBER || returnType == Type.OBJECT; 13.8 + assert returnType == Type.INT || returnType == Type.NUMBER || returnType == Type.OBJECT; 13.9 return returnType; 13.10 } 13.11 }
14.1 --- a/src/jdk/nashorn/internal/codegen/types/IntType.java Tue Jan 26 11:36:10 2016 -0800 14.2 +++ b/src/jdk/nashorn/internal/codegen/types/IntType.java Fri Feb 05 23:32:52 2016 -0800 14.3 @@ -72,7 +72,7 @@ 14.4 14.5 @Override 14.6 public Type nextWider() { 14.7 - return LONG; 14.8 + return NUMBER; 14.9 } 14.10 14.11 @Override
15.1 --- a/src/jdk/nashorn/internal/codegen/types/LongType.java Tue Jan 26 11:36:10 2016 -0800 15.2 +++ b/src/jdk/nashorn/internal/codegen/types/LongType.java Fri Feb 05 23:32:52 2016 -0800 15.3 @@ -28,20 +28,11 @@ 15.4 import static jdk.internal.org.objectweb.asm.Opcodes.L2D; 15.5 import static jdk.internal.org.objectweb.asm.Opcodes.L2I; 15.6 import static jdk.internal.org.objectweb.asm.Opcodes.LADD; 15.7 -import static jdk.internal.org.objectweb.asm.Opcodes.LAND; 15.8 -import static jdk.internal.org.objectweb.asm.Opcodes.LCMP; 15.9 import static jdk.internal.org.objectweb.asm.Opcodes.LCONST_0; 15.10 import static jdk.internal.org.objectweb.asm.Opcodes.LCONST_1; 15.11 import static jdk.internal.org.objectweb.asm.Opcodes.LLOAD; 15.12 -import static jdk.internal.org.objectweb.asm.Opcodes.LMUL; 15.13 -import static jdk.internal.org.objectweb.asm.Opcodes.LOR; 15.14 import static jdk.internal.org.objectweb.asm.Opcodes.LRETURN; 15.15 -import static jdk.internal.org.objectweb.asm.Opcodes.LSHL; 15.16 -import static jdk.internal.org.objectweb.asm.Opcodes.LSHR; 15.17 import static jdk.internal.org.objectweb.asm.Opcodes.LSTORE; 15.18 -import static jdk.internal.org.objectweb.asm.Opcodes.LSUB; 15.19 -import static jdk.internal.org.objectweb.asm.Opcodes.LUSHR; 15.20 -import static jdk.internal.org.objectweb.asm.Opcodes.LXOR; 15.21 import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup; 15.22 import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_LONG; 15.23 import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT; 15.24 @@ -53,7 +44,7 @@ 15.25 /** 15.26 * Type class: LONG 15.27 */ 15.28 -class LongType extends BitwiseType { 15.29 +class LongType extends Type { 15.30 private static final long serialVersionUID = 1L; 15.31 15.32 private static final CompilerConstants.Call VALUE_OF = staticCallNoLookup(Long.class, "valueOf", Long.class, long.class); 15.33 @@ -82,12 +73,6 @@ 15.34 } 15.35 15.36 @Override 15.37 - public Type cmp(final MethodVisitor method) { 15.38 - method.visitInsn(LCMP); 15.39 - return INT; 15.40 - } 15.41 - 15.42 - @Override 15.43 public Type load(final MethodVisitor method, final int slot) { 15.44 assert slot != -1; 15.45 method.visitVarInsn(LLOAD, slot); 15.46 @@ -149,88 +134,6 @@ 15.47 } 15.48 15.49 @Override 15.50 - public Type sub(final MethodVisitor method, final int programPoint) { 15.51 - if(programPoint == INVALID_PROGRAM_POINT) { 15.52 - method.visitInsn(LSUB); 15.53 - } else { 15.54 - method.visitInvokeDynamicInsn("lsub", "(JJ)J", MATHBOOTSTRAP, programPoint); 15.55 - } 15.56 - return LONG; 15.57 - } 15.58 - 15.59 - @Override 15.60 - public Type mul(final MethodVisitor method, final int programPoint) { 15.61 - if(programPoint == INVALID_PROGRAM_POINT) { 15.62 - method.visitInsn(LMUL); 15.63 - } else { 15.64 - method.visitInvokeDynamicInsn("lmul", "(JJ)J", MATHBOOTSTRAP, programPoint); 15.65 - } 15.66 - return LONG; 15.67 - } 15.68 - 15.69 - @Override 15.70 - public Type div(final MethodVisitor method, final int programPoint) { 15.71 - if (programPoint == INVALID_PROGRAM_POINT) { 15.72 - JSType.DIV_ZERO_LONG.invoke(method); 15.73 - } else { 15.74 - method.visitInvokeDynamicInsn("ldiv", "(JJ)J", MATHBOOTSTRAP, programPoint); 15.75 - } 15.76 - return LONG; 15.77 - } 15.78 - 15.79 - @Override 15.80 - public Type rem(final MethodVisitor method, final int programPoint) { 15.81 - if (programPoint == INVALID_PROGRAM_POINT) { 15.82 - JSType.REM_ZERO_LONG.invoke(method); 15.83 - } else { 15.84 - method.visitInvokeDynamicInsn("lrem", "(JJ)J", MATHBOOTSTRAP, programPoint); 15.85 - } 15.86 - return LONG; 15.87 - } 15.88 - 15.89 - @Override 15.90 - public Type shr(final MethodVisitor method) { 15.91 - method.visitInsn(LUSHR); 15.92 - return LONG; 15.93 - } 15.94 - 15.95 - @Override 15.96 - public Type sar(final MethodVisitor method) { 15.97 - method.visitInsn(LSHR); 15.98 - return LONG; 15.99 - } 15.100 - 15.101 - @Override 15.102 - public Type shl(final MethodVisitor method) { 15.103 - method.visitInsn(LSHL); 15.104 - return LONG; 15.105 - } 15.106 - 15.107 - @Override 15.108 - public Type and(final MethodVisitor method) { 15.109 - method.visitInsn(LAND); 15.110 - return LONG; 15.111 - } 15.112 - 15.113 - @Override 15.114 - public Type or(final MethodVisitor method) { 15.115 - method.visitInsn(LOR); 15.116 - return LONG; 15.117 - } 15.118 - 15.119 - @Override 15.120 - public Type xor(final MethodVisitor method) { 15.121 - method.visitInsn(LXOR); 15.122 - return LONG; 15.123 - } 15.124 - 15.125 - @Override 15.126 - public Type neg(final MethodVisitor method, final int programPoint) { 15.127 - method.visitInvokeDynamicInsn("lneg", "(J)J", MATHBOOTSTRAP, programPoint); 15.128 - return LONG; 15.129 - } 15.130 - 15.131 - @Override 15.132 public void _return(final MethodVisitor method) { 15.133 method.visitInsn(LRETURN); 15.134 } 15.135 @@ -246,9 +149,4 @@ 15.136 method.visitInsn(LCONST_0); 15.137 return LONG; 15.138 } 15.139 - 15.140 - @Override 15.141 - public Type cmp(final MethodVisitor method, final boolean isCmpG) { 15.142 - return cmp(method); 15.143 - } 15.144 }
16.1 --- a/src/jdk/nashorn/internal/codegen/types/Type.java Tue Jan 26 11:36:10 2016 -0800 16.2 +++ b/src/jdk/nashorn/internal/codegen/types/Type.java Fri Feb 05 23:32:52 2016 -0800 16.3 @@ -921,7 +921,7 @@ 16.4 /** 16.5 * This is the long singleton, used for all long types 16.6 */ 16.7 - public static final BitwiseType LONG = putInCache(new LongType()); 16.8 + public static final Type LONG = putInCache(new LongType()); 16.9 16.10 /** 16.11 * A string singleton
17.1 --- a/src/jdk/nashorn/internal/ir/BinaryNode.java Tue Jan 26 11:36:10 2016 -0800 17.2 +++ b/src/jdk/nashorn/internal/ir/BinaryNode.java Fri Feb 05 23:32:52 2016 -0800 17.3 @@ -70,7 +70,9 @@ 17.4 TokenType.ASSIGN_DIV, 17.5 TokenType.ASSIGN_MOD, 17.6 TokenType.ASSIGN_MUL, 17.7 - TokenType.ASSIGN_SUB 17.8 + TokenType.ASSIGN_SUB, 17.9 + TokenType.SHR, 17.10 + TokenType.ASSIGN_SHR 17.11 }))); 17.12 17.13 /** 17.14 @@ -196,9 +198,7 @@ 17.15 return Type.CHARSEQUENCE; 17.16 } 17.17 final Type widestOperandType = Type.widest(undefinedToNumber(booleanToInt(lhsType)), undefinedToNumber(booleanToInt(rhsType))); 17.18 - if(widestOperandType == Type.INT) { 17.19 - return Type.LONG; 17.20 - } else if (widestOperandType.isNumeric()) { 17.21 + if (widestOperandType.isNumeric()) { 17.22 return Type.NUMBER; 17.23 } 17.24 // We pretty much can't know what it will be statically. Must presume OBJECT conservatively, as we can end 17.25 @@ -210,7 +210,7 @@ 17.26 } 17.27 case SHR: 17.28 case ASSIGN_SHR: 17.29 - return Type.LONG; 17.30 + return Type.NUMBER; 17.31 case ASSIGN_SAR: 17.32 case ASSIGN_SHL: 17.33 case BIT_AND: 17.34 @@ -239,10 +239,6 @@ 17.35 if(lhsType == Type.BOOLEAN && rhsType == Type.BOOLEAN) { 17.36 return Type.INT; 17.37 } 17.38 - final Type widestOperandType = Type.widest(booleanToInt(lhsType), booleanToInt(rhsType)); 17.39 - if(widestOperandType == Type.INT) { 17.40 - return Type.LONG; 17.41 - } 17.42 return Type.NUMBER; 17.43 } 17.44 case VOID: { 17.45 @@ -565,6 +561,9 @@ 17.46 if(type == null) { 17.47 return widest; 17.48 } 17.49 + if (tokenType() == TokenType.ASSIGN_SHR || tokenType() == TokenType.SHR) { 17.50 + return type; 17.51 + } 17.52 return Type.narrowest(widest, Type.widest(type, Type.widest(lhs.getType(), rhs.getType()))); 17.53 } 17.54
18.1 --- a/src/jdk/nashorn/internal/ir/LiteralNode.java Tue Jan 26 11:36:10 2016 -0800 18.2 +++ b/src/jdk/nashorn/internal/ir/LiteralNode.java Fri Feb 05 23:32:52 2016 -0800 18.3 @@ -364,8 +364,6 @@ 18.4 private static Type numberGetType(final Number number) { 18.5 if (number instanceof Integer) { 18.6 return Type.INT; 18.7 - } else if (number instanceof Long) { 18.8 - return Type.LONG; 18.9 } else if (number instanceof Double) { 18.10 return Type.NUMBER; 18.11 } else { 18.12 @@ -396,6 +394,7 @@ 18.13 * @return the new literal node 18.14 */ 18.15 public static LiteralNode<Number> newInstance(final long token, final int finish, final Number value) { 18.16 + assert !(value instanceof Long); 18.17 return new NumberLiteralNode(token, finish, value); 18.18 } 18.19 18.20 @@ -748,8 +747,6 @@ 18.21 assert !elementType.isUnknown(); 18.22 if (elementType.isInteger()) { 18.23 return presetIntArray(value, postsets); 18.24 - } else if (elementType.isLong()) { 18.25 - return presetLongArray(value, postsets); 18.26 } else if (elementType.isNumeric()) { 18.27 return presetDoubleArray(value, postsets); 18.28 } else { 18.29 @@ -818,8 +815,6 @@ 18.30 private static ArrayType getArrayType(final Type elementType) { 18.31 if (elementType.isInteger()) { 18.32 return Type.INT_ARRAY; 18.33 - } else if (elementType.isLong()) { 18.34 - return Type.LONG_ARRAY; 18.35 } else if (elementType.isNumeric()) { 18.36 return Type.NUMBER_ARRAY; 18.37 } else { 18.38 @@ -854,8 +849,6 @@ 18.39 private boolean presetsMatchElementType() { 18.40 if (elementType == Type.INT) { 18.41 return presets instanceof int[]; 18.42 - } else if (elementType == Type.LONG) { 18.43 - return presets instanceof long[]; 18.44 } else if (elementType == Type.NUMBER) { 18.45 return presets instanceof double[]; 18.46 } else {
19.1 --- a/src/jdk/nashorn/internal/ir/Symbol.java Tue Jan 26 11:36:10 2016 -0800 19.2 +++ b/src/jdk/nashorn/internal/ir/Symbol.java Fri Feb 05 23:32:52 2016 -0800 19.3 @@ -82,14 +82,12 @@ 19.4 public static final int HAS_SLOT = 1 << 10; 19.5 /** Is this symbol known to store an int value ? */ 19.6 public static final int HAS_INT_VALUE = 1 << 11; 19.7 - /** Is this symbol known to store a long value ? */ 19.8 - public static final int HAS_LONG_VALUE = 1 << 12; 19.9 /** Is this symbol known to store a double value ? */ 19.10 - public static final int HAS_DOUBLE_VALUE = 1 << 13; 19.11 + public static final int HAS_DOUBLE_VALUE = 1 << 12; 19.12 /** Is this symbol known to store an object value ? */ 19.13 - public static final int HAS_OBJECT_VALUE = 1 << 14; 19.14 + public static final int HAS_OBJECT_VALUE = 1 << 13; 19.15 /** Is this symbol seen a declaration? Used for block scoped LET and CONST symbols only. */ 19.16 - public static final int HAS_BEEN_DECLARED = 1 << 15; 19.17 + public static final int HAS_BEEN_DECLARED = 1 << 14; 19.18 19.19 /** Null or name identifying symbol. */ 19.20 private final String name; 19.21 @@ -256,7 +254,6 @@ 19.22 */ 19.23 public int slotCount() { 19.24 return ((flags & HAS_INT_VALUE) == 0 ? 0 : 1) + 19.25 - ((flags & HAS_LONG_VALUE) == 0 ? 0 : 2) + 19.26 ((flags & HAS_DOUBLE_VALUE) == 0 ? 0 : 2) + 19.27 ((flags & HAS_OBJECT_VALUE) == 0 ? 0 : 1); 19.28 } 19.29 @@ -278,7 +275,6 @@ 19.30 append("slot="). 19.31 append(firstSlot).append(' '); 19.32 if((flags & HAS_INT_VALUE) != 0) { sb.append('I'); } 19.33 - if((flags & HAS_LONG_VALUE) != 0) { sb.append('J'); } 19.34 if((flags & HAS_DOUBLE_VALUE) != 0) { sb.append('D'); } 19.35 if((flags & HAS_OBJECT_VALUE) != 0) { sb.append('O'); } 19.36 sb.append(')'); 19.37 @@ -573,11 +569,6 @@ 19.38 return typeSlot; 19.39 } 19.40 typeSlot += ((flags & HAS_INT_VALUE) == 0 ? 0 : 1); 19.41 - if(type.isLong()) { 19.42 - assert (flags & HAS_LONG_VALUE) != 0; 19.43 - return typeSlot; 19.44 - } 19.45 - typeSlot += ((flags & HAS_LONG_VALUE) == 0 ? 0 : 2); 19.46 if(type.isNumber()) { 19.47 assert (flags & HAS_DOUBLE_VALUE) != 0; 19.48 return typeSlot; 19.49 @@ -595,8 +586,6 @@ 19.50 public boolean hasSlotFor(final Type type) { 19.51 if(type.isBoolean() || type.isInteger()) { 19.52 return (flags & HAS_INT_VALUE) != 0; 19.53 - } else if(type.isLong()) { 19.54 - return (flags & HAS_LONG_VALUE) != 0; 19.55 } else if(type.isNumber()) { 19.56 return (flags & HAS_DOUBLE_VALUE) != 0; 19.57 } 19.58 @@ -611,8 +600,6 @@ 19.59 public void setHasSlotFor(final Type type) { 19.60 if(type.isBoolean() || type.isInteger()) { 19.61 setFlag(HAS_INT_VALUE); 19.62 - } else if(type.isLong()) { 19.63 - setFlag(HAS_LONG_VALUE); 19.64 } else if(type.isNumber()) { 19.65 setFlag(HAS_DOUBLE_VALUE); 19.66 } else {
20.1 --- a/src/jdk/nashorn/internal/objects/Global.java Tue Jan 26 11:36:10 2016 -0800 20.2 +++ b/src/jdk/nashorn/internal/objects/Global.java Fri Feb 05 23:32:52 2016 -0800 20.3 @@ -1096,8 +1096,6 @@ 20.4 return new NativeArray(ArrayData.allocate((Object[])obj), this); 20.5 } else if (obj instanceof double[]) { // extension 20.6 return new NativeArray(ArrayData.allocate((double[])obj), this); 20.7 - } else if (obj instanceof long[]) { 20.8 - return new NativeArray(ArrayData.allocate((long[])obj), this); 20.9 } else if (obj instanceof int[]) { 20.10 return new NativeArray(ArrayData.allocate((int[]) obj), this); 20.11 } else if (obj instanceof ArrayData) { 20.12 @@ -1965,16 +1963,6 @@ 20.13 } 20.14 20.15 /** 20.16 - * Allocate a new long array. 20.17 - * 20.18 - * @param initial number values. 20.19 - * @return the new array 20.20 - */ 20.21 - public static NativeArray allocate(final long[] initial) { 20.22 - return new NativeArray(ArrayData.allocate(initial)); 20.23 - } 20.24 - 20.25 - /** 20.26 * Allocate a new integer array. 20.27 * 20.28 * @param initial number values. 20.29 @@ -2263,7 +2251,6 @@ 20.30 new Specialization[] { 20.31 new Specialization(GlobalFunctions.PARSEINT_Z), 20.32 new Specialization(GlobalFunctions.PARSEINT_I), 20.33 - new Specialization(GlobalFunctions.PARSEINT_J), 20.34 new Specialization(GlobalFunctions.PARSEINT_OI), 20.35 new Specialization(GlobalFunctions.PARSEINT_O) }); 20.36 this.parseFloat = ScriptFunction.createBuiltin("parseFloat", GlobalFunctions.PARSEFLOAT);
21.1 --- a/src/jdk/nashorn/internal/objects/NativeArguments.java Tue Jan 26 11:36:10 2016 -0800 21.2 +++ b/src/jdk/nashorn/internal/objects/NativeArguments.java Fri Feb 05 23:32:52 2016 -0800 21.3 @@ -128,12 +128,6 @@ 21.4 } 21.5 21.6 @Override 21.7 - public boolean delete(final long key, final boolean strict) { 21.8 - final int index = ArrayIndex.getArrayIndex(key); 21.9 - return isMapped(index) ? deleteMapped(index, strict) : super.delete(key, strict); 21.10 - } 21.11 - 21.12 - @Override 21.13 public boolean delete(final double key, final boolean strict) { 21.14 final int index = ArrayIndex.getArrayIndex(key); 21.15 return isMapped(index) ? deleteMapped(index, strict) : super.delete(key, strict);
22.1 --- a/src/jdk/nashorn/internal/objects/NativeArray.java Tue Jan 26 11:36:10 2016 -0800 22.2 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java Fri Feb 05 23:32:52 2016 -0800 22.3 @@ -70,7 +70,6 @@ 22.4 import jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator; 22.5 import jdk.nashorn.internal.runtime.arrays.ContinuousArrayData; 22.6 import jdk.nashorn.internal.runtime.arrays.IntElements; 22.7 -import jdk.nashorn.internal.runtime.arrays.IntOrLongElements; 22.8 import jdk.nashorn.internal.runtime.arrays.IteratorAction; 22.9 import jdk.nashorn.internal.runtime.arrays.NumericElements; 22.10 import jdk.nashorn.internal.runtime.linker.Bootstrap; 22.11 @@ -100,20 +99,38 @@ 22.12 } 22.13 22.14 NativeArray(final long length) { 22.15 - // TODO assert valid index in long before casting 22.16 - this(ArrayData.allocate((int)length)); 22.17 + this(ArrayData.allocate(length)); 22.18 } 22.19 22.20 NativeArray(final int[] array) { 22.21 this(ArrayData.allocate(array)); 22.22 } 22.23 22.24 - NativeArray(final long[] array) { 22.25 + NativeArray(final double[] array) { 22.26 this(ArrayData.allocate(array)); 22.27 } 22.28 22.29 - NativeArray(final double[] array) { 22.30 - this(ArrayData.allocate(array)); 22.31 + NativeArray(final long[] array) { 22.32 + this(ArrayData.allocate(array.length)); 22.33 + 22.34 + ArrayData arrayData = this.getArray(); 22.35 + Class<?> widest = int.class; 22.36 + 22.37 + for (int index = 0; index < array.length; index++) { 22.38 + final long value = array[index]; 22.39 + 22.40 + if (widest == int.class && JSType.isRepresentableAsInt(value)) { 22.41 + arrayData = arrayData.set(index, (int) value, false); 22.42 + } else if (widest != Object.class && JSType.isRepresentableAsDouble(value)) { 22.43 + arrayData = arrayData.set(index, (double) value, false); 22.44 + widest = double.class; 22.45 + } else { 22.46 + arrayData = arrayData.set(index, (Object) value, false); 22.47 + widest = Object.class; 22.48 + } 22.49 + } 22.50 + 22.51 + this.setArray(arrayData); 22.52 } 22.53 22.54 NativeArray(final Object[] array) { 22.55 @@ -188,7 +205,7 @@ 22.56 @Override 22.57 public MethodHandle call() { 22.58 return Bootstrap.createDynamicInvoker("dyn:call", rtype, Object.class, Object.class, Object.class, 22.59 - long.class, Object.class); 22.60 + double.class, Object.class); 22.61 } 22.62 }); 22.63 } 22.64 @@ -219,7 +236,7 @@ 22.65 @Override 22.66 public MethodHandle call() { 22.67 return Bootstrap.createDynamicInvoker("dyn:call", Object.class, Object.class, 22.68 - Undefined.class, Object.class, Object.class, long.class, Object.class); 22.69 + Undefined.class, Object.class, Object.class, double.class, Object.class); 22.70 } 22.71 }); 22.72 } 22.73 @@ -255,8 +272,9 @@ 22.74 22.75 @Override 22.76 public Object getLength() { 22.77 - final long length = JSType.toUint32(getArray().length()); 22.78 - if (length < Integer.MAX_VALUE) { 22.79 + final long length = getArray().length(); 22.80 + assert length >= 0L; 22.81 + if (length <= Integer.MAX_VALUE) { 22.82 return (int)length; 22.83 } 22.84 return length; 22.85 @@ -274,8 +292,8 @@ 22.86 // Step 3c and 3d - get new length and convert to long 22.87 final long newLen = NativeArray.validLength(newLenDesc.getValue()); 22.88 22.89 - // Step 3e 22.90 - newLenDesc.setValue(newLen); 22.91 + // Step 3e - note that we need to convert to int or double as long is not considered a JS number type anymore 22.92 + newLenDesc.setValue(JSType.toNarrowestNumber(newLen)); 22.93 22.94 // Step 3f 22.95 // increasing array length - just need to set new length value (and attributes if any) and return 22.96 @@ -454,7 +472,13 @@ 22.97 @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE) 22.98 public static Object length(final Object self) { 22.99 if (isArray(self)) { 22.100 - return JSType.toUint32(((ScriptObject) self).getArray().length()); 22.101 + final long length = ((ScriptObject) self).getArray().length(); 22.102 + assert length >= 0L; 22.103 + // Cast to the narrowest supported numeric type to help optimistic type calculator 22.104 + if (length <= Integer.MAX_VALUE) { 22.105 + return (int) length; 22.106 + } 22.107 + return (double) length; 22.108 } 22.109 22.110 return 0; 22.111 @@ -902,21 +926,6 @@ 22.112 * @throws ClassCastException if array is empty, facilitating Undefined return value 22.113 */ 22.114 @SpecializedFunction(name="pop", linkLogic=PopLinkLogic.class) 22.115 - public static long popLong(final Object self) { 22.116 - //must be non empty Int or LongArrayData 22.117 - return getContinuousNonEmptyArrayDataCCE(self, IntOrLongElements.class).fastPopLong(); 22.118 - } 22.119 - 22.120 - /** 22.121 - * Specialization of pop for ContinuousArrayData 22.122 - * 22.123 - * Primitive specialization, {@link LinkLogic} 22.124 - * 22.125 - * @param self self reference 22.126 - * @return element popped 22.127 - * @throws ClassCastException if array is empty, facilitating Undefined return value 22.128 - */ 22.129 - @SpecializedFunction(name="pop", linkLogic=PopLinkLogic.class) 22.130 public static double popDouble(final Object self) { 22.131 //must be non empty int long or double array data 22.132 return getContinuousNonEmptyArrayDataCCE(self, NumericElements.class).fastPopDouble(); 22.133 @@ -981,7 +990,7 @@ 22.134 * @return array length after push 22.135 */ 22.136 @SpecializedFunction(linkLogic=PushLinkLogic.class) 22.137 - public static long push(final Object self, final int arg) { 22.138 + public static double push(final Object self, final int arg) { 22.139 return getContinuousArrayDataCCE(self, Integer.class).fastPush(arg); 22.140 } 22.141 22.142 @@ -995,7 +1004,7 @@ 22.143 * @return array length after push 22.144 */ 22.145 @SpecializedFunction(linkLogic=PushLinkLogic.class) 22.146 - public static long push(final Object self, final long arg) { 22.147 + public static double push(final Object self, final long arg) { 22.148 return getContinuousArrayDataCCE(self, Long.class).fastPush(arg); 22.149 } 22.150 22.151 @@ -1009,7 +1018,7 @@ 22.152 * @return array length after push 22.153 */ 22.154 @SpecializedFunction(linkLogic=PushLinkLogic.class) 22.155 - public static long push(final Object self, final double arg) { 22.156 + public static double push(final Object self, final double arg) { 22.157 return getContinuousArrayDataCCE(self, Double.class).fastPush(arg); 22.158 } 22.159 22.160 @@ -1023,7 +1032,7 @@ 22.161 * @return array length after push 22.162 */ 22.163 @SpecializedFunction(name="push", linkLogic=PushLinkLogic.class) 22.164 - public static long pushObject(final Object self, final Object arg) { 22.165 + public static double pushObject(final Object self, final Object arg) { 22.166 return getContinuousArrayDataCCE(self, Object.class).fastPush(arg); 22.167 } 22.168 22.169 @@ -1042,7 +1051,7 @@ 22.170 if (bulkable(sobj) && sobj.getArray().length() + args.length <= JSType.MAX_UINT) { 22.171 final ArrayData newData = sobj.getArray().push(true, args); 22.172 sobj.setArray(newData); 22.173 - return newData.length(); 22.174 + return JSType.toNarrowestNumber(newData.length()); 22.175 } 22.176 22.177 long len = JSType.toUint32(sobj.getLength()); 22.178 @@ -1051,7 +1060,7 @@ 22.179 } 22.180 sobj.set("length", len, CALLSITE_STRICT); 22.181 22.182 - return len; 22.183 + return JSType.toNarrowestNumber(len); 22.184 } catch (final ClassCastException | NullPointerException e) { 22.185 throw typeError(Context.getGlobal(), e, "not.an.object", ScriptRuntime.safeToString(self)); 22.186 } 22.187 @@ -1065,7 +1074,7 @@ 22.188 * @return array after pushes 22.189 */ 22.190 @SpecializedFunction 22.191 - public static long push(final Object self, final Object arg) { 22.192 + public static double push(final Object self, final Object arg) { 22.193 try { 22.194 final ScriptObject sobj = (ScriptObject)self; 22.195 final ArrayData arrayData = sobj.getArray(); 22.196 @@ -1470,7 +1479,7 @@ 22.197 final long newLength = len + items.length; 22.198 sobj.set("length", newLength, CALLSITE_STRICT); 22.199 22.200 - return newLength; 22.201 + return JSType.toNarrowestNumber(newLength); 22.202 } 22.203 22.204 /** 22.205 @@ -1482,7 +1491,7 @@ 22.206 * @return index of element, or -1 if not found 22.207 */ 22.208 @Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1) 22.209 - public static long indexOf(final Object self, final Object searchElement, final Object fromIndex) { 22.210 + public static double indexOf(final Object self, final Object searchElement, final Object fromIndex) { 22.211 try { 22.212 final ScriptObject sobj = (ScriptObject)Global.toObject(self); 22.213 final long len = JSType.toUint32(sobj.getLength()); 22.214 @@ -1518,7 +1527,7 @@ 22.215 * @return index of element, or -1 if not found 22.216 */ 22.217 @Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1) 22.218 - public static long lastIndexOf(final Object self, final Object... args) { 22.219 + public static double lastIndexOf(final Object self, final Object... args) { 22.220 try { 22.221 final ScriptObject sobj = (ScriptObject)Global.toObject(self); 22.222 final long len = JSType.toUint32(sobj.getLength()); 22.223 @@ -1562,7 +1571,7 @@ 22.224 private final MethodHandle everyInvoker = getEVERY_CALLBACK_INVOKER(); 22.225 22.226 @Override 22.227 - protected boolean forEach(final Object val, final long i) throws Throwable { 22.228 + protected boolean forEach(final Object val, final double i) throws Throwable { 22.229 return result = (boolean)everyInvoker.invokeExact(callbackfn, thisArg, val, i, self); 22.230 } 22.231 }.apply(); 22.232 @@ -1582,7 +1591,7 @@ 22.233 private final MethodHandle someInvoker = getSOME_CALLBACK_INVOKER(); 22.234 22.235 @Override 22.236 - protected boolean forEach(final Object val, final long i) throws Throwable { 22.237 + protected boolean forEach(final Object val, final double i) throws Throwable { 22.238 return !(result = (boolean)someInvoker.invokeExact(callbackfn, thisArg, val, i, self)); 22.239 } 22.240 }.apply(); 22.241 @@ -1602,7 +1611,7 @@ 22.242 private final MethodHandle forEachInvoker = getFOREACH_CALLBACK_INVOKER(); 22.243 22.244 @Override 22.245 - protected boolean forEach(final Object val, final long i) throws Throwable { 22.246 + protected boolean forEach(final Object val, final double i) throws Throwable { 22.247 forEachInvoker.invokeExact(callbackfn, thisArg, val, i, self); 22.248 return true; 22.249 } 22.250 @@ -1623,7 +1632,7 @@ 22.251 private final MethodHandle mapInvoker = getMAP_CALLBACK_INVOKER(); 22.252 22.253 @Override 22.254 - protected boolean forEach(final Object val, final long i) throws Throwable { 22.255 + protected boolean forEach(final Object val, final double i) throws Throwable { 22.256 final Object r = mapInvoker.invokeExact(callbackfn, thisArg, val, i, self); 22.257 result.defineOwnProperty(ArrayIndex.getArrayIndex(index), r); 22.258 return true; 22.259 @@ -1653,7 +1662,7 @@ 22.260 private final MethodHandle filterInvoker = getFILTER_CALLBACK_INVOKER(); 22.261 22.262 @Override 22.263 - protected boolean forEach(final Object val, final long i) throws Throwable { 22.264 + protected boolean forEach(final Object val, final double i) throws Throwable { 22.265 if ((boolean)filterInvoker.invokeExact(callbackfn, thisArg, val, i, self)) { 22.266 result.defineOwnProperty(ArrayIndex.getArrayIndex(to++), val); 22.267 } 22.268 @@ -1685,7 +1694,7 @@ 22.269 private final MethodHandle reduceInvoker = getREDUCE_CALLBACK_INVOKER(); 22.270 22.271 @Override 22.272 - protected boolean forEach(final Object val, final long i) throws Throwable { 22.273 + protected boolean forEach(final Object val, final double i) throws Throwable { 22.274 // TODO: why can't I declare the second arg as Undefined.class? 22.275 result = reduceInvoker.invokeExact(callbackfn, ScriptRuntime.UNDEFINED, result, val, i, self); 22.276 return true;
23.1 --- a/src/jdk/nashorn/internal/objects/NativeDate.java Tue Jan 26 11:36:10 2016 -0800 23.2 +++ b/src/jdk/nashorn/internal/objects/NativeDate.java Fri Feb 05 23:32:52 2016 -0800 23.3 @@ -256,8 +256,9 @@ 23.4 * @return a Date that points to the current moment in time 23.5 */ 23.6 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) 23.7 - public static long now(final Object self) { 23.8 - return System.currentTimeMillis(); 23.9 + public static double now(final Object self) { 23.10 + // convert to double as long does not represent the primitive JS number type 23.11 + return (double) System.currentTimeMillis(); 23.12 } 23.13 23.14 /**
24.1 --- a/src/jdk/nashorn/internal/objects/NativeFloat32Array.java Tue Jan 26 11:36:10 2016 -0800 24.2 +++ b/src/jdk/nashorn/internal/objects/NativeFloat32Array.java Fri Feb 05 23:32:52 2016 -0800 24.3 @@ -124,7 +124,7 @@ 24.4 24.5 @Override 24.6 public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) { 24.7 - if (returnType == int.class || returnType == long.class) { 24.8 + if (returnType == int.class) { 24.9 return null; 24.10 } 24.11 return getContinuousElementGetter(getClass(), GET_ELEM, returnType, programPoint); 24.12 @@ -136,11 +136,6 @@ 24.13 } 24.14 24.15 @Override 24.16 - public long getLong(final int index) { 24.17 - return (long)getDouble(index); 24.18 - } 24.19 - 24.20 - @Override 24.21 public double getDouble(final int index) { 24.22 return getElem(index); 24.23 } 24.24 @@ -166,11 +161,6 @@ 24.25 } 24.26 24.27 @Override 24.28 - public ArrayData set(final int index, final long value, final boolean strict) { 24.29 - return set(index, (double)value, strict); 24.30 - } 24.31 - 24.32 - @Override 24.33 public ArrayData set(final int index, final double value, final boolean strict) { 24.34 setElem(index, value); 24.35 return this;
25.1 --- a/src/jdk/nashorn/internal/objects/NativeFloat64Array.java Tue Jan 26 11:36:10 2016 -0800 25.2 +++ b/src/jdk/nashorn/internal/objects/NativeFloat64Array.java Fri Feb 05 23:32:52 2016 -0800 25.3 @@ -124,7 +124,7 @@ 25.4 25.5 @Override 25.6 public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) { 25.7 - if (returnType == int.class || returnType == long.class) { 25.8 + if (returnType == int.class) { 25.9 return null; 25.10 } 25.11 return getContinuousElementGetter(getClass(), GET_ELEM, returnType, programPoint); 25.12 @@ -136,11 +136,6 @@ 25.13 } 25.14 25.15 @Override 25.16 - public long getLong(final int index) { 25.17 - return (long)getDouble(index); 25.18 - } 25.19 - 25.20 - @Override 25.21 public double getDouble(final int index) { 25.22 return getElem(index); 25.23 } 25.24 @@ -166,11 +161,6 @@ 25.25 } 25.26 25.27 @Override 25.28 - public ArrayData set(final int index, final long value, final boolean strict) { 25.29 - return set(index, (double)value, strict); 25.30 - } 25.31 - 25.32 - @Override 25.33 public ArrayData set(final int index, final double value, final boolean strict) { 25.34 setElem(index, value); 25.35 return this;
26.1 --- a/src/jdk/nashorn/internal/objects/NativeInt16Array.java Tue Jan 26 11:36:10 2016 -0800 26.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt16Array.java Fri Feb 05 23:32:52 2016 -0800 26.3 @@ -134,16 +134,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 @@ -170,11 +160,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/NativeInt32Array.java Tue Jan 26 11:36:10 2016 -0800 27.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt32Array.java Fri Feb 05 23:32:52 2016 -0800 27.3 @@ -133,16 +133,6 @@ 27.4 } 27.5 27.6 @Override 27.7 - public long getLong(final int index) { 27.8 - return getInt(index); 27.9 - } 27.10 - 27.11 - @Override 27.12 - public long getLongOptimistic(final int index, final int programPoint) { 27.13 - return getElem(index); 27.14 - } 27.15 - 27.16 - @Override 27.17 public double getDouble(final int index) { 27.18 return getInt(index); 27.19 } 27.20 @@ -169,11 +159,6 @@ 27.21 } 27.22 27.23 @Override 27.24 - public ArrayData set(final int index, final long value, final boolean strict) { 27.25 - return set(index, (int)value, strict); 27.26 - } 27.27 - 27.28 - @Override 27.29 public ArrayData set(final int index, final double value, final boolean strict) { 27.30 return set(index, (int)value, strict); 27.31 }
28.1 --- a/src/jdk/nashorn/internal/objects/NativeInt8Array.java Tue Jan 26 11:36:10 2016 -0800 28.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt8Array.java Fri Feb 05 23:32:52 2016 -0800 28.3 @@ -132,16 +132,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 @@ -168,11 +158,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/NativeJSAdapter.java Tue Jan 26 11:36:10 2016 -0800 29.2 +++ b/src/jdk/nashorn/internal/objects/NativeJSAdapter.java Fri Feb 05 23:32:52 2016 -0800 29.3 @@ -179,36 +179,11 @@ 29.4 } 29.5 29.6 @Override 29.7 - public int getInt(final long key, final int programPoint) { 29.8 - return (overrides && super.hasOwnProperty(key)) ? super.getInt(key, programPoint) : callAdapteeInt(programPoint, __get__, key); 29.9 - } 29.10 - 29.11 - @Override 29.12 public int getInt(final int key, final int programPoint) { 29.13 return (overrides && super.hasOwnProperty(key)) ? super.getInt(key, programPoint) : callAdapteeInt(programPoint, __get__, key); 29.14 } 29.15 29.16 @Override 29.17 - public long getLong(final Object key, final int programPoint) { 29.18 - return (overrides && super.hasOwnProperty(key)) ? super.getLong(key, programPoint) : callAdapteeLong(programPoint, __get__, key); 29.19 - } 29.20 - 29.21 - @Override 29.22 - public long getLong(final double key, final int programPoint) { 29.23 - return (overrides && super.hasOwnProperty(key)) ? super.getLong(key, programPoint) : callAdapteeLong(programPoint, __get__, key); 29.24 - } 29.25 - 29.26 - @Override 29.27 - public long getLong(final long key, final int programPoint) { 29.28 - return (overrides && super.hasOwnProperty(key)) ? super.getLong(key, programPoint) : callAdapteeLong(programPoint, __get__, key); 29.29 - } 29.30 - 29.31 - @Override 29.32 - public long getLong(final int key, final int programPoint) { 29.33 - return (overrides && super.hasOwnProperty(key)) ? super.getLong(key, programPoint) : callAdapteeLong(programPoint, __get__, key); 29.34 - } 29.35 - 29.36 - @Override 29.37 public double getDouble(final Object key, final int programPoint) { 29.38 return (overrides && super.hasOwnProperty(key)) ? super.getDouble(key, programPoint) : callAdapteeDouble(programPoint, __get__, key); 29.39 } 29.40 @@ -219,11 +194,6 @@ 29.41 } 29.42 29.43 @Override 29.44 - public double getDouble(final long key, final int programPoint) { 29.45 - return (overrides && super.hasOwnProperty(key)) ? super.getDouble(key, programPoint) : callAdapteeDouble(programPoint, __get__, key); 29.46 - } 29.47 - 29.48 - @Override 29.49 public double getDouble(final int key, final int programPoint) { 29.50 return (overrides && super.hasOwnProperty(key)) ? super.getDouble(key, programPoint) : callAdapteeDouble(programPoint, __get__, key); 29.51 } 29.52 @@ -239,11 +209,6 @@ 29.53 } 29.54 29.55 @Override 29.56 - public Object get(final long key) { 29.57 - return (overrides && super.hasOwnProperty(key)) ? super.get(key) : callAdaptee(__get__, key); 29.58 - } 29.59 - 29.60 - @Override 29.61 public Object get(final int key) { 29.62 return (overrides && super.hasOwnProperty(key)) ? super.get(key) : callAdaptee(__get__, key); 29.63 } 29.64 @@ -258,15 +223,6 @@ 29.65 } 29.66 29.67 @Override 29.68 - public void set(final Object key, final long value, final int flags) { 29.69 - if (overrides && super.hasOwnProperty(key)) { 29.70 - super.set(key, value, flags); 29.71 - } else { 29.72 - callAdaptee(__put__, key, value, flags); 29.73 - } 29.74 - } 29.75 - 29.76 - @Override 29.77 public void set(final Object key, final double value, final int flags) { 29.78 if (overrides && super.hasOwnProperty(key)) { 29.79 super.set(key, value, flags); 29.80 @@ -294,15 +250,6 @@ 29.81 } 29.82 29.83 @Override 29.84 - public void set(final double key, final long value, final int flags) { 29.85 - if (overrides && super.hasOwnProperty(key)) { 29.86 - super.set(key, value, flags); 29.87 - } else { 29.88 - callAdaptee(__put__, key, value, flags); 29.89 - } 29.90 - } 29.91 - 29.92 - @Override 29.93 public void set(final double key, final double value, final int flags) { 29.94 if (overrides && super.hasOwnProperty(key)) { 29.95 super.set(key, value, flags); 29.96 @@ -321,42 +268,6 @@ 29.97 } 29.98 29.99 @Override 29.100 - public void set(final long key, final int value, final int flags) { 29.101 - if (overrides && super.hasOwnProperty(key)) { 29.102 - super.set(key, value, flags); 29.103 - } else { 29.104 - callAdaptee(__put__, key, value, flags); 29.105 - } 29.106 - } 29.107 - 29.108 - @Override 29.109 - public void set(final long key, final long value, final int flags) { 29.110 - if (overrides && super.hasOwnProperty(key)) { 29.111 - super.set(key, value, flags); 29.112 - } else { 29.113 - callAdaptee(__put__, key, value, flags); 29.114 - } 29.115 - } 29.116 - 29.117 - @Override 29.118 - public void set(final long key, final double value, final int flags) { 29.119 - if (overrides && super.hasOwnProperty(key)) { 29.120 - super.set(key, value, flags); 29.121 - } else { 29.122 - callAdaptee(__put__, key, value, flags); 29.123 - } 29.124 - } 29.125 - 29.126 - @Override 29.127 - public void set(final long key, final Object value, final int flags) { 29.128 - if (overrides && super.hasOwnProperty(key)) { 29.129 - super.set(key, value, flags); 29.130 - } else { 29.131 - callAdaptee(__put__, key, value, flags); 29.132 - } 29.133 - } 29.134 - 29.135 - @Override 29.136 public void set(final int key, final int value, final int flags) { 29.137 if (overrides && super.hasOwnProperty(key)) { 29.138 super.set(key, value, flags); 29.139 @@ -366,15 +277,6 @@ 29.140 } 29.141 29.142 @Override 29.143 - public void set(final int key, final long value, final int flags) { 29.144 - if (overrides && super.hasOwnProperty(key)) { 29.145 - super.set(key, value, flags); 29.146 - } else { 29.147 - callAdaptee(__put__, key, value, flags); 29.148 - } 29.149 - } 29.150 - 29.151 - @Override 29.152 public void set(final int key, final double value, final int flags) { 29.153 if (overrides && super.hasOwnProperty(key)) { 29.154 super.set(key, value, flags); 29.155 @@ -411,15 +313,6 @@ 29.156 } 29.157 29.158 @Override 29.159 - public boolean has(final long key) { 29.160 - if (overrides && super.hasOwnProperty(key)) { 29.161 - return true; 29.162 - } 29.163 - 29.164 - return JSType.toBoolean(callAdaptee(Boolean.FALSE, __has__, key)); 29.165 - } 29.166 - 29.167 - @Override 29.168 public boolean has(final double key) { 29.169 if (overrides && super.hasOwnProperty(key)) { 29.170 return true; 29.171 @@ -438,15 +331,6 @@ 29.172 } 29.173 29.174 @Override 29.175 - public boolean delete(final long key, final boolean strict) { 29.176 - if (overrides && super.hasOwnProperty(key)) { 29.177 - return super.delete(key, strict); 29.178 - } 29.179 - 29.180 - return JSType.toBoolean(callAdaptee(Boolean.TRUE, __delete__, key, strict)); 29.181 - } 29.182 - 29.183 - @Override 29.184 public boolean delete(final double key, final boolean strict) { 29.185 if (overrides && super.hasOwnProperty(key)) { 29.186 return super.delete(key, strict); 29.187 @@ -663,10 +547,6 @@ 29.188 return JSType.toNumberMaybeOptimistic(callAdaptee(name, args), programPoint); 29.189 } 29.190 29.191 - private long callAdapteeLong(final int programPoint, final String name, final Object... args) { 29.192 - return JSType.toLongMaybeOptimistic(callAdaptee(name, args), programPoint); 29.193 - } 29.194 - 29.195 private int callAdapteeInt(final int programPoint, final String name, final Object... args) { 29.196 return JSType.toInt32MaybeOptimistic(callAdaptee(name, args), programPoint); 29.197 }
30.1 --- a/src/jdk/nashorn/internal/objects/NativeNumber.java Tue Jan 26 11:36:10 2016 -0800 30.2 +++ b/src/jdk/nashorn/internal/objects/NativeNumber.java Fri Feb 05 23:32:52 2016 -0800 30.3 @@ -49,6 +49,7 @@ 30.4 import jdk.nashorn.internal.runtime.PropertyMap; 30.5 import jdk.nashorn.internal.runtime.ScriptObject; 30.6 import jdk.nashorn.internal.runtime.ScriptRuntime; 30.7 +import jdk.nashorn.internal.runtime.linker.NashornGuards; 30.8 import jdk.nashorn.internal.runtime.linker.PrimitiveLookup; 30.9 30.10 /** 30.11 @@ -322,7 +323,7 @@ 30.12 * @return Link to be invoked at call site. 30.13 */ 30.14 public static GuardedInvocation lookupPrimitive(final LinkRequest request, final Object receiver) { 30.15 - return PrimitiveLookup.lookupPrimitive(request, Number.class, new NativeNumber(((Number)receiver).doubleValue()), WRAPFILTER, PROTOFILTER); 30.16 + return PrimitiveLookup.lookupPrimitive(request, NashornGuards.getNumberGuard(), new NativeNumber(((Number)receiver).doubleValue()), WRAPFILTER, PROTOFILTER); 30.17 } 30.18 30.19 @SuppressWarnings("unused")
31.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Tue Jan 26 11:36:10 2016 -0800 31.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Fri Feb 05 23:32:52 2016 -0800 31.3 @@ -74,7 +74,7 @@ 31.4 @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE) 31.5 public static Object length(final Object self) { 31.6 if (self instanceof ScriptObject) { 31.7 - return JSType.toUint32(((ScriptObject)self).getArray().length()); 31.8 + return (double) JSType.toUint32(((ScriptObject)self).getArray().length()); 31.9 } 31.10 31.11 return 0;
32.1 --- a/src/jdk/nashorn/internal/objects/NativeString.java Tue Jan 26 11:36:10 2016 -0800 32.2 +++ b/src/jdk/nashorn/internal/objects/NativeString.java Fri Feb 05 23:32:52 2016 -0800 32.3 @@ -157,7 +157,7 @@ 32.4 32.5 if (returnType == Object.class && JSType.isString(self)) { 32.6 try { 32.7 - return new GuardedInvocation(MH.findStatic(MethodHandles.lookup(), NativeString.class, "get", desc.getMethodType()), NashornGuards.getInstanceOf2Guard(String.class, ConsString.class)); 32.8 + return new GuardedInvocation(MH.findStatic(MethodHandles.lookup(), NativeString.class, "get", desc.getMethodType()), NashornGuards.getStringGuard()); 32.9 } catch (final LookupException e) { 32.10 //empty. Shouldn't happen. Fall back to super 32.11 } 32.12 @@ -221,14 +221,6 @@ 32.13 } 32.14 32.15 @Override 32.16 - public Object get(final long key) { 32.17 - if (key >= 0 && key < value.length()) { 32.18 - return String.valueOf(value.charAt((int)key)); 32.19 - } 32.20 - return super.get(key); 32.21 - } 32.22 - 32.23 - @Override 32.24 public Object get(final int key) { 32.25 if (key >= 0 && key < value.length()) { 32.26 return String.valueOf(value.charAt(key)); 32.27 @@ -247,36 +239,11 @@ 32.28 } 32.29 32.30 @Override 32.31 - public int getInt(final long key, final int programPoint) { 32.32 - return JSType.toInt32MaybeOptimistic(get(key), programPoint); 32.33 - } 32.34 - 32.35 - @Override 32.36 public int getInt(final int key, final int programPoint) { 32.37 return JSType.toInt32MaybeOptimistic(get(key), programPoint); 32.38 } 32.39 32.40 @Override 32.41 - public long getLong(final Object key, final int programPoint) { 32.42 - return JSType.toLongMaybeOptimistic(get(key), programPoint); 32.43 - } 32.44 - 32.45 - @Override 32.46 - public long getLong(final double key, final int programPoint) { 32.47 - return JSType.toLongMaybeOptimistic(get(key), programPoint); 32.48 - } 32.49 - 32.50 - @Override 32.51 - public long getLong(final long key, final int programPoint) { 32.52 - return JSType.toLongMaybeOptimistic(get(key), programPoint); 32.53 - } 32.54 - 32.55 - @Override 32.56 - public long getLong(final int key, final int programPoint) { 32.57 - return JSType.toLongMaybeOptimistic(get(key), programPoint); 32.58 - } 32.59 - 32.60 - @Override 32.61 public double getDouble(final Object key, final int programPoint) { 32.62 return JSType.toNumberMaybeOptimistic(get(key), programPoint); 32.63 } 32.64 @@ -287,11 +254,6 @@ 32.65 } 32.66 32.67 @Override 32.68 - public double getDouble(final long key, final int programPoint) { 32.69 - return JSType.toNumberMaybeOptimistic(get(key), programPoint); 32.70 - } 32.71 - 32.72 - @Override 32.73 public double getDouble(final int key, final int programPoint) { 32.74 return JSType.toNumberMaybeOptimistic(get(key), programPoint); 32.75 } 32.76 @@ -309,12 +271,6 @@ 32.77 } 32.78 32.79 @Override 32.80 - public boolean has(final long key) { 32.81 - final int index = ArrayIndex.getArrayIndex(key); 32.82 - return isValidStringIndex(index) || super.has(key); 32.83 - } 32.84 - 32.85 - @Override 32.86 public boolean has(final double key) { 32.87 final int index = ArrayIndex.getArrayIndex(key); 32.88 return isValidStringIndex(index) || super.has(key); 32.89 @@ -333,12 +289,6 @@ 32.90 } 32.91 32.92 @Override 32.93 - public boolean hasOwnProperty(final long key) { 32.94 - final int index = ArrayIndex.getArrayIndex(key); 32.95 - return isValidStringIndex(index) || super.hasOwnProperty(key); 32.96 - } 32.97 - 32.98 - @Override 32.99 public boolean hasOwnProperty(final double key) { 32.100 final int index = ArrayIndex.getArrayIndex(key); 32.101 return isValidStringIndex(index) || super.hasOwnProperty(key); 32.102 @@ -350,12 +300,6 @@ 32.103 } 32.104 32.105 @Override 32.106 - public boolean delete(final long key, final boolean strict) { 32.107 - final int index = ArrayIndex.getArrayIndex(key); 32.108 - return checkDeleteIndex(index, strict)? false : super.delete(key, strict); 32.109 - } 32.110 - 32.111 - @Override 32.112 public boolean delete(final double key, final boolean strict) { 32.113 final int index = ArrayIndex.getArrayIndex(key); 32.114 return checkDeleteIndex(index, strict)? false : super.delete(key, strict); 32.115 @@ -1297,8 +1241,8 @@ 32.116 * @return Link to be invoked at call site. 32.117 */ 32.118 public static GuardedInvocation lookupPrimitive(final LinkRequest request, final Object receiver) { 32.119 - final MethodHandle guard = NashornGuards.getInstanceOf2Guard(String.class, ConsString.class); 32.120 - return PrimitiveLookup.lookupPrimitive(request, guard, new NativeString((CharSequence)receiver), WRAPFILTER, PROTOFILTER); 32.121 + return PrimitiveLookup.lookupPrimitive(request, NashornGuards.getStringGuard(), 32.122 + new NativeString((CharSequence)receiver), WRAPFILTER, PROTOFILTER); 32.123 } 32.124 32.125 @SuppressWarnings("unused")
33.1 --- a/src/jdk/nashorn/internal/objects/NativeUint16Array.java Tue Jan 26 11:36:10 2016 -0800 33.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint16Array.java Fri Feb 05 23:32:52 2016 -0800 33.3 @@ -138,16 +138,6 @@ 33.4 } 33.5 33.6 @Override 33.7 - public long getLong(final int index) { 33.8 - return getInt(index); 33.9 - } 33.10 - 33.11 - @Override 33.12 - public long getLongOptimistic(final int index, final int programPoint) { 33.13 - return getElem(index); 33.14 - } 33.15 - 33.16 - @Override 33.17 public double getDouble(final int index) { 33.18 return getInt(index); 33.19 } 33.20 @@ -174,11 +164,6 @@ 33.21 } 33.22 33.23 @Override 33.24 - public ArrayData set(final int index, final long value, final boolean strict) { 33.25 - return set(index, (int)value, strict); 33.26 - } 33.27 - 33.28 - @Override 33.29 public ArrayData set(final int index, final double value, final boolean strict) { 33.30 return set(index, (int)value, strict); 33.31 }
34.1 --- a/src/jdk/nashorn/internal/objects/NativeUint32Array.java Tue Jan 26 11:36:10 2016 -0800 34.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint32Array.java Fri Feb 05 23:32:52 2016 -0800 34.3 @@ -32,6 +32,7 @@ 34.4 import java.nio.ByteBuffer; 34.5 import java.nio.ByteOrder; 34.6 import java.nio.IntBuffer; 34.7 +import jdk.nashorn.internal.codegen.types.Type; 34.8 import jdk.nashorn.internal.objects.annotations.Attribute; 34.9 import jdk.nashorn.internal.objects.annotations.Constructor; 34.10 import jdk.nashorn.internal.objects.annotations.Function; 34.11 @@ -41,6 +42,7 @@ 34.12 import jdk.nashorn.internal.runtime.JSType; 34.13 import jdk.nashorn.internal.runtime.PropertyMap; 34.14 import jdk.nashorn.internal.runtime.ScriptObject; 34.15 +import jdk.nashorn.internal.runtime.UnwarrantedOptimismException; 34.16 import jdk.nashorn.internal.runtime.arrays.ArrayData; 34.17 import jdk.nashorn.internal.runtime.arrays.TypedArrayData; 34.18 34.19 @@ -78,7 +80,7 @@ 34.20 34.21 private static final class Uint32ArrayData extends TypedArrayData<IntBuffer> { 34.22 34.23 - private static final MethodHandle GET_ELEM = specialCall(MethodHandles.lookup(), Uint32ArrayData.class, "getElem", long.class, int.class).methodHandle(); 34.24 + private static final MethodHandle GET_ELEM = specialCall(MethodHandles.lookup(), Uint32ArrayData.class, "getElem", double.class, int.class).methodHandle(); 34.25 private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint32ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle(); 34.26 34.27 private Uint32ArrayData(final IntBuffer nb, final int start, final int end) { 34.28 @@ -103,14 +105,18 @@ 34.29 return getContinuousElementGetter(getClass(), GET_ELEM, returnType, programPoint); 34.30 } 34.31 34.32 - private long getElem(final int index) { 34.33 + private int getRawElem(final int index) { 34.34 try { 34.35 - return JSType.toUint32(nb.get(index)); 34.36 + return nb.get(index); 34.37 } catch (final IndexOutOfBoundsException e) { 34.38 throw new ClassCastException(); //force relink - this works for unoptimistic too 34.39 } 34.40 } 34.41 34.42 + private double getElem(final int index) { 34.43 + return JSType.toUint32(getRawElem(index)); 34.44 + } 34.45 + 34.46 private void setElem(final int index, final int elem) { 34.47 try { 34.48 if (index < nb.limit()) { 34.49 @@ -128,42 +134,37 @@ 34.50 34.51 @Override 34.52 public Class<?> getElementType() { 34.53 - return long.class; 34.54 + return double.class; 34.55 } 34.56 34.57 @Override 34.58 public Class<?> getBoxedElementType() { 34.59 - return Integer.class; 34.60 + return Double.class; 34.61 } 34.62 34.63 @Override 34.64 public int getInt(final int index) { 34.65 - return (int)getLong(index); 34.66 + return getRawElem(index); 34.67 } 34.68 34.69 @Override 34.70 - public long getLong(final int index) { 34.71 + public int getIntOptimistic(final int index, final int programPoint) { 34.72 + return JSType.toUint32Optimistic(getRawElem(index), programPoint); 34.73 + } 34.74 + 34.75 + @Override 34.76 + public double getDouble(final int index) { 34.77 return getElem(index); 34.78 } 34.79 34.80 @Override 34.81 - public long getLongOptimistic(final int index, final int programPoint) { 34.82 + public double getDoubleOptimistic(final int index, final int programPoint) { 34.83 return getElem(index); 34.84 } 34.85 34.86 @Override 34.87 - public double getDouble(final int index) { 34.88 - return getLong(index); 34.89 - } 34.90 - 34.91 - @Override 34.92 - public double getDoubleOptimistic(final int index, final int programPoint) { 34.93 - return getLong(index); 34.94 - } 34.95 - 34.96 - @Override 34.97 public Object getObject(final int index) { 34.98 - return getLong(index); 34.99 + return getElem(index); 34.100 } 34.101 34.102 @Override 34.103 @@ -178,11 +179,6 @@ 34.104 } 34.105 34.106 @Override 34.107 - public ArrayData set(final int index, final long value, final boolean strict) { 34.108 - return set(index, (int)value, strict); 34.109 - } 34.110 - 34.111 - @Override 34.112 public ArrayData set(final int index, final double value, final boolean strict) { 34.113 return set(index, (int)value, strict); 34.114 }
35.1 --- a/src/jdk/nashorn/internal/objects/NativeUint8Array.java Tue Jan 26 11:36:10 2016 -0800 35.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint8Array.java Fri Feb 05 23:32:52 2016 -0800 35.3 @@ -138,16 +138,6 @@ 35.4 } 35.5 35.6 @Override 35.7 - public long getLong(final int index) { 35.8 - return getInt(index); 35.9 - } 35.10 - 35.11 - @Override 35.12 - public long getLongOptimistic(final int index, final int programPoint) { 35.13 - return getElem(index); 35.14 - } 35.15 - 35.16 - @Override 35.17 public double getDouble(final int index) { 35.18 return getInt(index); 35.19 } 35.20 @@ -174,11 +164,6 @@ 35.21 } 35.22 35.23 @Override 35.24 - public ArrayData set(final int index, final long value, final boolean strict) { 35.25 - return set(index, (int)value, strict); 35.26 - } 35.27 - 35.28 - @Override 35.29 public ArrayData set(final int index, final double value, final boolean strict) { 35.30 return set(index, (int)value, strict); 35.31 }
36.1 --- a/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Tue Jan 26 11:36:10 2016 -0800 36.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Fri Feb 05 23:32:52 2016 -0800 36.3 @@ -168,16 +168,6 @@ 36.4 } 36.5 36.6 @Override 36.7 - public long getLong(final int index) { 36.8 - return getInt(index); 36.9 - } 36.10 - 36.11 - @Override 36.12 - public long getLongOptimistic(final int index, final int programPoint) { 36.13 - return getElem(index); 36.14 - } 36.15 - 36.16 - @Override 36.17 public double getDouble(final int index) { 36.18 return getInt(index); 36.19 } 36.20 @@ -204,11 +194,6 @@ 36.21 } 36.22 36.23 @Override 36.24 - public ArrayData set(final int index, final long value, final boolean strict) { 36.25 - return set(index, (int)value, strict); 36.26 - } 36.27 - 36.28 - @Override 36.29 public ArrayData set(final int index, final double value, final boolean strict) { 36.30 return set(index, rint(value), strict); 36.31 }
37.1 --- a/src/jdk/nashorn/internal/parser/JSONParser.java Tue Jan 26 11:36:10 2016 -0800 37.2 +++ b/src/jdk/nashorn/internal/parser/JSONParser.java Fri Feb 05 23:32:52 2016 -0800 37.3 @@ -293,8 +293,6 @@ 37.4 private static Class<?> getType(final Object value) { 37.5 if (value instanceof Integer) { 37.6 return int.class; 37.7 - } else if (value instanceof Long) { 37.8 - return long.class; 37.9 } else if (value instanceof Double) { 37.10 return double.class; 37.11 } else { 37.12 @@ -477,8 +475,6 @@ 37.13 final double d = Double.parseDouble(source.substring(start, pos)); 37.14 if (JSType.isRepresentableAsInt(d)) { 37.15 return (int) d; 37.16 - } else if (JSType.isRepresentableAsLong(d)) { 37.17 - return (long) d; 37.18 } 37.19 return d; 37.20 }
38.1 --- a/src/jdk/nashorn/internal/parser/Lexer.java Tue Jan 26 11:36:10 2016 -0800 38.2 +++ b/src/jdk/nashorn/internal/parser/Lexer.java Fri Feb 05 23:32:52 2016 -0800 38.3 @@ -1042,11 +1042,7 @@ 38.4 */ 38.5 private static Number valueOf(final String valueString, final int radix) throws NumberFormatException { 38.6 try { 38.7 - final long value = Long.parseLong(valueString, radix); 38.8 - if(value >= MIN_INT_L && value <= MAX_INT_L) { 38.9 - return Integer.valueOf((int)value); 38.10 - } 38.11 - return Long.valueOf(value); 38.12 + return Integer.parseInt(valueString, radix); 38.13 } catch (final NumberFormatException e) { 38.14 if (radix == 10) { 38.15 return Double.valueOf(valueString); 38.16 @@ -1655,8 +1651,6 @@ 38.17 //yet we don't want e.g. 1e6 to be a double unnecessarily 38.18 if (JSType.isStrictlyRepresentableAsInt(value)) { 38.19 return (int)value; 38.20 - } else if (JSType.isStrictlyRepresentableAsLong(value)) { 38.21 - return (long)value; 38.22 } 38.23 return value; 38.24 case STRING:
39.1 --- a/src/jdk/nashorn/internal/runtime/AccessorProperty.java Tue Jan 26 11:36:10 2016 -0800 39.2 +++ b/src/jdk/nashorn/internal/runtime/AccessorProperty.java Fri Feb 05 23:32:52 2016 -0800 39.3 @@ -221,7 +221,7 @@ 39.4 39.5 assert setterType == null || setterType == getterType; 39.6 39.7 - if (getterType == int.class || getterType == long.class) { 39.8 + if (getterType == int.class) { 39.9 primitiveGetter = MH.asType(getter, Lookup.GET_PRIMITIVE_TYPE); 39.10 primitiveSetter = setter == null ? null : MH.asType(setter, Lookup.SET_PRIMITIVE_TYPE); 39.11 } else if (getterType == double.class) { 39.12 @@ -400,17 +400,6 @@ 39.13 } 39.14 } 39.15 39.16 - @Override 39.17 - public long getLongValue(final ScriptObject self, final ScriptObject owner) { 39.18 - try { 39.19 - return (long)getGetter(long.class).invokeExact((Object)self); 39.20 - } catch (final Error | RuntimeException e) { 39.21 - throw e; 39.22 - } catch (final Throwable e) { 39.23 - throw new RuntimeException(e); 39.24 - } 39.25 - } 39.26 - 39.27 @Override 39.28 public double getDoubleValue(final ScriptObject self, final ScriptObject owner) { 39.29 try { 39.30 @@ -453,21 +442,6 @@ 39.31 * @param self owner 39.32 * @param value value 39.33 */ 39.34 - protected final void invokeSetter(final ScriptObject self, final long value) { 39.35 - try { 39.36 - getSetter(long.class, self.getMap()).invokeExact((Object)self, value); 39.37 - } catch (final Error | RuntimeException e) { 39.38 - throw e; 39.39 - } catch (final Throwable e) { 39.40 - throw new RuntimeException(e); 39.41 - } 39.42 - } 39.43 - 39.44 - /** 39.45 - * Invoke setter for this property with a value 39.46 - * @param self owner 39.47 - * @param value value 39.48 - */ 39.49 protected final void invokeSetter(final ScriptObject self, final double value) { 39.50 try { 39.51 getSetter(double.class, self.getMap()).invokeExact((Object)self, value); 39.52 @@ -500,12 +474,6 @@ 39.53 } 39.54 39.55 @Override 39.56 - public void setValue(final ScriptObject self, final ScriptObject owner, final long value, final boolean strict) { 39.57 - assert isConfigurable() || isWritable() : getKey() + " is not writable or configurable"; 39.58 - invokeSetter(self, value); 39.59 - } 39.60 - 39.61 - @Override 39.62 public void setValue(final ScriptObject self, final ScriptObject owner, final double value, final boolean strict) { 39.63 assert isConfigurable() || isWritable() : getKey() + " is not writable or configurable"; 39.64 invokeSetter(self, value); 39.65 @@ -533,7 +501,6 @@ 39.66 final int i = getAccessorTypeIndex(type); 39.67 39.68 assert type == int.class || 39.69 - type == long.class || 39.70 type == double.class || 39.71 type == Object.class : 39.72 "invalid getter type " + type + " for " + getKey();
40.1 --- a/src/jdk/nashorn/internal/runtime/DebuggerSupport.java Tue Jan 26 11:36:10 2016 -0800 40.2 +++ b/src/jdk/nashorn/internal/runtime/DebuggerSupport.java Fri Feb 05 23:32:52 2016 -0800 40.3 @@ -239,7 +239,7 @@ 40.4 40.5 if (ScriptObject.isArray(object)) { 40.6 sb.append('['); 40.7 - final long length = object.getLong("length", INVALID_PROGRAM_POINT); 40.8 + final long length = (long) object.getDouble("length", INVALID_PROGRAM_POINT); 40.9 40.10 for (long i = 0; i < length; i++) { 40.11 if (object.has(i)) {
41.1 --- a/src/jdk/nashorn/internal/runtime/DefaultPropertyAccess.java Tue Jan 26 11:36:10 2016 -0800 41.2 +++ b/src/jdk/nashorn/internal/runtime/DefaultPropertyAccess.java Fri Feb 05 23:32:52 2016 -0800 41.3 @@ -44,36 +44,11 @@ 41.4 } 41.5 41.6 @Override 41.7 - public int getInt(final long key, final int programPoint) { 41.8 - return getInt(JSType.toObject(key), programPoint); 41.9 - } 41.10 - 41.11 - @Override 41.12 public int getInt(final int key, final int programPoint) { 41.13 return getInt(JSType.toObject(key), programPoint); 41.14 } 41.15 41.16 @Override 41.17 - public long getLong(final Object key, final int programPoint) { 41.18 - return JSType.toLong(get(key)); 41.19 - } 41.20 - 41.21 - @Override 41.22 - public long getLong(final double key, final int programPoint) { 41.23 - return getLong(JSType.toObject(key), programPoint); 41.24 - } 41.25 - 41.26 - @Override 41.27 - public long getLong(final long key, final int programPoint) { 41.28 - return getLong(JSType.toObject(key), programPoint); 41.29 - } 41.30 - 41.31 - @Override 41.32 - public long getLong(final int key, final int programPoint) { 41.33 - return getLong(JSType.toObject(key), programPoint); 41.34 - } 41.35 - 41.36 - @Override 41.37 public double getDouble(final Object key, final int programPoint) { 41.38 return JSType.toNumber(get(key)); 41.39 } 41.40 @@ -84,11 +59,6 @@ 41.41 } 41.42 41.43 @Override 41.44 - public double getDouble(final long key, final int programPoint) { 41.45 - return getDouble(JSType.toObject(key), programPoint); 41.46 - } 41.47 - 41.48 - @Override 41.49 public double getDouble(final int key, final int programPoint) { 41.50 return getDouble(JSType.toObject(key), programPoint); 41.51 } 41.52 @@ -102,11 +72,6 @@ 41.53 } 41.54 41.55 @Override 41.56 - public Object get(final long key) { 41.57 - return get(JSType.toObject(key)); 41.58 - } 41.59 - 41.60 - @Override 41.61 public Object get(final int key) { 41.62 return get(JSType.toObject(key)); 41.63 } 41.64 @@ -117,11 +82,6 @@ 41.65 } 41.66 41.67 @Override 41.68 - public void set(final double key, final long value, final int flags) { 41.69 - set(JSType.toObject(key), JSType.toObject(value), flags); 41.70 - } 41.71 - 41.72 - @Override 41.73 public void set(final double key, final double value, final int flags) { 41.74 set(JSType.toObject(key), JSType.toObject(value), flags); 41.75 } 41.76 @@ -132,36 +92,11 @@ 41.77 } 41.78 41.79 @Override 41.80 - public void set(final long key, final int value, final int flags) { 41.81 - set(JSType.toObject(key), JSType.toObject(value), flags); 41.82 - } 41.83 - 41.84 - @Override 41.85 - public void set(final long key, final long value, final int flags) { 41.86 - set(JSType.toObject(key), JSType.toObject(value), flags); 41.87 - } 41.88 - 41.89 - @Override 41.90 - public void set(final long key, final double value, final int flags) { 41.91 - set(JSType.toObject(key), JSType.toObject(value), flags); 41.92 - } 41.93 - 41.94 - @Override 41.95 - public void set(final long key, final Object value, final int flags) { 41.96 - set(JSType.toObject(key), value, flags); 41.97 - } 41.98 - 41.99 - @Override 41.100 public void set(final int key, final int value, final int flags) { 41.101 set(JSType.toObject(key), JSType.toObject(value), flags); 41.102 } 41.103 41.104 @Override 41.105 - public void set(final int key, final long value, final int flags) { 41.106 - set(JSType.toObject(key), JSType.toObject(value), flags); 41.107 - } 41.108 - 41.109 - @Override 41.110 public void set(final int key, final double value, final int flags) { 41.111 set(JSType.toObject(key), JSType.toObject(value), flags); 41.112 } 41.113 @@ -177,11 +112,6 @@ 41.114 } 41.115 41.116 @Override 41.117 - public void set(final Object key, final long value, final int flags) { 41.118 - set(key, JSType.toObject(value), flags); 41.119 - } 41.120 - 41.121 - @Override 41.122 public void set(final Object key, final double value, final int flags) { 41.123 set(key, JSType.toObject(value), flags); 41.124 } 41.125 @@ -198,11 +128,6 @@ 41.126 } 41.127 41.128 @Override 41.129 - public boolean has(final long key) { 41.130 - return has(JSType.toObject(key)); 41.131 - } 41.132 - 41.133 - @Override 41.134 public boolean has(final double key) { 41.135 return has(JSType.toObject(key)); 41.136 } 41.137 @@ -213,11 +138,6 @@ 41.138 } 41.139 41.140 @Override 41.141 - public boolean hasOwnProperty(final long key) { 41.142 - return hasOwnProperty(JSType.toObject(key)); 41.143 - } 41.144 - 41.145 - @Override 41.146 public boolean hasOwnProperty(final double key) { 41.147 return hasOwnProperty(JSType.toObject(key)); 41.148 } 41.149 @@ -231,11 +151,6 @@ 41.150 } 41.151 41.152 @Override 41.153 - public boolean delete(final long key, final boolean strict) { 41.154 - return delete(JSType.toObject(key), strict); 41.155 - } 41.156 - 41.157 - @Override 41.158 public boolean delete(final double key, final boolean strict) { 41.159 return delete(JSType.toObject(key), strict); 41.160 }
42.1 --- a/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java Tue Jan 26 11:36:10 2016 -0800 42.2 +++ b/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java Fri Feb 05 23:32:52 2016 -0800 42.3 @@ -89,11 +89,16 @@ 42.4 } 42.5 42.6 @Override 42.7 - CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden) { 42.8 + CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, boolean linkLogicOkay) { 42.9 assert isValidCallSite(callSiteType) : callSiteType; 42.10 42.11 CompiledFunction best = null; 42.12 for (final CompiledFunction candidate: code) { 42.13 + if (!linkLogicOkay && candidate.hasLinkLogic()) { 42.14 + // Skip! Version with no link logic is desired, but this one has link logic! 42.15 + continue; 42.16 + } 42.17 + 42.18 if (!forbidden.contains(candidate) && candidate.betterThanFinal(best, callSiteType)) { 42.19 best = candidate; 42.20 }
43.1 --- a/src/jdk/nashorn/internal/runtime/FindProperty.java Tue Jan 26 11:36:10 2016 -0800 43.2 +++ b/src/jdk/nashorn/internal/runtime/FindProperty.java Fri Feb 05 23:32:52 2016 -0800 43.3 @@ -218,13 +218,6 @@ 43.4 * Get the property value from self as object. 43.5 * @return the property value 43.6 */ 43.7 - public long getLongValue() { 43.8 - return property.getLongValue(getGetterReceiver(), getOwner()); 43.9 - } 43.10 - /** 43.11 - * Get the property value from self as object. 43.12 - * @return the property value 43.13 - */ 43.14 public double getDoubleValue() { 43.15 return property.getDoubleValue(getGetterReceiver(), getOwner()); 43.16 } 43.17 @@ -252,16 +245,6 @@ 43.18 * @param value the new value 43.19 * @param strict strict flag 43.20 */ 43.21 - public void setValue(final long value, final boolean strict) { 43.22 - property.setValue(getSetterReceiver(), getOwner(), value, strict); 43.23 - } 43.24 - 43.25 - /** 43.26 - * Set the property value in self. 43.27 - * 43.28 - * @param value the new value 43.29 - * @param strict strict flag 43.30 - */ 43.31 public void setValue(final double value, final boolean strict) { 43.32 property.setValue(getSetterReceiver(), getOwner(), value, strict); 43.33 }
44.1 --- a/src/jdk/nashorn/internal/runtime/GlobalFunctions.java Tue Jan 26 11:36:10 2016 -0800 44.2 +++ b/src/jdk/nashorn/internal/runtime/GlobalFunctions.java Fri Feb 05 23:32:52 2016 -0800 44.3 @@ -48,9 +48,6 @@ 44.4 /** ParseInt - identity for ints */ 44.5 public static final MethodHandle PARSEINT_I = MH.dropArguments(MH.identity(int.class), 0, Object.class); 44.6 44.7 - /** ParseInt - identity for longs */ 44.8 - public static final MethodHandle PARSEINT_J = MH.dropArguments(MH.identity(long.class), 0, Object.class); 44.9 - 44.10 /** Methodhandle (specialized) to implementation of ECMA 15.1.2.2, parseInt */ 44.11 public static final MethodHandle PARSEINT_O = findOwnMH("parseInt", double.class, Object.class, Object.class); 44.12
45.1 --- a/src/jdk/nashorn/internal/runtime/JSType.java Tue Jan 26 11:36:10 2016 -0800 45.2 +++ b/src/jdk/nashorn/internal/runtime/JSType.java Fri Feb 05 23:32:52 2016 -0800 45.3 @@ -115,14 +115,14 @@ 45.4 public static final Call TO_INT32_D = staticCall(JSTYPE_LOOKUP, JSType.class, "toInt32", int.class, double.class); 45.5 45.6 /** JavaScript compliant conversion function from int to uint32 */ 45.7 - public static final Call TO_UINT32_I = staticCall(JSTYPE_LOOKUP, JSType.class, "toUint32", long.class, int.class); 45.8 + public static final Call TO_UINT32_OPTIMISTIC = staticCall(JSTYPE_LOOKUP, JSType.class, "toUint32Optimistic", int.class, int.class, int.class); 45.9 + 45.10 + /** JavaScript compliant conversion function from int to uint32 */ 45.11 + public static final Call TO_UINT32_DOUBLE = staticCall(JSTYPE_LOOKUP, JSType.class, "toUint32Double", double.class, int.class); 45.12 45.13 /** JavaScript compliant conversion function from Object to uint32 */ 45.14 public static final Call TO_UINT32 = staticCall(JSTYPE_LOOKUP, JSType.class, "toUint32", long.class, Object.class); 45.15 45.16 - /** JavaScript compliant conversion function from Object to long with type check */ 45.17 - public static final Call TO_LONG_OPTIMISTIC = staticCall(JSTYPE_LOOKUP, JSType.class, "toLongOptimistic", long.class, Object.class, int.class); 45.18 - 45.19 /** JavaScript compliant conversion function from number to uint32 */ 45.20 public static final Call TO_UINT32_D = staticCall(JSTYPE_LOOKUP, JSType.class, "toUint32", long.class, double.class); 45.21 45.22 @@ -168,42 +168,18 @@ 45.23 /** Negate exact exact wrapper for potentially overflowing integer operations */ 45.24 public static final Call NEGATE_EXACT = staticCall(JSTYPE_LOOKUP, JSType.class, "negateExact", int.class, int.class, int.class); 45.25 45.26 - /** Add exact wrapper for potentially overflowing long operations */ 45.27 - public static final Call ADD_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "addExact", long.class, long.class, long.class, int.class); 45.28 - 45.29 - /** Sub exact wrapper for potentially overflowing long operations */ 45.30 - public static final Call SUB_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "subExact", long.class, long.class, long.class, int.class); 45.31 - 45.32 - /** Multiply exact wrapper for potentially overflowing long operations */ 45.33 - public static final Call MUL_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "mulExact", long.class, long.class, long.class, int.class); 45.34 - 45.35 - /** Div exact wrapper for potentially integer division that turns into float point */ 45.36 - public static final Call DIV_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "divExact", long.class, long.class, long.class, int.class); 45.37 - 45.38 - /** Div zero wrapper for long division that handles (0/0) >>> 0 == 0 */ 45.39 - public static final Call DIV_ZERO_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "divZero", long.class, long.class, long.class); 45.40 - 45.41 - /** Mod zero wrapper for long division that handles (0%0) >>> 0 == 0 */ 45.42 - public static final Call REM_ZERO_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "remZero", long.class, long.class, long.class); 45.43 - 45.44 - /** Mod exact wrapper for potentially integer remainders that turns into float point */ 45.45 - public static final Call REM_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "remExact", long.class, long.class, long.class, int.class); 45.46 - 45.47 - /** Decrement exact wrapper for potentially overflowing long operations */ 45.48 - public static final Call DECREMENT_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "decrementExact", long.class, long.class, int.class); 45.49 - 45.50 - /** Increment exact wrapper for potentially overflowing long operations */ 45.51 - public static final Call INCREMENT_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "incrementExact", long.class, long.class, int.class); 45.52 - 45.53 - /** Negate exact exact wrapper for potentially overflowing long operations */ 45.54 - public static final Call NEGATE_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "negateExact", long.class, long.class, int.class); 45.55 - 45.56 /** Method handle to convert a JS Object to a Java array. */ 45.57 public static final Call TO_JAVA_ARRAY = staticCall(JSTYPE_LOOKUP, JSType.class, "toJavaArray", Object.class, Object.class, Class.class); 45.58 45.59 /** Method handle for void returns. */ 45.60 public static final Call VOID_RETURN = staticCall(JSTYPE_LOOKUP, JSType.class, "voidReturn", void.class); 45.61 45.62 + /** Method handle for isString method */ 45.63 + public static final Call IS_STRING = staticCall(JSTYPE_LOOKUP, JSType.class, "isString", boolean.class, Object.class); 45.64 + 45.65 + /** Method handle for isNumber method */ 45.66 + public static final Call IS_NUMBER = staticCall(JSTYPE_LOOKUP, JSType.class, "isNumber", boolean.class, Object.class); 45.67 + 45.68 /** 45.69 * The list of available accessor types in width order. This order is used for type guesses narrow{@literal ->} wide 45.70 * in the dual--fields world 45.71 @@ -211,7 +187,6 @@ 45.72 private static final List<Type> ACCESSOR_TYPES = Collections.unmodifiableList( 45.73 Arrays.asList( 45.74 Type.INT, 45.75 - Type.LONG, 45.76 Type.NUMBER, 45.77 Type.OBJECT)); 45.78 45.79 @@ -219,17 +194,14 @@ 45.80 public static final int TYPE_UNDEFINED_INDEX = -1; 45.81 /** table index for integer type - hard coded so it can be used in switches at compile time */ 45.82 public static final int TYPE_INT_INDEX = 0; //getAccessorTypeIndex(int.class); 45.83 - /** table index for long type - hard coded so it can be used in switches at compile time */ 45.84 - public static final int TYPE_LONG_INDEX = 1; //getAccessorTypeIndex(long.class); 45.85 /** table index for double type - hard coded so it can be used in switches at compile time */ 45.86 - public static final int TYPE_DOUBLE_INDEX = 2; //getAccessorTypeIndex(double.class); 45.87 + public static final int TYPE_DOUBLE_INDEX = 1; //getAccessorTypeIndex(double.class); 45.88 /** table index for object type - hard coded so it can be used in switches at compile time */ 45.89 - public static final int TYPE_OBJECT_INDEX = 3; //getAccessorTypeIndex(Object.class); 45.90 + public static final int TYPE_OBJECT_INDEX = 2; //getAccessorTypeIndex(Object.class); 45.91 45.92 /** object conversion quickies with JS semantics - used for return value and parameter filter */ 45.93 public static final List<MethodHandle> CONVERT_OBJECT = toUnmodifiableList( 45.94 JSType.TO_INT32.methodHandle(), 45.95 - JSType.TO_UINT32.methodHandle(), 45.96 JSType.TO_NUMBER.methodHandle(), 45.97 null 45.98 ); 45.99 @@ -240,7 +212,6 @@ 45.100 */ 45.101 public static final List<MethodHandle> CONVERT_OBJECT_OPTIMISTIC = toUnmodifiableList( 45.102 JSType.TO_INT32_OPTIMISTIC.methodHandle(), 45.103 - JSType.TO_LONG_OPTIMISTIC.methodHandle(), 45.104 JSType.TO_NUMBER_OPTIMISTIC.methodHandle(), 45.105 null 45.106 ); 45.107 @@ -252,13 +223,16 @@ 45.108 /** The value of Undefined cast to a double */ 45.109 public static final double UNDEFINED_DOUBLE = Double.NaN; 45.110 45.111 + // Minimum and maximum range between which every long value can be precisely represented as a double. 45.112 + private static final long MAX_PRECISE_DOUBLE = 1L << 53; 45.113 + private static final long MIN_PRECISE_DOUBLE = -MAX_PRECISE_DOUBLE; 45.114 + 45.115 /** 45.116 * Method handles for getters that return undefined coerced 45.117 * to the appropriate type 45.118 */ 45.119 public static final List<MethodHandle> GET_UNDEFINED = toUnmodifiableList( 45.120 MH.constant(int.class, UNDEFINED_INT), 45.121 - MH.constant(long.class, UNDEFINED_LONG), 45.122 MH.constant(double.class, UNDEFINED_DOUBLE), 45.123 MH.constant(Object.class, Undefined.getUndefined()) 45.124 ); 45.125 @@ -308,7 +282,7 @@ 45.126 return JSType.STRING; 45.127 } 45.128 45.129 - if (obj instanceof Number) { 45.130 + if (isNumber(obj)) { 45.131 return JSType.NUMBER; 45.132 } 45.133 45.134 @@ -346,7 +320,7 @@ 45.135 return JSType.STRING; 45.136 } 45.137 45.138 - if (obj instanceof Number) { 45.139 + if (isNumber(obj)) { 45.140 return JSType.NUMBER; 45.141 } 45.142 45.143 @@ -416,7 +390,7 @@ 45.144 45.145 /** 45.146 * Returns true if double number can be represented as a long. Note that it returns true for negative 45.147 - * zero. If you need to exclude negative zero, use {@link #isStrictlyRepresentableAsLong(double)}. 45.148 + * zero. 45.149 * 45.150 * @param number a double to inspect 45.151 * @return true for long representable doubles 45.152 @@ -426,29 +400,12 @@ 45.153 } 45.154 45.155 /** 45.156 - * Returns true if double number can be represented as a long. Note that it returns false for negative 45.157 - * zero. If you don't need to distinguish negative zero, use {@link #isRepresentableAsLong(double)}. 45.158 - * 45.159 - * @param number a double to inspect 45.160 - * 45.161 - * @return true for long representable doubles 45.162 + * Returns true if long number can be represented as double without loss of precision. 45.163 + * @param number a long number 45.164 + * @return true if the double representation does not lose precision 45.165 */ 45.166 - public static boolean isStrictlyRepresentableAsLong(final double number) { 45.167 - return isRepresentableAsLong(number) && isNotNegativeZero(number); 45.168 - } 45.169 - 45.170 - /** 45.171 - * Returns true if Object can be represented as a long 45.172 - * 45.173 - * @param obj an object to inspect 45.174 - * 45.175 - * @return true for long representable objects 45.176 - */ 45.177 - public static boolean isRepresentableAsLong(final Object obj) { 45.178 - if (obj instanceof Number) { 45.179 - return isRepresentableAsLong(((Number)obj).doubleValue()); 45.180 - } 45.181 - return false; 45.182 + public static boolean isRepresentableAsDouble(final long number) { 45.183 + return MAX_PRECISE_DOUBLE >= number && number >= MIN_PRECISE_DOUBLE; 45.184 } 45.185 45.186 /** 45.187 @@ -470,9 +427,9 @@ 45.188 public static boolean isPrimitive(final Object obj) { 45.189 return obj == null || 45.190 obj == ScriptRuntime.UNDEFINED || 45.191 - obj instanceof Boolean || 45.192 - obj instanceof Number || 45.193 - isString(obj); 45.194 + isString(obj) || 45.195 + isNumber(obj) || 45.196 + obj instanceof Boolean; 45.197 } 45.198 45.199 /** 45.200 @@ -628,22 +585,6 @@ 45.201 } 45.202 45.203 /** 45.204 - * Check whether a string is representable as a JavaScript number 45.205 - * 45.206 - * @param str a string 45.207 - * 45.208 - * @return true if string can be represented as a number 45.209 - */ 45.210 - public static boolean isNumber(final String str) { 45.211 - try { 45.212 - Double.parseDouble(str); 45.213 - return true; 45.214 - } catch (final NumberFormatException e) { 45.215 - return false; 45.216 - } 45.217 - } 45.218 - 45.219 - /** 45.220 * Returns true if object represents a primitive JavaScript string value. 45.221 * @param obj the object 45.222 * @return true if the object represents a primitive JavaScript string value. 45.223 @@ -653,6 +594,24 @@ 45.224 } 45.225 45.226 /** 45.227 + * Returns true if object represents a primitive JavaScript number value. Note that we only 45.228 + * treat wrapper objects of Java primitive number types as objects that can be fully represented 45.229 + * as JavaScript numbers (doubles). This means we exclude {@code long} and special purpose Number 45.230 + * instances such as {@link java.util.concurrent.atomic.AtomicInteger}, as well as arbitrary precision 45.231 + * numbers such as {@link java.math.BigInteger}. 45.232 + * 45.233 + * @param obj the object 45.234 + * @return true if the object represents a primitive JavaScript number value. 45.235 + */ 45.236 + public static boolean isNumber(final Object obj) { 45.237 + if (obj != null) { 45.238 + final Class<?> c = obj.getClass(); 45.239 + return c == Integer.class || c == Double.class || c == Float.class || c == Short.class || c == Byte.class; 45.240 + } 45.241 + return false; 45.242 + } 45.243 + 45.244 + /** 45.245 * JavaScript compliant conversion of integer to String 45.246 * 45.247 * @param num an integer 45.248 @@ -802,12 +761,21 @@ 45.249 if (obj instanceof Double) { 45.250 return (Double)obj; 45.251 } 45.252 - if (obj instanceof Number) { 45.253 + if (isNumber(obj)) { 45.254 return ((Number)obj).doubleValue(); 45.255 } 45.256 return Double.NaN; 45.257 } 45.258 45.259 + /** 45.260 + * Convert a long to the narrowest JavaScript Number type. This returns either a 45.261 + * {@link Integer} or {@link Double} depending on the magnitude of {@code l}. 45.262 + * @param l a long value 45.263 + * @return the value converted to Integer or Double 45.264 + */ 45.265 + public static Number toNarrowestNumber(final long l) { 45.266 + return isRepresentableAsInt(l) ? Integer.valueOf((int) l) : Double.valueOf((double) l); 45.267 + } 45.268 45.269 /** 45.270 * JavaScript compliant conversion of Boolean to number 45.271 @@ -1009,35 +977,6 @@ 45.272 } 45.273 45.274 /** 45.275 - * Optimistic long conversion - throws UnwarrantedOptimismException if double or Object 45.276 - * 45.277 - * @param obj object to convert 45.278 - * @param programPoint program point 45.279 - * @return long 45.280 - */ 45.281 - public static long toLongOptimistic(final Object obj, final int programPoint) { 45.282 - if (obj != null) { 45.283 - final Class<?> clz = obj.getClass(); 45.284 - if (clz == Long.class || clz == Integer.class) { 45.285 - return ((Number)obj).longValue(); 45.286 - } 45.287 - } 45.288 - throw new UnwarrantedOptimismException(obj, programPoint); 45.289 - } 45.290 - 45.291 - /** 45.292 - * Object to int conversion that delegates to either {@link #toLong(Object)} or to 45.293 - * {@link #toLongOptimistic(Object, int)} depending on whether the program point is valid or not. 45.294 - * @param obj the object to convert 45.295 - * @param programPoint the program point; can be invalid. 45.296 - * @return the value converted to long 45.297 - * @throws UnwarrantedOptimismException if the value can't be represented as long and the program point is valid. 45.298 - */ 45.299 - public static long toLongMaybeOptimistic(final Object obj, final int programPoint) { 45.300 - return UnwarrantedOptimismException.isValid(programPoint) ? toLongOptimistic(obj, programPoint) : toLong(obj); 45.301 - } 45.302 - 45.303 - /** 45.304 * JavaScript compliant Object to int32 conversion 45.305 * See ECMA 9.5 ToInt32 45.306 * 45.307 @@ -1074,10 +1013,6 @@ 45.308 return UnwarrantedOptimismException.isValid(programPoint) ? toInt32Optimistic(obj, programPoint) : toInt32(obj); 45.309 } 45.310 45.311 - // Minimum and maximum range between which every long value can be precisely represented as a double. 45.312 - private static final long MAX_PRECISE_DOUBLE = 1L << 53; 45.313 - private static final long MIN_PRECISE_DOUBLE = -MAX_PRECISE_DOUBLE; 45.314 - 45.315 /** 45.316 * JavaScript compliant long to int32 conversion 45.317 * 45.318 @@ -1130,6 +1065,29 @@ 45.319 } 45.320 45.321 /** 45.322 + * Optimistic JavaScript compliant int to uint32 conversion 45.323 + * @param num an int 45.324 + * @param pp the program point 45.325 + * @return the uint32 value if it can be represented by an int 45.326 + * @throws UnwarrantedOptimismException if uint32 value cannot be represented by an int 45.327 + */ 45.328 + public static int toUint32Optimistic(final int num, final int pp) { 45.329 + if (num >= 0) { 45.330 + return num; 45.331 + } 45.332 + throw new UnwarrantedOptimismException(toUint32Double(num), pp, Type.NUMBER); 45.333 + } 45.334 + 45.335 + /** 45.336 + * JavaScript compliant int to uint32 conversion with double return type 45.337 + * @param num an int 45.338 + * @return the uint32 value as double 45.339 + */ 45.340 + public static double toUint32Double(final int num) { 45.341 + return (double) toUint32(num); 45.342 + } 45.343 + 45.344 + /** 45.345 * JavaScript compliant Object to uint16 conversion 45.346 * ECMA 9.7 ToUint16: (Unsigned 16 Bit Integer) 45.347 * 45.348 @@ -1388,7 +1346,7 @@ 45.349 return obj.toString(); 45.350 } 45.351 45.352 - if (obj instanceof Number) { 45.353 + if (isNumber(obj)) { 45.354 return toString(((Number)obj).doubleValue()); 45.355 } 45.356 45.357 @@ -1453,26 +1411,6 @@ 45.358 try { 45.359 return Math.addExact(x, y); 45.360 } catch (final ArithmeticException e) { 45.361 - throw new UnwarrantedOptimismException((long)x + (long)y, programPoint); 45.362 - } 45.363 - } 45.364 - 45.365 - /** 45.366 - * Wrapper for addExact 45.367 - * 45.368 - * Catches ArithmeticException and rethrows as UnwarrantedOptimismException 45.369 - * containing the result and the program point of the failure 45.370 - * 45.371 - * @param x first term 45.372 - * @param y second term 45.373 - * @param programPoint program point id 45.374 - * @return the result 45.375 - * @throws UnwarrantedOptimismException if overflow occurs 45.376 - */ 45.377 - public static long addExact(final long x, final long y, final int programPoint) throws UnwarrantedOptimismException { 45.378 - try { 45.379 - return Math.addExact(x, y); 45.380 - } catch (final ArithmeticException e) { 45.381 throw new UnwarrantedOptimismException((double)x + (double)y, programPoint); 45.382 } 45.383 } 45.384 @@ -1493,26 +1431,6 @@ 45.385 try { 45.386 return Math.subtractExact(x, y); 45.387 } catch (final ArithmeticException e) { 45.388 - throw new UnwarrantedOptimismException((long)x - (long)y, programPoint); 45.389 - } 45.390 - } 45.391 - 45.392 - /** 45.393 - * Wrapper for subExact 45.394 - * 45.395 - * Catches ArithmeticException and rethrows as UnwarrantedOptimismException 45.396 - * containing the result and the program point of the failure 45.397 - * 45.398 - * @param x first term 45.399 - * @param y second term 45.400 - * @param programPoint program point id 45.401 - * @return the result 45.402 - * @throws UnwarrantedOptimismException if overflow occurs 45.403 - */ 45.404 - public static long subExact(final long x, final long y, final int programPoint) throws UnwarrantedOptimismException { 45.405 - try { 45.406 - return Math.subtractExact(x, y); 45.407 - } catch (final ArithmeticException e) { 45.408 throw new UnwarrantedOptimismException((double)x - (double)y, programPoint); 45.409 } 45.410 } 45.411 @@ -1533,26 +1451,6 @@ 45.412 try { 45.413 return Math.multiplyExact(x, y); 45.414 } catch (final ArithmeticException e) { 45.415 - throw new UnwarrantedOptimismException((long)x * (long)y, programPoint); 45.416 - } 45.417 - } 45.418 - 45.419 - /** 45.420 - * Wrapper for mulExact 45.421 - * 45.422 - * Catches ArithmeticException and rethrows as UnwarrantedOptimismException 45.423 - * containing the result and the program point of the failure 45.424 - * 45.425 - * @param x first term 45.426 - * @param y second term 45.427 - * @param programPoint program point id 45.428 - * @return the result 45.429 - * @throws UnwarrantedOptimismException if overflow occurs 45.430 - */ 45.431 - public static long mulExact(final long x, final long y, final int programPoint) throws UnwarrantedOptimismException { 45.432 - try { 45.433 - return Math.multiplyExact(x, y); 45.434 - } catch (final ArithmeticException e) { 45.435 throw new UnwarrantedOptimismException((double)x * (double)y, programPoint); 45.436 } 45.437 } 45.438 @@ -1624,71 +1522,6 @@ 45.439 } 45.440 45.441 /** 45.442 - * Wrapper for divExact. Throws UnwarrantedOptimismException if the result of the division can't be represented as 45.443 - * long. 45.444 - * 45.445 - * @param x first term 45.446 - * @param y second term 45.447 - * @param programPoint program point id 45.448 - * @return the result 45.449 - * @throws UnwarrantedOptimismException if the result of the division can't be represented as long. 45.450 - */ 45.451 - public static long divExact(final long x, final long y, final int programPoint) throws UnwarrantedOptimismException { 45.452 - final long res; 45.453 - try { 45.454 - res = x / y; 45.455 - } catch (final ArithmeticException e) { 45.456 - assert y == 0L; // Only div by zero anticipated 45.457 - throw new UnwarrantedOptimismException(x > 0L ? Double.POSITIVE_INFINITY : x < 0L ? Double.NEGATIVE_INFINITY : Double.NaN, programPoint); 45.458 - } 45.459 - final long rem = x % y; 45.460 - if (rem == 0L) { 45.461 - return res; 45.462 - } 45.463 - throw new UnwarrantedOptimismException((double)x / (double)y, programPoint); 45.464 - } 45.465 - 45.466 - /** 45.467 - * Implements long division but allows {@code x / 0} to be represented as 0. Useful when division of two longs 45.468 - * is coerced to long. 45.469 - * @param x the dividend 45.470 - * @param y the divisor 45.471 - * @return the result 45.472 - */ 45.473 - public static long divZero(final long x, final long y) { 45.474 - return y == 0L ? 0L : x / y; 45.475 - } 45.476 - 45.477 - /** 45.478 - * Implements long remainder but allows {@code x % 0} to be represented as 0. Useful when remainder of two longs 45.479 - * is coerced to long. 45.480 - * @param x the dividend 45.481 - * @param y the divisor 45.482 - * @return the remainder 45.483 - */ 45.484 - public static long remZero(final long x, final long y) { 45.485 - return y == 0L ? 0L : x % y; 45.486 - } 45.487 - 45.488 - /** 45.489 - * Wrapper for modExact. Throws UnwarrantedOptimismException if the modulo can't be represented as int. 45.490 - * 45.491 - * @param x first term 45.492 - * @param y second term 45.493 - * @param programPoint program point id 45.494 - * @return the result 45.495 - * @throws UnwarrantedOptimismException if the modulo can't be represented as int. 45.496 - */ 45.497 - public static long remExact(final long x, final long y, final int programPoint) throws UnwarrantedOptimismException { 45.498 - try { 45.499 - return x % y; 45.500 - } catch (final ArithmeticException e) { 45.501 - assert y == 0L; // Only mod by zero anticipated 45.502 - throw new UnwarrantedOptimismException(Double.NaN, programPoint); 45.503 - } 45.504 - } 45.505 - 45.506 - /** 45.507 * Wrapper for decrementExact 45.508 * 45.509 * Catches ArithmeticException and rethrows as UnwarrantedOptimismException 45.510 @@ -1703,26 +1536,7 @@ 45.511 try { 45.512 return Math.decrementExact(x); 45.513 } catch (final ArithmeticException e) { 45.514 - throw new UnwarrantedOptimismException((long)x - 1, programPoint); 45.515 - } 45.516 - } 45.517 - 45.518 - /** 45.519 - * Wrapper for decrementExact 45.520 - * 45.521 - * Catches ArithmeticException and rethrows as UnwarrantedOptimismException 45.522 - * containing the result and the program point of the failure 45.523 - * 45.524 - * @param x number to negate 45.525 - * @param programPoint program point id 45.526 - * @return the result 45.527 - * @throws UnwarrantedOptimismException if overflow occurs 45.528 - */ 45.529 - public static long decrementExact(final long x, final int programPoint) throws UnwarrantedOptimismException { 45.530 - try { 45.531 - return Math.decrementExact(x); 45.532 - } catch (final ArithmeticException e) { 45.533 - throw new UnwarrantedOptimismException((double)x - 1L, programPoint); 45.534 + throw new UnwarrantedOptimismException((double)x - 1, programPoint); 45.535 } 45.536 } 45.537 45.538 @@ -1741,26 +1555,7 @@ 45.539 try { 45.540 return Math.incrementExact(x); 45.541 } catch (final ArithmeticException e) { 45.542 - throw new UnwarrantedOptimismException((long)x + 1, programPoint); 45.543 - } 45.544 - } 45.545 - 45.546 - /** 45.547 - * Wrapper for incrementExact 45.548 - * 45.549 - * Catches ArithmeticException and rethrows as UnwarrantedOptimismException 45.550 - * containing the result and the program point of the failure 45.551 - * 45.552 - * @param x the number to increment 45.553 - * @param programPoint program point id 45.554 - * @return the result 45.555 - * @throws UnwarrantedOptimismException if overflow occurs 45.556 - */ 45.557 - public static long incrementExact(final long x, final int programPoint) throws UnwarrantedOptimismException { 45.558 - try { 45.559 - return Math.incrementExact(x); 45.560 - } catch (final ArithmeticException e) { 45.561 - throw new UnwarrantedOptimismException((double)x + 1L, programPoint); 45.562 + throw new UnwarrantedOptimismException((double)x + 1, programPoint); 45.563 } 45.564 } 45.565 45.566 @@ -1782,28 +1577,6 @@ 45.567 } 45.568 return Math.negateExact(x); 45.569 } catch (final ArithmeticException e) { 45.570 - throw new UnwarrantedOptimismException(-(long)x, programPoint); 45.571 - } 45.572 - } 45.573 - 45.574 - /** 45.575 - * Wrapper for negateExact 45.576 - * 45.577 - * Catches ArithmeticException and rethrows as UnwarrantedOptimismException 45.578 - * containing the result and the program point of the failure 45.579 - * 45.580 - * @param x the number to negate 45.581 - * @param programPoint program point id 45.582 - * @return the result 45.583 - * @throws UnwarrantedOptimismException if overflow occurs 45.584 - */ 45.585 - public static long negateExact(final long x, final int programPoint) throws UnwarrantedOptimismException { 45.586 - try { 45.587 - if (x == 0L) { 45.588 - throw new UnwarrantedOptimismException(-0.0, programPoint); 45.589 - } 45.590 - return Math.negateExact(x); 45.591 - } catch (final ArithmeticException e) { 45.592 throw new UnwarrantedOptimismException(-(double)x, programPoint); 45.593 } 45.594 } 45.595 @@ -1835,8 +1608,6 @@ 45.596 return TYPE_UNDEFINED_INDEX; 45.597 } else if (type == int.class) { 45.598 return TYPE_INT_INDEX; 45.599 - } else if (type == long.class) { 45.600 - return TYPE_LONG_INDEX; 45.601 } else if (type == double.class) { 45.602 return TYPE_DOUBLE_INDEX; 45.603 } else if (!type.isPrimitive()) { 45.604 @@ -1930,23 +1701,6 @@ 45.605 } 45.606 45.607 /** 45.608 - * Returns the boxed version of a primitive class 45.609 - * @param clazz the class 45.610 - * @return the boxed type of clazz, or unchanged if not primitive 45.611 - */ 45.612 - public static Class<?> getBoxedClass(final Class<?> clazz) { 45.613 - if (clazz == int.class) { 45.614 - return Integer.class; 45.615 - } else if (clazz == long.class) { 45.616 - return Long.class; 45.617 - } else if (clazz == double.class) { 45.618 - return Double.class; 45.619 - } 45.620 - assert !clazz.isPrimitive(); 45.621 - return clazz; 45.622 - } 45.623 - 45.624 - /** 45.625 * Create a method handle constant of the correct primitive type 45.626 * for a constant object 45.627 * @param o object 45.628 @@ -1956,8 +1710,6 @@ 45.629 if (o != null) { 45.630 if (o.getClass() == Integer.class) { 45.631 return MH.constant(int.class, ((Integer)o).intValue()); 45.632 - } else if (o.getClass() == Long.class) { 45.633 - return MH.constant(long.class, ((Long)o).longValue()); 45.634 } else if (o.getClass() == Double.class) { 45.635 return MH.constant(double.class, ((Double)o).doubleValue()); 45.636 } 45.637 @@ -1975,8 +1727,6 @@ 45.638 return Object.class; 45.639 } else if (o.getClass() == Integer.class) { 45.640 return int.class; 45.641 - } else if (o.getClass() == Long.class) { 45.642 - return long.class; 45.643 } else if (o.getClass() == Double.class) { 45.644 return double.class; 45.645 } else {
46.1 --- a/src/jdk/nashorn/internal/runtime/OptimisticReturnFilters.java Tue Jan 26 11:36:10 2016 -0800 46.2 +++ b/src/jdk/nashorn/internal/runtime/OptimisticReturnFilters.java Fri Feb 05 23:32:52 2016 -0800 46.3 @@ -43,52 +43,42 @@ 46.4 */ 46.5 public final class OptimisticReturnFilters { 46.6 private static final MethodHandle[] ENSURE_INT; 46.7 - private static final MethodHandle[] ENSURE_LONG; 46.8 private static final MethodHandle[] ENSURE_NUMBER; 46.9 46.10 + // These extend the type index constants in JSType 46.11 + private static final int VOID_TYPE_INDEX; 46.12 private static final int BOOLEAN_TYPE_INDEX; 46.13 private static final int CHAR_TYPE_INDEX; 46.14 + private static final int LONG_TYPE_INDEX; 46.15 private static final int FLOAT_TYPE_INDEX; 46.16 - private static final int VOID_TYPE_INDEX; 46.17 46.18 static { 46.19 final MethodHandle INT_DOUBLE = findOwnMH("ensureInt", int.class, double.class, int.class); 46.20 ENSURE_INT = new MethodHandle[] { 46.21 null, 46.22 - findOwnMH("ensureInt", int.class, long.class, int.class), 46.23 INT_DOUBLE, 46.24 findOwnMH("ensureInt", int.class, Object.class, int.class), 46.25 findOwnMH("ensureInt", int.class, int.class), 46.26 findOwnMH("ensureInt", int.class, boolean.class, int.class), 46.27 findOwnMH("ensureInt", int.class, char.class, int.class), 46.28 + findOwnMH("ensureInt", int.class, long.class, int.class), 46.29 INT_DOUBLE.asType(INT_DOUBLE.type().changeParameterType(0, float.class)), 46.30 }; 46.31 46.32 - VOID_TYPE_INDEX = ENSURE_INT.length - 4; 46.33 - BOOLEAN_TYPE_INDEX = ENSURE_INT.length - 3; 46.34 - CHAR_TYPE_INDEX = ENSURE_INT.length - 2; 46.35 + VOID_TYPE_INDEX = ENSURE_INT.length - 5; 46.36 + BOOLEAN_TYPE_INDEX = ENSURE_INT.length - 4; 46.37 + CHAR_TYPE_INDEX = ENSURE_INT.length - 3; 46.38 + LONG_TYPE_INDEX = ENSURE_INT.length - 2; 46.39 FLOAT_TYPE_INDEX = ENSURE_INT.length - 1; 46.40 46.41 - final MethodHandle LONG_DOUBLE = findOwnMH("ensureLong", long.class, double.class, int.class); 46.42 - ENSURE_LONG = new MethodHandle[] { 46.43 - null, 46.44 - null, 46.45 - LONG_DOUBLE, 46.46 - findOwnMH("ensureLong", long.class, Object.class, int.class), 46.47 - ENSURE_INT[VOID_TYPE_INDEX].asType(ENSURE_INT[VOID_TYPE_INDEX].type().changeReturnType(long.class)), 46.48 - ENSURE_INT[BOOLEAN_TYPE_INDEX].asType(ENSURE_INT[BOOLEAN_TYPE_INDEX].type().changeReturnType(long.class)), 46.49 - ENSURE_INT[CHAR_TYPE_INDEX].asType(ENSURE_INT[CHAR_TYPE_INDEX].type().changeReturnType(long.class)), 46.50 - LONG_DOUBLE.asType(LONG_DOUBLE.type().changeParameterType(0, float.class)), 46.51 - }; 46.52 - 46.53 ENSURE_NUMBER = new MethodHandle[] { 46.54 null, 46.55 null, 46.56 - null, 46.57 findOwnMH("ensureNumber", double.class, Object.class, int.class), 46.58 ENSURE_INT[VOID_TYPE_INDEX].asType(ENSURE_INT[VOID_TYPE_INDEX].type().changeReturnType(double.class)), 46.59 ENSURE_INT[BOOLEAN_TYPE_INDEX].asType(ENSURE_INT[BOOLEAN_TYPE_INDEX].type().changeReturnType(double.class)), 46.60 ENSURE_INT[CHAR_TYPE_INDEX].asType(ENSURE_INT[CHAR_TYPE_INDEX].type().changeReturnType(double.class)), 46.61 + findOwnMH("ensureNumber", double.class, long.class, int.class), 46.62 null 46.63 }; 46.64 } 46.65 @@ -136,8 +126,6 @@ 46.66 final int provableTypeIndex = getProvableTypeIndex(provable); 46.67 if (actual == int.class) { 46.68 guard = ENSURE_INT[provableTypeIndex]; 46.69 - } else if (actual == long.class) { 46.70 - guard = ENSURE_LONG[provableTypeIndex]; 46.71 } else if (actual == double.class) { 46.72 guard = ENSURE_NUMBER[provableTypeIndex]; 46.73 } else { 46.74 @@ -167,6 +155,8 @@ 46.75 return 0; // never needs a guard, as it's assignable to int 46.76 } else if(provable == char.class) { 46.77 return CHAR_TYPE_INDEX; 46.78 + } else if(provable == long.class) { 46.79 + return LONG_TYPE_INDEX; 46.80 } else if(provable == float.class) { 46.81 return FLOAT_TYPE_INDEX; 46.82 } 46.83 @@ -179,7 +169,7 @@ 46.84 if (JSType.isRepresentableAsInt(arg)) { 46.85 return (int)arg; 46.86 } 46.87 - throw new UnwarrantedOptimismException(arg, programPoint); 46.88 + throw UnwarrantedOptimismException.createNarrowest(arg, programPoint); 46.89 } 46.90 46.91 @SuppressWarnings("unused") 46.92 @@ -187,7 +177,7 @@ 46.93 if (JSType.isStrictlyRepresentableAsInt(arg)) { 46.94 return (int)arg; 46.95 } 46.96 - throw new UnwarrantedOptimismException(arg, programPoint); 46.97 + throw new UnwarrantedOptimismException(arg, programPoint, Type.NUMBER); 46.98 } 46.99 46.100 /** 46.101 @@ -210,7 +200,7 @@ 46.102 return (int)d; 46.103 } 46.104 } 46.105 - throw new UnwarrantedOptimismException(arg, programPoint); 46.106 + throw UnwarrantedOptimismException.createNarrowest(arg, programPoint); 46.107 } 46.108 46.109 private static boolean isPrimitiveNumberWrapper(final Object obj) { 46.110 @@ -238,51 +228,29 @@ 46.111 throw new UnwarrantedOptimismException(ScriptRuntime.UNDEFINED, programPoint, Type.OBJECT); 46.112 } 46.113 46.114 - private static long ensureLong(final double arg, final int programPoint) { 46.115 - if (JSType.isStrictlyRepresentableAsLong(arg)) { 46.116 - return (long)arg; 46.117 + @SuppressWarnings("unused") 46.118 + private static double ensureNumber(final long arg, final int programPoint) { 46.119 + if (JSType.isRepresentableAsDouble(arg)) { 46.120 + return (double) arg; 46.121 } 46.122 - throw new UnwarrantedOptimismException(arg, programPoint); 46.123 + throw new UnwarrantedOptimismException(arg, programPoint, Type.OBJECT); 46.124 } 46.125 46.126 /** 46.127 - * Returns the argument value as a long. If the argument is not a wrapper for a primitive numeric type 46.128 - * with a value that can be exactly represented as a long, throw an {@link UnwarrantedOptimismException}. 46.129 - * This method is only public so that generated script code can use it. See {code CodeGenerator.ENSURE_LONG}. 46.130 - * @param arg the original argument. 46.131 - * @param programPoint the program point used in the exception 46.132 - * @return the value of the argument as a long. 46.133 - * @throws UnwarrantedOptimismException if the argument is not a wrapper for a primitive numeric type with 46.134 - * a value that can be exactly represented as a long 46.135 - */ 46.136 - public static long ensureLong(final Object arg, final int programPoint) { 46.137 - if (arg != null) { 46.138 - final Class<?> c = arg.getClass(); 46.139 - if (c == Long.class) { 46.140 - // Must check for Long separately, as Long.doubleValue() isn't precise. 46.141 - return ((Long)arg).longValue(); 46.142 - } else if (c == Integer.class || c == Double.class || c == Float.class || c == Short.class || 46.143 - c == Byte.class) { 46.144 - return ensureLong(((Number)arg).doubleValue(), programPoint); 46.145 - } 46.146 - } 46.147 - throw new UnwarrantedOptimismException(arg, programPoint); 46.148 - } 46.149 - 46.150 - /** 46.151 - * Returns the argument value as a double. If the argument is not a a wrapper for a primitive numeric type 46.152 - * throw an {@link UnwarrantedOptimismException}.This method is only public so that generated script code 46.153 - * can use it. See {code CodeGenerator.ENSURE_NUMBER}. 46.154 + * Returns the argument value as a double. If the argument is not a wrapper for a primitive numeric type 46.155 + * that can be represented as double throw an {@link UnwarrantedOptimismException}. 46.156 + * This method is only public so that generated script code can use it. See {code CodeGenerator.ENSURE_NUMBER}. 46.157 * @param arg the original argument. 46.158 * @param programPoint the program point used in the exception 46.159 * @return the value of the argument as a double. 46.160 * @throws UnwarrantedOptimismException if the argument is not a wrapper for a primitive numeric type. 46.161 */ 46.162 public static double ensureNumber(final Object arg, final int programPoint) { 46.163 - if (isPrimitiveNumberWrapper(arg)) { 46.164 - return ((Number)arg).doubleValue(); 46.165 + if (isPrimitiveNumberWrapper(arg) 46.166 + && (arg.getClass() != Long.class || JSType.isRepresentableAsDouble((Long) arg))) { 46.167 + return ((Number) arg).doubleValue(); 46.168 } 46.169 - throw new UnwarrantedOptimismException(arg, programPoint); 46.170 + throw new UnwarrantedOptimismException(arg, programPoint, Type.OBJECT); 46.171 } 46.172 46.173 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
47.1 --- a/src/jdk/nashorn/internal/runtime/Property.java Tue Jan 26 11:36:10 2016 -0800 47.2 +++ b/src/jdk/nashorn/internal/runtime/Property.java Fri Feb 05 23:32:52 2016 -0800 47.3 @@ -450,16 +450,6 @@ 47.4 * @param owner the owner of the property 47.5 * @return the property value 47.6 */ 47.7 - public abstract long getLongValue(final ScriptObject self, final ScriptObject owner); 47.8 - 47.9 - /** 47.10 - * get the Object value of this property from {@code owner}. This allows to bypass creation of the 47.11 - * getter MethodHandle for spill and user accessor properties. 47.12 - * 47.13 - * @param self the this object 47.14 - * @param owner the owner of the property 47.15 - * @return the property value 47.16 - */ 47.17 public abstract double getDoubleValue(final ScriptObject self, final ScriptObject owner); 47.18 47.19 /** 47.20 @@ -492,17 +482,6 @@ 47.21 * @param value the new property value 47.22 * @param strict is this a strict setter? 47.23 */ 47.24 - public abstract void setValue(final ScriptObject self, final ScriptObject owner, final long value, final boolean strict); 47.25 - 47.26 - /** 47.27 - * Set the value of this property in {@code owner}. This allows to bypass creation of the 47.28 - * setter MethodHandle for spill and user accessor properties. 47.29 - * 47.30 - * @param self the this object 47.31 - * @param owner the owner object 47.32 - * @param value the new property value 47.33 - * @param strict is this a strict setter? 47.34 - */ 47.35 public abstract void setValue(final ScriptObject self, final ScriptObject owner, final double value, final boolean strict); 47.36 47.37 /** 47.38 @@ -593,8 +572,6 @@ 47.39 return "undef"; 47.40 } else if (type == int.class) { 47.41 return "i"; 47.42 - } else if (type == long.class) { 47.43 - return "j"; 47.44 } else if (type == double.class) { 47.45 return "d"; 47.46 } else {
48.1 --- a/src/jdk/nashorn/internal/runtime/PropertyAccess.java Tue Jan 26 11:36:10 2016 -0800 48.2 +++ b/src/jdk/nashorn/internal/runtime/PropertyAccess.java Fri Feb 05 23:32:52 2016 -0800 48.3 @@ -57,49 +57,9 @@ 48.4 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 48.5 * @return the value 48.6 */ 48.7 - public int getInt(long key, int programPoint); 48.8 - 48.9 - /** 48.10 - * Get the value for a given key and return it as an int 48.11 - * @param key the key 48.12 - * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 48.13 - * @return the value 48.14 - */ 48.15 public int getInt(int key, int programPoint); 48.16 48.17 /** 48.18 - * Get the value for a given key and return it as a long 48.19 - * @param key the key 48.20 - * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 48.21 - * @return the value 48.22 - */ 48.23 - public long getLong(Object key, int programPoint); 48.24 - 48.25 - /** 48.26 - * Get the value for a given key and return it as a long 48.27 - * @param key the key 48.28 - * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 48.29 - * @return the value 48.30 - */ 48.31 - public long getLong(double key, int programPoint); 48.32 - 48.33 - /** 48.34 - * Get the value for a given key and return it as a long 48.35 - * @param key the key 48.36 - * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 48.37 - * @return the value 48.38 - */ 48.39 - public long getLong(long key, int programPoint); 48.40 - 48.41 - /** 48.42 - * Get the value for a given key and return it as a long 48.43 - * @param key the key 48.44 - * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 48.45 - * @return the value 48.46 - */ 48.47 - public long getLong(int key, int programPoint); 48.48 - 48.49 - /** 48.50 * Get the value for a given key and return it as a double 48.51 * @param key the key 48.52 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 48.53 @@ -121,14 +81,6 @@ 48.54 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 48.55 * @return the value 48.56 */ 48.57 - public double getDouble(long key, int programPoint); 48.58 - 48.59 - /** 48.60 - * Get the value for a given key and return it as a double 48.61 - * @param key the key 48.62 - * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 48.63 - * @return the value 48.64 - */ 48.65 public double getDouble(int key, int programPoint); 48.66 48.67 /** 48.68 @@ -150,13 +102,6 @@ 48.69 * @param key the key 48.70 * @return the value 48.71 */ 48.72 - public Object get(long key); 48.73 - 48.74 - /** 48.75 - * Get the value for a given key and return it as an Object 48.76 - * @param key the key 48.77 - * @return the value 48.78 - */ 48.79 public Object get(int key); 48.80 48.81 /** 48.82 @@ -173,14 +118,6 @@ 48.83 * @param value the value 48.84 * @param flags call site flags 48.85 */ 48.86 - public void set(Object key, long value, int flags); 48.87 - 48.88 - /** 48.89 - * Set the value of a given key 48.90 - * @param key the key 48.91 - * @param value the value 48.92 - * @param flags call site flags 48.93 - */ 48.94 public void set(Object key, double value, int flags); 48.95 48.96 /** 48.97 @@ -205,14 +142,6 @@ 48.98 * @param value the value 48.99 * @param flags call site flags 48.100 */ 48.101 - public void set(double key, long value, int flags); 48.102 - 48.103 - /** 48.104 - * Set the value of a given key 48.105 - * @param key the key 48.106 - * @param value the value 48.107 - * @param flags call site flags 48.108 - */ 48.109 public void set(double key, double value, int flags); 48.110 48.111 /** 48.112 @@ -229,38 +158,6 @@ 48.113 * @param value the value 48.114 * @param flags call site flags 48.115 */ 48.116 - public void set(long key, int value, int flags); 48.117 - 48.118 - /** 48.119 - * Set the value of a given key 48.120 - * @param key the key 48.121 - * @param value the value 48.122 - * @param flags call site flags 48.123 - */ 48.124 - public void set(long key, long value, int flags); 48.125 - 48.126 - /** 48.127 - * Set the value of a given key 48.128 - * @param key the key 48.129 - * @param value the value 48.130 - * @param flags call site flags 48.131 - */ 48.132 - public void set(long key, double value, int flags); 48.133 - 48.134 - /** 48.135 - * Set the value of a given key 48.136 - * @param key the key 48.137 - * @param value the value 48.138 - * @param flags call site flags 48.139 - */ 48.140 - public void set(long key, Object value, int flags); 48.141 - 48.142 - /** 48.143 - * Set the value of a given key 48.144 - * @param key the key 48.145 - * @param value the value 48.146 - * @param flags call site flags 48.147 - */ 48.148 public void set(int key, int value, int flags); 48.149 48.150 /** 48.151 @@ -269,14 +166,6 @@ 48.152 * @param value the value 48.153 * @param flags call site flags 48.154 */ 48.155 - public void set(int key, long value, int flags); 48.156 - 48.157 - /** 48.158 - * Set the value of a given key 48.159 - * @param key the key 48.160 - * @param value the value 48.161 - * @param flags call site flags 48.162 - */ 48.163 public void set(int key, double value, int flags); 48.164 48.165 /** 48.166 @@ -306,13 +195,6 @@ 48.167 * @param key the key 48.168 * @return true if key exists 48.169 */ 48.170 - public boolean has(long key); 48.171 - 48.172 - /** 48.173 - * Check if the given key exists anywhere in the proto chain 48.174 - * @param key the key 48.175 - * @return true if key exists 48.176 - */ 48.177 public boolean has(double key); 48.178 48.179 /** 48.180 @@ -334,13 +216,6 @@ 48.181 * @param key the key 48.182 * @return true if key exists 48.183 */ 48.184 - public boolean hasOwnProperty(long key); 48.185 - 48.186 - /** 48.187 - * Check if the given key exists directly in the implementor 48.188 - * @param key the key 48.189 - * @return true if key exists 48.190 - */ 48.191 public boolean hasOwnProperty(double key); 48.192 48.193 /** 48.194 @@ -357,14 +232,6 @@ 48.195 * @param strict are we in strict mode 48.196 * @return true if deletion succeeded, false otherwise 48.197 */ 48.198 - public boolean delete(long key, boolean strict); 48.199 - 48.200 - /** 48.201 - * Delete a property with the given key from the implementor 48.202 - * @param key the key 48.203 - * @param strict are we in strict mode 48.204 - * @return true if deletion succeeded, false otherwise 48.205 - */ 48.206 public boolean delete(double key, boolean strict); 48.207 48.208 /**
49.1 --- a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Tue Jan 26 11:36:10 2016 -0800 49.2 +++ b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Fri Feb 05 23:32:52 2016 -0800 49.3 @@ -894,7 +894,7 @@ 49.4 } 49.5 49.6 @Override 49.7 - synchronized CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden) { 49.8 + synchronized CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, final boolean linkLogicOkay) { 49.9 assert isValidCallSite(callSiteType) : callSiteType; 49.10 49.11 CompiledFunction existingBest = pickFunction(callSiteType, false);
50.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunction.java Tue Jan 26 11:36:10 2016 -0800 50.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunction.java Fri Feb 05 23:32:52 2016 -0800 50.3 @@ -937,6 +937,13 @@ 50.4 } 50.5 } 50.6 50.7 + // Is this an unstable callsite which was earlier apply-to-call optimized? 50.8 + // If so, earlier apply2call would have exploded arguments. We have to convert 50.9 + // that as an array again! 50.10 + if (isUnstable && NashornCallSiteDescriptor.isApplyToCall(desc)) { 50.11 + boundHandle = MH.asCollector(boundHandle, Object[].class, type.parameterCount() - 2); 50.12 + } 50.13 + 50.14 boundHandle = pairArguments(boundHandle, type); 50.15 50.16 if (bestInvoker.getSwitchPoints() != null) {
51.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java Tue Jan 26 11:36:10 2016 -0800 51.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java Fri Feb 05 23:32:52 2016 -0800 51.3 @@ -357,9 +357,23 @@ 51.4 * @param runtimeScope the runtime scope. It can be used to evaluate types of scoped variables to guide the 51.5 * optimistic compilation, should the call to this method trigger code compilation. Can be null if current runtime 51.6 * scope is not known, but that might cause compilation of code that will need more deoptimization passes. 51.7 + * @param linkLogicOkay is a CompiledFunction with a LinkLogic acceptable? 51.8 * @return the best function for the specified call site type. 51.9 */ 51.10 - abstract CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden); 51.11 + abstract CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, final boolean linkLogicOkay); 51.12 + 51.13 + /** 51.14 + * Returns the best function for the specified call site type. 51.15 + * @param callSiteType The call site type. Call site types are expected to have the form 51.16 + * {@code (callee, this[, args...])}. 51.17 + * @param runtimeScope the runtime scope. It can be used to evaluate types of scoped variables to guide the 51.18 + * optimistic compilation, should the call to this method trigger code compilation. Can be null if current runtime 51.19 + * scope is not known, but that might cause compilation of code that will need more deoptimization passes. 51.20 + * @return the best function for the specified call site type. 51.21 + */ 51.22 + final CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden) { 51.23 + return getBest(callSiteType, runtimeScope, forbidden, true); 51.24 + } 51.25 51.26 boolean isValidCallSite(final MethodType callSiteType) { 51.27 return callSiteType.parameterCount() >= 2 && // Must have at least (callee, this) 51.28 @@ -367,7 +381,7 @@ 51.29 } 51.30 51.31 CompiledFunction getGeneric(final ScriptObject runtimeScope) { 51.32 - return getBest(getGenericType(), runtimeScope, CompiledFunction.NO_FUNCTIONS); 51.33 + return getBest(getGenericType(), runtimeScope, CompiledFunction.NO_FUNCTIONS, false); 51.34 } 51.35 51.36 /**
52.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java Tue Jan 26 11:36:10 2016 -0800 52.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java Fri Feb 05 23:32:52 2016 -0800 52.3 @@ -33,7 +33,6 @@ 52.4 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 52.5 import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_DOUBLE; 52.6 import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_INT; 52.7 -import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_LONG; 52.8 import static jdk.nashorn.internal.runtime.PropertyDescriptor.CONFIGURABLE; 52.9 import static jdk.nashorn.internal.runtime.PropertyDescriptor.ENUMERABLE; 52.10 import static jdk.nashorn.internal.runtime.PropertyDescriptor.GET; 52.11 @@ -186,7 +185,6 @@ 52.12 52.13 static final MethodHandle[] SET_SLOW = new MethodHandle[] { 52.14 findOwnMH_V("set", void.class, Object.class, int.class, int.class), 52.15 - findOwnMH_V("set", void.class, Object.class, long.class, int.class), 52.16 findOwnMH_V("set", void.class, Object.class, double.class, int.class), 52.17 findOwnMH_V("set", void.class, Object.class, Object.class, int.class) 52.18 }; 52.19 @@ -1086,21 +1084,6 @@ 52.20 return UNDEFINED_INT; 52.21 } 52.22 52.23 - private static long getLongValue(final FindProperty find, final int programPoint) { 52.24 - final MethodHandle getter = find.getGetter(long.class, programPoint, null); 52.25 - if (getter != null) { 52.26 - try { 52.27 - return (long)getter.invokeExact((Object)find.getGetterReceiver()); 52.28 - } catch (final Error|RuntimeException e) { 52.29 - throw e; 52.30 - } catch (final Throwable e) { 52.31 - throw new RuntimeException(e); 52.32 - } 52.33 - } 52.34 - 52.35 - return UNDEFINED_LONG; 52.36 - } 52.37 - 52.38 private static double getDoubleValue(final FindProperty find, final int programPoint) { 52.39 final MethodHandle getter = find.getGetter(double.class, programPoint, null); 52.40 if (getter != null) { 52.41 @@ -2768,18 +2751,6 @@ 52.42 } 52.43 52.44 @Override 52.45 - public int getInt(final long key, final int programPoint) { 52.46 - final int index = getArrayIndex(key); 52.47 - final ArrayData array = getArray(); 52.48 - 52.49 - if (array.has(index)) { 52.50 - return isValid(programPoint) ? array.getIntOptimistic(index, programPoint) : array.getInt(index); 52.51 - } 52.52 - 52.53 - return getInt(index, JSType.toString(key), programPoint); 52.54 - } 52.55 - 52.56 - @Override 52.57 public int getInt(final int key, final int programPoint) { 52.58 final int index = getArrayIndex(key); 52.59 final ArrayData array = getArray(); 52.60 @@ -2791,88 +2762,6 @@ 52.61 return getInt(index, JSType.toString(key), programPoint); 52.62 } 52.63 52.64 - private long getLong(final int index, final String key, final int programPoint) { 52.65 - if (isValidArrayIndex(index)) { 52.66 - for (ScriptObject object = this; ; ) { 52.67 - if (object.getMap().containsArrayKeys()) { 52.68 - final FindProperty find = object.findProperty(key, false, this); 52.69 - if (find != null) { 52.70 - return getLongValue(find, programPoint); 52.71 - } 52.72 - } 52.73 - 52.74 - if ((object = object.getProto()) == null) { 52.75 - break; 52.76 - } 52.77 - 52.78 - final ArrayData array = object.getArray(); 52.79 - 52.80 - if (array.has(index)) { 52.81 - return isValid(programPoint) ? 52.82 - array.getLongOptimistic(index, programPoint) : 52.83 - array.getLong(index); 52.84 - } 52.85 - } 52.86 - } else { 52.87 - final FindProperty find = findProperty(key, true); 52.88 - 52.89 - if (find != null) { 52.90 - return getLongValue(find, programPoint); 52.91 - } 52.92 - } 52.93 - 52.94 - return JSType.toLong(invokeNoSuchProperty(key, false, programPoint)); 52.95 - } 52.96 - 52.97 - @Override 52.98 - public long getLong(final Object key, final int programPoint) { 52.99 - final Object primitiveKey = JSType.toPrimitive(key, String.class); 52.100 - final int index = getArrayIndex(primitiveKey); 52.101 - final ArrayData array = getArray(); 52.102 - 52.103 - if (array.has(index)) { 52.104 - return isValid(programPoint) ? array.getLongOptimistic(index, programPoint) : array.getLong(index); 52.105 - } 52.106 - 52.107 - return getLong(index, JSType.toString(primitiveKey), programPoint); 52.108 - } 52.109 - 52.110 - @Override 52.111 - public long getLong(final double key, final int programPoint) { 52.112 - final int index = getArrayIndex(key); 52.113 - final ArrayData array = getArray(); 52.114 - 52.115 - if (array.has(index)) { 52.116 - return isValid(programPoint) ? array.getLongOptimistic(index, programPoint) : array.getLong(index); 52.117 - } 52.118 - 52.119 - return getLong(index, JSType.toString(key), programPoint); 52.120 - } 52.121 - 52.122 - @Override 52.123 - public long getLong(final long key, final int programPoint) { 52.124 - final int index = getArrayIndex(key); 52.125 - final ArrayData array = getArray(); 52.126 - 52.127 - if (array.has(index)) { 52.128 - return isValid(programPoint) ? array.getLongOptimistic(index, programPoint) : array.getLong(index); 52.129 - } 52.130 - 52.131 - return getLong(index, JSType.toString(key), programPoint); 52.132 - } 52.133 - 52.134 - @Override 52.135 - public long getLong(final int key, final int programPoint) { 52.136 - final int index = getArrayIndex(key); 52.137 - final ArrayData array = getArray(); 52.138 - 52.139 - if (array.has(index)) { 52.140 - return isValid(programPoint) ? array.getLongOptimistic(key, programPoint) : array.getLong(key); 52.141 - } 52.142 - 52.143 - return getLong(index, JSType.toString(key), programPoint); 52.144 - } 52.145 - 52.146 private double getDouble(final int index, final String key, final int programPoint) { 52.147 if (isValidArrayIndex(index)) { 52.148 for (ScriptObject object = this; ; ) { 52.149 @@ -2932,18 +2821,6 @@ 52.150 } 52.151 52.152 @Override 52.153 - public double getDouble(final long key, final int programPoint) { 52.154 - final int index = getArrayIndex(key); 52.155 - final ArrayData array = getArray(); 52.156 - 52.157 - if (array.has(index)) { 52.158 - return isValid(programPoint) ? array.getDoubleOptimistic(index, programPoint) : array.getDouble(index); 52.159 - } 52.160 - 52.161 - return getDouble(index, JSType.toString(key), programPoint); 52.162 - } 52.163 - 52.164 - @Override 52.165 public double getDouble(final int key, final int programPoint) { 52.166 final int index = getArrayIndex(key); 52.167 final ArrayData array = getArray(); 52.168 @@ -3013,18 +2890,6 @@ 52.169 } 52.170 52.171 @Override 52.172 - public Object get(final long key) { 52.173 - final int index = getArrayIndex(key); 52.174 - final ArrayData array = getArray(); 52.175 - 52.176 - if (array.has(index)) { 52.177 - return array.getObject(index); 52.178 - } 52.179 - 52.180 - return get(index, JSType.toString(key)); 52.181 - } 52.182 - 52.183 - @Override 52.184 public Object get(final int key) { 52.185 final int index = getArrayIndex(key); 52.186 final ArrayData array = getArray(); 52.187 @@ -3107,15 +2972,6 @@ 52.188 } 52.189 } 52.190 52.191 - private void doesNotHave(final int index, final long value, final int callSiteFlags) { 52.192 - final long oldLength = getArray().length(); 52.193 - final long longIndex = ArrayIndex.toLongIndex(index); 52.194 - if (!doesNotHaveCheckArrayKeys(longIndex, value, callSiteFlags) && !doesNotHaveEnsureLength(longIndex, oldLength, callSiteFlags)) { 52.195 - final boolean strict = isStrictFlag(callSiteFlags); 52.196 - setArray(getArray().set(index, value, strict).safeDelete(oldLength, longIndex - 1, strict)); 52.197 - } 52.198 - } 52.199 - 52.200 private void doesNotHave(final int index, final double value, final int callSiteFlags) { 52.201 final long oldLength = getArray().length(); 52.202 final long longIndex = ArrayIndex.toLongIndex(index); 52.203 @@ -3222,7 +3078,7 @@ 52.204 } 52.205 52.206 @Override 52.207 - public void set(final Object key, final long value, final int callSiteFlags) { 52.208 + public void set(final Object key, final double value, final int callSiteFlags) { 52.209 final Object primitiveKey = JSType.toPrimitive(key, String.class); 52.210 final int index = getArrayIndex(primitiveKey); 52.211 52.212 @@ -3242,7 +3098,7 @@ 52.213 } 52.214 52.215 @Override 52.216 - public void set(final Object key, final double value, final int callSiteFlags) { 52.217 + public void set(final Object key, final Object value, final int callSiteFlags) { 52.218 final Object primitiveKey = JSType.toPrimitive(key, String.class); 52.219 final int index = getArrayIndex(primitiveKey); 52.220 52.221 @@ -3258,13 +3114,12 @@ 52.222 } 52.223 52.224 final String propName = JSType.toString(primitiveKey); 52.225 - setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value)); 52.226 + setObject(findProperty(propName, true), callSiteFlags, propName, value); 52.227 } 52.228 52.229 @Override 52.230 - public void set(final Object key, final Object value, final int callSiteFlags) { 52.231 - final Object primitiveKey = JSType.toPrimitive(key, String.class); 52.232 - final int index = getArrayIndex(primitiveKey); 52.233 + public void set(final double key, final int value, final int callSiteFlags) { 52.234 + final int index = getArrayIndex(key); 52.235 52.236 if (isValidArrayIndex(index)) { 52.237 final ArrayData data = getArray(); 52.238 @@ -3277,12 +3132,12 @@ 52.239 return; 52.240 } 52.241 52.242 - final String propName = JSType.toString(primitiveKey); 52.243 - setObject(findProperty(propName, true), callSiteFlags, propName, value); 52.244 + final String propName = JSType.toString(key); 52.245 + setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value)); 52.246 } 52.247 52.248 @Override 52.249 - public void set(final double key, final int value, final int callSiteFlags) { 52.250 + public void set(final double key, final double value, final int callSiteFlags) { 52.251 final int index = getArrayIndex(key); 52.252 52.253 if (isValidArrayIndex(index)) { 52.254 @@ -3301,44 +3156,6 @@ 52.255 } 52.256 52.257 @Override 52.258 - public void set(final double key, final long value, final int callSiteFlags) { 52.259 - final int index = getArrayIndex(key); 52.260 - 52.261 - if (isValidArrayIndex(index)) { 52.262 - final ArrayData data = getArray(); 52.263 - if (data.has(index)) { 52.264 - setArray(data.set(index, value, isStrictFlag(callSiteFlags))); 52.265 - } else { 52.266 - doesNotHave(index, value, callSiteFlags); 52.267 - } 52.268 - 52.269 - return; 52.270 - } 52.271 - 52.272 - final String propName = JSType.toString(key); 52.273 - setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value)); 52.274 - } 52.275 - 52.276 - @Override 52.277 - public void set(final double key, final double value, final int callSiteFlags) { 52.278 - final int index = getArrayIndex(key); 52.279 - 52.280 - if (isValidArrayIndex(index)) { 52.281 - final ArrayData data = getArray(); 52.282 - if (data.has(index)) { 52.283 - setArray(data.set(index, value, isStrictFlag(callSiteFlags))); 52.284 - } else { 52.285 - doesNotHave(index, value, callSiteFlags); 52.286 - } 52.287 - 52.288 - return; 52.289 - } 52.290 - 52.291 - final String propName = JSType.toString(key); 52.292 - setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value)); 52.293 - } 52.294 - 52.295 - @Override 52.296 public void set(final double key, final Object value, final int callSiteFlags) { 52.297 final int index = getArrayIndex(key); 52.298 52.299 @@ -3358,82 +3175,6 @@ 52.300 } 52.301 52.302 @Override 52.303 - public void set(final long key, final int value, final int callSiteFlags) { 52.304 - final int index = getArrayIndex(key); 52.305 - 52.306 - if (isValidArrayIndex(index)) { 52.307 - final ArrayData data = getArray(); 52.308 - if (data.has(index)) { 52.309 - setArray(data.set(index, value, isStrictFlag(callSiteFlags))); 52.310 - } else { 52.311 - doesNotHave(index, value, callSiteFlags); 52.312 - } 52.313 - 52.314 - return; 52.315 - } 52.316 - 52.317 - final String propName = JSType.toString(key); 52.318 - setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value)); 52.319 - } 52.320 - 52.321 - @Override 52.322 - public void set(final long key, final long value, final int callSiteFlags) { 52.323 - final int index = getArrayIndex(key); 52.324 - 52.325 - if (isValidArrayIndex(index)) { 52.326 - final ArrayData data = getArray(); 52.327 - if (data.has(index)) { 52.328 - setArray(data.set(index, value, isStrictFlag(callSiteFlags))); 52.329 - } else { 52.330 - doesNotHave(index, value, callSiteFlags); 52.331 - } 52.332 - 52.333 - return; 52.334 - } 52.335 - 52.336 - final String propName = JSType.toString(key); 52.337 - setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value)); 52.338 - } 52.339 - 52.340 - @Override 52.341 - public void set(final long key, final double value, final int callSiteFlags) { 52.342 - final int index = getArrayIndex(key); 52.343 - 52.344 - if (isValidArrayIndex(index)) { 52.345 - final ArrayData data = getArray(); 52.346 - if (data.has(index)) { 52.347 - setArray(data.set(index, value, isStrictFlag(callSiteFlags))); 52.348 - } else { 52.349 - doesNotHave(index, value, callSiteFlags); 52.350 - } 52.351 - 52.352 - return; 52.353 - } 52.354 - 52.355 - final String propName = JSType.toString(key); 52.356 - setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value)); 52.357 - } 52.358 - 52.359 - @Override 52.360 - public void set(final long key, final Object value, final int callSiteFlags) { 52.361 - final int index = getArrayIndex(key); 52.362 - 52.363 - if (isValidArrayIndex(index)) { 52.364 - final ArrayData data = getArray(); 52.365 - if (data.has(index)) { 52.366 - setArray(data.set(index, value, isStrictFlag(callSiteFlags))); 52.367 - } else { 52.368 - doesNotHave(index, value, callSiteFlags); 52.369 - } 52.370 - 52.371 - return; 52.372 - } 52.373 - 52.374 - final String propName = JSType.toString(key); 52.375 - setObject(findProperty(propName, true), callSiteFlags, propName, value); 52.376 - } 52.377 - 52.378 - @Override 52.379 public void set(final int key, final int value, final int callSiteFlags) { 52.380 final int index = getArrayIndex(key); 52.381 if (isValidArrayIndex(index)) { 52.382 @@ -3451,7 +3192,7 @@ 52.383 } 52.384 52.385 @Override 52.386 - public void set(final int key, final long value, final int callSiteFlags) { 52.387 + public void set(final int key, final double value, final int callSiteFlags) { 52.388 final int index = getArrayIndex(key); 52.389 52.390 if (isValidArrayIndex(index)) { 52.391 @@ -3470,7 +3211,7 @@ 52.392 } 52.393 52.394 @Override 52.395 - public void set(final int key, final double value, final int callSiteFlags) { 52.396 + public void set(final int key, final Object value, final int callSiteFlags) { 52.397 final int index = getArrayIndex(key); 52.398 52.399 if (isValidArrayIndex(index)) { 52.400 @@ -3485,25 +3226,6 @@ 52.401 } 52.402 52.403 final String propName = JSType.toString(key); 52.404 - setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value)); 52.405 - } 52.406 - 52.407 - @Override 52.408 - public void set(final int key, final Object value, final int callSiteFlags) { 52.409 - final int index = getArrayIndex(key); 52.410 - 52.411 - if (isValidArrayIndex(index)) { 52.412 - final ArrayData data = getArray(); 52.413 - if (data.has(index)) { 52.414 - setArray(data.set(index, value, isStrictFlag(callSiteFlags))); 52.415 - } else { 52.416 - doesNotHave(index, value, callSiteFlags); 52.417 - } 52.418 - 52.419 - return; 52.420 - } 52.421 - 52.422 - final String propName = JSType.toString(key); 52.423 setObject(findProperty(propName, true), callSiteFlags, propName, value); 52.424 } 52.425 52.426 @@ -3521,12 +3243,6 @@ 52.427 } 52.428 52.429 @Override 52.430 - public boolean has(final long key) { 52.431 - final int index = getArrayIndex(key); 52.432 - return isValidArrayIndex(index) ? hasArrayProperty(index) : hasProperty(JSType.toString(key), true); 52.433 - } 52.434 - 52.435 - @Override 52.436 public boolean has(final int key) { 52.437 final int index = getArrayIndex(key); 52.438 return isValidArrayIndex(index) ? hasArrayProperty(index) : hasProperty(JSType.toString(key), true); 52.439 @@ -3559,12 +3275,6 @@ 52.440 } 52.441 52.442 @Override 52.443 - public boolean hasOwnProperty(final long key) { 52.444 - final int index = getArrayIndex(key); 52.445 - return isValidArrayIndex(index) ? hasOwnArrayProperty(index) : hasProperty(JSType.toString(key), false); 52.446 - } 52.447 - 52.448 - @Override 52.449 public boolean hasOwnProperty(final double key) { 52.450 final int index = getArrayIndex(key); 52.451 return isValidArrayIndex(index) ? hasOwnArrayProperty(index) : hasProperty(JSType.toString(key), false); 52.452 @@ -3590,22 +3300,6 @@ 52.453 } 52.454 52.455 @Override 52.456 - public boolean delete(final long key, final boolean strict) { 52.457 - final int index = getArrayIndex(key); 52.458 - final ArrayData array = getArray(); 52.459 - 52.460 - if (array.has(index)) { 52.461 - if (array.canDelete(index, strict)) { 52.462 - setArray(array.delete(index)); 52.463 - return true; 52.464 - } 52.465 - return false; 52.466 - } 52.467 - 52.468 - return deleteObject(JSType.toObject(key), strict); 52.469 - } 52.470 - 52.471 - @Override 52.472 public boolean delete(final double key, final boolean strict) { 52.473 final int index = getArrayIndex(key); 52.474 final ArrayData array = getArray();
53.1 --- a/src/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java Tue Jan 26 11:36:10 2016 -0800 53.2 +++ b/src/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java Fri Feb 05 23:32:52 2016 -0800 53.3 @@ -49,7 +49,10 @@ 53.4 private final Type returnType; 53.5 53.6 /** 53.7 - * Constructor 53.8 + * Constructor without explicit return type. The return type is determined statically from the class of 53.9 + * the return value, and only canonical internal number representations are recognized. Use 53.10 + * {@link #createNarrowest} if you want to handle float and long values as numbers instead of objects. 53.11 + * 53.12 * @param returnValue actual return value from the too narrow operation 53.13 * @param programPoint program point where unwarranted optimism was detected 53.14 */ 53.15 @@ -58,7 +61,7 @@ 53.16 } 53.17 53.18 /** 53.19 - * Check if a program point is valid 53.20 + * Check if a program point is valid. 53.21 * @param programPoint the program point 53.22 * @return true if valid 53.23 */ 53.24 @@ -70,8 +73,6 @@ 53.25 private static Type getReturnType(final Object v) { 53.26 if (v instanceof Double) { 53.27 return Type.NUMBER; 53.28 - } else if (v instanceof Long) { 53.29 - return Type.LONG; 53.30 } 53.31 assert !(v instanceof Integer) : v + " is an int"; // Can't have an unwarranted optimism exception with int 53.32 return Type.OBJECT; 53.33 @@ -97,6 +98,22 @@ 53.34 } 53.35 53.36 /** 53.37 + * Create an {@code UnwarrantedOptimismException} with the given return value and program point, narrowing 53.38 + * the type to {@code number} if the value is a float or a long that can be represented as double. 53.39 + * 53.40 + * @param returnValue the return value 53.41 + * @param programPoint the program point 53.42 + * @return the exception 53.43 + */ 53.44 + public static UnwarrantedOptimismException createNarrowest(final Object returnValue, final int programPoint) { 53.45 + if (returnValue instanceof Float 53.46 + || (returnValue instanceof Long && JSType.isRepresentableAsDouble((Long) returnValue))) { 53.47 + return new UnwarrantedOptimismException(((Number) returnValue).doubleValue(), programPoint, Type.NUMBER); 53.48 + } 53.49 + return new UnwarrantedOptimismException(returnValue, programPoint); 53.50 + } 53.51 + 53.52 + /** 53.53 * Get the return value. This is a destructive readout, after the method is invoked the return value is null'd out. 53.54 * @return return value 53.55 */
54.1 --- a/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java Tue Jan 26 11:36:10 2016 -0800 54.2 +++ b/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java Fri Feb 05 23:32:52 2016 -0800 54.3 @@ -71,13 +71,11 @@ 54.4 /** Getter method handle */ 54.5 private final static MethodHandle INVOKE_OBJECT_GETTER = findOwnMH_S("invokeObjectGetter", Object.class, Accessors.class, MethodHandle.class, Object.class); 54.6 private final static MethodHandle INVOKE_INT_GETTER = findOwnMH_S("invokeIntGetter", int.class, Accessors.class, MethodHandle.class, int.class, Object.class); 54.7 - private final static MethodHandle INVOKE_LONG_GETTER = findOwnMH_S("invokeLongGetter", long.class, Accessors.class, MethodHandle.class, int.class, Object.class); 54.8 private final static MethodHandle INVOKE_NUMBER_GETTER = findOwnMH_S("invokeNumberGetter", double.class, Accessors.class, MethodHandle.class, int.class, Object.class); 54.9 54.10 /** Setter method handle */ 54.11 private final static MethodHandle INVOKE_OBJECT_SETTER = findOwnMH_S("invokeObjectSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, Object.class); 54.12 private final static MethodHandle INVOKE_INT_SETTER = findOwnMH_S("invokeIntSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, int.class); 54.13 - private final static MethodHandle INVOKE_LONG_SETTER = findOwnMH_S("invokeLongSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, long.class); 54.14 private final static MethodHandle INVOKE_NUMBER_SETTER = findOwnMH_S("invokeNumberSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, double.class); 54.15 54.16 private static final Object OBJECT_GETTER_INVOKER_KEY = new Object(); 54.17 @@ -188,11 +186,6 @@ 54.18 } 54.19 54.20 @Override 54.21 - public long getLongValue(final ScriptObject self, final ScriptObject owner) { 54.22 - return (long)getObjectValue(self, owner); 54.23 - } 54.24 - 54.25 - @Override 54.26 public double getDoubleValue(final ScriptObject self, final ScriptObject owner) { 54.27 return (double)getObjectValue(self, owner); 54.28 } 54.29 @@ -214,11 +207,6 @@ 54.30 } 54.31 54.32 @Override 54.33 - public void setValue(final ScriptObject self, final ScriptObject owner, final long value, final boolean strict) { 54.34 - setValue(self, owner, (Object) value, strict); 54.35 - } 54.36 - 54.37 - @Override 54.38 public void setValue(final ScriptObject self, final ScriptObject owner, final double value, final boolean strict) { 54.39 setValue(self, owner, (Object) value, strict); 54.40 } 54.41 @@ -244,8 +232,6 @@ 54.42 public MethodHandle getOptimisticGetter(final Class<?> type, final int programPoint) { 54.43 if (type == int.class) { 54.44 return INVOKE_INT_GETTER; 54.45 - } else if (type == long.class) { 54.46 - return INVOKE_LONG_GETTER; 54.47 } else if (type == double.class) { 54.48 return INVOKE_NUMBER_GETTER; 54.49 } else { 54.50 @@ -269,8 +255,6 @@ 54.51 public MethodHandle getSetter(final Class<?> type, final PropertyMap currentMap) { 54.52 if (type == int.class) { 54.53 return INVOKE_INT_SETTER; 54.54 - } else if (type == long.class) { 54.55 - return INVOKE_LONG_SETTER; 54.56 } else if (type == double.class) { 54.57 return INVOKE_NUMBER_SETTER; 54.58 } else { 54.59 @@ -320,16 +304,6 @@ 54.60 } 54.61 54.62 @SuppressWarnings("unused") 54.63 - private static long invokeLongGetter(final Accessors gs, final MethodHandle invoker, final int programPoint, final Object self) throws Throwable { 54.64 - final Object func = gs.getter; 54.65 - if (func instanceof ScriptFunction) { 54.66 - return (long) invoker.invokeExact(func, self); 54.67 - } 54.68 - 54.69 - throw new UnwarrantedOptimismException(UNDEFINED, programPoint); 54.70 - } 54.71 - 54.72 - @SuppressWarnings("unused") 54.73 private static double invokeNumberGetter(final Accessors gs, final MethodHandle invoker, final int programPoint, final Object self) throws Throwable { 54.74 final Object func = gs.getter; 54.75 if (func instanceof ScriptFunction) { 54.76 @@ -360,16 +334,6 @@ 54.77 } 54.78 54.79 @SuppressWarnings("unused") 54.80 - private static void invokeLongSetter(final Accessors gs, final MethodHandle invoker, final String name, final Object self, final long value) throws Throwable { 54.81 - final Object func = gs.setter; 54.82 - if (func instanceof ScriptFunction) { 54.83 - invoker.invokeExact(func, self, value); 54.84 - } else if (name != null) { 54.85 - throw typeError("property.has.no.setter", name, ScriptRuntime.safeToString(self)); 54.86 - } 54.87 - } 54.88 - 54.89 - @SuppressWarnings("unused") 54.90 private static void invokeNumberSetter(final Accessors gs, final MethodHandle invoker, final String name, final Object self, final double value) throws Throwable { 54.91 final Object func = gs.setter; 54.92 if (func instanceof ScriptFunction) {
55.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java Tue Jan 26 11:36:10 2016 -0800 55.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java Fri Feb 05 23:32:52 2016 -0800 55.3 @@ -52,9 +52,6 @@ 55.4 /** Minimum chunk size for underlying arrays */ 55.5 protected static final int CHUNK_SIZE = 32; 55.6 55.7 - /** Mask for getting a chunk */ 55.8 - protected static final int CHUNK_MASK = CHUNK_SIZE - 1; 55.9 - 55.10 /** Untouched data - still link callsites as IntArrayData, but expands to 55.11 * a proper ArrayData when we try to write to it */ 55.12 public static final ArrayData EMPTY_ARRAY = new UntouchedArrayData(); 55.13 @@ -164,11 +161,6 @@ 55.14 } 55.15 55.16 @Override 55.17 - public ArrayData set(final int index, final long value, final boolean strict) { 55.18 - return toRealArrayData(index).set(index, value, strict); 55.19 - } 55.20 - 55.21 - @Override 55.22 public ArrayData set(final int index, final double value, final boolean strict) { 55.23 return toRealArrayData(index).set(index, value, strict); 55.24 } 55.25 @@ -179,11 +171,6 @@ 55.26 } 55.27 55.28 @Override 55.29 - public long getLong(final int index) { 55.30 - throw new ArrayIndexOutOfBoundsException(index); //empty 55.31 - } 55.32 - 55.33 - @Override 55.34 public double getDouble(final int index) { 55.35 throw new ArrayIndexOutOfBoundsException(index); //empty 55.36 } 55.37 @@ -288,13 +275,13 @@ 55.38 * @param length the initial length 55.39 * @return ArrayData 55.40 */ 55.41 - public static ArrayData allocate(final int length) { 55.42 - if (length == 0) { 55.43 + public static ArrayData allocate(final long length) { 55.44 + if (length == 0L) { 55.45 return new IntArrayData(); 55.46 } else if (length >= SparseArrayData.MAX_DENSE_LENGTH) { 55.47 return new SparseArrayData(EMPTY_ARRAY, length); 55.48 } else { 55.49 - return new DeletedRangeArrayFilter(new IntArrayData(length), 0, length - 1); 55.50 + return new DeletedRangeArrayFilter(new IntArrayData((int) length), 0, length - 1); 55.51 } 55.52 } 55.53 55.54 @@ -309,8 +296,6 @@ 55.55 55.56 if (clazz == int[].class) { 55.57 return new IntArrayData((int[])array, ((int[])array).length); 55.58 - } else if (clazz == long[].class) { 55.59 - return new LongArrayData((long[])array, ((long[])array).length); 55.60 } else if (clazz == double[].class) { 55.61 return new NumberArrayData((double[])array, ((double[])array).length); 55.62 } else { 55.63 @@ -334,16 +319,6 @@ 55.64 * @param array the array to use for initial elements 55.65 * @return the ArrayData 55.66 */ 55.67 - public static ArrayData allocate(final long[] array) { 55.68 - return new LongArrayData(array, array.length); 55.69 - } 55.70 - 55.71 - /** 55.72 - * Allocate an ArrayData wrapping a given array 55.73 - * 55.74 - * @param array the array to use for initial elements 55.75 - * @return the ArrayData 55.76 - */ 55.77 public static ArrayData allocate(final double[] array) { 55.78 return new NumberArrayData(array, array.length); 55.79 } 55.80 @@ -537,16 +512,6 @@ 55.81 public abstract ArrayData set(final int index, final int value, final boolean strict); 55.82 55.83 /** 55.84 - * Set a long value at a given index 55.85 - * 55.86 - * @param index the index 55.87 - * @param value the value 55.88 - * @param strict are we in strict mode 55.89 - * @return new array data (or same) 55.90 - */ 55.91 - public abstract ArrayData set(final int index, final long value, final boolean strict); 55.92 - 55.93 - /** 55.94 * Set an double value at a given index 55.95 * 55.96 * @param index the index 55.97 @@ -609,26 +574,6 @@ 55.98 } 55.99 55.100 /** 55.101 - * Get a long value from a given index 55.102 - * 55.103 - * @param index the index 55.104 - * @return the value 55.105 - */ 55.106 - public abstract long getLong(final int index); 55.107 - 55.108 - /** 55.109 - * Get optimistic long - default is that it's impossible. Overridden 55.110 - * by arrays that actually represents longs or narrower 55.111 - * 55.112 - * @param index the index 55.113 - * @param programPoint program point 55.114 - * @return the value 55.115 - */ 55.116 - public long getLongOptimistic(final int index, final int programPoint) { 55.117 - throw new UnwarrantedOptimismException(getObject(index), programPoint, getOptimisticType()); 55.118 - } 55.119 - 55.120 - /** 55.121 * Get a double value from a given index 55.122 * 55.123 * @param index the index 55.124 @@ -821,12 +766,8 @@ 55.125 return Object.class; 55.126 } 55.127 final Class<?> itemClass = item.getClass(); 55.128 - if (itemClass == Long.class) { 55.129 + if (itemClass == Double.class || itemClass == Float.class || itemClass == Long.class) { 55.130 if (widest == Integer.class) { 55.131 - widest = Long.class; 55.132 - } 55.133 - } else if (itemClass == Double.class || itemClass == Float.class) { 55.134 - if (widest == Integer.class || widest == Long.class) { 55.135 widest = Double.class; 55.136 } 55.137 } else if (itemClass != Integer.class && itemClass != Short.class && itemClass != Byte.class) {
56.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java Tue Jan 26 11:36:10 2016 -0800 56.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java Fri Feb 05 23:32:52 2016 -0800 56.3 @@ -109,13 +109,6 @@ 56.4 } 56.5 56.6 @Override 56.7 - public ArrayData set(final int index, final long value, final boolean strict) { 56.8 - underlying = underlying.set(index, value, strict); 56.9 - setLength(underlying.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 underlying = underlying.set(index, value, strict); 56.16 setLength(underlying.length()); 56.17 @@ -150,16 +143,6 @@ 56.18 } 56.19 56.20 @Override 56.21 - public long getLong(final int index) { 56.22 - return underlying.getLong(index); 56.23 - } 56.24 - 56.25 - @Override 56.26 - public long getLongOptimistic(final int index, final int programPoint) { 56.27 - return underlying.getLongOptimistic(index, programPoint); 56.28 - } 56.29 - 56.30 - @Override 56.31 public double getDouble(final int index) { 56.32 return underlying.getDouble(index); 56.33 }
57.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java Tue Jan 26 11:36:10 2016 -0800 57.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java Fri Feb 05 23:32:52 2016 -0800 57.3 @@ -122,12 +122,6 @@ 57.4 } 57.5 57.6 @Override 57.7 - public ArrayData set(final int index, final long value, final boolean strict) { 57.8 - buf.put(index, (byte)value); 57.9 - return this; 57.10 - } 57.11 - 57.12 - @Override 57.13 public ArrayData set(final int index, final double value, final boolean strict) { 57.14 buf.put(index, (byte)value); 57.15 return this; 57.16 @@ -139,11 +133,6 @@ 57.17 } 57.18 57.19 @Override 57.20 - public long getLong(final int index) { 57.21 - return 0x0ff & buf.get(index); 57.22 - } 57.23 - 57.24 - @Override 57.25 public double getDouble(final int index) { 57.26 return 0x0ff & buf.get(index); 57.27 }
58.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java Tue Jan 26 11:36:10 2016 -0800 58.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java Fri Feb 05 23:32:52 2016 -0800 58.3 @@ -290,7 +290,7 @@ 58.4 * @param arg argument 58.5 * @return new array length 58.6 */ 58.7 - public long fastPush(final int arg) { 58.8 + public double fastPush(final int arg) { 58.9 throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink 58.10 } 58.11 58.12 @@ -299,7 +299,7 @@ 58.13 * @param arg argument 58.14 * @return new array length 58.15 */ 58.16 - public long fastPush(final long arg) { 58.17 + public double fastPush(final long arg) { 58.18 throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink 58.19 } 58.20 58.21 @@ -308,7 +308,7 @@ 58.22 * @param arg argument 58.23 * @return new array length 58.24 */ 58.25 - public long fastPush(final double arg) { 58.26 + public double fastPush(final double arg) { 58.27 throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink 58.28 } 58.29 58.30 @@ -317,7 +317,7 @@ 58.31 * @param arg argument 58.32 * @return new array length 58.33 */ 58.34 - public long fastPush(final Object arg) { 58.35 + public double fastPush(final Object arg) { 58.36 throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink 58.37 } 58.38 58.39 @@ -333,14 +333,6 @@ 58.40 * Specialization - fast pop implementation 58.41 * @return element value 58.42 */ 58.43 - public long fastPopLong() { 58.44 - throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink 58.45 - } 58.46 - 58.47 - /** 58.48 - * Specialization - fast pop implementation 58.49 - * @return element value 58.50 - */ 58.51 public double fastPopDouble() { 58.52 throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink 58.53 }
59.1 --- a/src/jdk/nashorn/internal/runtime/arrays/DeletedArrayFilter.java Tue Jan 26 11:36:10 2016 -0800 59.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/DeletedArrayFilter.java Fri Feb 05 23:32:52 2016 -0800 59.3 @@ -120,12 +120,6 @@ 59.4 } 59.5 59.6 @Override 59.7 - public ArrayData set(final int index, final long value, final boolean strict) { 59.8 - deleted.clear(ArrayIndex.toLongIndex(index)); 59.9 - return super.set(index, value, strict); 59.10 - } 59.11 - 59.12 - @Override 59.13 public ArrayData set(final int index, final double value, final boolean strict) { 59.14 deleted.clear(ArrayIndex.toLongIndex(index)); 59.15 return super.set(index, value, strict);
60.1 --- a/src/jdk/nashorn/internal/runtime/arrays/DeletedRangeArrayFilter.java Tue Jan 26 11:36:10 2016 -0800 60.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/DeletedRangeArrayFilter.java Fri Feb 05 23:32:52 2016 -0800 60.3 @@ -163,24 +163,6 @@ 60.4 } 60.5 60.6 @Override 60.7 - public ArrayData set(final int index, final long value, final boolean strict) { 60.8 - final long longIndex = ArrayIndex.toLongIndex(index); 60.9 - if (longIndex < lo || longIndex > hi) { 60.10 - return super.set(index, value, strict); 60.11 - } else if (longIndex > lo && longIndex < hi) { 60.12 - return getDeletedArrayFilter().set(index, value, strict); 60.13 - } 60.14 - if (longIndex == lo) { 60.15 - lo++; 60.16 - } else { 60.17 - assert longIndex == hi; 60.18 - hi--; 60.19 - } 60.20 - 60.21 - return isEmpty() ? getUnderlying().set(index, value, strict) : super.set(index, value, strict); 60.22 - } 60.23 - 60.24 - @Override 60.25 public ArrayData set(final int index, final double value, final boolean strict) { 60.26 final long longIndex = ArrayIndex.toLongIndex(index); 60.27 if (longIndex < lo || longIndex > hi) {
61.1 --- a/src/jdk/nashorn/internal/runtime/arrays/FrozenArrayFilter.java Tue Jan 26 11:36:10 2016 -0800 61.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/FrozenArrayFilter.java Fri Feb 05 23:32:52 2016 -0800 61.3 @@ -57,14 +57,6 @@ 61.4 } 61.5 61.6 @Override 61.7 - public ArrayData set(final int index, final long value, final boolean strict) { 61.8 - if (strict) { 61.9 - throw typeError("cant.set.property", Integer.toString(index), "frozen array"); 61.10 - } 61.11 - return this; 61.12 - } 61.13 - 61.14 - @Override 61.15 public ArrayData set(final int index, final double value, final boolean strict) { 61.16 if (strict) { 61.17 throw typeError("cant.set.property", Integer.toString(index), "frozen array");
62.1 --- a/src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java Tue Jan 26 11:36:10 2016 -0800 62.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java Fri Feb 05 23:32:52 2016 -0800 62.3 @@ -156,22 +156,6 @@ 62.4 return darray; 62.5 } 62.6 62.7 - private long[] toLongArray() { 62.8 - assert length() <= array.length : "length exceeds internal array size"; 62.9 - final int len = (int)length(); 62.10 - final long[] larray = new long[array.length]; 62.11 - 62.12 - for (int index = 0; index < len; index++) { 62.13 - larray[index] = array[index]; 62.14 - } 62.15 - 62.16 - return larray; 62.17 - } 62.18 - 62.19 - private LongArrayData convertToLong() { 62.20 - return new LongArrayData(toLongArray(), (int)length()); 62.21 - } 62.22 - 62.23 private NumberArrayData convertToDouble() { 62.24 return new NumberArrayData(toDoubleArray(), (int)length()); 62.25 } 62.26 @@ -184,8 +168,6 @@ 62.27 public ArrayData convert(final Class<?> type) { 62.28 if (type == Integer.class || type == Byte.class || type == Short.class) { 62.29 return this; 62.30 - } else if (type == Long.class) { 62.31 - return convertToLong(); 62.32 } else if (type == Double.class || type == Float.class) { 62.33 return convertToDouble(); 62.34 } else { 62.35 @@ -253,17 +235,6 @@ 62.36 } 62.37 62.38 @Override 62.39 - public ArrayData set(final int index, final long value, final boolean strict) { 62.40 - if (JSType.isRepresentableAsInt(value)) { 62.41 - array[index] = JSType.toInt32(value); 62.42 - setLength(Math.max(index + 1, length())); 62.43 - return this; 62.44 - } 62.45 - 62.46 - return convert(Long.class).set(index, value, strict); 62.47 - } 62.48 - 62.49 - @Override 62.50 public ArrayData set(final int index, final double value, final boolean strict) { 62.51 if (JSType.isRepresentableAsInt(value)) { 62.52 array[index] = (int)(long)value; 62.53 @@ -285,16 +256,6 @@ 62.54 } 62.55 62.56 @Override 62.57 - public long getLong(final int index) { 62.58 - return array[index]; 62.59 - } 62.60 - 62.61 - @Override 62.62 - public long getLongOptimistic(final int index, final int programPoint) { 62.63 - return array[index]; 62.64 - } 62.65 - 62.66 - @Override 62.67 public double getDouble(final int index) { 62.68 return array[index]; 62.69 } 62.70 @@ -379,7 +340,7 @@ 62.71 } 62.72 62.73 @Override 62.74 - public long fastPush(final int arg) { 62.75 + public double fastPush(final int arg) { 62.76 final int len = (int)length(); 62.77 if (len == array.length) { 62.78 array = Arrays.copyOf(array, nextSize(len)); 62.79 @@ -401,11 +362,6 @@ 62.80 } 62.81 62.82 @Override 62.83 - public long fastPopLong() { 62.84 - return fastPopInt(); 62.85 - } 62.86 - 62.87 - @Override 62.88 public double fastPopDouble() { 62.89 return fastPopInt(); 62.90 }
63.1 --- a/src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java Tue Jan 26 11:36:10 2016 -0800 63.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java Fri Feb 05 23:32:52 2016 -0800 63.3 @@ -130,6 +130,6 @@ 63.4 * 63.5 * @throws Throwable if invocation throws an exception/error 63.6 */ 63.7 - protected abstract boolean forEach(final Object val, final long i) throws Throwable; 63.8 + protected abstract boolean forEach(final Object val, final double i) throws Throwable; 63.9 63.10 }
64.1 --- a/src/jdk/nashorn/internal/runtime/arrays/LengthNotWritableFilter.java Tue Jan 26 11:36:10 2016 -0800 64.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/LengthNotWritableFilter.java Fri Feb 05 23:32:52 2016 -0800 64.3 @@ -91,22 +91,6 @@ 64.4 } 64.5 64.6 @Override 64.7 - public long getLong(final int index) { 64.8 - if (index >= length()) { 64.9 - return JSType.toLong(get(index)); 64.10 - } 64.11 - return underlying.getLong(index); 64.12 - } 64.13 - 64.14 - @Override 64.15 - public long getLongOptimistic(final int index, final int programPoint) { 64.16 - if (index >= length()) { 64.17 - return JSType.toLongOptimistic(get(index), programPoint); 64.18 - } 64.19 - return underlying.getLongOptimistic(index, programPoint); 64.20 - } 64.21 - 64.22 - @Override 64.23 public double getDouble(final int index) { 64.24 if (index >= length()) { 64.25 return JSType.toNumber(get(index)); 64.26 @@ -149,15 +133,6 @@ 64.27 } 64.28 64.29 @Override 64.30 - public ArrayData set(final int index, final long value, final boolean strict) { 64.31 - if (checkAdd(index, value)) { 64.32 - return this; 64.33 - } 64.34 - underlying = underlying.set(index, value, strict); 64.35 - return this; 64.36 - } 64.37 - 64.38 - @Override 64.39 public ArrayData set(final int index, final double value, final boolean strict) { 64.40 if (checkAdd(index, value)) { 64.41 return this;
65.1 --- a/src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Tue Jan 26 11:36:10 2016 -0800 65.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 65.3 @@ -1,406 +0,0 @@ 65.4 -/* 65.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 65.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 65.7 - * 65.8 - * This code is free software; you can redistribute it and/or modify it 65.9 - * under the terms of the GNU General Public License version 2 only, as 65.10 - * published by the Free Software Foundation. Oracle designates this 65.11 - * particular file as subject to the "Classpath" exception as provided 65.12 - * by Oracle in the LICENSE file that accompanied this code. 65.13 - * 65.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 65.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 65.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 65.17 - * version 2 for more details (a copy is included in the LICENSE file that 65.18 - * accompanied this code). 65.19 - * 65.20 - * You should have received a copy of the GNU General Public License version 65.21 - * 2 along with this work; if not, write to the Free Software Foundation, 65.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 65.23 - * 65.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 65.25 - * or visit www.oracle.com if you need additional information or have any 65.26 - * questions. 65.27 - */ 65.28 - 65.29 -package jdk.nashorn.internal.runtime.arrays; 65.30 - 65.31 -import static jdk.nashorn.internal.codegen.CompilerConstants.specialCall; 65.32 -import static jdk.nashorn.internal.lookup.Lookup.MH; 65.33 - 65.34 -import java.lang.invoke.MethodHandle; 65.35 -import java.lang.invoke.MethodHandles; 65.36 -import java.util.Arrays; 65.37 -import jdk.nashorn.internal.runtime.JSType; 65.38 -import jdk.nashorn.internal.runtime.ScriptRuntime; 65.39 - 65.40 -/** 65.41 - * Implementation of {@link ArrayData} as soon as a long has been 65.42 - * written to the array 65.43 - */ 65.44 -final class LongArrayData extends ContinuousArrayData implements IntOrLongElements { 65.45 - /** 65.46 - * The wrapped array 65.47 - */ 65.48 - private long[] array; 65.49 - 65.50 - /** 65.51 - * Constructor 65.52 - * @param array an int array 65.53 - * @param length a length, not necessarily array.length 65.54 - */ 65.55 - LongArrayData(final long array[], final int length) { 65.56 - super(length); 65.57 - assert array.length >= length; 65.58 - this.array = array; 65.59 - } 65.60 - 65.61 - @Override 65.62 - public final Class<?> getElementType() { 65.63 - return long.class; 65.64 - } 65.65 - 65.66 - @Override 65.67 - public final Class<?> getBoxedElementType() { 65.68 - return Long.class; 65.69 - } 65.70 - 65.71 - @Override 65.72 - public final ContinuousArrayData widest(final ContinuousArrayData otherData) { 65.73 - return otherData instanceof IntElements ? this : otherData; 65.74 - } 65.75 - 65.76 - @Override 65.77 - public final int getElementWeight() { 65.78 - return 2; 65.79 - } 65.80 - 65.81 - @Override 65.82 - public LongArrayData copy() { 65.83 - return new LongArrayData(array.clone(), (int)length()); 65.84 - } 65.85 - 65.86 - @Override 65.87 - public Object[] asObjectArray() { 65.88 - return toObjectArray(true); 65.89 - } 65.90 - 65.91 - private Object[] toObjectArray(final boolean trim) { 65.92 - assert length() <= array.length : "length exceeds internal array size"; 65.93 - final int len = (int)length(); 65.94 - final Object[] oarray = new Object[trim ? len : array.length]; 65.95 - 65.96 - for (int index = 0; index < len; index++) { 65.97 - oarray[index] = Long.valueOf(array[index]); 65.98 - } 65.99 - 65.100 - return oarray; 65.101 - } 65.102 - 65.103 - @Override 65.104 - public Object asArrayOfType(final Class<?> componentType) { 65.105 - if (componentType == long.class) { 65.106 - final int len = (int)length(); 65.107 - return array.length == len ? array.clone() : Arrays.copyOf(array, len); 65.108 - } 65.109 - return super.asArrayOfType(componentType); 65.110 - } 65.111 - 65.112 - private double[] toDoubleArray() { 65.113 - assert length() <= array.length : "length exceeds internal array size"; 65.114 - final int len = (int)length(); 65.115 - final double[] darray = new double[array.length]; 65.116 - 65.117 - for (int index = 0; index < len; index++) { 65.118 - darray[index] = array[index]; 65.119 - } 65.120 - 65.121 - return darray; 65.122 - } 65.123 - 65.124 - @Override 65.125 - public ContinuousArrayData convert(final Class<?> type) { 65.126 - if (type == Integer.class || type == Long.class || type == Byte.class || type == Short.class) { 65.127 - return this; 65.128 - } 65.129 - final int len = (int)length(); 65.130 - if (type == Double.class || type == Float.class) { 65.131 - return new NumberArrayData(toDoubleArray(), len); 65.132 - } 65.133 - return new ObjectArrayData(toObjectArray(false), len); 65.134 - } 65.135 - 65.136 - @Override 65.137 - public void shiftLeft(final int by) { 65.138 - System.arraycopy(array, by, array, 0, array.length - by); 65.139 - } 65.140 - 65.141 - @Override 65.142 - public ArrayData shiftRight(final int by) { 65.143 - final ArrayData newData = ensure(by + length() - 1); 65.144 - if (newData != this) { 65.145 - newData.shiftRight(by); 65.146 - return newData; 65.147 - } 65.148 - System.arraycopy(array, 0, array, by, array.length - by); 65.149 - 65.150 - return this; 65.151 - } 65.152 - 65.153 - @Override 65.154 - public ArrayData ensure(final long safeIndex) { 65.155 - if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH) { 65.156 - return new SparseArrayData(this, safeIndex + 1); 65.157 - } 65.158 - final int alen = array.length; 65.159 - if (safeIndex >= alen) { 65.160 - final int newLength = ArrayData.nextSize((int)safeIndex); 65.161 - array = Arrays.copyOf(array, newLength); 65.162 - } 65.163 - if (safeIndex >= length()) { 65.164 - setLength(safeIndex + 1); 65.165 - } 65.166 - return this; 65.167 - } 65.168 - 65.169 - @Override 65.170 - public ArrayData shrink(final long newLength) { 65.171 - Arrays.fill(array, (int)newLength, array.length, 0L); 65.172 - return this; 65.173 - } 65.174 - 65.175 - @Override 65.176 - public ArrayData set(final int index, final Object value, final boolean strict) { 65.177 - if (value instanceof Long || value instanceof Integer || 65.178 - value instanceof Byte || value instanceof Short) { 65.179 - return set(index, ((Number)value).longValue(), strict); 65.180 - } else if (value == ScriptRuntime.UNDEFINED) { 65.181 - return new UndefinedArrayFilter(this).set(index, value, strict); 65.182 - } 65.183 - 65.184 - final ArrayData newData = convert(value == null ? Object.class : value.getClass()); 65.185 - return newData.set(index, value, strict); 65.186 - } 65.187 - 65.188 - @Override 65.189 - public ArrayData set(final int index, final int value, final boolean strict) { 65.190 - array[index] = value; 65.191 - setLength(Math.max(index + 1, length())); 65.192 - return this; 65.193 - } 65.194 - 65.195 - @Override 65.196 - public ArrayData set(final int index, final long value, final boolean strict) { 65.197 - array[index] = value; 65.198 - setLength(Math.max(index + 1, length())); 65.199 - return this; 65.200 - } 65.201 - 65.202 - @Override 65.203 - public ArrayData set(final int index, final double value, final boolean strict) { 65.204 - if (JSType.isRepresentableAsLong(value)) { 65.205 - array[index] = (long)value; 65.206 - setLength(Math.max(index + 1, length())); 65.207 - return this; 65.208 - } 65.209 - return convert(Double.class).set(index, value, strict); 65.210 - } 65.211 - 65.212 - private static final MethodHandle HAS_GET_ELEM = specialCall(MethodHandles.lookup(), LongArrayData.class, "getElem", long.class, int.class).methodHandle(); 65.213 - private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), LongArrayData.class, "setElem", void.class, int.class, long.class).methodHandle(); 65.214 - 65.215 - @SuppressWarnings("unused") 65.216 - private long getElem(final int index) { 65.217 - if (has(index)) { 65.218 - return array[index]; 65.219 - } 65.220 - throw new ClassCastException(); 65.221 - } 65.222 - 65.223 - @SuppressWarnings("unused") 65.224 - private void setElem(final int index, final long elem) { 65.225 - if (hasRoomFor(index)) { 65.226 - array[index] = elem; 65.227 - return; 65.228 - } 65.229 - throw new ClassCastException(); 65.230 - } 65.231 - 65.232 - @Override 65.233 - public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) { 65.234 - if (returnType == int.class) { 65.235 - return null; 65.236 - } 65.237 - return getContinuousElementGetter(HAS_GET_ELEM, returnType, programPoint); 65.238 - } 65.239 - 65.240 - @Override 65.241 - public MethodHandle getElementSetter(final Class<?> elementType) { 65.242 - return elementType == int.class || elementType == long.class ? getContinuousElementSetter(MH.asType(SET_ELEM, SET_ELEM.type().changeParameterType(2, elementType)), elementType) : null; 65.243 - } 65.244 - 65.245 - @Override 65.246 - public int getInt(final int index) { 65.247 - return (int)array[index]; 65.248 - } 65.249 - 65.250 - @Override 65.251 - public long getLong(final int index) { 65.252 - return array[index]; 65.253 - } 65.254 - 65.255 - @Override 65.256 - public long getLongOptimistic(final int index, final int programPoint) { 65.257 - return array[index]; 65.258 - } 65.259 - 65.260 - @Override 65.261 - public double getDouble(final int index) { 65.262 - return array[index]; 65.263 - } 65.264 - 65.265 - @Override 65.266 - public double getDoubleOptimistic(final int index, final int programPoint) { 65.267 - return array[index]; 65.268 - } 65.269 - 65.270 - @Override 65.271 - public Object getObject(final int index) { 65.272 - return array[index]; 65.273 - } 65.274 - 65.275 - @Override 65.276 - public boolean has(final int index) { 65.277 - return 0 <= index && index < length(); 65.278 - } 65.279 - 65.280 - @Override 65.281 - public ArrayData delete(final int index) { 65.282 - return new DeletedRangeArrayFilter(this, index, index); 65.283 - } 65.284 - 65.285 - @Override 65.286 - public ArrayData delete(final long fromIndex, final long toIndex) { 65.287 - return new DeletedRangeArrayFilter(this, fromIndex, toIndex); 65.288 - } 65.289 - 65.290 - @Override 65.291 - public Object pop() { 65.292 - final int len = (int)length(); 65.293 - if (len == 0) { 65.294 - return ScriptRuntime.UNDEFINED; 65.295 - } 65.296 - 65.297 - final int newLength = len - 1; 65.298 - final long elem = array[newLength]; 65.299 - array[newLength] = 0; 65.300 - setLength(newLength); 65.301 - 65.302 - return elem; 65.303 - } 65.304 - 65.305 - @Override 65.306 - public ArrayData slice(final long from, final long to) { 65.307 - final long start = from < 0 ? from + length() : from; 65.308 - final long newLength = to - start; 65.309 - return new LongArrayData(Arrays.copyOfRange(array, (int)from, (int)to), (int)newLength); 65.310 - } 65.311 - 65.312 - @Override 65.313 - public ArrayData fastSplice(final int start, final int removed, final int added) throws UnsupportedOperationException { 65.314 - final long oldLength = length(); 65.315 - final long newLength = oldLength - removed + added; 65.316 - if (newLength > SparseArrayData.MAX_DENSE_LENGTH && newLength > array.length) { 65.317 - throw new UnsupportedOperationException(); 65.318 - } 65.319 - final ArrayData returnValue = removed == 0 ? 65.320 - EMPTY_ARRAY : new LongArrayData(Arrays.copyOfRange(array, start, start + removed), removed); 65.321 - 65.322 - if (newLength != oldLength) { 65.323 - final long[] newArray; 65.324 - 65.325 - if (newLength > array.length) { 65.326 - newArray = new long[ArrayData.nextSize((int)newLength)]; 65.327 - System.arraycopy(array, 0, newArray, 0, start); 65.328 - } else { 65.329 - newArray = array; 65.330 - } 65.331 - 65.332 - System.arraycopy(array, start + removed, newArray, start + added, (int)(oldLength - start - removed)); 65.333 - array = newArray; 65.334 - setLength(newLength); 65.335 - } 65.336 - 65.337 - return returnValue; 65.338 - } 65.339 - 65.340 - @Override 65.341 - public long fastPush(final int arg) { 65.342 - return fastPush((long)arg); 65.343 - } 65.344 - 65.345 - @Override 65.346 - public long fastPush(final long arg) { 65.347 - final int len = (int)length(); 65.348 - if (len == array.length) { 65.349 - array = Arrays.copyOf(array, nextSize(len)); 65.350 - } 65.351 - array[len] = arg; 65.352 - return increaseLength(); 65.353 - } 65.354 - 65.355 - @Override 65.356 - public long fastPopLong() { 65.357 - if (length() == 0) { 65.358 - throw new ClassCastException(); //undefined result 65.359 - } 65.360 - final int newLength = (int)decreaseLength(); 65.361 - final long elem = array[newLength]; 65.362 - array[newLength] = 0; 65.363 - return elem; 65.364 - } 65.365 - 65.366 - @Override 65.367 - public double fastPopDouble() { 65.368 - return fastPopLong(); 65.369 - } 65.370 - 65.371 - @Override 65.372 - public Object fastPopObject() { 65.373 - return fastPopLong(); 65.374 - } 65.375 - 65.376 - @Override 65.377 - public ContinuousArrayData fastConcat(final ContinuousArrayData otherData) { 65.378 - final int otherLength = (int)otherData.length(); 65.379 - final int thisLength = (int)length(); 65.380 - assert otherLength > 0 && thisLength > 0; 65.381 - 65.382 - final long[] otherArray = ((LongArrayData)otherData).array; 65.383 - final int newLength = otherLength + thisLength; 65.384 - final long[] newArray = new long[ArrayData.alignUp(newLength)]; 65.385 - 65.386 - System.arraycopy(array, 0, newArray, 0, thisLength); 65.387 - System.arraycopy(otherArray, 0, newArray, thisLength, otherLength); 65.388 - 65.389 - return new LongArrayData(newArray, newLength); 65.390 - } 65.391 - 65.392 - @Override 65.393 - public String toString() { 65.394 - assert length() <= array.length : length() + " > " + array.length; 65.395 - 65.396 - final StringBuilder sb = new StringBuilder(getClass().getSimpleName()). 65.397 - append(": ["); 65.398 - final int len = (int)length(); 65.399 - for (int i = 0; i < len; i++) { 65.400 - sb.append(array[i]).append('L'); //make sure L suffix is on elements, to discriminate this from IntArrayData.toString() 65.401 - if (i + 1 < len) { 65.402 - sb.append(", "); 65.403 - } 65.404 - } 65.405 - sb.append(']'); 65.406 - 65.407 - return sb.toString(); 65.408 - } 65.409 -}
66.1 --- a/src/jdk/nashorn/internal/runtime/arrays/NonExtensibleArrayFilter.java Tue Jan 26 11:36:10 2016 -0800 66.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/NonExtensibleArrayFilter.java Fri Feb 05 23:32:52 2016 -0800 66.3 @@ -51,14 +51,6 @@ 66.4 } 66.5 66.6 @Override 66.7 - public ArrayData set(final int index, final long value, final boolean strict) { 66.8 - if (has(index)) { 66.9 - return underlying.set(index, value, strict); 66.10 - } 66.11 - return extensionCheck(strict, index); 66.12 - } 66.13 - 66.14 - @Override 66.15 public ArrayData set(final int index, final double value, final boolean strict) { 66.16 if (has(index)) { 66.17 return underlying.set(index, value, strict);
67.1 --- a/src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java Tue Jan 26 11:36:10 2016 -0800 67.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java Fri Feb 05 23:32:52 2016 -0800 67.3 @@ -29,10 +29,11 @@ 67.4 import static jdk.nashorn.internal.lookup.Lookup.MH; 67.5 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; 67.6 67.7 -import jdk.internal.dynalink.support.TypeUtilities; 67.8 import java.lang.invoke.MethodHandle; 67.9 import java.lang.invoke.MethodHandles; 67.10 import java.util.Arrays; 67.11 +import jdk.internal.dynalink.support.TypeUtilities; 67.12 +import jdk.nashorn.internal.runtime.JSType; 67.13 67.14 /** 67.15 * Implementation of {@link ArrayData} as soon as a double has been 67.16 @@ -178,13 +179,6 @@ 67.17 } 67.18 67.19 @Override 67.20 - public ArrayData set(final int index, final long value, final boolean strict) { 67.21 - array[index] = value; 67.22 - setLength(Math.max(index + 1, length())); 67.23 - return this; 67.24 - } 67.25 - 67.26 - @Override 67.27 public ArrayData set(final int index, final double value, final boolean strict) { 67.28 array[index] = value; 67.29 setLength(Math.max(index + 1, length())); 67.30 @@ -213,7 +207,7 @@ 67.31 67.32 @Override 67.33 public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) { 67.34 - if (returnType == int.class || returnType == long.class) { 67.35 + if (returnType == int.class) { 67.36 return null; 67.37 } 67.38 return getContinuousElementGetter(HAS_GET_ELEM, returnType, programPoint); 67.39 @@ -226,12 +220,7 @@ 67.40 67.41 @Override 67.42 public int getInt(final int index) { 67.43 - return (int)array[index]; 67.44 - } 67.45 - 67.46 - @Override 67.47 - public long getLong(final int index) { 67.48 - return (long)array[index]; 67.49 + return JSType.toInt32(array[index]); 67.50 } 67.51 67.52 @Override 67.53 @@ -314,17 +303,17 @@ 67.54 } 67.55 67.56 @Override 67.57 - public long fastPush(final int arg) { 67.58 + public double fastPush(final int arg) { 67.59 return fastPush((double)arg); 67.60 } 67.61 67.62 @Override 67.63 - public long fastPush(final long arg) { 67.64 + public double fastPush(final long arg) { 67.65 return fastPush((double)arg); 67.66 } 67.67 67.68 @Override 67.69 - public long fastPush(final double arg) { 67.70 + public double fastPush(final double arg) { 67.71 final int len = (int)length(); 67.72 if (len == array.length) { 67.73 //note that fastpush never creates spares arrays, there is nothing to gain by that - it will just use even more memory
68.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java Tue Jan 26 11:36:10 2016 -0800 68.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java Fri Feb 05 23:32:52 2016 -0800 68.3 @@ -150,13 +150,6 @@ 68.4 } 68.5 68.6 @Override 68.7 - public ArrayData set(final int index, final long value, final boolean strict) { 68.8 - array[index] = value; 68.9 - setLength(Math.max(index + 1, length())); 68.10 - return this; 68.11 - } 68.12 - 68.13 - @Override 68.14 public ArrayData set(final int index, final double value, final boolean strict) { 68.15 array[index] = value; 68.16 setLength(Math.max(index + 1, length())); 68.17 @@ -216,11 +209,6 @@ 68.18 } 68.19 68.20 @Override 68.21 - public long getLong(final int index) { 68.22 - return JSType.toLong(array[index]); 68.23 - } 68.24 - 68.25 - @Override 68.26 public double getDouble(final int index) { 68.27 return JSType.toNumber(array[index]); 68.28 } 68.29 @@ -248,22 +236,22 @@ 68.30 } 68.31 68.32 @Override 68.33 - public long fastPush(final int arg) { 68.34 + public double fastPush(final int arg) { 68.35 return fastPush((Object)arg); 68.36 } 68.37 68.38 @Override 68.39 - public long fastPush(final long arg) { 68.40 + public double fastPush(final long arg) { 68.41 return fastPush((Object)arg); 68.42 } 68.43 68.44 @Override 68.45 - public long fastPush(final double arg) { 68.46 + public double fastPush(final double arg) { 68.47 return fastPush((Object)arg); 68.48 } 68.49 68.50 @Override 68.51 - public long fastPush(final Object arg) { 68.52 + public double fastPush(final Object arg) { 68.53 final int len = (int)length(); 68.54 if (len == array.length) { 68.55 array = Arrays.copyOf(array, nextSize(len));
69.1 --- a/src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java Tue Jan 26 11:36:10 2016 -0800 69.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java Fri Feb 05 23:32:52 2016 -0800 69.3 @@ -195,21 +195,6 @@ 69.4 } 69.5 69.6 @Override 69.7 - public ArrayData set(final int index, final long value, final boolean strict) { 69.8 - if (index >= 0 && index < maxDenseLength) { 69.9 - final long oldLength = underlying.length(); 69.10 - ensure(index); 69.11 - underlying = underlying.set(index, value, strict).safeDelete(oldLength, index - 1, strict); 69.12 - setLength(Math.max(underlying.length(), length())); 69.13 - } else { 69.14 - final Long longIndex = indexToKey(index); 69.15 - sparseMap.put(longIndex, value); 69.16 - setLength(Math.max(longIndex + 1, length())); 69.17 - } 69.18 - return this; 69.19 - } 69.20 - 69.21 - @Override 69.22 public ArrayData set(final int index, final double value, final boolean strict) { 69.23 if (index >= 0 && index < maxDenseLength) { 69.24 final long oldLength = underlying.length(); 69.25 @@ -258,22 +243,6 @@ 69.26 } 69.27 69.28 @Override 69.29 - public long getLong(final int index) { 69.30 - if (index >= 0 && index < maxDenseLength) { 69.31 - return underlying.getLong(index); 69.32 - } 69.33 - return JSType.toLong(sparseMap.get(indexToKey(index))); 69.34 - } 69.35 - 69.36 - @Override 69.37 - public long getLongOptimistic(final int index, final int programPoint) { 69.38 - if (index >= 0 && index < maxDenseLength) { 69.39 - return underlying.getLongOptimistic(index, programPoint); 69.40 - } 69.41 - return JSType.toLongOptimistic(sparseMap.get(indexToKey(index)), programPoint); 69.42 - } 69.43 - 69.44 - @Override 69.45 public double getDouble(final int index) { 69.46 if (index >= 0 && index < maxDenseLength) { 69.47 return underlying.getDouble(index);
70.1 --- a/src/jdk/nashorn/internal/runtime/arrays/UndefinedArrayFilter.java Tue Jan 26 11:36:10 2016 -0800 70.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/UndefinedArrayFilter.java Fri Feb 05 23:32:52 2016 -0800 70.3 @@ -128,13 +128,6 @@ 70.4 } 70.5 70.6 @Override 70.7 - public ArrayData set(final int index, final long value, final boolean strict) { 70.8 - undefined.clear(index); 70.9 - 70.10 - return super.set(index, value, strict); 70.11 - } 70.12 - 70.13 - @Override 70.14 public ArrayData set(final int index, final double value, final boolean strict) { 70.15 undefined.clear(index); 70.16 70.17 @@ -160,24 +153,6 @@ 70.18 } 70.19 70.20 @Override 70.21 - public long getLong(final int index) { 70.22 - if (undefined.isSet(index)) { 70.23 - return 0L; 70.24 - } 70.25 - 70.26 - return super.getLong(index); 70.27 - } 70.28 - 70.29 - @Override 70.30 - public long getLongOptimistic(final int index, final int programPoint) { 70.31 - if (undefined.isSet(index)) { 70.32 - throw new UnwarrantedOptimismException(UNDEFINED, programPoint); 70.33 - } 70.34 - 70.35 - return super.getLongOptimistic(index, programPoint); 70.36 - } 70.37 - 70.38 - @Override 70.39 public double getDouble(final int index) { 70.40 if (undefined.isSet(index)) { 70.41 return Double.NaN;
71.1 --- a/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java Tue Jan 26 11:36:10 2016 -0800 71.2 +++ b/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java Fri Feb 05 23:32:52 2016 -0800 71.3 @@ -215,7 +215,7 @@ 71.4 * 71.5 * @return callsite for a math intrinsic node 71.6 */ 71.7 - public static CallSite mathBootstrap(final MethodHandles.Lookup lookup, final String name, final MethodType type, final int programPoint) { 71.8 + public static CallSite mathBootstrap(final Lookup lookup, final String name, final MethodType type, final int programPoint) { 71.9 final MethodHandle mh; 71.10 switch (name) { 71.11 case "iadd": 71.12 @@ -236,24 +236,6 @@ 71.13 case "ineg": 71.14 mh = JSType.NEGATE_EXACT.methodHandle(); 71.15 break; 71.16 - case "ladd": 71.17 - mh = JSType.ADD_EXACT_LONG.methodHandle(); 71.18 - break; 71.19 - case "lsub": 71.20 - mh = JSType.SUB_EXACT_LONG.methodHandle(); 71.21 - break; 71.22 - case "lmul": 71.23 - mh = JSType.MUL_EXACT_LONG.methodHandle(); 71.24 - break; 71.25 - case "ldiv": 71.26 - mh = JSType.DIV_EXACT_LONG.methodHandle(); 71.27 - break; 71.28 - case "lrem": 71.29 - mh = JSType.REM_EXACT_LONG.methodHandle(); 71.30 - break; 71.31 - case "lneg": 71.32 - mh = JSType.NEGATE_EXACT_LONG.methodHandle(); 71.33 - break; 71.34 default: 71.35 throw new AssertionError("unsupported math intrinsic"); 71.36 }
72.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java Tue Jan 26 11:36:10 2016 -0800 72.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java Fri Feb 05 23:32:52 2016 -0800 72.3 @@ -141,8 +141,9 @@ 72.4 } 72.5 72.6 /** 72.7 - * Main part of the implementation of {@link GuardingTypeConverterFactory#convertToType(Class, Class)} that doesn't 72.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). 72.9 + * Main part of the implementation of {@link GuardingTypeConverterFactory#convertToType} that doesn't 72.10 + * care about adapting the method signature; that's done by the invoking method. Returns conversion 72.11 + * from Object to String/number/boolean (JS primitive types). 72.12 * @param sourceType the source type 72.13 * @param targetType the target type 72.14 * @return a guarded invocation that converts from the source type to the target type.
73.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java Tue Jan 26 11:36:10 2016 -0800 73.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java Fri Feb 05 23:32:52 2016 -0800 73.3 @@ -34,6 +34,7 @@ 73.4 import jdk.internal.dynalink.linker.LinkRequest; 73.5 import jdk.nashorn.api.scripting.JSObject; 73.6 import jdk.nashorn.internal.objects.Global; 73.7 +import jdk.nashorn.internal.runtime.JSType; 73.8 import jdk.nashorn.internal.runtime.Property; 73.9 import jdk.nashorn.internal.runtime.PropertyMap; 73.10 import jdk.nashorn.internal.runtime.ScriptFunction; 73.11 @@ -46,10 +47,9 @@ 73.12 public final class NashornGuards { 73.13 private static final MethodHandle IS_MAP = findOwnMH("isMap", boolean.class, ScriptObject.class, PropertyMap.class); 73.14 private static final MethodHandle IS_MAP_SCRIPTOBJECT = findOwnMH("isMap", boolean.class, Object.class, PropertyMap.class); 73.15 - private static final MethodHandle IS_INSTANCEOF_2 = findOwnMH("isInstanceOf2", boolean.class, Object.class, Class.class, Class.class); 73.16 private static final MethodHandle IS_SCRIPTOBJECT = findOwnMH("isScriptObject", boolean.class, Object.class); 73.17 private static final MethodHandle IS_NOT_JSOBJECT = findOwnMH("isNotJSObject", boolean.class, Object.class); 73.18 - private static final MethodHandle SAME_OBJECT = findOwnMH("sameObject", boolean.class, Object.class, WeakReference.class); 73.19 + private static final MethodHandle SAME_OBJECT = findOwnMH("sameObject", boolean.class, Object.class, WeakReference.class); 73.20 //TODO - maybe put this back in ScriptFunction instead of the ClassCastException.class relinkage 73.21 //private static final MethodHandle IS_SCRIPTFUNCTION = findOwnMH("isScriptFunction", boolean.class, Object.class); 73.22 73.23 @@ -165,14 +165,21 @@ 73.24 } 73.25 73.26 /** 73.27 - * Get a guard that checks if in item is an instance of either of two classes. 73.28 + * Get a guard that checks if in item is a JS string. 73.29 * 73.30 - * @param class1 the first class 73.31 - * @param class2 the second class 73.32 * @return method handle for guard 73.33 */ 73.34 - public static MethodHandle getInstanceOf2Guard(final Class<?> class1, final Class<?> class2) { 73.35 - return MH.insertArguments(IS_INSTANCEOF_2, 1, class1, class2); 73.36 + public static MethodHandle getStringGuard() { 73.37 + return JSType.IS_STRING.methodHandle(); 73.38 + } 73.39 + 73.40 + /** 73.41 + * Get a guard that checks if in item is a JS number. 73.42 + * 73.43 + * @return method handle for guard 73.44 + */ 73.45 + public static MethodHandle getNumberGuard() { 73.46 + return JSType.IS_NUMBER.methodHandle(); 73.47 } 73.48 73.49 /** 73.50 @@ -224,11 +231,6 @@ 73.51 } 73.52 73.53 @SuppressWarnings("unused") 73.54 - private static boolean isInstanceOf2(final Object self, final Class<?> class1, final Class<?> class2) { 73.55 - return class1.isInstance(self) || class2.isInstance(self); 73.56 - } 73.57 - 73.58 - @SuppressWarnings("unused") 73.59 private static boolean isScriptFunction(final Object self) { 73.60 return self instanceof ScriptFunction; 73.61 }
74.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java Tue Jan 26 11:36:10 2016 -0800 74.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java Fri Feb 05 23:32:52 2016 -0800 74.3 @@ -57,7 +57,8 @@ 74.4 } 74.5 74.6 private static boolean canLinkTypeStatic(final Class<?> type) { 74.7 - return type == String.class || type == Boolean.class || type == ConsString.class || Number.class.isAssignableFrom(type); 74.8 + return type == String.class || type == Boolean.class || type == ConsString.class || type == Integer.class 74.9 + || type == Double.class || type == Float.class || type == Short.class || type == Byte.class; 74.10 } 74.11 74.12 @Override 74.13 @@ -171,7 +172,7 @@ 74.14 74.15 @SuppressWarnings("unused") 74.16 private static boolean isJavaScriptPrimitive(final Object o) { 74.17 - return JSType.isString(o) || o instanceof Boolean || o instanceof Number || o == null; 74.18 + return JSType.isString(o) || o instanceof Boolean || JSType.isNumber(o) || o == null; 74.19 } 74.20 74.21 private static final MethodHandle GUARD_PRIMITIVE = findOwnMH("isJavaScriptPrimitive", boolean.class, Object.class);
75.1 --- a/test/script/basic/JDK-8030200.js Tue Jan 26 11:36:10 2016 -0800 75.2 +++ b/test/script/basic/JDK-8030200.js Fri Feb 05 23:32:52 2016 -0800 75.3 @@ -33,4 +33,4 @@ 75.4 var s = n.toString(5); 75.5 var m = parseInt(s, 5); 75.6 print(m === n); 75.7 -print(n); 75.8 +print(m);
76.1 --- a/test/script/basic/JDK-8062799.js Tue Jan 26 11:36:10 2016 -0800 76.2 +++ b/test/script/basic/JDK-8062799.js Fri Feb 05 23:32:52 2016 -0800 76.3 @@ -33,67 +33,46 @@ 76.4 76.5 var b = true; 76.6 var i = 1; 76.7 - var l = 4294967296; 76.8 var d = 2.1; 76.9 var o = "foo"; 76.10 76.11 print(inspect(b || b, "b || b")); 76.12 print(inspect(b || i, "b || i")); 76.13 - print(inspect(b || l, "b || l")); 76.14 print(inspect(b || d, "b || d")); 76.15 print(inspect(b || o, "b || o")); 76.16 76.17 print(inspect(i || b, "i || b")); 76.18 print(inspect(i || i, "i || i")); 76.19 - print(inspect(i || l, "i || l")); 76.20 print(inspect(i || d, "i || d")); 76.21 print(inspect(i || o, "i || o")); 76.22 76.23 - print(inspect(l || b, "l || b")); 76.24 - print(inspect(l || i, "l || i")); 76.25 - print(inspect(l || l, "l || l")); 76.26 - print(inspect(l || d, "l || d")); 76.27 - print(inspect(l || o, "l || o")); 76.28 - 76.29 print(inspect(d || b, "d || b")); 76.30 print(inspect(d || i, "d || i")); 76.31 - print(inspect(d || l, "d || l")); 76.32 print(inspect(d || d, "d || d")); 76.33 print(inspect(d || o, "d || o")); 76.34 76.35 print(inspect(o || b, "o || b")); 76.36 print(inspect(o || i, "o || i")); 76.37 - print(inspect(o || l, "o || l")); 76.38 print(inspect(o || d, "o || d")); 76.39 print(inspect(o || o, "o || o")); 76.40 76.41 print(inspect(b && b, "b && b")); 76.42 print(inspect(b && i, "b && i")); 76.43 - print(inspect(b && l, "b && l")); 76.44 print(inspect(b && d, "b && d")); 76.45 print(inspect(b && o, "b && o")); 76.46 76.47 print(inspect(i && b, "i && b")); 76.48 print(inspect(i && i, "i && i")); 76.49 - print(inspect(i && l, "i && l")); 76.50 print(inspect(i && d, "i && d")); 76.51 print(inspect(i && o, "i && o")); 76.52 76.53 - print(inspect(l && b, "l && b")); 76.54 - print(inspect(l && i, "l && i")); 76.55 - print(inspect(l && l, "l && l")); 76.56 - print(inspect(l && d, "l && d")); 76.57 - print(inspect(l && o, "l && o")); 76.58 - 76.59 print(inspect(d && b, "d && b")); 76.60 print(inspect(d && i, "d && i")); 76.61 - print(inspect(d && l, "d && l")); 76.62 print(inspect(d && d, "d && d")); 76.63 print(inspect(d && o, "d && o")); 76.64 76.65 print(inspect(o && b, "o && b")); 76.66 print(inspect(o && i, "o && i")); 76.67 - print(inspect(o && l, "o && l")); 76.68 print(inspect(o && d, "o && d")); 76.69 print(inspect(o && o, "o && o")); 76.70 })();
77.1 --- a/test/script/basic/JDK-8062799.js.EXPECTED Tue Jan 26 11:36:10 2016 -0800 77.2 +++ b/test/script/basic/JDK-8062799.js.EXPECTED Fri Feb 05 23:32:52 2016 -0800 77.3 @@ -1,50 +1,32 @@ 77.4 b || b: boolean 77.5 b || i: boolean 77.6 -b || l: boolean 77.7 b || d: boolean 77.8 b || o: boolean 77.9 i || b: int 77.10 i || i: int 77.11 -i || l: long 77.12 i || d: double 77.13 i || o: int 77.14 -l || b: long 77.15 -l || i: long 77.16 -l || l: long 77.17 -l || d: double 77.18 -l || o: long 77.19 d || b: double 77.20 d || i: double 77.21 -d || l: double 77.22 d || d: double 77.23 d || o: double 77.24 o || b: object 77.25 o || i: object 77.26 -o || l: object 77.27 o || d: object 77.28 o || o: object 77.29 b && b: boolean 77.30 b && i: int 77.31 -b && l: long 77.32 b && d: double 77.33 b && o: object 77.34 i && b: boolean 77.35 i && i: int 77.36 -i && l: long 77.37 i && d: double 77.38 i && o: object 77.39 -l && b: boolean 77.40 -l && i: long 77.41 -l && l: long 77.42 -l && d: double 77.43 -l && o: object 77.44 d && b: boolean 77.45 d && i: double 77.46 -d && l: double 77.47 d && d: double 77.48 d && o: object 77.49 o && b: boolean 77.50 o && i: int 77.51 -o && l: long 77.52 o && d: double 77.53 o && o: object
78.1 --- a/test/script/basic/JDK-8079145.js.EXPECTED Tue Jan 26 11:36:10 2016 -0800 78.2 +++ b/test/script/basic/JDK-8079145.js.EXPECTED Fri Feb 05 23:32:52 2016 -0800 78.3 @@ -5,8 +5,8 @@ 78.4 int array: check widen for true [class java.lang.Boolean] 78.5 int array: check widen for 34 [class java.lang.Byte] 78.6 int array: check widen for 344454 [class java.lang.Integer] 78.7 -int array: check widen for 454545 [class java.lang.Long] 78.8 -int array: check widen for 2147483648 [class java.lang.Long] 78.9 +int array: check widen for 454545 78.10 +int array: check widen for 2147483648 78.11 int array: check widen for 34.29999923706055 [class java.lang.Float] 78.12 int array: check widen for 3.141592653589793 [class java.lang.Double] 78.13 int array: check widen for s 78.14 @@ -17,8 +17,8 @@ 78.15 long array: check widen for true [class java.lang.Boolean] 78.16 long array: check widen for 34 [class java.lang.Byte] 78.17 long array: check widen for 344454 [class java.lang.Integer] 78.18 -long array: check widen for 454545 [class java.lang.Long] 78.19 -long array: check widen for 2147483648 [class java.lang.Long] 78.20 +long array: check widen for 454545 78.21 +long array: check widen for 2147483648 78.22 long array: check widen for 34.29999923706055 [class java.lang.Float] 78.23 long array: check widen for 3.141592653589793 [class java.lang.Double] 78.24 long array: check widen for s 78.25 @@ -29,8 +29,8 @@ 78.26 number array: check widen for true [class java.lang.Boolean] 78.27 number array: check widen for 34 [class java.lang.Byte] 78.28 number array: check widen for 344454 [class java.lang.Integer] 78.29 -number array: check widen for 454545 [class java.lang.Long] 78.30 -number array: check widen for 2147483648 [class java.lang.Long] 78.31 +number array: check widen for 454545 78.32 +number array: check widen for 2147483648 78.33 number array: check widen for 34.29999923706055 [class java.lang.Float] 78.34 number array: check widen for 3.141592653589793 [class java.lang.Double] 78.35 number array: check widen for s 78.36 @@ -41,8 +41,8 @@ 78.37 object array: check widen for true [class java.lang.Boolean] 78.38 object array: check widen for 34 [class java.lang.Byte] 78.39 object array: check widen for 344454 [class java.lang.Integer] 78.40 -object array: check widen for 454545 [class java.lang.Long] 78.41 -object array: check widen for 2147483648 [class java.lang.Long] 78.42 +object array: check widen for 454545 78.43 +object array: check widen for 2147483648 78.44 object array: check widen for 34.29999923706055 [class java.lang.Float] 78.45 object array: check widen for 3.141592653589793 [class java.lang.Double] 78.46 object array: check widen for s
79.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 79.2 +++ b/test/script/basic/JDK-8143896.js Fri Feb 05 23:32:52 2016 -0800 79.3 @@ -0,0 +1,107 @@ 79.4 +/* 79.5 + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 79.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 79.7 + * 79.8 + * This code is free software; you can redistribute it and/or modify it 79.9 + * under the terms of the GNU General Public License version 2 only, as 79.10 + * published by the Free Software Foundation. 79.11 + * 79.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 79.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 79.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 79.15 + * version 2 for more details (a copy is included in the LICENSE file that 79.16 + * accompanied this code). 79.17 + * 79.18 + * You should have received a copy of the GNU General Public License version 79.19 + * 2 along with this work; if not, write to the Free Software Foundation, 79.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 79.21 + * 79.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 79.23 + * or visit www.oracle.com if you need additional information or have any 79.24 + * questions. 79.25 + */ 79.26 + 79.27 +/** 79.28 + * JDK-8143896: java.lang.Long is implicitly converted to double 79.29 + * 79.30 + * @test 79.31 + * @run 79.32 + */ 79.33 + 79.34 +Assert.assertTrue(java.lang.Long.valueOf("301077366599181567").toString() === "301077366599181567"); 79.35 +Assert.assertTrue(java.lang.Long.valueOf("-301077366599181567").toString() === "-301077366599181567"); 79.36 +Assert.assertTrue(java.lang.Long.valueOf("301077366599181567") == 301077366599181567); 79.37 +Assert.assertFalse(java.lang.Long.valueOf("301077366599181567") === 301077366599181567); 79.38 + 79.39 +Assert.assertTrue(new java.math.BigInteger("301077366599181567").toString() === "301077366599181567"); 79.40 +Assert.assertTrue(new java.math.BigInteger("-301077366599181567").toString() === "-301077366599181567"); 79.41 +Assert.assertTrue(new java.math.BigInteger("301077366599181567") == 301077366599181567); 79.42 +Assert.assertFalse(new java.math.BigInteger("301077366599181567") === 301077366599181567); 79.43 + 79.44 + 79.45 +var n = new java.lang.Byte("123"); 79.46 +Assert.assertTrue(typeof n === "number"); 79.47 +Assert.assertTrue(n + 1 === 124); 79.48 +Assert.assertTrue(n == 123); 79.49 +Assert.assertTrue(n === 123); 79.50 + 79.51 +n = new java.lang.Short("123"); 79.52 +Assert.assertTrue(typeof n === "number"); 79.53 +Assert.assertTrue(n + 1 === 124); 79.54 +Assert.assertTrue(n == 123); 79.55 +Assert.assertTrue(n === 123); 79.56 + 79.57 +n = new java.lang.Integer("123"); 79.58 +Assert.assertTrue(typeof n === "number"); 79.59 +Assert.assertTrue(n + 1 === 124); 79.60 +Assert.assertTrue(n == 123); 79.61 +Assert.assertTrue(n === 123); 79.62 + 79.63 +n = new java.lang.Float("123"); 79.64 +Assert.assertTrue(typeof n === "number"); 79.65 +Assert.assertTrue(n + 1 === 124); 79.66 +Assert.assertTrue(n == 123); 79.67 +Assert.assertTrue(n === 123); 79.68 + 79.69 +n = new java.lang.Double("123"); 79.70 +Assert.assertTrue(typeof n === "number"); 79.71 +Assert.assertTrue(n + 1 === 124); 79.72 +Assert.assertTrue(n == 123); 79.73 +Assert.assertTrue(n === 123); 79.74 + 79.75 +n = new java.lang.Long("123"); 79.76 +Assert.assertTrue(typeof n === "object"); 79.77 +Assert.assertTrue(n + 1 === 124); 79.78 +Assert.assertTrue(n == 123); 79.79 +Assert.assertFalse(n === 123); 79.80 + 79.81 +n = new java.util.concurrent.atomic.DoubleAdder(); 79.82 +n.add("123"); 79.83 +Assert.assertTrue(typeof n === "object"); 79.84 +Assert.assertTrue(n + 1 === 124); 79.85 +Assert.assertTrue(n == 123); 79.86 +Assert.assertFalse(n === 123); 79.87 + 79.88 +n = new java.util.concurrent.atomic.AtomicInteger(123); 79.89 +Assert.assertTrue(typeof n === "object"); 79.90 +Assert.assertTrue(n + 1 === 124); 79.91 +Assert.assertTrue(n == 123); 79.92 +Assert.assertFalse(n === 123); 79.93 + 79.94 +n = new java.util.concurrent.atomic.AtomicLong(123); 79.95 +Assert.assertTrue(typeof n === "object"); 79.96 +Assert.assertTrue(n + 1 === 124); 79.97 +Assert.assertTrue(n == 123); 79.98 +Assert.assertFalse(n === 123); 79.99 + 79.100 +n = new java.math.BigInteger("123"); 79.101 +Assert.assertTrue(typeof n === "object"); 79.102 +Assert.assertTrue(n + 1 === 124); 79.103 +Assert.assertTrue(n == 123); 79.104 +Assert.assertFalse(n === 123); 79.105 + 79.106 +n = new java.math.BigDecimal("123"); 79.107 +Assert.assertTrue(typeof n === "object"); 79.108 +Assert.assertTrue(n + 1 === 124); 79.109 +Assert.assertTrue(n == 123); 79.110 +Assert.assertFalse(n === 123);
80.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 80.2 +++ b/test/script/basic/JDK-8144020.js Fri Feb 05 23:32:52 2016 -0800 80.3 @@ -0,0 +1,126 @@ 80.4 +/* 80.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 80.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 80.7 + * 80.8 + * This code is free software; you can redistribute it and/or modify it 80.9 + * under the terms of the GNU General Public License version 2 only, as 80.10 + * published by the Free Software Foundation. 80.11 + * 80.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 80.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 80.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 80.15 + * version 2 for more details (a copy is included in the LICENSE file that 80.16 + * accompanied this code). 80.17 + * 80.18 + * You should have received a copy of the GNU General Public License version 80.19 + * 2 along with this work; if not, write to the Free Software Foundation, 80.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 80.21 + * 80.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 80.23 + * or visit www.oracle.com if you need additional information or have any 80.24 + * questions. 80.25 + */ 80.26 + 80.27 +/** 80.28 + * JDK-8144020: Remove long as an internal numeric type 80.29 + * 80.30 + * @test 80.31 + * @run 80.32 + */ 80.33 + 80.34 +var LongProvider = Java.type("jdk.nashorn.test.models.LongProvider"); 80.35 +var Long = Java.type("java.lang.Long"); 80.36 +var LongClass = Long.class; 80.37 +var Integer = Java.type("java.lang.Integer"); 80.38 +var Double = Java.type("java.lang.Double"); 80.39 + 80.40 +var INT = "3"; 80.41 +var DOUBLE = "5.5"; 80.42 +var MAX_LONG = "9223372036854775807"; 80.43 +var MIN_LONG = "-9223372036854775808"; 80.44 +var BIG_LONG = "281474976710655"; // can be represented as double 80.45 +var NEG_LONG = "-281474976710656"; // can be represented as double 80.46 +var SMALL_LONG = "13"; 80.47 + 80.48 +// Make sure we can pass longs from and to Java without losing precision 80.49 +LongProvider.checkLong(LongProvider.getLong(MAX_LONG), MAX_LONG); 80.50 +LongProvider.checkLong(LongProvider.getLong(MIN_LONG), MIN_LONG); 80.51 +LongProvider.checkLong(LongProvider.getLong(BIG_LONG), BIG_LONG); 80.52 +LongProvider.checkLong(LongProvider.getLong(NEG_LONG), NEG_LONG); 80.53 +LongProvider.checkLong(LongProvider.getLong(SMALL_LONG), SMALL_LONG); 80.54 + 80.55 +// a polymorphic function that can return various number types 80.56 +function getNumber(str) { 80.57 + switch (str) { 80.58 + case INT: return +INT; 80.59 + case DOUBLE: return +DOUBLE; 80.60 + default: return Long.parseLong(str); 80.61 + } 80.62 +} 80.63 + 80.64 +function compareValue(n, str) { 80.65 + switch (str) { 80.66 + case INT: return Integer.compare(n, Integer.parseInt(str) == 0); 80.67 + case DOUBLE: return Double.compare(n, Double.parseDouble(str) == 0); 80.68 + default: return Long.compare(n, Long.parseLong(str) == 0); 80.69 + } 80.70 +} 80.71 + 80.72 +// Call a a function with a sequence of values. The purpose of this is that we can handle 80.73 +// longs without losing precision in the presence of optimistic deoptimization, cached callsites, etc. 80.74 +function testSequence(fn, values) { 80.75 + for (var i in values) { 80.76 + fn(values[i]); 80.77 + } 80.78 +} 80.79 + 80.80 +// We need to use "fresh" (unlinked and un-deoptimized) functions for each of the test runs. 80.81 +testSequence(function(str) { 80.82 + var n = getNumber(str); 80.83 + Assert.assertTrue(compareValue(n, str)); 80.84 +}, [INT, BIG_LONG, MIN_LONG]); 80.85 + 80.86 +testSequence(function(str) { 80.87 + var n = getNumber(str); 80.88 + Assert.assertTrue(compareValue(n, str)); 80.89 +}, [INT, MAX_LONG]); 80.90 + 80.91 +testSequence(function(str) { 80.92 + var n = getNumber(str); 80.93 + Assert.assertTrue(compareValue(n, str)); 80.94 +}, [INT, DOUBLE, NEG_LONG]); 80.95 + 80.96 +testSequence(function(str) { 80.97 + var n = getNumber(str); 80.98 + Assert.assertTrue(compareValue(n, str)); 80.99 +}, [DOUBLE, MAX_LONG]); 80.100 + 80.101 +testSequence(function(str) { 80.102 + var n = getNumber(str); 80.103 + Assert.assertTrue(compareValue(n, str)); 80.104 +}, [DOUBLE, SMALL_LONG, MAX_LONG]); 80.105 + 80.106 +testSequence(function(str) { 80.107 + var n = getNumber(str); 80.108 + Assert.assertTrue(compareValue(n, str)); 80.109 +}, [INT, DOUBLE, NEG_LONG, MAX_LONG]); 80.110 + 80.111 +testSequence(function(str) { 80.112 + var n = getNumber(str); 80.113 + Assert.assertTrue(compareValue(n, str)); 80.114 +}, [DOUBLE, MAX_LONG, DOUBLE, INT]); 80.115 + 80.116 +// Make sure long arrays make it through Java.from and Java.to without losing precision 80.117 +var longArrayType = Java.type("long[]"); 80.118 +for (var i = 0; i < 3; i++) { 80.119 + LongProvider.checkLongArray(Java.to(Java.from(LongProvider.getLongArray(i)), longArrayType), i); 80.120 +} 80.121 + 80.122 +l = Long.parseLong(BIG_LONG); 80.123 +Assert.assertTrue(l >>> 8 === 0xffffff); 80.124 +Assert.assertTrue(l << 8 === -0x100); 80.125 +Assert.assertTrue(l + 1 === 0x1000000000000); 80.126 +Assert.assertTrue(l - 1 === 0xfffffffffffe); 80.127 + 80.128 +Assert.assertEquals(LongProvider.getLong(MAX_LONG).getClass(), LongClass); 80.129 +Assert.assertEquals(LongProvider.getLong(MIN_LONG).getClass(), LongClass);
81.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 81.2 +++ b/test/script/basic/JDK-8144131.js Fri Feb 05 23:32:52 2016 -0800 81.3 @@ -0,0 +1,44 @@ 81.4 +/* 81.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 81.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 81.7 + * 81.8 + * This code is free software; you can redistribute it and/or modify it 81.9 + * under the terms of the GNU General Public License version 2 only, as 81.10 + * published by the Free Software Foundation. 81.11 + * 81.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 81.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 81.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 81.15 + * version 2 for more details (a copy is included in the LICENSE file that 81.16 + * accompanied this code). 81.17 + * 81.18 + * You should have received a copy of the GNU General Public License version 81.19 + * 2 along with this work; if not, write to the Free Software Foundation, 81.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 81.21 + * 81.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 81.23 + * or visit www.oracle.com if you need additional information or have any 81.24 + * questions. 81.25 + */ 81.26 + 81.27 +/** 81.28 + * JDK-8144131: ArrayData.getInt implementations do not convert to int32 81.29 + * 81.30 + * @test 81.31 + * @run 81.32 + */ 81.33 + 81.34 +var doubleArray = [97912312397.234, -182374983434.56]; 81.35 +var doubleArrayResults = [-871935411, -1986357002]; 81.36 + 81.37 +// Make sure array uses double array data 81.38 +Assert.assertEquals(doubleArray[0].getClass(), java.lang.Double.class); 81.39 + 81.40 +function testBinaryOp(array, index, expected) { 81.41 + Assert.assertEquals(array[index] & 0xffffffff, expected); 81.42 +} 81.43 + 81.44 +for (var i = 0; i < doubleArray.length; i++) { 81.45 + testBinaryOp(doubleArray, i, doubleArrayResults[i]); 81.46 +} 81.47 +
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 82.2 +++ b/test/script/basic/JDK-8145550.js Fri Feb 05 23:32:52 2016 -0800 82.3 @@ -0,0 +1,33 @@ 82.4 +/* 82.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 82.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 82.7 + * 82.8 + * This code is free software; you can redistribute it and/or modify it 82.9 + * under the terms of the GNU General Public License version 2 only, as 82.10 + * published by the Free Software Foundation. 82.11 + * 82.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 82.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 82.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 82.15 + * version 2 for more details (a copy is included in the LICENSE file that 82.16 + * accompanied this code). 82.17 + * 82.18 + * You should have received a copy of the GNU General Public License version 82.19 + * 2 along with this work; if not, write to the Free Software Foundation, 82.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 82.21 + * 82.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 82.23 + * or visit www.oracle.com if you need additional information or have any 82.24 + * questions. 82.25 + */ 82.26 + 82.27 +/** 82.28 + * JDK-8141537: Megamorphic invoke should use CompiledFunction variants without any LinkLogic 82.29 + * 82.30 + * @test 82.31 + * @option -Dnashorn.unstable.relink.threshold=1 82.32 + * @fork 82.33 + * @run 82.34 + */ 82.35 + 82.36 +load(__DIR__ + "NASHORN-421.js")
83.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 83.2 +++ b/test/script/basic/JDK-8146147.js Fri Feb 05 23:32:52 2016 -0800 83.3 @@ -0,0 +1,49 @@ 83.4 +/* 83.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 83.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 83.7 + * 83.8 + * This code is free software; you can redistribute it and/or modify it 83.9 + * under the terms of the GNU General Public License version 2 only, as 83.10 + * published by the Free Software Foundation. 83.11 + * 83.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 83.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 83.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 83.15 + * version 2 for more details (a copy is included in the LICENSE file that 83.16 + * accompanied this code). 83.17 + * 83.18 + * You should have received a copy of the GNU General Public License version 83.19 + * 2 along with this work; if not, write to the Free Software Foundation, 83.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 83.21 + * 83.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 83.23 + * or visit www.oracle.com if you need additional information or have any 83.24 + * questions. 83.25 + */ 83.26 + 83.27 +/** 83.28 + * JDK-8146147: Java linker indexed property getter does not work for computed nashorn string 83.29 + * 83.30 + * @test 83.31 + * @run 83.32 + */ 83.33 + 83.34 +var locale = java.util.Locale.ENGLISH; 83.35 +var prop = 'ISO3Language'; 83.36 +var prop1 = 'ISO3'; 83.37 +var prop2 = prop1 + 'Language'; 83.38 +var prop3 = String(prop2); 83.39 + 83.40 +function checkLang(obj) { 83.41 + if (obj != "eng") { 83.42 + throw new Error("FAILED: expected 'eng', got " + obj); 83.43 + } 83.44 +} 83.45 + 83.46 +checkLang(locale.ISO3Language); 83.47 +checkLang(locale['ISO3Language']); 83.48 +checkLang(locale[prop]); 83.49 +checkLang(locale[prop1 + 'Language']); 83.50 +checkLang(locale[prop2]); 83.51 +checkLang(locale[prop3]); 83.52 +checkLang(locale[String(prop1 + 'Language')]);
84.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 84.2 +++ b/test/script/basic/JDK-8147845.js Fri Feb 05 23:32:52 2016 -0800 84.3 @@ -0,0 +1,44 @@ 84.4 +/* 84.5 + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 84.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 84.7 + * 84.8 + * This code is free software; you can redistribute it and/or modify it 84.9 + * under the terms of the GNU General Public License version 2 only, as 84.10 + * published by the Free Software Foundation. 84.11 + * 84.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 84.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 84.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 84.15 + * version 2 for more details (a copy is included in the LICENSE file that 84.16 + * accompanied this code). 84.17 + * 84.18 + * You should have received a copy of the GNU General Public License version 84.19 + * 2 along with this work; if not, write to the Free Software Foundation, 84.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 84.21 + * 84.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 84.23 + * or visit www.oracle.com if you need additional information or have any 84.24 + * questions. 84.25 + */ 84.26 + 84.27 +/** 84.28 + * JDK-8147845: Varargs Array functions still leaking longs 84.29 + * 84.30 + * @test 84.31 + * @run 84.32 + */ 84.33 + 84.34 +Assert.assertTrue([].push() === 0); 84.35 +Assert.assertTrue([].unshift() === 0); 84.36 +Assert.assertTrue(typeof [].push() === 'number'); 84.37 +Assert.assertTrue(typeof [].unshift() === 'number'); 84.38 + 84.39 +Assert.assertTrue([].push(1, 2, 3) === 3); 84.40 +Assert.assertTrue([].unshift(1, 2, 3) === 3); 84.41 +Assert.assertTrue(typeof [].push(1, 2, 3) === 'number'); 84.42 +Assert.assertTrue(typeof [].unshift(1, 2, 3) === 'number'); 84.43 + 84.44 +Assert.assertTrue([].push(1) === 1); 84.45 +Assert.assertTrue([].unshift(1) === 1); 84.46 +Assert.assertTrue(typeof [].push(1) === 'number'); 84.47 +Assert.assertTrue(typeof [].unshift(1) === 'number');
85.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 85.2 +++ b/test/script/basic/apply_to_call/JDK-8145669.js Fri Feb 05 23:32:52 2016 -0800 85.3 @@ -0,0 +1,33 @@ 85.4 +/* 85.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 85.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 85.7 + * 85.8 + * This code is free software; you can redistribute it and/or modify it 85.9 + * under the terms of the GNU General Public License version 2 only, as 85.10 + * published by the Free Software Foundation. 85.11 + * 85.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 85.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 85.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 85.15 + * version 2 for more details (a copy is included in the LICENSE file that 85.16 + * accompanied this code). 85.17 + * 85.18 + * You should have received a copy of the GNU General Public License version 85.19 + * 2 along with this work; if not, write to the Free Software Foundation, 85.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 85.21 + * 85.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 85.23 + * or visit www.oracle.com if you need additional information or have any 85.24 + * questions. 85.25 + */ 85.26 + 85.27 +/* 85.28 + * JDK-8145669: apply2call optimized callsite fails after becoming megamorphic 85.29 + * 85.30 + * @test 85.31 + * @option -Dnashorn.unstable.relink.threshold=1 85.32 + * @fork 85.33 + * @run 85.34 + */ 85.35 + 85.36 +load(__DIR__ + "apply_to_call2.js");
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 86.2 +++ b/test/script/basic/apply_to_call/JDK-8145669.js.EXPECTED Fri Feb 05 23:32:52 2016 -0800 86.3 @@ -0,0 +1,8 @@ 86.4 +start 86.5 +4711 86.6 +23 86.7 +17 86.8 +Overwriting call now 86.9 +1 86.10 +2 86.11 +3
87.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 87.2 +++ b/test/script/basic/apply_to_call/JDK-8145669_2.js Fri Feb 05 23:32:52 2016 -0800 87.3 @@ -0,0 +1,33 @@ 87.4 +/* 87.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 87.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 87.7 + * 87.8 + * This code is free software; you can redistribute it and/or modify it 87.9 + * under the terms of the GNU General Public License version 2 only, as 87.10 + * published by the Free Software Foundation. 87.11 + * 87.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 87.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 87.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 87.15 + * version 2 for more details (a copy is included in the LICENSE file that 87.16 + * accompanied this code). 87.17 + * 87.18 + * You should have received a copy of the GNU General Public License version 87.19 + * 2 along with this work; if not, write to the Free Software Foundation, 87.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 87.21 + * 87.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 87.23 + * or visit www.oracle.com if you need additional information or have any 87.24 + * questions. 87.25 + */ 87.26 + 87.27 +/** 87.28 + * JDK-8145669: apply2call optimized callsite fails after becoming megamorphic 87.29 + * 87.30 + * @test 87.31 + * @option -Dnashorn.unstable.relink.threshold=1 87.32 + * @fork 87.33 + * @run 87.34 + */ 87.35 + 87.36 +load(__DIR__ + "apply_to_call_varargs.js");
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 88.2 +++ b/test/script/basic/apply_to_call/JDK-8145669_2.js.EXPECTED Fri Feb 05 23:32:52 2016 -0800 88.3 @@ -0,0 +1,66 @@ 88.4 +[red=0, green=255, blue=255] 88.5 +undefined 88.6 +[red=1, green=255, blue=255] 88.7 +undefined 88.8 +[red=2, green=255, blue=255] 88.9 +undefined 88.10 +[red=3, green=255, blue=255] 88.11 +undefined 88.12 +[red=4, green=255, blue=255] 88.13 +undefined 88.14 +[red=5, green=255, blue=255] 88.15 +undefined 88.16 +[red=6, green=255, blue=255] 88.17 +undefined 88.18 +[red=7, green=255, blue=255] 88.19 +undefined 88.20 +[red=8, green=255, blue=255] 88.21 +undefined 88.22 +[red=9, green=255, blue=255] 88.23 +undefined 88.24 +[red=10, green=255, blue=255] 88.25 +undefined 88.26 +[red=11, green=255, blue=255] 88.27 +undefined 88.28 +[red=12, green=255, blue=255] 88.29 +undefined 88.30 +[red=13, green=255, blue=255] 88.31 +undefined 88.32 +[red=14, green=255, blue=255] 88.33 +undefined 88.34 +[red=15, green=255, blue=255] 88.35 +undefined 88.36 +Swapping out call 88.37 +[red=0, green=255, blue=255] 88.38 +undefined 88.39 +[red=1, green=255, blue=255] 88.40 +undefined 88.41 +[red=2, green=255, blue=255] 88.42 +undefined 88.43 +[red=3, green=255, blue=255] 88.44 +undefined 88.45 +[red=4, green=255, blue=255] 88.46 +undefined 88.47 +[red=5, green=255, blue=255] 88.48 +undefined 88.49 +[red=6, green=255, blue=255] 88.50 +undefined 88.51 +[red=7, green=255, blue=255] 88.52 +undefined 88.53 +[red=8, green=255, blue=255] 88.54 +undefined 88.55 +[red=9, green=255, blue=255] 88.56 +undefined 88.57 +[red=10, green=255, blue=255] 88.58 +undefined 88.59 +[red=11, green=255, blue=255] 88.60 +undefined 88.61 +[red=12, green=255, blue=255] 88.62 +undefined 88.63 +[red=13, green=255, blue=255] 88.64 +undefined 88.65 +[red=14, green=255, blue=255] 88.66 +undefined 88.67 +[red=15, green=255, blue=255] 88.68 +undefined 88.69 +All done!
89.1 --- a/test/script/basic/minuszero.js Tue Jan 26 11:36:10 2016 -0800 89.2 +++ b/test/script/basic/minuszero.js Fri Feb 05 23:32:52 2016 -0800 89.3 @@ -39,3 +39,7 @@ 89.4 print(obj.length === -0); 89.5 print(1/obj.length); 89.6 89.7 +var mzl = -(0x7fffffffffffffff - 0x7fffffffffffffff); 89.8 +print(mzl); 89.9 +print(mzl === -0); 89.10 +print(1/mzl); 89.11 \ No newline at end of file
90.1 --- a/test/script/basic/minuszero.js.EXPECTED Tue Jan 26 11:36:10 2016 -0800 90.2 +++ b/test/script/basic/minuszero.js.EXPECTED Fri Feb 05 23:32:52 2016 -0800 90.3 @@ -4,3 +4,6 @@ 90.4 0 90.5 true 90.6 -Infinity 90.7 +0 90.8 +true 90.9 +-Infinity
91.1 --- a/test/script/nosecurity/JDK-8067215.js Tue Jan 26 11:36:10 2016 -0800 91.2 +++ b/test/script/nosecurity/JDK-8067215.js Fri Feb 05 23:32:52 2016 -0800 91.3 @@ -32,7 +32,6 @@ 91.4 91.5 var intType = Java.type("int"); 91.6 var doubleType = Java.type("double"); 91.7 -var longType = Java.type("long"); 91.8 var objectType = Java.type("java.lang.Object"); 91.9 91.10 var Context = Java.type("jdk.nashorn.internal.runtime.Context"); 91.11 @@ -58,7 +57,6 @@ 91.12 } 91.13 if (prop.getType() != getExpectedType(obj[key])) { 91.14 throw new Error("Wrong property type: " + prop.getType() + " // " + getExpectedType(obj[key])); 91.15 - 91.16 } 91.17 } 91.18 } 91.19 @@ -67,14 +65,8 @@ 91.20 if (!dualFields) { 91.21 return objectType.class; 91.22 } 91.23 - if (JSType.isRepresentableAsInt(value)) { 91.24 - return intType.class; 91.25 - } 91.26 - if (JSType.isRepresentableAsLong(value)) { 91.27 - return longType.class; 91.28 - } 91.29 - if (JSType.isNumber(value)) { 91.30 - return doubleType.class; 91.31 + if (typeof value === "number") { 91.32 + return JSType.isRepresentableAsInt(value) ? intType.class : doubleType.class; 91.33 } 91.34 return objectType.class; 91.35 }
92.1 --- a/test/src/jdk/nashorn/api/javaaccess/test/NumberAccessTest.java Tue Jan 26 11:36:10 2016 -0800 92.2 +++ b/test/src/jdk/nashorn/api/javaaccess/test/NumberAccessTest.java Fri Feb 05 23:32:52 2016 -0800 92.3 @@ -143,7 +143,7 @@ 92.4 @Test 92.5 public void accessStaticFinalFieldLong() throws ScriptException { 92.6 e.eval("var psf_long = SharedObject.publicStaticFinalLong;"); 92.7 - assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long")); 92.8 + assertEquals(SharedObject.publicStaticFinalLong, ((Number) e.get("psf_long")).longValue()); 92.9 e.eval("SharedObject.publicStaticFinalLong = 120;"); 92.10 assertEquals(8333333333333L, SharedObject.publicStaticFinalLong); 92.11 }
93.1 --- a/test/src/jdk/nashorn/api/javaaccess/test/NumberBoxingTest.java Tue Jan 26 11:36:10 2016 -0800 93.2 +++ b/test/src/jdk/nashorn/api/javaaccess/test/NumberBoxingTest.java Fri Feb 05 23:32:52 2016 -0800 93.3 @@ -70,7 +70,7 @@ 93.4 @Test 93.5 public void accessFieldLongBoxing() throws ScriptException { 93.6 e.eval("var p_long = o.publicLongBox;"); 93.7 - assertEquals(o.publicLongBox, e.get("p_long")); 93.8 + assertEquals(o.publicLongBox.longValue(), ((Number) e.get("p_long")).longValue()); 93.9 e.eval("o.publicLongBox = 12;"); 93.10 assertEquals(Long.valueOf(12), o.publicLongBox); 93.11 } 93.12 @@ -78,7 +78,7 @@ 93.13 @Test 93.14 public void accessStaticFieldLongBoxing() throws ScriptException { 93.15 e.eval("var ps_long = SharedObject.publicStaticLongBox;"); 93.16 - assertEquals(SharedObject.publicStaticLongBox, e.get("ps_long")); 93.17 + assertEquals(SharedObject.publicStaticLongBox.longValue(), ((Number) e.get("ps_long")).longValue()); 93.18 e.eval("SharedObject.publicStaticLongBox = 120;"); 93.19 assertEquals(120L, SharedObject.publicStaticLongBox.longValue()); 93.20 } 93.21 @@ -86,7 +86,7 @@ 93.22 @Test 93.23 public void accessFinalFieldLongBoxing() throws ScriptException { 93.24 e.eval("var pf_long = o.publicFinalLongBox;"); 93.25 - assertEquals(o.publicFinalLongBox, e.get("pf_long")); 93.26 + assertEquals(o.publicFinalLongBox.longValue(), ((Number) e.get("pf_long")).longValue()); 93.27 e.eval("o.publicFinalLongBox = 120;"); 93.28 assertEquals(Long.valueOf(9377333334L), o.publicFinalLongBox); 93.29 } 93.30 @@ -94,7 +94,7 @@ 93.31 @Test 93.32 public void accessStaticFinalFieldLongBoxing() throws ScriptException { 93.33 e.eval("var psf_long = SharedObject.publicStaticFinalLong;"); 93.34 - assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long")); 93.35 + assertEquals(SharedObject.publicStaticFinalLong, ((Number) e.get("psf_long")).longValue()); 93.36 e.eval("SharedObject.publicStaticFinalLong = 120;"); 93.37 assertEquals(8333333333333L, SharedObject.publicStaticFinalLong); 93.38 }
94.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 94.2 +++ b/test/src/jdk/nashorn/test/models/LongProvider.java Fri Feb 05 23:32:52 2016 -0800 94.3 @@ -0,0 +1,63 @@ 94.4 +/* 94.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 94.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 94.7 + * 94.8 + * This code is free software; you can redistribute it and/or modify it 94.9 + * under the terms of the GNU General Public License version 2 only, as 94.10 + * published by the Free Software Foundation. Oracle designates this 94.11 + * particular file as subject to the "Classpath" exception as provided 94.12 + * by Oracle in the LICENSE file that accompanied this code. 94.13 + * 94.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 94.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 94.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 94.17 + * version 2 for more details (a copy is included in the LICENSE file that 94.18 + * accompanied this code). 94.19 + * 94.20 + * You should have received a copy of the GNU General Public License version 94.21 + * 2 along with this work; if not, write to the Free Software Foundation, 94.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 94.23 + * 94.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 94.25 + * or visit www.oracle.com if you need additional information or have any 94.26 + * questions. 94.27 + */ 94.28 + 94.29 +package jdk.nashorn.test.models; 94.30 + 94.31 +import java.util.Arrays; 94.32 + 94.33 +/** 94.34 + * A class that returns and receives longs. 94.35 + */ 94.36 +@SuppressWarnings("javadoc") 94.37 +public class LongProvider { 94.38 + 94.39 + final static long[][] arrays = { 94.40 + {1L, 2L, 3L}, 94.41 + {1L, 1L << 30, 1L << 50, 4L}, 94.42 + {1L, Long.MAX_VALUE, Long.MIN_VALUE, 4L} 94.43 + }; 94.44 + 94.45 + public static long getLong(final String str) { 94.46 + final long l = Long.parseLong(str); 94.47 + checkLong(l, str); 94.48 + return l; 94.49 + } 94.50 + 94.51 + public static long[] getLongArray(final int n) { 94.52 + return arrays[n]; 94.53 + } 94.54 + 94.55 + public static void checkLong(final long value, final String str) { 94.56 + if (!Long.toString(value).equals(str)) { 94.57 + throw new RuntimeException("Wrong value. Expected " + str + ", got " + value); 94.58 + } 94.59 + } 94.60 + 94.61 + public static void checkLongArray(final long[] array, final int n) { 94.62 + if (!Arrays.equals(array, arrays[n])) { 94.63 + throw new RuntimeException("Arrays don't match: " + Arrays.toString(array) + ", " + Arrays.toString(arrays[n])); 94.64 + } 94.65 + } 94.66 +}