author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 42790 | nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ArrayData.java@edb30aa1a99b |
permissions | -rw-r--r-- |
16147 | 1 |
/* |
35726
621225a25d50
8149334: JSON.parse(JSON.stringify([])).push(10) creates an array containing two elements
mhaupt
parents:
34732
diff
changeset
|
2 |
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. |
16147 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.nashorn.internal.runtime.arrays; |
|
27 |
||
24719 | 28 |
import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall; |
28576 | 29 |
|
16147 | 30 |
import java.lang.invoke.MethodHandle; |
24719 | 31 |
import java.lang.invoke.MethodHandles; |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
32 |
import java.lang.reflect.Array; |
23078
06c03700f884
8011964: need indexed access to externally-managed ByteBuffer
sundar
parents:
21438
diff
changeset
|
33 |
import java.nio.ByteBuffer; |
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
34 |
import java.util.ArrayList; |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
35 |
import java.util.Iterator; |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
36 |
import java.util.List; |
34447
ec4c069f9436
8141338: Move jdk.internal.dynalink package to jdk.dynalink
attila
parents:
33343
diff
changeset
|
37 |
import jdk.dynalink.CallSiteDescriptor; |
ec4c069f9436
8141338: Move jdk.internal.dynalink package to jdk.dynalink
attila
parents:
33343
diff
changeset
|
38 |
import jdk.dynalink.linker.GuardedInvocation; |
ec4c069f9436
8141338: Move jdk.internal.dynalink package to jdk.dynalink
attila
parents:
33343
diff
changeset
|
39 |
import jdk.dynalink.linker.LinkRequest; |
24719 | 40 |
import jdk.nashorn.internal.codegen.CompilerConstants; |
41 |
import jdk.nashorn.internal.codegen.types.Type; |
|
23375
a1110f2cbe75
8037400: Remove getInitialMap getters and GlobalObject interface
sundar
parents:
23078
diff
changeset
|
42 |
import jdk.nashorn.internal.objects.Global; |
19897
4235a28bb5e8
8024847: Java.to should accept mirror and external JSObjects as array-like objects as well
sundar
parents:
19236
diff
changeset
|
43 |
import jdk.nashorn.internal.runtime.JSType; |
16147 | 44 |
import jdk.nashorn.internal.runtime.PropertyDescriptor; |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
45 |
import jdk.nashorn.internal.runtime.ScriptRuntime; |
24719 | 46 |
import jdk.nashorn.internal.runtime.UnwarrantedOptimismException; |
16147 | 47 |
|
48 |
/** |
|
49 |
* ArrayData - abstraction for wrapping array elements |
|
50 |
*/ |
|
51 |
public abstract class ArrayData { |
|
52 |
/** Minimum chunk size for underlying arrays */ |
|
24720 | 53 |
protected static final int CHUNK_SIZE = 32; |
16147 | 54 |
|
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
55 |
/** Untouched data - still link callsites as IntArrayData, but expands to |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
56 |
* a proper ArrayData when we try to write to it */ |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
57 |
public static final ArrayData EMPTY_ARRAY = new UntouchedArrayData(); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
58 |
|
16147 | 59 |
/** |
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
60 |
* Length of the array data. Not necessarily length of the wrapped array. |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
61 |
* This is private to ensure that no one in a subclass is able to touch the length |
27817
56f6161c3e55
8057980: let & const: remaining issues with lexical scoping
hannesw
parents:
27525
diff
changeset
|
62 |
* without going through {@link #setLength}. This is used to implement |
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
63 |
* {@link LengthNotWritableFilter}s, ensuring that there are no ways past |
27817
56f6161c3e55
8057980: let & const: remaining issues with lexical scoping
hannesw
parents:
27525
diff
changeset
|
64 |
* a {@link #setLength} function replaced by a nop |
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
65 |
*/ |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
66 |
private long length; |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
67 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
68 |
/** |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
69 |
* Method handle to throw an {@link UnwarrantedOptimismException} when getting an element |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
70 |
* of the wrong type |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
71 |
*/ |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
72 |
protected static final CompilerConstants.Call THROW_UNWARRANTED = staticCall(MethodHandles.lookup(), ArrayData.class, "throwUnwarranted", void.class, ArrayData.class, int.class, int.class); |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
73 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
74 |
/** |
16147 | 75 |
* Immutable empty array to get ScriptObjects started. |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
76 |
* Use the same array and convert it to mutable as soon as it is modified |
16147 | 77 |
*/ |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
78 |
private static class UntouchedArrayData extends ContinuousArrayData { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
79 |
private UntouchedArrayData() { |
27817
56f6161c3e55
8057980: let & const: remaining issues with lexical scoping
hannesw
parents:
27525
diff
changeset
|
80 |
super(0); |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
81 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
82 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
83 |
private ArrayData toRealArrayData() { |
35726
621225a25d50
8149334: JSON.parse(JSON.stringify([])).push(10) creates an array containing two elements
mhaupt
parents:
34732
diff
changeset
|
84 |
return new IntArrayData(0); |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
85 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
86 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
87 |
private ArrayData toRealArrayData(final int index) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
88 |
final IntArrayData newData = new IntArrayData(index + 1); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
89 |
return new DeletedRangeArrayFilter(newData, 0, index); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
90 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
91 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
92 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
93 |
public ContinuousArrayData copy() { |
27817
56f6161c3e55
8057980: let & const: remaining issues with lexical scoping
hannesw
parents:
27525
diff
changeset
|
94 |
assert length() == 0; |
56f6161c3e55
8057980: let & const: remaining issues with lexical scoping
hannesw
parents:
27525
diff
changeset
|
95 |
return this; |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
96 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
97 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
98 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
99 |
public Object asArrayOfType(final Class<?> componentType) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
100 |
return Array.newInstance(componentType, 0); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
101 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
102 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
103 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
104 |
public Object[] asObjectArray() { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
105 |
return ScriptRuntime.EMPTY_ARRAY; |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
106 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
107 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
108 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
109 |
public ArrayData ensure(final long safeIndex) { |
42790
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
110 |
assert safeIndex >= 0L; |
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
111 |
if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH) { |
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
112 |
return new SparseArrayData(this, safeIndex + 1); |
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
113 |
} |
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
114 |
//known to fit in int |
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
115 |
return toRealArrayData((int)safeIndex); |
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
116 |
|
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
117 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
118 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
119 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
120 |
public ArrayData convert(final Class<?> type) { |
35726
621225a25d50
8149334: JSON.parse(JSON.stringify([])).push(10) creates an array containing two elements
mhaupt
parents:
34732
diff
changeset
|
121 |
return toRealArrayData().convert(type); |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
122 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
123 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
124 |
@Override |
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
125 |
public ArrayData delete(final int index) { |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
126 |
return new DeletedRangeArrayFilter(this, index, index); |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
127 |
} |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
128 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
129 |
@Override |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
130 |
public ArrayData delete(final long fromIndex, final long toIndex) { |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
131 |
return new DeletedRangeArrayFilter(this, fromIndex, toIndex); |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
132 |
} |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
133 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
134 |
@Override |
42790
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
135 |
public ArrayData shiftLeft(final int by) { |
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
136 |
return this; //nop, always empty or we wouldn't be of this class |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
137 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
138 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
139 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
140 |
public ArrayData shiftRight(final int by) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
141 |
return this; //always empty or we wouldn't be of this class |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
142 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
143 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
144 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
145 |
public ArrayData shrink(final long newLength) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
146 |
return this; |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
147 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
148 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
149 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
150 |
public ArrayData set(final int index, final Object value, final boolean strict) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
151 |
return toRealArrayData(index).set(index, value, strict); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
152 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
153 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
154 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
155 |
public ArrayData set(final int index, final int value, final boolean strict) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
156 |
return toRealArrayData(index).set(index, value, strict); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
157 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
158 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
159 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
160 |
public ArrayData set(final int index, final double value, final boolean strict) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
161 |
return toRealArrayData(index).set(index, value, strict); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
162 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
163 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
164 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
165 |
public int getInt(final int index) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
166 |
throw new ArrayIndexOutOfBoundsException(index); //empty |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
167 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
168 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
169 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
170 |
public double getDouble(final int index) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
171 |
throw new ArrayIndexOutOfBoundsException(index); //empty |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
172 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
173 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
174 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
175 |
public Object getObject(final int index) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
176 |
throw new ArrayIndexOutOfBoundsException(index); //empty |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
177 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
178 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
179 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
180 |
public boolean has(final int index) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
181 |
return false; //empty |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
182 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
183 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
184 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
185 |
public Object pop() { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
186 |
return ScriptRuntime.UNDEFINED; |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
187 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
188 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
189 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
190 |
public ArrayData push(final boolean strict, final Object item) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
191 |
return toRealArrayData().push(strict, item); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
192 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
193 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
194 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
195 |
public ArrayData slice(final long from, final long to) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
196 |
return this; //empty |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
197 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
198 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
199 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
200 |
public ContinuousArrayData fastConcat(final ContinuousArrayData otherData) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
201 |
return otherData.copy(); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
202 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
203 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
204 |
//no need to override fastPopInt, as the default behavior is to throw classcast exception so we |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
205 |
//can relink and return an undefined, this is the IntArrayData default behavior |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
206 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
207 |
public String toString() { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
208 |
return getClass().getSimpleName(); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
209 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
210 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
211 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
212 |
public MethodHandle getElementGetter(final Class<?> returnType, final int programPoint) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
213 |
return null; |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
214 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
215 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
216 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
217 |
public MethodHandle getElementSetter(final Class<?> elementType) { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
218 |
return null; |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
219 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
220 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
221 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
222 |
public Class<?> getElementType() { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
223 |
return int.class; |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
224 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
225 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
226 |
@Override |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
227 |
public Class<?> getBoxedElementType() { |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
228 |
return Integer.class; |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
229 |
} |
27817
56f6161c3e55
8057980: let & const: remaining issues with lexical scoping
hannesw
parents:
27525
diff
changeset
|
230 |
} |
16147 | 231 |
|
232 |
/** |
|
233 |
* Constructor |
|
234 |
* @param length Virtual length of the array. |
|
235 |
*/ |
|
19236
73d242d205f9
8020132: Big object literal with numerical keys exceeds method size
hannesw
parents:
18881
diff
changeset
|
236 |
protected ArrayData(final long length) { |
16147 | 237 |
this.length = length; |
238 |
} |
|
239 |
||
240 |
/** |
|
241 |
* Factory method for unspecified array - start as int |
|
242 |
* @return ArrayData |
|
243 |
*/ |
|
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
244 |
public static ArrayData initialArray() { |
16147 | 245 |
return new IntArrayData(); |
246 |
} |
|
247 |
||
248 |
/** |
|
24720 | 249 |
* Unwarranted thrower |
250 |
* |
|
251 |
* @param data array data |
|
24719 | 252 |
* @param programPoint program point |
24720 | 253 |
* @param index array index |
24719 | 254 |
*/ |
24720 | 255 |
protected static void throwUnwarranted(final ArrayData data, final int programPoint, final int index) { |
256 |
throw new UnwarrantedOptimismException(data.getObject(index), programPoint); |
|
257 |
} |
|
24719 | 258 |
|
259 |
/** |
|
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
260 |
* Align an array size up to the nearest array chunk size |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
261 |
* @param size size required |
28126 | 262 |
* @return size given, always >= size |
24719 | 263 |
*/ |
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
264 |
protected static int alignUp(final int size) { |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
265 |
return size + CHUNK_SIZE - 1 & ~(CHUNK_SIZE - 1); |
24719 | 266 |
} |
267 |
||
268 |
/** |
|
16147 | 269 |
* Factory method for unspecified array with given length - start as int array data |
270 |
* |
|
271 |
* @param length the initial length |
|
272 |
* @return ArrayData |
|
273 |
*/ |
|
34732 | 274 |
public static ArrayData allocate(final long length) { |
275 |
if (length == 0L) { |
|
18881
3198876c1f4f
8020358: Array(0xfffffff) throws OutOfMemoryError
hannesw
parents:
18606
diff
changeset
|
276 |
return new IntArrayData(); |
3198876c1f4f
8020358: Array(0xfffffff) throws OutOfMemoryError
hannesw
parents:
18606
diff
changeset
|
277 |
} else if (length >= SparseArrayData.MAX_DENSE_LENGTH) { |
3198876c1f4f
8020358: Array(0xfffffff) throws OutOfMemoryError
hannesw
parents:
18606
diff
changeset
|
278 |
return new SparseArrayData(EMPTY_ARRAY, length); |
3198876c1f4f
8020358: Array(0xfffffff) throws OutOfMemoryError
hannesw
parents:
18606
diff
changeset
|
279 |
} else { |
34732 | 280 |
return new DeletedRangeArrayFilter(new IntArrayData((int) length), 0, length - 1); |
18881
3198876c1f4f
8020358: Array(0xfffffff) throws OutOfMemoryError
hannesw
parents:
18606
diff
changeset
|
281 |
} |
16147 | 282 |
} |
283 |
||
284 |
/** |
|
285 |
* Factory method for unspecified given an array object |
|
286 |
* |
|
287 |
* @param array the array |
|
288 |
* @return ArrayData wrapping this array |
|
289 |
*/ |
|
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
290 |
public static ArrayData allocate(final Object array) { |
16147 | 291 |
final Class<?> clazz = array.getClass(); |
292 |
||
293 |
if (clazz == int[].class) { |
|
294 |
return new IntArrayData((int[])array, ((int[])array).length); |
|
295 |
} else if (clazz == double[].class) { |
|
296 |
return new NumberArrayData((double[])array, ((double[])array).length); |
|
297 |
} else { |
|
298 |
return new ObjectArrayData((Object[])array, ((Object[])array).length); |
|
299 |
} |
|
300 |
} |
|
301 |
||
302 |
/** |
|
303 |
* Allocate an ArrayData wrapping a given array |
|
304 |
* |
|
305 |
* @param array the array to use for initial elements |
|
306 |
* @return the ArrayData |
|
307 |
*/ |
|
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
308 |
public static ArrayData allocate(final int[] array) { |
16147 | 309 |
return new IntArrayData(array, array.length); |
310 |
} |
|
311 |
||
312 |
/** |
|
313 |
* Allocate an ArrayData wrapping a given array |
|
314 |
* |
|
315 |
* @param array the array to use for initial elements |
|
316 |
* @return the ArrayData |
|
317 |
*/ |
|
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
318 |
public static ArrayData allocate(final double[] array) { |
16147 | 319 |
return new NumberArrayData(array, array.length); |
320 |
} |
|
321 |
||
322 |
/** |
|
323 |
* Allocate an ArrayData wrapping a given array |
|
324 |
* |
|
325 |
* @param array the array to use for initial elements |
|
326 |
* @return the ArrayData |
|
327 |
*/ |
|
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
328 |
public static ArrayData allocate(final Object[] array) { |
16147 | 329 |
return new ObjectArrayData(array, array.length); |
330 |
} |
|
331 |
||
332 |
/** |
|
23078
06c03700f884
8011964: need indexed access to externally-managed ByteBuffer
sundar
parents:
21438
diff
changeset
|
333 |
* Allocate an ArrayData wrapping a given nio ByteBuffer |
06c03700f884
8011964: need indexed access to externally-managed ByteBuffer
sundar
parents:
21438
diff
changeset
|
334 |
* |
06c03700f884
8011964: need indexed access to externally-managed ByteBuffer
sundar
parents:
21438
diff
changeset
|
335 |
* @param buf the nio ByteBuffer to wrap |
06c03700f884
8011964: need indexed access to externally-managed ByteBuffer
sundar
parents:
21438
diff
changeset
|
336 |
* @return the ArrayData |
06c03700f884
8011964: need indexed access to externally-managed ByteBuffer
sundar
parents:
21438
diff
changeset
|
337 |
*/ |
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
338 |
public static ArrayData allocate(final ByteBuffer buf) { |
24719 | 339 |
return new ByteBufferArrayData(buf); |
23078
06c03700f884
8011964: need indexed access to externally-managed ByteBuffer
sundar
parents:
21438
diff
changeset
|
340 |
} |
06c03700f884
8011964: need indexed access to externally-managed ByteBuffer
sundar
parents:
21438
diff
changeset
|
341 |
|
06c03700f884
8011964: need indexed access to externally-managed ByteBuffer
sundar
parents:
21438
diff
changeset
|
342 |
/** |
16147 | 343 |
* Apply a freeze filter to an ArrayData. |
344 |
* |
|
345 |
* @param underlying the underlying ArrayData to wrap in the freeze filter |
|
346 |
* @return the frozen ArrayData |
|
347 |
*/ |
|
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
348 |
public static ArrayData freeze(final ArrayData underlying) { |
16147 | 349 |
return new FrozenArrayFilter(underlying); |
350 |
} |
|
351 |
||
352 |
/** |
|
353 |
* Apply a seal filter to an ArrayData. |
|
354 |
* |
|
355 |
* @param underlying the underlying ArrayData to wrap in the seal filter |
|
356 |
* @return the sealed ArrayData |
|
357 |
*/ |
|
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
358 |
public static ArrayData seal(final ArrayData underlying) { |
16147 | 359 |
return new SealedArrayFilter(underlying); |
360 |
} |
|
361 |
||
362 |
/** |
|
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
363 |
* Prevent this array from being extended |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
364 |
* |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
365 |
* @param underlying the underlying ArrayData to wrap in the non extensible filter |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
366 |
* @return new array data, filtered |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
367 |
*/ |
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
368 |
public static ArrayData preventExtension(final ArrayData underlying) { |
27209
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
369 |
return new NonExtensibleArrayFilter(underlying); |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
370 |
} |
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
371 |
|
30d8609b9561
8061391: concat as a builtin optimistic form, had to remove NoTypedArrayData and replace it, as we throw away a lot of optimistic link opportunities with NoTypedArrayData not being Continuous
lagergren
parents:
26886
diff
changeset
|
372 |
/** |
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
373 |
* Prevent this array from having its length reset |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
374 |
* |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
375 |
* @param underlying the underlying ArrayDAta to wrap in the non extensible filter |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
376 |
* @return new array data, filtered |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
377 |
*/ |
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
378 |
public static ArrayData setIsLengthNotWritable(final ArrayData underlying) { |
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
379 |
return new LengthNotWritableFilter(underlying); |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
380 |
} |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
381 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
382 |
/** |
16147 | 383 |
* Return the length of the array data. This may differ from the actual |
384 |
* length of the array this wraps as length may be set or gotten as any |
|
385 |
* other JavaScript Property |
|
386 |
* |
|
387 |
* Even though a JavaScript array length may be a long, we only store |
|
388 |
* int parts for the optimized array access. For long lengths there |
|
389 |
* are special cases anyway. |
|
390 |
* |
|
391 |
* TODO: represent arrays with "long" lengths as a special ArrayData |
|
392 |
* that basically maps to the ScriptObject directly for better abstraction |
|
393 |
* |
|
394 |
* @return the length of the data |
|
395 |
*/ |
|
396 |
public final long length() { |
|
397 |
return length; |
|
398 |
} |
|
399 |
||
400 |
/** |
|
19236
73d242d205f9
8020132: Big object literal with numerical keys exceeds method size
hannesw
parents:
18881
diff
changeset
|
401 |
* Return a copy of the array that can be modified without affecting this instance. |
73d242d205f9
8020132: Big object literal with numerical keys exceeds method size
hannesw
parents:
18881
diff
changeset
|
402 |
* It is safe to return themselves for immutable subclasses. |
73d242d205f9
8020132: Big object literal with numerical keys exceeds method size
hannesw
parents:
18881
diff
changeset
|
403 |
* |
73d242d205f9
8020132: Big object literal with numerical keys exceeds method size
hannesw
parents:
18881
diff
changeset
|
404 |
* @return a new array |
73d242d205f9
8020132: Big object literal with numerical keys exceeds method size
hannesw
parents:
18881
diff
changeset
|
405 |
*/ |
73d242d205f9
8020132: Big object literal with numerical keys exceeds method size
hannesw
parents:
18881
diff
changeset
|
406 |
public abstract ArrayData copy(); |
73d242d205f9
8020132: Big object literal with numerical keys exceeds method size
hannesw
parents:
18881
diff
changeset
|
407 |
|
73d242d205f9
8020132: Big object literal with numerical keys exceeds method size
hannesw
parents:
18881
diff
changeset
|
408 |
/** |
16147 | 409 |
* Return a copy of the array data as an Object array. |
410 |
* |
|
411 |
* @return an Object array |
|
412 |
*/ |
|
413 |
public abstract Object[] asObjectArray(); |
|
414 |
||
415 |
/** |
|
416 |
* Return a copy of the array data as an array of the specified type. |
|
417 |
* |
|
418 |
* @param componentType the type of elements in the array |
|
419 |
* @return and array of the given type |
|
420 |
*/ |
|
421 |
public Object asArrayOfType(final Class<?> componentType) { |
|
19897
4235a28bb5e8
8024847: Java.to should accept mirror and external JSObjects as array-like objects as well
sundar
parents:
19236
diff
changeset
|
422 |
return JSType.convertArray(asObjectArray(), componentType); |
16147 | 423 |
} |
424 |
||
425 |
/** |
|
426 |
* Set the length of the data array |
|
427 |
* |
|
428 |
* @param length the new length for the data array |
|
429 |
*/ |
|
430 |
public void setLength(final long length) { |
|
431 |
this.length = length; |
|
432 |
} |
|
433 |
||
434 |
/** |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
435 |
* Increase length by 1 |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
436 |
* @return the new length, not the old one (i.e. pre-increment) |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
437 |
*/ |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
438 |
protected final long increaseLength() { |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
439 |
return ++this.length; |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
440 |
} |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
441 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
442 |
/** |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
443 |
* Decrease length by 1. |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
444 |
* @return the new length, not the old one (i.e. pre-decrement) |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
445 |
*/ |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
446 |
protected final long decreaseLength() { |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
447 |
return --this.length; |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
448 |
} |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
449 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
450 |
/** |
16147 | 451 |
* Shift the array data left |
452 |
* |
|
42790
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
453 |
* TODO: This is used for Array.prototype.shift() which only shifts by 1, |
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
454 |
* so we might consider dropping the offset parameter. |
16147 | 455 |
* |
456 |
* @param by offset to shift |
|
42790
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
457 |
* @return New arraydata (or same) |
16147 | 458 |
*/ |
42790
edb30aa1a99b
8171219: Missing checks in sparse array shift() implementation
hannesw
parents:
35726
diff
changeset
|
459 |
public abstract ArrayData shiftLeft(final int by); |
16147 | 460 |
|
461 |
/** |
|
462 |
* Shift the array right |
|
463 |
* |
|
464 |
* @param by offset to shift |
|
465 |
||
466 |
* @return New arraydata (or same) |
|
467 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
468 |
public abstract ArrayData shiftRight(final int by); |
16147 | 469 |
|
470 |
/** |
|
28787 | 471 |
* Ensure that the given index exists and won't fail in a subsequent access. |
472 |
* If {@code safeIndex} is equal or greater than the current length the length is |
|
473 |
* updated to {@code safeIndex + 1}. |
|
16147 | 474 |
* |
475 |
* @param safeIndex the index to ensure wont go out of bounds |
|
476 |
* @return new array data (or same) |
|
477 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
478 |
public abstract ArrayData ensure(final long safeIndex); |
16147 | 479 |
|
480 |
/** |
|
481 |
* Shrink the array to a new length, may or may not retain the |
|
482 |
* inner array |
|
483 |
* |
|
484 |
* @param newLength new max length |
|
485 |
* |
|
486 |
* @return new array data (or same) |
|
487 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
488 |
public abstract ArrayData shrink(final long newLength); |
16147 | 489 |
|
490 |
/** |
|
491 |
* Set an object value at a given index |
|
492 |
* |
|
493 |
* @param index the index |
|
494 |
* @param value the value |
|
495 |
* @param strict are we in strict mode |
|
496 |
* @return new array data (or same) |
|
497 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
498 |
public abstract ArrayData set(final int index, final Object value, final boolean strict); |
16147 | 499 |
|
500 |
/** |
|
501 |
* Set an int value at a given index |
|
502 |
* |
|
503 |
* @param index the index |
|
504 |
* @param value the value |
|
505 |
* @param strict are we in strict mode |
|
506 |
* @return new array data (or same) |
|
507 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
508 |
public abstract ArrayData set(final int index, final int value, final boolean strict); |
16147 | 509 |
|
510 |
/** |
|
511 |
* Set an double value at a given index |
|
512 |
* |
|
513 |
* @param index the index |
|
514 |
* @param value the value |
|
515 |
* @param strict are we in strict mode |
|
516 |
* @return new array data (or same) |
|
517 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
518 |
public abstract ArrayData set(final int index, final double value, final boolean strict); |
16147 | 519 |
|
520 |
/** |
|
18606 | 521 |
* Set an empty value at a given index. Should only affect Object array. |
522 |
* |
|
523 |
* @param index the index |
|
524 |
* @return new array data (or same) |
|
525 |
*/ |
|
526 |
public ArrayData setEmpty(final int index) { |
|
527 |
// Do nothing. |
|
528 |
return this; |
|
529 |
} |
|
530 |
||
531 |
/** |
|
532 |
* Set an empty value for a given range. Should only affect Object array. |
|
533 |
* |
|
534 |
* @param lo range low end |
|
535 |
* @param hi range high end |
|
536 |
* @return new array data (or same) |
|
537 |
*/ |
|
538 |
public ArrayData setEmpty(final long lo, final long hi) { |
|
539 |
// Do nothing. |
|
540 |
return this; |
|
541 |
} |
|
542 |
||
543 |
/** |
|
16147 | 544 |
* Get an int value from a given index |
545 |
* |
|
546 |
* @param index the index |
|
547 |
* @return the value |
|
548 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
549 |
public abstract int getInt(final int index); |
16147 | 550 |
|
551 |
/** |
|
24719 | 552 |
* Returns the optimistic type of this array data. Basically, when an array data object needs to throw an |
553 |
* {@link UnwarrantedOptimismException}, this type is used as the actual type of the return value. |
|
554 |
* @return the optimistic type of this array data. |
|
555 |
*/ |
|
556 |
public Type getOptimisticType() { |
|
557 |
return Type.OBJECT; |
|
558 |
} |
|
559 |
||
560 |
/** |
|
561 |
* Get optimistic int - default is that it's impossible. Overridden |
|
562 |
* by arrays that actually represents ints |
|
563 |
* |
|
564 |
* @param index the index |
|
565 |
* @param programPoint program point |
|
566 |
* @return the value |
|
567 |
*/ |
|
24741
4232289c3235
8040102: Remove all references to Unsafe and definition of anonymous clases from the code
lagergren
parents:
24727
diff
changeset
|
568 |
public int getIntOptimistic(final int index, final int programPoint) { |
24719 | 569 |
throw new UnwarrantedOptimismException(getObject(index), programPoint, getOptimisticType()); |
570 |
} |
|
571 |
||
572 |
/** |
|
16147 | 573 |
* Get a double value from a given index |
574 |
* |
|
575 |
* @param index the index |
|
576 |
* @return the value |
|
577 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
578 |
public abstract double getDouble(final int index); |
16147 | 579 |
|
580 |
/** |
|
24719 | 581 |
* Get optimistic double - default is that it's impossible. Overridden |
582 |
* by arrays that actually represents doubles or narrower |
|
583 |
* |
|
584 |
* @param index the index |
|
585 |
* @param programPoint program point |
|
586 |
* @return the value |
|
587 |
*/ |
|
24741
4232289c3235
8040102: Remove all references to Unsafe and definition of anonymous clases from the code
lagergren
parents:
24727
diff
changeset
|
588 |
public double getDoubleOptimistic(final int index, final int programPoint) { |
24719 | 589 |
throw new UnwarrantedOptimismException(getObject(index), programPoint, getOptimisticType()); |
590 |
} |
|
591 |
||
592 |
/** |
|
16147 | 593 |
* Get an Object value from a given index |
594 |
* |
|
595 |
* @param index the index |
|
596 |
* @return the value |
|
597 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
598 |
public abstract Object getObject(final int index); |
16147 | 599 |
|
600 |
/** |
|
601 |
* Tests to see if an entry exists (avoids boxing.) |
|
602 |
* @param index the index |
|
603 |
* @return true if entry exists |
|
604 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
605 |
public abstract boolean has(final int index); |
16147 | 606 |
|
607 |
/** |
|
608 |
* Returns if element at specific index can be deleted or not. |
|
609 |
* |
|
610 |
* @param index the index of the element |
|
611 |
* @param strict are we in strict mode |
|
612 |
* |
|
613 |
* @return true if element can be deleted |
|
614 |
*/ |
|
615 |
public boolean canDelete(final int index, final boolean strict) { |
|
616 |
return true; |
|
617 |
} |
|
618 |
||
619 |
/** |
|
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
620 |
* Returns if element at specific index can be deleted or not. |
16147 | 621 |
* |
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
622 |
* @param longIndex the index |
16147 | 623 |
* @param strict are we in strict mode |
624 |
* |
|
625 |
* @return true if range can be deleted |
|
626 |
*/ |
|
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
627 |
public boolean canDelete(final long longIndex, final boolean strict) { |
16147 | 628 |
return true; |
629 |
} |
|
630 |
||
631 |
/** |
|
32892
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
632 |
* Delete a range from the array if {@code fromIndex} is less than or equal to {@code toIndex} |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
633 |
* and the array supports deletion. |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
634 |
* |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
635 |
* @param fromIndex the start index (inclusive) |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
636 |
* @param toIndex the end index (inclusive) |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
637 |
* @param strict are we in strict mode |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
638 |
* @return an array with the range deleted, or this array if no deletion took place |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
639 |
*/ |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
640 |
public final ArrayData safeDelete(final long fromIndex, final long toIndex, final boolean strict) { |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
641 |
if (fromIndex <= toIndex && canDelete(fromIndex, strict)) { |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
642 |
return delete(fromIndex, toIndex); |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
643 |
} |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
644 |
return this; |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
645 |
} |
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
646 |
|
7186b06a72cf
8138632: Sparse array does not handle growth of underlying dense array
hannesw
parents:
28787
diff
changeset
|
647 |
/** |
16147 | 648 |
* Returns property descriptor for element at a given index |
649 |
* |
|
650 |
* @param global the global object |
|
651 |
* @param index the index |
|
652 |
* |
|
653 |
* @return property descriptor for element |
|
654 |
*/ |
|
23375
a1110f2cbe75
8037400: Remove getInitialMap getters and GlobalObject interface
sundar
parents:
23078
diff
changeset
|
655 |
public PropertyDescriptor getDescriptor(final Global global, final int index) { |
16147 | 656 |
return global.newDataDescriptor(getObject(index), true, true, true); |
657 |
} |
|
658 |
||
659 |
/** |
|
660 |
* Delete an array value at the given index, substituting |
|
661 |
* for an undefined |
|
662 |
* |
|
663 |
* @param index the index |
|
664 |
* @return new array data (or same) |
|
665 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
666 |
public abstract ArrayData delete(final int index); |
16147 | 667 |
|
668 |
/** |
|
669 |
* Delete a given range from this array; |
|
670 |
* |
|
671 |
* @param fromIndex from index (inclusive) |
|
672 |
* @param toIndex to index (inclusive) |
|
673 |
* |
|
674 |
* @return new ArrayData after deletion |
|
675 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
676 |
public abstract ArrayData delete(final long fromIndex, final long toIndex); |
16147 | 677 |
|
678 |
/** |
|
679 |
* Convert the ArrayData to one with a different element type |
|
680 |
* Currently Arrays are not collapsed to narrower types, just to |
|
681 |
* wider ones. Attempting to narrow an array will assert |
|
682 |
* |
|
683 |
* @param type new element type |
|
684 |
* @return new array data |
|
685 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
686 |
public abstract ArrayData convert(final Class<?> type); |
16147 | 687 |
|
688 |
/** |
|
689 |
* Push an array of items to the end of the array |
|
690 |
* |
|
691 |
* @param strict are we in strict mode |
|
692 |
* @param items the items |
|
693 |
* @return new array data (or same) |
|
694 |
*/ |
|
695 |
public ArrayData push(final boolean strict, final Object... items) { |
|
696 |
if (items.length == 0) { |
|
697 |
return this; |
|
698 |
} |
|
699 |
||
700 |
final Class<?> widest = widestType(items); |
|
701 |
||
702 |
ArrayData newData = convert(widest); |
|
26886
18c744ab4df2
8059211: Changed ArrayData.length accessor to use the protected field and fixed javadoc warnings related to this
lagergren
parents:
26768
diff
changeset
|
703 |
long pos = newData.length; |
16147 | 704 |
for (final Object item : items) { |
705 |
newData = newData.ensure(pos); //avoid sparse array |
|
706 |
newData.set((int)pos++, item, strict); |
|
707 |
} |
|
708 |
return newData; |
|
709 |
} |
|
710 |
||
711 |
/** |
|
24720 | 712 |
* Push an array of items to the end of the array |
713 |
* |
|
714 |
* @param strict are we in strict mode |
|
715 |
* @param item the item |
|
716 |
* @return new array data (or same) |
|
717 |
*/ |
|
718 |
public ArrayData push(final boolean strict, final Object item) { |
|
719 |
return push(strict, new Object[] { item }); |
|
720 |
} |
|
721 |
||
722 |
/** |
|
16147 | 723 |
* Pop an element from the end of the array |
724 |
* |
|
725 |
* @return the popped element |
|
726 |
*/ |
|
727 |
public abstract Object pop(); |
|
728 |
||
729 |
/** |
|
730 |
* Slice out a section of the array and return that |
|
731 |
* subsection as a new array data: [from, to) |
|
732 |
* |
|
733 |
* @param from start index |
|
734 |
* @param to end index + 1 |
|
735 |
* @return new array data |
|
736 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
737 |
public abstract ArrayData slice(final long from, final long to); |
16147 | 738 |
|
21438
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
739 |
/** |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
740 |
* Fast splice operation. This just modifies the array according to the number of |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
741 |
* elements added and deleted but does not insert the added elements. Throws |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
742 |
* {@code UnsupportedOperationException} if fast splice operation is not supported |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
743 |
* for this class or arguments. |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
744 |
* |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
745 |
* @param start start index of splice operation |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
746 |
* @param removed number of removed elements |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
747 |
* @param added number of added elements |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
748 |
* @throws UnsupportedOperationException if fast splice is not supported for the class or arguments. |
24719 | 749 |
* @return new arraydata, but this never happens because we always throw an exception |
21438
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
750 |
*/ |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
751 |
public ArrayData fastSplice(final int start, final int removed, final int added) throws UnsupportedOperationException { |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
752 |
throw new UnsupportedOperationException(); |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
753 |
} |
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
754 |
|
4292865c758b
8026701: Array.prototype.splice is slow on dense arrays
hannesw
parents:
19897
diff
changeset
|
755 |
static Class<?> widestType(final Object... items) { |
16147 | 756 |
assert items.length > 0; |
757 |
||
758 |
Class<?> widest = Integer.class; |
|
759 |
||
760 |
for (final Object item : items) { |
|
26378
ca7093bd5fd1
8056129: AtomicInteger is treated as primitive number with optimistic compilation
attila
parents:
25865
diff
changeset
|
761 |
if (item == null) { |
ca7093bd5fd1
8056129: AtomicInteger is treated as primitive number with optimistic compilation
attila
parents:
25865
diff
changeset
|
762 |
return Object.class; |
ca7093bd5fd1
8056129: AtomicInteger is treated as primitive number with optimistic compilation
attila
parents:
25865
diff
changeset
|
763 |
} |
ca7093bd5fd1
8056129: AtomicInteger is treated as primitive number with optimistic compilation
attila
parents:
25865
diff
changeset
|
764 |
final Class<?> itemClass = item.getClass(); |
34732 | 765 |
if (itemClass == Double.class || itemClass == Float.class || itemClass == Long.class) { |
16147 | 766 |
if (widest == Integer.class) { |
767 |
widest = Double.class; |
|
768 |
} |
|
26378
ca7093bd5fd1
8056129: AtomicInteger is treated as primitive number with optimistic compilation
attila
parents:
25865
diff
changeset
|
769 |
} else if (itemClass != Integer.class && itemClass != Short.class && itemClass != Byte.class) { |
ca7093bd5fd1
8056129: AtomicInteger is treated as primitive number with optimistic compilation
attila
parents:
25865
diff
changeset
|
770 |
return Object.class; |
16147 | 771 |
} |
772 |
} |
|
773 |
||
774 |
return widest; |
|
775 |
} |
|
776 |
||
777 |
/** |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
778 |
* Return a list of keys in the array for the iterators |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
779 |
* @return iterator key list |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
780 |
*/ |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
781 |
protected List<Long> computeIteratorKeys() { |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
782 |
final List<Long> keys = new ArrayList<>(); |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
783 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
784 |
final long len = length(); |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
785 |
for (long i = 0L; i < len; i = nextIndex(i)) { |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
786 |
if (has((int)i)) { |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
787 |
keys.add(i); |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
788 |
} |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
789 |
} |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
790 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
791 |
return keys; |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
792 |
} |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
793 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
794 |
/** |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
795 |
* Return an iterator that goes through all indexes of elements |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
796 |
* in this array. This includes those after array.length if |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
797 |
* they exist |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
798 |
* |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
799 |
* @return iterator |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
800 |
*/ |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
801 |
public Iterator<Long> indexIterator() { |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
802 |
return computeIteratorKeys().iterator(); |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
803 |
} |
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
804 |
|
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
805 |
/** |
16147 | 806 |
* Exponential growth function for array size when in |
807 |
* need of resizing. |
|
808 |
* |
|
809 |
* @param size current size |
|
810 |
* @return next size to allocate for internal array |
|
811 |
*/ |
|
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
812 |
public static int nextSize(final int size) { |
24720 | 813 |
return alignUp(size + 1) * 2; |
16147 | 814 |
} |
815 |
||
816 |
/** |
|
817 |
* Return the next valid index from a given one. Subclassed for various |
|
818 |
* array representation |
|
819 |
* |
|
820 |
* @param index the current index |
|
821 |
* |
|
822 |
* @return the next index |
|
823 |
*/ |
|
27525
e7d3c00b9fb8
8035312: Various array and ScriptObject length issues for non writable length fields
lagergren
parents:
27364
diff
changeset
|
824 |
long nextIndex(final long index) { |
16147 | 825 |
return index + 1; |
826 |
} |
|
827 |
||
828 |
static Object invoke(final MethodHandle mh, final Object arg) { |
|
829 |
try { |
|
830 |
return mh.invoke(arg); |
|
831 |
} catch (final RuntimeException | Error e) { |
|
832 |
throw e; |
|
833 |
} catch (final Throwable t) { |
|
834 |
throw new RuntimeException(t); |
|
835 |
} |
|
836 |
} |
|
24719 | 837 |
|
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
838 |
/** |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
839 |
* Find a fast call if one exists |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
840 |
* |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
841 |
* @param clazz array data class |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
842 |
* @param desc callsite descriptor |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
843 |
* @param request link request |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
844 |
* @return fast property getter if one is found |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
845 |
*/ |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
846 |
public GuardedInvocation findFastCallMethod(final Class<? extends ArrayData> clazz, final CallSiteDescriptor desc, final LinkRequest request) { |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
847 |
return null; |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
848 |
} |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26378
diff
changeset
|
849 |
|
24720 | 850 |
/** |
851 |
* Find a fast element getter if one exists |
|
852 |
* |
|
853 |
* @param clazz array data class |
|
854 |
* @param desc callsite descriptor |
|
855 |
* @param request link request |
|
856 |
* @return fast index getter if one is found |
|
857 |
*/ |
|
858 |
public GuardedInvocation findFastGetIndexMethod(final Class<? extends ArrayData> clazz, final CallSiteDescriptor desc, final LinkRequest request) { // array, index, value |
|
859 |
return null; |
|
860 |
} |
|
861 |
||
862 |
/** |
|
863 |
* Find a fast element setter if one exists |
|
864 |
* |
|
865 |
* @param clazz array data class |
|
866 |
* @param desc callsite descriptor |
|
867 |
* @param request link request |
|
868 |
* @return fast index getter if one is found |
|
869 |
*/ |
|
870 |
public GuardedInvocation findFastSetIndexMethod(final Class<? extends ArrayData> clazz, final CallSiteDescriptor desc, final LinkRequest request) { // array, index, value |
|
871 |
return null; |
|
872 |
} |
|
16147 | 873 |
} |