aboutsummaryrefslogtreecommitdiff
path: root/src/compile/compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile/compile.c')
-rw-r--r--src/compile/compile.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/compile/compile.c b/src/compile/compile.c
index d716ca3..91a8ea8 100644
--- a/src/compile/compile.c
+++ b/src/compile/compile.c
@@ -287,7 +287,16 @@ static size_t compile_fn_body(struct ejit_func *f, jit_state_t *j, void *arena,
struct vec labels = vec_create(sizeof(jit_addr_t));
vec_reserve(&labels, vec_len(&f->insns));
+ size_t label = 0;
foreach_vec(ii, f->insns) {
+ /* if we've hit a label, add it to our vector of label addresses */
+ if (label < vec_len(&f->labels)) {
+ if (vect_at(size_t, f->labels, label) == ii) {
+ compile_label(j, ii, &labels);
+ label++;
+ }
+ }
+
struct ejit_insn i = vect_at(struct ejit_insn, f->insns, ii);
switch (i.op) {
case MOVR: compile_movr(f, j, i); break;
@@ -349,7 +358,6 @@ static size_t compile_fn_body(struct ejit_func *f, jit_state_t *j, void *arena,
break;
}
- case LABEL: compile_label(j, ii, &labels); break;
case RET: {
jit_gpr_t r = getloc(f, j, i.r0, 0);
/* R0 won't get overwritten by jit_leave_jit_abi */