Implement general tail call optimization

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
HyukWoo Park 2024-01-26 19:12:55 +09:00 committed by Patrick Kim
commit 023b7ea014
27 changed files with 368 additions and 89 deletions

View file

@ -278,7 +278,7 @@ ByteCodeBlock* ByteCodeGenerator::generateByteCode(Context* context, Interpreted
block->m_code.shrinkToFit();
block->m_requiredTotalRegisterNumber = block->m_requiredOperandRegisterNumber + codeBlock->totalStackAllocatedVariableSize() + block->m_numeralLiteralData.size();
block->m_needsExtendedExectuionState = ctx.m_needsExtendedExecutionState;
block->m_needsExtendedExecutionState = ctx.m_needsExtendedExecutionState;
#if defined(ENABLE_CODE_CACHE)
// cache bytecode right before relocation
@ -612,6 +612,13 @@ void ByteCodeGenerator::relocateByteCode(ByteCodeBlock* block)
ASSIGN_STACKINDEX_IF_NEEDED(cd->m_argumentsStartIndex, stackBase, stackBaseWillBe, stackVariableSize);
break;
}
case TailCallOpcode: {
TailCall* cd = (TailCall*)currentCode;
ASSIGN_STACKINDEX_IF_NEEDED(cd->m_receiverIndex, stackBase, stackBaseWillBe, stackVariableSize);
ASSIGN_STACKINDEX_IF_NEEDED(cd->m_calleeIndex, stackBase, stackBaseWillBe, stackVariableSize);
ASSIGN_STACKINDEX_IF_NEEDED(cd->m_argumentsStartIndex, stackBase, stackBaseWillBe, stackVariableSize);
break;
}
case TailRecursionOpcode: {
TailRecursion* cd = (TailRecursion*)currentCode;
ASSIGN_STACKINDEX_IF_NEEDED(cd->m_receiverIndex, stackBase, stackBaseWillBe, stackVariableSize);