Skip to content

Commit 566aff9

Browse files
committed
Make the code after throwing an error unreachable and do not even emit GC pop after throw
1 parent aeb4902 commit 566aff9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/codegen.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,11 @@ class LocalGCFrame {
638638
}
639639
}
640640
void
641-
restore()
641+
restore(bool unreachable=false)
642642
{
643643
if (frame_swapped) {
644-
emit_gcpop(ctx);
644+
if (!unreachable)
645+
emit_gcpop(ctx);
645646
finalize_gc_frame(ctx);
646647
std::swap(gc, ctx->gc);
647648
if (gc.argSpaceOffs + gc.maxDepth != 0) {
@@ -2228,7 +2229,9 @@ static Value *emit_known_call(jl_value_t *ff, jl_value_t **args, size_t nargs,
22282229
LocalGCFrame local_gc_frame(ctx);
22292230
Value *arg1 = boxed(emit_expr(args[1], ctx), ctx);
22302231
raise_exception_unless(ConstantInt::get(T_int1,0), arg1, ctx);
2231-
local_gc_frame.restore();
2232+
// Update GC frame creation. The GC pop instructions should be removed
2233+
// by LLVM anyway but not emitting those instructions save us some work
2234+
local_gc_frame.restore(true); // unreachable=true
22322235
JL_GC_POP();
22332236
return V_null;
22342237
}

0 commit comments

Comments
 (0)