gt:             return new IntArrayData((int[])array, ((int[])array).length);
context: /*
   * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this
   * particular file as subject to the "Classpath" exception as provided
   * by Oracle in the LICENSE file that accompanied this code.
   *
   * This code is distributed in the hope that it will be useful, but WITHOUT
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   * version 2 for more details (a copy is included in the LICENSE file that
   * accompanied this code).
   *
   * You should have received a copy of the GNU General Public License version
   * 2 along with this work; if not, write to the Free Software Foundation,
   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   *
   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   */
  
  package jdk.nashorn.internal.runtime.arrays;
  
  import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall;
  
  import java.lang.invoke.MethodHandle;
  import java.lang.invoke.MethodHandles;
  import java.lang.reflect.Array;
  import java.nio.ByteBuffer;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  import jdk.internal.dynalink.CallSiteDescriptor;
  import jdk.internal.dynalink.linker.GuardedInvocation;
  import jdk.internal.dynalink.linker.LinkRequest;
  import jdk.nashorn.internal.codegen.CompilerConstants;
  import jdk.nashorn.internal.codegen.types.Type;
  import jdk.nashorn.internal.objects.Global;
  import jdk.nashorn.internal.runtime.JSType;
  import jdk.nashorn.internal.runtime.PropertyDescriptor;
  import jdk.nashorn.internal.runtime.ScriptRuntime;
  import jdk.nashorn.internal.runtime.UnwarrantedOptimismException;
  
  /**
   * ArrayData - abstraction for wrapping array elements
   */
  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();
  
      /**
       * Length of the array data. Not necessarily length of the wrapped array.
       * This is private to ensure that no one in a subclass is able to touch the length
       * without going through {@link #setLength}. This is used to implement
       * {@link LengthNotWritableFilter}s, ensuring that there are no ways past
       * a {@link #setLength} function replaced by a nop
       */
      private long length;
  
      /**
       * Method handle to throw an {@link UnwarrantedOptimismException} when getting an element
       * of the wrong type
       */
      protected static final CompilerConstants.Call THROW_UNWARRANTED = staticCall(MethodHandles.lookup(), ArrayData.class, "throwUnwarranted", void.class, ArrayData.class, int.class, int.class);
  
      /**
       * Immutable empty array to get ScriptObjects started.
       * Use the same array and convert it to mutable as soon as it is modified
       */
      private static class UntouchedArrayData extends ContinuousArrayData {
          private UntouchedArrayData() {
              super(0);
          }
  
          private ArrayData toRealArrayData() {
              return toRealArrayData(0);
          }
  
          private ArrayData toRealArrayData(final int index) {
              final IntArrayData newData = new IntArrayData(index + 1);
              if (index == 0) {
                  return newData;
              }
              return new DeletedRangeArrayFilter(newData, 0, index);
          }
  
          @Override
          public ContinuousArrayData copy() {
              assert length() == 0;
              return this;
          }
  
          @Override
          public Object asArrayOfType(final Class<?> componentType) {
              return Array.newInstance(componentType, 0);
          }
  
          @Override
          public Object[] asObjectArray() {
              return ScriptRuntime.EMPTY_ARRAY;
          }
  
          @Override
          public ArrayData ensure(final long safeIndex) {
              if (safeIndex > 0L) {
                  if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH) {
                      return new SparseArrayData(this, safeIndex + 1);
                  }
                  //known to fit in int
                  return toRealArrayData((int)safeIndex);
             }
             return this;
          }
  
          @Override
          public ArrayData convert(final Class<?> type) {
              return toRealArrayData(0).convert(type);
          }
  
          @Override
          public ArrayData delete(final int index) {
              return new DeletedRangeArrayFilter(this, index, index);
          }
  
          @Override
          public ArrayData delete(final long fromIndex, final long toIndex) {
              return new DeletedRangeArrayFilter(this, fromIndex, toIndex);
          }
  
          @Override
          public void shiftLeft(final int by) {
              //nop, always empty or we wouldn't be of this class
          }
  
          @Override
          public ArrayData shiftRight(final int by) {
              return this; //always empty or we wouldn't be of this class
          }
  
          @Override
          public ArrayData shrink(final long newLength) {
              return this;
          }
  
          @Override
          public ArrayData set(final int index, final Object value, final boolean strict) {
              return toRealArrayData(index).set(index, value, strict);
          }
  
          @Override
          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
          public Object getObject(final int index) {
              throw new ArrayIndexOutOfBoundsException(index); //empty
          }
  
          @Override
          public boolean has(final int index) {
              return false; //empty
          }
  
          @Override
          public Object pop() {
              return ScriptRuntime.UNDEFINED;
          }
  
          @Override
          public ArrayData push(final boolean strict, final Object item) {
              return toRealArrayData().push(strict, item);
          }
  
          @Override
          public ArrayData slice(final long from, final long to) {
              return this; //empty
          }
  
          @Override
          public ContinuousArrayData fastConcat(final ContinuousArrayData otherData) {
              return otherData.copy();
          }
  
          //no need to override fastPopInt, as the default behavior is to throw classcast exception so we
          //can relink and return an undefined, this is the IntArrayData default behavior
          @Override
          public String toString() {
              return getClass().getSimpleName();
          }
  
          @Override
          public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) {
              return null;
          }
  
          @Override
          public MethodHandle getElementSetter(final Class<?> elementType) {
              return null;
          }
  
          @Override
          public Class<?> getElementType() {
              return int.class;
          }
  
          @Override
          public Class<?> getBoxedElementType() {
              return Integer.class;
          }
      }
  
      /**
       * Constructor
       * @param length Virtual length of the array.
       */
      protected ArrayData(final long length) {
          this.length = length;
      }
  
      /**
       * Factory method for unspecified array - start as int
       * @return ArrayData
       */
      public final static ArrayData initialArray() {
          return new IntArrayData();
      }
  
      /**
       * Unwarranted thrower
       *
       * @param data         array data
       * @param programPoint program point
       * @param index        array index
       */
      protected static void throwUnwarranted(final ArrayData data, final int programPoint, final int index) {
          throw new UnwarrantedOptimismException(data.getObject(index), programPoint);
      }
  
      /**
       * Align an array size up to the nearest array chunk size
       * @param size size required
       * @return size given, always &gt;= size
       */
      protected final static int alignUp(final int size) {
          return size + CHUNK_SIZE - 1 & ~(CHUNK_SIZE - 1);
      }
  
      /**
       * Factory method for unspecified array with given length - start as int array data
       *
       * @param length the initial length
       * @return ArrayData
       */
      public static final 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
       *
       * @param  array the array
       * @return ArrayData wrapping this array
       */
      public static final ArrayData allocate(final Object array) {
          final Class<?> clazz = array.getClass();
  
          if (clazz == int[].class) {
  