File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/array Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,18 @@ public final long length(JSDynamicObject object) {
112112 @ Override
113113 public final int lengthInt (JSDynamicObject object ) {
114114 JSTypedArrayObject typedArray = (JSTypedArrayObject ) object ;
115- return fixedLength ? typedArray .getLengthFixed () : typedArray .getLength ();
115+ if (fixedLength ) {
116+ return typedArray .getLengthFixed ();
117+ } else {
118+ JSArrayBufferObject arrayBuffer = typedArray .getArrayBuffer ();
119+ int byteLength = switch (bufferType ) {
120+ case BUFFER_TYPE_ARRAY -> ((JSArrayBufferObject .Heap ) arrayBuffer ).getByteLength ();
121+ case BUFFER_TYPE_DIRECT -> ((JSArrayBufferObject .DirectBase ) arrayBuffer ).getByteLength ();
122+ case BUFFER_TYPE_INTEROP -> ((JSArrayBufferObject .Interop ) arrayBuffer ).getByteLength ();
123+ default -> throw Errors .shouldNotReachHereUnexpectedValue (bufferType );
124+ };
125+ return (byteLength - getOffset (object )) / bytesPerElement ;
126+ }
116127 }
117128
118129 @ Override
You can’t perform that action at this time.
0 commit comments