From 599fc81ed550a846858c2c018598a55fe6660eea Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 4 Oct 2004 04:22:23 +0000 Subject: [PATCH] Use a common helper function for performing debug hook tests on native platforms, to avoid the need to implement breakpoint testing individually in every native back end. --- ChangeLog | 5 ++++ jit/jit-insn.c | 60 +++++++++++++++++++++++++++++++++++++++++++ jit/jit-rules-arm.sel | 10 -------- jit/jit-rules-x86.sel | 10 -------- 4 files changed, 65 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 81ab682..463fe60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,11 @@ jitplus/jit-plus-function.cpp: clean up the breakpoint API and implement debug hooks for the interpreter. + * jit/jit-insn.c, jit/jit-rules-arm.sel, jit/jit-rules-x86.sel: + use a common helper function for performing debug hook tests on + native platforms, to avoid the need to implement breakpoint testing + individually in every native back end. + 2004-09-10 Rhys Weatherley * jit/jit-rules-x86.sel: pointer-relative loads and stores diff --git a/jit/jit-insn.c b/jit/jit-insn.c index 75924b3..b0b7a9c 100644 --- a/jit/jit-insn.c +++ b/jit/jit-insn.c @@ -7694,10 +7694,33 @@ int jit_insn_mark_offset(jit_function_t func, jit_int offset) (func, jit_type_int, offset)); } +#if !defined(JIT_BACKEND_INTERP) + +/* + * Perform first-level debug hook testing. + */ +void _jit_hook_test(jit_function_t func, jit_nint data1, jit_nint data2) +{ + if(func->breakpoints_enabled || func->context->breakpoints_enabled) + { + jit_debug_hook_func hook; + hook = (jit_debug_hook_func) + jit_context_get_meta(func->context, JIT_OPTION_DEBUG_HOOK); + if(hook) + { + (*hook)(func, data1, data2); + } + } +} + +#endif /* !JIT_BACKEND_INTERP */ + /* Documentation is in jit-debug.c */ int jit_insn_mark_breakpoint (jit_function_t func, jit_nint data1, jit_nint data2) { +#if defined(JIT_BACKEND_INTERP) + /* Use the "mark_breakpoint" instruction for the interpreter */ if(!jit_insn_new_block(func)) { return 0; @@ -7707,6 +7730,43 @@ int jit_insn_mark_breakpoint (func, jit_type_nint, data1), jit_value_create_nint_constant (func, jit_type_nint, data2)); +#else + /* Insert a call to "_jit_hook_test" on native platforms */ + jit_type_t params[3]; + jit_type_t signature; + jit_value_t values[3]; + params[0] = jit_type_void_ptr; + params[1] = jit_type_nint; + params[2] = jit_type_nint; + signature = jit_type_create_signature + (jit_abi_cdecl, jit_type_void, params, 3, 0); + if(!signature) + { + return 0; + } + if((values[0] = jit_value_create_nint_constant + (func, jit_type_void_ptr, (jit_nint)func)) == 0) + { + jit_type_free(signature); + return 0; + } + if((values[1] = jit_value_create_nint_constant + (func, jit_type_nint, data1)) == 0) + { + jit_type_free(signature); + return 0; + } + if((values[2] = jit_value_create_nint_constant + (func, jit_type_nint, data2)) == 0) + { + jit_type_free(signature); + return 0; + } + jit_insn_call_native(func, "_jit_hook_test", (void *)_jit_hook_test, + signature, values, 3, JIT_CALL_NOTHROW); + jit_type_free(signature); + return 1; +#endif } /*@ diff --git a/jit/jit-rules-arm.sel b/jit/jit-rules-arm.sel index e27304e..173033f 100644 --- a/jit/jit-rules-arm.sel +++ b/jit/jit-rules-arm.sel @@ -1399,13 +1399,3 @@ JIT_OP_ADD_RELATIVE: unary arm_alu_reg_imm(inst, ARM_ADD, $1, $1, insn->value2->address); } } - -/* - * Debugging support. - */ - -JIT_OP_MARK_BREAKPOINT: manual - [] -> { - /* TODO */ - TODO(); - } diff --git a/jit/jit-rules-x86.sel b/jit/jit-rules-x86.sel index c29d739..30aa4cc 100644 --- a/jit/jit-rules-x86.sel +++ b/jit/jit-rules-x86.sel @@ -2800,13 +2800,3 @@ JIT_OP_ALLOCA: unary x86_mov_reg_reg(inst, $1, X86_ESP, 4); gen->stack_changed = 1; } - -/* - * Debugging support. - */ - -JIT_OP_MARK_BREAKPOINT: manual - [] -> { - /* TODO */ - TODO(); - } -- 2.47.3