Merge branch 'master' into record-vector-optimization
This commit is contained in:
commit
f213119dd6
|
@ -364,7 +364,7 @@ typedef struct codegen_context {
|
|||
pic_code *code;
|
||||
size_t clen, ccapa;
|
||||
/* child ireps */
|
||||
union irep_node *irep;
|
||||
struct pic_irep **irep;
|
||||
size_t ilen, icapa;
|
||||
/* constant object pool */
|
||||
int *ints;
|
||||
|
@ -393,7 +393,7 @@ codegen_context_init(pic_state *pic, codegen_context *cxt, codegen_context *up,
|
|||
cxt->clen = 0;
|
||||
cxt->ccapa = PIC_ISEQ_SIZE;
|
||||
|
||||
cxt->irep = pic_calloc(pic, PIC_IREP_SIZE, sizeof(union irep_node));
|
||||
cxt->irep = pic_calloc(pic, PIC_IREP_SIZE, sizeof(struct pic_irep *));
|
||||
cxt->ilen = 0;
|
||||
cxt->icapa = PIC_IREP_SIZE;
|
||||
|
||||
|
@ -424,10 +424,10 @@ codegen_context_destroy(pic_state *pic, codegen_context *cxt)
|
|||
irep->argc = (int)cxt->args->len + 1;
|
||||
irep->localc = (int)cxt->locals->len;
|
||||
irep->capturec = (int)cxt->captures->len;
|
||||
irep->u.s.code = pic_realloc(pic, cxt->code, sizeof(pic_code) * cxt->clen);
|
||||
irep->u.s.irep = pic_realloc(pic, cxt->irep, sizeof(union irep_node) * cxt->ilen);
|
||||
irep->u.s.ints = pic_realloc(pic, cxt->ints, sizeof(int) * cxt->klen);
|
||||
irep->u.s.nums = pic_realloc(pic, cxt->nums, sizeof(double) * cxt->flen);
|
||||
irep->code = pic_realloc(pic, cxt->code, sizeof(pic_code) * cxt->clen);
|
||||
irep->irep = pic_realloc(pic, cxt->irep, sizeof(struct pic_irep *) * cxt->ilen);
|
||||
irep->ints = pic_realloc(pic, cxt->ints, sizeof(int) * cxt->klen);
|
||||
irep->nums = pic_realloc(pic, cxt->nums, sizeof(double) * cxt->flen);
|
||||
irep->pool = pic_realloc(pic, cxt->pool, sizeof(struct pic_object *) * cxt->plen);
|
||||
irep->ncode = cxt->clen;
|
||||
irep->nirep = cxt->ilen;
|
||||
|
@ -647,7 +647,7 @@ codegen_lambda(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos
|
|||
/* emit irep */
|
||||
codegen_context_init(pic, inner_cxt, cxt, rest, args, locals, captures);
|
||||
codegen(pic, inner_cxt, body, true);
|
||||
cxt->irep[cxt->ilen].i = codegen_context_destroy(pic, inner_cxt);
|
||||
cxt->irep[cxt->ilen] = codegen_context_destroy(pic, inner_cxt);
|
||||
|
||||
/* emit OP_LAMBDA */
|
||||
emit_i(pic, cxt, OP_LAMBDA, cxt->ilen++);
|
||||
|
|
|
@ -24,17 +24,11 @@ struct pic_irep {
|
|||
unsigned refc;
|
||||
int argc, localc, capturec;
|
||||
bool varg;
|
||||
union {
|
||||
struct {
|
||||
pic_code *code;
|
||||
struct pic_irep **irep;
|
||||
int *ints;
|
||||
double *nums;
|
||||
union irep_node {
|
||||
struct pic_irep *i;
|
||||
} *irep;
|
||||
} s;
|
||||
} u;
|
||||
struct pic_object **pool; /* pool of heap objects */
|
||||
struct pic_object **pool;
|
||||
size_t ncode, nirep, nints, nnums, npool;
|
||||
};
|
||||
|
||||
|
|
|
@ -392,15 +392,15 @@ pic_apply(pic_state *pic, struct pic_proc *proc, int argc, pic_value *argv)
|
|||
NEXT;
|
||||
}
|
||||
CASE(OP_PUSHINT) {
|
||||
PUSH(pic_int_value(pic->ci->irep->u.s.ints[c.a]));
|
||||
PUSH(pic_int_value(pic->ci->irep->ints[c.a]));
|
||||
NEXT;
|
||||
}
|
||||
CASE(OP_PUSHFLOAT) {
|
||||
PUSH(pic_float_value(pic->ci->irep->u.s.nums[c.a]));
|
||||
PUSH(pic_float_value(pic->ci->irep->nums[c.a]));
|
||||
NEXT;
|
||||
}
|
||||
CASE(OP_PUSHCHAR) {
|
||||
PUSH(pic_char_value(pic->ci->irep->u.s.ints[c.a]));
|
||||
PUSH(pic_char_value(pic->ci->irep->ints[c.a]));
|
||||
NEXT;
|
||||
}
|
||||
CASE(OP_PUSHEOF) {
|
||||
|
@ -560,7 +560,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, int argc, pic_value *argv)
|
|||
ci->regc = irep->capturec;
|
||||
ci->regs = ci->fp + irep->argc + irep->localc;
|
||||
|
||||
pic->ip = irep->u.s.code;
|
||||
pic->ip = irep->code;
|
||||
pic_gc_arena_restore(pic, ai);
|
||||
JUMP;
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, int argc, pic_value *argv)
|
|||
vm_push_cxt(pic);
|
||||
}
|
||||
|
||||
proc = pic_make_proc_irep(pic, pic->ci->irep->u.s.irep[c.a].i, pic->ci->cxt);
|
||||
proc = pic_make_proc_irep(pic, pic->ci->irep->irep[c.a], pic->ci->cxt);
|
||||
PUSH(pic_obj_value(proc));
|
||||
pic_gc_arena_restore(pic, ai);
|
||||
NEXT;
|
||||
|
@ -1032,9 +1032,9 @@ pic_irep_decref(pic_state *pic, struct pic_irep *irep)
|
|||
size_t i;
|
||||
|
||||
if (--irep->refc == 0) {
|
||||
pic_free(pic, irep->u.s.code);
|
||||
pic_free(pic, irep->u.s.ints);
|
||||
pic_free(pic, irep->u.s.nums);
|
||||
pic_free(pic, irep->code);
|
||||
pic_free(pic, irep->ints);
|
||||
pic_free(pic, irep->nums);
|
||||
pic_free(pic, irep->pool);
|
||||
|
||||
/* unchain before decref children ireps */
|
||||
|
@ -1042,9 +1042,9 @@ pic_irep_decref(pic_state *pic, struct pic_irep *irep)
|
|||
irep->list.next->prev = irep->list.prev;
|
||||
|
||||
for (i = 0; i < irep->nirep; ++i) {
|
||||
pic_irep_decref(pic, irep->u.s.irep[i].i);
|
||||
pic_irep_decref(pic, irep->irep[i]);
|
||||
}
|
||||
pic_free(pic, irep->u.s.irep);
|
||||
pic_free(pic, irep->irep);
|
||||
pic_free(pic, irep);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue