diff options
| author | Andrea Corallo | 2019-12-24 14:51:18 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:38:16 +0100 |
| commit | b6d6e7feb75b792c74fe3e1d036b9edf540d771e (patch) | |
| tree | d39f8115419d93153ebd94698ba9115157562599 /src | |
| parent | 15ac087712250b5ffeb4d162761b2495a5e572a3 (diff) | |
| download | emacs-b6d6e7feb75b792c74fe3e1d036b9edf540d771e.tar.gz emacs-b6d6e7feb75b792c74fe3e1d036b9edf540d771e.zip | |
add native compilation unit pdumper support
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp.c | 33 | ||||
| -rw-r--r-- | src/comp.h | 3 | ||||
| -rw-r--r-- | src/pdumper.c | 16 |
3 files changed, 37 insertions, 15 deletions
diff --git a/src/comp.c b/src/comp.c index 003d3d7ca44..43b22a86805 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -3217,7 +3217,7 @@ load_static_obj (dynlib_handle_ptr handle, const char *name) | |||
| 3217 | } | 3217 | } |
| 3218 | 3218 | ||
| 3219 | void | 3219 | void |
| 3220 | load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u) | 3220 | load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump) |
| 3221 | { | 3221 | { |
| 3222 | dynlib_handle_ptr handle = comp_u->handle; | 3222 | dynlib_handle_ptr handle = comp_u->handle; |
| 3223 | struct thread_state ***current_thread_reloc = | 3223 | struct thread_state ***current_thread_reloc = |
| @@ -3237,22 +3237,26 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u) | |||
| 3237 | *current_thread_reloc = ¤t_thread; | 3237 | *current_thread_reloc = ¤t_thread; |
| 3238 | *pure_reloc = (EMACS_INT **)&pure; | 3238 | *pure_reloc = (EMACS_INT **)&pure; |
| 3239 | 3239 | ||
| 3240 | /* Imported data. */ | ||
| 3241 | Lisp_Object d_vec = load_static_obj (handle, TEXT_DATA_RELOC_SYM); | ||
| 3242 | EMACS_INT d_vec_len = XFIXNUM (Flength (d_vec)); | ||
| 3243 | |||
| 3244 | for (EMACS_INT i = 0; i < d_vec_len; i++) | ||
| 3245 | data_relocs[i] = AREF (d_vec, i); | ||
| 3246 | |||
| 3247 | comp_u->data_vec = d_vec; | ||
| 3248 | /* Imported functions. */ | 3240 | /* Imported functions. */ |
| 3249 | *freloc_link_table = freloc.link_table; | 3241 | *freloc_link_table = freloc.link_table; |
| 3250 | 3242 | ||
| 3251 | Lisp_Object comp_u_obj; | 3243 | /* Imported data. */ |
| 3252 | XSETNATIVE_COMP_UNIT (comp_u_obj, comp_u); | 3244 | if (!loading_dump) |
| 3245 | comp_u->data_vec = load_static_obj (handle, TEXT_DATA_RELOC_SYM); | ||
| 3246 | |||
| 3247 | EMACS_INT d_vec_len = XFIXNUM (Flength (comp_u->data_vec)); | ||
| 3248 | |||
| 3249 | for (EMACS_INT i = 0; i < d_vec_len; i++) | ||
| 3250 | data_relocs[i] = AREF (comp_u->data_vec, i); | ||
| 3253 | 3251 | ||
| 3254 | /* Executing this will perform all the expected environment modification. */ | 3252 | if (!loading_dump) |
| 3255 | top_level_run (comp_u_obj); | 3253 | { |
| 3254 | Lisp_Object comp_u_obj; | ||
| 3255 | XSETNATIVE_COMP_UNIT (comp_u_obj, comp_u); | ||
| 3256 | /* Executing this will perform all the expected environment | ||
| 3257 | modification. */ | ||
| 3258 | top_level_run (comp_u_obj); | ||
| 3259 | } | ||
| 3256 | 3260 | ||
| 3257 | return; | 3261 | return; |
| 3258 | } | 3262 | } |
| @@ -3308,7 +3312,8 @@ DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 1, 0, | |||
| 3308 | if (!comp_u->handle) | 3312 | if (!comp_u->handle) |
| 3309 | xsignal2 (Qnative_lisp_load_failed, file, build_string (dynlib_error ())); | 3313 | xsignal2 (Qnative_lisp_load_failed, file, build_string (dynlib_error ())); |
| 3310 | comp_u->file = file; | 3314 | comp_u->file = file; |
| 3311 | load_comp_unit (comp_u); | 3315 | comp_u->data_vec = Qnil; |
| 3316 | load_comp_unit (comp_u, false); | ||
| 3312 | 3317 | ||
| 3313 | return Qt; | 3318 | return Qt; |
| 3314 | } | 3319 | } |
diff --git a/src/comp.h b/src/comp.h index c4849ba13d1..90b4f40426b 100644 --- a/src/comp.h +++ b/src/comp.h | |||
| @@ -47,7 +47,8 @@ XNATIVE_COMP_UNIT (Lisp_Object a) | |||
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | /* Defined in comp.c. */ | 49 | /* Defined in comp.c. */ |
| 50 | extern void load_comp_unit (struct Lisp_Native_Comp_Unit *); | 50 | extern void load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, |
| 51 | bool loading_dump); | ||
| 51 | extern void syms_of_comp (void); | 52 | extern void syms_of_comp (void); |
| 52 | /* Fill the freloc structure. Must be called before any eln is loaded. */ | 53 | /* Fill the freloc structure. Must be called before any eln is loaded. */ |
| 53 | extern void fill_freloc (void); | 54 | extern void fill_freloc (void); |
diff --git a/src/pdumper.c b/src/pdumper.c index 4e770f79af5..2dbe6c73fb4 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -197,6 +197,7 @@ enum dump_reloc_type | |||
| 197 | /* dump_ptr = dump_ptr + dump_base */ | 197 | /* dump_ptr = dump_ptr + dump_base */ |
| 198 | RELOC_DUMP_TO_DUMP_PTR_RAW, | 198 | RELOC_DUMP_TO_DUMP_PTR_RAW, |
| 199 | /* dump_mpz = [rebuild bignum] */ | 199 | /* dump_mpz = [rebuild bignum] */ |
| 200 | RELOC_NATIVE_COMP_UNIT, | ||
| 200 | RELOC_BIGNUM, | 201 | RELOC_BIGNUM, |
| 201 | /* dump_lv = make_lisp_ptr (dump_lv + dump_base, | 202 | /* dump_lv = make_lisp_ptr (dump_lv + dump_base, |
| 202 | type - RELOC_DUMP_TO_DUMP_LV) | 203 | type - RELOC_DUMP_TO_DUMP_LV) |
| @@ -2991,6 +2992,11 @@ dump_native_comp_unit (struct dump_context *ctx, | |||
| 2991 | out->handle = NULL; | 2992 | out->handle = NULL; |
| 2992 | 2993 | ||
| 2993 | dump_off comp_u_off = finish_dump_pvec (ctx, &out->header); | 2994 | dump_off comp_u_off = finish_dump_pvec (ctx, &out->header); |
| 2995 | if (ctx->flags.dump_object_contents) | ||
| 2996 | /* We'll do the real elf load during the LATE_RELOCS_1 relocation time. */ | ||
| 2997 | dump_push (&ctx->dump_relocs[LATE_RELOCS_1], | ||
| 2998 | list2 (make_fixnum (RELOC_NATIVE_COMP_UNIT), | ||
| 2999 | dump_off_to_lisp (comp_u_off))); | ||
| 2994 | return comp_u_off; | 3000 | return comp_u_off; |
| 2995 | } | 3001 | } |
| 2996 | #endif | 3002 | #endif |
| @@ -5290,6 +5296,16 @@ dump_do_dump_relocation (const uintptr_t dump_base, | |||
| 5290 | dump_write_word_to_dump (dump_base, reloc_offset, value); | 5296 | dump_write_word_to_dump (dump_base, reloc_offset, value); |
| 5291 | break; | 5297 | break; |
| 5292 | } | 5298 | } |
| 5299 | case RELOC_NATIVE_COMP_UNIT: | ||
| 5300 | { | ||
| 5301 | struct Lisp_Native_Comp_Unit *comp_u = | ||
| 5302 | dump_ptr (dump_base, reloc_offset); | ||
| 5303 | comp_u->handle = dynlib_open (SSDATA (comp_u->file)); | ||
| 5304 | if (!comp_u->handle) | ||
| 5305 | error ("%s", dynlib_error ()); | ||
| 5306 | load_comp_unit (comp_u, true); | ||
| 5307 | } | ||
| 5308 | break; | ||
| 5293 | case RELOC_BIGNUM: | 5309 | case RELOC_BIGNUM: |
| 5294 | { | 5310 | { |
| 5295 | struct Lisp_Bignum *bignum = dump_ptr (dump_base, reloc_offset); | 5311 | struct Lisp_Bignum *bignum = dump_ptr (dump_base, reloc_offset); |