Skip to content

Commit

Permalink
JIT some recently added guard ops
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jun 20, 2018
1 parent a4f8ce3 commit 6fb5277
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/core/oplist
Expand Up @@ -880,6 +880,8 @@ sp_guardsfouter .s r(obj) sslot uint32

# Literal object match guard.
sp_guardobj .s r(obj) sslot uint32

# Guards that check concrete or type object, without caring for type.
sp_guardjustconc .s r(obj) uint32
sp_guardjusttype .s r(obj) uint32

Expand Down
3 changes: 3 additions & 0 deletions src/jit/graph.c
Expand Up @@ -3211,6 +3211,9 @@ static MVMint32 consume_ins(MVMThreadContext *tc, MVMJitGraph *jg,
case MVM_OP_sp_guardconc:
case MVM_OP_sp_guardtype:
case MVM_OP_sp_guardsf:
case MVM_OP_sp_guardobj:
case MVM_OP_sp_guardjustconc:
case MVM_OP_sp_guardjusttype:
jg_append_guard(tc, jg, ins);
break;
case MVM_OP_sp_resolvecode: {
Expand Down
27 changes: 25 additions & 2 deletions src/jit/x64/emit.dasc
Expand Up @@ -2519,9 +2519,11 @@ void MVM_jit_emit_guard(MVMThreadContext *tc, MVMJitCompiler *compiler, MVMJitGr
MVMint16 obj = guard->ins->operands[0].reg.orig;
MVMint16 spesh_idx = guard->ins->operands[1].lit_i16;
MVM_jit_log(tc, "emit guard <%s>\n", guard->ins->info->name);
/* load object and spesh slot value */
/* load object and spesh slot value, except for those that don't need it */
| mov TMP1, WORK[obj];
| get_spesh_slot TMP2, spesh_idx;
if (op != MVM_OP_sp_guardjustconc && op != MVM_OP_sp_guardjusttype) {
| get_spesh_slot TMP2, spesh_idx;
}
if (op == MVM_OP_sp_guard) {
/* object in question should just match the type, so it shouldn't
* be zero, and the STABLE should be equal to the value in the spesh
Expand Down Expand Up @@ -2564,6 +2566,27 @@ void MVM_jit_emit_guard(MVMThreadContext *tc, MVMJitCompiler *compiler, MVMJitGr
| jne >1;
| cmp TMP2, CODE:TMP1->body.sf;
| jne >1;
} else if (op == MVM_OP_sp_guardobj) {
/* object should match that from the spesh slot */
| cmp TMP2, TMP1;
| jne >1;
} else if (op == MVM_OP_sp_guardjustconc) {
/* object should be a non-null concrete (non-type) object;
* exact type doesn't matter */
| test TMP1, TMP1;
| jz >1;
/* shouldn't be type object */
| test_type_object TMP1;
| jnz >1;
} else if (op == MVM_OP_sp_guardjusttype) {
/* object in question should be a type object, so it shouldn't
* be zero, and should not be concrete */
/* check for null */
| test TMP1, TMP1;
| jz >1;
/* should be type object */
| test_type_object TMP1;
| jz >1;
}
/* if we're here, we didn't jump to deopt, so skip it */
| jmp >2;
Expand Down

0 comments on commit 6fb5277

Please sign in to comment.