From 39390edcf95f3fe21dbb68e0e35f1d8b5b93588e Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 23 Jun 2019 11:44:30 +0200 Subject: [PATCH] jmp_buf as struct + offset workaround --- src/comp.c | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/comp.c b/src/comp.c index 61809a01227..aee7ca99463 100644 --- a/src/comp.c +++ b/src/comp.c @@ -186,11 +186,12 @@ typedef struct { gcc_jit_type *emacs_int_type; gcc_jit_type *void_ptr_type; gcc_jit_type *ptrdiff_type; - gcc_jit_type *jmp_buf_type; gcc_jit_type *lisp_obj_type; gcc_jit_type *lisp_obj_ptr_type; gcc_jit_field *lisp_obj_as_ptr; gcc_jit_field *lisp_obj_as_num; + /* struct jmp_buf. */ + gcc_jit_struct *jmp_buf; /* struct handler. */ gcc_jit_struct *handler; gcc_jit_field *handler_jmp_field; @@ -773,18 +774,40 @@ emit_scratch_callN (const char *f_name, unsigned nargs, gcc_jit_rvalue **args) return emit_call (f_name, comp.lisp_obj_type, 2, args); } +/* opaque jmp_buf definition */ + +static void +define_jmp_buf (void) +{ + gcc_jit_field *field = + gcc_jit_context_new_field ( + comp.ctxt, + NULL, + gcc_jit_context_new_array_type (comp.ctxt, + NULL, + comp.char_type, + sizeof (jmp_buf)), + "stuff"); + comp.jmp_buf = + gcc_jit_context_new_struct_type (comp.ctxt, + NULL, + "comp_jmp_buf", + 1, &field); +} + /* struct handler definition */ static void define_handler_struct (void) { - comp.handler = gcc_jit_context_new_opaque_struct (comp.ctxt, NULL, "handler"); + comp.handler = gcc_jit_context_new_opaque_struct (comp.ctxt, NULL, "comp_handler"); comp.handler_ptr_type = gcc_jit_type_get_pointer (gcc_jit_struct_as_type (comp.handler)); comp.handler_jmp_field = gcc_jit_context_new_field (comp.ctxt, NULL, - comp.jmp_buf_type, + gcc_jit_struct_as_type ( + comp.jmp_buf), "jmp"); comp.handler_val_field = gcc_jit_context_new_field (comp.ctxt, NULL, @@ -821,6 +844,13 @@ define_handler_struct (void) NULL, comp.int_type, "bytecode_dest"), + gcc_jit_context_new_field (comp.ctxt, + NULL, + gcc_jit_context_new_array_type (comp.ctxt, + NULL, + comp.char_type, + 4), + "pad"), comp.handler_jmp_field, gcc_jit_context_new_field (comp.ctxt, NULL, @@ -1273,11 +1303,6 @@ init_comp (int opt_level) comp.ptrdiff_type = gcc_jit_context_get_type (comp.ctxt, ptrdiff_t_gcc); - /* Opaque definition for jmp_buf. */ - comp.jmp_buf_type = gcc_jit_context_new_array_type (comp.ctxt, - NULL, - comp.char_type, - sizeof (jmp_buf)); comp.scratch = gcc_jit_lvalue_get_address( gcc_jit_context_new_global (comp.ctxt, NULL, @@ -1288,6 +1313,7 @@ init_comp (int opt_level) comp.func_hash = CALLN (Fmake_hash_table, QCtest, Qequal, QCweakness, Qt); + define_jmp_buf (); define_handler_struct (); define_thread_state_struct (); comp.current_thread = -- 2.39.5