diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/compile/compile.c | 17 | ||||
| -rw-r--r-- | src/interp.c | 14 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/compile/compile.c b/src/compile/compile.c index 5aab67e..7965f93 100644 --- a/src/compile/compile.c +++ b/src/compile/compile.c @@ -47,7 +47,7 @@ static void *alloc_arena(size_t size, bool im_scawed) MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); } -static void assert_helper(const char *msg) +static inline void assert_helper(const char *msg) { assert(false && msg); } @@ -1974,6 +1974,10 @@ static void resolve_top_reloc(jit_state_t *j, struct relocs *relocs, struct addr assert(a); jit_patch_there(j, r, a); relocs_pop(relocs); + + /* hope this turns into a tailcall */ + if (relocs_len(relocs)) + resolve_top_reloc(j, relocs, addrs, ii); } static void resolve_relocs(jit_state_t *j, struct relocs *relocs, struct addrs *addrs, size_t ii) @@ -2066,12 +2070,11 @@ static size_t compile_fn_body(struct ejit_func *f, jit_state_t *j, void *arena, size_t label = 0; for (size_t ii = 0; ii < insns_len(&f->insns); ++ii) { /* if we've hit a label, add it to our vector of label addresses */ - if (label < labels_len(&f->labels)) { - if (*labels_at(&f->labels, label) == ii) { - compile_label(j, ii, &addrs); - resolve_relocs(j, &relocs, &addrs, ii); - label++; - } + while (label < labels_len(&f->labels) + && *labels_at(&f->labels, label) == ii) { + compile_label(j, ii, &addrs); + resolve_relocs(j, &relocs, &addrs, ii); + label++; } struct ejit_insn i = *insns_at(&f->insns, ii); diff --git a/src/interp.c b/src/interp.c index 894be30..7fdd4b1 100644 --- a/src/interp.c +++ b/src/interp.c @@ -258,7 +258,7 @@ union interp_ret ejit_run(struct ejit_func *f, size_t paramc, struct ejit_arg pa }; } -top: +top:; union interp_ret retval = {.i = 0}; union fpr { double d; @@ -1019,7 +1019,7 @@ top: case EJIT_UINT16: gpr[i.r2] = params[i.r0].u16; break; case EJIT_UINT32: gpr[i.r2] = params[i.r0].u32; break; case EJIT_UINT64: gpr[i.r2] = params[i.r0].u64; break; - case EJIT_POINTER: gpr[i.r2] = (int64_t)params[i.r0].p; break; + case EJIT_POINTER: gpr[i.r2] = (int64_t)(intptr_t)params[i.r0].p; break; default: abort(); } DISPATCH(); @@ -1075,7 +1075,7 @@ top: DISPATCH(); DO(TAILR); - f = (struct ejit_func *)gpr[i.r1]; + f = (struct ejit_func *)(intptr_t)gpr[i.r1]; /** @todo we could potentially just interpret the func as a fallback * instead of aborting here, but this is good enough for now */ @@ -1089,22 +1089,22 @@ top: DISPATCH(); DO(CALLR_I); - retval = ejit_run((struct ejit_func *)gpr[i.r1], argc, args, NULL); + retval = ejit_run((struct ejit_func *)(intptr_t)gpr[i.r1], argc, args, NULL); argc = 0; DISPATCH(); DO(CALLR_L); - retval = ejit_run((struct ejit_func *)gpr[i.r1], argc, args, NULL); + retval = ejit_run((struct ejit_func *)(intptr_t)gpr[i.r1], argc, args, NULL); argc = 0; DISPATCH(); DO(CALLR_F); - retval = ejit_run((struct ejit_func *)gpr[i.r1], argc, args, NULL); + retval = ejit_run((struct ejit_func *)(intptr_t)gpr[i.r1], argc, args, NULL); argc = 0; DISPATCH(); DO(CALLR_D); - retval = ejit_run((struct ejit_func *)gpr[i.r1], argc, args, NULL); + retval = ejit_run((struct ejit_func *)(intptr_t)gpr[i.r1], argc, args, NULL); argc = 0; DISPATCH(); |
