Skip to content

Commit

Permalink
fix stack imbalance for promise deopt
Browse files Browse the repository at this point in the history
  • Loading branch information
JanJecmen committed May 17, 2022
1 parent 138ff14 commit 913ac11
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions rir/src/compiler/native/lower_function_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,7 @@ void LowerFunctionLLVM::compile() {
stack({container(paramCode())});
additionalStackSlots++;
}

{
SmallSet<std::pair<Value*, SEXP>> bindings;
Visitor::run(code->entry, [&](Instruction* i) {
Expand Down Expand Up @@ -3565,14 +3566,18 @@ void LowerFunctionLLVM::compile() {
// In that case, the result is the returned value and we simply
// return it from here.
if (code->isPromise()) {
auto res = withCallFrame(args, [&]() {
return call(
NativeBuiltins::get(NativeBuiltins::Id::deoptProm),
{paramCode(), convertToPointer(m, t::i8, true),
paramArgs(), c(deopt->escapedEnv, 1),
load(deopt->deoptReason()),
loadSxp(deopt->deoptTrigger())});
});
auto res = withCallFrame(
args,
[&]() {
return call(NativeBuiltins::get(
NativeBuiltins::Id::deoptProm),
{paramCode(),
convertToPointer(m, t::i8, true),
paramArgs(), c(deopt->escapedEnv, 1),
load(deopt->deoptReason()),
loadSxp(deopt->deoptTrigger())});
},
false);
exitBlocks.push_back(builder.GetInsertBlock());
builder.CreateRet(res);
} else {
Expand Down

0 comments on commit 913ac11

Please sign in to comment.