diff --git a/src/codegen.c b/src/codegen.c index 71ae73ce..b02592e6 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -664,8 +664,8 @@ pic_codegen(pic_state *pic, pic_value obj) } state->irep = new_irep(pic); state->irep->argc = 1; - codegen(state, obj, false); - state->irep->code[state->irep->clen].insn = OP_STOP; + codegen(state, pic_expand(pic, obj), false); + state->irep->code[state->irep->clen].insn = OP_RET; state->irep->clen++; env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TT_ENV); diff --git a/src/vm.c b/src/vm.c index aa0ed709..7da07712 100644 --- a/src/vm.c +++ b/src/vm.c @@ -185,7 +185,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) int ai = pic_gc_arena_preserve(pic); jmp_buf jmp; size_t argc, i; - struct pic_code boot; + struct pic_code boot[2]; #if PIC_DIRECT_THREADED_VM static void *oplabels[] = { @@ -214,8 +214,9 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) } /* boot! */ - boot.insn = OP_CALL; - boot.u.i = argc; + boot[0].insn = OP_CALL; + boot[0].u.i = argc; + boot[1].insn = OP_STOP; pc = &boot; goto L_CALL; @@ -516,7 +517,6 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) L_STOP: val = POP(); - pic->sp = POPCI()->fp; pic->jmp = NULL; if (pic->errmsg) {