Skip to content

Commit

Permalink
Reinstate callsite during uninlining
Browse files Browse the repository at this point in the history
This fixes the bug in rakudo/rakudo#3114. It's
possible that there may be situations that need a more complete args
processing context too, but for the crash in question this is sufficient.
  • Loading branch information
jnthn committed Sep 5, 2019
1 parent 5f177f5 commit cf3b545
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/spesh/deopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ static void uninline(MVMThreadContext *tc, MVMFrame *f, MVMSpeshCandidate *cand,
memcpy(uf->env, f->env + cand->inlines[i].lexicals_start,
usf->body.num_lexicals * sizeof(MVMRegister));

/* Store the callsite, in case we need it for further processing
* of arguments. (TODO may need to consider the rest of the arg
* processing context too.) */
uf->params.callsite = cand->inlines[i].cs;

/* Store the named argument used bit field, since if we deopt in
* argument handling code we may have missed some. */
if (cand->inlines[i].deopt_named_used_bit_field)
Expand Down
7 changes: 5 additions & 2 deletions src/spesh/inline.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ MVMSpeshBB * merge_graph(MVMThreadContext *tc, MVMSpeshGraph *inliner,
MVMSpeshGraph *inlinee, MVMStaticFrame *inlinee_sf,
MVMSpeshBB *invoke_bb, MVMSpeshIns *invoke_ins,
MVMSpeshOperand code_ref_reg,
MVMuint32 *inline_boundary_handler, MVMuint16 bytecode_size) {
MVMuint32 *inline_boundary_handler, MVMuint16 bytecode_size,
MVMCallsite *cs) {
MVMSpeshFacts **merged_facts;
MVMuint16 *merged_fact_counts;
MVMint32 i, j, orig_inlines, total_inlines, orig_deopt_addrs,
Expand Down Expand Up @@ -819,6 +820,7 @@ MVMSpeshBB * merge_graph(MVMThreadContext *tc, MVMSpeshGraph *inliner,
inliner->inlines[total_inlines - 1].unreachable = 0;
inliner->inlines[total_inlines - 1].deopt_named_used_bit_field =
inlinee->deopt_named_used_bit_field;
inliner->inlines[total_inlines - 1].cs = cs;
inliner->inlines[total_inlines - 1].may_cause_deopt = may_cause_deopt;
inliner->inlines[total_inlines - 1].bytecode_size = bytecode_size;
inliner->num_inlines = total_inlines;
Expand Down Expand Up @@ -1327,7 +1329,8 @@ void MVM_spesh_inline(MVMThreadContext *tc, MVMSpeshGraph *inliner,
/* Merge inlinee's graph into the inliner. */
MVMuint32 inline_boundary_handler;
MVMSpeshBB *inlinee_last_bb = merge_graph(tc, inliner, inlinee, inlinee_sf,
invoke_bb, invoke_ins, code_ref_reg, &inline_boundary_handler, bytecode_size);
invoke_bb, invoke_ins, code_ref_reg, &inline_boundary_handler, bytecode_size,
call_info->cs);

/* If we're profiling, note it's an inline. */
first_ins = find_first_instruction(tc, inlinee);
Expand Down
3 changes: 3 additions & 0 deletions src/spesh/inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ struct MVMSpeshInline {
* not count them multiple times. */
MVMuint16 bytecode_size;

/* The callsite that we were invoked with. */
MVMCallsite *cs;

/* Bit field of named args used to put in place during deopt, since we
* typically don't update the array in specialized code. */
MVMuint64 deopt_named_used_bit_field;
Expand Down

0 comments on commit cf3b545

Please sign in to comment.