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/ejit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/ejit.c') diff --git a/src/ejit.c b/src/ejit.c index 246f1fc..2e13e93 100644 --- a/src/ejit.c +++ b/src/ejit.c @@ -37,6 +37,7 @@ struct ejit_func *ejit_create_func(enum ejit_type rtype, size_t argc, const stru f->rtype = rtype; f->insns = vec_create(sizeof(struct ejit_insn)); + f->labels = vec_create(sizeof(size_t)); f->arena = NULL; f->size = 0; @@ -84,13 +85,14 @@ void ejit_destroy_func(struct ejit_func *f) munmap(f->arena, f->size); vec_destroy(&f->insns); + vec_destroy(&f->labels); free(f); } struct ejit_label ejit_label(struct ejit_func *f) { size_t addr = vec_len(&f->insns); - emit_insn_r(f, LABEL, 0, 0, 0); + vec_append(&f->labels, &addr); return (struct ejit_label){.addr = addr}; } -- cgit v1.2.3