aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2019-11-10 08:58:48 +0100
committerAndrea Corallo2020-01-01 11:38:02 +0100
commitc47892201b2b9f1ef903ff2a12bb9ed9e64d19de (patch)
tree193f11646f967fe8dd322c6d7fbd71ca65a71148 /src
parent6d230fc2c04532b4abf2474411b2995c237d5cc8 (diff)
downloademacs-c47892201b2b9f1ef903ff2a12bb9ed9e64d19de.tar.gz
emacs-c47892201b2b9f1ef903ff2a12bb9ed9e64d19de.zip
add current thread missing reloc mechanism
Diffstat (limited to 'src')
-rw-r--r--src/comp.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/comp.c b/src/comp.c
index 273d8aeac33..04a63c1aec5 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -38,6 +38,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
38#define COMP_DEBUG 1 38#define COMP_DEBUG 1
39 39
40/* C symbols emited for the load relocation mechanism. */ 40/* C symbols emited for the load relocation mechanism. */
41#define CURRENT_THREAD_RELOC_SYM "current_thread_reloc"
41#define DATA_RELOC_SYM "d_reloc" 42#define DATA_RELOC_SYM "d_reloc"
42#define IMPORTED_FUNC_RELOC_SYM "f_reloc" 43#define IMPORTED_FUNC_RELOC_SYM "f_reloc"
43#define TEXT_DATA_RELOC_SYM "text_data_reloc" 44#define TEXT_DATA_RELOC_SYM "text_data_reloc"
@@ -116,7 +117,7 @@ typedef struct {
116 gcc_jit_struct *thread_state_s; 117 gcc_jit_struct *thread_state_s;
117 gcc_jit_field *m_handlerlist; 118 gcc_jit_field *m_handlerlist;
118 gcc_jit_type *thread_state_ptr_type; 119 gcc_jit_type *thread_state_ptr_type;
119 gcc_jit_rvalue *current_thread; 120 gcc_jit_rvalue *current_thread_ref;
120 /* other globals */ 121 /* other globals */
121 gcc_jit_rvalue *pure; 122 gcc_jit_rvalue *pure;
122 /* libgccjit has really limited support for casting therefore this union will 123 /* libgccjit has really limited support for casting therefore this union will
@@ -1258,9 +1259,11 @@ emit_limple_insn (Lisp_Object insn)
1258 current_thread->m_handlerlist->next; 1259 current_thread->m_handlerlist->next;
1259 */ 1260 */
1260 gcc_jit_lvalue *m_handlerlist = 1261 gcc_jit_lvalue *m_handlerlist =
1261 gcc_jit_rvalue_dereference_field (comp.current_thread, 1262 gcc_jit_rvalue_dereference_field (
1262 NULL, 1263 gcc_jit_lvalue_as_rvalue (
1263 comp.m_handlerlist); 1264 gcc_jit_rvalue_dereference (comp.current_thread_ref, NULL)),
1265 NULL,
1266 comp.m_handlerlist);
1264 1267
1265 gcc_jit_block_add_assignment( 1268 gcc_jit_block_add_assignment(
1266 comp.block, 1269 comp.block,
@@ -1279,7 +1282,9 @@ emit_limple_insn (Lisp_Object insn)
1279 gcc_jit_lvalue *c = 1282 gcc_jit_lvalue *c =
1280 xmint_pointer (AREF (comp.buffer_handler_vec, handler_buff_n)); 1283 xmint_pointer (AREF (comp.buffer_handler_vec, handler_buff_n));
1281 gcc_jit_lvalue *m_handlerlist = 1284 gcc_jit_lvalue *m_handlerlist =
1282 gcc_jit_rvalue_dereference_field (comp.current_thread, 1285 gcc_jit_rvalue_dereference_field (
1286 gcc_jit_lvalue_as_rvalue (
1287 gcc_jit_rvalue_dereference (comp.current_thread_ref, NULL)),
1283 NULL, 1288 NULL,
1284 comp.m_handlerlist); 1289 comp.m_handlerlist);
1285 gcc_jit_block_add_assignment ( 1290 gcc_jit_block_add_assignment (
@@ -1723,6 +1728,15 @@ emit_ctxt_code (void)
1723{ 1728{
1724 USE_SAFE_ALLOCA; 1729 USE_SAFE_ALLOCA;
1725 1730
1731 comp.current_thread_ref =
1732 gcc_jit_lvalue_as_rvalue (
1733 gcc_jit_context_new_global (
1734 comp.ctxt,
1735 NULL,
1736 GCC_JIT_GLOBAL_EXPORTED,
1737 gcc_jit_type_get_pointer (comp.thread_state_ptr_type),
1738 CURRENT_THREAD_RELOC_SYM));
1739
1726 declare_runtime_imported_data (); 1740 declare_runtime_imported_data ();
1727 /* Imported objects. */ 1741 /* Imported objects. */
1728 EMACS_UINT d_reloc_len = 1742 EMACS_UINT d_reloc_len =
@@ -2984,15 +2998,11 @@ DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
2984 define_thread_state_struct (); 2998 define_thread_state_struct ();
2985 define_cast_union (); 2999 define_cast_union ();
2986 3000
2987 comp.current_thread = 3001 /* FIXME!! */
2988 gcc_jit_context_new_rvalue_from_ptr (comp.ctxt,
2989 comp.thread_state_ptr_type,
2990 current_thread);
2991 comp.pure = 3002 comp.pure =
2992 gcc_jit_context_new_rvalue_from_ptr (comp.ctxt, 3003 gcc_jit_context_new_rvalue_from_ptr (comp.ctxt,
2993 comp.void_ptr_type, 3004 comp.void_ptr_type,
2994 pure); 3005 pure);
2995
2996 return Qt; 3006 return Qt;
2997} 3007}
2998 3008
@@ -3156,6 +3166,10 @@ load_static_obj (dynlib_handle_ptr handle, const char *name)
3156static int 3166static int
3157load_comp_unit (dynlib_handle_ptr handle) 3167load_comp_unit (dynlib_handle_ptr handle)
3158{ 3168{
3169 struct thread_state ***current_thread_reloc =
3170 dynlib_sym (handle, CURRENT_THREAD_RELOC_SYM);
3171 *current_thread_reloc = &current_thread;
3172
3159 /* Imported data. */ 3173 /* Imported data. */
3160 Lisp_Object *data_relocs = dynlib_sym (handle, DATA_RELOC_SYM); 3174 Lisp_Object *data_relocs = dynlib_sym (handle, DATA_RELOC_SYM);
3161 3175