diff --git a/main/gbx/gb.jit.h b/main/gbx/gb.jit.h index 07a8c17d5..ac14b82ad 100644 --- a/main/gbx/gb.jit.h +++ b/main/gbx/gb.jit.h @@ -47,6 +47,7 @@ typedef void **cp; char **op; GB_VALUE *ret; + bool *exec_debug; void (*debug)(const char *fmt, ...); JIT_PCODE *(*get_code)(void *class, int index); void (*throw)(int code, ...) NORETURN; @@ -75,6 +76,8 @@ typedef void (*push_complex)(void); void (*push_vargs)(void); void (*pop_vargs)(void); + void (*exec_quit)(ushort code); + void (*exec_break)(ushort code); } JIT_INTERFACE; diff --git a/main/gbx/gbx_api.c b/main/gbx/gbx_api.c index 6975c3e96..20a524e67 100644 --- a/main/gbx/gbx_api.c +++ b/main/gbx/gbx_api.c @@ -340,6 +340,7 @@ const void *const GAMBAS_JitApi[] = (void *)&CP, (void *)&OP, (void *)&TEMP, + (void *)&EXEC_debug, (void *)JIT_debug, (void *)JIT_get_code, (void *)THROW, @@ -368,6 +369,8 @@ const void *const GAMBAS_JitApi[] = (void *)EXEC_push_complex, (void *)EXEC_push_vargs, (void *)EXEC_drop_vargs, + (void *)EXEC_quit, + (void *)EXEC_break, NULL }; diff --git a/main/gbx/gbx_exec.c b/main/gbx/gbx_exec.c index 015d496e3..7a337a79a 100644 --- a/main/gbx/gbx_exec.c +++ b/main/gbx/gbx_exec.c @@ -1943,7 +1943,7 @@ void EXEC_new(ushort code) } -void EXEC_quit(void) +void EXEC_do_quit(void) { GAMBAS_DoNotRaiseEvent = TRUE; diff --git a/main/gbx/gbx_exec.h b/main/gbx/gbx_exec.h index d388bc06c..31c9e6b02 100644 --- a/main/gbx/gbx_exec.h +++ b/main/gbx/gbx_exec.h @@ -239,7 +239,7 @@ void *EXEC_create_object(CLASS *class, int np, char *event); void EXEC_new(ushort code); void EXEC_release_return_value(void); -void EXEC_quit(void); +void EXEC_do_quit(void); void EXEC_dup(int n); @@ -345,6 +345,9 @@ void SUBR_left(ushort code); void SUBR_mid(ushort code); void SUBR_right(ushort code); +void EXEC_quit(ushort code); +void EXEC_break(ushort code); + void EXEC_push_array(ushort code); void EXEC_pop_array(ushort code); diff --git a/main/gbx/gbx_exec_loop.c b/main/gbx/gbx_exec_loop.c index 16b3b898a..b41ba92d2 100644 --- a/main/gbx/gbx_exec_loop.c +++ b/main/gbx/gbx_exec_loop.c @@ -66,8 +66,6 @@ static void my_VALUE_class_read(CLASS *class, VALUE *value, char *addr, CTYPE ctype, void *ref); static void my_VALUE_class_constant(CLASS *class, VALUE *value, int ind); -static void _quit(ushort code); -static void _break(ushort code); //static void _SUBR_comp(ushort code); static void _SUBR_compe(ushort code); @@ -1860,14 +1858,14 @@ _CATCH: _BREAK: - _break(code); + EXEC_break(code); goto _NEXT; /*-----------------------------------------------*/ _QUIT: - _quit(code); + EXEC_quit(code); goto _NEXT; /*-----------------------------------------------*/ @@ -3927,12 +3925,12 @@ __POP_ARRAY_2: POP(); /* free the object */ } -static void _quit(ushort code) +void EXEC_quit(ushort code) { switch(code & 3) { case 0: - EXEC_quit(); + EXEC_do_quit(); break; case 1: @@ -3948,12 +3946,12 @@ static void _quit(ushort code) VALUE_conv(&SP[-1], T_BYTE); SP--; EXEC_quit_value = (uchar)SP->_integer.value; - EXEC_quit(); + EXEC_do_quit(); break; } } -static void _break(ushort code) +void EXEC_break(ushort code) { if (EXEC_debug) { diff --git a/main/lib/jit/gb.jit/jit.h b/main/lib/jit/gb.jit/jit.h index 4b2e1919c..44db1d05b 100644 --- a/main/lib/jit/gb.jit/jit.h +++ b/main/lib/jit/gb.jit/jit.h @@ -386,3 +386,5 @@ enum #define ERROR_handler (*(ERROR_HANDLER **)(JIT.error_handler)) #define ERROR_reset JIT.error_reset +#define BREAK(_pc, _code) (PC = &pc[_pc], SP = sp, JIT.exec_break(_code)) +#define QUIT(_code) (SP = sp, JIT.exec_quit(_code)) diff --git a/main/lib/jit/jit_body.c b/main/lib/jit/jit_body.c index 8467edcad..ffedd2281 100644 --- a/main/lib/jit/jit_body.c +++ b/main/lib/jit/jit_body.c @@ -2656,11 +2656,27 @@ _SUBR_BIT: _BREAK: + /*if (*(JIT.exec_debug)) + JIT_print(" BREAK(%d,0x%04X);\n", _pc, code);*/ + goto _MAIN; + +_QUIT: + + JIT_print(" "); + + if ((code & 3) == 3) + { + check_stack(1); + JIT_print("%s,", push_expr(-1, T_BYTE)); + pop_stack(1); + } + + JIT_print(" QUIT(0x%04X);\n", code); goto _MAIN; _TRY: - JIT_print(" TRY {\n", _pc); + JIT_print(" TRY {\n"); p++; goto _MAIN; @@ -2723,7 +2739,6 @@ _ON_GOTO_GOSUB: _PUSH_EVENT: _PUSH_EXTERN: _BYREF: -_QUIT: _CALL_QUICK: _CALL_SLOW: _ILLEGAL: