diff options
Diffstat (limited to 'src/ejit.c')
-rw-r--r-- | src/ejit.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -338,11 +338,12 @@ struct ejit_func *ejit_create_func(enum ejit_type rtype, size_t argc, f->rtype = rtype; - f->sign = types_create(); - f->insns = insns_create(); - f->labels = labels_create(); - f->gpr = gpr_stats_create(); - f->fpr = fpr_stats_create(); + f->sign = types_create(0); + f->insns = insns_create(0); + f->labels = labels_create(0); + f->barriers = barriers_create(0); + f->gpr = gpr_stats_create(0); + f->fpr = fpr_stats_create(0); f->arena = NULL; f->direct_call = NULL; f->extern_call = NULL; @@ -416,12 +417,10 @@ void ejit_select_compile_func(struct ejit_func *f, size_t gpr, size_t fpr, /* just get labels, don't actually run anything yet */ ejit_run(f, 0, NULL, &labels); - foreach_vec(ii, f->insns) { - struct ejit_insn i = *insns_at(&f->insns, ii); - void *addr = labels[i.op]; + foreach(insns, i, &f->insns) { + void *addr = labels[i->op]; assert(addr); - i.addr = addr; - *insns_at(&f->insns, ii) = i; + i->addr = addr; } /* doesn't really matter what we put here as long as it isn't 0 */ @@ -436,6 +435,7 @@ void ejit_destroy_func(struct ejit_func *f) types_destroy(&f->sign); insns_destroy(&f->insns); labels_destroy(&f->labels); + barriers_destroy(&f->barriers); gpr_stats_destroy(&f->gpr); fpr_stats_destroy(&f->fpr); free(f); @@ -454,6 +454,12 @@ void ejit_patch(struct ejit_func *f, struct ejit_reloc r, struct ejit_label l) /** @todo some assert that checks the opcode? */ i.r0 = l.addr; *insns_at(&f->insns, r.insn) = i; + + struct barrier_tuple tuple = { + .start = r.insn > l.addr ? l.addr : r.insn, + .end = r.insn > l.addr ? r.insn : l.addr + }; + barriers_append(&f->barriers, tuple); } void ejit_taili(struct ejit_func *s, struct ejit_func *f, |