Changeset 272170 in webkit


Ignore:
Timestamp:
Feb 1, 2021 12:56:41 PM (18 months ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Implement BigInt64Array and BigUint64Array
https://bugs.webkit.org/show_bug.cgi?id=190800

Reviewed by Ross Kirsling.

JSTests:

Through this patch, we encounter two test262 failures and found that these tests have issues.

  • stress/bigint-typed-array-array-modes-profile.js: Added.

(foo):

  • stress/bigint-typed-array-byte-offset.js: Added.

(foo):

  • stress/bigint-typed-array-canonical-numeric-index-string.js: Added.

(makeTest.assert):
(makeTest):
(const.testInvalidIndices.makeTest.set assert):
(const.testInvalidIndices.makeTest):
(const.testValidIndices.makeTest.set assert):
(const.testValidIndices.makeTest):

  • stress/bigint-typed-array-constructor-undefined.js: Added.
  • stress/bigint-typed-array-get-by-val-profiling.js: Added.

(testArray.testCode):
(testArray):

  • stress/bigint-typed-array-lastIndexOf-exception-check.js: Added.
  • stress/bigint-typed-array-put-by-val-profiling.js: Added.

(testArray.testCode):
(testArray):

  • stress/bigint-typedarray-getownproperty.js: Added.

(assert):
(foo):

  • stress/bigint64array-bytelength.js: Added.

(test1):
(test2):
(shouldBe):

  • stress/bigint64array-get-by-val.js: Added.

(shouldBe):
(test1):
(test2):

  • stress/bigint64array-put-by-val.js: Added.

(shouldBe):
(test11):
(test12):
(test21):
(test22):

  • test262/config.yaml:
  • test262/expectations.yaml:

Source/JavaScriptCore:

This patch implements BigInt64Array and BigUint64Array.

  1. In this patch, we do not support BigInt64Array/BigUint64Array + Atomics yet.
  2. We make canGetIndexQuickly false for BigInt64Array and BigUint64Array. And we use generic path for getting values from BigInt64Array and BigUint64Array. We will optimize it in [1] and [2]. But possibly, this does not have super large impact on performance since getting value from BigInt64Array and BigUint64Array are already costly since we always need to allocate BigInt for results.
  3. DFG / FTL GetByVal etc. are using Array::Generic for BigInt64Array and BigUint64Array.
  4. But GetArrayLength, CheckArray, byteLength getter etc. are using Array::BigInt64Array / Array::BigUint64Array for optimization.
  5. Extend ArrayProfile's ArrayMode for BigInt64Array and BigUint64Array so that ArrayProfile can record BigInt64Array and BigUint64Array information.
  6. Implement DataView#{setBigInt64,setBigUint64,getBigInt64,getBigUint64}.
  7. Extend JSC APIs to support BigInt64Array and BigUint64Array.

[1]: https://bugs.webkit.org/show_bug.cgi?id=221181
[2]: https://bugs.webkit.org/show_bug.cgi?id=221183

  • API/JSTypedArray.cpp:

(toJSTypedArrayType):
(toTypedArrayType):
(createTypedArray):

  • API/JSValueRef.h:
  • API/tests/TypedArrayCTest.cpp:

(forEachTypedArrayType):

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • builtins/BuiltinNames.h:
  • builtins/TypedArrayPrototype.js:

(fill):
(map):
(filter):

  • bytecode/ArrayProfile.cpp:

(JSC::dumpArrayModes):

  • bytecode/ArrayProfile.h:
  • bytecode/ByValInfo.h:

(JSC::jitArrayModeForClassInfo):
(JSC::jitArrayModePermitsPut):
(JSC::typedArrayTypeForJITArrayMode):

  • bytecode/LinkTimeConstant.h:
  • bytecode/SpeculatedType.cpp:

(JSC::dumpSpeculation):
(JSC::speculationToAbbreviatedString):
(JSC::speculationFromTypedArrayType):
(JSC::typedArrayTypeFromSpeculation):
(JSC::speculationFromString):

  • bytecode/SpeculatedType.h:

(JSC::isBigInt64ArraySpeculation):
(JSC::isBigUint64ArraySpeculation):
(JSC::isDirectArgumentsSpeculation):
(JSC::isScopedArgumentsSpeculation):
(JSC::isActionableIntMutableArraySpeculation): Deleted.
(JSC::isActionableFloatMutableArraySpeculation): Deleted.
(JSC::isActionableTypedMutableArraySpeculation): Deleted.
(JSC::isActionableMutableArraySpeculation): Deleted.
(JSC::isActionableArraySpeculation): Deleted.

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • dfg/DFGArrayMode.cpp:

(JSC::DFG::ArrayMode::fromObserved):
(JSC::DFG::ArrayMode::refine const):
(JSC::DFG::ArrayMode::alreadyChecked const):
(JSC::DFG::arrayTypeToString):
(JSC::DFG::toTypedArrayType):
(JSC::DFG::toArrayType):
(JSC::DFG::permitsBoundsCheckLowering):

  • dfg/DFGArrayMode.h:

(JSC::DFG::ArrayMode::supportsSelfLength const):
(JSC::DFG::ArrayMode::arrayModesThatPassFiltering const):

  • dfg/DFGClobberize.h:

(JSC::DFG::clobberize):

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode):

  • dfg/DFGOperations.cpp:

(JSC::DFG::JSC_DEFINE_JIT_OPERATION):

  • dfg/DFGOperations.h:

(JSC::DFG::operationNewTypedArrayWithSizeForType):
(JSC::DFG::operationNewTypedArrayWithOneArgumentForType):

  • dfg/DFGPredictionPropagationPhase.cpp:
  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileHasIndexedProperty):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileGetByVal):
(JSC::FTL::DFG::LowerDFGToB3::compilePutByVal):

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::subtype):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::privateCompilePutByVal):

  • jit/Repatch.cpp:

(JSC::tryCacheArrayGetByVal):

  • llint/LowLevelInterpreter.asm:
  • runtime/AtomicsObject.cpp:
  • runtime/AtomicsObject.h:
  • runtime/BigInt64Array.h: Copied from Source/JavaScriptCore/runtime/JSTypedArrayConstructors.cpp.
  • runtime/BigUint64Array.h: Copied from Source/JavaScriptCore/runtime/JSTypedArrayConstructors.cpp.
  • runtime/JSArrayBufferView.cpp:

(JSC::elementSize):
(JSC::validateTypedArray):

  • runtime/JSArrayBufferView.h:
  • runtime/JSBigInt.h:
  • runtime/JSCell.h:
  • runtime/JSDataView.h:
  • runtime/JSDataViewPrototype.cpp:

(JSC::getData):
(JSC::JSC_DEFINE_HOST_FUNCTION):

  • runtime/JSGenericTypedArrayView.h:
  • runtime/JSGenericTypedArrayViewConstructor.h:
  • runtime/JSGenericTypedArrayViewConstructorInlines.h:

(JSC::constructGenericTypedArrayViewWithArguments):

  • runtime/JSGenericTypedArrayViewInlines.h:

(JSC::JSGenericTypedArrayView<Adaptor>::setWithSpecificType):
(JSC::JSGenericTypedArrayView<Adaptor>::set):
(JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlotByIndex):

  • runtime/JSGenericTypedArrayViewPrototypeFunctions.h:

(JSC::genericTypedArrayViewProtoFuncJoin):
(JSC::genericTypedArrayViewProtoFuncSlice):
(JSC::genericTypedArrayViewPrivateFuncSubarrayCreate):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • runtime/JSGlobalObjectFunctions.h:
  • runtime/JSType.cpp:

(WTF::printInternal):

  • runtime/JSType.h:
  • runtime/JSTypedArrayConstructors.cpp:
  • runtime/JSTypedArrayConstructors.h:
  • runtime/JSTypedArrayPrototypes.cpp:
  • runtime/JSTypedArrayPrototypes.h:
  • runtime/JSTypedArrayViewPrototype.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • runtime/JSTypedArrayViewPrototype.h:
  • runtime/JSTypedArrays.cpp:
  • runtime/JSTypedArrays.h:
  • runtime/ToNativeFromValue.h:

(JSC::toNativeFromValue):
(JSC::toNativeFromValueWithoutCoercion):

  • runtime/TypedArrayAdaptors.h:

(JSC::IntegralTypedArrayAdaptor::toJSValue):
(JSC::FloatTypedArrayAdaptor::toJSValue):
(JSC::BigIntTypedArrayAdaptor::toJSValue):
(JSC::BigIntTypedArrayAdaptor::toNativeFromInt32):
(JSC::BigIntTypedArrayAdaptor::toNativeFromUint32):
(JSC::BigIntTypedArrayAdaptor::toNativeFromDouble):
(JSC::BigIntTypedArrayAdaptor::convertTo):
(JSC::Uint8ClampedAdaptor::toJSValue):
(JSC::IntegralTypedArrayAdaptor::toDouble): Deleted.
(JSC::FloatTypedArrayAdaptor::toDouble): Deleted.
(JSC::Uint8ClampedAdaptor::toDouble): Deleted.

  • runtime/TypedArrayType.cpp:

(JSC::constructorClassInfoForType):
(WTF::printInternal):

  • runtime/TypedArrayType.h:

(JSC::isBigIntTypedView):
(JSC::logElementSize):
(JSC::isBigInt):
(JSC::isSigned):
(JSC::contentType):

  • runtime/TypedArrays.h:
  • runtime/VM.cpp:
  • runtime/VM.h:
Location:
trunk
Files:
12 added
64 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r272139 r272170  
     12021-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
    1492021-02-01  Yusuke Suzuki  <ysuzuki@apple.com>
    250
  • trunk/JSTests/test262/config.yaml

    r271511 r272170  
    2929    - Intl.ListFormat
    3030  paths:
    31     - test/built-ins/DataView/prototype/getBigInt64
    32     - test/built-ins/DataView/prototype/getBigUint64
    33     - test/built-ins/DataView/prototype/setBigInt64
    34 
    35     # https://bugs.webkit.org/show_bug.cgi?id=190800
    36     - test/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt
    37     - test/built-ins/TypedArray/prototype/buffer/BigInt
    38     - test/built-ins/TypedArray/prototype/byteLength/BigInt
    39     - test/built-ins/TypedArray/prototype/byteOffset/BigInt
    40     - test/built-ins/TypedArray/prototype/copyWithin/BigInt
    41     - test/built-ins/TypedArray/prototype/entries/BigInt
    42     - test/built-ins/TypedArray/prototype/every/BigInt
    43     - test/built-ins/TypedArray/prototype/fill/BigInt
    44     - test/built-ins/TypedArray/prototype/filter/BigInt
    45     - test/built-ins/TypedArray/prototype/find/BigInt
    46     - test/built-ins/TypedArray/prototype/findIndex/BigInt
    47     - test/built-ins/TypedArray/prototype/forEach/BigInt
    48     - test/built-ins/TypedArray/prototype/includes/BigInt
    49     - test/built-ins/TypedArray/prototype/indexOf/BigInt
    50     - test/built-ins/TypedArray/prototype/join/BigInt
    51     - test/built-ins/TypedArray/prototype/keys/BigInt
    52     - test/built-ins/TypedArray/prototype/lastIndexOf/BigInt
    53     - test/built-ins/TypedArray/prototype/length/BigInt
    54     - test/built-ins/TypedArray/prototype/map/BigInt
    55     - test/built-ins/TypedArray/prototype/reduce/BigInt
    56     - test/built-ins/TypedArray/prototype/reduceRight/BigInt
    57     - test/built-ins/TypedArray/prototype/reverse/BigInt
    58     - test/built-ins/TypedArray/prototype/set/BigInt
    59     - test/built-ins/TypedArray/prototype/slice/BigInt
    60     - test/built-ins/TypedArray/prototype/some/BigInt
    61     - test/built-ins/TypedArray/prototype/sort/BigInt
    62     - test/built-ins/TypedArray/prototype/subarray/BigInt
    63     - test/built-ins/TypedArray/prototype/toLocaleString/BigInt
    64     - test/built-ins/TypedArray/prototype/toString/BigInt
    65     - test/built-ins/TypedArray/prototype/values/BigInt
    66     - test/built-ins/TypedArrayConstructors/BigInt64Array
    67     - test/built-ins/TypedArrayConstructors/BigUint64Array
    68     - test/built-ins/TypedArrayConstructors/ctors-bigint
    69     - test/built-ins/TypedArrayConstructors/from/BigInt
    70     - test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt
    71     - test/built-ins/TypedArrayConstructors/internals/Delete/BigInt
    72     - test/built-ins/TypedArrayConstructors/internals/Get/BigInt
    73     - test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt
    74     - test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt
    75     - test/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/BigInt
    76     - test/built-ins/TypedArrayConstructors/internals/Set/BigInt
    77     - test/built-ins/TypedArrayConstructors/of/BigInt
    78 
    7931    - test/built-ins/Atomics/add/bigint
    8032    - test/built-ins/Atomics/and/bigint
     
    10153    - test/language/identifiers/start-unicode-13.0.0-escaped.js
    10254    - test/language/identifiers/start-unicode-13.0.0.js
    103 
    104     # https://bugs.webkit.org/show_bug.cgi?id=190800
    105     - test/built-ins/Object/seal/seal-bigint64array.js
    106     - test/built-ins/Object/seal/seal-biguint64array.js
    107     - test/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js
    108     - test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/src-typedarray-big-throws.js
    109     - test/built-ins/TypedArrayConstructors/prototype/Symbol.toStringTag/bigint-inherited.js
    110     - test/built-ins/TypedArrayConstructors/prototype/bigint-Symbol.iterator.js
    111     - test/built-ins/TypedArrayConstructors/prototype/buffer/bigint-inherited.js
    112     - test/built-ins/TypedArrayConstructors/prototype/byteLength/bigint-inherited.js
    113     - test/built-ins/TypedArrayConstructors/prototype/byteOffset/bigint-inherited.js
    114     - test/built-ins/TypedArrayConstructors/prototype/copyWithin/bigint-inherited.js
    115     - test/built-ins/TypedArrayConstructors/prototype/entries/bigint-inherited.js
    116     - test/built-ins/TypedArrayConstructors/prototype/every/bigint-inherited.js
    117     - test/built-ins/TypedArrayConstructors/prototype/fill/bigint-inherited.js
    118     - test/built-ins/TypedArrayConstructors/prototype/filter/bigint-inherited.js
    119     - test/built-ins/TypedArrayConstructors/prototype/find/bigint-inherited.js
    120     - test/built-ins/TypedArrayConstructors/prototype/findIndex/bigint-inherited.js
    121     - test/built-ins/TypedArrayConstructors/prototype/forEach/bigint-inherited.js
    122     - test/built-ins/TypedArrayConstructors/prototype/indexOf/bigint-inherited.js
    123     - test/built-ins/TypedArrayConstructors/prototype/join/bigint-inherited.js
    124     - test/built-ins/TypedArrayConstructors/prototype/keys/bigint-inherited.js
    125     - test/built-ins/TypedArrayConstructors/prototype/lastIndexOf/bigint-inherited.js
    126     - test/built-ins/TypedArrayConstructors/prototype/length/bigint-inherited.js
    127     - test/built-ins/TypedArrayConstructors/prototype/map/bigint-inherited.js
    128     - test/built-ins/TypedArrayConstructors/prototype/reduce/bigint-inherited.js
    129     - test/built-ins/TypedArrayConstructors/prototype/reduceRight/bigint-inherited.js
    130     - test/built-ins/TypedArrayConstructors/prototype/reverse/bigint-inherited.js
    131     - test/built-ins/TypedArrayConstructors/prototype/set/bigint-inherited.js
    132     - test/built-ins/TypedArrayConstructors/prototype/slice/bigint-inherited.js
    133     - test/built-ins/TypedArrayConstructors/prototype/some/bigint-inherited.js
    134     - test/built-ins/TypedArrayConstructors/prototype/sort/bigint-inherited.js
    135     - test/built-ins/TypedArrayConstructors/prototype/subarray/bigint-inherited.js
    136     - test/built-ins/TypedArrayConstructors/prototype/toLocaleString/bigint-inherited.js
    137     - test/built-ins/TypedArrayConstructors/prototype/toString/bigint-inherited.js
    138     - test/built-ins/TypedArrayConstructors/prototype/values/bigint-inherited.js
    139     - test/language/expressions/class/subclass-builtins/subclass-BigInt64Array.js
    140     - test/language/expressions/class/subclass-builtins/subclass-BigUint64Array.js
    141     - test/language/statements/class/subclass-builtins/subclass-BigInt64Array.js
    142     - test/language/statements/class/subclass-builtins/subclass-BigUint64Array.js
    14355
    14456    # requires ICU 65 (https://unicode-org.atlassian.net/browse/ICU-20654)
     
    213125    - test/intl402/NumberFormat/prototype/resolvedOptions/compactDisplay.js
    214126    - 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  
    824824  default: 'SyntaxError: Invalid regular expression: number too large in {} quantifier'
    825825  strict mode: 'SyntaxError: Invalid regular expression: number too large in {} quantifier'
     826test/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.)'
     829test/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.)'
    826832test/intl402/DateTimeFormat/prototype/formatRange/en-US.js:
    827833  default: 'Test262Error: Expected SameValue(«1/3/2019 – 1/5/2019», «1/3/2019 – 1/5/2019») to be true'
     
    866872  default: 'Test262Error: Expected SameValue(«ru-Armn-SU», «ru-Armn-AM») to be true'
    867873  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'
    871874test/intl402/Locale/constructor-options-region-valid.js:
    872875  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  
    6565    case TypeFloat64:
    6666        return kJSTypedArrayTypeFloat64Array;
     67    case TypeBigInt64:
     68        return kJSTypedArrayTypeBigInt64Array;
     69    case TypeBigUint64:
     70        return kJSTypedArrayTypeBigUint64Array;
    6771    }
    6872    RELEASE_ASSERT_NOT_REACHED();
     
    9397    case kJSTypedArrayTypeFloat64Array:
    9498        return TypeFloat64;
     99    case kJSTypedArrayTypeBigInt64Array:
     100        return TypeBigInt64;
     101    case kJSTypedArrayTypeBigUint64Array:
     102        return TypeBigUint64;
    95103    }
    96104    RELEASE_ASSERT_NOT_REACHED();
     
    124132    case kJSTypedArrayTypeFloat64Array:
    125133        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);
    126138    case kJSTypedArrayTypeArrayBuffer:
    127139    case kJSTypedArrayTypeNone:
  • trunk/Source/JavaScriptCore/API/JSValueRef.h

    r246265 r272170  
    6767 @constant     kJSTypedArrayTypeFloat32Array         Float32Array
    6868 @constant     kJSTypedArrayTypeFloat64Array         Float64Array
     69 @constant     kJSTypedArrayTypeBigInt64Array        BigInt64Array
     70 @constant     kJSTypedArrayTypeBigUint64Array       BigUint64Array
    6971 @constant     kJSTypedArrayTypeArrayBuffer          ArrayBuffer
    7072 @constant     kJSTypedArrayTypeNone                 Not a Typed Array
     
    8385    kJSTypedArrayTypeArrayBuffer,
    8486    kJSTypedArrayTypeNone,
     87    kJSTypedArrayTypeBigInt64Array,
     88    kJSTypedArrayTypeBigUint64Array,
    8589} JSTypedArrayType JSC_API_AVAILABLE(macos(10.12), ios(10.0));
    8690
  • trunk/Source/JavaScriptCore/API/tests/TypedArrayCTest.cpp

    r250005 r272170  
    5050};
    5151
    52 static const unsigned byteSizes[kJSTypedArrayTypeArrayBuffer] =
     52static const unsigned byteSizes[] =
    5353{
    5454    1, // kJSTypedArrayTypeInt8Array
     
    6161    4, // kJSTypedArrayTypeFloat32Array
    6262    8, // kJSTypedArrayTypeFloat64Array
     63    0, // kJSTypedArrayTypeArrayBuffer
     64    0, // kJSTypedArrayTypeNone
     65    8, // kJSTypedArrayTypeBigInt64Array
     66    8, // kJSTypedArrayTypeBigUint64Array
    6367};
    6468
    65 static const char* typeToString[kJSTypedArrayTypeArrayBuffer] =
     69static const char* typeToString[] =
    6670{
    6771    "kJSTypedArrayTypeInt8Array",
     
    7478    "kJSTypedArrayTypeFloat32Array",
    7579    "kJSTypedArrayTypeFloat64Array",
     80    "kJSTypedArrayTypeArrayBuffer",
     81    "kJSTypedArrayTypeNone",
     82    "kJSTypedArrayTypeBigInt64Array",
     83    "kJSTypedArrayTypeBigUint64Array",
    7684};
    7785
     
    213221{
    214222    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    }
    217227    return failed;
    218228}
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r271993 r272170  
    823823    runtime/BasicBlockLocation.h
    824824    runtime/BatchedTransitionOptimizer.h
     825    runtime/BigInt64Array.h
    825826    runtime/BigIntObject.h
    826827    runtime/BigIntPrototype.h
     828    runtime/BigUint64Array.h
    827829    runtime/BooleanObject.h
    828830    runtime/BooleanPrototype.h
  • trunk/Source/JavaScriptCore/ChangeLog

    r272139 r272170  
     12021-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
    11732021-02-01  Yusuke Suzuki  <ysuzuki@apple.com>
    2174
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r271993 r272170  
    18491849                E35CA1541DBC3A5C00F83516 /* DOMJITHeapRange.h in Headers */ = {isa = PBXBuildFile; fileRef = E35CA1521DBC3A5600F83516 /* DOMJITHeapRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18501850                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, ); }; };
    18511853                E3637EE9236E56B00096BD0A /* LinkTimeConstant.h in Headers */ = {isa = PBXBuildFile; fileRef = E3637EE7236E56B00096BD0A /* LinkTimeConstant.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18521854                E365F33A24AA623900C991B2 /* IntlDisplayNamesConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E365F33924AA621200C991B2 /* IntlDisplayNamesConstructor.lut.h */; };
     
    50625064                E35CA1511DBC3A5600F83516 /* DOMJITHeapRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMJITHeapRange.cpp; sourceTree = "<group>"; };
    50635065                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>"; };
    50645068                E3637EE7236E56B00096BD0A /* LinkTimeConstant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkTimeConstant.h; sourceTree = "<group>"; };
    50655069                E3637EE8236E56B00096BD0A /* LinkTimeConstant.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LinkTimeConstant.cpp; sourceTree = "<group>"; };
     
    71377141                                52678F8D1A031009006A306D /* BasicBlockLocation.h */,
    71387142                                147B83AA0E6DB8C9004775A4 /* BatchedTransitionOptimizer.h */,
     7143                                E35E89FB25C50F860071EE1E /* BigInt64Array.h */,
    71397144                                86976E581FA3756D00E7C4E1 /* BigIntConstructor.cpp */,
    71407145                                86976E571FA3754000E7C4E1 /* BigIntConstructor.h */,
     
    71447149                                86976E5B1FA375A800E7C4E1 /* BigIntPrototype.cpp */,
    71457150                                86976E5A1FA3758A00E7C4E1 /* BigIntPrototype.h */,
     7151                                E35E89FC25C50F870071EE1E /* BigUint64Array.h */,
    71467152                                BC7952320E15EB5600A898AB /* BooleanConstructor.cpp */,
    71477153                                BC7952330E15EB5600A898AB /* BooleanConstructor.h */,
     
    92569262                                52678F8F1A031009006A306D /* BasicBlockLocation.h in Headers */,
    92579263                                147B83AC0E6DB8C9004775A4 /* BatchedTransitionOptimizer.h in Headers */,
     9264                                E35E89FD25C50F870071EE1E /* BigInt64Array.h in Headers */,
    92589265                                86976E5F1FA3E8BC00E7C4E1 /* BigIntConstructor.h in Headers */,
    92599266                                866739D213BFDE710023D87C /* BigInteger.h in Headers */,
    92609267                                861816771FB7924200ECC4EC /* BigIntObject.h in Headers */,
    92619268                                86976E5E1FA3E8B600E7C4E1 /* BigIntPrototype.h in Headers */,
     9269                                E35E89FE25C50F870071EE1E /* BigUint64Array.h in Headers */,
    92629270                                0F64B2721A784BAF006E4E66 /* BinarySwitch.h in Headers */,
    92639271                                C2B916C214DA014E00CBAC86 /* BlockDirectory.h in Headers */,
  • trunk/Source/JavaScriptCore/builtins/BuiltinNames.h

    r271942 r272170  
    7171    macro(throwTypeErrorFunction) \
    7272    macro(typedArrayLength) \
     73    macro(typedArrayContentType) \
    7374    macro(typedArraySort) \
    7475    macro(typedArrayGetOriginalConstructor) \
     
    99100    macro(Float32Array) \
    100101    macro(Float64Array) \
     102    macro(BigInt64Array) \
     103    macro(BigUint64Array) \
    101104    macro(exec) \
    102105    macro(generator) \
     
    174177    macro(instanceFieldInitializer) \
    175178    macro(hasOwnPropertyFunction) \
    176     macro(createPrivateSymbol)
     179    macro(createPrivateSymbol) \
     180    macro(toBigInt) \
     181    macro(isBigIntTypedArrayView)
    177182
    178183namespace Symbols {
  • trunk/Source/JavaScriptCore/builtins/TypedArrayPrototype.js

    r269531 r272170  
    9292    var length = @typedArrayLength(this);
    9393
    94     var number = @toNumber(value);
     94    if (@isBigIntTypedArrayView(this))
     95        var number = @toBigInt(value);
     96    else
     97        var number = @toNumber(value);
    9598
    9699    var start = @typedArrayClampArgumentToStartOrEnd(@argument(1), length, 0);
     
    336339    if (@typedArrayLength(result) < length)
    337340        @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|");
    338343
    339344    for (var i = 0; i < length; i++) {
     
    367372    if (@typedArrayLength(result) < length)
    368373        @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|");
    369376
    370377    for (var i = 0; i < length; i++)
  • trunk/Source/JavaScriptCore/bytecode/ArrayProfile.cpp

    r261895 r272170  
    4545    Float32ArrayMode,
    4646    Float64ArrayMode,
     47    BigInt64ArrayMode,
     48    BigUint64ArrayMode,
    4749};
    4850
     
    111113    if (arrayModes & Float64ArrayMode)
    112114        out.print(comma, "Float64ArrayMode");
     115    if (arrayModes & BigInt64ArrayMode)
     116        out.print(comma, "BigInt64ArrayMode");
     117    if (arrayModes & BigUint64ArrayMode)
     118        out.print(comma, "BigUint64ArrayMode");
    113119}
    114120
  • trunk/Source/JavaScriptCore/bytecode/ArrayProfile.h

    r260323 r272170  
    4848const ArrayModes CopyOnWriteArrayWithContiguousArrayMode = 1 << CopyOnWriteArrayWithContiguous;
    4949
    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;
     50const ArrayModes Int8ArrayMode = 1U << 16;
     51const ArrayModes Int16ArrayMode = 1U << 17;
     52const ArrayModes Int32ArrayMode = 1U << 18;
     53const ArrayModes Uint8ArrayMode = 1U << 19;
     54const ArrayModes Uint8ClampedArrayMode = 1U << 20; // 21 - 25 are used for CoW arrays.
     55const ArrayModes Uint16ArrayMode = 1U << 26;
     56const ArrayModes Uint32ArrayMode = 1U << 27;
     57const ArrayModes Float32ArrayMode = 1U << 28;
     58const ArrayModes Float64ArrayMode = 1U << 29;
     59const ArrayModes BigInt64ArrayMode = 1U << 30;
     60const ArrayModes BigUint64ArrayMode = 1U << 31;
    5961
    6062JS_EXPORT_PRIVATE extern const ArrayModes typedArrayModes[NumberOfTypedArrayTypesExcludingDataView];
     
    7577    | Float32ArrayMode        \
    7678    | Float64ArrayMode        \
     79    | BigInt64ArrayMode       \
     80    | BigUint64ArrayMode      \
    7781    )
    7882
  • trunk/Source/JavaScriptCore/bytecode/ByValInfo.h

    r266359 r272170  
    5757    JITUint32Array,
    5858    JITFloat32Array,
    59     JITFloat64Array
     59    JITFloat64Array,
     60    JITBigInt64Array,
     61    JITBigUint64Array,
    6062};
    6163
     
    147149    case TypeFloat64:
    148150        return JITFloat64Array;
     151    case TypeBigInt64:
     152        return JITBigInt64Array;
     153    case TypeBigUint64:
     154        return JITBigUint64Array;
    149155    default:
    150156        CRASH();
     
    158164    case JITDirectArguments:
    159165    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:
    160170        // We could support put_by_val on these at some point, but it's just not that profitable
    161171        // at the moment.
     
    207217    case JITFloat64Array:
    208218        return TypeFloat64;
     219    case JITBigInt64Array:
     220        return TypeBigInt64;
     221    case JITBigUint64Array:
     222        return TypeBigUint64;
    209223    default:
    210224        CRASH();
  • trunk/Source/JavaScriptCore/bytecode/LinkTimeConstant.h

    r271942 r272170  
    5151    v(AggregateError, nullptr) \
    5252    v(typedArrayLength, nullptr) \
     53    v(typedArrayContentType, nullptr) \
    5354    v(typedArrayGetOriginalConstructor, nullptr) \
    5455    v(typedArraySort, nullptr) \
     
    111112    v(hasOwnPropertyFunction, nullptr) \
    112113    v(createPrivateSymbol, nullptr) \
     114    v(toBigInt, nullptr) \
     115    v(isBigIntTypedArrayView, nullptr) \
    113116
    114117
  • trunk/Source/JavaScriptCore/bytecode/SpeculatedType.cpp

    r267221 r272170  
    149149            else
    150150                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
    152162            if (value & SpecFunction)
    153163                strOut.print("Function");
     
    360370    if (isFloat64ArraySpeculation(prediction))
    361371        return "<Float64array>";
     372    if (isBigInt64ArraySpeculation(prediction))
     373        return "<BigInt64array>";
     374    if (isBigUint64ArraySpeculation(prediction))
     375        return "<BigUint64array>";
    362376    if (isDirectArgumentsSpeculation(prediction))
    363377        return "<DirectArguments>";
     
    425439    case TypeFloat64:
    426440        return SpecFloat64Array;
     441    case TypeBigInt64:
     442        return SpecBigInt64Array;
     443    case TypeBigUint64:
     444        return SpecBigUint64Array;
    427445    case NotTypedArray:
    428446    case TypeDataView:
     
    657675    if (isFloat64ArraySpeculation(type))
    658676        return TypeFloat64;
     677
     678    if (isBigInt64ArraySpeculation(type))
     679        return TypeBigInt64;
     680
     681    if (isBigUint64ArraySpeculation(type))
     682        return TypeBigUint64;
    659683   
    660684    return NotTypedArray;
     
    903927    if (!strncmp(speculation, "SpecFloat64Array", strlen("SpecFloat64Array")))
    904928        return SpecFloat64Array;
     929    if (!strncmp(speculation, "SpecBigInt64Array", strlen("SpecBigInt64Array")))
     930        return SpecBigInt64Array;
     931    if (!strncmp(speculation, "SpecBigUint64Array", strlen("SpecBigUint64Array")))
     932        return SpecBigUint64Array;
    905933    if (!strncmp(speculation, "SpecTypedArrayView", strlen("SpecTypedArrayView")))
    906934        return SpecTypedArrayView;
  • trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h

    r262252 r272170  
    5252static constexpr SpeculatedType SpecUint16Array                       = 1ull << 9; // It's definitely an Uint16Array or one of its subclasses.
    5353static 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.
     54static constexpr SpeculatedType SpecFloat32Array                      = 1ull << 11; // It's definitely an Float32Array or one of its subclasses.
     55static constexpr SpeculatedType SpecFloat64Array                      = 1ull << 12; // It's definitely an Float64Array or one of its subclasses.
     56static constexpr SpeculatedType SpecBigInt64Array                     = 1ull << 13; // It's definitely an BigInt64Array or one of its subclasses.
     57static constexpr SpeculatedType SpecBigUint64Array                    = 1ull << 14; // It's definitely an BigUint64Array or one of its subclasses.
     58static constexpr SpeculatedType SpecTypedArrayView                    = SpecInt8Array | SpecInt16Array | SpecInt32Array | SpecUint8Array | SpecUint8ClampedArray | SpecUint16Array | SpecUint32Array | SpecFloat32Array | SpecFloat64Array | SpecBigInt64Array | SpecBigUint64Array;
     59static constexpr SpeculatedType SpecDirectArguments                   = 1ull << 15; // It's definitely a DirectArguments object.
     60static constexpr SpeculatedType SpecScopedArguments                   = 1ull << 16; // It's definitely a ScopedArguments object.
     61static constexpr SpeculatedType SpecStringObject                      = 1ull << 17; // It's definitely a StringObject.
     62static constexpr SpeculatedType SpecRegExpObject                      = 1ull << 18; // It's definitely a RegExpObject (and not any subclass of RegExpObject).
     63static constexpr SpeculatedType SpecDateObject                        = 1ull << 19; // It's definitely a Date object or one of its subclasses.
     64static constexpr SpeculatedType SpecPromiseObject                     = 1ull << 20; // It's definitely a Promise object or one of its subclasses.
     65static constexpr SpeculatedType SpecMapObject                         = 1ull << 21; // It's definitely a Map object or one of its subclasses.
     66static constexpr SpeculatedType SpecSetObject                         = 1ull << 22; // It's definitely a Set object or one of its subclasses.
     67static constexpr SpeculatedType SpecWeakMapObject                     = 1ull << 23; // It's definitely a WeakMap object or one of its subclasses.
     68static constexpr SpeculatedType SpecWeakSetObject                     = 1ull << 24; // It's definitely a WeakSet object or one of its subclasses.
     69static constexpr SpeculatedType SpecProxyObject                       = 1ull << 25; // It's definitely a Proxy object or one of its subclasses.
     70static constexpr SpeculatedType SpecDerivedArray                      = 1ull << 26; // It's definitely a DerivedArray object.
     71static constexpr SpeculatedType SpecObjectOther                       = 1ull << 27; // It's definitely an object but not JSFinalObject, JSArray, or JSFunction.
     72static constexpr SpeculatedType SpecStringIdent                       = 1ull << 28; // It's definitely a JSString, and it's an identifier.
     73static constexpr SpeculatedType SpecStringVar                         = 1ull << 29; // It's definitely a JSString, and it's not an identifier.
    7274static 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 << 30; // It's definitely an Int32 with value 0 or 1.
    76 static constexpr SpeculatedType SpecNonBoolInt32                      = 1ull << 31; // It's definitely an Int32 with value other than 0 or 1.
     75static constexpr SpeculatedType SpecSymbol                            = 1ull << 30; // It's definitely a Symbol.
     76static constexpr SpeculatedType SpecCellOther                         = 1ull << 31; // It's definitely a JSCell but not a subclass of JSObject and definitely not a JSString, BigInt, or Symbol.
     77static constexpr SpeculatedType SpecBoolInt32                         = 1ull << 32; // It's definitely an Int32 with value 0 or 1.
     78static constexpr SpeculatedType SpecNonBoolInt32                      = 1ull << 33; // It's definitely an Int32 with value other than 0 or 1.
    7779static constexpr SpeculatedType SpecInt32Only                         = SpecBoolInt32 | SpecNonBoolInt32; // It's definitely an Int32.
    7880
    79 static constexpr SpeculatedType SpecInt32AsInt52                      = 1ull << 32; // It's an Int52 and it can fit in an int32.
    80 static constexpr SpeculatedType SpecNonInt32AsInt52                   = 1ull << 33; // It's an Int52 and it can't fit in an int32.
     81static constexpr SpeculatedType SpecInt32AsInt52                      = 1ull << 34; // It's an Int52 and it can fit in an int32.
     82static constexpr SpeculatedType SpecNonInt32AsInt52                   = 1ull << 35; // It's an Int52 and it can't fit in an int32.
    8183static constexpr SpeculatedType SpecInt52Any                          = SpecInt32AsInt52 | SpecNonInt32AsInt52; // It's any kind of Int52.
    8284
    83 static constexpr SpeculatedType SpecAnyIntAsDouble                    = 1ull << 34; // It's definitely an Int52 and it's inside a double.
    84 static constexpr SpeculatedType SpecNonIntAsDouble                    = 1ull << 35; // It's definitely not an Int52 but it's a real number and it's a double.
     85static constexpr SpeculatedType SpecAnyIntAsDouble                    = 1ull << 36; // It's definitely an Int52 and it's inside a double.
     86static constexpr SpeculatedType SpecNonIntAsDouble                    = 1ull << 37; // It's definitely not an Int52 but it's a real number and it's a double.
    8587static constexpr SpeculatedType SpecDoubleReal                        = SpecNonIntAsDouble | SpecAnyIntAsDouble; // It's definitely a non-NaN double.
    86 static constexpr SpeculatedType SpecDoublePureNaN                     = 1ull << 36; // It's definitely a NaN that is safe to tag (i.e. pure).
    87 static constexpr SpeculatedType SpecDoubleImpureNaN                   = 1ull << 37; // It's definitely a NaN that is unsafe to tag (i.e. impure).
     88static constexpr SpeculatedType SpecDoublePureNaN                     = 1ull << 38; // It's definitely a NaN that is safe to tag (i.e. pure).
     89static constexpr SpeculatedType SpecDoubleImpureNaN                   = 1ull << 39; // It's definitely a NaN that is unsafe to tag (i.e. impure).
    8890static constexpr SpeculatedType SpecDoubleNaN                         = SpecDoublePureNaN | SpecDoubleImpureNaN; // It's definitely some kind of NaN.
    8991static constexpr SpeculatedType SpecBytecodeDouble                    = SpecDoubleReal | SpecDoublePureNaN; // It's either a non-NaN or a NaN double, but it's definitely not impure NaN.
     
    9597
    9698static 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.
     99static constexpr SpeculatedType SpecBoolean                           = 1ull << 40; // It's definitely a Boolean.
     100static constexpr SpeculatedType SpecOther                             = 1ull << 41; // It's definitely either Null or Undefined.
    99101static constexpr SpeculatedType SpecMisc                              = SpecBoolean | SpecOther; // It's definitely either a boolean, Null, or Undefined.
    100 static constexpr SpeculatedType SpecEmpty                             = 1ull << 40; // It's definitely an empty value marker.
    101 static constexpr SpeculatedType SpecHeapBigInt                        = 1ull << 41; // It's definitely a BigInt that is allocated on the heap
    102 static constexpr SpeculatedType SpecBigInt32                          = 1ull << 42; // It's definitely a small BigInt that is inline the JSValue
     102static constexpr SpeculatedType SpecEmpty                             = 1ull << 42; // It's definitely an empty value marker.
     103static constexpr SpeculatedType SpecHeapBigInt                        = 1ull << 43; // It's definitely a BigInt that is allocated on the heap
     104static constexpr SpeculatedType SpecBigInt32                          = 1ull << 44; // It's definitely a small BigInt that is inline the JSValue
    103105#if USE(BIGINT32)
    104106static constexpr SpeculatedType SpecBigInt                            = SpecBigInt32 | SpecHeapBigInt;
     
    107109static constexpr SpeculatedType SpecBigInt                            = SpecHeapBigInt;
    108110#endif
    109 static constexpr SpeculatedType SpecDataViewObject                    = 1ull << 43; // It's definitely a JSDataView.
     111static constexpr SpeculatedType SpecDataViewObject                    = 1ull << 45; // It's definitely a JSDataView.
    110112static constexpr SpeculatedType SpecPrimitive                         = SpecString | SpecSymbol | SpecBytecodeNumber | SpecMisc | SpecBigInt; // It's any non-Object JSValue.
    111113static 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.
     
    288290}
    289291
     292inline bool isBigInt64ArraySpeculation(SpeculatedType value)
     293{
     294    return value == SpecBigInt64Array;
     295}
     296
     297inline bool isBigUint64ArraySpeculation(SpeculatedType value)
     298{
     299    return value == SpecBigUint64Array;
     300}
     301
    290302inline bool isDirectArgumentsSpeculation(SpeculatedType value)
    291303{
     
    296308{
    297309    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);
    335310}
    336311
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r271298 r272170  
    36483648            filter(node->child1(), SpecFloat64Array | admittedTypes);
    36493649            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;
    36503656        case Array::AnyTypedArray:
    36513657            filter(node->child1(), SpecTypedArrayView | admittedTypes);
  • trunk/Source/JavaScriptCore/dfg/DFGArrayMode.cpp

    r265775 r272170  
    146146    case Float64ArrayMode:
    147147        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);
    148152
    149153    default:
     
    289293    case Array::Float32Array:
    290294    case Array::Float64Array:
     295    case Array::BigInt64Array:
     296    case Array::BigUint64Array:
    291297        if (node->op() == PutByVal) {
    292298            if (graph.hasExitSite(node->origin.semantic, OutOfBounds) || !isInBounds())
     
    294300        }
    295301        return typedArrayResult(withSpeculation(Array::InBounds));
     302
    296303    case Array::Unprofiled:
    297304    case Array::SelectUsingPredictions: {
     
    354361        if (isFloat64ArraySpeculation(base))
    355362            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));
    356369
    357370        if (type() == Array::Unprofiled)
     
    605618    case Array::Float64Array:
    606619        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);
    607626
    608627    case Array::AnyTypedArray:
     
    680699    case Array::Float64Array:
    681700        return "Float64Array";
     701    case Array::BigInt64Array:
     702        return "BigInt64Array";
     703    case Array::BigUint64Array:
     704        return "BigUint64Array";
    682705    case Array::AnyTypedArray:
    683706        return "AnyTypedArray";
     
    782805    case Array::Float64Array:
    783806        return TypeFloat64;
     807    case Array::BigInt64Array:
     808        return TypeBigInt64;
     809    case Array::BigUint64Array:
     810        return TypeBigUint64;
    784811    case Array::AnyTypedArray:
    785812        RELEASE_ASSERT_NOT_REACHED();
     
    811838    case TypeFloat64:
    812839        return Array::Float64Array;
     840    case TypeBigInt64:
     841        return Array::BigInt64Array;
     842    case TypeBigUint64:
     843        return Array::BigUint64Array;
    813844    default:
    814845        return Array::Generic;
     
    846877    case Array::Float32Array:
    847878    case Array::Float64Array:
     879    case Array::BigInt64Array:
     880    case Array::BigUint64Array:
    848881    case Array::AnyTypedArray:
    849882        return true;
  • trunk/Source/JavaScriptCore/dfg/DFGArrayMode.h

    r271573 r272170  
    7777    Float32Array,
    7878    Float64Array,
     79    BigInt64Array,
     80    BigUint64Array,
    7981    AnyTypedArray
    8082};
     
    394396        case Array::Float32Array:
    395397        case Array::Float64Array:
     398        case Array::BigInt64Array:
     399        case Array::BigUint64Array:
    396400            return false;
    397401        case Array::Int32:
     
    478482        case Array::Float64Array:
    479483            return Float64ArrayMode;
     484        case Array::BigInt64Array:
     485            return BigInt64ArrayMode;
     486        case Array::BigUint64Array:
     487            return BigUint64ArrayMode;
    480488        case Array::AnyTypedArray:
    481489            return ALL_TYPED_ARRAY_MODES;
  • trunk/Source/JavaScriptCore/dfg/DFGClobberize.h

    r270874 r272170  
    915915           
    916916        case Array::Generic:
     917        case Array::BigInt64Array:
     918        case Array::BigUint64Array:
    917919            clobberTop();
    918920            return;
     
    10521054           
    10531055        case Array::Generic:
     1056        case Array::BigInt64Array:
     1057        case Array::BigUint64Array:
    10541058            clobberTop();
    10551059            return;
  • trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp

    r271573 r272170  
    10531053                    m_graph.varArgChild(node, 1)->prediction(),
    10541054                    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
    10561068            blessArrayOperation(m_graph.varArgChild(node, 0), m_graph.varArgChild(node, 1), m_graph.varArgChild(node, 2));
    10571069           
     
    12241236                    child2->prediction(),
    12251237                    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            }
    12261250           
    12271251            blessArrayOperation(child1, child2, m_graph.varArgChild(node, 3));
     
    13721396            default: {
    13731397                // Make it Array::Generic.
     1398                // FIXME: Add BigInt64Array / BigUint64Array support.
     1399                // https://bugs.webkit.org/show_bug.cgi?id=221172
    13741400                node->setArrayMode(ArrayMode(Array::Generic, node->arrayMode().action()));
    13751401                break;
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r271987 r272170  
    19431943}
    19441944
     1945JSC_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
     1953JSC_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
     1961JSC_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
     1969JSC_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
    19451977JSC_DEFINE_JIT_OPERATION(operationNewArrayIterator, JSCell*, (VM* vmPointer, Structure* structure))
    19461978{
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.h

    r270874 r272170  
    131131JSC_DECLARE_JIT_OPERATION(operationNewFloat64ArrayWithSize, char*, (JSGlobalObject*, Structure*, int32_t, char*));
    132132JSC_DECLARE_JIT_OPERATION(operationNewFloat64ArrayWithOneArgument, char*, (JSGlobalObject*, Structure*, EncodedJSValue));
     133JSC_DECLARE_JIT_OPERATION(operationNewBigInt64ArrayWithSize, char*, (JSGlobalObject*, Structure*, int32_t, char*));
     134JSC_DECLARE_JIT_OPERATION(operationNewBigInt64ArrayWithOneArgument, char*, (JSGlobalObject*, Structure*, EncodedJSValue));
     135JSC_DECLARE_JIT_OPERATION(operationNewBigUint64ArrayWithSize, char*, (JSGlobalObject*, Structure*, int32_t, char*));
     136JSC_DECLARE_JIT_OPERATION(operationNewBigUint64ArrayWithOneArgument, char*, (JSGlobalObject*, Structure*, EncodedJSValue));
    133137JSC_DECLARE_JIT_OPERATION(operationNewArrayIterator, JSCell*, (VM*, Structure*));
    134138JSC_DECLARE_JIT_OPERATION(operationNewMapIterator, JSCell*, (VM*, Structure*));
     
    362366    case TypeFloat64:
    363367        return operationNewFloat64ArrayWithSize;
     368    case TypeBigInt64:
     369        return operationNewBigInt64ArrayWithSize;
     370    case TypeBigUint64:
     371        return operationNewBigUint64ArrayWithSize;
    364372    case NotTypedArray:
    365373    case TypeDataView:
     
    391399    case TypeFloat64:
    392400        return operationNewFloat64ArrayWithOneArgument;
     401    case TypeBigInt64:
     402        return operationNewBigInt64ArrayWithOneArgument;
     403    case TypeBigUint64:
     404        return operationNewBigUint64ArrayWithOneArgument;
    393405    case NotTypedArray:
    394406    case TypeDataView:
  • trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp

    r270874 r272170  
    515515            case Array::Int32Array:
    516516                changed |= mergePrediction(SpecInt32Only);
     517                break;
     518            case Array::BigInt64Array:
     519            case Array::BigUint64Array:
     520                changed |= mergePrediction(SpecBigInt);
    517521                break;
    518522            default:
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r271490 r272170  
    1438214382    }
    1438314383    default: {
     14384        // FIXME: Optimize TypedArrays in HasIndexedProperty IC
     14385        // https://bugs.webkit.org/show_bug.cgi?id=221183
    1438414386        slowCases.append(m_jit.jump());
    1438514387        break;
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r271592 r272170  
    26492649            break;
    26502650        }
     2651        case Array::BigInt64Array:
     2652        case Array::BigUint64Array:
    26512653        case Array::Generic: {
    26522654            if (m_graph.m_slowGetByVal.contains(node)) {
     
    29812983            DFG_CRASH(m_jit.graph(), node, "Bad array mode type");
    29822984            break;
     2985        case Array::BigInt64Array:
     2986        case Array::BigUint64Array:
    29832987        case Array::Generic: {
    29842988            DFG_ASSERT(m_jit.graph(), node, node->op() == PutByVal || node->op() == PutByValDirect, node->op());
     
    32113215        case Array::Undecided:
    32123216        case Array::Unprofiled:
     3217        case Array::BigInt64Array:
     3218        case Array::BigUint64Array:
    32133219            RELEASE_ASSERT_NOT_REACHED();
    32143220        }
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r271592 r272170  
    50645064        }
    50655065           
     5066        case Array::BigInt64Array:
     5067        case Array::BigUint64Array:
    50665068        case Array::Generic: {
    50675069            if (m_graph.m_slowGetByVal.contains(m_node)) {
     
    53595361        ArrayMode arrayMode = m_node->arrayMode().modeForPut();
    53605362        switch (arrayMode.type()) {
     5363        case Array::BigInt64Array:
     5364        case Array::BigUint64Array:
    53615365        case Array::Generic: {
    53625366            if (child1.useKind() == CellUse) {
     
    56485652        case Array::Undecided:
    56495653        case Array::Unprofiled:
     5654        case Array::BigInt64Array:
     5655        case Array::BigUint64Array:
    56505656            DFG_CRASH(m_graph, m_node, "Bad array type");
    56515657            break;
  • trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp

    r264736 r272170  
    229229            || object->inherits<JSUint32Array>(vm)
    230230            || object->inherits<JSFloat32Array>(vm)
    231             || object->inherits<JSFloat64Array>(vm))
     231            || object->inherits<JSFloat64Array>(vm)
     232            || object->inherits<JSBigInt64Array>(vm)
     233            || object->inherits<JSBigUint64Array>(vm))
    232234            return jsNontrivialString(vm, "array"_s);
    233235    }
  • trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp

    r271279 r272170  
    14941494        if (isInt(type))
    14951495            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));
    14971501            slowCases = emitFloatTypedArrayPutByVal(bytecode, badType, type);
     1502        }
    14981503        break;
    14991504    }
  • trunk/Source/JavaScriptCore/jit/Repatch.cpp

    r270764 r272170  
    496496                accessType = AccessCase::IndexedTypedArrayFloat64Load;
    497497                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;
    498503            default:
    499504                RELEASE_ASSERT_NOT_REACHED();
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r270967 r272170  
    557557const FirstTypedArrayType = constexpr FirstTypedArrayType
    558558const NumberOfTypedArrayTypesExcludingDataView = constexpr NumberOfTypedArrayTypesExcludingDataView
     559const NumberOfTypedArrayTypesExcludingBigIntArraysAndDataView = constexpr NumberOfTypedArrayTypesExcludingBigIntArraysAndDataView
    559560
    560561# Type flags constants.
     
    12341235    loadb JSCell::m_type[base], t2
    12351236    subi FirstTypedArrayType, t2
    1236     biaeq t2, NumberOfTypedArrayTypesExcludingDataView, slowPath
     1237    biaeq t2, NumberOfTypedArrayTypesExcludingBigIntArraysAndDataView, slowPath
    12371238   
    12381239    # Sweet, now we know that we have a typed array. Do some basic things now.
     
    12611262    #    Float32ArrayType,
    12621263    #    Float64ArrayType,
     1264    #
     1265    # Yet, we are not supporting BitInt64Array and BigUint64Array.
    12631266
    12641267    bia t2, Uint16ArrayType - FirstTypedArrayType, .opGetByValAboveUint16Array
  • trunk/Source/JavaScriptCore/runtime/AtomicsObject.cpp

    r269531 r272170  
    128128}
    129129
    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 
    154130enum class TypedArrayOperationMode { Read, Write };
    155131template<TypedArrayOperationMode mode>
  • trunk/Source/JavaScriptCore/runtime/BigInt64Array.h

    r272165 r272170  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (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.
    2424 */
    2525
    26 #include "config.h"
    27 #include "JSTypedArrayConstructors.h"
     26#pragma once
    2827
    29 #include "JSCInlines.h"
     28#include "TypedArrays.h"
    3029
    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 
     30using JSC::BigInt64Array;
  • trunk/Source/JavaScriptCore/runtime/BigUint64Array.h

    r272165 r272170  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (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.
    2424 */
    2525
    26 #include "config.h"
    27 #include "JSTypedArrayConstructors.h"
     26#pragma once
    2827
    29 #include "JSCInlines.h"
     28#include "TypedArrays.h"
    3029
    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 
     30using JSC::BigUint64Array;
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp

    r269832 r272170  
    244244{
    245245    ASSERT(type >= Int8ArrayType && type <= DataViewType);
    246     static_assert(Float64ArrayType + 1 == DataViewType);
     246    static_assert(BigUint64ArrayType + 1 == DataViewType);
    247247    return ElementSizeData[type - Int8ArrayType];
    248248}
     
    341341}
    342342
     343JSArrayBufferView* 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
    343367} // namespace JSC
    344368
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.h

    r269974 r272170  
    225225};
    226226
     227JSArrayBufferView* validateTypedArray(JSGlobalObject*, JSValue);
     228
    227229} // namespace JSC
    228230
  • trunk/Source/JavaScriptCore/runtime/JSBigInt.h

    r271217 r272170  
    7373    static JSBigInt* tryCreateFrom(VM&, int32_t value);
    7474    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);
    7676    JS_EXPORT_PRIVATE static JSBigInt* createFrom(JSGlobalObject*, uint64_t value);
    7777    static JSBigInt* createFrom(JSGlobalObject*, bool value);
     
    9898#if USE(BIGINT32)
    9999        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)
    100109            return jsBigInt32(static_cast<int32_t>(value));
    101110#endif
     
    431440    }
    432441
    433     static uint64_t toBigInt64(JSValue bigInt)
     442    static int64_t toBigInt64(JSValue bigInt)
    434443    {
    435444        ASSERT(bigInt.isBigInt());
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r271269 r272170  
    234234    }
    235235   
    236     static const TypedArrayType TypedArrayStorageType = NotTypedArray;
     236    static constexpr TypedArrayType TypedArrayStorageType = NotTypedArray;
    237237
    238238    void setPerCellBit(bool);
  • trunk/Source/JavaScriptCore/runtime/JSDataView.h

    r267564 r272170  
    3838    static constexpr unsigned elementSize = 1;
    3939
     40    static constexpr TypedArrayContentType contentType = TypedArrayContentType::None;
     41
    4042    template<typename CellType, SubspaceAccess mode>
    4143    static IsoSubspace* subspaceFor(VM& vm)
     
    6567    RefPtr<DataView> unsharedTypedImpl();
    6668   
    67     static const TypedArrayType TypedArrayStorageType = TypeDataView;
     69    static constexpr TypedArrayType TypedArrayStorageType = TypeDataView;
    6870
    6971    static Structure* createStructure(VM&, JSGlobalObject*, JSValue prototype);
  • trunk/Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp

    r269343 r272170  
    4646  getFloat32            dataViewProtoFuncGetFloat32          DontEnum|Function       1  DataViewGetFloat32
    4747  getFloat64            dataViewProtoFuncGetFloat64          DontEnum|Function       1  DataViewGetFloat64
     48  getBigInt64           dataViewProtoFuncGetBigInt64         DontEnum|Function       1
     49  getBigUint64          dataViewProtoFuncGetBigUint64        DontEnum|Function       1
    4850  setInt8               dataViewProtoFuncSetInt8             DontEnum|Function       2  DataViewSetInt8
    4951  setUint8              dataViewProtoFuncSetUint8            DontEnum|Function       2  DataViewSetUint8
     
    5456  setFloat32            dataViewProtoFuncSetFloat32          DontEnum|Function       2  DataViewSetFloat32
    5557  setFloat64            dataViewProtoFuncSetFloat64          DontEnum|Function       2  DataViewSetFloat64
     58  setBigInt64           dataViewProtoFuncSetBigInt64         DontEnum|Function       2
     59  setBigUint64          dataViewProtoFuncSetBigUint64        DontEnum|Function       2
    5660  buffer                dataViewProtoGetterBuffer            DontEnum|Accessor       0
    5761  byteLength            dataViewProtoGetterByteLength        DontEnum|Accessor       0
     
    6872static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncGetFloat32);
    6973static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncGetFloat64);
     74static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncGetBigInt64);
     75static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncGetBigUint64);
    7076static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetInt8);
    7177static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetInt16);
     
    7682static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetFloat32);
    7783static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetFloat64);
     84static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetBigInt64);
     85static JSC_DECLARE_HOST_FUNCTION(dataViewProtoFuncSetBigUint64);
    7886static JSC_DECLARE_HOST_FUNCTION(dataViewProtoGetterBuffer);
    7987static JSC_DECLARE_HOST_FUNCTION(dataViewProtoGetterByteLength);
     
    162170    }
    163171
    164     return JSValue::encode(Adaptor::toJSValue(u.value));
     172    RELEASE_AND_RETURN(scope, JSValue::encode(Adaptor::toJSValue(globalObject, u.value)));
    165173}
    166174
     
    296304}
    297305
     306JSC_DEFINE_HOST_FUNCTION(dataViewProtoFuncGetBigInt64, (JSGlobalObject* globalObject, CallFrame* callFrame))
     307{
     308    return getData<BigInt64Adaptor>(globalObject, callFrame);
     309}
     310
     311JSC_DEFINE_HOST_FUNCTION(dataViewProtoFuncGetBigUint64, (JSGlobalObject* globalObject, CallFrame* callFrame))
     312{
     313    return getData<BigUint64Adaptor>(globalObject, callFrame);
     314}
     315
    298316JSC_DEFINE_HOST_FUNCTION(dataViewProtoFuncSetInt8, (JSGlobalObject* globalObject, CallFrame* callFrame))
    299317{
     
    335353    return setData<Float64Adaptor>(globalObject, callFrame);
    336354}
     355
     356JSC_DEFINE_HOST_FUNCTION(dataViewProtoFuncSetBigInt64, (JSGlobalObject* globalObject, CallFrame* callFrame))
     357{
     358    return setData<BigInt64Adaptor>(globalObject, callFrame);
     359}
     360
     361JSC_DEFINE_HOST_FUNCTION(dataViewProtoFuncSetBigUint64, (JSGlobalObject* globalObject, CallFrame* callFrame))
     362{
     363    return setData<BigUint64Adaptor>(globalObject, callFrame);
     364}
    337365IGNORE_CLANG_WARNINGS_END
    338366
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h

    r271269 r272170  
    4141JS_EXPORT_PRIVATE const ClassInfo* getFloat32ArrayClassInfo();
    4242JS_EXPORT_PRIVATE const ClassInfo* getFloat64ArrayClassInfo();
     43JS_EXPORT_PRIVATE const ClassInfo* getBigInt64ArrayClassInfo();
     44JS_EXPORT_PRIVATE const ClassInfo* getBigUint64ArrayClassInfo();
    4345
    4446// A typed array view is our representation of a typed array object as seen
     
    8082//     static int8_t toNativeFromDouble(double);
    8183//     static JSValue toJSValue(int8_t);
    82 //     static double toDouble(int8_t);
    8384//     template<T> static T::Type convertTo(uint8_t);
    8485// };
     
    9192extern const ASCIILiteral typedArrayBufferHasBeenDetachedErrorMessage;
    9293
    93 template<typename Adaptor>
     94template<typename PassedAdaptor>
    9495class JSGenericTypedArrayView final : public JSArrayBufferView {
    9596public:
    9697    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;
    98101
    99102    static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero;
     
    120123    }
    121124
     125    bool inBounds(unsigned i) const
     126    {
     127        return i < m_length;
     128    }
     129
    122130    // These methods are meant to match indexed access methods that JSObject
    123131    // supports - hence the slight redundancy.
    124132    bool canGetIndexQuickly(unsigned i) const
    125133    {
    126         return i < m_length;
     134        return inBounds(i) && Adaptor::canConvertToJSQuickly;
    127135    }
    128136    bool canSetIndexQuickly(unsigned i, JSValue value) const
    129137    {
    130         return i < m_length && value.isNumber();
     138        return i < m_length && value.isNumber() && Adaptor::canConvertToJSQuickly;
    131139    }
    132140   
     
    137145    }
    138146   
    139     double getIndexQuicklyAsDouble(unsigned i)
    140     {
    141         return Adaptor::toDouble(getIndexQuicklyAsNativeValue(i));
    142     }
    143    
    144147    JSValue getIndexQuickly(unsigned i) const
    145148    {
    146         return Adaptor::toJSValue(getIndexQuicklyAsNativeValue(i));
     149        return Adaptor::toJSValue(nullptr, getIndexQuicklyAsNativeValue(i));
    147150    }
    148151   
     
    151154        ASSERT(i < m_length);
    152155        typedVector()[i] = value;
    153     }
    154    
    155     void setIndexQuicklyToDouble(unsigned i, double value)
    156     {
    157         setIndexQuicklyToNativeValue(i, toNativeFromValue<Adaptor>(jsNumber(value)));
    158156    }
    159157   
     
    248246        case TypeFloat64:
    249247            return getFloat64ArrayClassInfo();
     248        case TypeBigInt64:
     249            return getBigInt64ArrayClassInfo();
     250        case TypeBigUint64:
     251            return getBigUint64ArrayClassInfo();
    250252        default:
    251253            RELEASE_ASSERT_NOT_REACHED();
     
    276278        case TypeFloat64:
    277279            return vm.float64ArraySpace<mode>();
     280        case TypeBigInt64:
     281            return vm.bigInt64ArraySpace<mode>();
     282        case TypeBigUint64:
     283            return vm.bigUint64ArraySpace<mode>();
    278284        default:
    279285            RELEASE_ASSERT_NOT_REACHED();
     
    284290    ArrayBuffer* existingBuffer();
    285291
    286     static const TypedArrayType TypedArrayStorageType = Adaptor::typeValue;
     292    static constexpr TypedArrayType TypedArrayStorageType = Adaptor::typeValue;
    287293
    288294    // This is the default DOM unwrapping. It calls toUnsharedNativeTypedView().
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.h

    r267603 r272170  
    3939JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callFloat32Array);
    4040JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callFloat64Array);
     41JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callBigInt64Array);
     42JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callBigUint64Array);
    4143JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(callDataView);
    4244
     
    5052JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructFloat32Array);
    5153JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructFloat64Array);
     54JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructBigInt64Array);
     55JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructBigUint64Array);
    5256JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(constructDataView);
    5357
     
    8892        case TypeFloat64:
    8993            return callFloat64Array;
     94        case TypeBigInt64:
     95            return callBigInt64Array;
     96        case TypeBigUint64:
     97            return callBigUint64Array;
    9098        case TypeDataView:
    9199            return callDataView;
     
    117125        case TypeFloat64:
    118126            return constructFloat64Array;
     127        case TypeBigInt64:
     128            return constructBigInt64Array;
     129        case TypeBigUint64:
     130            return constructBigUint64Array;
    119131        case TypeDataView:
    120132            return constructDataView;
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h

    r270571 r272170  
    194194            }
    195195
     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
    196201            length = view->length();
    197202        } else {
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h

    r271269 r272170  
    163163    unsigned otherOffset, unsigned length, CopyType type)
    164164{
     165    VM& vm = globalObject->vm();
     166    auto scope = DECLARE_THROW_SCOPE(vm);
     167
    165168    // Handle the hilarious case: the act of getting the length could have resulted
    166169    // in detaching. Well, no. That'll never happen because there cannot be
     
    172175
    173176    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)
    175180        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    }
    176186   
    177187    // This method doesn't support copying between the same array. Note that
     
    290300        RELEASE_AND_RETURN(scope, setWithSpecificType<Float64Adaptor>(
    291301            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));
    292308    case NotTypedArray:
    293309    case TypeDataView: {
     
    434450template<typename Adaptor>
    435451bool 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);
    438456    JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(object);
    439457
    440     if (thisObject->isDetached() || !thisObject->canGetIndexQuickly(propertyName))
     458    if (thisObject->isDetached() || !thisObject->inBounds(propertyName))
    441459        return false;
    442460
    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);
    444470    return true;
    445471}
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h

    r270371 r272170  
    273273    auto joinWithSeparator = [&] (StringView separator) -> EncodedJSValue {
    274274        JSStringJoiner joiner(globalObject, separator, length);
    275         RETURN_IF_EXCEPTION(scope, encodedJSValue());
     275        RETURN_IF_EXCEPTION(scope, { });
    276276        if (!thisObject->isDetached()) {
    277277            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, { });
    280288            }
    281289        } else {
     
    293301
    294302    JSString* separatorString = separatorValue.toString(globalObject);
    295     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     303    RETURN_IF_EXCEPTION(scope, { });
    296304
    297305    auto viewWithString = separatorString->viewWithUnderlyingString(globalObject);
    298     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     306    RETURN_IF_EXCEPTION(scope, { });
    299307    return joinWithSeparator(viewWithString.view);
    300308}
     
    455463    ASSERT(!result->isDetached());
    456464
     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
    457470    // We return early here since we don't allocate a backing store if length is 0 and memmove does not like nullptrs
    458471    if (!length)
     
    502515        scope.release();
    503516        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);
    504525        return JSValue::encode(result);
    505526    default:
     
    544565    if (UNLIKELY(!arrayBuffer)) {
    545566        throwOutOfMemoryError(globalObject, scope);
    546         return encodedJSValue();
     567        return { };
    547568    }
    548569    RELEASE_ASSERT(thisLength == thisObject->length());
     
    568589
    569590    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);
    577599}
    578600
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r271993 r272170  
    458458  Float32Array          JSGlobalObject::m_typedArrayFloat32          DontEnum|ClassStructure
    459459  Float64Array          JSGlobalObject::m_typedArrayFloat64          DontEnum|ClassStructure
     460  BigInt64Array         JSGlobalObject::m_typedArrayBigInt64         DontEnum|ClassStructure
     461  BigUint64Array        JSGlobalObject::m_typedArrayBigUint64        DontEnum|ClassStructure
    460462  DataView              JSGlobalObject::m_typedArrayDataView         DontEnum|ClassStructure
    461463  Date                  JSGlobalObject::m_dateStructure              DontEnum|ClassStructure
     
    12081210            init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), typedArrayViewPrivateFuncGetOriginalConstructor));
    12091211        });
     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        });
    12101215    m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::typedArraySort)].initLater([] (const Initializer<JSCell>& init) {
    12111216            init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), typedArrayViewPrivateFuncSort));
     
    12141219            init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), typedArrayViewPrivateFuncIsTypedArrayView, IsTypedArrayViewIntrinsic));
    12151220        });
     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        });
    12161224    m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::isSharedTypedArrayView)].initLater([] (const Initializer<JSCell>& init) {
    12171225            init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), typedArrayViewPrivateFuncIsSharedTypedArrayView));
     
    12341242    m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::instanceOf)].initLater([] (const Initializer<JSCell>& init) {
    12351243            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));
    12361247        });
    12371248    m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::BuiltinLog)].initLater([] (const Initializer<JSCell>& init) {
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r271766 r272170  
    968968}
    969969
     970JSC_DEFINE_HOST_FUNCTION(globalFuncToBigInt, (JSGlobalObject* globalObject, CallFrame* callFrame))
     971{
     972    return JSValue::encode(callFrame->argument(0).toBigInt(globalObject));
     973}
     974
    970975} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h

    r271343 r272170  
    6060JSC_DECLARE_HOST_FUNCTION(globalFuncCopyDataProperties);
    6161JSC_DECLARE_HOST_FUNCTION(globalFuncDateTimeFormat);
     62JSC_DECLARE_HOST_FUNCTION(globalFuncToBigInt);
    6263
    6364JS_EXPORT_PRIVATE double jsToNumber(StringView);
  • trunk/Source/JavaScriptCore/runtime/JSType.cpp

    r263134 r272170  
    8585    CASE(Float32ArrayType)
    8686    CASE(Float64ArrayType)
     87    CASE(BigInt64ArrayType)
     88    CASE(BigUint64ArrayType)
    8789    CASE(DataViewType)
    8890    CASE(GetterSetterType)
  • trunk/Source/JavaScriptCore/runtime/JSType.h

    r263134 r272170  
    8888    Float32ArrayType,
    8989    Float64ArrayType,
     90    BigInt64ArrayType,
     91    BigUint64ArrayType,
    9092    DataViewType,
    9193    // End JSArrayBufferView types.
     
    142144static constexpr uint32_t NumberOfTypedArrayTypes = LastTypedArrayType - FirstTypedArrayType + 1;
    143145static constexpr uint32_t NumberOfTypedArrayTypesExcludingDataView = NumberOfTypedArrayTypes - 1;
     146static constexpr uint32_t NumberOfTypedArrayTypesExcludingBigIntArraysAndDataView = NumberOfTypedArrayTypes - 3;
    144147
    145148static_assert(sizeof(JSType) == sizeof(uint8_t), "sizeof(JSType) is one byte.");
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayConstructors.cpp

    r261895 r272170  
    4444MAKE_S_INFO(Float32Array);
    4545MAKE_S_INFO(Float64Array);
     46MAKE_S_INFO(BigInt64Array);
     47MAKE_S_INFO(BigUint64Array);
    4648MAKE_S_INFO(DataView);
    4749
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayConstructors.h

    r253019 r272170  
    4141using JSFloat32ArrayConstructor = JSGenericTypedArrayViewConstructor<JSFloat32Array>;
    4242using JSFloat64ArrayConstructor = JSGenericTypedArrayViewConstructor<JSFloat64Array>;
     43using JSBigInt64ArrayConstructor = JSGenericTypedArrayViewConstructor<JSBigInt64Array>;
     44using JSBigUint64ArrayConstructor = JSGenericTypedArrayViewConstructor<JSBigUint64Array>;
    4345using JSDataViewConstructor = JSGenericTypedArrayViewConstructor<JSDataView>;
    4446STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSInt8ArrayConstructor, InternalFunction);
     
    5153STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFloat32ArrayConstructor, InternalFunction);
    5254STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFloat64ArrayConstructor, InternalFunction);
     55STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBigInt64ArrayConstructor, InternalFunction);
     56STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBigUint64ArrayConstructor, InternalFunction);
    5357STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSDataViewConstructor, InternalFunction);
    5458
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.cpp

    r261895 r272170  
    4848MAKE_S_INFO(Float32Array);
    4949MAKE_S_INFO(Float64Array);
     50MAKE_S_INFO(BigInt64Array);
     51MAKE_S_INFO(BigUint64Array);
    5052
    5153} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.h

    r218794 r272170  
    4040typedef JSGenericTypedArrayViewPrototype<JSFloat32Array> JSFloat32ArrayPrototype;
    4141typedef JSGenericTypedArrayViewPrototype<JSFloat64Array> JSFloat64ArrayPrototype;
     42typedef JSGenericTypedArrayViewPrototype<JSBigInt64Array> JSBigInt64ArrayPrototype;
     43typedef JSGenericTypedArrayViewPrototype<JSBigUint64Array> JSBigUint64ArrayPrototype;
    4244
    4345} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp

    r269531 r272170  
    7373    case TypeUint16:                                                                            \
    7474        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);                     \
    7579    case NotTypedArray:                                                                         \
    7680    case TypeDataView:                                                                          \
     
    8589    JSValue value = callFrame->uncheckedArgument(0);
    8690    return JSValue::encode(jsBoolean(value.isCell() && isTypedView(value.asCell()->classInfo(globalObject->vm())->typedArrayStorageType)));
     91}
     92
     93JSC_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)));
    8797}
    8898
     
    172182}
    173183
     184JSC_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
    174194JSC_DEFINE_HOST_FUNCTION(typedArrayViewPrivateFuncGetOriginalConstructor, (JSGlobalObject* globalObject, CallFrame* callFrame))
    175195{
     
    389409    case TypeUint16:
    390410        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));
    391415    case NotTypedArray:
    392416    case TypeDataView:
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.h

    r269531 r272170  
    5353
    5454JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncIsTypedArrayView);
     55JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncIsBigIntTypedArrayView);
    5556JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncIsSharedTypedArrayView);
    5657JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncIsDetached);
     
    5859JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncSort);
    5960JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncLength);
     61JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncContentType);
    6062JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncGetOriginalConstructor);
    6163JSC_DECLARE_HOST_FUNCTION(typedArrayViewPrivateFuncSubarrayCreate);
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrays.cpp

    r268640 r272170  
    6262MAKE_S_INFO(Float32);
    6363MAKE_S_INFO(Float64);
     64MAKE_S_INFO(BigInt64);
     65MAKE_S_INFO(BigUint64);
    6466
    6567MAKE_CONSTRUCTORS(DataView);
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrays.h

    r253143 r272170  
    4040using JSFloat32Array = JSGenericTypedArrayView<Float32Adaptor>;
    4141using JSFloat64Array = JSGenericTypedArrayView<Float64Adaptor>;
     42using JSBigInt64Array = JSGenericTypedArrayView<BigInt64Adaptor>;
     43using JSBigUint64Array = JSGenericTypedArrayView<BigUint64Adaptor>;
    4244
    4345JS_EXPORT_PRIVATE JSUint8Array* createUint8TypedArray(JSGlobalObject*, Structure*, RefPtr<ArrayBuffer>&&, unsigned byteOffset, unsigned length);
  • trunk/Source/JavaScriptCore/runtime/ToNativeFromValue.h

    r251425 r272170  
    2727
    2828#include "JSCJSValue.h"
     29#include "TypedArrayAdaptors.h"
    2930
    3031namespace JSC {
     
    3334typename Adaptor::Type toNativeFromValue(JSValue value)
    3435{
     36    // FIXME: BigInt
    3537    if (value.isInt32())
    3638        return Adaptor::toNativeFromInt32(value.asInt32());
     
    4143typename Adaptor::Type toNativeFromValue(JSGlobalObject* globalObject, JSValue value)
    4244{
    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    }
    4857}
    4958
     
    5160Optional<typename Adaptor::Type> toNativeFromValueWithoutCoercion(JSValue value)
    5261{
    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    }
    5876}
    5977
  • trunk/Source/JavaScriptCore/runtime/TypedArrayAdaptors.h

    r253143 r272170  
    2626#pragma once
    2727
     28#include "JSBigInt.h"
    2829#include "JSCJSValue.h"
    2930#include "MathCommon.h"
     
    4041    typedef ViewTypeArg ViewType;
    4142    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)
    4750    {
    4851        static_assert(!std::is_floating_point<Type>::value, "");
    4952        return jsNumber(value);
    50     }
    51    
    52     static double toDouble(Type value)
    53     {
    54         return static_cast<double>(value);
    5553    }
    5654   
     
    116114    typedef ViewTypeArg ViewType;
    117115    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)
    123123    {
    124124        return jsDoubleNumber(purifyNaN(value));
    125     }
    126 
    127     static double toDouble(Type value)
    128     {
    129         return static_cast<double>(value);
    130125    }
    131126
     
    170165
    171166        return valueResult;
     167    }
     168};
     169
     170template<
     171    typename TypeArg, typename ViewTypeArg, typename JSViewTypeArg,
     172    TypedArrayType typeValueArg>
     173struct 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);
    172208    }
    173209};
     
    182218struct Float32Adaptor;
    183219struct Float64Adaptor;
     220struct BigInt64Adaptor;
     221struct BigUint64Adaptor;
    184222
    185223template<typename Adaptor> class GenericTypedArrayView;
     
    193231typedef GenericTypedArrayView<Float32Adaptor> Float32Array;
    194232typedef GenericTypedArrayView<Float64Adaptor> Float64Array;
     233typedef GenericTypedArrayView<BigInt64Adaptor> BigInt64Array;
     234typedef GenericTypedArrayView<BigUint64Adaptor> BigUint64Array;
    195235
    196236template<typename Adaptor> class JSGenericTypedArrayView;
     
    204244using JSFloat32Array = JSGenericTypedArrayView<Float32Adaptor>;
    205245using JSFloat64Array = JSGenericTypedArrayView<Float64Adaptor>;
     246using JSBigInt64Array = JSGenericTypedArrayView<BigInt64Adaptor>;
     247using JSBigUint64Array = JSGenericTypedArrayView<BigUint64Adaptor>;
    206248
    207249struct Int8Adaptor : IntegralTypedArrayAdaptor<int8_t, Int8Array, JSInt8Array, TypeInt8> { };
     
    213255struct Float32Adaptor : FloatTypedArrayAdaptor<float, Float32Array, JSFloat32Array, TypeFloat32> { };
    214256struct Float64Adaptor : FloatTypedArrayAdaptor<double, Float64Array, JSFloat64Array, TypeFloat64> { };
     257struct BigInt64Adaptor : BigIntTypedArrayAdaptor<int64_t, BigInt64Array, JSBigInt64Array, TypeBigInt64> { };
     258struct BigUint64Adaptor : BigIntTypedArrayAdaptor<uint64_t, BigUint64Array, JSBigUint64Array, TypeBigUint64> { };
    215259
    216260struct Uint8ClampedAdaptor {
     
    218262    typedef Uint8ClampedArray ViewType;
    219263    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)
    225271    {
    226272        return jsNumber(value);
    227     }
    228 
    229     static double toDouble(uint8_t value)
    230     {
    231         return static_cast<double>(value);
    232273    }
    233274
  • trunk/Source/JavaScriptCore/runtime/TypedArrayType.cpp

    r261755 r272170  
    5454    case TypeFloat64:
    5555        return JSFloat64ArrayConstructor::info();
     56    case TypeBigInt64:
     57        return JSBigInt64ArrayConstructor::info();
     58    case TypeBigUint64:
     59        return JSBigUint64ArrayConstructor::info();
    5660    case TypeDataView:
    5761        return JSDataViewConstructor::info();
     
    100104        out.print("TypeFloat64");
    101105        return;
     106    case TypeBigInt64:
     107        out.print("TypeBigInt64");
     108        return;
     109    case TypeBigUint64:
     110        out.print("TypeBigUint64");
     111        return;
    102112    case TypeDataView:
    103113        out.print("TypeDataView");
  • trunk/Source/JavaScriptCore/runtime/TypedArrayType.h

    r233721 r272170  
    4343    macro(Uint32) \
    4444    macro(Float32) \
    45     macro(Float64)
     45    macro(Float64) \
     46    macro(BigInt64) \
     47    macro(BigUint64)
    4648
    4749#define FOR_EACH_TYPED_ARRAY_TYPE(macro) \
     
    5658};
    5759
     60enum class TypedArrayContentType : uint8_t {
     61    None,
     62    Number,
     63    BigInt,
     64};
     65
    5866#define ASSERT_TYPED_ARRAY_TYPE(name) \
    5967    static_assert(static_cast<uint32_t>(Type ## name) == (static_cast<uint32_t>(name ## ArrayType) - FirstTypedArrayType + static_cast<uint32_t>(TypeInt8)), "");
     
    8694}
    8795
     96inline 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
    88107inline unsigned logElementSize(TypedArrayType type)
    89108{
     
    104123        return 2;
    105124    case TypeFloat64:
     125    case TypeBigInt64:
     126    case TypeBigUint64:
    106127        return 3;
    107128    }
     
    160181}
    161182
     183inline 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
    162194inline bool isSigned(TypedArrayType type)
    163195{
     
    168200    case TypeFloat32:
    169201    case TypeFloat64:
     202    case TypeBigInt64:
    170203        return true;
    171204    default:
     
    179212}
    180213
     214inline 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
    181237} // namespace JSC
    182238
  • trunk/Source/JavaScriptCore/runtime/TypedArrays.h

    r206525 r272170  
    4040typedef GenericTypedArrayView<Float32Adaptor> Float32Array;
    4141typedef GenericTypedArrayView<Float64Adaptor> Float64Array;
     42typedef GenericTypedArrayView<BigInt64Adaptor> BigInt64Array;
     43typedef GenericTypedArrayView<BigUint64Adaptor> BigUint64Array;
    4244
    4345} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r270861 r272170  
    14721472DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(arrayIteratorSpace, cellHeapCellType.get(), JSArrayIterator)
    14731473DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(asyncGeneratorSpace, cellHeapCellType.get(), JSAsyncGenerator)
     1474DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(bigInt64ArraySpace, cellHeapCellType.get(), JSBigInt64Array)
    14741475DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(bigIntObjectSpace, cellHeapCellType.get(), BigIntObject)
     1476DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(bigUint64ArraySpace, cellHeapCellType.get(), JSBigUint64Array)
    14751477DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(booleanObjectSpace, cellHeapCellType.get(), BooleanObject)
    14761478DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(boundFunctionSpace, cellHeapCellType.get(), JSBoundFunction) // Hash:0xd7916d41
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r270861 r272170  
    494494    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(arrayIteratorSpace)
    495495    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(asyncGeneratorSpace)
     496    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(bigInt64ArraySpace)
    496497    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(bigIntObjectSpace)
     498    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(bigUint64ArraySpace)
    497499    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(booleanObjectSpace)
    498500    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(boundFunctionSpace)
Note: See TracChangeset for help on using the changeset viewer.