3434#include " AbstractModuleRecord.h"
3535#include " BuiltinExecutables.h"
3636#include " BuiltinNames.h"
37- #include " BytecodeGeneratorBaseInlines .h"
37+ #include " BytecodeGeneratorInlines .h"
3838#include " BytecodeGeneratorification.h"
3939#include " BytecodeUseDef.h"
4040#include " DefinePropertyAttributes.h"
@@ -104,10 +104,9 @@ struct VarArgsOp<OpSuperConstruct> {
104104 using type = OpSuperConstructVarargs;
105105};
106106
107- template <>
108- void GenericLabel<JSGeneratorTraits>::setLocation(BytecodeGenerator& generator, unsigned location)
107+ void Label::setLocation (BytecodeGenerator& generator, unsigned location)
109108{
110- static_cast < JSC ::BytecodeGenerator&>( generator) .invalidateLoadedPrivateNames ();
109+ generator.invalidateLoadedPrivateNames ();
111110 m_location = location;
112111
113112 for (auto offset : m_unresolvedJumps) {
@@ -384,8 +383,14 @@ ParserError BytecodeGenerator::generate(unsigned& size)
384383 return ParserError (ParserError::ErrorNone);
385384}
386385
386+ void BytecodeGenerator::allocateCalleeSaveSpace ()
387+ {
388+ for (size_t i = 0 ; i < CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters (); i++)
389+ addVar ();
390+ }
391+
387392BytecodeGenerator::BytecodeGenerator (VM & vm, ProgramNode* programNode, UnlinkedProgramCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const FixedVector<Identifier>*, const PrivateNameEnvironment*)
388- : BytecodeGeneratorBase (makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock), CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters( ))
393+ : m_codeBlock (makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock))
389394 , m_codeGenerationMode(codeGenerationMode)
390395 , m_scopeNode(programNode)
391396 , m_thisRegister(CallFrame::thisArgumentOffset())
@@ -400,6 +405,8 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, ProgramNode* programNode, UnlinkedP
400405 , m_needsToUpdateArrowFunctionContext(programNode->usesArrowFunction () || programNode->usesEval())
401406 , m_ecmaMode(ECMAMode::fromBool(programNode->isStrictMode ()))
402407{
408+ allocateCalleeSaveSpace ();
409+
403410 ASSERT_UNUSED (parentScopeTDZVariables, !parentScopeTDZVariables);
404411
405412 m_codeBlock->setNumParameters (1 ); // Allocate space for "this"
@@ -431,7 +438,7 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, ProgramNode* programNode, UnlinkedP
431438}
432439
433440BytecodeGenerator::BytecodeGenerator (VM & vm, FunctionNode* functionNode, UnlinkedFunctionCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const FixedVector<Identifier>* generatorOrAsyncWrapperFunctionParameterNames, const PrivateNameEnvironment* parentPrivateNameEnvironment)
434- : BytecodeGeneratorBase (makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock), CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters( ))
441+ : m_codeBlock (makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock))
435442 , m_codeGenerationMode(codeGenerationMode)
436443 , m_scopeNode(functionNode)
437444 , m_codeType(FunctionCode)
@@ -460,6 +467,8 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, FunctionNode* functionNode, Unlinke
460467 , m_ecmaMode(ECMAMode::fromBool(functionNode->isStrictMode ()))
461468 , m_derivedContextType(codeBlock->derivedContextType ())
462469{
470+ allocateCalleeSaveSpace ();
471+
463472 ECMAMode ecmaMode = m_ecmaMode;
464473 pushPrivateAccessNames (parentPrivateNameEnvironment);
465474
@@ -1002,7 +1011,7 @@ IGNORE_GCC_WARNINGS_END
10021011}
10031012
10041013BytecodeGenerator::BytecodeGenerator (VM & vm, EvalNode* evalNode, UnlinkedEvalCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const FixedVector<Identifier>*, const PrivateNameEnvironment* parentPrivateNameEnvironment)
1005- : BytecodeGeneratorBase (makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock), CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters( ))
1014+ : m_codeBlock (makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock))
10061015 , m_codeGenerationMode(codeGenerationMode)
10071016 , m_scopeNode(evalNode)
10081017 , m_thisRegister(CallFrame::thisArgumentOffset())
@@ -1018,6 +1027,8 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, EvalNode* evalNode, UnlinkedEvalCod
10181027 , m_ecmaMode(ECMAMode::fromBool(evalNode->isStrictMode ()))
10191028 , m_derivedContextType(codeBlock->derivedContextType ())
10201029{
1030+ allocateCalleeSaveSpace ();
1031+
10211032 m_codeBlock->setNumParameters (1 );
10221033
10231034 pushPrivateAccessNames (parentPrivateNameEnvironment);
@@ -1068,7 +1079,7 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, EvalNode* evalNode, UnlinkedEvalCod
10681079}
10691080
10701081BytecodeGenerator::BytecodeGenerator (VM & vm, ModuleProgramNode* moduleProgramNode, UnlinkedModuleProgramCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const FixedVector<Identifier>*, const PrivateNameEnvironment*)
1071- : BytecodeGeneratorBase (makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock), CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters( ))
1082+ : m_codeBlock (makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock))
10721083 , m_codeGenerationMode(codeGenerationMode)
10731084 , m_scopeNode(moduleProgramNode)
10741085 , m_thisRegister(CallFrame::thisArgumentOffset())
@@ -1084,6 +1095,8 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, ModuleProgramNode* moduleProgramNod
10841095 , m_needsToUpdateArrowFunctionContext(moduleProgramNode->usesArrowFunction () || moduleProgramNode->usesEval())
10851096 , m_ecmaMode(ECMAMode::strict())
10861097{
1098+ allocateCalleeSaveSpace ();
1099+
10871100 ASSERT_UNUSED (parentScopeTDZVariables, !parentScopeTDZVariables);
10881101 codeBlock->setVariableDeclarations (moduleProgramNode->varDeclarations ());
10891102
@@ -1485,7 +1498,7 @@ void BytecodeGenerator::emitLoopHint()
14851498
14861499void BytecodeGenerator::emitJump (Label& target)
14871500{
1488- OpJmp::emit (this , target.bind (this ));
1501+ OpJmp::emit (this , target.bind (m_writer ));
14891502}
14901503
14911504void BytecodeGenerator::emitCheckTraps ()
@@ -1511,7 +1524,7 @@ bool BytecodeGenerator::fuseCompareAndJump(RegisterID* cond, Label& target, bool
15111524 if (swapOperands)
15121525 std::swap (binop.m_lhs , binop.m_rhs );
15131526
1514- JmpOp::emit (this , binop.m_lhs , binop.m_rhs , target.bind (this ));
1527+ JmpOp::emit (this , binop.m_lhs , binop.m_rhs , target.bind (m_writer ));
15151528 return true ;
15161529 }
15171530 return false ;
@@ -1525,7 +1538,7 @@ bool BytecodeGenerator::fuseTestAndJmp(RegisterID* cond, Label& target)
15251538 if (cond->index () == unop.m_dst .offset () && cond->isTemporary () && !cond->refCount ()) {
15261539 rewind ();
15271540
1528- JmpOp::emit (this , unop.m_operand , target.bind (this ));
1541+ JmpOp::emit (this , unop.m_operand , target.bind (m_writer ));
15291542 return true ;
15301543 }
15311544 return false ;
@@ -1576,7 +1589,7 @@ void BytecodeGenerator::emitJumpIfTrue(RegisterID* cond, Label& target)
15761589 }
15771590 }
15781591
1579- OpJtrue::emit (this , cond, target.bind (this ));
1592+ OpJtrue::emit (this , cond, target.bind (m_writer ));
15801593}
15811594
15821595void BytecodeGenerator::emitJumpIfFalse (RegisterID* cond, Label& target)
@@ -1627,42 +1640,42 @@ void BytecodeGenerator::emitJumpIfFalse(RegisterID* cond, Label& target)
16271640 }
16281641 }
16291642
1630- OpJfalse::emit (this , cond, target.bind (this ));
1643+ OpJfalse::emit (this , cond, target.bind (m_writer ));
16311644}
16321645
16331646void BytecodeGenerator::emitJumpIfNotFunctionCall (RegisterID* cond, Label& target)
16341647{
1635- OpJneqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::callFunction), target.bind (this ));
1648+ OpJneqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::callFunction), target.bind (m_writer ));
16361649}
16371650
16381651void BytecodeGenerator::emitJumpIfNotFunctionApply (RegisterID* cond, Label& target)
16391652{
1640- OpJneqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::applyFunction), target.bind (this ));
1653+ OpJneqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::applyFunction), target.bind (m_writer ));
16411654}
16421655
16431656void BytecodeGenerator::emitJumpIfNotReflectConstruct (RegisterID* cond, Label& target)
16441657{
1645- OpJneqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::reflectConstructFunction), target.bind (this ));
1658+ OpJneqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::reflectConstructFunction), target.bind (m_writer ));
16461659}
16471660
16481661void BytecodeGenerator::emitJumpIfNotEvalFunction (RegisterID* cond, Label& target)
16491662{
1650- OpJneqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::evalFunction), target.bind (this ));
1663+ OpJneqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::evalFunction), target.bind (m_writer ));
16511664}
16521665
16531666void BytecodeGenerator::emitJumpIfEmptyPropertyNameEnumerator (RegisterID* cond, Label& target)
16541667{
1655- OpJeqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::emptyPropertyNameEnumerator), target.bind (this ));
1668+ OpJeqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::emptyPropertyNameEnumerator), target.bind (m_writer ));
16561669}
16571670
16581671void BytecodeGenerator::emitJumpIfSentinelString (RegisterID* cond, Label& target)
16591672{
1660- OpJeqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::sentinelString), target.bind (this ));
1673+ OpJeqPtr::emit (this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::sentinelString), target.bind (m_writer ));
16611674}
16621675
16631676unsigned BytecodeGenerator::emitWideJumpIfNotFunctionHasOwnProperty (RegisterID* cond, Label& target)
16641677{
1665- OpJneqPtr::emit<OpcodeSize::Wide32>(this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::hasOwnPropertyFunction), target.bind (this ));
1678+ OpJneqPtr::emit<OpcodeSize::Wide32>(this , cond, moveLinkTimeConstant (nullptr , LinkTimeConstant::hasOwnPropertyFunction), target.bind (m_writer ));
16661679 return m_lastInstruction.offset ();
16671680}
16681681
@@ -3789,7 +3802,7 @@ ExpectedFunction BytecodeGenerator::emitExpectedFunctionSnippet(RegisterID* dst,
37893802 if (callArguments.argumentCountIncludingThis () >= 2 )
37903803 return NoExpectedFunction;
37913804
3792- OpJneqPtr::emit (this , func, moveLinkTimeConstant (nullptr , LinkTimeConstant::Object), realCall->bind (this ));
3805+ OpJneqPtr::emit (this , func, moveLinkTimeConstant (nullptr , LinkTimeConstant::Object), realCall->bind (m_writer ));
37933806
37943807 if (dst != ignoredResult ())
37953808 emitNewObject (dst);
@@ -3805,7 +3818,7 @@ ExpectedFunction BytecodeGenerator::emitExpectedFunctionSnippet(RegisterID* dst,
38053818 if (callArguments.argumentCountIncludingThis () > 2 )
38063819 return NoExpectedFunction;
38073820
3808- OpJneqPtr::emit (this , func, moveLinkTimeConstant (nullptr , LinkTimeConstant::Array), realCall->bind (this ));
3821+ OpJneqPtr::emit (this , func, moveLinkTimeConstant (nullptr , LinkTimeConstant::Array), realCall->bind (m_writer ));
38093822
38103823 if (dst != ignoredResult ()) {
38113824 if (callArguments.argumentCountIncludingThis () == 2 )
@@ -3823,7 +3836,7 @@ ExpectedFunction BytecodeGenerator::emitExpectedFunctionSnippet(RegisterID* dst,
38233836 return NoExpectedFunction;
38243837 }
38253838
3826- OpJmp::emit (this , done.bind (this ));
3839+ OpJmp::emit (this , done.bind (m_writer ));
38273840 emitLabel (realCall.get ());
38283841
38293842 return expectedFunction;
@@ -5344,15 +5357,15 @@ RegisterID* BytecodeGenerator::emitRestParameter(RegisterID* result, unsigned nu
53445357void BytecodeGenerator::emitRequireObjectCoercible (RegisterID* value, ASCIILiteral error)
53455358{
53465359 Ref<Label> target = newLabel ();
5347- OpJnundefinedOrNull::emit (this , value, target->bind (this ));
5360+ OpJnundefinedOrNull::emit (this , value, target->bind (m_writer ));
53485361 emitThrowTypeError (error);
53495362 emitLabel (target.get ());
53505363}
53515364
53525365void BytecodeGenerator::emitRequireObjectCoercibleForDestructuring (RegisterID* value, const Identifier* propertyName)
53535366{
53545367 Ref<Label> target = newLabel ();
5355- OpJnundefinedOrNull::emit (this , value, target->bind (this ));
5368+ OpJnundefinedOrNull::emit (this , value, target->bind (m_writer ));
53565369
53575370 if (propertyName && !propertyName->isNull ()) {
53585371 auto errorMessageStr = tryMakeString (" Cannot destructure property '" _s, propertyName->string (), " ' from null or undefined value" _s);
@@ -5552,7 +5565,7 @@ void BytecodeGenerator::emitIteratorGenericClose(RegisterID* iterator, const Thr
55525565void BytecodeGenerator::emitIteratorClose (RegisterID* iterator, RegisterID* nextOrIndex, RegisterID* iterable, const ThrowableExpressionData* node)
55535566{
55545567 Ref<Label> done = newLabel ();
5555- OpIteratorCloseCheck::emit (this , iterator, nextOrIndex, iterable, done->bind (this ));
5568+ OpIteratorCloseCheck::emit (this , iterator, nextOrIndex, iterable, done->bind (m_writer ));
55565569 emitIteratorGenericClose (iterator, node);
55575570 emitLabel (done.get ());
55585571}
0 commit comments