< prev index next >

src/jdk/nashorn/internal/runtime/ScriptObject.java

Print this page

        

@@ -31,11 +31,10 @@
 import static jdk.nashorn.internal.lookup.Lookup.MH;
 import static jdk.nashorn.internal.runtime.ECMAErrors.referenceError;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
 import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_DOUBLE;
 import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_INT;
-import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_LONG;
 import static jdk.nashorn.internal.runtime.PropertyDescriptor.CONFIGURABLE;
 import static jdk.nashorn.internal.runtime.PropertyDescriptor.ENUMERABLE;
 import static jdk.nashorn.internal.runtime.PropertyDescriptor.GET;
 import static jdk.nashorn.internal.runtime.PropertyDescriptor.SET;
 import static jdk.nashorn.internal.runtime.PropertyDescriptor.VALUE;

@@ -184,11 +183,10 @@
     //TODO fastpath this
     public static final Call SET_USER_ACCESSORS = virtualCall(MethodHandles.lookup(), ScriptObject.class, "setUserAccessors", void.class, String.class, ScriptFunction.class, ScriptFunction.class);
 
     static final MethodHandle[] SET_SLOW = new MethodHandle[] {
         findOwnMH_V("set", void.class, Object.class, int.class, int.class),
-        findOwnMH_V("set", void.class, Object.class, long.class, int.class),
         findOwnMH_V("set", void.class, Object.class, double.class, int.class),
         findOwnMH_V("set", void.class, Object.class, Object.class, int.class)
     };
 
     /** Method handle to reset the map of this ScriptObject */

@@ -1084,25 +1082,10 @@
         }
 
         return UNDEFINED_INT;
     }
 
-    private static long getLongValue(final FindProperty find, final int programPoint) {
-        final MethodHandle getter = find.getGetter(long.class, programPoint, null);
-        if (getter != null) {
-            try {
-                return (long)getter.invokeExact((Object)find.getGetterReceiver());
-            } catch (final Error|RuntimeException e) {
-                throw e;
-            } catch (final Throwable e) {
-                throw new RuntimeException(e);
-            }
-        }
-
-        return UNDEFINED_LONG;
-    }
-
     private static double getDoubleValue(final FindProperty find, final int programPoint) {
         final MethodHandle getter = find.getGetter(double.class, programPoint, null);
         if (getter != null) {
             try {
                 return (double)getter.invokeExact((Object)find.getGetterReceiver());

@@ -2766,22 +2749,10 @@
 
         return getInt(index, JSType.toString(key), programPoint);
     }
 
     @Override
-    public int getInt(final long key, final int programPoint) {
-        final int       index = getArrayIndex(key);
-        final ArrayData array = getArray();
-
-        if (array.has(index)) {
-            return isValid(programPoint) ? array.getIntOptimistic(index, programPoint) : array.getInt(index);
-        }
-
-        return getInt(index, JSType.toString(key), programPoint);
-    }
-
-    @Override
     public int getInt(final int key, final int programPoint) {
         final int       index = getArrayIndex(key);
         final ArrayData array = getArray();
 
         if (array.has(index)) {

@@ -2789,92 +2760,10 @@
         }
 
         return getInt(index, JSType.toString(key), programPoint);
     }
 
-    private long getLong(final int index, final String key, final int programPoint) {
-        if (isValidArrayIndex(index)) {
-            for (ScriptObject object = this; ; ) {
-                if (object.getMap().containsArrayKeys()) {
-                    final FindProperty find = object.findProperty(key, false, this);
-                    if (find != null) {
-                        return getLongValue(find, programPoint);
-                    }
-                }
-
-                if ((object = object.getProto()) == null) {
-                    break;
-                }
-
-                final ArrayData array = object.getArray();
-
-                if (array.has(index)) {
-                    return isValid(programPoint) ?
-                        array.getLongOptimistic(index, programPoint) :
-                        array.getLong(index);
-                }
-            }
-        } else {
-            final FindProperty find = findProperty(key, true);
-
-            if (find != null) {
-                return getLongValue(find, programPoint);
-            }
-        }
-
-        return JSType.toLong(invokeNoSuchProperty(key, false, programPoint));
-    }
-
-    @Override
-    public long getLong(final Object key, final int programPoint) {
-        final Object    primitiveKey = JSType.toPrimitive(key, String.class);
-        final int       index        = getArrayIndex(primitiveKey);
-        final ArrayData array        = getArray();
-
-        if (array.has(index)) {
-            return isValid(programPoint) ? array.getLongOptimistic(index, programPoint) : array.getLong(index);
-        }
-
-        return getLong(index, JSType.toString(primitiveKey), programPoint);
-    }
-
-    @Override
-    public long getLong(final double key, final int programPoint) {
-        final int       index = getArrayIndex(key);
-        final ArrayData array = getArray();
-
-        if (array.has(index)) {
-            return isValid(programPoint) ? array.getLongOptimistic(index, programPoint) : array.getLong(index);
-        }
-
-        return getLong(index, JSType.toString(key), programPoint);
-    }
-
-    @Override
-    public long getLong(final long key, final int programPoint) {
-        final int       index = getArrayIndex(key);
-        final ArrayData array = getArray();
-
-        if (array.has(index)) {
-            return isValid(programPoint) ? array.getLongOptimistic(index, programPoint) : array.getLong(index);
-        }
-
-        return getLong(index, JSType.toString(key), programPoint);
-    }
-
-    @Override
-    public long getLong(final int key, final int programPoint) {
-        final int       index = getArrayIndex(key);
-        final ArrayData array = getArray();
-
-        if (array.has(index)) {
-            return isValid(programPoint) ? array.getLongOptimistic(key, programPoint) : array.getLong(key);
-        }
-
-        return getLong(index, JSType.toString(key), programPoint);
-    }
-
     private double getDouble(final int index, final String key, final int programPoint) {
         if (isValidArrayIndex(index)) {
             for (ScriptObject object = this; ; ) {
                 if (object.getMap().containsArrayKeys()) {
                     final FindProperty find = object.findProperty(key, false, this);

@@ -2930,22 +2819,10 @@
 
         return getDouble(index, JSType.toString(key), programPoint);
     }
 
     @Override
-    public double getDouble(final long key, final int programPoint) {
-        final int       index = getArrayIndex(key);
-        final ArrayData array = getArray();
-
-        if (array.has(index)) {
-            return isValid(programPoint) ? array.getDoubleOptimistic(index, programPoint) : array.getDouble(index);
-        }
-
-        return getDouble(index, JSType.toString(key), programPoint);
-    }
-
-    @Override
     public double getDouble(final int key, final int programPoint) {
         final int       index = getArrayIndex(key);
         final ArrayData array = getArray();
 
         if (array.has(index)) {

@@ -3011,22 +2888,10 @@
 
         return get(index, JSType.toString(key));
     }
 
     @Override
-    public Object get(final long key) {
-        final int index = getArrayIndex(key);
-        final ArrayData array = getArray();
-
-        if (array.has(index)) {
-            return array.getObject(index);
-        }
-
-        return get(index, JSType.toString(key));
-    }
-
-    @Override
     public Object get(final int key) {
         final int index = getArrayIndex(key);
         final ArrayData array = getArray();
 
         if (array.has(index)) {

@@ -3105,19 +2970,10 @@
             final boolean strict = isStrictFlag(callSiteFlags);
             setArray(getArray().set(index, value, strict).safeDelete(oldLength, longIndex - 1, strict));
         }
     }
 
-    private void doesNotHave(final int index, final long value, final int callSiteFlags) {
-        final long oldLength = getArray().length();
-        final long longIndex = ArrayIndex.toLongIndex(index);
-        if (!doesNotHaveCheckArrayKeys(longIndex, value, callSiteFlags) && !doesNotHaveEnsureLength(longIndex, oldLength, callSiteFlags)) {
-            final boolean strict = isStrictFlag(callSiteFlags);
-            setArray(getArray().set(index, value, strict).safeDelete(oldLength, longIndex - 1, strict));
-        }
-    }
-
     private void doesNotHave(final int index, final double value, final int callSiteFlags) {
         final long oldLength = getArray().length();
         final long longIndex = ArrayIndex.toLongIndex(index);
         if (!doesNotHaveCheckArrayKeys(longIndex, value, callSiteFlags) && !doesNotHaveEnsureLength(longIndex, oldLength, callSiteFlags)) {
             final boolean strict = isStrictFlag(callSiteFlags);

@@ -3220,30 +3076,10 @@
         final String propName = JSType.toString(primitiveKey);
         setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
     }
 
     @Override
-    public void set(final Object key, final long value, final int callSiteFlags) {
-        final Object primitiveKey = JSType.toPrimitive(key, String.class);
-        final int    index        = getArrayIndex(primitiveKey);
-
-        if (isValidArrayIndex(index)) {
-            final ArrayData data = getArray();
-            if (data.has(index)) {
-                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
-            } else {
-                doesNotHave(index, value, callSiteFlags);
-            }
-
-            return;
-        }
-
-        final String propName = JSType.toString(primitiveKey);
-        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
-    }
-
-    @Override
     public void set(final Object key, final double value, final int callSiteFlags) {
         final Object primitiveKey = JSType.toPrimitive(key, String.class);
         final int    index        = getArrayIndex(primitiveKey);
 
         if (isValidArrayIndex(index)) {

@@ -3299,29 +3135,10 @@
         final String propName = JSType.toString(key);
         setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
     }
 
     @Override
-    public void set(final double key, final long value, final int callSiteFlags) {
-        final int index = getArrayIndex(key);
-
-        if (isValidArrayIndex(index)) {
-            final ArrayData data = getArray();
-            if (data.has(index)) {
-                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
-            } else {
-                doesNotHave(index, value, callSiteFlags);
-            }
-
-            return;
-        }
-
-        final String propName = JSType.toString(key);
-        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
-    }
-
-    @Override
     public void set(final double key, final double value, final int callSiteFlags) {
         final int index = getArrayIndex(key);
 
         if (isValidArrayIndex(index)) {
             final ArrayData data = getArray();

@@ -3356,86 +3173,10 @@
         final String propName = JSType.toString(key);
         setObject(findProperty(propName, true), callSiteFlags, propName, value);
     }
 
     @Override
-    public void set(final long key, final int value, final int callSiteFlags) {
-        final int index = getArrayIndex(key);
-
-        if (isValidArrayIndex(index)) {
-            final ArrayData data = getArray();
-            if (data.has(index)) {
-                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
-            } else {
-                doesNotHave(index, value, callSiteFlags);
-            }
-
-            return;
-        }
-
-        final String propName = JSType.toString(key);
-        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
-    }
-
-    @Override
-    public void set(final long key, final long value, final int callSiteFlags) {
-        final int index = getArrayIndex(key);
-
-        if (isValidArrayIndex(index)) {
-            final ArrayData data = getArray();
-            if (data.has(index)) {
-                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
-            } else {
-                doesNotHave(index, value, callSiteFlags);
-            }
-
-            return;
-        }
-
-        final String propName = JSType.toString(key);
-        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
-    }
-
-    @Override
-    public void set(final long key, final double value, final int callSiteFlags) {
-        final int index = getArrayIndex(key);
-
-        if (isValidArrayIndex(index)) {
-            final ArrayData data = getArray();
-            if (data.has(index)) {
-                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
-            } else {
-                doesNotHave(index, value, callSiteFlags);
-            }
-
-            return;
-        }
-
-        final String propName = JSType.toString(key);
-        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
-    }
-
-    @Override
-    public void set(final long key, final Object value, final int callSiteFlags) {
-        final int index = getArrayIndex(key);
-
-        if (isValidArrayIndex(index)) {
-            final ArrayData data = getArray();
-            if (data.has(index)) {
-                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
-            } else {
-                doesNotHave(index, value, callSiteFlags);
-            }
-
-            return;
-        }
-
-        final String propName = JSType.toString(key);
-        setObject(findProperty(propName, true), callSiteFlags, propName, value);
-    }
-
-    @Override
     public void set(final int key, final int value, final int callSiteFlags) {
         final int index = getArrayIndex(key);
         if (isValidArrayIndex(index)) {
             if (getArray().has(index)) {
                 final ArrayData data = getArray();

@@ -3449,29 +3190,10 @@
         final String propName = JSType.toString(key);
         setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
     }
 
     @Override
-    public void set(final int key, final long value, final int callSiteFlags) {
-        final int index = getArrayIndex(key);
-
-        if (isValidArrayIndex(index)) {
-            final ArrayData data = getArray();
-            if (data.has(index)) {
-                setArray(data.set(index, value, isStrictFlag(callSiteFlags)));
-            } else {
-                doesNotHave(index, value, callSiteFlags);
-            }
-
-            return;
-        }
-
-        final String propName = JSType.toString(key);
-        setObject(findProperty(propName, true), callSiteFlags, propName, JSType.toObject(value));
-    }
-
-    @Override
     public void set(final int key, final double value, final int callSiteFlags) {
         final int index = getArrayIndex(key);
 
         if (isValidArrayIndex(index)) {
             final ArrayData data = getArray();

@@ -3519,16 +3241,10 @@
         final int index = getArrayIndex(key);
         return isValidArrayIndex(index) ? hasArrayProperty(index) : hasProperty(JSType.toString(key), true);
     }
 
     @Override
-    public boolean has(final long key) {
-        final int index = getArrayIndex(key);
-        return isValidArrayIndex(index) ? hasArrayProperty(index) : hasProperty(JSType.toString(key), true);
-    }
-
-    @Override
     public boolean has(final int key) {
         final int index = getArrayIndex(key);
         return isValidArrayIndex(index) ? hasArrayProperty(index) : hasProperty(JSType.toString(key), true);
     }
 

@@ -3557,16 +3273,10 @@
         final int index = getArrayIndex(key);
         return isValidArrayIndex(index) ? hasOwnArrayProperty(index) : hasProperty(JSType.toString(key), false);
     }
 
     @Override
-    public boolean hasOwnProperty(final long key) {
-        final int index = getArrayIndex(key);
-        return isValidArrayIndex(index) ? hasOwnArrayProperty(index) : hasProperty(JSType.toString(key), false);
-    }
-
-    @Override
     public boolean hasOwnProperty(final double key) {
         final int index = getArrayIndex(key);
         return isValidArrayIndex(index) ? hasOwnArrayProperty(index) : hasProperty(JSType.toString(key), false);
     }
 

@@ -3588,26 +3298,10 @@
         }
         return deleteObject(JSType.toObject(key), strict);
     }
 
     @Override
-    public boolean delete(final long key, final boolean strict) {
-        final int index = getArrayIndex(key);
-        final ArrayData array = getArray();
-
-        if (array.has(index)) {
-            if (array.canDelete(index, strict)) {
-                setArray(array.delete(index));
-                return true;
-            }
-            return false;
-        }
-
-        return deleteObject(JSType.toObject(key), strict);
-    }
-
-    @Override
     public boolean delete(final double key, final boolean strict) {
         final int index = getArrayIndex(key);
         final ArrayData array = getArray();
 
         if (array.has(index)) {
< prev index next >