Changeset 225799 in webkit


Ignore:
Timestamp:
Dec 12, 2017 1:01:57 PM (6 years ago)
Author:
Caio Lima
Message:

[ESNext][BigInt] Implement BigInt literals and JSBigInt
https://bugs.webkit.org/show_bug.cgi?id=179000

Reviewed by Darin Adler and Yusuke Suzuki.

JSTests:

  • bigIntTests.yaml: Added.
  • stress/big-int-literal-line-terminator.js: Added.
  • stress/big-int-literals.js: Added.
  • stress/big-int-operations-error.js: Added.
  • stress/big-int-type-of.js: Added.
  • stress/big-int-white-space-trailing-leading.js: Added.
  • stress/big-int-function-apply.js: Added.

Source/JavaScriptCore:

This patch starts the implementation of BigInt primitive on
JavaScriptCore. We are introducing BigInt primitive and
implementing it on JSBigInt as a subclass of JSCell with BigIntData?
field implemented contiguosly on memory as inline storage of JSBigInt to
take advantages on performance due to cache locality. The
implementation allows 64 or 32 bitwise arithmetic operations.
JSBigInt also has m_sign to store the sign of BigIntData? and
m_length that keeps track of BigInt length.
The implementation is following the V8 one. BigIntData? is manipulated
by JSBigInt::setDigit(index, value) and JSBigInt::digit(index) operations.
We also have some operations to support arithmetics over digits.

It is important to notice that on our representation,
JSBigInt::dataStorage()[0] represents the least significant digit and
JSBigInt::dataStorage()[m_length - 1] represents the most siginificant digit.

We are also introducing into this Patch the BigInt literals lexer and
syntax parsing support. The operation Strict Equals on BigInts is also being
implemented to enable tests.
These features are being implemented behind a runtime flage "--useBigInt" and
are disabled by default.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • bytecode/CodeBlock.cpp:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitEqualityOp):
(JSC::BytecodeGenerator::addBigIntConstant):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::BigIntEntryHash::hash):
(JSC::BytecodeGenerator::BigIntEntryHash::equal):

  • bytecompiler/NodesCodegen.cpp:

(JSC::BigIntNode::jsValue const):

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::isToThisAnIdentity):

  • interpreter/Interpreter.cpp:

(JSC::sizeOfVarargs):

  • llint/LLIntData.cpp:

(JSC::LLInt::Data::performAssertions):

  • llint/LowLevelInterpreter.asm:
  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createBigInt):

  • parser/Lexer.cpp:

(JSC::Lexer<T>::parseBinary):
(JSC::Lexer<T>::parseOctal):
(JSC::Lexer<T>::parseDecimal):
(JSC::Lexer<T>::lex):
(JSC::Lexer<T>::parseHex): Deleted.

  • parser/Lexer.h:
  • parser/NodeConstructors.h:

(JSC::BigIntNode::BigIntNode):

  • parser/Nodes.h:

(JSC::ExpressionNode::isBigInt const):
(JSC::BigIntNode::value):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parsePrimaryExpression):

  • parser/ParserTokens.h:
  • parser/ResultType.h:

(JSC::ResultType::definitelyIsBigInt const):
(JSC::ResultType::mightBeBigInt const):
(JSC::ResultType::isNotBigInt const):
(JSC::ResultType::addResultType):
(JSC::ResultType::bigIntType):
(JSC::ResultType::forAdd):
(JSC::ResultType::forLogicalOp):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createBigInt):

  • runtime/CommonIdentifiers.h:
  • runtime/JSBigInt.cpp: Added.

(JSC::JSBigInt::visitChildren):
(JSC::JSBigInt::JSBigInt):
(JSC::JSBigInt::initialize):
(JSC::JSBigInt::createStructure):
(JSC::JSBigInt::createZero):
(JSC::JSBigInt::allocationSize):
(JSC::JSBigInt::createWithLength):
(JSC::JSBigInt::finishCreation):
(JSC::JSBigInt::toPrimitive const):
(JSC::JSBigInt::singleDigitValueForString):
(JSC::JSBigInt::parseInt):
(JSC::JSBigInt::toString):
(JSC::JSBigInt::isZero):
(JSC::JSBigInt::inplaceMultiplyAdd):
(JSC::JSBigInt::digitAdd):
(JSC::JSBigInt::digitSub):
(JSC::JSBigInt::digitMul):
(JSC::JSBigInt::digitPow):
(JSC::JSBigInt::digitDiv):
(JSC::JSBigInt::internalMultiplyAdd):
(JSC::JSBigInt::equalToBigInt):
(JSC::JSBigInt::absoluteDivSmall):
(JSC::JSBigInt::calculateMaximumCharactersRequired):
(JSC::JSBigInt::toStringGeneric):
(JSC::JSBigInt::rightTrim):
(JSC::JSBigInt::allocateFor):
(JSC::JSBigInt::estimatedSize):
(JSC::JSBigInt::toNumber const):
(JSC::JSBigInt::getPrimitiveNumber const):

  • runtime/JSBigInt.h: Added.

(JSC::JSBigInt::setSign):
(JSC::JSBigInt::sign const):
(JSC::JSBigInt::setLength):
(JSC::JSBigInt::length const):
(JSC::JSBigInt::parseInt):
(JSC::JSBigInt::offsetOfData):
(JSC::JSBigInt::dataStorage):
(JSC::JSBigInt::digit):
(JSC::JSBigInt::setDigit):
(JSC::asBigInt):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::synthesizePrototype const):
(JSC::JSValue::toStringSlowCase const):

  • runtime/JSCJSValue.h:
  • runtime/JSCJSValueInlines.h:

(JSC::JSValue::isBigInt const):
(JSC::JSValue::strictEqualSlowCaseInline):

  • runtime/JSCell.cpp:

(JSC::JSCell::put):
(JSC::JSCell::putByIndex):
(JSC::JSCell::toPrimitive const):
(JSC::JSCell::getPrimitiveNumber const):
(JSC::JSCell::toNumber const):
(JSC::JSCell::toObjectSlow const):

  • runtime/JSCell.h:
  • runtime/JSCellInlines.h:

(JSC::JSCell::isBigInt const):

  • runtime/JSType.h:
  • runtime/MathCommon.h:

(JSC::clz64):

  • runtime/NumberPrototype.cpp:
  • runtime/Operations.cpp:

(JSC::jsTypeStringForValue):
(JSC::jsIsObjectTypeOrNull):

  • runtime/Options.h:
  • runtime/ParseInt.h:
  • runtime/SmallStrings.h:

(JSC::SmallStrings::typeString const):

  • runtime/StructureInlines.h:

(JSC::prototypeForLookupPrimitiveImpl):

  • runtime/TypeofType.cpp:

(WTF::printInternal):

  • runtime/TypeofType.h:
  • runtime/VM.cpp:

(JSC::VM::VM):

  • runtime/VM.h:

Source/WTF:

  • wtf/HashFunctions.h:

Tools:

  • Scripts/run-jsc-stress-tests:
Location:
trunk
Files:
9 added
46 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r225768 r225799  
     12017-12-12  Caio Lima  <ticaiolima@gmail.com>
     2
     3        [ESNext][BigInt] Implement BigInt literals and JSBigInt
     4        https://bugs.webkit.org/show_bug.cgi?id=179000
     5
     6        Reviewed by Darin Adler and Yusuke Suzuki.
     7
     8        * bigIntTests.yaml: Added.
     9        * stress/big-int-literal-line-terminator.js: Added.
     10        * stress/big-int-literals.js: Added.
     11        * stress/big-int-operations-error.js: Added.
     12        * stress/big-int-type-of.js: Added.
     13        * stress/big-int-white-space-trailing-leading.js: Added.
     14        * stress/big-int-function-apply.js: Added.
     15
    1162017-12-11  Saam Barati  <sbarati@apple.com>
    217
  • trunk/Source/JavaScriptCore/ChangeLog

    r225788 r225799  
     12017-12-12  Caio Lima  <ticaiolima@gmail.com>
     2
     3        [ESNext][BigInt] Implement BigInt literals and JSBigInt
     4        https://bugs.webkit.org/show_bug.cgi?id=179000
     5
     6        Reviewed by Darin Adler and Yusuke Suzuki.
     7
     8        This patch starts the implementation of BigInt primitive on
     9        JavaScriptCore. We are introducing BigInt primitive and
     10        implementing it on JSBigInt as a subclass of JSCell with [[BigIntData]]
     11        field implemented contiguosly on memory as inline storage of JSBigInt to
     12        take advantages on performance due to cache locality. The
     13        implementation allows 64 or 32 bitwise arithmetic operations.
     14        JSBigInt also has m_sign to store the sign of [[BigIntData]] and
     15        m_length that keeps track of BigInt length.
     16        The implementation is following the V8 one. [[BigIntData]] is manipulated
     17        by JSBigInt::setDigit(index, value) and JSBigInt::digit(index) operations.
     18        We also have some operations to support arithmetics over digits.
     19
     20        It is important to notice that on our representation,
     21        JSBigInt::dataStorage()[0] represents the least significant digit and
     22        JSBigInt::dataStorage()[m_length - 1] represents the most siginificant digit.
     23
     24        We are also introducing into this Patch the BigInt literals lexer and
     25        syntax parsing support. The operation Strict Equals on BigInts is also being
     26        implemented to enable tests.
     27        These features are being implemented behind a runtime flage "--useBigInt" and
     28        are disabled by default.
     29
     30        * JavaScriptCore.xcodeproj/project.pbxproj:
     31        * Sources.txt:
     32        * bytecode/CodeBlock.cpp:
     33        * bytecompiler/BytecodeGenerator.cpp:
     34        (JSC::BytecodeGenerator::emitEqualityOp):
     35        (JSC::BytecodeGenerator::addBigIntConstant):
     36        * bytecompiler/BytecodeGenerator.h:
     37        (JSC::BytecodeGenerator::BigIntEntryHash::hash):
     38        (JSC::BytecodeGenerator::BigIntEntryHash::equal):
     39        * bytecompiler/NodesCodegen.cpp:
     40        (JSC::BigIntNode::jsValue const):
     41        * dfg/DFGAbstractInterpreterInlines.h:
     42        (JSC::DFG::isToThisAnIdentity):
     43        * interpreter/Interpreter.cpp:
     44        (JSC::sizeOfVarargs):
     45        * llint/LLIntData.cpp:
     46        (JSC::LLInt::Data::performAssertions):
     47        * llint/LowLevelInterpreter.asm:
     48        * parser/ASTBuilder.h:
     49        (JSC::ASTBuilder::createBigInt):
     50        * parser/Lexer.cpp:
     51        (JSC::Lexer<T>::parseBinary):
     52        (JSC::Lexer<T>::parseOctal):
     53        (JSC::Lexer<T>::parseDecimal):
     54        (JSC::Lexer<T>::lex):
     55        (JSC::Lexer<T>::parseHex): Deleted.
     56        * parser/Lexer.h:
     57        * parser/NodeConstructors.h:
     58        (JSC::BigIntNode::BigIntNode):
     59        * parser/Nodes.h:
     60        (JSC::ExpressionNode::isBigInt const):
     61        (JSC::BigIntNode::value):
     62        * parser/Parser.cpp:
     63        (JSC::Parser<LexerType>::parsePrimaryExpression):
     64        * parser/ParserTokens.h:
     65        * parser/ResultType.h:
     66        (JSC::ResultType::definitelyIsBigInt const):
     67        (JSC::ResultType::mightBeBigInt const):
     68        (JSC::ResultType::isNotBigInt const):
     69        (JSC::ResultType::addResultType):
     70        (JSC::ResultType::bigIntType):
     71        (JSC::ResultType::forAdd):
     72        (JSC::ResultType::forLogicalOp):
     73        * parser/SyntaxChecker.h:
     74        (JSC::SyntaxChecker::createBigInt):
     75        * runtime/CommonIdentifiers.h:
     76        * runtime/JSBigInt.cpp: Added.
     77        (JSC::JSBigInt::visitChildren):
     78        (JSC::JSBigInt::JSBigInt):
     79        (JSC::JSBigInt::initialize):
     80        (JSC::JSBigInt::createStructure):
     81        (JSC::JSBigInt::createZero):
     82        (JSC::JSBigInt::allocationSize):
     83        (JSC::JSBigInt::createWithLength):
     84        (JSC::JSBigInt::finishCreation):
     85        (JSC::JSBigInt::toPrimitive const):
     86        (JSC::JSBigInt::singleDigitValueForString):
     87        (JSC::JSBigInt::parseInt):
     88        (JSC::JSBigInt::toString):
     89        (JSC::JSBigInt::isZero):
     90        (JSC::JSBigInt::inplaceMultiplyAdd):
     91        (JSC::JSBigInt::digitAdd):
     92        (JSC::JSBigInt::digitSub):
     93        (JSC::JSBigInt::digitMul):
     94        (JSC::JSBigInt::digitPow):
     95        (JSC::JSBigInt::digitDiv):
     96        (JSC::JSBigInt::internalMultiplyAdd):
     97        (JSC::JSBigInt::equalToBigInt):
     98        (JSC::JSBigInt::absoluteDivSmall):
     99        (JSC::JSBigInt::calculateMaximumCharactersRequired):
     100        (JSC::JSBigInt::toStringGeneric):
     101        (JSC::JSBigInt::rightTrim):
     102        (JSC::JSBigInt::allocateFor):
     103        (JSC::JSBigInt::estimatedSize):
     104        (JSC::JSBigInt::toNumber const):
     105        (JSC::JSBigInt::getPrimitiveNumber const):
     106        * runtime/JSBigInt.h: Added.
     107        (JSC::JSBigInt::setSign):
     108        (JSC::JSBigInt::sign const):
     109        (JSC::JSBigInt::setLength):
     110        (JSC::JSBigInt::length const):
     111        (JSC::JSBigInt::parseInt):
     112        (JSC::JSBigInt::offsetOfData):
     113        (JSC::JSBigInt::dataStorage):
     114        (JSC::JSBigInt::digit):
     115        (JSC::JSBigInt::setDigit):
     116        (JSC::asBigInt):
     117        * runtime/JSCJSValue.cpp:
     118        (JSC::JSValue::synthesizePrototype const):
     119        (JSC::JSValue::toStringSlowCase const):
     120        * runtime/JSCJSValue.h:
     121        * runtime/JSCJSValueInlines.h:
     122        (JSC::JSValue::isBigInt const):
     123        (JSC::JSValue::strictEqualSlowCaseInline):
     124        * runtime/JSCell.cpp:
     125        (JSC::JSCell::put):
     126        (JSC::JSCell::putByIndex):
     127        (JSC::JSCell::toPrimitive const):
     128        (JSC::JSCell::getPrimitiveNumber const):
     129        (JSC::JSCell::toNumber const):
     130        (JSC::JSCell::toObjectSlow const):
     131        * runtime/JSCell.h:
     132        * runtime/JSCellInlines.h:
     133        (JSC::JSCell::isBigInt const):
     134        * runtime/JSType.h:
     135        * runtime/MathCommon.h:
     136        (JSC::clz64):
     137        * runtime/NumberPrototype.cpp:
     138        * runtime/Operations.cpp:
     139        (JSC::jsTypeStringForValue):
     140        (JSC::jsIsObjectTypeOrNull):
     141        * runtime/Options.h:
     142        * runtime/ParseInt.h:
     143        * runtime/SmallStrings.h:
     144        (JSC::SmallStrings::typeString const):
     145        * runtime/StructureInlines.h:
     146        (JSC::prototypeForLookupPrimitiveImpl):
     147        * runtime/TypeofType.cpp:
     148        (WTF::printInternal):
     149        * runtime/TypeofType.h:
     150        * runtime/VM.cpp:
     151        (JSC::VM::VM):
     152        * runtime/VM.h:
     153
    11542017-12-12  Guillaume Emont  <guijemont@igalia.com>
    2155
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r225725 r225799  
    806806                2D342F36F7244096804ADB24 /* SourceOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = 425BA1337E4344E1B269A671 /* SourceOrigin.h */; settings = {ATTRIBUTES = (Private, ); }; };
    807807                371D842D17C98B6E00ECF994 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 371D842C17C98B6E00ECF994 /* libz.dylib */; };
    808                 37C738D21EDB56E4003F2B0B /* ParseInt.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C738D11EDB5672003F2B0B /* ParseInt.h */; };
     808                37C738D21EDB56E4003F2B0B /* ParseInt.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C738D11EDB5672003F2B0B /* ParseInt.h */; settings = {ATTRIBUTES = (Private, ); }; };
    809809                412952771D2CF6BC00E78B89 /* builtins_generate_internals_wrapper_header.py in Headers */ = {isa = PBXBuildFile; fileRef = 412952731D2CF6AC00E78B89 /* builtins_generate_internals_wrapper_header.py */; settings = {ATTRIBUTES = (Private, ); }; };
    810810                412952781D2CF6BC00E78B89 /* builtins_generate_internals_wrapper_implementation.py in Headers */ = {isa = PBXBuildFile; fileRef = 412952741D2CF6AC00E78B89 /* builtins_generate_internals_wrapper_implementation.py */; settings = {ATTRIBUTES = (Private, ); }; };
     
    11431143                86704B8A12DBA33700A9FE7B /* YarrPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B8312DBA33700A9FE7B /* YarrPattern.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11441144                868916B0155F286300CB2B9A /* PrivateName.h in Headers */ = {isa = PBXBuildFile; fileRef = 868916A9155F285400CB2B9A /* PrivateName.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1145                868921C21F9C0CB7001159F6 /* JSBigInt.h in Headers */ = {isa = PBXBuildFile; fileRef = 868921C11F9C0CB7001159F6 /* JSBigInt.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11451146                869EBCB70E8C6D4A008722CC /* ResultType.h in Headers */ = {isa = PBXBuildFile; fileRef = 869EBCB60E8C6D4A008722CC /* ResultType.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11461147                86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 86ADD1430FDDEA980006EEC2 /* ARMv7Assembler.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    36793680                86880F4C14353B2100B08D42 /* DFGSpeculativeJIT64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGSpeculativeJIT64.cpp; path = dfg/DFGSpeculativeJIT64.cpp; sourceTree = "<group>"; };
    36803681                868916A9155F285400CB2B9A /* PrivateName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateName.h; sourceTree = "<group>"; };
     3682                868921C11F9C0CB7001159F6 /* JSBigInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBigInt.h; sourceTree = "<group>"; };
     3683                868921C31F9C2947001159F6 /* JSBigInt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBigInt.cpp; sourceTree = "<group>"; };
    36813684                869EBCB60E8C6D4A008722CC /* ResultType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResultType.h; sourceTree = "<group>"; };
    36823685                86A054461556451B00445157 /* LowLevelInterpreter.asm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm.asm; name = LowLevelInterpreter.asm; path = llint/LowLevelInterpreter.asm; sourceTree = "<group>"; };
     
    64956498                                E35E035D1B7AB43E0073AD2A /* InspectorInstrumentationObject.cpp */,
    64966499                                E35E035E1B7AB43E0073AD2A /* InspectorInstrumentationObject.h */,
    6497                                 A7A8AF2B17ADB5F3005AB174 /* Int8Array.h */,
    64986500                                A7A8AF2C17ADB5F3005AB174 /* Int16Array.h */,
    64996501                                A7A8AF2D17ADB5F3005AB174 /* Int32Array.h */,
     6502                                A7A8AF2B17ADB5F3005AB174 /* Int8Array.h */,
    65006503                                BC9BB95B0E19680600DF8855 /* InternalFunction.cpp */,
    65016504                                BC11667A0E199C05008066DD /* InternalFunction.h */,
     
    65456548                                8BC064871E1A583F00B2B8CA /* JSAsyncGeneratorFunction.cpp */,
    65466549                                8BC064881E1A584000B2B8CA /* JSAsyncGeneratorFunction.h */,
     6550                                868921C31F9C2947001159F6 /* JSBigInt.cpp */,
     6551                                868921C11F9C0CB7001159F6 /* JSBigInt.h */,
    65476552                                86FA9E8F142BBB2D001773B7 /* JSBoundFunction.cpp */,
    65486553                                86FA9E90142BBB2E001773B7 /* JSBoundFunction.h */,
     
    65966601                                BC756FC70E2031B200DE7D12 /* JSGlobalObjectFunctions.h */,
    65976602                                79B819921DD25CF500DDC714 /* JSGlobalObjectInlines.h */,
    6598                                 0F2B66C917B6B5AB00A7AE3F /* JSInt8Array.h */,
    65996603                                0F2B66CA17B6B5AB00A7AE3F /* JSInt16Array.h */,
    66006604                                0F2B66CB17B6B5AB00A7AE3F /* JSInt32Array.h */,
     6605                                0F2B66C917B6B5AB00A7AE3F /* JSInt8Array.h */,
    66016606                                E33F507E1B8429A400413856 /* JSInternalPromise.cpp */,
    66026607                                E33F507F1B8429A400413856 /* JSInternalPromise.h */,
     
    66876692                                53917E7C1B791106000EBD33 /* JSTypedArrayViewPrototype.h */,
    66886693                                6507D2970E871E4A00D7D896 /* JSTypeInfo.h */,
     6694                                0F2B66D417B6B5AB00A7AE3F /* JSUint16Array.h */,
     6695                                0F2B66D517B6B5AB00A7AE3F /* JSUint32Array.h */,
    66896696                                0F2B66D217B6B5AB00A7AE3F /* JSUint8Array.h */,
    66906697                                0F2B66D317B6B5AB00A7AE3F /* JSUint8ClampedArray.h */,
    6691                                 0F2B66D417B6B5AB00A7AE3F /* JSUint16Array.h */,
    6692                                 0F2B66D517B6B5AB00A7AE3F /* JSUint32Array.h */,
    66936698                                A7CA3AE117DA41AE006538AF /* JSWeakMap.cpp */,
    66946699                                A7CA3AE217DA41AE006538AF /* JSWeakMap.h */,
     
    69046909                                0F2D4DE319832D91007D4B19 /* TypeSet.cpp */,
    69056910                                0F2D4DE419832D91007D4B19 /* TypeSet.h */,
    6906                                 A7A8AF3017ADB5F3005AB174 /* Uint8Array.h */,
    6907                                 A7A8AF3117ADB5F3005AB174 /* Uint8ClampedArray.h */,
    69086911                                A7A8AF3217ADB5F3005AB174 /* Uint16Array.h */,
    69096912                                866739D113BFDE710023D87C /* Uint16WithFraction.h */,
    69106913                                A7A8AF3317ADB5F3005AB174 /* Uint32Array.h */,
     6914                                A7A8AF3017ADB5F3005AB174 /* Uint8Array.h */,
     6915                                A7A8AF3117ADB5F3005AB174 /* Uint8ClampedArray.h */,
    69116916                                0FE050231AA9095600D33B33 /* VarOffset.cpp */,
    69126917                                0FE050241AA9095600D33B33 /* VarOffset.h */,
     
    80408045                                0F5CF9891E9ED65200C18692 /* AirStackAllocation.h in Headers */,
    80418046                                0FEC858C1BDACDC70080FF74 /* AirStackSlot.h in Headers */,
    8042                                 0F41545B1FD20B22001B58F6 /* ConstraintConcurrency.h in Headers */,
    80438047                                0F2BBD9E1C5FF4050023EF23 /* AirStackSlotKind.h in Headers */,
    80448048                                0FEC858E1BDACDC70080FF74 /* AirTmp.h in Headers */,
     
    80518055                                0FEC3C531F33A41600F59B6C /* AlignedMemoryAllocator.h in Headers */,
    80528056                                0FA7620B1DB959F900B7A2FD /* AllocatingScope.h in Headers */,
     8057                                0FDCE11C1FAE6209006F3901 /* AllocationFailureMode.h in Headers */,
    80538058                                0F96303A1D4192C8005609D9 /* AllocatorAttributes.h in Headers */,
     8059                                0F30CB5E1FCE4E37004B5323 /* AllocatorForMode.h in Headers */,
    80548060                                0F3730911C0CD70C00052BFA /* AllowMacroScratchRegisterUsage.h in Headers */,
    80558061                                A5EA70E919F5B1010098F5EC /* AlternateDispatchableAgent.h in Headers */,
     
    80598065                                BCF605140E203EF800B9A64D /* ArgList.h in Headers */,
    80608066                                0FE050141AA9091100D33B33 /* ArgumentsMode.h in Headers */,
    8061                                 0FBF92BA1FD7700400AC28A8 /* InferredStructureWatchpoint.h in Headers */,
    80628067                                79A228361D35D71F00D8E067 /* ArithProfile.h in Headers */,
    80638068                                0F6B1CB91861244C00845D97 /* ArityCheckMode.h in Headers */,
     
    80668071                                86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */,
    80678072                                65C0285D1717966800351E35 /* ARMv7DOpcode.h in Headers */,
    8068                                 0FDCE1321FB11DA4006F3901 /* IsoAlignedMemoryAllocator.h in Headers */,
    80698073                                0F8335B81639C1EA001443B5 /* ArrayAllocationProfile.h in Headers */,
    80708074                                A7A8AF3517ADB5F3005AB174 /* ArrayBuffer.h in Headers */,
     
    81168120                                0F33FCFB1C1625BE00323F67 /* B3CFG.h in Headers */,
    81178121                                0FEC85061BDACDAC0080FF74 /* B3CheckSpecial.h in Headers */,
    8118                                 FE2B0B731FD9EF700075DA5F /* JSCPoison.h in Headers */,
    81198122                                0FEC85081BDACDAC0080FF74 /* B3CheckValue.h in Headers */,
    81208123                                0FEC850A1BDACDAC0080FF74 /* B3Common.h in Headers */,
    8121                                 0FDCE12D1FAFB4E5006F3901 /* IsoSubspace.h in Headers */,
    81228124                                0FEC850C1BDACDAC0080FF74 /* B3Commutativity.h in Headers */,
    81238125                                0F338E0C1BF0276C0013C88F /* B3Compilation.h in Headers */,
     
    81718173                                0F37308D1C0BD29100052BFA /* B3PhiChildren.h in Headers */,
    81728174                                0FEC852C1BDACDAC0080FF74 /* B3Procedure.h in Headers */,
    8173                                 FE2B0B691FD227E00075DA5F /* JSCPoisonedPtr.h in Headers */,
    81748175                                0FEC852D1BDACDAC0080FF74 /* B3ProcedureInlines.h in Headers */,
    81758176                                0F725CAA1C503DED00AD943A /* B3PureCSE.h in Headers */,
     
    82448245                                0F885E111849A3BE00F1E3FA /* BytecodeUseDef.h in Headers */,
    82458246                                0F8023EA1613832B00A0BA45 /* ByValInfo.h in Headers */,
    8246                                 0F4D8C751FC7A97D001D32AC /* ConstraintParallelism.h in Headers */,
    82478247                                65B8392E1BACAD360044E824 /* CachedRecovery.h in Headers */,
    82488248                                0FEC3C601F379F5300F59B6C /* CagedBarrierPtr.h in Headers */,
     
    82898289                                0FD82E39141AB14D00179C94 /* CompactJITCodeMap.h in Headers */,
    82908290                                A7E5A3A81797432D00E893C0 /* CompilationResult.h in Headers */,
     8291                                0FDCE12A1FAFA85F006F3901 /* CompleteSubspace.h in Headers */,
    82918292                                BC18C3F40E16F5CD00B34460 /* Completion.h in Headers */,
    82928293                                0F6FC751196110A800E1D02D /* ComplexGetStatus.h in Headers */,
     
    83008301                                A5FD0074189B038C00633231 /* ConsoleTypes.h in Headers */,
    83018302                                0FFC99D1184EC8AD009C10AB /* ConstantMode.h in Headers */,
     8303                                0F41545B1FD20B22001B58F6 /* ConstraintConcurrency.h in Headers */,
     8304                                0F4D8C751FC7A97D001D32AC /* ConstraintParallelism.h in Headers */,
    83028305                                0F7DF1341E2970D70095951B /* ConstraintVolatility.h in Headers */,
    83038306                                E354622B1B6065D100545386 /* ConstructAbility.h in Headers */,
     
    83388341                                A704D90317A0BAA8006BA554 /* DFGAbstractInterpreter.h in Headers */,
    83398342                                A704D90417A0BAA8006BA554 /* DFGAbstractInterpreterInlines.h in Headers */,
    8340                                 0F6453181FD246A7002432A1 /* MarkStackMergingConstraint.h in Headers */,
    83418343                                0F620177143FCD3F0068B77C /* DFGAbstractValue.h in Headers */,
    83428344                                0FD3E4021B618AAF00C80E1E /* DFGAdaptiveInferredPropertyValueWatchpoint.h in Headers */,
     
    85488550                                FE1C0FFD1B193E9800B53FCA /* Exception.h in Headers */,
    85498551                                FE6029D91D6E1E4F0030204D /* ExceptionEventLocation.h in Headers */,
    8550                                 0F30CB5E1FCE4E37004B5323 /* AllocatorForMode.h in Headers */,
    85518552                                0F12DE101979D5FD0006FF4E /* ExceptionFuzz.h in Headers */,
    85528553                                BC18C4000E16F5CD00B34460 /* ExceptionHelpers.h in Headers */,
     
    86358636                                0F2B66AE17B6B54500A7AE3F /* GCIncomingRefCountedSet.h in Headers */,
    86368637                                0F2B66AF17B6B54500A7AE3F /* GCIncomingRefCountedSetInlines.h in Headers */,
    8637                                 0FBF92B91FD76FFF00AC28A8 /* InferredStructure.h in Headers */,
    86388638                                2AABCDE718EF294200002096 /* GCLogging.h in Headers */,
    86398639                                0F9715311EB28BEE00A1645D /* GCRequest.h in Headers */,
     
    86668666                                70B791951C024A28002481E2 /* GeneratorFunctionConstructor.h in Headers */,
    86678667                                70B791971C024A29002481E2 /* GeneratorFunctionPrototype.h in Headers */,
    8668                                 0FDCE12A1FAFA85F006F3901 /* CompleteSubspace.h in Headers */,
    86698668                                70B791991C024A29002481E2 /* GeneratorPrototype.h in Headers */,
    86708669                                70B7919D1C024A56002481E2 /* GeneratorPrototype.lut.h in Headers */,
     
    86938692                                DC3D2B0A1D34316200BA918C /* HeapCell.h in Headers */,
    86948693                                0F070A491D543A93006E7232 /* HeapCellInlines.h in Headers */,
     8694                                0FDCE1221FAE858C006F3901 /* HeapCellType.h in Headers */,
    86958695                                0F0CAEFF1EC4DA8800970D12 /* HeapFinalizerCallback.h in Headers */,
    86968696                                0F32BD111BB34F190093A57F /* HeapHelperPool.h in Headers */,
     
    87138713                                0FB7F39B15ED8E4600F167B2 /* IndexingType.h in Headers */,
    87148714                                14386A791DD6989C008652C4 /* IndirectEvalExecutable.h in Headers */,
     8715                                0FBF92B91FD76FFF00AC28A8 /* InferredStructure.h in Headers */,
     8716                                0FBF92BA1FD7700400AC28A8 /* InferredStructureWatchpoint.h in Headers */,
    87158717                                0F0A75231B94BFA900110660 /* InferredType.h in Headers */,
    87168718                                0FFC92121B94D4DF0071DD66 /* InferredTypeTable.h in Headers */,
     
    87748776                                860BD801148EA6F200112B2F /* Intrinsic.h in Headers */,
    87758777                                534E03541E53BD2900213F64 /* IntrinsicGetterAccessCase.h in Headers */,
     8778                                0FDCE1321FB11DA4006F3901 /* IsoAlignedMemoryAllocator.h in Headers */,
     8779                                0FDCE12D1FAFB4E5006F3901 /* IsoSubspace.h in Headers */,
    87768780                                8B9F6D561D5912FA001C739F /* IterationKind.h in Headers */,
    87778781                                FE4D55B81AE716CA0052E459 /* IterationStatus.h in Headers */,
     
    88158819                                0F2B66E717B6B5AB00A7AE3F /* JSArrayBufferPrototype.h in Headers */,
    88168820                                0F2B66E917B6B5AB00A7AE3F /* JSArrayBufferView.h in Headers */,
    8817                                 0F9DAA091FD1C3CF0079C5B2 /* MarkingConstraintSolver.h in Headers */,
    88188821                                0F2B66EA17B6B5AB00A7AE3F /* JSArrayBufferViewInlines.h in Headers */,
    88198822                                539FB8BA1C99DA7C00940FA1 /* JSArrayInlines.h in Headers */,
     
    88228825                                BC18C4180E16F5CD00B34460 /* JSBase.h in Headers */,
    88238826                                140D17D70E8AD4A9000CD17D /* JSBasePrivate.h in Headers */,
     8827                                868921C21F9C0CB7001159F6 /* JSBigInt.h in Headers */,
    88248828                                86FA9E92142BBB2E001773B7 /* JSBoundFunction.h in Headers */,
    88258829                                BC18C4190E16F5CD00B34460 /* JSCallbackConstructor.h in Headers */,
     
    88438847                                A5D2E665195E174000A518E7 /* JSContextRefInternal.h in Headers */,
    88448848                                148CD1D8108CF902008163C6 /* JSContextRefPrivate.h in Headers */,
     8849                                FE2B0B731FD9EF700075DA5F /* JSCPoison.h in Headers */,
     8850                                FE2B0B691FD227E00075DA5F /* JSCPoisonedPtr.h in Headers */,
     8851                                FE2B0B691FD227E00075DA5F /* JSCScrambledPtr.h in Headers */,
    88458852                                A72028B81797601E0098028C /* JSCTestRunnerUtils.h in Headers */,
    88468853                                72AAF7CE1D0D31B3005E60BE /* JSCustomGetterSetterFunction.h in Headers */,
     
    89038910                                D9722752DC54459B9125B539 /* JSModuleLoader.h in Headers */,
    89048911                                E318CBC11B8AEF5100A2929D /* JSModuleNamespaceObject.h in Headers */,
    8905                                 0FDCE11C1FAE6209006F3901 /* AllocationFailureMode.h in Headers */,
    89068912                                E39DA4A71B7E8B7C0084F33A /* JSModuleRecord.h in Headers */,
    89078913                                E33E8D1D1B9013C300346B52 /* JSNativeStdFunction.h in Headers */,
     
    89338939                                BDFCB2BBE90F41349E1B0BED /* JSSourceCode.h in Headers */,
    89348940                                BC18C4270E16F5CD00B34460 /* JSString.h in Headers */,
     8941                                0F7DF13F1E2AFC4D0095951B /* JSStringHeapCellType.h in Headers */,
    89358942                                FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */,
    89368943                                70EC0EC31AA0D7DA00B6AAFA /* JSStringIterator.h in Headers */,
     
    89398946                                BC18C4290E16F5CD00B34460 /* JSStringRefCF.h in Headers */,
    89408947                                1A28D4A8177B71C80007FA3C /* JSStringRefPrivate.h in Headers */,
    8941                                 0F7DF13F1E2AFC4D0095951B /* JSStringHeapCellType.h in Headers */,
    89428948                                0F919D0D157EE0A2004A4E7D /* JSSymbolTableObject.h in Headers */,
    89438949                                70ECA6061AFDBEA200449739 /* JSTemplateRegistryKey.h in Headers */,
     
    89648970                                A7482B9311671147003B0712 /* JSWeakObjectMapRefPrivate.h in Headers */,
    89658971                                0F0B286B1EB8E6CF000EB5D2 /* JSWeakPrivate.h in Headers */,
    8966                                 0F4D8C741FC7A97A001D32AC /* VisitCounter.h in Headers */,
    89678972                                709FB8681AE335C60039D069 /* JSWeakSet.h in Headers */,
    89688973                                AD5C36EB1F75AD73000BCAAF /* JSWebAssembly.h in Headers */,
     
    90409045                                0F660E381E0517BB0031462C /* MarkingConstraint.h in Headers */,
    90419046                                0F660E3A1E0517C10031462C /* MarkingConstraintSet.h in Headers */,
     9047                                0F9DAA091FD1C3CF0079C5B2 /* MarkingConstraintSolver.h in Headers */,
    90429048                                142D6F1213539A4100B02E86 /* MarkStack.h in Headers */,
     9049                                0F6453181FD246A7002432A1 /* MarkStackMergingConstraint.h in Headers */,
    90439050                                8612E4CD152389EC00C836BE /* MatchResult.h in Headers */,
    90449051                                4340A4851A9051AF00D73CCA /* MathCommon.h in Headers */,
     
    90849091                                0FD3E40A1B618B6600C80E1E /* ObjectPropertyCondition.h in Headers */,
    90859092                                0FD3E40C1B618B6600C80E1E /* ObjectPropertyConditionSet.h in Headers */,
    9086                                 0F4D8C781FCA3CFA001D32AC /* SimpleMarkingConstraint.h in Headers */,
    90879093                                BC18C4460E16F5CD00B34460 /* ObjectPrototype.h in Headers */,
    90889094                                E124A8F70E555775003091F1 /* OpaqueJSString.h in Headers */,
     
    90929098                                BC18C4480E16F5CD00B34460 /* Operations.h in Headers */,
    90939099                                0FE228ED1436AB2700196C48 /* Options.h in Headers */,
     9100                                0F9DAA0A1FD1C3D30079C5B2 /* ParallelSourceAdapter.h in Headers */,
    90949101                                37C738D21EDB56E4003F2B0B /* ParseInt.h in Headers */,
    90959102                                BC18C44B0E16F5CD00B34460 /* Parser.h in Headers */,
     
    92119218                                DC17E8191C9C91DB008A6AB3 /* ShadowChickenInlines.h in Headers */,
    92129219                                FE3022D31E3D73A500BAC493 /* SigillCrashAnalyzer.h in Headers */,
     9220                                0F4D8C781FCA3CFA001D32AC /* SimpleMarkingConstraint.h in Headers */,
    92139221                                0F2B670517B6B5AB00A7AE3F /* SimpleTypedArrayController.h in Headers */,
    92149222                                14BA78F113AAB88F005B7C2C /* SlotVisitor.h in Headers */,
     
    92929300                                0F2B670617B6B5AB00A7AE3F /* TypedArrayAdaptors.h in Headers */,
    92939301                                0F2B670817B6B5AB00A7AE3F /* TypedArrayController.h in Headers */,
    9294                                 0F9DAA0A1FD1C3D30079C5B2 /* ParallelSourceAdapter.h in Headers */,
    92959302                                0F4B94DC17B9F07500DD03A4 /* TypedArrayInlines.h in Headers */,
    92969303                                0F2B670917B6B5AB00A7AE3F /* TypedArrays.h in Headers */,
     
    93029309                                52C952B719A289850069B386 /* TypeProfiler.h in Headers */,
    93039310                                0F2D4DEC19832DC4007D4B19 /* TypeProfilerLog.h in Headers */,
    9304                                 0FDCE1221FAE858C006F3901 /* HeapCellType.h in Headers */,
    93059311                                0F2D4DF019832DD6007D4B19 /* TypeSet.h in Headers */,
    93069312                                0FF4274B158EBE91004CB9FF /* udis86.h in Headers */,
     
    93339339                                0FE0502D1AA9095600D33B33 /* VarOffset.h in Headers */,
    93349340                                0F426A491460CBB700131F8F /* VirtualRegister.h in Headers */,
     9341                                0F4D8C741FC7A97A001D32AC /* VisitCounter.h in Headers */,
    93359342                                0F952AA11DF7860900E06FBD /* VisitRaceKey.h in Headers */,
    93369343                                BC18C4200E16F5CD00B34460 /* VM.h in Headers */,
  • trunk/Source/JavaScriptCore/Sources.txt

    r225725 r225799  
    773773runtime/JSAsyncFunction.cpp
    774774runtime/JSAsyncGeneratorFunction.cpp
     775runtime/JSBigInt.cpp
    775776runtime/JSBoundFunction.cpp
    776777runtime/JSCJSValue.cpp
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r225618 r225799  
    5454#include "JIT.h"
    5555#include "JITMathIC.h"
     56#include "JSBigInt.h"
    5657#include "JSCInlines.h"
    5758#include "JSCJSValue.h"
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r225385 r225799  
    4040#include "Interpreter.h"
    4141#include "JSAsyncGeneratorFunction.h"
     42#include "JSBigInt.h"
    4243#include "JSCInlines.h"
    4344#include "JSFixedArray.h"
     
    17851786                return dst;
    17861787            }
     1788            if (Options::useBigInt() && value == "bigint") {
     1789                rewindUnaryOp();
     1790                emitOpcode(op_is_cell_with_type);
     1791                instructions().append(dst->index());
     1792                instructions().append(srcIndex);
     1793                instructions().append(BigIntType);
     1794                return dst;
     1795            }
    17871796            if (value == "object") {
    17881797                rewindUnaryOp();
     
    31223131}
    31233132
     3133JSValue BytecodeGenerator::addBigIntConstant(const Identifier& identifier, uint8_t radix)
     3134{
     3135    return m_bigIntMap.ensure(BigIntMapEntry(identifier.impl(), radix), [&] {
     3136        JSBigInt* bigIntInMap = JSBigInt::parseInt(nullptr, *vm(), identifier.string(), radix);
     3137        // FIXME: [ESNext] Enables a way to throw an error on ByteCodeGenerator step
     3138        // https://bugs.webkit.org/show_bug.cgi?id=180139
     3139        RELEASE_ASSERT(bigIntInMap);
     3140        addConstantValue(bigIntInMap);
     3141
     3142        return bigIntInMap;
     3143    }).iterator->value;
     3144}
     3145
    31243146JSString* BytecodeGenerator::addStringConstant(const Identifier& identifier)
    31253147{
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r225385 r225799  
    3535#include "Interpreter.h"
    3636#include "JSAsyncGeneratorFunction.h"
     37#include "JSBigInt.h"
    3738#include "JSGeneratorFunction.h"
    3839#include "Label.h"
     
    4748#include <functional>
    4849#include <wtf/CheckedArithmetic.h>
     50#include <wtf/HashFunctions.h>
    4951#include <wtf/SegmentedVector.h>
    5052#include <wtf/SetForScope.h>
     
    10011003        void allocateAndEmitScope();
    10021004
    1003         typedef HashMap<double, JSValue> NumberMap;
    1004         typedef HashMap<UniquedStringImpl*, JSString*, IdentifierRepHash> IdentifierStringMap;
    1005         typedef HashMap<Ref<TemplateRegistryKey>, RegisterID*> TemplateRegistryKeyMap;
    1006        
     1005        using BigIntMapEntry = std::pair<UniquedStringImpl*, uint8_t>;
     1006
     1007        using NumberMap = HashMap<double, JSValue>;
     1008        using IdentifierStringMap = HashMap<UniquedStringImpl*, JSString*, IdentifierRepHash>;
     1009        using IdentifierBigIntMap = HashMap<BigIntMapEntry, JSBigInt*>;
     1010        using TemplateRegistryKeyMap = HashMap<Ref<TemplateRegistryKey>, RegisterID*>;
     1011
    10071012        // Helper for emitCall() and emitConstruct(). This works because the set of
    10081013        // expected functions have identical behavior for both call and construct
     
    10871092    public:
    10881093        JSString* addStringConstant(const Identifier&);
     1094        JSValue addBigIntConstant(const Identifier&, uint8_t radix);
    10891095        RegisterID* addTemplateRegistryKeyConstant(Ref<TemplateRegistryKey>&&);
    10901096
     
    11861192        JSValueMap m_jsValueMap;
    11871193        IdentifierStringMap m_stringMap;
     1194        IdentifierBigIntMap m_bigIntMap;
    11881195        TemplateRegistryKeyMap m_templateRegistryKeyMap;
    11891196
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r224280 r225799  
    121121{
    122122    return generator.addStringConstant(m_value);
     123}
     124
     125JSValue BigIntNode::jsValue(BytecodeGenerator& generator) const
     126{
     127    return generator.addBigIntConstant(m_value, m_radix);
    123128}
    124129
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r225307 r225799  
    178178        valueForNode.m_structure.forEach([&](RegisteredStructure structure) {
    179179            TypeInfo type = structure->typeInfo();
    180             ASSERT(type.isObject() || type.type() == StringType || type.type() == SymbolType);
     180            ASSERT(type.isObject() || type.type() == StringType || type.type() == SymbolType || type.type() == BigIntType);
    181181            if (!isStrictMode)
    182182                ASSERT(type.isObject());
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r224862 r225799  
    203203    case StringType:
    204204    case SymbolType:
     205    case BigIntType:
    205206        throwException(callFrame, scope, createInvalidFunctionApplyParameterError(callFrame,  arguments));
    206207        return 0;
  • trunk/Source/JavaScriptCore/llint/LLIntData.cpp

    r221954 r225799  
    168168
    169169    {
    170         uint32_t bits = 0x120000;
     170        uint32_t bits = 0x480000;
    171171        UNUSED_PARAM(bits);
    172172        ArithProfile arithProfile;
     
    178178    }
    179179    {
    180         uint32_t bits = 0x220000;
     180        uint32_t bits = 0x880000;
    181181        UNUSED_PARAM(bits);
    182182        ArithProfile arithProfile;
     
    188188    }
    189189    {
    190         uint32_t bits = 0x240000;
     190        uint32_t bits = 0x900000;
    191191        UNUSED_PARAM(bits);
    192192        ArithProfile arithProfile;
     
    198198    }
    199199    {
    200         uint32_t bits = 0x140000;
     200        uint32_t bits = 0x500000;
    201201        UNUSED_PARAM(bits);
    202202        ArithProfile arithProfile;
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r225385 r225799  
    254254
    255255# ArithProfile data
    256 const ArithProfileInt = 0x100000
    257 const ArithProfileIntInt = 0x120000
    258 const ArithProfileNumber = 0x200000
    259 const ArithProfileNumberInt = 0x220000
    260 const ArithProfileNumberNumber = 0x240000
    261 const ArithProfileIntNumber = 0x140000
     256const ArithProfileInt = 0x400000
     257const ArithProfileIntInt = 0x480000
     258const ArithProfileNumber = 0x800000
     259const ArithProfileNumberInt = 0x880000
     260const ArithProfileNumberNumber = 0x900000
     261const ArithProfileIntNumber = 0x500000
    262262
    263263# Some register conventions.
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r223232 r225799  
    233233        return new (m_parserArena) IntegerNode(location, d);
    234234    }
     235   
     236    ExpressionNode* createBigInt(const JSTokenLocation& location, const Identifier* bigInt, uint8_t radix)
     237    {
     238        incConstants();
     239        return new (m_parserArena) BigIntNode(location, *bigInt, radix);
     240    }
    235241
    236242    ExpressionNode* createString(const JSTokenLocation& location, const Identifier* string)
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r223124 r225799  
    3939#include <string.h>
    4040#include <wtf/Assertions.h>
     41#include <wtf/Variant.h>
    4142#include <wtf/dtoa.h>
    4243
     
    15011502
    15021503template <typename T>
    1503 ALWAYS_INLINE void Lexer<T>::parseHex(double& returnValue)
     1504ALWAYS_INLINE auto Lexer<T>::parseHex() -> NumberParseResult
    15041505{
    15051506    // Optimization: most hexadecimal values fit into 4 bytes.
     
    15131514    } while (isASCIIHexDigit(m_current) && maximumDigits >= 0);
    15141515
    1515     if (maximumDigits >= 0) {
    1516         returnValue = hexValue;
    1517         return;
    1518     }
     1516    if (LIKELY(maximumDigits >= 0 && m_current != 'n'))
     1517        return hexValue;
    15191518
    15201519    // No more place in the hexValue buffer.
     
    15341533    }
    15351534
    1536     returnValue = parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 16);
    1537 }
    1538 
    1539 template <typename T>
    1540 ALWAYS_INLINE bool Lexer<T>::parseBinary(double& returnValue)
     1535    if (UNLIKELY(Options::useBigInt() && m_current == 'n'))
     1536        return makeIdentifier(m_buffer8.data(), m_buffer8.size());
     1537   
     1538    return parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 16);
     1539}
     1540
     1541template <typename T>
     1542ALWAYS_INLINE auto Lexer<T>::parseBinary() -> std::optional<NumberParseResult>
    15411543{
    15421544    // Optimization: most binary values fit into 4 bytes.
     
    15551557    } while (isASCIIBinaryDigit(m_current) && digit >= 0);
    15561558
    1557     if (!isASCIIDigit(m_current) && digit >= 0) {
    1558         returnValue = binaryValue;
    1559         return true;
    1560     }
     1559    if (LIKELY(!isASCIIDigit(m_current) && digit >= 0 && m_current != 'n'))
     1560        return Variant<double, const Identifier*> { binaryValue };
    15611561
    15621562    for (int i = maximumDigits - 1; i > digit; --i)
     
    15681568    }
    15691569
    1570     if (isASCIIDigit(m_current)) {
    1571         returnValue = 0;
    1572         return false;
    1573     }
    1574 
    1575     returnValue = parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 2);
    1576     return true;
    1577 }
    1578 
    1579 template <typename T>
    1580 ALWAYS_INLINE bool Lexer<T>::parseOctal(double& returnValue)
     1570    if (UNLIKELY(Options::useBigInt() && m_current == 'n'))
     1571        return Variant<double, const Identifier*> { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
     1572
     1573    if (isASCIIDigit(m_current))
     1574        return std::nullopt;
     1575
     1576    return Variant<double, const Identifier*> { parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 2) };
     1577}
     1578
     1579template <typename T>
     1580ALWAYS_INLINE auto Lexer<T>::parseOctal() -> std::optional<NumberParseResult>
    15811581{
    15821582    // Optimization: most octal values fit into 4 bytes.
     
    15951595    } while (isASCIIOctalDigit(m_current) && digit >= 0);
    15961596
    1597     if (!isASCIIDigit(m_current) && digit >= 0) {
    1598         returnValue = octalValue;
    1599         return true;
    1600     }
     1597    if (LIKELY(!isASCIIDigit(m_current) && digit >= 0 && m_current != 'n'))
     1598        return Variant<double, const Identifier*> { octalValue };
     1599
    16011600
    16021601    for (int i = maximumDigits - 1; i > digit; --i)
     
    16081607    }
    16091608
    1610     if (isASCIIDigit(m_current)) {
    1611         returnValue = 0;
    1612         return false;
    1613     }
    1614 
    1615     returnValue = parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 8);
    1616     return true;
    1617 }
    1618 
    1619 template <typename T>
    1620 ALWAYS_INLINE bool Lexer<T>::parseDecimal(double& returnValue)
     1609    if (UNLIKELY(Options::useBigInt() && m_current == 'n'))
     1610        return Variant<double, const Identifier*> { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
     1611
     1612    if (isASCIIDigit(m_current))
     1613        return std::nullopt;
     1614
     1615    return Variant<double, const Identifier*> { parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 8) };
     1616}
     1617
     1618template <typename T>
     1619ALWAYS_INLINE auto Lexer<T>::parseDecimal() -> std::optional<NumberParseResult>
    16211620{
    16221621    // Optimization: most decimal values fit into 4 bytes.
     
    16391638        } while (isASCIIDigit(m_current) && digit >= 0);
    16401639
    1641         if (digit >= 0 && m_current != '.' && (m_current | 0x20) != 'e') {
    1642             returnValue = decimalValue;
    1643             return true;
    1644         }
     1640        if (digit >= 0 && m_current != '.' && !isASCIIAlphaCaselessEqual(m_current, 'e') && m_current != 'n')
     1641            return Variant<double, const Identifier*> { decimalValue };
    16451642
    16461643        for (int i = maximumDigits - 1; i > digit; --i)
     
    16521649        shift();
    16531650    }
    1654 
    1655     return false;
     1651   
     1652    if (UNLIKELY(Options::useBigInt() && m_current == 'n'))
     1653        return Variant<double, const Identifier*> { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
     1654
     1655    return std::nullopt;
    16561656}
    16571657
     
    21012101            break;
    21022102        }
    2103         goto inNumberAfterDecimalPoint;
     2103        parseNumberAfterDecimalPoint();
     2104        token = DOUBLE;
     2105        if (isASCIIAlphaCaselessEqual(m_current, 'e')) {
     2106            if (!parseNumberAfterExponentIndicator()) {
     2107                m_lexErrorMessage = ASCIILiteral("Non-number found after exponent indicator");
     2108                token = atEnd() ? UNTERMINATED_NUMERIC_LITERAL_ERRORTOK : INVALID_NUMERIC_LITERAL_ERRORTOK;
     2109                goto returnError;
     2110            }
     2111        }
     2112        size_t parsedLength;
     2113        tokenData->doubleValue = parseDouble(m_buffer8.data(), m_buffer8.size(), parsedLength);
     2114        if (token == INTEGER)
     2115            token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
     2116
     2117        if (UNLIKELY(isIdentStart(m_current))) {
     2118            m_lexErrorMessage = ASCIILiteral("No identifiers allowed directly after numeric literal");
     2119            token = atEnd() ? UNTERMINATED_NUMERIC_LITERAL_ERRORTOK : INVALID_NUMERIC_LITERAL_ERRORTOK;
     2120            goto returnError;
     2121        }
     2122        m_buffer8.shrink(0);
     2123        break;
    21042124    case CharacterZero:
    21052125        shift();
    2106         if ((m_current | 0x20) == 'x') {
     2126        if (isASCIIAlphaCaselessEqual(m_current, 'x')) {
    21072127            if (!isASCIIHexDigit(peek(1))) {
    21082128                m_lexErrorMessage = ASCIILiteral("No hexadecimal digits after '0x'");
     
    21142134            shift();
    21152135
    2116             parseHex(tokenData->doubleValue);
     2136            auto parseNumberResult = parseHex();
     2137            if (WTF::holds_alternative<double>(parseNumberResult))
     2138                tokenData->doubleValue = WTF::get<double>(parseNumberResult);
     2139            else {
     2140                token = BIGINT;
     2141                shift();
     2142                tokenData->bigIntString = WTF::get<const Identifier*>(parseNumberResult);
     2143                tokenData->radix = 16;
     2144            }
     2145
    21172146            if (isIdentStart(m_current)) {
    21182147                m_lexErrorMessage = ASCIILiteral("No space between hexadecimal literal and identifier");
     
    21202149                goto returnError;
    21212150            }
    2122             token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
     2151            if (LIKELY(token != BIGINT))
     2152                token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
    21232153            m_buffer8.shrink(0);
    21242154            break;
    21252155        }
    2126         if ((m_current | 0x20) == 'b') {
     2156        if (isASCIIAlphaCaselessEqual(m_current, 'b')) {
    21272157            if (!isASCIIBinaryDigit(peek(1))) {
    21282158                m_lexErrorMessage = ASCIILiteral("No binary digits after '0b'");
     
    21342164            shift();
    21352165
    2136             parseBinary(tokenData->doubleValue);
     2166            auto parseNumberResult = parseBinary();
     2167            if (!parseNumberResult)
     2168                tokenData->doubleValue = 0;
     2169            else if (WTF::holds_alternative<double>(*parseNumberResult))
     2170                tokenData->doubleValue = WTF::get<double>(*parseNumberResult);
     2171            else {
     2172                token = BIGINT;
     2173                shift();
     2174                tokenData->bigIntString = WTF::get<const Identifier*>(*parseNumberResult);
     2175                tokenData->radix = 2;
     2176            }
     2177
    21372178            if (isIdentStart(m_current)) {
    21382179                m_lexErrorMessage = ASCIILiteral("No space between binary literal and identifier");
     
    21402181                goto returnError;
    21412182            }
    2142             token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
     2183            if (LIKELY(token != BIGINT))
     2184                token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
    21432185            m_buffer8.shrink(0);
    21442186            break;
    21452187        }
    21462188
    2147         if ((m_current | 0x20) == 'o') {
     2189        if (isASCIIAlphaCaselessEqual(m_current, 'o')) {
    21482190            if (!isASCIIOctalDigit(peek(1))) {
    21492191                m_lexErrorMessage = ASCIILiteral("No octal digits after '0o'");
     
    21552197            shift();
    21562198
    2157             parseOctal(tokenData->doubleValue);
     2199            auto parseNumberResult = parseOctal();
     2200            if (!parseNumberResult)
     2201                tokenData->doubleValue = 0;
     2202            else if (WTF::holds_alternative<double>(*parseNumberResult))
     2203                tokenData->doubleValue = WTF::get<double>(*parseNumberResult);
     2204            else {
     2205                token = BIGINT;
     2206                shift();
     2207                tokenData->bigIntString = WTF::get<const Identifier*>(*parseNumberResult);
     2208                tokenData->radix = 8;
     2209            }
     2210
    21582211            if (isIdentStart(m_current)) {
    21592212                m_lexErrorMessage = ASCIILiteral("No space between octal literal and identifier");
     
    21612214                goto returnError;
    21622215            }
    2163             token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
     2216            if (LIKELY(token != BIGINT))
     2217                token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
    21642218            m_buffer8.shrink(0);
    21652219            break;
     
    21732227        }
    21742228        if (isASCIIOctalDigit(m_current)) {
    2175             if (parseOctal(tokenData->doubleValue)) {
     2229            auto parseNumberResult = parseOctal();
     2230            if (parseNumberResult && WTF::holds_alternative<double>(*parseNumberResult)) {
     2231                tokenData->doubleValue = WTF::get<double>(*parseNumberResult);
    21762232                token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
    21772233            }
     
    21802236    case CharacterNumber:
    21812237        if (LIKELY(token != INTEGER && token != DOUBLE)) {
    2182             if (!parseDecimal(tokenData->doubleValue)) {
    2183                 token = INTEGER;
    2184                 if (m_current == '.') {
     2238            auto parseNumberResult = parseDecimal();
     2239            if (parseNumberResult && WTF::holds_alternative<double>(*parseNumberResult)) {
     2240                tokenData->doubleValue = WTF::get<double>(*parseNumberResult);
     2241                token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
     2242            } else {
     2243                if (parseNumberResult) {
     2244                    ASSERT(WTF::get<const Identifier*>(*parseNumberResult));
     2245                    token = BIGINT;
    21852246                    shift();
    2186 inNumberAfterDecimalPoint:
    2187                     parseNumberAfterDecimalPoint();
    2188                     token = DOUBLE;
     2247                    tokenData->bigIntString = WTF::get<const Identifier*>(*parseNumberResult);
     2248                    tokenData->radix = 10;
     2249                } else {
     2250                    token = INTEGER;
     2251                    if (m_current == '.') {
     2252                        shift();
     2253                        parseNumberAfterDecimalPoint();
     2254                        token = DOUBLE;
     2255                    }
     2256                    if (isASCIIAlphaCaselessEqual(m_current, 'e')) {
     2257                        if (!parseNumberAfterExponentIndicator()) {
     2258                            m_lexErrorMessage = ASCIILiteral("Non-number found after exponent indicator");
     2259                            token = atEnd() ? UNTERMINATED_NUMERIC_LITERAL_ERRORTOK : INVALID_NUMERIC_LITERAL_ERRORTOK;
     2260                            goto returnError;
     2261                        }
     2262                    }
     2263                    size_t parsedLength;
     2264                    tokenData->doubleValue = parseDouble(m_buffer8.data(), m_buffer8.size(), parsedLength);
     2265                    if (token == INTEGER)
     2266                        token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
    21892267                }
    2190                 if ((m_current | 0x20) == 'e') {
    2191                     if (!parseNumberAfterExponentIndicator()) {
    2192                         m_lexErrorMessage = ASCIILiteral("Non-number found after exponent indicator");
    2193                         token = atEnd() ? UNTERMINATED_NUMERIC_LITERAL_ERRORTOK : INVALID_NUMERIC_LITERAL_ERRORTOK;
    2194                         goto returnError;
    2195                     }
    2196                 }
    2197                 size_t parsedLength;
    2198                 tokenData->doubleValue = parseDouble(m_buffer8.data(), m_buffer8.size(), parsedLength);
    2199                 if (token == INTEGER)
    2200                     token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
    2201             } else
    2202                 token = tokenTypeForIntegerLikeToken(tokenData->doubleValue);
     2268            }
    22032269        }
    22042270
  • trunk/Source/JavaScriptCore/parser/Lexer.h

    r219702 r225799  
    174174    template <bool shouldBuildStrings> NEVER_INLINE StringParseResult parseStringSlowCase(JSTokenData*, bool strictMode);
    175175
     176
    176177    template <bool shouldBuildStrings, LexerEscapeParseMode escapeParseMode> ALWAYS_INLINE StringParseResult parseComplexEscape(bool strictMode, T stringQuoteCharacter);
    177178    ALWAYS_INLINE StringParseResult parseTemplateLiteral(JSTokenData*, RawStringsBuildMode);
    178     ALWAYS_INLINE void parseHex(double& returnValue);
    179     ALWAYS_INLINE bool parseBinary(double& returnValue);
    180     ALWAYS_INLINE bool parseOctal(double& returnValue);
    181     ALWAYS_INLINE bool parseDecimal(double& returnValue);
     179   
     180    using NumberParseResult = Variant<double, const Identifier*>;
     181    ALWAYS_INLINE NumberParseResult parseHex();
     182    ALWAYS_INLINE std::optional<NumberParseResult> parseBinary();
     183    ALWAYS_INLINE std::optional<NumberParseResult> parseOctal();
     184    ALWAYS_INLINE std::optional<NumberParseResult> parseDecimal();
    182185    ALWAYS_INLINE void parseNumberAfterDecimalPoint();
    183186    ALWAYS_INLINE bool parseNumberAfterExponentIndicator();
  • trunk/Source/JavaScriptCore/parser/NodeConstructors.h

    r223232 r225799  
    9393    }
    9494
     95    inline BigIntNode::BigIntNode(const JSTokenLocation& location, const Identifier& value, uint8_t radix)
     96        : ConstantNode(location, ResultType::bigIntType())
     97        , m_value(value)
     98        , m_radix(radix)
     99    {
     100    }
     101
    95102    inline StringNode::StringNode(const JSTokenLocation& location, const Identifier& value)
    96103        : ConstantNode(location, ResultType::stringType())
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r223318 r225799  
    163163        virtual bool isNumber() const { return false; }
    164164        virtual bool isString() const { return false; }
     165        virtual bool isBigInt() const { return false; }
    165166        virtual bool isObjectLiteral() const { return false; }
    166167        virtual bool isArrayLiteral() const { return false; }
     
    329330    };
    330331
     332    class BigIntNode final : public ConstantNode {
     333    public:
     334        BigIntNode(const JSTokenLocation&, const Identifier&, uint8_t radix);
     335        const Identifier& value() { return m_value; }
     336
     337    private:
     338        bool isBigInt() const final { return true; }
     339        JSValue jsValue(BytecodeGenerator&) const final;
     340
     341        const Identifier& m_value;
     342        const uint8_t m_radix;
     343    };
     344
    331345    class ThrowableExpressionData {
    332346    public:
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r223232 r225799  
    44934493        return createResolveAndUseVariable(context, ident, *ident == m_vm->propertyNames->eval, start, location);
    44944494    }
     4495    case BIGINT: {
     4496        const Identifier* ident = m_token.m_data.bigIntString;
     4497        JSTokenLocation location(tokenLocation());
     4498        next();
     4499        return context.createBigInt(location, ident, m_token.m_data.radix);
     4500    }
    44954501    case STRING: {
    44964502        const Identifier* ident = m_token.m_data.ident;
  • trunk/Source/JavaScriptCore/parser/ParserTokens.h

    r223124 r225799  
    111111    INTEGER,
    112112    DOUBLE,
     113    BIGINT,
    113114    IDENT,
    114115    STRING,
     
    219220    };
    220221    struct {
     222        const Identifier* bigIntString;
     223        uint8_t radix;
     224    };
     225    struct {
    221226        const Identifier* cooked;
    222227        const Identifier* raw;
  • trunk/Source/JavaScriptCore/parser/ResultType.h

    r206525 r225799  
    3232        friend struct OperandTypes;
    3333
    34         typedef uint8_t Type;
     34        using Type = uint8_t;
    3535        static const Type TypeInt32 = 1;
    3636        static const Type TypeMaybeNumber = 0x02;
     
    3838        static const Type TypeMaybeNull   = 0x08;
    3939        static const Type TypeMaybeBool   = 0x10;
    40         static const Type TypeMaybeOther  = 0x20;
    41 
    42         static const Type TypeBits = TypeMaybeNumber | TypeMaybeString | TypeMaybeNull | TypeMaybeBool | TypeMaybeOther;
     40        static const Type TypeMaybeBigInt = 0x20;
     41        static const Type TypeMaybeOther  = 0x40;
     42
     43        static const Type TypeBits = TypeMaybeNumber | TypeMaybeString | TypeMaybeNull | TypeMaybeBool | TypeMaybeBigInt | TypeMaybeOther;
    4344
    4445    public:
    45         static const int numBitsNeeded = 6;
     46        static const int numBitsNeeded = 7;
    4647        static_assert((TypeBits & ((1 << numBitsNeeded) - 1)) == TypeBits, "This is necessary for correctness.");
    4748
     
    7172        }
    7273
     74        bool definitelyIsBigInt() const
     75        {
     76            return (m_bits & TypeBits) == TypeMaybeBigInt;
     77        }
     78
    7379        bool mightBeNumber() const
    7480        {
     
    8187        }
    8288       
     89        bool mightBeBigInt() const
     90        {
     91            return m_bits & TypeMaybeBigInt;
     92        }
     93
     94        bool isNotBigInt() const
     95        {
     96            return !mightBeBigInt();
     97        }
     98       
    8399        static ResultType nullType()
    84100        {
     
    106122        }
    107123       
     124        static ResultType addResultType()
     125        {
     126            return ResultType(TypeMaybeNumber | TypeMaybeString | TypeMaybeBigInt);
     127        }
     128       
    108129        static ResultType stringType()
    109130        {
    110131            return ResultType(TypeMaybeString);
     132        }
     133       
     134        static ResultType bigIntType()
     135        {
     136            return ResultType(TypeMaybeBigInt);
    111137        }
    112138       
     
    122148            if (op1.definitelyIsString() || op2.definitelyIsString())
    123149                return stringType();
    124             return stringOrNumberType();
     150            if (op1.definitelyIsBigInt() && op2.definitelyIsBigInt())
     151                return bigIntType();
     152            return addResultType();
    125153        }
    126154
     
    135163            if (op1.definitelyIsString() && op2.definitelyIsString())
    136164                return stringType();
     165            if (op1.definitelyIsBigInt() && op2.definitelyIsBigInt())
     166                return bigIntType();
    137167            return unknownType();
    138168        }
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r223232 r225799  
    7171    static const constexpr int MetaPropertyBit = 0x80000000;
    7272    enum : int { NoneExpr = 0,
    73         ResolveEvalExpr, ResolveExpr, IntegerExpr, DoubleExpr, StringExpr,
     73        ResolveEvalExpr, ResolveExpr, IntegerExpr, DoubleExpr, StringExpr, BigIntExpr,
    7474        ThisExpr, NullExpr, BoolExpr, RegExpExpr, ObjectLiteralExpr,
    7575        FunctionExpr, ClassExpr, SuperExpr, ImportExpr, BracketExpr, DotExpr, CallExpr,
     
    176176    ExpressionType createDoubleExpr(const JSTokenLocation&, double) { return DoubleExpr; }
    177177    ExpressionType createIntegerExpr(const JSTokenLocation&, double) { return IntegerExpr; }
     178    ExpressionType createBigInt(const JSTokenLocation&, const Identifier*, int) { return BigIntExpr; }
    178179    ExpressionType createString(const JSTokenLocation&, const Identifier*) { return StringExpr; }
    179180    ExpressionType createBoolean(const JSTokenLocation&, bool) { return BoolExpr; }
  • trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h

    r223124 r225799  
    3131    macro(ArrayIterator) \
    3232    macro(BYTES_PER_ELEMENT) \
     33    macro(BigInt) \
    3334    macro(Boolean) \
    3435    macro(Collator) \
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r225618 r225799  
    3030#include "ExceptionHelpers.h"
    3131#include "GetterSetter.h"
     32#include "JSBigInt.h"
    3233#include "JSCInlines.h"
    3334#include "JSFunction.h"
     
    130131        if (isString())
    131132            return exec->lexicalGlobalObject()->stringPrototype();
     133        // FIXME: [ESNext][BigInt] Implement BigIntConstructor and BigIntPrototype
     134        // https://bugs.webkit.org/show_bug.cgi?id=175359
     135        RELEASE_ASSERT(!isBigInt());
    132136        ASSERT(isSymbol());
    133137        return exec->lexicalGlobalObject()->symbolPrototype();
     
    376380        return errorValue();
    377381    }
     382    if (isBigInt()) {
     383        JSBigInt* bigInt = asBigInt(*this);
     384        if (auto digit = bigInt->singleDigitValueForString())
     385            return vm.smallStrings.singleCharacterString(*digit + '0');
     386        return jsNontrivialString(&vm, bigInt->toString(*exec, 10));
     387    }
    378388
    379389    ASSERT(isCell());
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.h

    r222871 r225799  
    223223    bool isNumber() const;
    224224    bool isString() const;
     225    bool isBigInt() const;
    225226    bool isSymbol() const;
    226227    bool isPrimitive() const;
  • trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h

    r222871 r225799  
    3030#include "Identifier.h"
    3131#include "InternalFunction.h"
     32#include "JSBigInt.h"
    3233#include "JSCJSValue.h"
    3334#include "JSCellInlines.h"
     
    577578{
    578579    return isCell() && asCell()->isString();
     580}
     581
     582inline bool JSValue::isBigInt() const
     583{
     584    return isCell() && asCell()->isBigInt();
    579585}
    580586
     
    10211027    if (v1.asCell()->isString() && v2.asCell()->isString())
    10221028        return asString(v1)->equal(exec, asString(v2));
     1029    if (v1.isBigInt() && v2.isBigInt())
     1030        return JSBigInt::equals(asBigInt(v1.asCell()), asBigInt(v2.asCell()));
    10231031    return v1 == v2;
    10241032}
  • trunk/Source/JavaScriptCore/runtime/JSCell.cpp

    r224927 r225799  
    114114bool JSCell::put(JSCell* cell, ExecState* exec, PropertyName identifier, JSValue value, PutPropertySlot& slot)
    115115{
    116     if (cell->isString() || cell->isSymbol())
     116    if (cell->isString() || cell->isSymbol() || cell->isBigInt())
    117117        return JSValue(cell).putToPrimitive(exec, identifier, value, slot);
    118118
     
    123123bool JSCell::putByIndex(JSCell* cell, ExecState* exec, unsigned identifier, JSValue value, bool shouldThrow)
    124124{
    125     if (cell->isString() || cell->isSymbol()) {
     125    if (cell->isString() || cell->isSymbol() || cell->isBigInt()) {
    126126        PutPropertySlot slot(cell, shouldThrow);
    127127        return JSValue(cell).putToPrimitive(exec, Identifier::from(exec, identifier), value, slot);
     
    156156    if (isSymbol())
    157157        return static_cast<const Symbol*>(this)->toPrimitive(exec, preferredType);
     158    if (isBigInt())
     159        return static_cast<const JSBigInt*>(this)->toPrimitive(exec, preferredType);
    158160    return static_cast<const JSObject*>(this)->toPrimitive(exec, preferredType);
    159161}
     
    165167    if (isSymbol())
    166168        return static_cast<const Symbol*>(this)->getPrimitiveNumber(exec, number, value);
     169    if (isBigInt())
     170        return static_cast<const JSBigInt*>(this)->getPrimitiveNumber(exec, number, value);
    167171    return static_cast<const JSObject*>(this)->getPrimitiveNumber(exec, number, value);
    168172}
     
    174178    if (isSymbol())
    175179        return static_cast<const Symbol*>(this)->toNumber(exec);
     180    if (isBigInt())
     181        return static_cast<const JSBigInt*>(this)->toNumber(exec);
    176182    return static_cast<const JSObject*>(this)->toNumber(exec);
    177183}
     
    182188    if (isString())
    183189        return static_cast<const JSString*>(this)->toObject(exec, globalObject);
     190    // FIXME: [ESNext][BigInt] Implement JSBigInt, BigIntConstructor and BigIntPrototype
     191    // https://bugs.webkit.org/show_bug.cgi?id=175359
     192    RELEASE_ASSERT(!isBigInt());
    184193    ASSERT(isSymbol());
    185194    return static_cast<const Symbol*>(this)->toObject(exec, globalObject);
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r225314 r225799  
    109109    // Querying the type.
    110110    bool isString() const;
     111    bool isBigInt() const;
    111112    bool isSymbol() const;
    112113    bool isObject() const;
  • trunk/Source/JavaScriptCore/runtime/JSCellInlines.h

    r225314 r225799  
    193193}
    194194
     195inline bool JSCell::isBigInt() const
     196{
     197    return m_type == BigIntType;
     198}
     199
    195200inline bool JSCell::isSymbol() const
    196201{
  • trunk/Source/JavaScriptCore/runtime/JSModuleRecord.cpp

    r222895 r225799  
    2727#include "JSModuleRecord.h"
    2828
     29#include "BuiltinNames.h"
    2930#include "Error.h"
    3031#include "Interpreter.h"
    3132#include "JSCInlines.h"
    3233#include "JSModuleEnvironment.h"
     34#include "JSModuleLoader.h"
    3335#include "JSModuleNamespaceObject.h"
    3436#include "UnlinkedModuleProgramCodeBlock.h"
  • trunk/Source/JavaScriptCore/runtime/JSType.h

    r224487 r225799  
    3434    StringType,
    3535    SymbolType,
     36    BigIntType,
    3637
    3738    CustomGetterSetterType,
  • trunk/Source/JavaScriptCore/runtime/MathCommon.h

    r216178 r225799  
    6767}
    6868
     69inline int clz64(uint64_t number)
     70{
     71#if COMPILER(GCC_OR_CLANG)
     72    int zeroCount = 64;
     73    if (number)
     74        zeroCount = __builtin_clzll(number);
     75    return zeroCount;
     76#else
     77    int zeroCount = 0;
     78    for (int i = 63; i >= 0; i--) {
     79        if (!(number >> i))
     80            zeroCount++;
     81        else
     82            break;
     83    }
     84    return zeroCount;
     85#endif
     86}
     87
    6988// This in the ToInt32 operation is defined in section 9.5 of the ECMA-262 spec.
    7089// Note that this operation is identical to ToUInt32 other than to interpretation
  • trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp

    r222473 r225799  
    3030#include "JSGlobalObject.h"
    3131#include "JSString.h"
     32#include "ParseInt.h"
    3233#include "Uint16WithFraction.h"
    3334#include <wtf/dtoa.h>
     
    139140// fo any number of digits an IEEE number may require to represent.
    140141typedef char RadixBuffer[2180];
    141 
    142 // Mapping from integers 0..35 to digit identifying this value, for radix 2..36.
    143 static const char radixDigits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
    144142
    145143static inline char* int52ToStringWithRadix(char* startOfResultString, int64_t int52Value, unsigned radix)
  • trunk/Source/JavaScriptCore/runtime/Operations.cpp

    r222827 r225799  
    8383    if (v.isSymbol())
    8484        return vm.smallStrings.symbolString();
     85    if (v.isBigInt())
     86        return vm.smallStrings.bigintString();
    8587    if (v.isObject()) {
    8688        JSObject* object = asObject(v);
     
    113115
    114116    JSType type = v.asCell()->type();
    115     if (type == StringType || type == SymbolType)
     117    if (type == StringType || type == SymbolType || type == BigIntType)
    116118        return false;
    117119    if (type >= ObjectType) {
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r225550 r225799  
    481481    v(bool, useEagerWebAssemblyModuleHashing, false, Normal, "Unnamed WebAssembly modules are identified in backtraces through their hash, if available.") \
    482482    v(bool, useObjectRestSpread, true, Normal, "If true, we will enable Object Rest/Spread feature.") \
     483    v(bool, useBigInt, false, Normal, "If true, we will enable BigInt support.") \
    483484    v(bool, useArrayAllocationProfiling, true, Normal, "If true, we will use our normal array allocation profiling. If false, the allocation profile will always claim to be undecided.")\
    484485    v(bool, forcePolyProto, false, Normal, "If true, create_this will always create an object with a poly proto structure.")
  • trunk/Source/JavaScriptCore/runtime/ParseInt.h

    r221849 r225799  
    227227}
    228228
     229// Mapping from integers 0..35 to digit identifying this value, for radix 2..36.
     230const char radixDigits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
     231
    229232} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/SmallStrings.h

    r218794 r225799  
    4141    macro(string) \
    4242    macro(symbol) \
     43    macro(bigint) \
    4344    macro(true)
    4445
     
    104105        case TypeofType::Function:
    105106            return functionString();
     107        case TypeofType::BigInt:
     108            return bigintString();
    106109        }
    107110       
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r225768 r225799  
    2727#include "Structure.h"
    2828
     29#include "BuiltinNames.h"
    2930#include "CodeBlock.h"
    3031#include "DumpContext.h"
  • trunk/Source/JavaScriptCore/runtime/StructureInlines.h

    r223746 r225799  
    204204    ASSERT(structure->typeInfo().type() == SymbolType);
    205205    return globalObject->symbolPrototype();
    206 
    207206}
    208207
  • trunk/Source/JavaScriptCore/runtime/TypeofType.cpp

    r183724 r225799  
    5555        out.print("function");
    5656        return;
     57    case TypeofType::BigInt:
     58        out.print("bigint");
     59        return;
    5760    }
    5861   
  • trunk/Source/JavaScriptCore/runtime/TypeofType.h

    r206525 r225799  
    3232enum class TypeofType {
    3333    Undefined,
     34    BigInt,
    3435    Boolean,
    3536    Number,
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r225725 r225799  
    6767#include "JSAPIValueWrapper.h"
    6868#include "JSArray.h"
     69#include "JSBigInt.h"
    6970#include "JSCInlines.h"
    7071#include "JSDestructibleObjectHeapCellType.h"
     
    309310    setIteratorStructure.set(*this, JSSetIterator::createStructure(*this, 0, jsNull()));
    310311    mapIteratorStructure.set(*this, JSMapIterator::createStructure(*this, 0, jsNull()));
     312    bigIntStructure.set(*this, JSBigInt::createStructure(*this, 0, jsNull()));
    311313
    312314    sentinelSetBucket.set(*this, JSSet::BucketType::createSentinel(*this));
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r225725 r225799  
    410410    Strong<Structure> setIteratorStructure;
    411411    Strong<Structure> mapIteratorStructure;
     412    Strong<Structure> bigIntStructure;
    412413
    413414    Strong<JSCell> emptyPropertyNameEnumerator;
  • trunk/Source/WTF/ChangeLog

    r225792 r225799  
     12017-12-12  Caio Lima  <ticaiolima@gmail.com>
     2
     3        [ESNext][BigInt] Implement BigInt literals and JSBigInt
     4        https://bugs.webkit.org/show_bug.cgi?id=179000
     5
     6        Reviewed by Darin Adler and Yusuke Suzuki.
     7
     8        * wtf/HashFunctions.h:
     9
    1102017-12-12  Joseph Pecoraro  <pecoraro@apple.com>
    211
  • trunk/Source/WTF/wtf/HashFunctions.h

    r225096 r225799  
    219219
    220220    template<> struct DefaultHash<bool> { typedef IntHash<uint8_t> Hash; };
     221    template<> struct DefaultHash<uint8_t> { typedef IntHash<uint8_t> Hash; };
    221222    template<> struct DefaultHash<short> { typedef IntHash<unsigned> Hash; };
    222223    template<> struct DefaultHash<unsigned short> { typedef IntHash<unsigned> Hash; };
  • trunk/Tools/ChangeLog

    r225780 r225799  
     12017-12-12  Caio Lima  <ticaiolima@gmail.com>
     2
     3        [ESNext][BigInt] Implement BigInt literals and JSBigInt
     4        https://bugs.webkit.org/show_bug.cgi?id=179000
     5
     6        Reviewed by Darin Adler and Yusuke Suzuki.
     7
     8        * Scripts/run-jsc-stress-tests:
     9
    1102017-12-12  Carlos Alberto Lopez Perez  <clopez@igalia.com>
    211
  • trunk/Tools/Scripts/run-jsc-stress-tests

    r225129 r225799  
    617617end
    618618
     619def runBigIntEnabled(*optionalTestSpecificOptions)
     620    run("big-int-enabled", "--useBigInt=true" , *(FTL_OPTIONS + optionalTestSpecificOptions))
     621end
     622
    619623def runFTLNoCJIT(*optionalTestSpecificOptions)
    620624    run("misc-ftl-no-cjit", *(FTL_OPTIONS + NO_CJIT_OPTIONS + optionalTestSpecificOptions))
Note: See TracChangeset for help on using the changeset viewer.