summaryrefslogtreecommitdiff
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2019-11-10 08:58:48 +0100
committerAndrea Corallo <akrl@sdf.org>2020-01-01 11:38:02 +0100
commitc47892201b2b9f1ef903ff2a12bb9ed9e64d19de (patch)
tree193f11646f967fe8dd322c6d7fbd71ca65a71148 /src/comp.c
parent6d230fc2c04532b4abf2474411b2995c237d5cc8 (diff)
downloademacs-c47892201b2b9f1ef903ff2a12bb9ed9e64d19de.tar.gz
emacs-c47892201b2b9f1ef903ff2a12bb9ed9e64d19de.tar.bz2
emacs-c47892201b2b9f1ef903ff2a12bb9ed9e64d19de.zip
add current thread missing reloc mechanism
Diffstat (limited to 'src/comp.c')
-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/>. */
#define COMP_DEBUG 1
/* C symbols emited for the load relocation mechanism. */
+#define CURRENT_THREAD_RELOC_SYM "current_thread_reloc"
#define DATA_RELOC_SYM "d_reloc"
#define IMPORTED_FUNC_RELOC_SYM "f_reloc"
#define TEXT_DATA_RELOC_SYM "text_data_reloc"
@@ -116,7 +117,7 @@ typedef struct {
gcc_jit_struct *thread_state_s;
gcc_jit_field *m_handlerlist;
gcc_jit_type *thread_state_ptr_type;
- gcc_jit_rvalue *current_thread;
+ gcc_jit_rvalue *current_thread_ref;
/* other globals */
gcc_jit_rvalue *pure;
/* libgccjit has really limited support for casting therefore this union will
@@ -1258,9 +1259,11 @@ emit_limple_insn (Lisp_Object insn)
current_thread->m_handlerlist->next;
*/
gcc_jit_lvalue *m_handlerlist =
- gcc_jit_rvalue_dereference_field (comp.current_thread,
- NULL,
- comp.m_handlerlist);
+ gcc_jit_rvalue_dereference_field (
+ gcc_jit_lvalue_as_rvalue (
+ gcc_jit_rvalue_dereference (comp.current_thread_ref, NULL)),
+ NULL,
+ comp.m_handlerlist);
gcc_jit_block_add_assignment(
comp.block,
@@ -1279,7 +1282,9 @@ emit_limple_insn (Lisp_Object insn)
gcc_jit_lvalue *c =
xmint_pointer (AREF (comp.buffer_handler_vec, handler_buff_n));
gcc_jit_lvalue *m_handlerlist =
- gcc_jit_rvalue_dereference_field (comp.current_thread,
+ gcc_jit_rvalue_dereference_field (
+ gcc_jit_lvalue_as_rvalue (
+ gcc_jit_rvalue_dereference (comp.current_thread_ref, NULL)),
NULL,
comp.m_handlerlist);
gcc_jit_block_add_assignment (
@@ -1723,6 +1728,15 @@ emit_ctxt_code (void)
{
USE_SAFE_ALLOCA;
+ comp.current_thread_ref =
+ gcc_jit_lvalue_as_rvalue (
+ gcc_jit_context_new_global (
+ comp.ctxt,
+ NULL,
+ GCC_JIT_GLOBAL_EXPORTED,
+ gcc_jit_type_get_pointer (comp.thread_state_ptr_type),
+ CURRENT_THREAD_RELOC_SYM));
+
declare_runtime_imported_data ();
/* Imported objects. */
EMACS_UINT d_reloc_len =
@@ -2984,15 +2998,11 @@ DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
define_thread_state_struct ();
define_cast_union ();
- comp.current_thread =
- gcc_jit_context_new_rvalue_from_ptr (comp.ctxt,
- comp.thread_state_ptr_type,
- current_thread);
+ /* FIXME!! */
comp.pure =
gcc_jit_context_new_rvalue_from_ptr (comp.ctxt,
comp.void_ptr_type,
pure);
-
return Qt;
}
@@ -3156,6 +3166,10 @@ load_static_obj (dynlib_handle_ptr handle, const char *name)
static int
load_comp_unit (dynlib_handle_ptr handle)
{
+ struct thread_state ***current_thread_reloc =
+ dynlib_sym (handle, CURRENT_THREAD_RELOC_SYM);
+ *current_thread_reloc = &current_thread;
+
/* Imported data. */
Lisp_Object *data_relocs = dynlib_sym (handle, DATA_RELOC_SYM);