aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/comp.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/comp.c b/src/comp.c
index d7966d42221..1ef4f3054b1 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -90,6 +90,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
90#undef gcc_jit_function_get_param 90#undef gcc_jit_function_get_param
91#undef gcc_jit_function_new_block 91#undef gcc_jit_function_new_block
92#undef gcc_jit_function_new_local 92#undef gcc_jit_function_new_local
93#undef gcc_jit_global_set_initializer
93#undef gcc_jit_lvalue_access_field 94#undef gcc_jit_lvalue_access_field
94#undef gcc_jit_lvalue_as_rvalue 95#undef gcc_jit_lvalue_as_rvalue
95#undef gcc_jit_lvalue_get_address 96#undef gcc_jit_lvalue_get_address
@@ -144,6 +145,8 @@ DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_context_new_global,
144DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_function_new_local, 145DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_function_new_local,
145 (gcc_jit_function *func, gcc_jit_location *loc, gcc_jit_type *type, 146 (gcc_jit_function *func, gcc_jit_location *loc, gcc_jit_type *type,
146 const char *name)); 147 const char *name));
148DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_global_set_initializer,
149 (gcc_jit_lvalue *global, const void *blob, size_t num_bytes));
147DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_lvalue_access_field, 150DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_lvalue_access_field,
148 (gcc_jit_lvalue *struct_or_union, gcc_jit_location *loc, 151 (gcc_jit_lvalue *struct_or_union, gcc_jit_location *loc,
149 gcc_jit_field *field)); 152 gcc_jit_field *field));
@@ -307,6 +310,7 @@ init_gccjit_functions (void)
307 LOAD_DLL_FN (library, gcc_jit_struct_set_fields); 310 LOAD_DLL_FN (library, gcc_jit_struct_set_fields);
308 LOAD_DLL_FN (library, gcc_jit_type_get_pointer); 311 LOAD_DLL_FN (library, gcc_jit_type_get_pointer);
309 LOAD_DLL_FN_OPT (library, gcc_jit_context_add_driver_option); 312 LOAD_DLL_FN_OPT (library, gcc_jit_context_add_driver_option);
313 LOAD_DLL_FN_OPT (library, gcc_jit_global_set_initializer);
310 LOAD_DLL_FN_OPT (library, gcc_jit_version_major); 314 LOAD_DLL_FN_OPT (library, gcc_jit_version_major);
311 LOAD_DLL_FN_OPT (library, gcc_jit_version_minor); 315 LOAD_DLL_FN_OPT (library, gcc_jit_version_minor);
312 LOAD_DLL_FN_OPT (library, gcc_jit_version_patchlevel); 316 LOAD_DLL_FN_OPT (library, gcc_jit_version_patchlevel);
@@ -357,6 +361,7 @@ init_gccjit_functions (void)
357#define gcc_jit_function_get_param fn_gcc_jit_function_get_param 361#define gcc_jit_function_get_param fn_gcc_jit_function_get_param
358#define gcc_jit_function_new_block fn_gcc_jit_function_new_block 362#define gcc_jit_function_new_block fn_gcc_jit_function_new_block
359#define gcc_jit_function_new_local fn_gcc_jit_function_new_local 363#define gcc_jit_function_new_local fn_gcc_jit_function_new_local
364#define gcc_jit_global_set_initializer fn_gcc_jit_global_set_initializer
360#define gcc_jit_lvalue_access_field fn_gcc_jit_lvalue_access_field 365#define gcc_jit_lvalue_access_field fn_gcc_jit_lvalue_access_field
361#define gcc_jit_lvalue_as_rvalue fn_gcc_jit_lvalue_as_rvalue 366#define gcc_jit_lvalue_as_rvalue fn_gcc_jit_lvalue_as_rvalue
362#define gcc_jit_lvalue_get_address fn_gcc_jit_lvalue_get_address 367#define gcc_jit_lvalue_get_address fn_gcc_jit_lvalue_get_address
@@ -589,7 +594,7 @@ FILE *logfile = NULL;
589/* This is used for serialized objects by the reload mechanism. */ 594/* This is used for serialized objects by the reload mechanism. */
590typedef struct { 595typedef struct {
591 ptrdiff_t len; 596 ptrdiff_t len;
592 const char data[]; 597 char data[];
593} static_obj_t; 598} static_obj_t;
594 599
595typedef struct { 600typedef struct {
@@ -2497,6 +2502,33 @@ emit_static_object (const char *name, Lisp_Object obj)
2497 ptrdiff_t len = SBYTES (str); 2502 ptrdiff_t len = SBYTES (str);
2498 const char *p = SSDATA (str); 2503 const char *p = SSDATA (str);
2499 2504
2505#if defined (LIBGCCJIT_HAVE_gcc_jit_global_set_initializer) \
2506 || defined (WINDOWSNT)
2507#pragma GCC diagnostic ignored "-Waddress"
2508 if (gcc_jit_global_set_initializer)
2509#pragma GCC diagnostic pop
2510 {
2511 ptrdiff_t str_size = len + 1;
2512 ptrdiff_t size = sizeof (static_obj_t) + str_size;
2513 static_obj_t *static_obj = xmalloc (size);
2514 static_obj->len = str_size;
2515 memcpy (static_obj->data, p, str_size);
2516 gcc_jit_lvalue *blob =
2517 gcc_jit_context_new_global (
2518 comp.ctxt,
2519 NULL,
2520 GCC_JIT_GLOBAL_EXPORTED,
2521 gcc_jit_context_new_array_type (comp.ctxt, NULL,
2522 comp.char_type,
2523 size),
2524 format_string ("%s_blob", name));
2525 gcc_jit_global_set_initializer (blob, static_obj, size);
2526 xfree (static_obj);
2527
2528 return;
2529 }
2530#endif
2531
2500 gcc_jit_type *a_type = 2532 gcc_jit_type *a_type =
2501 gcc_jit_context_new_array_type (comp.ctxt, 2533 gcc_jit_context_new_array_type (comp.ctxt,
2502 NULL, 2534 NULL,
@@ -4599,12 +4631,19 @@ typedef char *(*comp_lit_str_func) (void);
4599static Lisp_Object 4631static Lisp_Object
4600load_static_obj (struct Lisp_Native_Comp_Unit *comp_u, const char *name) 4632load_static_obj (struct Lisp_Native_Comp_Unit *comp_u, const char *name)
4601{ 4633{
4634 static_obj_t *blob =
4635 dynlib_sym (comp_u->handle, format_string ("%s_blob", name));
4636 if (blob)
4637 /* New blob format. */
4638 return Fread (make_string (blob->data, blob->len));
4639
4602 static_obj_t *(*f)(void) = dynlib_sym (comp_u->handle, name); 4640 static_obj_t *(*f)(void) = dynlib_sym (comp_u->handle, name);
4603 if (!f) 4641 if (!f)
4604 xsignal1 (Qnative_lisp_file_inconsistent, comp_u->file); 4642 xsignal1 (Qnative_lisp_file_inconsistent, comp_u->file);
4605 4643
4606 static_obj_t *res = f (); 4644 blob = f ();
4607 return Fread (make_string (res->data, res->len)); 4645 return Fread (make_string (blob->data, blob->len));
4646
4608} 4647}
4609 4648
4610/* Return false when something is wrong or true otherwise. */ 4649/* Return false when something is wrong or true otherwise. */