static void fix_wval(MVMThreadContext *tc, MVMSpeshGraph *inliner, MVMSpeshGraph *inlinee, MVMSpeshIns *to_fix) { /* Resolve object, then just put it into a spesh slot. (Could do some * smarter things like trying to see if the SC is referenced by both * compilation units, too.) */ MVMCompUnit *cu = inlinee->sf->body.cu; MVMint16 dep = to_fix->operands[1].lit_i16; MVMint64 idx = to_fix->info->opcode == MVM_OP_wval ? to_fix->operands[2].lit_i16 : to_fix->operands[2].lit_i64; if (dep >= 0 && dep < cu->body.num_scs) { MVMSerializationContext *sc = MVM_sc_get_sc(tc, cu, dep); if (sc) { MVMObject *obj = MVM_sc_get_object(tc, sc, idx); MVMint16 ss = MVM_spesh_add_spesh_slot(tc, inliner, (MVMCollectable *)obj); to_fix->info = MVM_op_get_op(MVM_OP_sp_getspeshslot); to_fix->operands[1].lit_i16 = ss; } else { MVM_oops(tc, "Spesh inline: SC not yet resolved; lookup failed"); } } else { MVM_oops(tc, "Spesh inline: invalid SC index found"); } }
/* Looks up a wval and adds information based on it. */ static void wval_facts(MVMThreadContext *tc, MVMSpeshGraph *g, MVMuint16 tgt_orig, MVMuint16 tgt_i, MVMuint16 dep, MVMint64 idx) { MVMCompUnit *cu = g->sf->body.cu; if (dep < cu->body.num_scs) { MVMSerializationContext *sc = MVM_sc_get_sc(tc, cu, dep); if (sc) object_facts(tc, g, tgt_orig, tgt_i, MVM_sc_get_object(tc, sc, idx)); } }
/* Gets the HOW (meta-object), which may be lazily deserialized. */ MVMObject * MVM_6model_get_how(MVMThreadContext *tc, MVMSTable *st) { MVMObject *HOW = st->HOW; if (!HOW) st->HOW = HOW = MVM_sc_get_object(tc, st->HOW_sc, st->HOW_idx); return HOW; }
static void wvalfrom_facts(MVMThreadContext *tc, MVMSpeshGraph *g, MVMuint16 tgt_orig, MVMuint16 tgt_i, MVMuint16 sslot, MVMint64 idx) { MVMSerializationContext *sc = (MVMSerializationContext *)g->spesh_slots[sslot]; MVMObject *target = MVM_sc_get_object(tc, sc, idx); object_facts(tc, g, tgt_orig, tgt_i, MVM_sc_try_get_object(tc, sc, idx)); }