-
-
Save MasterDuke17/fa73039e2bdd1844fd430fee8fa993ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git src/core/interp.c src/core/interp.c | |
index 4f8abd4d3..8a4e77cbd 100644 | |
--- src/core/interp.c | |
+++ src/core/interp.c | |
@@ -2761,9 +2761,8 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex | |
goto NEXT; | |
} | |
OP(sp_getcurhllsym): { | |
- MVMString *hll_name = (MVMString *)tc->cur_frame->effective_spesh_slots[GET_UI16(cur_op, 4)]; | |
- GET_REG(cur_op, 0).o = MVM_hll_sym_get(tc, hll_name, GET_REG(cur_op, 2).s); | |
- cur_op += 6; | |
+ GET_REG(cur_op, 0).o = ((MVMHashEntry *)GET_REG(cur_op, 2).i64)->value; | |
+ cur_op += 4; | |
goto NEXT; | |
} | |
OP(bindcurhllsym): { | |
diff --git src/core/oplist src/core/oplist | |
index 137900f0e..b54bb2b1e 100644 | |
--- src/core/oplist | |
+++ src/core/oplist | |
@@ -1062,7 +1062,7 @@ sp_mul_I .s w(obj) int16 sslot r(obj) r(obj) int16 int16 :pure | |
sp_bool_I .s w(int64) r(obj) int16 :pure | |
-sp_getcurhllsym .s w(obj) r(str) sslot :pure | |
+sp_getcurhllsym .s w(obj) int64 :pure | |
# Profiler recording ops. Naming convention: start with prof_. Must all be | |
# marked .s, which is how the validator knows to exclude them. (For that | |
diff --git src/core/ops.c src/core/ops.c | |
index 81c18657c..ff0e4a66e 100644 | |
--- src/core/ops.c | |
+++ src/core/ops.c | |
@@ -12758,7 +12758,7 @@ static const MVMOpInfo MVM_op_infos[] = { | |
{ | |
MVM_OP_sp_getcurhllsym, | |
"sp_getcurhllsym", | |
- 3, | |
+ 2, | |
1, | |
0, | |
0, | |
@@ -12767,7 +12767,7 @@ static const MVMOpInfo MVM_op_infos[] = { | |
0, | |
0, | |
0, | |
- { MVM_operand_write_reg | MVM_operand_obj, MVM_operand_read_reg | MVM_operand_str, MVM_operand_spesh_slot } | |
+ { MVM_operand_write_reg | MVM_operand_obj, MVM_operand_int64 } | |
}, | |
{ | |
MVM_OP_prof_enter, | |
diff --git src/jit/core_templates.expr src/jit/core_templates.expr | |
index 70b813930..fdc38c4db 100644 | |
--- src/jit/core_templates.expr | |
+++ src/jit/core_templates.expr | |
@@ -1434,12 +1434,12 @@ | |
(template: hllhash | |
(^getf (^hllconfig) MVMHLLConfig slurpy_hash_type)) | |
-(template: sp_getcurhllsym | |
- (call (^func &MVM_hll_sym_get) | |
- (arglist | |
- (carg (tc) ptr) | |
- (carg (^spesh_slot_value $2) ptr) | |
- (carg $1 ptr)) ptr_sz)) | |
+#(template: sp_getcurhllsym | |
+# (call (^func &MVM_hll_sym_get) | |
+# (arglist | |
+# (carg (tc) ptr) | |
+# (carg (^spesh_slot_value $2) ptr) | |
+# (carg $1 ptr)) ptr_sz)) | |
(template: gethllsym | |
(call (^func &MVM_hll_sym_get) | |
diff --git src/jit/graph.c src/jit/graph.c | |
index cda586d4f..7fa7ef23f 100644 | |
--- src/jit/graph.c | |
+++ src/jit/graph.c | |
@@ -1869,6 +1869,7 @@ start: | |
case MVM_OP_getcodename: | |
case MVM_OP_setcodeobj: | |
case MVM_OP_hllbool: | |
+ case MVM_OP_sp_getcurhllsym: | |
/* Profiling */ | |
case MVM_OP_prof_enterspesh: | |
case MVM_OP_prof_enterinline: | |
@@ -2028,16 +2029,6 @@ start: | |
jg_append_call_c(tc, jg, op_to_func(tc, op), 4, args, MVM_JIT_RV_VOID, -1); | |
break; | |
} | |
- case MVM_OP_sp_getcurhllsym: { | |
- MVMint16 dst = ins->operands[0].reg.orig; | |
- MVMint32 sym = ins->operands[1].reg.orig; | |
- MVMint16 idx = ins->operands[2].lit_i16; | |
- MVMJitCallArg args[] = { { MVM_JIT_INTERP_VAR, MVM_JIT_INTERP_TC }, | |
- { MVM_JIT_SPESH_SLOT_VALUE, idx }, | |
- { MVM_JIT_REG_VAL, sym } }; | |
- jg_append_call_c(tc, jg, op_to_func(tc, op), 3, args, MVM_JIT_RV_PTR, dst); | |
- break; | |
- } | |
case MVM_OP_gethllsym: { | |
MVMint16 dst = ins->operands[0].reg.orig; | |
MVMint16 hll = ins->operands[1].reg.orig; | |
diff --git src/jit/x64/emit.dasc src/jit/x64/emit.dasc | |
index c8ebdbae1..a31ca25ec 100644 | |
--- src/jit/x64/emit.dasc | |
+++ src/jit/x64/emit.dasc | |
@@ -117,6 +117,7 @@ | |
|.type U32, MVMuint32 | |
|.type U64, MVMuint64 | |
|.type MPINT, mp_int | |
+|.type MVMHASHENTRY, MVMHashEntry | |
/* Static allocation of relevant types to registers. I pick | |
@@ -2119,6 +2120,14 @@ void MVM_jit_emit_primitive(MVMThreadContext *tc, MVMJitCompiler *compiler, MVMJ | |
|1: | |
break; | |
} | |
+ case MVM_OP_sp_getcurhllsym: { | |
+ MVMint16 dst = ins->operands[0].reg.orig; | |
+ MVMint64 entry = ins->operands[1].lit_i64; | |
+ | mov64 TMP1, entry; | |
+ | mov TMP1, MVMHASHENTRY:TMP1->value; | |
+ | mov WORK[dst], TMP1; | |
+ break; | |
+ } | |
case MVM_OP_prof_enterspesh: | |
| mov ARG1, TC; | |
| mov ARG2, TC->cur_frame; | |
diff --git src/spesh/optimize.c src/spesh/optimize.c | |
index 9b62c7f2a..949da69fe 100644 | |
--- src/spesh/optimize.c | |
+++ src/spesh/optimize.c | |
@@ -1305,15 +1305,33 @@ static void optimize_hllbool(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshIns | |
} | |
} | |
-/* Turns a getcurhllsym instruction into an sp_getcurhllsym with the HLL name added to | |
- * a spesh slot so the function call can be jitted. */ | |
+/* Turns a getcurhllsym instruction into an sp_getcurhllsym with the sym operand overwritten | |
+ * with the hash entry literal so its value can be looked up by the jit. */ | |
static void optimize_getcurhllsym(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshIns *ins) { | |
- MVMSpeshOperand *orig_o = ins->operands; | |
- MVM_spesh_graph_add_comment(tc, g, ins, "specialized from %s", ins->info->name); | |
- ins->info = MVM_op_get_op(MVM_OP_sp_getcurhllsym); | |
- ins->operands = MVM_spesh_alloc(tc, g, 3 * sizeof(MVMSpeshOperand)); | |
- memcpy(ins->operands, orig_o, 2 * sizeof(MVMSpeshOperand)); | |
- ins->operands[2].lit_i16 = MVM_spesh_add_spesh_slot_try_reuse(tc, g, (MVMCollectable *)g->sf->body.cu->body.hll_name); | |
+ MVMSpeshFacts *sym_facts = MVM_spesh_get_facts(tc, g, ins->operands[1]); | |
+ if (sym_facts->flags & MVM_SPESH_FACT_KNOWN_VALUE) { | |
+ MVMObject *syms = tc->instance->hll_syms, *hash; | |
+ MVM_gc_mark_thread_blocked(tc); | |
+ uv_mutex_lock(&tc->instance->mutex_hll_syms); | |
+ hash = MVM_repr_at_key_o(tc, syms, g->sf->body.cu->body.hll_name); | |
+ if (hash) { | |
+ MVMHashEntry *entry = NULL; | |
+ MVM_HASH_GET(tc, ((MVMHashBody *)OBJECT_BODY(hash))->hash_head, sym_facts->value.s, entry); | |
+ uv_mutex_unlock(&tc->instance->mutex_hll_syms); | |
+ if (entry) { | |
+ MVM_spesh_usages_delete_by_reg(tc, g, ins->operands[1], ins); | |
+ MVM_spesh_graph_add_comment(tc, g, ins, "specialized from %s", ins->info->name); | |
+ ins->info = MVM_op_get_op(MVM_OP_sp_getcurhllsym); | |
+ ins->operands[1].lit_i64 = entry; | |
+ sym_facts->value.i = entry; | |
+ MVM_spesh_use_facts(tc, g, sym_facts); | |
+ } | |
+ } | |
+ else { | |
+ uv_mutex_unlock(&tc->instance->mutex_hll_syms); | |
+ } | |
+ MVM_gc_mark_thread_unblocked(tc); | |
+ } | |
} | |
/* Optimize an object conditional (if_o, unless_o) to simpler operations. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment