diff --git a/src/core/interp.c b/src/core/interp.c index 535d57688e..5cee6eec39 100644 --- a/src/core/interp.c +++ b/src/core/interp.c @@ -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; diff --git a/src/disp/inline_cache.c b/src/disp/inline_cache.c index b6466a4cf8..d45137b39a 100644 --- a/src/disp/inline_cache.c +++ b/src/disp/inline_cache.c @@ -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 diff --git a/src/disp/inline_cache.h b/src/disp/inline_cache.h index c7d05d4d44..0d1bd282f9 100644 --- a/src/disp/inline_cache.h +++ b/src/disp/inline_cache.h @@ -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. */