-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT Generator (and Async func) loops #6990
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
//------------------------------------------------------------------------------------------------------- | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved. | ||
// Copyright (c) ChakraCore Project Contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. | ||
//------------------------------------------------------------------------------------------------------- | ||
#include "Backend.h" | ||
|
@@ -118,7 +118,7 @@ IRBuilder::DoBailOnNoProfile() | |
return false; | ||
} | ||
|
||
if (m_func->GetTopFunc()->GetJITFunctionBody()->IsCoroutine()) | ||
if (m_func->GetTopFunc()->GetJITFunctionBody()->IsCoroutine() && !m_func->IsLoopBody()) | ||
{ | ||
return false; | ||
} | ||
|
@@ -441,7 +441,7 @@ IRBuilder::Build() | |
// Note that for generators, we insert the bailout after the jump table to allow | ||
// the generator's execution to proceed before bailing out. Otherwise, we would always | ||
// bail to the beginning of the function in the interpreter, creating an infinite loop. | ||
if (m_func->IsJitInDebugMode() && !this->m_func->GetJITFunctionBody()->IsCoroutine()) | ||
if (m_func->IsJitInDebugMode() && (!this->m_func->GetJITFunctionBody()->IsCoroutine() || this->IsLoopBody())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Different debug break point for Generator functions BUT not relevant for LoopBodies. |
||
{ | ||
this->InsertBailOutForDebugger(m_functionStartOffset, IR::BailOutForceByFlag | IR::BailOutBreakPointInFunction | IR::BailOutStep, nullptr); | ||
} | ||
|
@@ -1880,6 +1880,9 @@ IRBuilder::BuildReg2(Js::OpCode newOpcode, uint32 offset, Js::RegSlot R0, Js::Re | |
break; | ||
|
||
case Js::OpCode::Yield: | ||
// Jitting Loop Bodies containing Yield is not possible, blocked at callsites of GenerateLoopBody | ||
AssertMsg(!this->IsLoopBody(), "Attempting to JIT loop body containing Yield"); | ||
|
||
instr = IR::Instr::New(newOpcode, dstOpnd, src1Opnd, m_func); | ||
this->AddInstr(instr, offset); | ||
IR::Instr* yieldInstr = instr->ConvertToBailOutInstr(instr, IR::BailOutForGeneratorYield); | ||
|
@@ -7849,6 +7852,7 @@ IRBuilder::GeneratorJumpTable::GeneratorJumpTable(Func* func, IRBuilder* irBuild | |
IR::Instr* | ||
IRBuilder::GeneratorJumpTable::BuildJumpTable() | ||
{ | ||
AssertMsg(!this->m_func->IsLoopBody(), "Coroutine Loop Bodies can be jitted but should follow a different path"); | ||
if (!this->m_func->GetJITFunctionBody()->IsCoroutine()) | ||
{ | ||
return this->m_irBuilder->m_lastInstr; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5467,7 +5467,7 @@ Lowerer::LowerPrologEpilog() | |
instr = m_func->m_exitInstr; | ||
AssertMsg(instr->IsExitInstr(), "Last instr isn't an ExitInstr..."); | ||
|
||
if (m_func->GetJITFunctionBody()->IsCoroutine()) | ||
if (m_func->GetJITFunctionBody()->IsCoroutine() && !m_func->IsLoopBody()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generator function required custom Epilog, irrelevant for a loopBody. |
||
{ | ||
IR::LabelInstr* epilogueLabel = this->m_lowerGeneratorHelper.GetEpilogueForReturnStatements(); | ||
this->m_lowerGeneratorHelper.InsertNullOutGeneratorFrameInEpilogue(epilogueLabel); | ||
|
@@ -11527,6 +11527,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn) | |
|
||
if (m_func->GetJITFunctionBody()->IsCoroutine()) | ||
{ | ||
AssertMsg(!m_func->IsLoopBody(), "LoopBody Jit should not involve Rest params"); | ||
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrArgIn); | ||
} | ||
|
||
|
@@ -11544,7 +11545,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn) | |
if (argIndex == 1) | ||
{ | ||
// The "this" argument is not source-dependent and doesn't need to be checked. | ||
if (m_func->GetJITFunctionBody()->IsCoroutine()) | ||
if (m_func->GetJITFunctionBody()->IsCoroutine() && !m_func->IsLoopBody()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generator function arguments loaded from a different location; not relevant for LoopBodies. |
||
{ | ||
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrArgIn); | ||
ConvertArgOpndIfGeneratorFunction(instrArgIn, generatorArgsPtrOpnd); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BailOnNoProfile caused problems when put in a loop containing a Yield; not a problem when jitting loop bodies that cannot contain yield.