From 892d0f16b2e69bc527b576ee896c39484216338f Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 26 Jun 2024 22:36:59 +0300 Subject: move labels out of the bytecode + Speeds up interpreter a little bit since we don't have to execute what's effectively a no-op --- src/compile/compile.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/compile/compile.c') 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 */ -- cgit v1.2.3