VM works with procs not terminated with OP_STOP
This commit is contained in:
parent
5be1cd7092
commit
d4001a70ae
|
@ -664,8 +664,8 @@ pic_codegen(pic_state *pic, pic_value obj)
|
||||||
}
|
}
|
||||||
state->irep = new_irep(pic);
|
state->irep = new_irep(pic);
|
||||||
state->irep->argc = 1;
|
state->irep->argc = 1;
|
||||||
codegen(state, obj, false);
|
codegen(state, pic_expand(pic, obj), false);
|
||||||
state->irep->code[state->irep->clen].insn = OP_STOP;
|
state->irep->code[state->irep->clen].insn = OP_RET;
|
||||||
state->irep->clen++;
|
state->irep->clen++;
|
||||||
|
|
||||||
env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TT_ENV);
|
env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TT_ENV);
|
||||||
|
|
8
src/vm.c
8
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);
|
int ai = pic_gc_arena_preserve(pic);
|
||||||
jmp_buf jmp;
|
jmp_buf jmp;
|
||||||
size_t argc, i;
|
size_t argc, i;
|
||||||
struct pic_code boot;
|
struct pic_code boot[2];
|
||||||
|
|
||||||
#if PIC_DIRECT_THREADED_VM
|
#if PIC_DIRECT_THREADED_VM
|
||||||
static void *oplabels[] = {
|
static void *oplabels[] = {
|
||||||
|
@ -214,8 +214,9 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* boot! */
|
/* boot! */
|
||||||
boot.insn = OP_CALL;
|
boot[0].insn = OP_CALL;
|
||||||
boot.u.i = argc;
|
boot[0].u.i = argc;
|
||||||
|
boot[1].insn = OP_STOP;
|
||||||
pc = &boot;
|
pc = &boot;
|
||||||
goto L_CALL;
|
goto L_CALL;
|
||||||
|
|
||||||
|
@ -516,7 +517,6 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
|
||||||
|
|
||||||
L_STOP:
|
L_STOP:
|
||||||
val = POP();
|
val = POP();
|
||||||
pic->sp = POPCI()->fp;
|
|
||||||
|
|
||||||
pic->jmp = NULL;
|
pic->jmp = NULL;
|
||||||
if (pic->errmsg) {
|
if (pic->errmsg) {
|
||||||
|
|
Loading…
Reference in New Issue