Changeset 272170 in webkit
- Timestamp:
- Feb 1, 2021 12:56:41 PM (18 months ago)
- Location:
- trunk
- Files:
-
- 12 added
- 64 edited
- 2 copied
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/bigint-typed-array-array-modes-profile.js (added)
-
JSTests/stress/bigint-typed-array-byte-offset.js (added)
-
JSTests/stress/bigint-typed-array-canonical-numeric-index-string.js (added)
-
JSTests/stress/bigint-typed-array-constructor-undefined.js (added)
-
JSTests/stress/bigint-typed-array-get-by-val-profiling.js (added)
-
JSTests/stress/bigint-typed-array-lastIndexOf-exception-check.js (added)
-
JSTests/stress/bigint-typed-array-put-by-val-profiling.js (added)
-
JSTests/stress/bigint-typedarray-getownproperty.js (added)
-
JSTests/stress/bigint64array-bytelength.js (added)
-
JSTests/stress/bigint64array-get-by-val.js (added)
-
JSTests/stress/bigint64array-put-by-val.js (added)
-
JSTests/stress/data-view-bigint.js (added)
-
JSTests/test262/config.yaml (modified) (3 diffs)
-
JSTests/test262/expectations.yaml (modified) (2 diffs)
-
Source/JavaScriptCore/API/JSTypedArray.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/API/JSValueRef.h (modified) (2 diffs)
-
Source/JavaScriptCore/API/tests/TypedArrayCTest.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/CMakeLists.txt (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (modified) (5 diffs)
-
Source/JavaScriptCore/builtins/BuiltinNames.h (modified) (3 diffs)
-
Source/JavaScriptCore/builtins/TypedArrayPrototype.js (modified) (3 diffs)
-
Source/JavaScriptCore/bytecode/ArrayProfile.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/bytecode/ArrayProfile.h (modified) (2 diffs)
-
Source/JavaScriptCore/bytecode/ByValInfo.h (modified) (4 diffs)
-
Source/JavaScriptCore/bytecode/LinkTimeConstant.h (modified) (2 diffs)
-
Source/JavaScriptCore/bytecode/SpeculatedType.cpp (modified) (5 diffs)
-
Source/JavaScriptCore/bytecode/SpeculatedType.h (modified) (5 diffs)
-
Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGArrayMode.cpp (modified) (9 diffs)
-
Source/JavaScriptCore/dfg/DFGArrayMode.h (modified) (3 diffs)
-
Source/JavaScriptCore/dfg/DFGClobberize.h (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGFixupPhase.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/dfg/DFGOperations.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGOperations.h (modified) (3 diffs)
-
Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp (modified) (1 diff)
-
Source/JavaScriptCore/jit/JITPropertyAccess.cpp (modified) (1 diff)
-
Source/JavaScriptCore/jit/Repatch.cpp (modified) (1 diff)
-
Source/JavaScriptCore/llint/LowLevelInterpreter.asm (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/AtomicsObject.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/BigInt64Array.h (copied) (copied from trunk/Source/JavaScriptCore/runtime/JSTypedArrayConstructors.cpp) (2 diffs)
-
Source/JavaScriptCore/runtime/BigUint64Array.h (copied) (copied from trunk/Source/JavaScriptCore/runtime/JSTypedArrayConstructors.cpp) (2 diffs)
-
Source/JavaScriptCore/runtime/JSArrayBufferView.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSArrayBufferView.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSBigInt.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/JSCell.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSDataView.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp (modified) (7 diffs)
-
Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h (modified) (9 diffs)
-
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.h (modified) (4 diffs)
-
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h (modified) (4 diffs)
-
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h (modified) (6 diffs)
-
Source/JavaScriptCore/runtime/JSGlobalObject.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSType.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSType.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSTypedArrayConstructors.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSTypedArrayConstructors.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSTypedArrays.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSTypedArrays.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ToNativeFromValue.h (modified) (4 diffs)
-
Source/JavaScriptCore/runtime/TypedArrayAdaptors.h (modified) (9 diffs)
-
Source/JavaScriptCore/runtime/TypedArrayType.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/TypedArrayType.h (modified) (7 diffs)
-
Source/JavaScriptCore/runtime/TypedArrays.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/VM.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/VM.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r272139 r272170 1 2021-01-31 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Implement BigInt64Array and BigUint64Array 4 https://bugs.webkit.org/show_bug.cgi?id=190800 5 6 Reviewed by Ross Kirsling. 7 8 Through this patch, we encounter two test262 failures and found that these tests have issues. 9 10 * stress/bigint-typed-array-array-modes-profile.js: Added. 11 (foo): 12 * stress/bigint-typed-array-byte-offset.js: Added. 13 (foo): 14 * stress/bigint-typed-array-canonical-numeric-index-string.js: Added. 15 (makeTest.assert): 16 (makeTest): 17 (const.testInvalidIndices.makeTest.set assert): 18 (const.testInvalidIndices.makeTest): 19 (const.testValidIndices.makeTest.set assert): 20 (const.testValidIndices.makeTest): 21 * stress/bigint-typed-array-constructor-undefined.js: Added. 22 * stress/bigint-typed-array-get-by-val-profiling.js: Added. 23 (testArray.testCode): 24 (testArray): 25 * stress/bigint-typed-array-lastIndexOf-exception-check.js: Added. 26 * stress/bigint-typed-array-put-by-val-profiling.js: Added. 27 (testArray.testCode): 28 (testArray): 29 * stress/bigint-typedarray-getownproperty.js: Added. 30 (assert): 31 (foo): 32 * stress/bigint64array-bytelength.js: Added. 33 (test1): 34 (test2): 35 (shouldBe): 36 * stress/bigint64array-get-by-val.js: Added. 37 (shouldBe): 38 (test1): 39 (test2): 40 * stress/bigint64array-put-by-val.js: Added. 41 (shouldBe): 42 (test11): 43 (test12): 44 (test21): 45 (test22): 46 * test262/config.yaml: 47 * test262/expectations.yaml: 48 1 49 2021-02-01 Yusuke Suzuki <ysuzuki@apple.com> 2 50 -
trunk/JSTests/test262/config.yaml
r271511 r272170 29 29 - Intl.ListFormat 30 30 paths: 31 - test/built-ins/DataView/prototype/getBigInt6432 - test/built-ins/DataView/prototype/getBigUint6433 - test/built-ins/DataView/prototype/setBigInt6434 35 # https://bugs.webkit.org/show_bug.cgi?id=19080036 - test/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt37 - test/built-ins/TypedArray/prototype/buffer/BigInt38 - test/built-ins/TypedArray/prototype/byteLength/BigInt39 - test/built-ins/TypedArray/prototype/byteOffset/BigInt40 - test/built-ins/TypedArray/prototype/copyWithin/BigInt41 - test/built-ins/TypedArray/prototype/entries/BigInt42 - test/built-ins/TypedArray/prototype/every/BigInt43 - test/built-ins/TypedArray/prototype/fill/BigInt44 - test/built-ins/TypedArray/prototype/filter/BigInt45 - test/built-ins/TypedArray/prototype/find/BigInt46 - test/built-ins/TypedArray/prototype/findIndex/BigInt47 - test/built-ins/TypedArray/prototype/forEach/BigInt48 - test/built-ins/TypedArray/prototype/includes/BigInt49 - test/built-ins/TypedArray/prototype/indexOf/BigInt50 - test/built-ins/TypedArray/prototype/join/BigInt51 - test/built-ins/TypedArray/prototype/keys/BigInt52 - test/built-ins/TypedArray/prototype/lastIndexOf/BigInt53 - test/built-ins/TypedArray/prototype/length/BigInt54 - test/built-ins/TypedArray/prototype/map/BigInt55 - test/built-ins/TypedArray/prototype/reduce/BigInt56 - test/built-ins/TypedArray/prototype/reduceRight/BigInt57 - test/built-ins/TypedArray/prototype/reverse/BigInt58 - test/built-ins/TypedArray/prototype/set/BigInt59 - test/built-ins/TypedArray/prototype/slice/BigInt60 - test/built-ins/TypedArray/prototype/some/BigInt61 - test/built-ins/TypedArray/prototype/sort/BigInt62 - test/built-ins/TypedArray/prototype/subarray/BigInt63 - test/built-ins/TypedArray/prototype/toLocaleString/BigInt64 - test/built-ins/TypedArray/prototype/toString/BigInt65 - test/built-ins/TypedArray/prototype/values/BigInt66 - test/built-ins/TypedArrayConstructors/BigInt64Array67 - test/built-ins/TypedArrayConstructors/BigUint64Array68 - test/built-ins/TypedArrayConstructors/ctors-bigint69 - test/built-ins/TypedArrayConstructors/from/BigInt70 - test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt71 - test/built-ins/TypedArrayConstructors/internals/Delete/BigInt72 - test/built-ins/TypedArrayConstructors/internals/Get/BigInt73 - test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt74 - test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt75 - test/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/BigInt76 - test/built-ins/TypedArrayConstructors/internals/Set/BigInt77 - test/built-ins/TypedArrayConstructors/of/BigInt78 79 31 - test/built-ins/Atomics/add/bigint 80 32 - test/built-ins/Atomics/and/bigint … … 101 53 - test/language/identifiers/start-unicode-13.0.0-escaped.js 102 54 - test/language/identifiers/start-unicode-13.0.0.js 103 104 # https://bugs.webkit.org/show_bug.cgi?id=190800105 - test/built-ins/Object/seal/seal-bigint64array.js106 - test/built-ins/Object/seal/seal-biguint64array.js107 - test/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js108 - test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/src-typedarray-big-throws.js109 - test/built-ins/TypedArrayConstructors/prototype/Symbol.toStringTag/bigint-inherited.js110 - test/built-ins/TypedArrayConstructors/prototype/bigint-Symbol.iterator.js111 - test/built-ins/TypedArrayConstructors/prototype/buffer/bigint-inherited.js112 - test/built-ins/TypedArrayConstructors/prototype/byteLength/bigint-inherited.js113 - test/built-ins/TypedArrayConstructors/prototype/byteOffset/bigint-inherited.js114 - test/built-ins/TypedArrayConstructors/prototype/copyWithin/bigint-inherited.js115 - test/built-ins/TypedArrayConstructors/prototype/entries/bigint-inherited.js116 - test/built-ins/TypedArrayConstructors/prototype/every/bigint-inherited.js117 - test/built-ins/TypedArrayConstructors/prototype/fill/bigint-inherited.js118 - test/built-ins/TypedArrayConstructors/prototype/filter/bigint-inherited.js119 - test/built-ins/TypedArrayConstructors/prototype/find/bigint-inherited.js120 - test/built-ins/TypedArrayConstructors/prototype/findIndex/bigint-inherited.js121 - test/built-ins/TypedArrayConstructors/prototype/forEach/bigint-inherited.js122 - test/built-ins/TypedArrayConstructors/prototype/indexOf/bigint-inherited.js123 - test/built-ins/TypedArrayConstructors/prototype/join/bigint-inherited.js124 - test/built-ins/TypedArrayConstructors/prototype/keys/bigint-inherited.js125 - test/built-ins/TypedArrayConstructors/prototype/lastIndexOf/bigint-inherited.js126 - test/built-ins/TypedArrayConstructors/prototype/length/bigint-inherited.js127 - test/built-ins/TypedArrayConstructors/prototype/map/bigint-inherited.js128 - test/built-ins/TypedArrayConstructors/prototype/reduce/bigint-inherited.js129 - test/built-ins/TypedArrayConstructors/prototype/reduceRight/bigint-inherited.js130 - test/built-ins/TypedArrayConstructors/prototype/reverse/bigint-inherited.js131 - test/built-ins/TypedArrayConstructors/prototype/set/bigint-inherited.js132 - test/built-ins/TypedArrayConstructors/prototype/slice/bigint-inherited.js133 - test/built-ins/TypedArrayConstructors/prototype/some/bigint-inherited.js134 - test/built-ins/TypedArrayConstructors/prototype/sort/bigint-inherited.js135 - test/built-ins/TypedArrayConstructors/prototype/subarray/bigint-inherited.js136 - test/built-ins/TypedArrayConstructors/prototype/toLocaleString/bigint-inherited.js137 - test/built-ins/TypedArrayConstructors/prototype/toString/bigint-inherited.js138 - test/built-ins/TypedArrayConstructors/prototype/values/bigint-inherited.js139 - test/language/expressions/class/subclass-builtins/subclass-BigInt64Array.js140 - test/language/expressions/class/subclass-builtins/subclass-BigUint64Array.js141 - test/language/statements/class/subclass-builtins/subclass-BigInt64Array.js142 - test/language/statements/class/subclass-builtins/subclass-BigUint64Array.js143 55 144 56 # requires ICU 65 (https://unicode-org.atlassian.net/browse/ICU-20654) … … 213 125 - test/intl402/NumberFormat/prototype/resolvedOptions/compactDisplay.js 214 126 - test/intl402/NumberFormat/style-unit.js 127 128 # New ICU (66~) raises a different failure 129 - test/intl402/Locale/constructor-non-iana-canon.js -
trunk/JSTests/test262/expectations.yaml
r271509 r272170 824 824 default: 'SyntaxError: Invalid regular expression: number too large in {} quantifier' 825 825 strict mode: 'SyntaxError: Invalid regular expression: number too large in {} quantifier' 826 test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js: 827 default: 'TypeError: Invalid argument type in ToBigInt operation (Testing with BigInt64Array.)' 828 strict mode: 'TypeError: Invalid argument type in ToBigInt operation (Testing with BigInt64Array.)' 829 test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js: 830 default: 'Test262Error: throws a TypeError getting a value from the detached buffer Expected a TypeError to be thrown but no exception was thrown at all (Testing with BigInt64Array.)' 831 strict mode: 'Test262Error: throws a TypeError getting a value from the detached buffer Expected a TypeError to be thrown but no exception was thrown at all (Testing with BigInt64Array.)' 826 832 test/intl402/DateTimeFormat/prototype/formatRange/en-US.js: 827 833 default: 'Test262Error: Expected SameValue(«1/3/2019 – 1/5/2019», «1/3/2019 – 1/5/2019») to be true' … … 866 872 default: 'Test262Error: Expected SameValue(«ru-Armn-SU», «ru-Armn-AM») to be true' 867 873 strict mode: 'Test262Error: Expected SameValue(«ru-Armn-SU», «ru-Armn-AM») to be true' 868 test/intl402/Locale/constructor-non-iana-canon.js:869 default: 'Test262Error: new Intl.Locale("mo").maximize().toString() returns "ro-Latn-RO" Expected SameValue(«ro», «ro-Latn-RO») to be true'870 strict mode: 'Test262Error: new Intl.Locale("mo").maximize().toString() returns "ro-Latn-RO" Expected SameValue(«ro», «ro-Latn-RO») to be true'871 874 test/intl402/Locale/constructor-options-region-valid.js: 872 875 default: "Test262Error: new Intl.Locale('en', {region: \"554\"}).toString() returns \"en-NZ\" Expected SameValue(«en-554», «en-NZ») to be true" -
trunk/Source/JavaScriptCore/API/JSTypedArray.cpp
r261895 r272170 65 65 case TypeFloat64: 66 66 return kJSTypedArrayTypeFloat64Array; 67 case TypeBigInt64: 68 return kJSTypedArrayTypeBigInt64Array; 69 case TypeBigUint64: 70 return kJSTypedArrayTypeBigUint64Array; 67 71 } 68 72 RELEASE_ASSERT_NOT_REACHED(); … … 93 97 case kJSTypedArrayTypeFloat64Array: 94 98 return TypeFloat64; 99 case kJSTypedArrayTypeBigInt64Array: 100 return TypeBigInt64; 101 case kJSTypedArrayTypeBigUint64Array: 102 return TypeBigUint64; 95 103 } 96 104 RELEASE_ASSERT_NOT_REACHED(); … … 124 132 case kJSTypedArrayTypeFloat64Array: 125 133 return JSFloat64Array::create(globalObject, globalObject->typedArrayStructure(TypeFloat64), WTFMove(buffer), offset, length); 134 case kJSTypedArrayTypeBigInt64Array: 135 return JSBigInt64Array::create(globalObject, globalObject->typedArrayStructure(TypeBigInt64), WTFMove(buffer), offset, length); 136 case kJSTypedArrayTypeBigUint64Array: 137 return JSBigUint64Array::create(globalObject, globalObject->typedArrayStructure(TypeBigUint64), WTFMove(buffer), offset, length); 126 138 case kJSTypedArrayTypeArrayBuffer: 127 139 case kJSTypedArrayTypeNone: -
trunk/Source/JavaScriptCore/API/JSValueRef.h
r246265 r272170 67 67 @constant kJSTypedArrayTypeFloat32Array Float32Array 68 68 @constant kJSTypedArrayTypeFloat64Array Float64Array 69 @constant kJSTypedArrayTypeBigInt64Array BigInt64Array 70 @constant kJSTypedArrayTypeBigUint64Array BigUint64Array 69 71 @constant kJSTypedArrayTypeArrayBuffer ArrayBuffer 70 72 @constant kJSTypedArrayTypeNone Not a Typed Array … … 83 85 kJSTypedArrayTypeArrayBuffer, 84 86 kJSTypedArrayTypeNone, 87 kJSTypedArrayTypeBigInt64Array, 88 kJSTypedArrayTypeBigUint64Array, 85 89 } JSTypedArrayType JSC_API_AVAILABLE(macos(10.12), ios(10.0)); 86 90 -
trunk/Source/JavaScriptCore/API/tests/TypedArrayCTest.cpp
r250005 r272170 50 50 }; 51 51 52 static const unsigned byteSizes[ kJSTypedArrayTypeArrayBuffer] =52 static const unsigned byteSizes[] = 53 53 { 54 54 1, // kJSTypedArrayTypeInt8Array … … 61 61 4, // kJSTypedArrayTypeFloat32Array 62 62 8, // kJSTypedArrayTypeFloat64Array 63 0, // kJSTypedArrayTypeArrayBuffer 64 0, // kJSTypedArrayTypeNone 65 8, // kJSTypedArrayTypeBigInt64Array 66 8, // kJSTypedArrayTypeBigUint64Array 63 67 }; 64 68 65 static const char* typeToString[ kJSTypedArrayTypeArrayBuffer] =69 static const char* typeToString[] = 66 70 { 67 71 "kJSTypedArrayTypeInt8Array", … … 74 78 "kJSTypedArrayTypeFloat32Array", 75 79 "kJSTypedArrayTypeFloat64Array", 80 "kJSTypedArrayTypeArrayBuffer", 81 "kJSTypedArrayTypeNone", 82 "kJSTypedArrayTypeBigInt64Array", 83 "kJSTypedArrayTypeBigUint64Array", 76 84 }; 77 85 … … 213 221 { 214 222 int failed = 0; 215 for (unsigned i = 0; i < kJSTypedArrayTypeArrayBuffer; i++) 216 failed = failed || functor(static_cast<JSTypedArrayType>(i)); 223 for (unsigned i = 0; i < kJSTypedArrayTypeArrayBuffer; i++) { 224 if (i != kJSTypedArrayTypeNone && i != kJSTypedArrayTypeArrayBuffer) 225 failed = failed || functor(static_cast<JSTypedArrayType>(i)); 226 } 217 227 return failed; 218 228 } -
trunk/Source/JavaScriptCore/CMakeLists.txt
r271993 r272170 823 823 runtime/BasicBlockLocation.h 824 824 runtime/BatchedTransitionOptimizer.h 825 runtime/BigInt64Array.h 825 826 runtime/BigIntObject.h 826 827 runtime/BigIntPrototype.h 828 runtime/BigUint64Array.h 827 829 runtime/BooleanObject.h 828 830 runtime/BooleanPrototype.h -
trunk/Source/JavaScriptCore/ChangeLog
r272139 r272170 1 2021-01-31 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Implement BigInt64Array and BigUint64Array 4 https://bugs.webkit.org/show_bug.cgi?id=190800 5 6 Reviewed by Ross Kirsling. 7 8 This patch implements BigInt64Array and BigUint64Array. 9 10 1. In this patch, we do not support BigInt64Array/BigUint64Array + Atomics yet. 11 2. We make canGetIndexQuickly false for BigInt64Array and BigUint64Array. And we 12 use generic path for getting values from BigInt64Array and BigUint64Array. We 13 will optimize it in [1] and [2]. But possibly, this does not have super large 14 impact on performance since getting value from BigInt64Array and BigUint64Array 15 are already costly since we always need to allocate BigInt for results. 16 3. DFG / FTL GetByVal etc. are using Array::Generic for BigInt64Array and BigUint64Array. 17 4. But GetArrayLength, CheckArray, byteLength getter etc. are using Array::BigInt64Array / Array::BigUint64Array 18 for optimization. 19 5. Extend ArrayProfile's ArrayMode for BigInt64Array and BigUint64Array so that ArrayProfile 20 can record BigInt64Array and BigUint64Array information. 21 6. Implement DataView#{setBigInt64,setBigUint64,getBigInt64,getBigUint64}. 22 7. Extend JSC APIs to support BigInt64Array and BigUint64Array. 23 24 [1]: https://bugs.webkit.org/show_bug.cgi?id=221181 25 [2]: https://bugs.webkit.org/show_bug.cgi?id=221183 26 27 * API/JSTypedArray.cpp: 28 (toJSTypedArrayType): 29 (toTypedArrayType): 30 (createTypedArray): 31 * API/JSValueRef.h: 32 * API/tests/TypedArrayCTest.cpp: 33 (forEachTypedArrayType): 34 * CMakeLists.txt: 35 * JavaScriptCore.xcodeproj/project.pbxproj: 36 * builtins/BuiltinNames.h: 37 * builtins/TypedArrayPrototype.js: 38 (fill): 39 (map): 40 (filter): 41 * bytecode/ArrayProfile.cpp: 42 (JSC::dumpArrayModes): 43 * bytecode/ArrayProfile.h: 44 * bytecode/ByValInfo.h: 45 (JSC::jitArrayModeForClassInfo): 46 (JSC::jitArrayModePermitsPut): 47 (JSC::typedArrayTypeForJITArrayMode): 48 * bytecode/LinkTimeConstant.h: 49 * bytecode/SpeculatedType.cpp: 50 (JSC::dumpSpeculation): 51 (JSC::speculationToAbbreviatedString): 52 (JSC::speculationFromTypedArrayType): 53 (JSC::typedArrayTypeFromSpeculation): 54 (JSC::speculationFromString): 55 * bytecode/SpeculatedType.h: 56 (JSC::isBigInt64ArraySpeculation): 57 (JSC::isBigUint64ArraySpeculation): 58 (JSC::isDirectArgumentsSpeculation): 59 (JSC::isScopedArgumentsSpeculation): 60 (JSC::isActionableIntMutableArraySpeculation): Deleted. 61 (JSC::isActionableFloatMutableArraySpeculation): Deleted. 62 (JSC::isActionableTypedMutableArraySpeculation): Deleted. 63 (JSC::isActionableMutableArraySpeculation): Deleted. 64 (JSC::isActionableArraySpeculation): Deleted. 65 * dfg/DFGAbstractInterpreterInlines.h: 66 (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): 67 * dfg/DFGArrayMode.cpp: 68 (JSC::DFG::ArrayMode::fromObserved): 69 (JSC::DFG::ArrayMode::refine const): 70 (JSC::DFG::ArrayMode::alreadyChecked const): 71 (JSC::DFG::arrayTypeToString): 72 (JSC::DFG::toTypedArrayType): 73 (JSC::DFG::toArrayType): 74 (JSC::DFG::permitsBoundsCheckLowering): 75 * dfg/DFGArrayMode.h: 76 (JSC::DFG::ArrayMode::supportsSelfLength const): 77 (JSC::DFG::ArrayMode::arrayModesThatPassFiltering const): 78 * dfg/DFGClobberize.h: 79 (JSC::DFG::clobberize): 80 * dfg/DFGFixupPhase.cpp: 81 (JSC::DFG::FixupPhase::fixupNode): 82 * dfg/DFGOperations.cpp: 83 (JSC::DFG::JSC_DEFINE_JIT_OPERATION): 84 * dfg/DFGOperations.h: 85 (JSC::DFG::operationNewTypedArrayWithSizeForType): 86 (JSC::DFG::operationNewTypedArrayWithOneArgumentForType): 87 * dfg/DFGPredictionPropagationPhase.cpp: 88 * dfg/DFGSpeculativeJIT.cpp: 89 (JSC::DFG::SpeculativeJIT::compileHasIndexedProperty): 90 * dfg/DFGSpeculativeJIT64.cpp: 91 (JSC::DFG::SpeculativeJIT::compile): 92 * ftl/FTLLowerDFGToB3.cpp: 93 (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): 94 (JSC::FTL::DFG::LowerDFGToB3::compilePutByVal): 95 * inspector/JSInjectedScriptHost.cpp: 96 (Inspector::JSInjectedScriptHost::subtype): 97 * jit/JITPropertyAccess.cpp: 98 (JSC::JIT::privateCompilePutByVal): 99 * jit/Repatch.cpp: 100 (JSC::tryCacheArrayGetByVal): 101 * llint/LowLevelInterpreter.asm: 102 * runtime/AtomicsObject.cpp: 103 * runtime/AtomicsObject.h: 104 * runtime/BigInt64Array.h: Copied from Source/JavaScriptCore/runtime/JSTypedArrayConstructors.cpp. 105 * runtime/BigUint64Array.h: Copied from Source/JavaScriptCore/runtime/JSTypedArrayConstructors.cpp. 106 * runtime/JSArrayBufferView.cpp: 107 (JSC::elementSize): 108 (JSC::validateTypedArray): 109 * runtime/JSArrayBufferView.h: 110 * runtime/JSBigInt.h: 111 * runtime/JSCell.h: 112 * runtime/JSDataView.h: 113 * runtime/JSDataViewPrototype.cpp: 114 (JSC::getData): 115 (JSC::JSC_DEFINE_HOST_FUNCTION): 116 * runtime/JSGenericTypedArrayView.h: 117 * runtime/JSGenericTypedArrayViewConstructor.h: 118 * runtime/JSGenericTypedArrayViewConstructorInlines.h: 119 (JSC::constructGenericTypedArrayViewWithArguments): 120 * runtime/JSGenericTypedArrayViewInlines.h: 121 (JSC::JSGenericTypedArrayView<Adaptor>::setWithSpecificType): 122 (JSC::JSGenericTypedArrayView<Adaptor>::set): 123 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlotByIndex): 124 * runtime/JSGenericTypedArrayViewPrototypeFunctions.h: 125 (JSC::genericTypedArrayViewProtoFuncJoin): 126 (JSC::genericTypedArrayViewProtoFuncSlice): 127 (JSC::genericTypedArrayViewPrivateFuncSubarrayCreate): 128 * runtime/JSGlobalObject.cpp: 129 (JSC::JSGlobalObject::init): 130 * runtime/JSGlobalObjectFunctions.cpp: 131 (JSC::JSC_DEFINE_HOST_FUNCTION): 132 * runtime/JSGlobalObjectFunctions.h: 133 * runtime/JSType.cpp: 134 (WTF::printInternal): 135 * runtime/JSType.h: 136 * runtime/JSTypedArrayConstructors.cpp: 137 * runtime/JSTypedArrayConstructors.h: 138 * runtime/JSTypedArrayPrototypes.cpp: 139 * runtime/JSTypedArrayPrototypes.h: 140 * runtime/JSTypedArrayViewPrototype.cpp: 141 (JSC::JSC_DEFINE_HOST_FUNCTION): 142 * runtime/JSTypedArrayViewPrototype.h: 143 * runtime/JSTypedArrays.cpp: 144 * runtime/JSTypedArrays.h: 145 * runtime/ToNativeFromValue.h: 146 (JSC::toNativeFromValue): 147 (JSC::toNativeFromValueWithoutCoercion): 148 * runtime/TypedArrayAdaptors.h: 149 (JSC::IntegralTypedArrayAdaptor::toJSValue): 150 (JSC::FloatTypedArrayAdaptor::toJSValue): 151 (JSC::BigIntTypedArrayAdaptor::toJSValue): 152 (JSC::BigIntTypedArrayAdaptor::toNativeFromInt32): 153 (JSC::BigIntTypedArrayAdaptor::toNativeFromUint32): 154 (JSC::BigIntTypedArrayAdaptor::toNativeFromDouble): 155 (JSC::BigIntTypedArrayAdaptor::convertTo): 156 (JSC::Uint8ClampedAdaptor::toJSValue): 157 (JSC::IntegralTypedArrayAdaptor::toDouble): Deleted. 158 (JSC::FloatTypedArrayAdaptor::toDouble): Deleted. 159 (JSC::Uint8ClampedAdaptor::toDouble): Deleted. 160 * runtime/TypedArrayType.cpp: 161 (JSC::constructorClassInfoForType): 162 (WTF::printInternal): 163 * runtime/TypedArrayType.h: 164 (JSC::isBigIntTypedView): 165 (JSC::logElementSize): 166 (JSC::isBigInt): 167 (JSC::isSigned): 168 (JSC::contentType): 169 * runtime/TypedArrays.h: 170 * runtime/VM.cpp: 171 * runtime/VM.h: 172 1 173 2021-02-01 Yusuke Suzuki <ysuzuki@apple.com> 2 174 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r271993 r272170 1849 1849 E35CA1541DBC3A5C00F83516 /* DOMJITHeapRange.h in Headers */ = {isa = PBXBuildFile; fileRef = E35CA1521DBC3A5600F83516 /* DOMJITHeapRange.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1850 1850 E35CA1561DBC3A5F00F83516 /* DOMJITAbstractHeap.h in Headers */ = {isa = PBXBuildFile; fileRef = E35CA1501DBC3A5600F83516 /* DOMJITAbstractHeap.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1851 E35E89FD25C50F870071EE1E /* BigInt64Array.h in Headers */ = {isa = PBXBuildFile; fileRef = E35E89FB25C50F860071EE1E /* BigInt64Array.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1852 E35E89FE25C50F870071EE1E /* BigUint64Array.h in Headers */ = {isa = PBXBuildFile; fileRef = E35E89FC25C50F870071EE1E /* BigUint64Array.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1851 1853 E3637EE9236E56B00096BD0A /* LinkTimeConstant.h in Headers */ = {isa = PBXBuildFile; fileRef = E3637EE7236E56B00096BD0A /* LinkTimeConstant.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1852 1854 E365F33A24AA623900C991B2 /* IntlDisplayNamesConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E365F33924AA621200C991B2 /* IntlDisplayNamesConstructor.lut.h */; }; … … 5062 5064 E35CA1511DBC3A5600F83516 /* DOMJITHeapRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMJITHeapRange.cpp; sourceTree = "<group>"; }; 5063 5065 E35CA1521DBC3A5600F83516 /* DOMJITHeapRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITHeapRange.h; sourceTree = "<group>"; }; 5066 E35E89FB25C50F860071EE1E /* BigInt64Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BigInt64Array.h; sourceTree = "<group>"; }; 5067 E35E89FC25C50F870071EE1E /* BigUint64Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BigUint64Array.h; sourceTree = "<group>"; }; 5064 5068 E3637EE7236E56B00096BD0A /* LinkTimeConstant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkTimeConstant.h; sourceTree = "<group>"; }; 5065 5069 E3637EE8236E56B00096BD0A /* LinkTimeConstant.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LinkTimeConstant.cpp; sourceTree = "<group>"; }; … … 7137 7141 52678F8D1A031009006A306D /* BasicBlockLocation.h */, 7138 7142 147B83AA0E6DB8C9004775A4 /* BatchedTransitionOptimizer.h */, 7143 E35E89FB25C50F860071EE1E /* BigInt64Array.h */, 7139 7144 86976E581FA3756D00E7C4E1 /* BigIntConstructor.cpp */, 7140 7145 86976E571FA3754000E7C4E1 /* BigIntConstructor.h */, … … 7144 7149 86976E5B1FA375A800E7C4E1 /* BigIntPrototype.cpp */, 7145 7150 86976E5A1FA3758A00E7C4E1 /* BigIntPrototype.h */, 7151 E35E89FC25C50F870071EE1E /* BigUint64Array.h */, 7146 7152 BC7952320E15EB5600A898AB /* BooleanConstructor.cpp */, 7147 7153 BC7952330E15EB5600A898AB /* BooleanConstructor.h */, … … 9256 9262 52678F8F1A031009006A306D /* BasicBlockLocation.h in Headers */, 9257 9263 147B83AC0E6DB8C9004775A4 /* BatchedTransitionOptimizer.h in Headers */, 9264 E35E89FD25C50F870071EE1E /* BigInt64Array.h in Headers */, 9258 9265 86976E5F1FA3E8BC00E7C4E1 /* BigIntConstructor.h in Headers */, 9259 9266 866739D213BFDE710023D87C /* BigInteger.h in Headers */, 9260 9267 861816771FB7924200ECC4EC /* BigIntObject.h in Headers */, 9261 9268 86976E5E1FA3E8B600E7C4E1 /* BigIntPrototype.h in Headers */, 9269 E35E89FE25C50F870071EE1E /* BigUint64Array.h in Headers */, 9262 9270 0F64B2721A784BAF006E4E66 /* BinarySwitch.h in Headers */, 9263 9271 C2B916C214DA014E00CBAC86 /* BlockDirectory.h in Headers */, -
trunk/Source/JavaScriptCore/builtins/BuiltinNames.h
r271942 r272170 71 71 macro(throwTypeErrorFunction) \ 72 72 macro(typedArrayLength) \ 73 macro(typedArrayContentType) \ 73 74 macro(typedArraySort) \ 74 75 macro(typedArrayGetOriginalConstructor) \ … … 99 100 macro(Float32Array) \ 100 101 macro(Float64Array) \ 102 macro(BigInt64Array) \ 103 macro(BigUint64Array) \ 101 104 macro(exec) \ 102 105 macro(generator) \ … … 174 177 macro(instanceFieldInitializer) \ 175 178 macro(hasOwnPropertyFunction) \ 176 macro(createPrivateSymbol) 179 macro(createPrivateSymbol) \ 180 macro(toBigInt) \ 181 macro(isBigIntTypedArrayView) 177 182 178 183 namespace Symbols { -
trunk/Source/JavaScriptCore/builtins/TypedArrayPrototype.js
r269531 r272170 92 92 var length = @typedArrayLength(this); 93 93 94 var number = @toNumber(value); 94 if (@isBigIntTypedArrayView(this)) 95 var number = @toBigInt(value); 96 else 97 var number = @toNumber(value); 95 98 96 99 var start = @typedArrayClampArgumentToStartOrEnd(@argument(1), length, 0); … … 336 339 if (@typedArrayLength(result) < length) 337 340 @throwTypeError("TypedArray.prototype.map constructed typed array of insufficient length"); 341 if (@typedArrayContentType(this) !== @typedArrayContentType(result)) 342 @throwTypeError("TypedArray.prototype.map constructed typed array of different content type from |this|"); 338 343 339 344 for (var i = 0; i < length; i++) { … … 367 372 if (@typedArrayLength(result) < length) 368 373 @throwTypeError("TypedArray.prototype.filter constructed typed array of insufficient length"); 374 if (@typedArrayContentType(this) !== @typedArrayContentType(result)) 375 @throwTypeError("TypedArray.prototype.filter constructed typed array of different content type from |this|"); 369 376 370 377 for (var i = 0; i < length; i++) -
trunk/Source/JavaScriptCore/bytecode/ArrayProfile.cpp
r261895 r272170 45 45 Float32ArrayMode, 46 46 Float64ArrayMode, 47 BigInt64ArrayMode, 48 BigUint64ArrayMode, 47 49 }; 48 50 … … 111 113 if (arrayModes & Float64ArrayMode) 112 114 out.print(comma, "Float64ArrayMode"); 115 if (arrayModes & BigInt64ArrayMode) 116 out.print(comma, "BigInt64ArrayMode"); 117 if (arrayModes & BigUint64ArrayMode) 118 out.print(comma, "BigUint64ArrayMode"); 113 119 } 114 120 -
trunk/Source/JavaScriptCore/bytecode/ArrayProfile.h
r260323 r272170 48 48 const ArrayModes CopyOnWriteArrayWithContiguousArrayMode = 1 << CopyOnWriteArrayWithContiguous; 49 49 50 const ArrayModes Int8ArrayMode = 1 << 16; 51 const ArrayModes Int16ArrayMode = 1 << 17; 52 const ArrayModes Int32ArrayMode = 1 << 18; 53 const ArrayModes Uint8ArrayMode = 1 << 19; 54 const ArrayModes Uint8ClampedArrayMode = 1 << 20; // 21 - 25 are used for CoW arrays. 55 const ArrayModes Uint16ArrayMode = 1 << 26; 56 const ArrayModes Uint32ArrayMode = 1 << 27; 57 const ArrayModes Float32ArrayMode = 1 << 28; 58 const ArrayModes Float64ArrayMode = 1 << 29; 50 const ArrayModes Int8ArrayMode = 1U << 16; 51 const ArrayModes Int16ArrayMode = 1U << 17; 52 const ArrayModes Int32ArrayMode = 1U << 18; 53 const ArrayModes Uint8ArrayMode = 1U << 19; 54 const ArrayModes Uint8ClampedArrayMode = 1U << 20; // 21 - 25 are used for CoW arrays. 55 const ArrayModes Uint16ArrayMode = 1U << 26; 56 const ArrayModes Uint32ArrayMode = 1U << 27; 57 const ArrayModes Float32ArrayMode = 1U << 28; 58 const ArrayModes Float64ArrayMode = 1U << 29; 59 const ArrayModes BigInt64ArrayMode = 1U << 30; 60 const ArrayModes BigUint64ArrayMode = 1U << 31; 59 61 60 62 JS_EXPORT_PRIVATE extern const ArrayModes typedArrayModes[NumberOfTypedArrayTypesExcludingDataView]; … … 75 77 | Float32ArrayMode \ 76 78 | Float64ArrayMode \ 79 | BigInt64ArrayMode \ 80 | BigUint64ArrayMode \ 77 81 ) 78 82 -
trunk/Source/JavaScriptCore/bytecode/ByValInfo.h
r266359 r272170 57 57 JITUint32Array, 58 58 JITFloat32Array, 59 JITFloat64Array 59 JITFloat64Array, 60 JITBigInt64Array, 61 JITBigUint64Array, 60 62 }; 61 63 … … 147 149 case TypeFloat64: 148 150 return JITFloat64Array; 151 case TypeBigInt64: 152 return JITBigInt64Array; 153 case TypeBigUint64: 154 return JITBigUint64Array; 149 155 default: 150 156 CRASH(); … … 158 164 case JITDirectArguments: 159 165 case JITScopedArguments: 166 // FIXME: Optimize BigInt64Array / BigUint64Array in IC 167 // https://bugs.webkit.org/show_bug.cgi?id=221183 168 case JITBigInt64Array: 169 case JITBigUint64Array: 160 170 // We could support put_by_val on these at some point, but it's just not that profitable 161 171 // at the moment. … … 207 217 case JITFloat64Array: 208 218 return TypeFloat64; 219 case JITBigInt64Array: 220 return TypeBigInt64; 221 case JITBigUint64Array: 222 return TypeBigUint64; 209 223 default: 210 224 CRASH(); -
trunk/Source/JavaScriptCore/bytecode/LinkTimeConstant.h
r271942 r272170 51 51 v(AggregateError, nullptr) \ 52 52 v(typedArrayLength, nullptr) \ 53 v(typedArrayContentType, nullptr) \ 53 54 v(typedArrayGetOriginalConstructor, nullptr) \ 54 55 v(typedArraySort, nullptr) \ … … 111 112 v(hasOwnPropertyFunction, nullptr) \ 112 113 v(createPrivateSymbol, nullptr) \ 114 v(toBigInt, nullptr) \ 115 v(isBigIntTypedArrayView, nullptr) \ 113 116 114 117 -
trunk/Source/JavaScriptCore/bytecode/SpeculatedType.cpp
r267221 r272170 149 149 else 150 150 isTop = false; 151 151 152 if (value & SpecBigInt64Array) 153 strOut.print("BigInt64Array"); 154 else 155 isTop = false; 156 157 if (value & SpecBigUint64Array) 158 strOut.print("BigUint64Array"); 159 else 160 isTop = false; 161 152 162 if (value & SpecFunction) 153 163 strOut.print("Function"); … … 360 370 if (isFloat64ArraySpeculation(prediction)) 361 371 return "<Float64array>"; 372 if (isBigInt64ArraySpeculation(prediction)) 373 return "<BigInt64array>"; 374 if (isBigUint64ArraySpeculation(prediction)) 375 return "<BigUint64array>"; 362 376 if (isDirectArgumentsSpeculation(prediction)) 363 377 return "<DirectArguments>"; … … 425 439 case TypeFloat64: 426 440 return SpecFloat64Array; 441 case TypeBigInt64: 442 return SpecBigInt64Array; 443 case TypeBigUint64: 444 return SpecBigUint64Array; 427 445 case NotTypedArray: 428 446 case TypeDataView: … … 657 675 if (isFloat64ArraySpeculation(type)) 658 676 return TypeFloat64; 677 678 if (isBigInt64ArraySpeculation(type)) 679 return TypeBigInt64; 680 681 if (isBigUint64ArraySpeculation(type)) 682 return TypeBigUint64; 659 683 660 684 return NotTypedArray; … … 903 927 if (!strncmp(speculation, "SpecFloat64Array", strlen("SpecFloat64Array"))) 904 928 return SpecFloat64Array; 929 if (!strncmp(speculation, "SpecBigInt64Array", strlen("SpecBigInt64Array"))) 930 return SpecBigInt64Array; 931 if (!strncmp(speculation, "SpecBigUint64Array", strlen("SpecBigUint64Array"))) 932 return SpecBigUint64Array; 905 933 if (!strncmp(speculation, "SpecTypedArrayView", strlen("SpecTypedArrayView"))) 906 934 return SpecTypedArrayView; -
trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h
r262252 r272170 52 52 static constexpr SpeculatedType SpecUint16Array = 1ull << 9; // It's definitely an Uint16Array or one of its subclasses. 53 53 static constexpr SpeculatedType SpecUint32Array = 1ull << 10; // It's definitely an Uint32Array or one of its subclasses. 54 static constexpr SpeculatedType SpecFloat32Array = 1ull << 11; // It's definitely an Uint16Array or one of its subclasses. 55 static constexpr SpeculatedType SpecFloat64Array = 1ull << 12; // It's definitely an Uint16Array or one of its subclasses. 56 static constexpr SpeculatedType SpecTypedArrayView = SpecInt8Array | SpecInt16Array | SpecInt32Array | SpecUint8Array | SpecUint8ClampedArray | SpecUint16Array | SpecUint32Array | SpecFloat32Array | SpecFloat64Array; 57 static constexpr SpeculatedType SpecDirectArguments = 1ull << 13; // It's definitely a DirectArguments object. 58 static constexpr SpeculatedType SpecScopedArguments = 1ull << 14; // It's definitely a ScopedArguments object. 59 static constexpr SpeculatedType SpecStringObject = 1ull << 15; // It's definitely a StringObject. 60 static constexpr SpeculatedType SpecRegExpObject = 1ull << 16; // It's definitely a RegExpObject (and not any subclass of RegExpObject). 61 static constexpr SpeculatedType SpecDateObject = 1ull << 17; // It's definitely a Date object or one of its subclasses. 62 static constexpr SpeculatedType SpecPromiseObject = 1ull << 18; // It's definitely a Promise object or one of its subclasses. 63 static constexpr SpeculatedType SpecMapObject = 1ull << 19; // It's definitely a Map object or one of its subclasses. 64 static constexpr SpeculatedType SpecSetObject = 1ull << 20; // It's definitely a Set object or one of its subclasses. 65 static constexpr SpeculatedType SpecWeakMapObject = 1ull << 21; // It's definitely a WeakMap object or one of its subclasses. 66 static constexpr SpeculatedType SpecWeakSetObject = 1ull << 22; // It's definitely a WeakSet object or one of its subclasses. 67 static constexpr SpeculatedType SpecProxyObject = 1ull << 23; // It's definitely a Proxy object or one of its subclasses. 68 static constexpr SpeculatedType SpecDerivedArray = 1ull << 24; // It's definitely a DerivedArray object. 69 static constexpr SpeculatedType SpecObjectOther = 1ull << 25; // It's definitely an object but not JSFinalObject, JSArray, or JSFunction. 70 static constexpr SpeculatedType SpecStringIdent = 1ull << 26; // It's definitely a JSString, and it's an identifier. 71 static constexpr SpeculatedType SpecStringVar = 1ull << 27; // It's definitely a JSString, and it's not an identifier. 54 static constexpr SpeculatedType SpecFloat32Array = 1ull << 11; // It's definitely an Float32Array or one of its subclasses. 55 static constexpr SpeculatedType SpecFloat64Array = 1ull << 12; // It's definitely an Float64Array or one of its subclasses. 56 static constexpr SpeculatedType SpecBigInt64Array = 1ull << 13; // It's definitely an BigInt64Array or one of its subclasses. 57 static constexpr SpeculatedType SpecBigUint64Array = 1ull << 14; // It's definitely an BigUint64Array or one of its subclasses. 58 static constexpr SpeculatedType SpecTypedArrayView = SpecInt8Array | SpecInt16Array | SpecInt32Array | SpecUint8Array | SpecUint8ClampedArray | SpecUint16Array | SpecUint32Array | SpecFloat32Array | SpecFloat64Array | SpecBigInt64Array | SpecBigUint64Array; 59 static constexpr SpeculatedType SpecDirectArguments = 1ull << 15; // It's definitely a DirectArguments object. 60 static constexpr SpeculatedType SpecScopedArguments = 1ull << 16; // It's definitely a ScopedArguments object. 61 static constexpr SpeculatedType SpecStringObject = 1ull << 17; // It's definitely a StringObject. 62 static constexpr SpeculatedType SpecRegExpObject = 1ull << 18; // It's definitely a RegExpObject (and not any subclass of RegExpObject). 63 static constexpr SpeculatedType SpecDateObject = 1ull << 19; // It's definitely a Date object or one of its subclasses. 64 static constexpr SpeculatedType SpecPromiseObject = 1ull << 20; // It's definitely a Promise object or one of its subclasses. 65 static constexpr SpeculatedType SpecMapObject = 1ull << 21; // It's definitely a Map object or one of its subclasses. 66 static constexpr SpeculatedType SpecSetObject = 1ull << 22; // It's definitely a Set object or one of its subclasses. 67 static constexpr SpeculatedType SpecWeakMapObject = 1ull << 23; // It's definitely a WeakMap object or one of its subclasses. 68 static constexpr SpeculatedType SpecWeakSetObject = 1ull << 24; // It's definitely a WeakSet object or one of its subclasses. 69 static constexpr SpeculatedType SpecProxyObject = 1ull << 25; // It's definitely a Proxy object or one of its subclasses. 70 static constexpr SpeculatedType SpecDerivedArray = 1ull << 26; // It's definitely a DerivedArray object. 71 static constexpr SpeculatedType SpecObjectOther = 1ull << 27; // It's definitely an object but not JSFinalObject, JSArray, or JSFunction. 72 static constexpr SpeculatedType SpecStringIdent = 1ull << 28; // It's definitely a JSString, and it's an identifier. 73 static constexpr SpeculatedType SpecStringVar = 1ull << 29; // It's definitely a JSString, and it's not an identifier. 72 74 static constexpr SpeculatedType SpecString = SpecStringIdent | SpecStringVar; // It's definitely a JSString. 73 static constexpr SpeculatedType SpecSymbol = 1ull << 28; // It's definitely a Symbol.74 static constexpr SpeculatedType SpecCellOther = 1ull << 29; // It's definitely a JSCell but not a subclass of JSObject and definitely not a JSString, BigInt, or Symbol.75 static constexpr SpeculatedType SpecBoolInt32 = 1ull << 3 0; // It's definitely an Int32 with value 0 or 1.76 static constexpr SpeculatedType SpecNonBoolInt32 = 1ull << 3 1; // It's definitely an Int32 with value other than 0 or 1.75 static constexpr SpeculatedType SpecSymbol = 1ull << 30; // It's definitely a Symbol. 76 static constexpr SpeculatedType SpecCellOther = 1ull << 31; // It's definitely a JSCell but not a subclass of JSObject and definitely not a JSString, BigInt, or Symbol. 77 static constexpr SpeculatedType SpecBoolInt32 = 1ull << 32; // It's definitely an Int32 with value 0 or 1. 78 static constexpr SpeculatedType SpecNonBoolInt32 = 1ull << 33; // It's definitely an Int32 with value other than 0 or 1. 77 79 static constexpr SpeculatedType SpecInt32Only = SpecBoolInt32 | SpecNonBoolInt32; // It's definitely an Int32. 78 80 79 static constexpr SpeculatedType SpecInt32AsInt52 = 1ull << 3 2; // It's an Int52 and it can fit in an int32.80 static constexpr SpeculatedType SpecNonInt32AsInt52 = 1ull << 3 3; // It's an Int52 and it can't fit in an int32.81 static constexpr SpeculatedType SpecInt32AsInt52 = 1ull << 34; // It's an Int52 and it can fit in an int32. 82 static constexpr SpeculatedType SpecNonInt32AsInt52 = 1ull << 35; // It's an Int52 and it can't fit in an int32. 81 83 static constexpr SpeculatedType SpecInt52Any = SpecInt32AsInt52 | SpecNonInt32AsInt52; // It's any kind of Int52. 82 84 83 static constexpr SpeculatedType SpecAnyIntAsDouble = 1ull << 3 4; // It's definitely an Int52 and it's inside a double.84 static constexpr SpeculatedType SpecNonIntAsDouble = 1ull << 3 5; // It's definitely not an Int52 but it's a real number and it's a double.85 static constexpr SpeculatedType SpecAnyIntAsDouble = 1ull << 36; // It's definitely an Int52 and it's inside a double. 86 static constexpr SpeculatedType SpecNonIntAsDouble = 1ull << 37; // It's definitely not an Int52 but it's a real number and it's a double. 85 87 static constexpr SpeculatedType SpecDoubleReal = SpecNonIntAsDouble | SpecAnyIntAsDouble; // It's definitely a non-NaN double. 86 static constexpr SpeculatedType SpecDoublePureNaN = 1ull << 3 6; // It's definitely a NaN that is safe to tag (i.e. pure).87 static constexpr SpeculatedType SpecDoubleImpureNaN = 1ull << 3 7; // It's definitely a NaN that is unsafe to tag (i.e. impure).88 static constexpr SpeculatedType SpecDoublePureNaN = 1ull << 38; // It's definitely a NaN that is safe to tag (i.e. pure). 89 static constexpr SpeculatedType SpecDoubleImpureNaN = 1ull << 39; // It's definitely a NaN that is unsafe to tag (i.e. impure). 88 90 static constexpr SpeculatedType SpecDoubleNaN = SpecDoublePureNaN | SpecDoubleImpureNaN; // It's definitely some kind of NaN. 89 91 static constexpr SpeculatedType SpecBytecodeDouble = SpecDoubleReal | SpecDoublePureNaN; // It's either a non-NaN or a NaN double, but it's definitely not impure NaN. … … 95 97 96 98 static constexpr SpeculatedType SpecFullNumber = SpecIntAnyFormat | SpecFullDouble; // It's either an Int32, Int52, or a Double, and the Double can be impure NaN. 97 static constexpr SpeculatedType SpecBoolean = 1ull << 38; // It's definitely a Boolean.98 static constexpr SpeculatedType SpecOther = 1ull << 39; // It's definitely either Null or Undefined.99 static constexpr SpeculatedType SpecBoolean = 1ull << 40; // It's definitely a Boolean. 100 static constexpr SpeculatedType SpecOther = 1ull << 41; // It's definitely either Null or Undefined. 99 101 static constexpr SpeculatedType SpecMisc = SpecBoolean | SpecOther; // It's definitely either a boolean, Null, or Undefined. 100 static constexpr SpeculatedType SpecEmpty = 1ull << 4 0; // It's definitely an empty value marker.101 static constexpr SpeculatedType SpecHeapBigInt = 1ull << 4 1; // It's definitely a BigInt that is allocated on the heap102 static constexpr SpeculatedType SpecBigInt32 = 1ull << 4 2; // It's definitely a small BigInt that is inline the JSValue102 static constexpr SpeculatedType SpecEmpty = 1ull << 42; // It's definitely an empty value marker. 103 static constexpr SpeculatedType SpecHeapBigInt = 1ull << 43; // It's definitely a BigInt that is allocated on the heap 104 static constexpr SpeculatedType SpecBigInt32 = 1ull << 44; // It's definitely a small BigInt that is inline the JSValue 103 105 #if USE(BIGINT32) 104 106 static constexpr SpeculatedType SpecBigInt = SpecBigInt32 | SpecHeapBigInt; … … 107 109 static constexpr SpeculatedType SpecBigInt = SpecHeapBigInt; 108 110 #endif 109 static constexpr SpeculatedType SpecDataViewObject = 1ull << 4 3; // It's definitely a JSDataView.111 static constexpr SpeculatedType SpecDataViewObject = 1ull << 45; // It's definitely a JSDataView. 110 112 static constexpr SpeculatedType SpecPrimitive = SpecString | SpecSymbol | SpecBytecodeNumber | SpecMisc | SpecBigInt; // It's any non-Object JSValue. 111 113 static constexpr SpeculatedType SpecObject = SpecFinalObject | SpecArray | SpecFunction | SpecTypedArrayView | SpecDirectArguments | SpecScopedArguments | SpecStringObject | SpecRegExpObject | SpecDateObject | SpecPromiseObject | SpecMapObject | SpecSetObject | SpecWeakMapObject | SpecWeakSetObject | SpecProxyObject | SpecDerivedArray | SpecObjectOther | SpecDataViewObject; // Bitmask used for testing for any kind of object prediction. … … 288 290 } 289 291 292 inline bool isBigInt64ArraySpeculation(SpeculatedType value) 293 { 294 return value == SpecBigInt64Array; 295 } 296 297 inline bool isBigUint64ArraySpeculation(SpeculatedType value) 298 { 299 return value == SpecBigUint64Array; 300 } 301 290 302 inline bool isDirectArgumentsSpeculation(SpeculatedType value) 291 303 { … … 296 308 { 297 309 return value == SpecScopedArguments; 298 }299 300 inline bool isActionableIntMutableArraySpeculation(SpeculatedType value)301 {302 return isInt8ArraySpeculation(value)303 || isInt16ArraySpeculation(value)304 || isInt32ArraySpeculation(value)305 || isUint8ArraySpeculation(value)306 || isUint8ClampedArraySpeculation(value)307 || isUint16ArraySpeculation(value)308 || isUint32ArraySpeculation(value);309 }310 311 inline bool isActionableFloatMutableArraySpeculation(SpeculatedType value)312 {313 return isFloat32ArraySpeculation(value)314 || isFloat64ArraySpeculation(value);315 }316 317 inline bool isActionableTypedMutableArraySpeculation(SpeculatedType value)318 {319 return isActionableIntMutableArraySpeculation(value)320 || isActionableFloatMutableArraySpeculation(value);321 }322 323 inline bool isActionableMutableArraySpeculation(SpeculatedType value)324 {325 return isArraySpeculation(value)326 || isActionableTypedMutableArraySpeculation(value);327 }328 329 inline bool isActionableArraySpeculation(SpeculatedType value)330 {331 return isStringSpeculation(value)332 || isDirectArgumentsSpeculation(value)333 || isScopedArgumentsSpeculation(value)334 || isActionableMutableArraySpeculation(value);335 310 } 336 311 -
trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
r271298 r272170 3648 3648 filter(node->child1(), SpecFloat64Array | admittedTypes); 3649 3649 break; 3650 case Array::BigInt64Array: 3651 filter(node->child1(), SpecBigInt64Array | admittedTypes); 3652 break; 3653 case Array::BigUint64Array: 3654 filter(node->child1(), SpecBigUint64Array | admittedTypes); 3655 break; 3650 3656 case Array::AnyTypedArray: 3651 3657 filter(node->child1(), SpecTypedArrayView | admittedTypes); -
trunk/Source/JavaScriptCore/dfg/DFGArrayMode.cpp
r265775 r272170 146 146 case Float64ArrayMode: 147 147 return ArrayMode(Array::Float64Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 148 case BigInt64ArrayMode: 149 return ArrayMode(Array::BigInt64Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 150 case BigUint64ArrayMode: 151 return ArrayMode(Array::BigUint64Array, nonArray, Array::AsIs, action).withProfile(locker, profile, makeSafe); 148 152 149 153 default: … … 289 293 case Array::Float32Array: 290 294 case Array::Float64Array: 295 case Array::BigInt64Array: 296 case Array::BigUint64Array: 291 297 if (node->op() == PutByVal) { 292 298 if (graph.hasExitSite(node->origin.semantic, OutOfBounds) || !isInBounds()) … … 294 300 } 295 301 return typedArrayResult(withSpeculation(Array::InBounds)); 302 296 303 case Array::Unprofiled: 297 304 case Array::SelectUsingPredictions: { … … 354 361 if (isFloat64ArraySpeculation(base)) 355 362 return typedArrayResult(result.withType(Array::Float64Array)); 363 364 if (isBigInt64ArraySpeculation(base)) 365 return typedArrayResult(result.withType(Array::BigInt64Array)); 366 367 if (isBigUint64ArraySpeculation(base)) 368 return typedArrayResult(result.withType(Array::BigUint64Array)); 356 369 357 370 if (type() == Array::Unprofiled) … … 605 618 case Array::Float64Array: 606 619 return speculationChecked(value.m_type, SpecFloat64Array); 620 621 case Array::BigInt64Array: 622 return speculationChecked(value.m_type, SpecBigInt64Array); 623 624 case Array::BigUint64Array: 625 return speculationChecked(value.m_type, SpecBigUint64Array); 607 626 608 627 case Array::AnyTypedArray: … … 680 699 case Array::Float64Array: 681 700 return "Float64Array"; 701 case Array::BigInt64Array: 702 return "BigInt64Array"; 703 case Array::BigUint64Array: 704 return "BigUint64Array"; 682 705 case Array::AnyTypedArray: 683 706 return "AnyTypedArray"; … … 782 805 case Array::Float64Array: 783 806 return TypeFloat64; 807 case Array::BigInt64Array: 808 return TypeBigInt64; 809 case Array::BigUint64Array: 810 return TypeBigUint64; 784 811 case Array::AnyTypedArray: 785 812 RELEASE_ASSERT_NOT_REACHED(); … … 811 838 case TypeFloat64: 812 839 return Array::Float64Array; 840 case TypeBigInt64: 841 return Array::BigInt64Array; 842 case TypeBigUint64: 843 return Array::BigUint64Array; 813 844 default: 814 845 return Array::Generic; … … 846 877 case Array::Float32Array: 847 878 case Array::Float64Array: 879 case Array::BigInt64Array: 880 case Array::BigUint64Array: 848 881 case Array::AnyTypedArray: 849 882 return true; -
trunk/Source/JavaScriptCore/dfg/DFGArrayMode.h
r271573 r272170 77 77 Float32Array, 78 78 Float64Array, 79 BigInt64Array, 80 BigUint64Array, 79 81 AnyTypedArray 80 82 }; … … 394 396 case Array::Float32Array: 395 397 case Array::Float64Array: 398 case Array::BigInt64Array: 399 case Array::BigUint64Array: 396 400 return false; 397 401 case Array::Int32: … … 478 482 case Array::Float64Array: 479 483 return Float64ArrayMode; 484 case Array::BigInt64Array: 485 return BigInt64ArrayMode; 486 case Array::BigUint64Array: 487 return BigUint64ArrayMode; 480 488 case Array::AnyTypedArray: 481 489 return ALL_TYPED_ARRAY_MODES; -
trunk/Source/JavaScriptCore/dfg/DFGClobberize.h
r270874 r272170 915 915 916 916 case Array::Generic: 917 case Array::BigInt64Array: 918 case Array::BigUint64Array: 917 919 clobberTop(); 918 920 return; … … 1052 1054 1053 1055 case Array::Generic: 1056 case Array::BigInt64Array: 1057 case Array::BigUint64Array: 1054 1058 clobberTop(); 1055 1059 return; -
trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
r271573 r272170 1053 1053 m_graph.varArgChild(node, 1)->prediction(), 1054 1054 SpecNone)); 1055 1055 1056 switch (node->arrayMode().type()) { 1057 case Array::BigInt64Array: 1058 case Array::BigUint64Array: 1059 // Make it Array::Generic. 1060 // FIXME: Add BigInt64Array / BigUint64Array support. 1061 // https://bugs.webkit.org/show_bug.cgi?id=221172 1062 node->setArrayMode(ArrayMode(Array::Generic, node->arrayMode().action())); 1063 break; 1064 default: 1065 break; 1066 } 1067 1056 1068 blessArrayOperation(m_graph.varArgChild(node, 0), m_graph.varArgChild(node, 1), m_graph.varArgChild(node, 2)); 1057 1069 … … 1224 1236 child2->prediction(), 1225 1237 child3->prediction())); 1238 1239 switch (node->arrayMode().type()) { 1240 case Array::BigInt64Array: 1241 case Array::BigUint64Array: 1242 // Make it Array::Generic. 1243 // FIXME: Add BigInt64Array / BigUint64Array support. 1244 // https://bugs.webkit.org/show_bug.cgi?id=221172 1245 node->setArrayMode(ArrayMode(Array::Generic, node->arrayMode().action())); 1246 break; 1247 default: 1248 break; 1249 } 1226 1250 1227 1251 blessArrayOperation(child1, child2, m_graph.varArgChild(node, 3)); … … 1372 1396 default: { 1373 1397 // Make it Array::Generic. 1398 // FIXME: Add BigInt64Array / BigUint64Array support. 1399 // https://bugs.webkit.org/show_bug.cgi?id=221172 1374 1400 node->setArrayMode(ArrayMode(Array::Generic, node->arrayMode().action())); 1375 1401 break; -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r271987 r272170 1943 1943 } 1944 1944 1945 JSC_DEFINE_JIT_OPERATION(operationNewBigInt64ArrayWithSize, char*, (JSGlobalObject* globalObject, Structure* structure, int32_t length, char* vector)) 1946 { 1947 VM& vm = globalObject->vm(); 1948 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 1949 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 1950 return newTypedArrayWithSize<JSBigInt64Array>(globalObject, vm, structure, length, vector); 1951 } 1952 1953 JSC_DEFINE_JIT_OPERATION(operationNewBigInt64ArrayWithOneArgument, char*, (JSGlobalObject* globalObject, Structure* structure, EncodedJSValue encodedValue)) 1954 { 1955 VM& vm = globalObject->vm(); 1956 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 1957 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 1958 return reinterpret_cast<char*>(constructGenericTypedArrayViewWithArguments<JSBigInt64Array>(globalObject, structure, encodedValue, 0, WTF::nullopt)); 1959 } 1960 1961 JSC_DEFINE_JIT_OPERATION(operationNewBigUint64ArrayWithSize, char*, (JSGlobalObject* globalObject, Structure* structure, int32_t length, char* vector)) 1962 { 1963 VM& vm = globalObject->vm(); 1964 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 1965 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 1966 return newTypedArrayWithSize<JSBigUint64Array>(globalObject, vm, structure, length, vector); 1967 } 1968 1969 JSC_DEFINE_JIT_OPERATION(operationNewBigUint64ArrayWithOneArgument, char*, (JSGlobalObject* globalObject, Structure* structure, EncodedJSValue encodedValue)) 1970 { 1971 VM& vm = globalObject->vm(); 1972 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 1973 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 1974 return reinterpret_cast<char*>(constructGenericTypedArrayViewWithArguments<JSBigUint64Array>(globalObject, structure, encodedValue, 0, WTF::nullopt)); 1975 } 1976 1945 1977 JSC_DEFINE_JIT_OPERATION(operationNewArrayIterator, JSCell*, (VM* vmPointer, Structure* structure)) 1946 1978 { -
trunk/Source/JavaScriptCore/dfg/DFGOperations.h
r270874 r272170 131 131 JSC_DECLARE_JIT_OPERATION(operationNewFloat64ArrayWithSize, char*, (JSGlobalObject*, Structure*, int32_t, char*)); 132 132 JSC_DECLARE_JIT_OPERATION(operationNewFloat64ArrayWithOneArgument, char*, (JSGlobalObject*, Structure*, EncodedJSValue)); 133 JSC_DECLARE_JIT_OPERATION(operationNewBigInt64ArrayWithSize, char*, (JSGlobalObject*, Structure*, int32_t, char*)); 134 JSC_DECLARE_JIT_OPERATION(operationNewBigInt64ArrayWithOneArgument, char*, (JSGlobalObject*, Structure*, EncodedJSValue)); 135 JSC_DECLARE_JIT_OPERATION(operationNewBigUint64ArrayWithSize, char*, (JSGlobalObject*, Structure*, int32_t, char*)); 136 JSC_DECLARE_JIT_OPERATION(operationNewBigUint64ArrayWithOneArgument, char*, (JSGlobalObject*, Structure*, EncodedJSValue)); 133 137 JSC_DECLARE_JIT_OPERATION(operationNewArrayIterator, JSCell*, (VM*, Structure*)); 134 138 JSC_DECLARE_JIT_OPERATION(operationNewMapIterator, JSCell*, (VM*, Structure*)); … … 362 366 case TypeFloat64: 363 367 return operationNewFloat64ArrayWithSize; 368 case TypeBigInt64: 369 return operationNewBigInt64ArrayWithSize; 370 case TypeBigUint64: 371 return operationNewBigUint64ArrayWithSize; 364 372 case NotTypedArray: 365 373 case TypeDataView: … … 391 399 case TypeFloat64: 392 400 return operationNewFloat64ArrayWithOneArgument; 401 case TypeBigInt64: 402 return operationNewBigInt64ArrayWithOneArgument; 403 case TypeBigUint64: 404 return operationNewBigUint64ArrayWithOneArgument; 393 405 case NotTypedArray: 394 406 case TypeDataView: -
trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
r270874 r272170 515 515 case Array::Int32Array: 516 516 changed |= mergePrediction(SpecInt32Only); 517 break; 518 case Array::BigInt64Array: 519 case Array::BigUint64Array: 520 changed |= mergePrediction(SpecBigInt); 517 521 break; 518 522 default: -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r271490 r272170 14382 14382 } 14383 14383 default: { 14384 // FIXME: Optimize TypedArrays in HasIndexedProperty IC 14385 // https://bugs.webkit.org/show_bug.cgi?id=221183 14384 14386 slowCases.append(m_jit.jump()); 14385 14387 break; -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
r271592 r272170 2649 2649 break; 2650 2650 } 2651 case Array::BigInt64Array: 2652 case Array::BigUint64Array: 2651 2653 case Array::Generic: { 2652 2654 if (m_graph.m_slowGetByVal.contains(node)) { … … 2981 2983 DFG_CRASH(m_jit.graph(), node, "Bad array mode type"); 2982 2984 break; 2985 case Array::BigInt64Array: 2986 case Array::BigUint64Array: 2983 2987 case Array::Generic: { 2984 2988 DFG_ASSERT(m_jit.graph(), node, node->op() == PutByVal || node->op() == PutByValDirect, node->op()); … … 3211 3215 case Array::Undecided: 3212 3216 case Array::Unprofiled: 3217 case Array::BigInt64Array: 3218 case Array::BigUint64Array: 3213 3219 RELEASE_ASSERT_NOT_REACHED(); 3214 3220 } -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r271592 r272170 5064 5064 } 5065 5065 5066 case Array::BigInt64Array: 5067 case Array::BigUint64Array: 5066 5068 case Array::Generic: { 5067 5069 if (m_graph.m_slowGetByVal.contains(m_node)) { … … 5359 5361 ArrayMode arrayMode = m_node->arrayMode().modeForPut(); 5360 5362 switch (arrayMode.type()) { 5363 case Array::BigInt64Array: 5364 case Array::BigUint64Array: 5361 5365 case Array::Generic: { 5362 5366 if (child1.useKind() == CellUse) { … … 5648 5652 case Array::Undecided: 5649 5653 case Array::Unprofiled: 5654 case Array::BigInt64Array: 5655 case Array::BigUint64Array: 5650 5656 DFG_CRASH(m_graph, m_node, "Bad array type"); 5651 5657 break; -
trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp
r264736 r272170 229 229 || object->inherits<JSUint32Array>(vm) 230 230 || object->inherits<JSFloat32Array>(vm) 231 || object->inherits<JSFloat64Array>(vm)) 231 || object->inherits<JSFloat64Array>(vm) 232 || object->inherits<JSBigInt64Array>(vm) 233 || object->inherits<JSBigUint64Array>(vm)) 232 234 return jsNontrivialString(vm, "array"_s); 233 235 } -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp
r271279 r272170 1494 1494 if (isInt(type)) 1495 1495 slowCases = emitIntTypedArrayPutByVal(bytecode, badType, type); 1496 else 1496 else { 1497 // FIXME: Optimize BigInt64Array / BigUint64Array in IC 1498 // Currently, BigInt64Array / BigUint64Array never comes here. 1499 // https://bugs.webkit.org/show_bug.cgi?id=221183 1500 ASSERT(isFloat(type)); 1497 1501 slowCases = emitFloatTypedArrayPutByVal(bytecode, badType, type); 1502 } 1498 1503 break; 1499 1504 } -
trunk/Source/JavaScriptCore/jit/Repatch.cpp
r270764 r272170 496 496 accessType = AccessCase::IndexedTypedArrayFloat64Load; 497 497 break; 498 // FIXME: Optimize BigInt64Array / BigUint64Array in IC 499 // https://bugs.webkit.org/show_bug.cgi?id=221183 500 case TypeBigInt64: 501 case TypeBigUint64: 502 return GiveUpOnCache; 498 503 default: 499 504 RELEASE_ASSERT_NOT_REACHED(); -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r270967 r272170 557 557 const FirstTypedArrayType = constexpr FirstTypedArrayType 558 558 const NumberOfTypedArrayTypesExcludingDataView = constexpr NumberOfTypedArrayTypesExcludingDataView 559 const NumberOfTypedArrayTypesExcludingBigIntArraysAndDataView = constexpr NumberOfTypedArrayTypesExcludingBigIntArraysAndDataView 559 560 560 561 # Type flags constants. … … 1234 1235 loadb JSCell::m_type[base], t2 1235 1236 subi FirstTypedArrayType, t2 1236 biaeq t2, NumberOfTypedArrayTypesExcluding DataView, slowPath1237 biaeq t2, NumberOfTypedArrayTypesExcludingBigIntArraysAndDataView, slowPath 1237 1238 1238 1239 # Sweet, now we know that we have a typed array. Do some basic things now. … … 1261 1262 # Float32ArrayType, 1262 1263 # Float64ArrayType, 1264 # 1265 # Yet, we are not supporting BitInt64Array and BigUint64Array. 1263 1266 1264 1267 bia t2, Uint16ArrayType - FirstTypedArrayType, .opGetByValAboveUint16Array -
trunk/Source/JavaScriptCore/runtime/AtomicsObject.cpp
r269531 r272170 128 128 } 129 129 130 static JSArrayBufferView* validateTypedArray(JSGlobalObject* globalObject, JSValue typedArrayValue)131 {132 VM& vm = globalObject->vm();133 auto scope = DECLARE_THROW_SCOPE(vm);134 135 if (!typedArrayValue.isCell()) {136 throwTypeError(globalObject, scope, "Argument needs to be a typed array."_s);137 return nullptr;138 }139 140 JSCell* typedArrayCell = typedArrayValue.asCell();141 if (!isTypedView(typedArrayCell->classInfo(vm)->typedArrayStorageType)) {142 throwTypeError(globalObject, scope, "Argument needs to be a typed array."_s);143 return nullptr;144 }145 146 JSArrayBufferView* typedArray = jsCast<JSArrayBufferView*>(typedArrayCell);147 if (typedArray->isDetached()) {148 throwTypeError(globalObject, scope, "Argument typed array is detached."_s);149 return nullptr;150 }151 return typedArray;152 }153 154 130 enum class TypedArrayOperationMode { Read, Write }; 155 131 template<TypedArrayOperationMode mode> -
trunk/Source/JavaScriptCore/runtime/BigInt64Array.h
r272165 r272170 1 1 /* 2 * Copyright (C) 20 13Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 #include "config.h" 27 #include "JSTypedArrayConstructors.h" 26 #pragma once 28 27 29 #include " JSCInlines.h"28 #include "TypedArrays.h" 30 29 31 namespace JSC { 32 33 #undef MAKE_S_INFO 34 #define MAKE_S_INFO(type) \ 35 template<> const ClassInfo JS##type##Constructor::s_info = {"Function", &JS##type##Constructor::Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JS##type##Constructor)} 36 37 MAKE_S_INFO(Int8Array); 38 MAKE_S_INFO(Int16Array); 39 MAKE_S_INFO(Int32Array); 40 MAKE_S_INFO(Uint8Array); 41 MAKE_S_INFO(Uint8ClampedArray); 42 MAKE_S_INFO(Uint16Array); 43 MAKE_S_INFO(Uint32Array); 44 MAKE_S_INFO(Float32Array); 45 MAKE_S_INFO(Float64Array); 46 MAKE_S_INFO(DataView); 47 48 } // namespace JSC 49 30 using JSC::BigInt64Array; -
trunk/Source/JavaScriptCore/runtime/BigUint64Array.h
r272165 r272170 1 1 /* 2 * Copyright (C) 20 13Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 #include "config.h" 27 #include "JSTypedArrayConstructors.h" 26 #pragma once 28 27 29 #include " JSCInlines.h"28 #include "TypedArrays.h" 30 29 31 namespace JSC { 32 33 #undef MAKE_S_INFO 34 #define MAKE_S_INFO(type) \ 35 template<> const ClassInfo JS##type##Constructor::s_info = {"Function", &JS##type##Constructor::Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JS##type##Constructor)} 36 37 MAKE_S_INFO(Int8Array); 38 MAKE_S_INFO(Int16Array); 39 MAKE_S_INFO(Int32Array); 40 MAKE_S_INFO(Uint8Array); 41 MAKE_S_INFO(Uint8ClampedArray); 42 MAKE_S_INFO(Uint16Array); 43 MAKE_S_INFO(Uint32Array); 44 MAKE_S_INFO(Float32Array); 45 MAKE_S_INFO(Float64Array); 46 MAKE_S_INFO(DataView); 47 48 } // namespace JSC 49 30 using JSC::BigUint64Array; -
trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp
r269832 r272170 244 244 { 245 245 ASSERT(type >= Int8ArrayType && type <= DataViewType); 246 static_assert( Float64ArrayType + 1 == DataViewType);246 static_assert(BigUint64ArrayType + 1 == DataViewType); 247 247 return ElementSizeData[type - Int8ArrayType]; 248 248 } … … 341 341 } 342 342 343 JSArrayBufferView* validateTypedArray(JSGlobalObject* globalObject, JSValue typedArrayValue) 344 { 345 VM& vm = globalObject->vm(); 346 auto scope = DECLARE_THROW_SCOPE(vm); 347 348 if (!typedArrayValue.isCell()) { 349 throwTypeError(globalObject, scope, "Argument needs to be a typed array."_s); 350 return nullptr; 351 } 352 353 JSCell* typedArrayCell = typedArrayValue.asCell(); 354 if (!isTypedView(typedArrayCell->classInfo(vm)->typedArrayStorageType)) { 355 throwTypeError(globalObject, scope, "Argument needs to be a typed array."_s); 356 return nullptr; 357 } 358 359 JSArrayBufferView* typedArray = jsCast<JSArrayBufferView*>(typedArrayCell); 360 if (typedArray->isDetached()) { 361 throwTypeError(globalObject, scope, "Argument typed array is detached."_s); 362 return nullptr; 363 } 364 return typedArray; 365 } 366 343 367 } // namespace JSC 344 368 -
trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.h
r269974 r272170 225 225 }; 226 226 227 JSArrayBufferView* validateTypedArray(JSGlobalObject*, JSValue); 228 227 229 } // namespace JSC 228 230 -
trunk/Source/JavaScriptCore/runtime/JSBigInt.h
r271217 r272170 73 73 static JSBigInt* tryCreateFrom(VM&, int32_t value); 74 74 static JSBigInt* createFrom(JSGlobalObject*, uint32_t value); 75 static JSBigInt* createFrom(JSGlobalObject*, int64_t value);75 JS_EXPORT_PRIVATE static JSBigInt* createFrom(JSGlobalObject*, int64_t value); 76 76 JS_EXPORT_PRIVATE static JSBigInt* createFrom(JSGlobalObject*, uint64_t value); 77 77 static JSBigInt* createFrom(JSGlobalObject*, bool value); … … 98 98 #if USE(BIGINT32) 99 99 if (value <= INT_MAX && value >= INT_MIN) 100 return jsBigInt32(static_cast<int32_t>(value)); 101 #endif 102 return JSBigInt::createFrom(globalObject, value); 103 } 104 105 static JSValue makeHeapBigIntOrBigInt32(JSGlobalObject* globalObject, uint64_t value) 106 { 107 #if USE(BIGINT32) 108 if (value <= INT_MAX) 100 109 return jsBigInt32(static_cast<int32_t>(value)); 101 110 #endif … … 431 440 } 432 441 433 static uint64_t toBigInt64(JSValue bigInt)442 static int64_t toBigInt64(JSValue bigInt) 434 443 { 435 444 ASSERT(bigInt.isBigInt()); -
trunk/Source/JavaScriptCore/runtime/JSCell.h
r271269 r272170 234 234 } 235 235 236 static const TypedArrayType TypedArrayStorageType = NotTypedArray;236 static constexpr TypedArrayType TypedArrayStorageType = NotTypedArray; 237 237 238 238 void setPerCellBit(bool); -
trunk/Source/JavaScriptCore/runtime/JSDataView.h
r267564 r272170 38 38 static constexpr unsigned elementSize = 1; 39 39 40 static constexpr TypedArrayContentType contentType = TypedArrayContentType::None; 41 40 42 template<typename CellType, SubspaceAccess mode> 41 43 static IsoSubspace* subspaceFor(VM& vm) … … 65 67 RefPtr<DataView> unsharedTypedImpl(); 66 68 67 static const TypedArrayType TypedArrayStorageType = TypeDataView;69 static constexpr TypedArrayType TypedArrayStorageType = TypeDataView; 68 70 69 71 static Structure* createStructure(VM&, JSGlobalObject*, JSValue prototype); -
trunk/Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp
r269343 r272170 46 46 getFloat32 dataViewProtoFuncGetFloat32 DontEnum|Function 1 DataViewGetFloat32 47 47 getFloat64 dataViewProtoFuncGetFloat64 DontEnum|Function 1 DataViewGetFloat64 48 getBigInt64 dataViewProtoFuncGetBigInt64 DontEnum|Function 1 49 getBigUint64 dataViewProtoFuncGetBigUint64 DontEnum|Function 1 48 50 setInt8 dataViewProtoFuncSetInt8 DontEnum|Function 2 DataViewSetInt8 49 51 setUint8 dataViewProtoFuncSetUint8 DontEnum|Function 2 DataViewSetUint8 … … 54 56 setFloat32 dataViewProtoFuncSetFloat32 DontEnum|Function 2 DataViewSetFloat32 55 57 setFloat64 dataViewProtoFuncSetFloat64 DontEnum|Function 2 DataViewSetFloat64 58 setBigInt64 dataViewProtoFuncSetBigInt64 DontEnum|Function 2 59 setBigUint64 dataViewProtoFuncSetBigUint64 DontEnum|Function 2 56 60 buffer dataViewProtoGetterBuffer DontEnum|Accessor 0 57 61 byteLength dataViewProtoGetterByteLength DontEnum|Accessor 0 … … 68 72 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncGetFloat32); 69 73 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncGetFloat64); 74 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncGetBigInt64); 75 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncGetBigUint64); 70 76 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetInt8); 71 77 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetInt16); … … 76 82 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetFloat32); 77 83 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetFloat64); 84 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetBigInt64); 85 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetBigUint64); 78 86 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoGetterBuffer); 79 87 static JSC_DECLARE_HOST_FUNCTION(dataViewProtoGetterByteLength); … … 162 170 } 163 171 164 return JSValue::encode(Adaptor::toJSValue(u.value));172 RELEASE_AND_RETURN(scope, JSValue::encode(Adaptor::toJSValue(globalObject, u.value))); 165 173 } 166 174 … … 296 304 } 297 305 306 JSC_DEFINE_HOST_FUNCTION(dataViewProtoFuncGetBigInt64, (JSGlobalObject* globalObject, CallFrame* callFrame)) 307 { 308 return getData<BigInt64Adaptor>(globalObject, callFrame); 309 } 310 311 JSC_DEFINE_HOST_FUNCTION(dataViewProtoFuncGetBigUint64, (JSGlobalObject* globalObject, CallFrame* callFrame)) 312 { 313 return getData<BigUint64Adaptor>(globalObject, callFrame); 314 } 315 298 316 JSC_DEFINE_HOST_FUNCTION(dataViewProtoFuncSetInt8, (JSGlobalObject* globalObject, CallFrame* callFrame)) 299 317 { … … 335 353 return setData<Float64Adaptor>(globalObject, callFrame); 336 354 } 355 356 JSC_DEFINE_HOST_FUNCTION(dataViewProtoFuncSetBigInt64, (JSGlobalObject* globalObject, CallFrame* callFrame)) 357 { 358 return setData<BigInt64Adaptor>(globalObject, callFrame); 359 } 360 361 JSC_DEFINE_HOST_FUNCTION(dataViewProtoFuncSetBigUint64, (JSGlobalObject* globalObject, CallFrame* callFrame)) 362 { 363 return setData<BigUint64Adaptor>(globalObject, callFrame); 364 } 337 365 IGNORE_CLANG_WARNINGS_END 338 366 -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h
r271269 r272170 41 41 JS_EXPORT_PRIVATE const ClassInfo* getFloat32ArrayClassInfo(); 42 42 JS_EXPORT_PRIVATE const ClassInfo* getFloat64ArrayClassInfo(); 43 JS_EXPORT_PRIVATE const ClassInfo* getBigInt64ArrayClassInfo(); 44 JS_EXPORT_PRIVATE const ClassInfo* getBigUint64ArrayClassInfo(); 43 45 44 46 // A typed array view is our representation of a typed array object as seen … … 80 82 // static int8_t toNativeFromDouble(double); 81 83 // static JSValue toJSValue(int8_t); 82 // static double toDouble(int8_t);83 84 // template<T> static T::Type convertTo(uint8_t); 84 85 // }; … … 91 92 extern const ASCIILiteral typedArrayBufferHasBeenDetachedErrorMessage; 92 93 93 template<typename Adaptor>94 template<typename PassedAdaptor> 94 95 class JSGenericTypedArrayView final : public JSArrayBufferView { 95 96 public: 96 97 using Base = JSArrayBufferView; 97 typedef typename Adaptor::Type ElementType; 98 using Adaptor = PassedAdaptor; 99 using ElementType = typename Adaptor::Type; 100 static constexpr TypedArrayContentType contentType = Adaptor::contentType; 98 101 99 102 static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero; … … 120 123 } 121 124 125 bool inBounds(unsigned i) const 126 { 127 return i < m_length; 128 } 129 122 130 // These methods are meant to match indexed access methods that JSObject 123 131 // supports - hence the slight redundancy. 124 132 bool canGetIndexQuickly(unsigned i) const 125 133 { 126 return i < m_length;134 return inBounds(i) && Adaptor::canConvertToJSQuickly; 127 135 } 128 136 bool canSetIndexQuickly(unsigned i, JSValue value) const 129 137 { 130 return i < m_length && value.isNumber() ;138 return i < m_length && value.isNumber() && Adaptor::canConvertToJSQuickly; 131 139 } 132 140 … … 137 145 } 138 146 139 double getIndexQuicklyAsDouble(unsigned i)140 {141 return Adaptor::toDouble(getIndexQuicklyAsNativeValue(i));142 }143 144 147 JSValue getIndexQuickly(unsigned i) const 145 148 { 146 return Adaptor::toJSValue( getIndexQuicklyAsNativeValue(i));149 return Adaptor::toJSValue(nullptr, getIndexQuicklyAsNativeValue(i)); 147 150 } 148 151 … … 151 154 ASSERT(i < m_length); 152 155 typedVector()[i] = value; 153 }154 155 void setIndexQuicklyToDouble(unsigned i, double value)156 {157 setIndexQuicklyToNativeValue(i, toNativeFromValue<Adaptor>(jsNumber(value)));158 156 } 159 157 … … 248 246 case TypeFloat64: 249 247 return getFloat64ArrayClassInfo(); 248 case TypeBigInt64: 249 return getBigInt64ArrayClassInfo(); 250 case TypeBigUint64: 251 return getBigUint64ArrayClassInfo(); 250 252 default: 251 253 RELEASE_ASSERT_NOT_REACHED(); … … 276 278 case TypeFloat64: 277 279 return vm.float64ArraySpace<mode>(); 280 case TypeBigInt64: 281 return vm.bigInt64ArraySpace<mode>(); 282 case TypeBigUint64: 283 return vm.bigUint64ArraySpace<mode>(); 278 284 default: 279 285 RELEASE_ASSERT_NOT_REACHED(); … … 284 290 ArrayBuffer* existingBuffer(); 285 291 286 static const TypedArrayType TypedArrayStorageType = Adaptor::typeValue;292 static constexpr TypedArrayType TypedArrayStorageType = Adaptor::typeValue; 287 293 288 294 // This is the default DOM unwrapping. It calls toUnsharedNativeTypedView(). -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.h
r267603 r272170 39 39 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callFloat32Array); 40 40 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callFloat64Array); 41 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callBigInt64Array); 42 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callBigUint64Array); 41 43 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callDataView); 42 44 … … 50 52 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructFloat32Array); 51 53 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructFloat64Array); 54 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructBigInt64Array); 55 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructBigUint64Array); 52 56 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructDataView); 53 57 … … 88 92 case TypeFloat64: 89 93 return callFloat64Array; 94 case TypeBigInt64: 95 return callBigInt64Array; 96 case TypeBigUint64: 97 return callBigUint64Array; 90 98 case TypeDataView: 91 99 return callDataView; … … 117 125 case TypeFloat64: 118 126 return constructFloat64Array; 127 case TypeBigInt64: 128 return constructBigInt64Array; 129 case TypeBigUint64: 130 return constructBigUint64Array; 119 131 case TypeDataView: 120 132 return constructDataView; -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h
r270571 r272170 194 194 } 195 195 196 if (contentType(object->classInfo(vm)->typedArrayStorageType) != ViewClass::contentType) { 197 throwTypeError(globalObject, scope, "Content types of source and new typed array are different"_s); 198 return nullptr; 199 } 200 196 201 length = view->length(); 197 202 } else { -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
r271269 r272170 163 163 unsigned otherOffset, unsigned length, CopyType type) 164 164 { 165 VM& vm = globalObject->vm(); 166 auto scope = DECLARE_THROW_SCOPE(vm); 167 165 168 // Handle the hilarious case: the act of getting the length could have resulted 166 169 // in detaching. Well, no. That'll never happen because there cannot be … … 172 175 173 176 RELEASE_ASSERT(other->canAccessRangeQuickly(otherOffset, length)); 174 if (!validateRange(globalObject, offset, length)) 177 bool success = validateRange(globalObject, offset, length); 178 EXCEPTION_ASSERT(!scope.exception() == success); 179 if (!success) 175 180 return false; 181 182 if constexpr (Adaptor::contentType != OtherAdaptor::contentType) { 183 throwTypeError(globalObject, scope, "Content types of source and destination typed arrays are different"_s); 184 return false; 185 } 176 186 177 187 // This method doesn't support copying between the same array. Note that … … 290 300 RELEASE_AND_RETURN(scope, setWithSpecificType<Float64Adaptor>( 291 301 globalObject, offset, jsCast<JSFloat64Array*>(object), objectOffset, length, type)); 302 case TypeBigInt64: 303 RELEASE_AND_RETURN(scope, setWithSpecificType<BigInt64Adaptor>( 304 globalObject, offset, jsCast<JSBigInt64Array*>(object), objectOffset, length, type)); 305 case TypeBigUint64: 306 RELEASE_AND_RETURN(scope, setWithSpecificType<BigUint64Adaptor>( 307 globalObject, offset, jsCast<JSBigUint64Array*>(object), objectOffset, length, type)); 292 308 case NotTypedArray: 293 309 case TypeDataView: { … … 434 450 template<typename Adaptor> 435 451 bool JSGenericTypedArrayView<Adaptor>::getOwnPropertySlotByIndex( 436 JSObject* object, JSGlobalObject*, unsigned propertyName, PropertySlot& slot) 437 { 452 JSObject* object, JSGlobalObject* globalObject, unsigned propertyName, PropertySlot& slot) 453 { 454 VM& vm = globalObject->vm(); 455 auto scope = DECLARE_THROW_SCOPE(vm); 438 456 JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(object); 439 457 440 if (thisObject->isDetached() || !thisObject-> canGetIndexQuickly(propertyName))458 if (thisObject->isDetached() || !thisObject->inBounds(propertyName)) 441 459 return false; 442 460 443 slot.setValue(thisObject, static_cast<unsigned>(PropertyAttribute::None), thisObject->getIndexQuickly(propertyName)); 461 JSValue value; 462 if constexpr (Adaptor::canConvertToJSQuickly) 463 value = thisObject->getIndexQuickly(propertyName); 464 else { 465 auto nativeValue = thisObject->getIndexQuicklyAsNativeValue(propertyName); 466 value = Adaptor::toJSValue(globalObject, nativeValue); 467 RETURN_IF_EXCEPTION(scope, false); 468 } 469 slot.setValue(thisObject, static_cast<unsigned>(PropertyAttribute::None), value); 444 470 return true; 445 471 } -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h
r270371 r272170 273 273 auto joinWithSeparator = [&] (StringView separator) -> EncodedJSValue { 274 274 JSStringJoiner joiner(globalObject, separator, length); 275 RETURN_IF_EXCEPTION(scope, encodedJSValue());275 RETURN_IF_EXCEPTION(scope, { }); 276 276 if (!thisObject->isDetached()) { 277 277 for (unsigned i = 0; i < length; i++) { 278 joiner.append(globalObject, thisObject->getIndexQuickly(i)); 279 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 278 JSValue value; 279 if constexpr (ViewClass::Adaptor::canConvertToJSQuickly) 280 value = thisObject->getIndexQuickly(i); 281 else { 282 auto nativeValue = thisObject->getIndexQuicklyAsNativeValue(i); 283 value = ViewClass::Adaptor::toJSValue(globalObject, nativeValue); 284 RETURN_IF_EXCEPTION(scope, { }); 285 } 286 joiner.append(globalObject, value); 287 RETURN_IF_EXCEPTION(scope, { }); 280 288 } 281 289 } else { … … 293 301 294 302 JSString* separatorString = separatorValue.toString(globalObject); 295 RETURN_IF_EXCEPTION(scope, encodedJSValue());303 RETURN_IF_EXCEPTION(scope, { }); 296 304 297 305 auto viewWithString = separatorString->viewWithUnderlyingString(globalObject); 298 RETURN_IF_EXCEPTION(scope, encodedJSValue());306 RETURN_IF_EXCEPTION(scope, { }); 299 307 return joinWithSeparator(viewWithString.view); 300 308 } … … 455 463 ASSERT(!result->isDetached()); 456 464 465 // https://tc39.es/ecma262/#typedarray-species-create 466 // If result.[[ContentType]] ≠ exemplar.[[ContentType]], throw a TypeError exception. 467 if (contentType(result->classInfo(vm)->typedArrayStorageType) != ViewClass::contentType) 468 return throwVMTypeError(globalObject, scope, "Content types of source and created typed arrays are different"_s); 469 457 470 // We return early here since we don't allocate a backing store if length is 0 and memmove does not like nullptrs 458 471 if (!length) … … 502 515 scope.release(); 503 516 jsCast<JSFloat64Array*>(result)->set(globalObject, 0, thisObject, begin, length, CopyType::LeftToRight); 517 return JSValue::encode(result); 518 case TypeBigInt64: 519 scope.release(); 520 jsCast<JSBigInt64Array*>(result)->set(globalObject, 0, thisObject, begin, length, CopyType::LeftToRight); 521 return JSValue::encode(result); 522 case TypeBigUint64: 523 scope.release(); 524 jsCast<JSBigUint64Array*>(result)->set(globalObject, 0, thisObject, begin, length, CopyType::LeftToRight); 504 525 return JSValue::encode(result); 505 526 default: … … 544 565 if (UNLIKELY(!arrayBuffer)) { 545 566 throwOutOfMemoryError(globalObject, scope); 546 return encodedJSValue();567 return { }; 547 568 } 548 569 RELEASE_ASSERT(thisLength == thisObject->length()); … … 568 589 569 590 JSObject* result = construct(globalObject, species, args, "species is not a constructor"); 570 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 571 572 if (jsDynamicCast<JSArrayBufferView*>(vm, result)) 573 return JSValue::encode(result); 574 575 throwTypeError(globalObject, scope, "species constructor did not return a TypedArray View"_s); 576 return JSValue::encode(JSValue()); 591 RETURN_IF_EXCEPTION(scope, { }); 592 593 JSArrayBufferView* validated = validateTypedArray(globalObject, result); 594 RETURN_IF_EXCEPTION(scope, { }); 595 if (contentType(validated->classInfo(vm)->typedArrayStorageType) != ViewClass::contentType) 596 return throwVMTypeError(globalObject, scope, "TypedArray.prototype.subarray constructed typed array of different content type from |this|"_s); 597 598 return JSValue::encode(validated); 577 599 } 578 600 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r271993 r272170 458 458 Float32Array JSGlobalObject::m_typedArrayFloat32 DontEnum|ClassStructure 459 459 Float64Array JSGlobalObject::m_typedArrayFloat64 DontEnum|ClassStructure 460 BigInt64Array JSGlobalObject::m_typedArrayBigInt64 DontEnum|ClassStructure 461 BigUint64Array JSGlobalObject::m_typedArrayBigUint64 DontEnum|ClassStructure 460 462 DataView JSGlobalObject::m_typedArrayDataView DontEnum|ClassStructure 461 463 Date JSGlobalObject::m_dateStructure DontEnum|ClassStructure … … 1208 1210 init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), typedArrayViewPrivateFuncGetOriginalConstructor)); 1209 1211 }); 1212 m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::typedArrayContentType)].initLater([] (const Initializer<JSCell>& init) { 1213 init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), typedArrayViewPrivateFuncContentType)); 1214 }); 1210 1215 m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::typedArraySort)].initLater([] (const Initializer<JSCell>& init) { 1211 1216 init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), typedArrayViewPrivateFuncSort)); … … 1214 1219 init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), typedArrayViewPrivateFuncIsTypedArrayView, IsTypedArrayViewIntrinsic)); 1215 1220 }); 1221 m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::isBigIntTypedArrayView)].initLater([] (const Initializer<JSCell>& init) { 1222 init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), typedArrayViewPrivateFuncIsBigIntTypedArrayView)); 1223 }); 1216 1224 m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::isSharedTypedArrayView)].initLater([] (const Initializer<JSCell>& init) { 1217 1225 init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), typedArrayViewPrivateFuncIsSharedTypedArrayView)); … … 1234 1242 m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::instanceOf)].initLater([] (const Initializer<JSCell>& init) { 1235 1243 init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), objectPrivateFuncInstanceOf)); 1244 }); 1245 m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::toBigInt)].initLater([] (const Initializer<JSCell>& init) { 1246 init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), globalFuncToBigInt)); 1236 1247 }); 1237 1248 m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::BuiltinLog)].initLater([] (const Initializer<JSCell>& init) { -
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r271766 r272170 968 968 } 969 969 970 JSC_DEFINE_HOST_FUNCTION(globalFuncToBigInt, (JSGlobalObject* globalObject, CallFrame* callFrame)) 971 { 972 return JSValue::encode(callFrame->argument(0).toBigInt(globalObject)); 973 } 974 970 975 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h
r271343 r272170 60 60 JSC_DECLARE_HOST_FUNCTION(globalFuncCopyDataProperties); 61 61 JSC_DECLARE_HOST_FUNCTION(globalFuncDateTimeFormat); 62 JSC_DECLARE_HOST_FUNCTION(globalFuncToBigInt); 62 63 63 64 JS_EXPORT_PRIVATE double jsToNumber(StringView); -
trunk/Source/JavaScriptCore/runtime/JSType.cpp
r263134 r272170 85 85 CASE(Float32ArrayType) 86 86 CASE(Float64ArrayType) 87 CASE(BigInt64ArrayType) 88 CASE(BigUint64ArrayType) 87 89 CASE(DataViewType) 88 90 CASE(GetterSetterType) -
trunk/Source/JavaScriptCore/runtime/JSType.h
r263134 r272170 88 88 Float32ArrayType, 89 89 Float64ArrayType, 90 BigInt64ArrayType, 91 BigUint64ArrayType, 90 92 DataViewType, 91 93 // End JSArrayBufferView types. … … 142 144 static constexpr uint32_t NumberOfTypedArrayTypes = LastTypedArrayType - FirstTypedArrayType + 1; 143 145 static constexpr uint32_t NumberOfTypedArrayTypesExcludingDataView = NumberOfTypedArrayTypes - 1; 146 static constexpr uint32_t NumberOfTypedArrayTypesExcludingBigIntArraysAndDataView = NumberOfTypedArrayTypes - 3; 144 147 145 148 static_assert(sizeof(JSType) == sizeof(uint8_t), "sizeof(JSType) is one byte."); -
trunk/Source/JavaScriptCore/runtime/JSTypedArrayConstructors.cpp
r261895 r272170 44 44 MAKE_S_INFO(Float32Array); 45 45 MAKE_S_INFO(Float64Array); 46 MAKE_S_INFO(BigInt64Array); 47 MAKE_S_INFO(BigUint64Array); 46 48 MAKE_S_INFO(DataView); 47 49 -
trunk/Source/JavaScriptCore/runtime/JSTypedArrayConstructors.h
r253019 r272170 41 41 using JSFloat32ArrayConstructor = JSGenericTypedArrayViewConstructor<JSFloat32Array>; 42 42 using JSFloat64ArrayConstructor = JSGenericTypedArrayViewConstructor<JSFloat64Array>; 43 using JSBigInt64ArrayConstructor = JSGenericTypedArrayViewConstructor<JSBigInt64Array>; 44 using JSBigUint64ArrayConstructor = JSGenericTypedArrayViewConstructor<JSBigUint64Array>; 43 45 using JSDataViewConstructor = JSGenericTypedArrayViewConstructor<JSDataView>; 44 46 STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSInt8ArrayConstructor, InternalFunction); … … 51 53 STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFloat32ArrayConstructor, InternalFunction); 52 54 STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFloat64ArrayConstructor, InternalFunction); 55 STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBigInt64ArrayConstructor, InternalFunction); 56 STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBigUint64ArrayConstructor, InternalFunction); 53 57 STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSDataViewConstructor, InternalFunction); 54 58 -
trunk/Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.cpp
r261895 r272170 48 48 MAKE_S_INFO(Float32Array); 49 49 MAKE_S_INFO(Float64Array); 50 MAKE_S_INFO(BigInt64Array); 51 MAKE_S_INFO(BigUint64Array); 50 52 51 53 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.h
r218794 r272170 40 40 typedef JSGenericTypedArrayViewPrototype<JSFloat32Array> JSFloat32ArrayPrototype; 41 41 typedef JSGenericTypedArrayViewPrototype<JSFloat64Array> JSFloat64ArrayPrototype; 42 typedef JSGenericTypedArrayViewPrototype<JSBigInt64Array> JSBigInt64ArrayPrototype; 43 typedef JSGenericTypedArrayViewPrototype<JSBigUint64Array> JSBigUint64ArrayPrototype; 42 44 43 45 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp
r269531 r272170 73 73 case TypeUint16: \ 74 74 return functionName<JSUint16Array>(vm, globalObject, callFrame); \ 75 case TypeBigInt64: \ 76 return functionName<JSBigInt64Array>(vm, globalObject, callFrame); \ 77 case TypeBigUint64: \ 78 return functionName<JSBigUint64Array>(vm, globalObject, callFrame); \ 75 79 case NotTypedArray: \ 76 80 case TypeDataView: \ … … 85 89 JSValue value = callFrame->uncheckedArgument(0); 86 90 return JSValue::encode(jsBoolean(value.isCell() && isTypedView(value.asCell()->classInfo(globalObject->vm())->typedArrayStorageType))); 91 } 92 93 JSC_DEFINE_HOST_FUNCTION(typedArrayViewPrivateFuncIsBigIntTypedArrayView, (JSGlobalObject* globalObject, CallFrame* callFrame)) 94 { 95 JSValue value = callFrame->uncheckedArgument(0); 96 return JSValue::encode(jsBoolean(value.isCell() && isBigIntTypedView(value.asCell()->classInfo(globalObject->vm())->typedArrayStorageType))); 87 97 } 88 98 … … 172 182 } 173 183 184 JSC_DEFINE_HOST_FUNCTION(typedArrayViewPrivateFuncContentType, (JSGlobalObject* globalObject, CallFrame* callFrame)) 185 { 186 VM& vm = globalObject->vm(); 187 auto scope = DECLARE_THROW_SCOPE(vm); 188 JSValue argument = callFrame->argument(0); 189 if (!argument.isCell() || !isTypedView(argument.asCell()->classInfo(vm)->typedArrayStorageType)) 190 return throwVMTypeError(globalObject, scope, "Receiver should be a typed array view"_s); 191 return JSValue::encode(jsNumber(static_cast<int32_t>(contentType(argument.asCell()->classInfo(vm)->typedArrayStorageType)))); 192 } 193 174 194 JSC_DEFINE_HOST_FUNCTION(typedArrayViewPrivateFuncGetOriginalConstructor, (JSGlobalObject* globalObject, CallFrame* callFrame)) 175 195 { … … 389 409 case TypeUint16: 390 410 return JSValue::encode(jsNontrivialString(vm, "Uint16Array"_s)); 411 case TypeBigInt64: 412 return JSValue::encode(jsNontrivialString(vm, "BigInt64Array"_s)); 413 case TypeBigUint64: 414 return JSValue::encode(jsNontrivialString(vm, "BigUint64Array"_s)); 391 415 case NotTypedArray: 392 416 case TypeDataView: -
trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.h
r269531 r272170 53 53 54 54 JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncIsTypedArrayView); 55 JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncIsBigIntTypedArrayView); 55 56 JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncIsSharedTypedArrayView); 56 57 JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncIsDetached); … … 58 59 JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncSort); 59 60 JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncLength); 61 JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncContentType); 60 62 JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncGetOriginalConstructor); 61 63 JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncSubarrayCreate); -
trunk/Source/JavaScriptCore/runtime/JSTypedArrays.cpp
r268640 r272170 62 62 MAKE_S_INFO(Float32); 63 63 MAKE_S_INFO(Float64); 64 MAKE_S_INFO(BigInt64); 65 MAKE_S_INFO(BigUint64); 64 66 65 67 MAKE_CONSTRUCTORS(DataView); -
trunk/Source/JavaScriptCore/runtime/JSTypedArrays.h
r253143 r272170 40 40 using JSFloat32Array = JSGenericTypedArrayView<Float32Adaptor>; 41 41 using JSFloat64Array = JSGenericTypedArrayView<Float64Adaptor>; 42 using JSBigInt64Array = JSGenericTypedArrayView<BigInt64Adaptor>; 43 using JSBigUint64Array = JSGenericTypedArrayView<BigUint64Adaptor>; 42 44 43 45 JS_EXPORT_PRIVATE JSUint8Array* createUint8TypedArray(JSGlobalObject*, Structure*, RefPtr<ArrayBuffer>&&, unsigned byteOffset, unsigned length); -
trunk/Source/JavaScriptCore/runtime/ToNativeFromValue.h
r251425 r272170 27 27 28 28 #include "JSCJSValue.h" 29 #include "TypedArrayAdaptors.h" 29 30 30 31 namespace JSC { … … 33 34 typename Adaptor::Type toNativeFromValue(JSValue value) 34 35 { 36 // FIXME: BigInt 35 37 if (value.isInt32()) 36 38 return Adaptor::toNativeFromInt32(value.asInt32()); … … 41 43 typename Adaptor::Type toNativeFromValue(JSGlobalObject* globalObject, JSValue value) 42 44 { 43 if (value.isInt32()) 44 return Adaptor::toNativeFromInt32(value.asInt32()); 45 if (value.isNumber()) 46 return Adaptor::toNativeFromDouble(value.asDouble()); 47 return Adaptor::toNativeFromDouble(value.toNumber(globalObject)); 45 if constexpr (std::is_same_v<Adaptor, BigInt64Adaptor> || std::is_same_v<Adaptor, BigUint64Adaptor>) { 46 if constexpr (std::is_same_v<Adaptor, BigInt64Adaptor>) 47 return value.toBigInt64(globalObject); 48 else 49 return value.toBigUInt64(globalObject); 50 } else { 51 if (value.isInt32()) 52 return Adaptor::toNativeFromInt32(value.asInt32()); 53 if (value.isNumber()) 54 return Adaptor::toNativeFromDouble(value.asDouble()); 55 return Adaptor::toNativeFromDouble(value.toNumber(globalObject)); 56 } 48 57 } 49 58 … … 51 60 Optional<typename Adaptor::Type> toNativeFromValueWithoutCoercion(JSValue value) 52 61 { 53 if (!value.isNumber()) 54 return WTF::nullopt; 55 if (value.isInt32()) 56 return Adaptor::toNativeFromInt32WithoutCoercion(value.asInt32()); 57 return Adaptor::toNativeFromDoubleWithoutCoercion(value.asDouble()); 62 if constexpr (std::is_same_v<Adaptor, BigInt64Adaptor> || std::is_same_v<Adaptor, BigUint64Adaptor>) { 63 if (!value.isBigInt()) 64 return WTF::nullopt; 65 if constexpr (std::is_same_v<Adaptor, BigInt64Adaptor>) 66 return JSBigInt::toBigInt64(value); 67 else 68 return JSBigInt::toBigUInt64(value); 69 } else { 70 if (!value.isNumber()) 71 return WTF::nullopt; 72 if (value.isInt32()) 73 return Adaptor::toNativeFromInt32WithoutCoercion(value.asInt32()); 74 return Adaptor::toNativeFromDoubleWithoutCoercion(value.asDouble()); 75 } 58 76 } 59 77 -
trunk/Source/JavaScriptCore/runtime/TypedArrayAdaptors.h
r253143 r272170 26 26 #pragma once 27 27 28 #include "JSBigInt.h" 28 29 #include "JSCJSValue.h" 29 30 #include "MathCommon.h" … … 40 41 typedef ViewTypeArg ViewType; 41 42 typedef JSViewTypeArg JSViewType; 42 static const TypedArrayType typeValue = typeValueArg; 43 constexpr static const TypeArg minValue = std::numeric_limits<TypeArg>::lowest(); 44 constexpr static const TypeArg maxValue = std::numeric_limits<TypeArg>::max(); 45 46 static JSValue toJSValue(Type value) 43 static constexpr TypedArrayType typeValue = typeValueArg; 44 static constexpr TypeArg minValue = std::numeric_limits<TypeArg>::lowest(); 45 static constexpr TypeArg maxValue = std::numeric_limits<TypeArg>::max(); 46 static constexpr bool canConvertToJSQuickly = true; 47 static constexpr TypedArrayContentType contentType = JSC::contentType(typeValue); 48 49 static JSValue toJSValue(JSGlobalObject*, Type value) 47 50 { 48 51 static_assert(!std::is_floating_point<Type>::value, ""); 49 52 return jsNumber(value); 50 }51 52 static double toDouble(Type value)53 {54 return static_cast<double>(value);55 53 } 56 54 … … 116 114 typedef ViewTypeArg ViewType; 117 115 typedef JSViewTypeArg JSViewType; 118 static const TypedArrayType typeValue = typeValueArg; 119 constexpr static const TypeArg minValue = std::numeric_limits<TypeArg>::lowest(); 120 constexpr static const TypeArg maxValue = std::numeric_limits<TypeArg>::max(); 121 122 static JSValue toJSValue(Type value) 116 static constexpr TypedArrayType typeValue = typeValueArg; 117 static constexpr TypeArg minValue = std::numeric_limits<TypeArg>::lowest(); 118 static constexpr TypeArg maxValue = std::numeric_limits<TypeArg>::max(); 119 static constexpr bool canConvertToJSQuickly = true; 120 static constexpr TypedArrayContentType contentType = JSC::contentType(typeValue); 121 122 static JSValue toJSValue(JSGlobalObject*, Type value) 123 123 { 124 124 return jsDoubleNumber(purifyNaN(value)); 125 }126 127 static double toDouble(Type value)128 {129 return static_cast<double>(value);130 125 } 131 126 … … 170 165 171 166 return valueResult; 167 } 168 }; 169 170 template< 171 typename TypeArg, typename ViewTypeArg, typename JSViewTypeArg, 172 TypedArrayType typeValueArg> 173 struct BigIntTypedArrayAdaptor { 174 typedef TypeArg Type; 175 typedef ViewTypeArg ViewType; 176 typedef JSViewTypeArg JSViewType; 177 static constexpr TypedArrayType typeValue = typeValueArg; 178 static constexpr TypeArg minValue = std::numeric_limits<TypeArg>::lowest(); 179 static constexpr TypeArg maxValue = std::numeric_limits<TypeArg>::max(); 180 static constexpr bool canConvertToJSQuickly = false; 181 static constexpr TypedArrayContentType contentType = JSC::contentType(typeValue); 182 183 static JSValue toJSValue(JSGlobalObject* globalObject, Type value) 184 { 185 ASSERT(globalObject); 186 return JSBigInt::makeHeapBigIntOrBigInt32(globalObject, value); 187 } 188 189 static Type toNativeFromInt32(int32_t value) 190 { 191 return static_cast<Type>(value); 192 } 193 194 static Type toNativeFromUint32(uint32_t value) 195 { 196 return static_cast<Type>(value); 197 } 198 199 static Type toNativeFromDouble(double value) 200 { 201 return static_cast<Type>(value); 202 } 203 204 template<typename OtherAdaptor> 205 static typename OtherAdaptor::Type convertTo(Type value) 206 { 207 return static_cast<typename OtherAdaptor::Type>(value); 172 208 } 173 209 }; … … 182 218 struct Float32Adaptor; 183 219 struct Float64Adaptor; 220 struct BigInt64Adaptor; 221 struct BigUint64Adaptor; 184 222 185 223 template<typename Adaptor> class GenericTypedArrayView; … … 193 231 typedef GenericTypedArrayView<Float32Adaptor> Float32Array; 194 232 typedef GenericTypedArrayView<Float64Adaptor> Float64Array; 233 typedef GenericTypedArrayView<BigInt64Adaptor> BigInt64Array; 234 typedef GenericTypedArrayView<BigUint64Adaptor> BigUint64Array; 195 235 196 236 template<typename Adaptor> class JSGenericTypedArrayView; … … 204 244 using JSFloat32Array = JSGenericTypedArrayView<Float32Adaptor>; 205 245 using JSFloat64Array = JSGenericTypedArrayView<Float64Adaptor>; 246 using JSBigInt64Array = JSGenericTypedArrayView<BigInt64Adaptor>; 247 using JSBigUint64Array = JSGenericTypedArrayView<BigUint64Adaptor>; 206 248 207 249 struct Int8Adaptor : IntegralTypedArrayAdaptor<int8_t, Int8Array, JSInt8Array, TypeInt8> { }; … … 213 255 struct Float32Adaptor : FloatTypedArrayAdaptor<float, Float32Array, JSFloat32Array, TypeFloat32> { }; 214 256 struct Float64Adaptor : FloatTypedArrayAdaptor<double, Float64Array, JSFloat64Array, TypeFloat64> { }; 257 struct BigInt64Adaptor : BigIntTypedArrayAdaptor<int64_t, BigInt64Array, JSBigInt64Array, TypeBigInt64> { }; 258 struct BigUint64Adaptor : BigIntTypedArrayAdaptor<uint64_t, BigUint64Array, JSBigUint64Array, TypeBigUint64> { }; 215 259 216 260 struct Uint8ClampedAdaptor { … … 218 262 typedef Uint8ClampedArray ViewType; 219 263 typedef JSUint8ClampedArray JSViewType; 220 static const TypedArrayType typeValue = TypeUint8Clamped; 221 constexpr static const uint8_t minValue = std::numeric_limits<uint8_t>::lowest(); 222 constexpr static const uint8_t maxValue = std::numeric_limits<uint8_t>::max(); 223 224 static JSValue toJSValue(uint8_t value) 264 static constexpr TypedArrayType typeValue = TypeUint8Clamped; 265 static constexpr uint8_t minValue = std::numeric_limits<uint8_t>::lowest(); 266 static constexpr uint8_t maxValue = std::numeric_limits<uint8_t>::max(); 267 static constexpr bool canConvertToJSQuickly = true; 268 static constexpr TypedArrayContentType contentType = JSC::contentType(typeValue); 269 270 static JSValue toJSValue(JSGlobalObject*, uint8_t value) 225 271 { 226 272 return jsNumber(value); 227 }228 229 static double toDouble(uint8_t value)230 {231 return static_cast<double>(value);232 273 } 233 274 -
trunk/Source/JavaScriptCore/runtime/TypedArrayType.cpp
r261755 r272170 54 54 case TypeFloat64: 55 55 return JSFloat64ArrayConstructor::info(); 56 case TypeBigInt64: 57 return JSBigInt64ArrayConstructor::info(); 58 case TypeBigUint64: 59 return JSBigUint64ArrayConstructor::info(); 56 60 case TypeDataView: 57 61 return JSDataViewConstructor::info(); … … 100 104 out.print("TypeFloat64"); 101 105 return; 106 case TypeBigInt64: 107 out.print("TypeBigInt64"); 108 return; 109 case TypeBigUint64: 110 out.print("TypeBigUint64"); 111 return; 102 112 case TypeDataView: 103 113 out.print("TypeDataView"); -
trunk/Source/JavaScriptCore/runtime/TypedArrayType.h
r233721 r272170 43 43 macro(Uint32) \ 44 44 macro(Float32) \ 45 macro(Float64) 45 macro(Float64) \ 46 macro(BigInt64) \ 47 macro(BigUint64) 46 48 47 49 #define FOR_EACH_TYPED_ARRAY_TYPE(macro) \ … … 56 58 }; 57 59 60 enum class TypedArrayContentType : uint8_t { 61 None, 62 Number, 63 BigInt, 64 }; 65 58 66 #define ASSERT_TYPED_ARRAY_TYPE(name) \ 59 67 static_assert(static_cast<uint32_t>(Type ## name) == (static_cast<uint32_t>(name ## ArrayType) - FirstTypedArrayType + static_cast<uint32_t>(TypeInt8)), ""); … … 86 94 } 87 95 96 inline bool isBigIntTypedView(TypedArrayType type) 97 { 98 switch (type) { 99 case TypeBigInt64: 100 case TypeBigUint64: 101 return true; 102 default: 103 return false; 104 } 105 } 106 88 107 inline unsigned logElementSize(TypedArrayType type) 89 108 { … … 104 123 return 2; 105 124 case TypeFloat64: 125 case TypeBigInt64: 126 case TypeBigUint64: 106 127 return 3; 107 128 } … … 160 181 } 161 182 183 inline bool isBigInt(TypedArrayType type) 184 { 185 switch (type) { 186 case TypeBigInt64: 187 case TypeBigUint64: 188 return true; 189 default: 190 return false; 191 } 192 } 193 162 194 inline bool isSigned(TypedArrayType type) 163 195 { … … 168 200 case TypeFloat32: 169 201 case TypeFloat64: 202 case TypeBigInt64: 170 203 return true; 171 204 default: … … 179 212 } 180 213 214 inline constexpr TypedArrayContentType contentType(TypedArrayType type) 215 { 216 switch (type) { 217 case TypeBigInt64: 218 case TypeBigUint64: 219 return TypedArrayContentType::BigInt; 220 case TypeInt8: 221 case TypeInt16: 222 case TypeInt32: 223 case TypeUint8: 224 case TypeUint16: 225 case TypeUint32: 226 case TypeFloat32: 227 case TypeFloat64: 228 case TypeUint8Clamped: 229 return TypedArrayContentType::Number; 230 case NotTypedArray: 231 case TypeDataView: 232 return TypedArrayContentType::None; 233 } 234 return TypedArrayContentType::None; 235 } 236 181 237 } // namespace JSC 182 238 -
trunk/Source/JavaScriptCore/runtime/TypedArrays.h
r206525 r272170 40 40 typedef GenericTypedArrayView<Float32Adaptor> Float32Array; 41 41 typedef GenericTypedArrayView<Float64Adaptor> Float64Array; 42 typedef GenericTypedArrayView<BigInt64Adaptor> BigInt64Array; 43 typedef GenericTypedArrayView<BigUint64Adaptor> BigUint64Array; 42 44 43 45 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r270861 r272170 1472 1472 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(arrayIteratorSpace, cellHeapCellType.get(), JSArrayIterator) 1473 1473 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(asyncGeneratorSpace, cellHeapCellType.get(), JSAsyncGenerator) 1474 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(bigInt64ArraySpace, cellHeapCellType.get(), JSBigInt64Array) 1474 1475 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(bigIntObjectSpace, cellHeapCellType.get(), BigIntObject) 1476 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(bigUint64ArraySpace, cellHeapCellType.get(), JSBigUint64Array) 1475 1477 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(booleanObjectSpace, cellHeapCellType.get(), BooleanObject) 1476 1478 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(boundFunctionSpace, cellHeapCellType.get(), JSBoundFunction) // Hash:0xd7916d41 -
trunk/Source/JavaScriptCore/runtime/VM.h
r270861 r272170 494 494 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(arrayIteratorSpace) 495 495 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(asyncGeneratorSpace) 496 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(bigInt64ArraySpace) 496 497 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(bigIntObjectSpace) 498 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(bigUint64ArraySpace) 497 499 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(booleanObjectSpace) 498 500 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(boundFunctionSpace)
Note: See TracChangeset
for help on using the changeset viewer.