< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ArrayData.java

Print this page

        

*** 50,62 **** */ public abstract class ArrayData { /** Minimum chunk size for underlying arrays */ protected static final int CHUNK_SIZE = 32; - /** Mask for getting a chunk */ - protected static final int CHUNK_MASK = CHUNK_SIZE - 1; - /** Untouched data - still link callsites as IntArrayData, but expands to * a proper ArrayData when we try to write to it */ public static final ArrayData EMPTY_ARRAY = new UntouchedArrayData(); /** --- 50,59 ----
*** 162,191 **** public ArrayData set(final int index, final int value, final boolean strict) { return toRealArrayData(index).set(index, value, strict); } @Override - public ArrayData set(final int index, final long value, final boolean strict) { - return toRealArrayData(index).set(index, value, strict); - } - - @Override public ArrayData set(final int index, final double value, final boolean strict) { return toRealArrayData(index).set(index, value, strict); } @Override public int getInt(final int index) { throw new ArrayIndexOutOfBoundsException(index); //empty } @Override - public long getLong(final int index) { - throw new ArrayIndexOutOfBoundsException(index); //empty - } - - @Override public double getDouble(final int index) { throw new ArrayIndexOutOfBoundsException(index); //empty } @Override --- 159,178 ----
*** 286,302 **** * Factory method for unspecified array with given length - start as int array data * * @param length the initial length * @return ArrayData */ ! public static ArrayData allocate(final int length) { ! if (length == 0) { return new IntArrayData(); } else if (length >= SparseArrayData.MAX_DENSE_LENGTH) { return new SparseArrayData(EMPTY_ARRAY, length); } else { ! return new DeletedRangeArrayFilter(new IntArrayData(length), 0, length - 1); } } /** * Factory method for unspecified given an array object --- 273,289 ---- * Factory method for unspecified array with given length - start as int array data * * @param length the initial length * @return ArrayData */ ! public static ArrayData allocate(final long length) { ! if (length == 0L) { return new IntArrayData(); } else if (length >= SparseArrayData.MAX_DENSE_LENGTH) { return new SparseArrayData(EMPTY_ARRAY, length); } else { ! return new DeletedRangeArrayFilter(new IntArrayData((int) length), 0, length - 1); } } /** * Factory method for unspecified given an array object
*** 307,318 **** public static ArrayData allocate(final Object array) { final Class<?> clazz = array.getClass(); if (clazz == int[].class) { return new IntArrayData((int[])array, ((int[])array).length); - } else if (clazz == long[].class) { - return new LongArrayData((long[])array, ((long[])array).length); } else if (clazz == double[].class) { return new NumberArrayData((double[])array, ((double[])array).length); } else { return new ObjectArrayData((Object[])array, ((Object[])array).length); } --- 294,303 ----
*** 332,351 **** * Allocate an ArrayData wrapping a given array * * @param array the array to use for initial elements * @return the ArrayData */ - public static ArrayData allocate(final long[] array) { - return new LongArrayData(array, array.length); - } - - /** - * Allocate an ArrayData wrapping a given array - * - * @param array the array to use for initial elements - * @return the ArrayData - */ public static ArrayData allocate(final double[] array) { return new NumberArrayData(array, array.length); } /** --- 317,326 ----
*** 535,554 **** * @return new array data (or same) */ public abstract ArrayData set(final int index, final int value, final boolean strict); /** - * Set a long value at a given index - * - * @param index the index - * @param value the value - * @param strict are we in strict mode - * @return new array data (or same) - */ - public abstract ArrayData set(final int index, final long value, final boolean strict); - - /** * Set an double value at a given index * * @param index the index * @param value the value * @param strict are we in strict mode --- 510,519 ----
*** 607,636 **** public int getIntOptimistic(final int index, final int programPoint) { throw new UnwarrantedOptimismException(getObject(index), programPoint, getOptimisticType()); } /** - * Get a long value from a given index - * - * @param index the index - * @return the value - */ - public abstract long getLong(final int index); - - /** - * Get optimistic long - default is that it's impossible. Overridden - * by arrays that actually represents longs or narrower - * - * @param index the index - * @param programPoint program point - * @return the value - */ - public long getLongOptimistic(final int index, final int programPoint) { - throw new UnwarrantedOptimismException(getObject(index), programPoint, getOptimisticType()); - } - - /** * Get a double value from a given index * * @param index the index * @return the value */ --- 572,581 ----
*** 819,834 **** for (final Object item : items) { if (item == null) { return Object.class; } final Class<?> itemClass = item.getClass(); ! if (itemClass == Long.class) { if (widest == Integer.class) { - widest = Long.class; - } - } else if (itemClass == Double.class || itemClass == Float.class) { - if (widest == Integer.class || widest == Long.class) { widest = Double.class; } } else if (itemClass != Integer.class && itemClass != Short.class && itemClass != Byte.class) { return Object.class; } --- 764,775 ---- for (final Object item : items) { if (item == null) { return Object.class; } final Class<?> itemClass = item.getClass(); ! if (itemClass == Double.class || itemClass == Float.class || itemClass == Long.class) { if (widest == Integer.class) { widest = Double.class; } } else if (itemClass != Integer.class && itemClass != Short.class && itemClass != Byte.class) { return Object.class; }
< prev index next >