Ignore:
Timestamp:
Nov 19, 2019, 7:41:57 PM (6 years ago)
Author:
[email protected]
Message:

[ESNext][BigInt] Add support for op_inc
https://bugs.webkit.org/show_bug.cgi?id=193240

Reviewed by Yusuke Suzuki.

JSTests:

Some parts of these tests are inspired by tests in a WIP patch by Caio Lima.
Thanks to him for allowing their reuse.

  • stress/inc-osr-exit-from-big-int.js: Added.

(let.assert.sameValue):
(postInc):
(preInc):
(postDec):
(preDec):

  • stress/inc-osr-exit-to-big-int.js: Added.

(let.assert.sameValue):
(postInc):
(preInc):
(postDec):
(preDec):
(o.valueOf):

Source/JavaScriptCore:

This patch adds support for both ++ and -- on BigInts.

It required the following secondary changes:

  • teaching FixupPhase how to replace it by ArithAdd/ArithSub/ValueAdd/ValueSub when the type is Int32/Double/BigInt
  • pulling ObservedResults out of UnaryArithProfile/BinaryArithProfile, so that it can be used by ArithAdd regardless of whether it comes from an Inc or from an Add
  • adding the constant 1n to the VM object so that it can be used by FixupPhase since it cannot allocate a new JSValue.
  • adding an UnaryArithProfile to op_inc and op_dec, and teaching the llint to update them.
  • adding ToNumeric (identity on bigints, same as toNumber on everything else) to all tiers
  • bytecode/ArithProfile.cpp:

(JSC::ArithProfile<BitfieldType>::shouldEmitSetDouble const):
(JSC::ArithProfile<BitfieldType>::emitSetDouble const):
(JSC::ArithProfile<BitfieldType>::shouldEmitSetNonNumeric const):
(JSC::ArithProfile<BitfieldType>::shouldEmitSetBigInt const):
(JSC::ArithProfile<BitfieldType>::emitSetNonNumeric const):
(JSC::ArithProfile<BitfieldType>::emitSetBigInt const):

  • bytecode/ArithProfile.h:

(JSC::ObservedResults::ObservedResults):
(JSC::ObservedResults::didObserveNonInt32):
(JSC::ObservedResults::didObserveDouble):
(JSC::ObservedResults::didObserveNonNegZeroDouble):
(JSC::ObservedResults::didObserveNegZeroDouble):
(JSC::ObservedResults::didObserveNonNumeric):
(JSC::ObservedResults::didObserveBigInt):
(JSC::ObservedResults::didObserveInt32Overflow):
(JSC::ObservedResults::didObserveInt52Overflow):
(JSC::ArithProfile::observedResults const):
(JSC::ArithProfile::didObserveNonInt32 const):
(JSC::ArithProfile::didObserveDouble const):
(JSC::ArithProfile::didObserveNonNegZeroDouble const):
(JSC::ArithProfile::didObserveNegZeroDouble const):
(JSC::ArithProfile::didObserveNonNumeric const):
(JSC::ArithProfile::didObserveBigInt const):
(JSC::ArithProfile::didObserveInt32Overflow const):
(JSC::ArithProfile::didObserveInt52Overflow const):
(JSC::ArithProfile::setObservedNonNegZeroDouble):
(JSC::ArithProfile::setObservedNegZeroDouble):
(JSC::ArithProfile::setObservedNonNumeric):
(JSC::ArithProfile::setObservedBigInt):
(JSC::ArithProfile::setObservedInt32Overflow):
(JSC::ArithProfile::setObservedInt52Overflow):
(JSC::ArithProfile::observeResult):

  • bytecode/BytecodeList.rb:
  • bytecode/BytecodeUseDef.h:

(JSC::computeUsesForBytecodeIndex):
(JSC::computeDefsForBytecodeIndex):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::unaryArithProfileForPC):

  • bytecode/ExitKind.h:
  • bytecode/SpeculatedType.h:

(JSC::isInt32SpeculationForArithmetic):
(JSC::isInt32OrBooleanSpeculationForArithmetic):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitUnaryOp):
(JSC::BytecodeGenerator::emitToNumeric):

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp:

(JSC::emitPostIncOrDec):

  • dfg/DFGAbstractInterpreterInlines.h:

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

  • dfg/DFGBackwardsPropagationPhase.cpp:

(JSC::DFG::BackwardsPropagationPhase::propagate):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::makeSafe):
(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGCapabilities.cpp:

(JSC::DFG::capabilityLevel):

  • dfg/DFGClobberize.h:

(JSC::DFG::clobberize):

  • dfg/DFGConstantFoldingPhase.cpp:

(JSC::DFG::ConstantFoldingPhase::foldConstants):

  • dfg/DFGDoesGC.cpp:

(JSC::DFG::doesGC):

  • dfg/DFGFixupPhase.cpp:

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

  • dfg/DFGMayExit.cpp:
  • dfg/DFGNode.h:

(JSC::DFG::Node::hasHeapPrediction):

  • dfg/DFGNodeType.h:
  • dfg/DFGOperations.cpp:
  • dfg/DFGOperations.h:
  • dfg/DFGPredictionPropagationPhase.cpp:
  • dfg/DFGSafeToExecute.h:

(JSC::DFG::safeToExecute):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileIncOrDec):
(JSC::DFG::SpeculativeJIT::compileToPrimitive):
(JSC::DFG::SpeculativeJIT::compileToNumeric):

  • dfg/DFGSpeculativeJIT.h:
  • dfg/DFGSpeculativeJIT32_64.cpp:

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

  • dfg/DFGSpeculativeJIT64.cpp:

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

  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileNode):
(JSC::FTL::DFG::LowerDFGToB3::compileIncOrDec):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileMainPass):
(JSC::JIT::privateCompileSlowCases):

  • jit/JIT.h:
  • jit/JITMathIC.h:

(JSC::JITMathIC::generateInline):

  • jit/JITMulGenerator.cpp:

(JSC::JITMulGenerator::generateFastPath):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_to_numeric):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::emit_op_to_numeric):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/CommonSlowPaths.h:
  • runtime/JSBigInt.cpp:

(JSC::JSBigInt::inc):
(JSC::JSBigInt::dec):

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

(JSC::VM::VM):

  • runtime/VM.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r252674 r252680  
     12019-11-19  Robin Morisset  <[email protected]>
     2
     3        [ESNext][BigInt] Add support for op_inc
     4        https://bugs.webkit.org/show_bug.cgi?id=193240
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        This patch adds support for both ++ and -- on BigInts.
     9
     10        It required the following secondary changes:
     11        - teaching FixupPhase how to replace it by ArithAdd/ArithSub/ValueAdd/ValueSub when the type is Int32/Double/BigInt
     12        - pulling ObservedResults out of UnaryArithProfile/BinaryArithProfile, so that it can be used by ArithAdd regardless of whether it comes from an Inc or from an Add
     13        - adding the constant 1n to the VM object so that it can be used by FixupPhase since it cannot allocate a new JSValue.
     14        - adding an UnaryArithProfile to op_inc and op_dec, and teaching the llint to update them.
     15        - adding ToNumeric (identity on bigints, same as toNumber on everything else) to all tiers
     16
     17        * bytecode/ArithProfile.cpp:
     18        (JSC::ArithProfile<BitfieldType>::shouldEmitSetDouble const):
     19        (JSC::ArithProfile<BitfieldType>::emitSetDouble const):
     20        (JSC::ArithProfile<BitfieldType>::shouldEmitSetNonNumeric const):
     21        (JSC::ArithProfile<BitfieldType>::shouldEmitSetBigInt const):
     22        (JSC::ArithProfile<BitfieldType>::emitSetNonNumeric const):
     23        (JSC::ArithProfile<BitfieldType>::emitSetBigInt const):
     24        * bytecode/ArithProfile.h:
     25        (JSC::ObservedResults::ObservedResults):
     26        (JSC::ObservedResults::didObserveNonInt32):
     27        (JSC::ObservedResults::didObserveDouble):
     28        (JSC::ObservedResults::didObserveNonNegZeroDouble):
     29        (JSC::ObservedResults::didObserveNegZeroDouble):
     30        (JSC::ObservedResults::didObserveNonNumeric):
     31        (JSC::ObservedResults::didObserveBigInt):
     32        (JSC::ObservedResults::didObserveInt32Overflow):
     33        (JSC::ObservedResults::didObserveInt52Overflow):
     34        (JSC::ArithProfile::observedResults const):
     35        (JSC::ArithProfile::didObserveNonInt32 const):
     36        (JSC::ArithProfile::didObserveDouble const):
     37        (JSC::ArithProfile::didObserveNonNegZeroDouble const):
     38        (JSC::ArithProfile::didObserveNegZeroDouble const):
     39        (JSC::ArithProfile::didObserveNonNumeric const):
     40        (JSC::ArithProfile::didObserveBigInt const):
     41        (JSC::ArithProfile::didObserveInt32Overflow const):
     42        (JSC::ArithProfile::didObserveInt52Overflow const):
     43        (JSC::ArithProfile::setObservedNonNegZeroDouble):
     44        (JSC::ArithProfile::setObservedNegZeroDouble):
     45        (JSC::ArithProfile::setObservedNonNumeric):
     46        (JSC::ArithProfile::setObservedBigInt):
     47        (JSC::ArithProfile::setObservedInt32Overflow):
     48        (JSC::ArithProfile::setObservedInt52Overflow):
     49        (JSC::ArithProfile::observeResult):
     50        * bytecode/BytecodeList.rb:
     51        * bytecode/BytecodeUseDef.h:
     52        (JSC::computeUsesForBytecodeIndex):
     53        (JSC::computeDefsForBytecodeIndex):
     54        * bytecode/CodeBlock.cpp:
     55        (JSC::CodeBlock::unaryArithProfileForPC):
     56        * bytecode/ExitKind.h:
     57        * bytecode/SpeculatedType.h:
     58        (JSC::isInt32SpeculationForArithmetic):
     59        (JSC::isInt32OrBooleanSpeculationForArithmetic):
     60        * bytecompiler/BytecodeGenerator.cpp:
     61        (JSC::BytecodeGenerator::emitUnaryOp):
     62        (JSC::BytecodeGenerator::emitToNumeric):
     63        * bytecompiler/BytecodeGenerator.h:
     64        * bytecompiler/NodesCodegen.cpp:
     65        (JSC::emitPostIncOrDec):
     66        * dfg/DFGAbstractInterpreterInlines.h:
     67        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     68        * dfg/DFGBackwardsPropagationPhase.cpp:
     69        (JSC::DFG::BackwardsPropagationPhase::propagate):
     70        * dfg/DFGByteCodeParser.cpp:
     71        (JSC::DFG::ByteCodeParser::makeSafe):
     72        (JSC::DFG::ByteCodeParser::parseBlock):
     73        * dfg/DFGCapabilities.cpp:
     74        (JSC::DFG::capabilityLevel):
     75        * dfg/DFGClobberize.h:
     76        (JSC::DFG::clobberize):
     77        * dfg/DFGConstantFoldingPhase.cpp:
     78        (JSC::DFG::ConstantFoldingPhase::foldConstants):
     79        * dfg/DFGDoesGC.cpp:
     80        (JSC::DFG::doesGC):
     81        * dfg/DFGFixupPhase.cpp:
     82        (JSC::DFG::FixupPhase::fixupNode):
     83        (JSC::DFG::FixupPhase::fixupToNumeric):
     84        * dfg/DFGMayExit.cpp:
     85        * dfg/DFGNode.h:
     86        (JSC::DFG::Node::hasHeapPrediction):
     87        * dfg/DFGNodeType.h:
     88        * dfg/DFGOperations.cpp:
     89        * dfg/DFGOperations.h:
     90        * dfg/DFGPredictionPropagationPhase.cpp:
     91        * dfg/DFGSafeToExecute.h:
     92        (JSC::DFG::safeToExecute):
     93        * dfg/DFGSpeculativeJIT.cpp:
     94        (JSC::DFG::SpeculativeJIT::compileIncOrDec):
     95        (JSC::DFG::SpeculativeJIT::compileToPrimitive):
     96        (JSC::DFG::SpeculativeJIT::compileToNumeric):
     97        * dfg/DFGSpeculativeJIT.h:
     98        * dfg/DFGSpeculativeJIT32_64.cpp:
     99        (JSC::DFG::SpeculativeJIT::compile):
     100        * dfg/DFGSpeculativeJIT64.cpp:
     101        (JSC::DFG::SpeculativeJIT::compile):
     102        * ftl/FTLCapabilities.cpp:
     103        (JSC::FTL::canCompile):
     104        * ftl/FTLLowerDFGToB3.cpp:
     105        (JSC::FTL::DFG::LowerDFGToB3::compileNode):
     106        (JSC::FTL::DFG::LowerDFGToB3::compileIncOrDec):
     107        * jit/JIT.cpp:
     108        (JSC::JIT::privateCompileMainPass):
     109        (JSC::JIT::privateCompileSlowCases):
     110        * jit/JIT.h:
     111        * jit/JITMathIC.h:
     112        (JSC::JITMathIC::generateInline):
     113        * jit/JITMulGenerator.cpp:
     114        (JSC::JITMulGenerator::generateFastPath):
     115        * jit/JITOpcodes.cpp:
     116        (JSC::JIT::emit_op_to_numeric):
     117        * jit/JITOpcodes32_64.cpp:
     118        (JSC::JIT::emit_op_to_numeric):
     119        * llint/LowLevelInterpreter.asm:
     120        * llint/LowLevelInterpreter32_64.asm:
     121        * llint/LowLevelInterpreter64.asm:
     122        * runtime/CommonSlowPaths.cpp:
     123        (JSC::SLOW_PATH_DECL):
     124        * runtime/CommonSlowPaths.h:
     125        * runtime/JSBigInt.cpp:
     126        (JSC::JSBigInt::inc):
     127        (JSC::JSBigInt::dec):
     128        * runtime/JSBigInt.h:
     129        * runtime/VM.cpp:
     130        (JSC::VM::VM):
     131        * runtime/VM.h:
     132
    11332019-11-19  Yusuke Suzuki  <[email protected]>
    2134
Note: See TracChangeset for help on using the changeset viewer.