Skip to content

Instantly share code, notes, and snippets.

@bdw

bdw/comments.txt Secret

Created March 13, 2016 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdw/a2851e0697cd38388478 to your computer and use it in GitHub Desktop.
Save bdw/a2851e0697cd38388478 to your computer and use it in GitHub Desktop.
jit entry label check occurences
Use in src/core/frame.c is for lexical lookup in inlines. It's rather a special case, I'm not yet sure how to make it much cheaper.
Originally I had programmed a jit entry label for whenever we enter an inlined basic block, but that was apparantly insufficient.
The same logic more or less applies to exceptions.
The use in deopt and especially in osr is probably legit.
src/core/exceptions.c
88=static MVMint32 search_frame_handlers(MVMThreadContext *tc, MVMFrame *f,
92: if (f->spesh_cand && f->spesh_cand->jitcode && f->jit_entry_label) {
97: void *cur_label = f->jit_entry_label;
174=static void run_handler(MVMThreadContext *tc, LocatedHandler lh, MVMObject *ex_obj, MVMuint32 category) {
180: lh.frame->jit_entry_label = labels[lh.jit_handler->goto_label];
229=static void unwind_after_handler(MVMThreadContext *tc, void *sr_data) {
247: frame->jit_entry_label = labels[ah->jit_handler->goto_label];
514=void MVM_exception_throwobj(MVMThreadContext *tc, MVMuint8 mode, MVMObject *ex_obj, MVMRegister *resume_result) {
530: ex->body.jit_resume_label = tc->cur_frame->jit_entry_label;
545=void MVM_exception_resume(MVMThreadContext *tc, MVMObject *ex_obj) {
583: target->jit_entry_label = ex->body.jit_resume_label;
src/core/frame.c
247=static MVMFrame * allocate_frame(MVMThreadContext *tc, MVMStaticFrameBody *static_frame_body,
264: frame->jit_entry_label = NULL;
307=void MVM_frame_invoke(MVMThreadContext *tc, MVMStaticFrame *static_frame,
442: frame->jit_entry_label = code->labels[0];
443: if (frame->jit_entry_label == NULL ||
444: frame->jit_entry_label - (void*)code->func_ptr > code->size ||
445: frame->jit_entry_label - (void*)code->func_ptr < 0) {
1170=MVMRegister * MVM_frame_find_contextual_by_name(MVMThreadContext *tc, MVMString *name, MVMuint16 *type, MVMFrame *cur_frame, MVMint32 vivify) {
1200: void *return_label = cur_frame->jit_entry_label;
src/core/frame.h
44=struct MVMFrame {
172: void * jit_entry_label;
src/jit/compile.c
507=void MVM_jit_enter_code(MVMThreadContext *tc, MVMCompUnit *cu,
509: void *label = tc->cur_frame->jit_entry_label;
src/jit/graph.c
596=static void after_ins(MVMThreadContext *tc, MVMJitGraph *jg,
623: * will in fact set the jit_entry_label to a correct
src/jit/x64/emit.dasc
279=void MVM_jit_emit_primitive(MVMThreadContext *tc, MVMJitCompiler *compiler, MVMJitGraph *jg,
1353: | mov aword FRAME->jit_entry_label, TMP1;
2218=void MVM_jit_emit_invoke(MVMThreadContext *tc, MVMJitCompiler *compiler, MVMJitGraph *jg, MVMJitInvoke *invoke) {
2283: | mov aword FRAME->jit_entry_label, TMP2;
2343=void MVM_jit_emit_control(MVMThreadContext *tc, MVMJitCompiler *compiler, MVMJitGraph *jg,
2350: | mov aword FRAME->jit_entry_label, TMP1;
2361: | mov aword FRAME->jit_entry_label, TMP1;
2369: | mov aword FRAME->jit_entry_label, TMP1;
2377: * jit_entry_label now points to the correct label. If not, it
2379: | jmp aword FRAME->jit_entry_label;
src/spesh/deopt.c
219=void MVM_spesh_deopt_all(MVMThreadContext *tc) {
228: if (f->spesh_cand->jitcode && f->jit_entry_label) {
234: if (labels[deopts[i].label] == f->jit_entry_label) {
258: f->jit_entry_label = NULL;
src/spesh/osr.c
75=void MVM_spesh_osr_finalize(MVMThreadContext *tc) {
127: tc->cur_frame->jit_entry_label = jc->labels[jc->deopts[i].label];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment