Class AbstractWritableArray
java.lang.Object
com.oracle.truffle.js.runtime.array.ScriptArray
com.oracle.truffle.js.runtime.array.DynamicArray
com.oracle.truffle.js.runtime.array.dyn.AbstractWritableArray
- Direct Known Subclasses:
AbstractDoubleArray,AbstractIntArray,AbstractJSObjectArray,AbstractObjectArray
Base class of a javascript dynamic writable array. The array implementation uses three write
access modes:
- InBoundsFast: Accessed index is in bounds of the physical and logical array. So no housekeeping should usually be necessary in this access mode.
- InBounds: Accessed index is in bounds of the physical backing array. Little housekeeping.
- Supported: If a write to this index is supported by the array. Full housekeeping.
- Not Supported: If a write to this index is not supported by the array. The array will transition to another implementation that supports the written index.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.oracle.truffle.js.runtime.array.DynamicArray
DynamicArray.DynamicArrayCacheNested classes/interfaces inherited from class com.oracle.truffle.js.runtime.array.ScriptArray
ScriptArray.CreateWritableProfileAccess, ScriptArray.DefaultIterator, ScriptArray.SetLengthProfileAccess -
Field Summary
Fields inherited from class com.oracle.truffle.js.runtime.array.DynamicArray
cache, INTEGRITY_LEVEL_FROZEN, INTEGRITY_LEVEL_FROZEN_LENGTH_READONLY, INTEGRITY_LEVEL_MASK, INTEGRITY_LEVEL_NONE, INTEGRITY_LEVEL_NONE_LENGTH_READONLY, INTEGRITY_LEVEL_NOT_EXTENSIBLE, INTEGRITY_LEVEL_NOT_EXTENSIBLE_LENGTH_READONLY, INTEGRITY_LEVEL_SEALED, INTEGRITY_LEVEL_SEALED_LENGTH_READONLY, INTEGRITY_LEVELS, integrityLevel, LENGTH_NOT_WRITABLE, LENGTH_WRITABLE_MASKFields inherited from class com.oracle.truffle.js.runtime.array.ScriptArray
EMPTY_OBJECT_ARRAY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractWritableArray(int integrityLevel, DynamicArray.DynamicArrayCache cache) -
Method Summary
Modifier and TypeMethodDescriptionabstract ObjectallocateArray(int length) protected final booleanassertHoleCount(JSDynamicObject object) protected final booleancheckFillHoles(JSDynamicObject object, int internalIndex, int grown) protected voidclearUnusedArea(JSDynamicObject object, int startIdx, int endIdx, int arrayOffset, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) After shortening the array, the now unused area has to be cleared.booleancontainsHoles(JSDynamicObject object, long index) protected final intcountHoles(JSDynamicObject object) protected final ScriptArraydeleteElementHoles(JSDynamicObject object, long index) protected voidfillHoles(JSDynamicObject object, int internalIndex, int grown, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) protected abstract intgetArrayCapacity(JSDynamicObject object) protected intgetArrayOffset(JSDynamicObject object) The arrayOffset (int) is the first element in internal array.final ObjectgetElement(JSDynamicObject object, long index) final ObjectgetElementInBounds(JSDynamicObject object, long index) abstract ObjectgetInBoundsFast(JSDynamicObject object, int index) doublegetInBoundsFastDouble(JSDynamicObject object, int index) intgetInBoundsFastInt(JSDynamicObject object, int index) protected longgetIndexOffset(JSDynamicObject object) The indexOffset (int) is the first element is in array[indexOffset + arrayOffset].protected static intgetUsedLength(JSDynamicObject object) booleanhasElement(JSDynamicObject object, long index) booleanhasHoles(JSDynamicObject object) Returns true when this array actually has holes betweenScriptArray.firstElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject)andScriptArray.lastElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject).booleanhasHolesOrUnused(JSDynamicObject object) Returns true when this array has any hole or unused elements between 0 andScriptArray.length(com.oracle.truffle.js.runtime.objects.JSDynamicObject).protected final voidincrementHolesCount(JSDynamicObject object, int offset) protected abstract booleanisHolePrepared(JSDynamicObject object, int index) Returns true when the array contains a hole at that index.final booleanisInBounds(JSDynamicObject object, int index) final booleanisInBoundsFast(JSDynamicObject object, long index) Returns true if the index can be written using inBoundsFast access mode.final booleanisSparse(JSDynamicObject object, long index) abstract booleanisSupported(JSDynamicObject object, long index) final booleanisSupportedContiguous(JSDynamicObject object, long index) final booleanisSupportedHoles(JSDynamicObject object, long index) static booleanisSupportedZeroBased(JSDynamicObject object, int index) final longlength(JSDynamicObject object) final intlengthInt(JSDynamicObject object) protected abstract voidmoveRangePrepared(JSDynamicObject object, int src, int dst, int len) Movelenelements fromsrctodst.longnextElementIndex(JSDynamicObject object, long index) Returns the next index.protected final longnextElementIndexHoles(JSDynamicObject object, long index0) protected final longnextElementIndexZeroBased(JSDynamicObject object, long index) protected abstract intprepareInBounds(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) protected final intprepareInBoundsContiguous(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) protected abstract intprepareInBoundsFast(JSDynamicObject object, long index) protected final intprepareInBoundsHoles(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) protected static voidprepareInBoundsZeroBased(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) protected abstract intprepareSupported(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) protected final intprepareSupportedContiguous(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) protected final intprepareSupportedHoles(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) protected final voidprepareSupportedZeroBased(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) longpreviousElementIndex(JSDynamicObject object, long index) Returns the previous index.protected final longpreviousElementIndexHoles(JSDynamicObject object, long index0) protected final ScriptArrayremoveRangeContiguous(JSDynamicObject object, long start, long end) protected final ScriptArrayremoveRangeHoles(JSDynamicObject object, long start, long end) protected abstract voidresizeArray(JSDynamicObject object, int newCapacity, int oldCapacity, int offset) protected voidsetArrayOffset(JSDynamicObject object, int value) protected static final voidsetArrayProperties(JSDynamicObject object, long length, int usedLength, long indexOffset, int arrayOffset) protected static final voidsetArrayProperties(JSDynamicObject object, Object array, long length, int usedLength, long indexOffset, int arrayOffset) protected abstract voidsetHoleValue(JSDynamicObject object, int index) protected voidsetIndexOffset(JSDynamicObject object, long value) final ScriptArraysetLengthImpl(JSDynamicObject object, long length, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) protected abstract voidsetLengthLess(JSDynamicObject object, long length, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) protected final voidsetLengthLessContiguous(JSDynamicObject object, long length, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) protected voidsetLengthLessZeroBased(JSDynamicObject object, long length, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) shiftRangeImpl(JSDynamicObject object, long from) This function shifts all elements in the range from [0..limit[.toContiguous(JSDynamicObject object, long index, Object value) abstract AbstractWritableArraytoDouble(JSDynamicObject object, long index, double value) abstract AbstractWritableArraytoHoles(JSDynamicObject object, long index, Object value) toNonContiguous(JSDynamicObject object, int index, Object value, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) toNonHoles(JSDynamicObject object, long index, Object value) abstract AbstractWritableArraytoObject(JSDynamicObject object, long index, Object value) final SparseArraytoSparse(JSDynamicObject object, long index, Object value) protected final voidtraceWriteValue(String access, int index, Object value) protected static booleanunusedElementsAreHoles(Object[] array, int usedStart, int usedLength) protected abstract AbstractWritableArraywithIntegrityLevel(int newIntegrityLevel) Methods inherited from class com.oracle.truffle.js.runtime.array.DynamicArray
cloneArray, createCache, freeze, isExtensible, isFrozen, isLengthNotWritable, isSealed, maybePreinitializeCache, preventExtensions, seal, setIntegrityLevel, setLengthNotWritable, toStringMethods inherited from class com.oracle.truffle.js.runtime.array.ScriptArray
addRange, addRangeImpl, asIterable, canDeleteElement, cast, createConstantArray, createConstantEmptyArray, deleteElement, deleteElementImpl, firstElementIndex, isHolesType, isInstance, lastElementIndex, makeMultiRangeList, makeRangeList, nextPower, ownPropertyKeys, ownPropertyKeysContiguous, ownPropertyKeysHoles, removeRange, removeRange, removeRangeImpl, setElement, setElementImpl, setLength, setLength, shiftRange, toArray, traceArrayTransition, traceWrite, valueIsByte
-
Constructor Details
-
AbstractWritableArray
-
-
Method Details
-
setArrayProperties
protected static final void setArrayProperties(JSDynamicObject object, Object array, long length, int usedLength, long indexOffset, int arrayOffset) -
setArrayProperties
protected static final void setArrayProperties(JSDynamicObject object, long length, int usedLength, long indexOffset, int arrayOffset) -
isInBoundsFast
Returns true if the index can be written using inBoundsFast access mode.- Overrides:
isInBoundsFastin classScriptArray
-
prepareInBoundsFast
-
isInBounds
-
prepareInBounds
protected abstract int prepareInBounds(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) -
prepareInBoundsZeroBased
protected static void prepareInBoundsZeroBased(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) -
getUsedLength
-
prepareInBoundsContiguous
protected final int prepareInBoundsContiguous(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) -
prepareInBoundsHoles
protected final int prepareInBoundsHoles(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) -
containsHoles
-
isSupported
-
isSupportedZeroBased
-
isSupportedContiguous
-
isSupportedHoles
-
prepareSupported
protected abstract int prepareSupported(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) -
prepareSupportedZeroBased
protected final void prepareSupportedZeroBased(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) -
prepareSupportedContiguous
protected final int prepareSupportedContiguous(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) -
prepareSupportedHoles
protected final int prepareSupportedHoles(JSDynamicObject object, int index, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) -
incrementHolesCount
-
setHoleValue
-
getArrayCapacity
-
getArrayOffset
The arrayOffset (int) is the first element in internal array. -
setArrayOffset
-
getIndexOffset
The indexOffset (int) is the first element is in array[indexOffset + arrayOffset]. -
setIndexOffset
-
fillHoles
protected void fillHoles(JSDynamicObject object, int internalIndex, int grown, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) -
checkFillHoles
-
toDouble
-
toObject
-
toContiguous
-
toHoles
-
toNonHoles
-
toSparse
-
resizeArray
protected abstract void resizeArray(JSDynamicObject object, int newCapacity, int oldCapacity, int offset) -
isSparse
-
hasElement
- Specified by:
hasElementin classScriptArray- Returns:
- true if array has an element (not a hole) at this index.
-
nextElementIndex
Description copied from class:ScriptArrayReturns the next index. The index is guaranteed either to exist, or be MAX_SAFE_INTEGER. Reason for MAX_SAFE_INTEGER is: this array could be the prototype of another one; returning the length() of this array would be wrong, if the inheriting array is longer, but has a hole at length().- Specified by:
nextElementIndexin classScriptArray
-
isHolePrepared
Returns true when the array contains a hole at that index. The index is a prepared (internal) index. -
nextElementIndexHoles
-
nextElementIndexZeroBased
-
previousElementIndex
Description copied from class:ScriptArrayReturns the previous index. The index is guaranteed either to exist, or be smaller than firstElementIndex().- Specified by:
previousElementIndexin classScriptArray
-
previousElementIndexHoles
-
length
- Specified by:
lengthin classScriptArray
-
lengthInt
- Specified by:
lengthIntin classScriptArray
-
setLengthImpl
public final ScriptArray setLengthImpl(JSDynamicObject object, long length, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) - Specified by:
setLengthImplin classScriptArray
-
setLengthLess
protected abstract void setLengthLess(JSDynamicObject object, long length, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) -
setLengthLessZeroBased
protected void setLengthLessZeroBased(JSDynamicObject object, long length, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) -
setLengthLessContiguous
protected final void setLengthLessContiguous(JSDynamicObject object, long length, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) -
clearUnusedArea
protected void clearUnusedArea(JSDynamicObject object, int startIdx, int endIdx, int arrayOffset, com.oracle.truffle.api.nodes.Node node, ScriptArray.SetLengthProfileAccess profile) After shortening the array, the now unused area has to be cleared. -
getElement
- Specified by:
getElementin classScriptArray
-
getElementInBounds
- Specified by:
getElementInBoundsin classScriptArray
-
getInBoundsFast
-
getInBoundsFastInt
public int getInBoundsFastInt(JSDynamicObject object, int index) throws com.oracle.truffle.api.nodes.UnexpectedResultException - Throws:
com.oracle.truffle.api.nodes.UnexpectedResultException
-
getInBoundsFastDouble
public double getInBoundsFastDouble(JSDynamicObject object, int index) throws com.oracle.truffle.api.nodes.UnexpectedResultException - Throws:
com.oracle.truffle.api.nodes.UnexpectedResultException
-
deleteElementHoles
-
traceWriteValue
-
toNonContiguous
public ScriptArray toNonContiguous(JSDynamicObject object, int index, Object value, com.oracle.truffle.api.nodes.Node node, AbstractWritableArray.SetSupportedProfileAccess profile) -
withIntegrityLevel
- Specified by:
withIntegrityLevelin classDynamicArray
-
allocateArray
-
removeRangeContiguous
-
removeRangeHoles
-
hasHoles
Description copied from class:ScriptArrayReturns true when this array actually has holes betweenScriptArray.firstElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject)andScriptArray.lastElementIndex(com.oracle.truffle.js.runtime.objects.JSDynamicObject). ImpliesScriptArray.isHolesType().- Specified by:
hasHolesin classScriptArray- See Also:
-
hasHolesOrUnused
Description copied from class:ScriptArrayReturns true when this array has any hole or unused elements between 0 andScriptArray.length(com.oracle.truffle.js.runtime.objects.JSDynamicObject).- Overrides:
hasHolesOrUnusedin classScriptArray- See Also:
-
countHoles
-
assertHoleCount
-
moveRangePrepared
Movelenelements fromsrctodst. -
shiftRangeImpl
Description copied from class:ScriptArrayThis function shifts all elements in the range from [0..limit[. Depending on the underlying implementation, the shift operation might be zero-copy. Can be used by e.g. Array.prototype.shift;- Overrides:
shiftRangeImplin classScriptArray
-
unusedElementsAreHoles
-