Skip to content

Commit

Permalink
Use type tuple to find spesh candidate if present.
Browse files Browse the repository at this point in the history
If not, we fall back to using the facts inferred using the facts
established thus far.
  • Loading branch information
jnthn committed Aug 3, 2017
1 parent a33c6b5 commit 1f1f27e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/spesh/optimize.c
Expand Up @@ -1054,9 +1054,13 @@ static void optimize_getlex_per_invocant(MVMThreadContext *tc, MVMSpeshGraph *g,

/* Determines if there's a matching spesh candidate for a callee and a given
* set of argument info. */
static MVMint32 try_find_spesh_candidate(MVMThreadContext *tc, MVMCode *code, MVMSpeshCallInfo *arg_info) {
MVMStaticFrameSpesh *spesh = code->body.sf->body.spesh;
return MVM_spesh_arg_guard_run_callinfo(tc, spesh->body.spesh_arg_guard, arg_info);
static MVMint32 try_find_spesh_candidate(MVMThreadContext *tc, MVMCode *code,
MVMSpeshCallInfo *arg_info,
MVMSpeshStatsType *type_tuple) {
MVMSpeshArgGuard *ag = code->body.sf->body.spesh->body.spesh_arg_guard;
return type_tuple
? MVM_spesh_arg_guard_run_types(tc, ag, arg_info->cs, type_tuple)
: MVM_spesh_arg_guard_run_callinfo(tc, ag, arg_info);
}

/* Given a callsite instruction, finds the type tuples there and checks if
Expand Down Expand Up @@ -1373,7 +1377,8 @@ static void optimize_call(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshBB *bb
/* See if we can point the call at a particular specialization. */
if (((MVMCode *)target)->body.sf->body.instrumentation_level == tc->instance->instrumentation_level) {
MVMCode *target_code = (MVMCode *)target;
MVMint32 spesh_cand = try_find_spesh_candidate(tc, target_code, arg_info);
MVMint32 spesh_cand = try_find_spesh_candidate(tc, target_code, arg_info,
stable_type_tuple);
if (spesh_cand >= 0) {
/* Yes. Will we be able to inline? */
MVMSpeshGraph *inline_graph = MVM_spesh_inline_try_get_graph(tc, g,
Expand Down

0 comments on commit 1f1f27e

Please sign in to comment.