Fix a bug in explicitly declared funtion name with exception case

* remove a redundant bytecode addition in node line info calculation

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
HyukWoo Park 2022-07-12 11:08:12 +09:00 committed by Patrick Kim
commit 79c3b4c73f
2 changed files with 2 additions and 23 deletions

View file

@ -294,28 +294,7 @@ void ByteCodeGenerator::collectByteCodeLOCData(Context* context, InterpretedCode
ctx.m_breakpointContext = &breakpointContext;
#endif /* ESCARGOT_DEBUGGER */
// generate common codes
{
AtomicString name = codeBlock->functionName();
if (name.string()->length()) {
if (UNLIKELY(codeBlock->isFunctionNameExplicitlyDeclared())) {
if (codeBlock->canUseIndexedVariableStorage()) {
if (!codeBlock->isFunctionNameSaveOnHeap()) {
auto r = ctx.getRegister();
block.pushCode(LoadLiteral(ByteCodeLOC(0), r, Value()), &ctx, nullptr);
block.pushCode(Move(ByteCodeLOC(0), r, REGULAR_REGISTER_LIMIT + 1), &ctx, nullptr);
ctx.giveUpRegister();
}
}
} else if (UNLIKELY(codeBlock->isFunctionNameSaveOnHeap() && !name.string()->equals("arguments"))) {
ctx.m_isVarDeclaredBindingInitialization = true;
IdentifierNode* id = new (alloca(sizeof(IdentifierNode))) IdentifierNode(codeBlock->functionName());
id->generateStoreByteCode(&block, &ctx, REGULAR_REGISTER_LIMIT + 1, true);
}
}
ast->generateStatementByteCode(&block, &ctx);
}
ast->generateStatementByteCode(&block, &ctx);
// reset ASTAllocator
context->astAllocator().reset();