Skip to content

Commit

Permalink
Wire dispatch ops up to dispatch cache
Browse files Browse the repository at this point in the history
Which just pushes the NYI a step further forward for now.
  • Loading branch information
jnthn committed May 5, 2020
1 parent caca374 commit 5aae7a4
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 9 deletions.
66 changes: 60 additions & 6 deletions src/core/interp.c
Expand Up @@ -5709,12 +5709,66 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
cur_op += 2;
goto NEXT;
}
OP(dispatch_v):
OP(dispatch_i):
OP(dispatch_n):
OP(dispatch_s):
OP(dispatch_o):
MVM_panic(1, "dispatch ops NYI");
OP(dispatch_v): {
MVMDispInlineCacheEntry **ice_ptr = MVM_disp_inline_cache_get(
cur_op, bytecode_start, tc->cur_frame);
MVMString *id = GET_REG(cur_op, 0).s;
MVMCallsite *callsite = cu->body.callsites[GET_UI16(cur_op, 4)];
MVMuint16 *args = (MVMuint16 *)(cur_op + 6);
tc->cur_frame->return_value = NULL;
tc->cur_frame->return_type = MVM_RETURN_VOID;
cur_op += 6 + 2 * callsite->flag_count;
(*ice_ptr)->run_dispatch(tc, ice_ptr, id, callsite, args);
goto NEXT;
}
OP(dispatch_i): {
MVMDispInlineCacheEntry **ice_ptr = MVM_disp_inline_cache_get(
cur_op, bytecode_start, tc->cur_frame);
MVMString *id = GET_REG(cur_op, 2).s;
MVMCallsite *callsite = cu->body.callsites[GET_UI16(cur_op, 6)];
MVMuint16 *args = (MVMuint16 *)(cur_op + 8);
tc->cur_frame->return_value = &GET_REG(cur_op, 0);
tc->cur_frame->return_type = MVM_RETURN_INT;
cur_op += 8 + 2 * callsite->flag_count;
(*ice_ptr)->run_dispatch(tc, ice_ptr, id, callsite, args);
goto NEXT;
}
OP(dispatch_n): {
MVMDispInlineCacheEntry **ice_ptr = MVM_disp_inline_cache_get(
cur_op, bytecode_start, tc->cur_frame);
MVMString *id = GET_REG(cur_op, 2).s;
MVMCallsite *callsite = cu->body.callsites[GET_UI16(cur_op, 6)];
MVMuint16 *args = (MVMuint16 *)(cur_op + 8);
tc->cur_frame->return_value = &GET_REG(cur_op, 0);
tc->cur_frame->return_type = MVM_RETURN_NUM;
cur_op += 8 + 2 * callsite->flag_count;
(*ice_ptr)->run_dispatch(tc, ice_ptr, id, callsite, args);
goto NEXT;
}
OP(dispatch_s): {
MVMDispInlineCacheEntry **ice_ptr = MVM_disp_inline_cache_get(
cur_op, bytecode_start, tc->cur_frame);
MVMString *id = GET_REG(cur_op, 2).s;
MVMCallsite *callsite = cu->body.callsites[GET_UI16(cur_op, 6)];
MVMuint16 *args = (MVMuint16 *)(cur_op + 8);
tc->cur_frame->return_value = &GET_REG(cur_op, 0);
tc->cur_frame->return_type = MVM_RETURN_STR;
cur_op += 8 + 2 * callsite->flag_count;
(*ice_ptr)->run_dispatch(tc, ice_ptr, id, callsite, args);
goto NEXT;
}
OP(dispatch_o): {
MVMDispInlineCacheEntry **ice_ptr = MVM_disp_inline_cache_get(
cur_op, bytecode_start, tc->cur_frame);
MVMString *id = GET_REG(cur_op, 2).s;
MVMCallsite *callsite = cu->body.callsites[GET_UI16(cur_op, 6)];
MVMuint16 *args = (MVMuint16 *)(cur_op + 8);
tc->cur_frame->return_value = &GET_REG(cur_op, 0);
tc->cur_frame->return_type = MVM_RETURN_OBJ;
cur_op += 8 + 2 * callsite->flag_count;
(*ice_ptr)->run_dispatch(tc, ice_ptr, id, callsite, args);
goto NEXT;
}
OP(sp_guard): {
MVMRegister *target = &GET_REG(cur_op, 0);
MVMObject *check = GET_REG(cur_op, 2).o;
Expand Down
12 changes: 11 additions & 1 deletion src/disp/inline_cache.c
Expand Up @@ -46,7 +46,17 @@ static MVMObject * getlexstatic_resolved(MVMThreadContext *tc,
* Inline caching of dispatch_*
**/

static MVMDispInlineCacheEntry unlinked_dispatch = { NULL };
static void dispatch_initial(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMString *id,
MVMCallsite *cs, MVMuint16 *arg_indices);

static MVMDispInlineCacheEntry unlinked_dispatch = { .run_dispatch = dispatch_initial };

static void dispatch_initial(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMString *id,
MVMCallsite *cs, MVMuint16 *arg_indices) {
MVM_panic(1, "dispatch inline cache linking NYI");
}

/**
* Inline caching general stuff
Expand Down
4 changes: 2 additions & 2 deletions src/disp/inline_cache.h
Expand Up @@ -33,8 +33,8 @@ struct MVMDispInlineCache {
typedef MVMObject * MVMDispInlineCacheRunGetLexStatic(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMString *name);
typedef void MVMDispInlineCacheRunDispatch(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMCallsite *cs,
MVMuint16 *arg_indices);
MVMDispInlineCacheEntry **entry_ptr, MVMString *id,
MVMCallsite *cs, MVMuint16 *arg_indices);

/* The baseline inline cache entry. These always start with a pointer to
* invoke to reach the handler. */
Expand Down

0 comments on commit 5aae7a4

Please sign in to comment.