diff options
| author | Andrea Corallo | 2019-12-24 16:52:40 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:38:16 +0100 |
| commit | 568883c9be8bfbb15ea48ae0de2c117894e8db4e (patch) | |
| tree | 99d1465d98412f8d9c3cdfed94cfcfb73f7085b7 /src | |
| parent | b6d6e7feb75b792c74fe3e1d036b9edf540d771e (diff) | |
| download | emacs-568883c9be8bfbb15ea48ae0de2c117894e8db4e.tar.gz emacs-568883c9be8bfbb15ea48ae0de2c117894e8db4e.zip | |
add native elisp subr pdumper support
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp.c | 14 | ||||
| -rw-r--r-- | src/pdumper.c | 34 |
2 files changed, 35 insertions, 13 deletions
diff --git a/src/comp.c b/src/comp.c index 43b22a86805..7e25bdc9256 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -3202,8 +3202,6 @@ helper_PSEUDOVECTOR_TYPEP_XUNTAG (Lisp_Object a, enum pvec_type code) | |||
| 3202 | /* Functions used to load eln files. */ | 3202 | /* Functions used to load eln files. */ |
| 3203 | /**************************************/ | 3203 | /**************************************/ |
| 3204 | 3204 | ||
| 3205 | static Lisp_Object Vnative_elisp_refs_hash; | ||
| 3206 | |||
| 3207 | typedef char *(*comp_lit_str_func) (void); | 3205 | typedef char *(*comp_lit_str_func) (void); |
| 3208 | 3206 | ||
| 3209 | /* Deserialize read and return static object. */ | 3207 | /* Deserialize read and return static object. */ |
| @@ -3292,6 +3290,7 @@ DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr, | |||
| 3292 | XSETSUBR (tem, &x->s); | 3290 | XSETSUBR (tem, &x->s); |
| 3293 | set_symbol_function (name, tem); | 3291 | set_symbol_function (name, tem); |
| 3294 | 3292 | ||
| 3293 | Fputhash (name, c_name, Vsym_subr_c_name_h); | ||
| 3295 | LOADHIST_ATTACH (Fcons (Qdefun, name)); | 3294 | LOADHIST_ATTACH (Fcons (Qdefun, name)); |
| 3296 | 3295 | ||
| 3297 | return Qnil; | 3296 | return Qnil; |
| @@ -3434,13 +3433,10 @@ syms_of_comp (void) | |||
| 3434 | /* FIXME should be initialized but not here... */ | 3433 | /* FIXME should be initialized but not here... */ |
| 3435 | DEFVAR_LISP ("comp-subr-list", Vsubr_list, | 3434 | DEFVAR_LISP ("comp-subr-list", Vsubr_list, |
| 3436 | doc: /* List of all defined subrs. */); | 3435 | doc: /* List of all defined subrs. */); |
| 3437 | 3436 | DEFVAR_LISP ("comp-sym-subr-c-name-h", Vsym_subr_c_name_h, | |
| 3438 | /* Load mechanism. */ | 3437 | doc: /* Hash table symbol-function -> function-c-name. For |
| 3439 | staticpro (&Vnative_elisp_refs_hash); | 3438 | internal use during */); |
| 3440 | Vnative_elisp_refs_hash | 3439 | Vsym_subr_c_name_h = CALLN (Fmake_hash_table); |
| 3441 | = make_hash_table (hashtest_eq, DEFAULT_HASH_SIZE, | ||
| 3442 | DEFAULT_REHASH_SIZE, DEFAULT_REHASH_THRESHOLD, | ||
| 3443 | Qnil, false); | ||
| 3444 | } | 3440 | } |
| 3445 | 3441 | ||
| 3446 | #endif /* HAVE_NATIVE_COMP */ | 3442 | #endif /* HAVE_NATIVE_COMP */ |
diff --git a/src/pdumper.c b/src/pdumper.c index 2dbe6c73fb4..5bfccb8ac90 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -198,6 +198,7 @@ enum dump_reloc_type | |||
| 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_NATIVE_COMP_UNIT, |
| 201 | RELOC_NATIVE_SUBR, | ||
| 201 | RELOC_BIGNUM, | 202 | RELOC_BIGNUM, |
| 202 | /* dump_lv = make_lisp_ptr (dump_lv + dump_base, | 203 | /* dump_lv = make_lisp_ptr (dump_lv + dump_base, |
| 203 | type - RELOC_DUMP_TO_DUMP_LV) | 204 | type - RELOC_DUMP_TO_DUMP_LV) |
| @@ -2979,7 +2980,15 @@ dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr) | |||
| 2979 | dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec); | 2980 | dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec); |
| 2980 | DUMP_FIELD_COPY (&out, subr, doc); | 2981 | DUMP_FIELD_COPY (&out, subr, doc); |
| 2981 | #endif | 2982 | #endif |
| 2982 | return dump_object_finish (ctx, &out, sizeof (out)); | 2983 | |
| 2984 | dump_off subr_off = dump_object_finish (ctx, &out, sizeof (out)); | ||
| 2985 | if (ctx->flags.dump_object_contents && subr->native_comp_u) | ||
| 2986 | /* We'll do the final addr relocation during VERY_LATE_RELOCS time | ||
| 2987 | after the compilation units has been loaded. */ | ||
| 2988 | dump_push (&ctx->dump_relocs[VERY_LATE_RELOCS], | ||
| 2989 | list2 (make_fixnum (RELOC_NATIVE_SUBR), | ||
| 2990 | dump_off_to_lisp (subr_off))); | ||
| 2991 | return subr_off; | ||
| 2983 | } | 2992 | } |
| 2984 | 2993 | ||
| 2985 | #ifdef HAVE_NATIVE_COMP | 2994 | #ifdef HAVE_NATIVE_COMP |
| @@ -2993,8 +3002,8 @@ dump_native_comp_unit (struct dump_context *ctx, | |||
| 2993 | 3002 | ||
| 2994 | dump_off comp_u_off = finish_dump_pvec (ctx, &out->header); | 3003 | dump_off comp_u_off = finish_dump_pvec (ctx, &out->header); |
| 2995 | if (ctx->flags.dump_object_contents) | 3004 | if (ctx->flags.dump_object_contents) |
| 2996 | /* We'll do the real elf load during the LATE_RELOCS_1 relocation time. */ | 3005 | /* We'll do the real elf load during LATE_RELOCS relocation time. */ |
| 2997 | dump_push (&ctx->dump_relocs[LATE_RELOCS_1], | 3006 | dump_push (&ctx->dump_relocs[LATE_RELOCS], |
| 2998 | list2 (make_fixnum (RELOC_NATIVE_COMP_UNIT), | 3007 | list2 (make_fixnum (RELOC_NATIVE_COMP_UNIT), |
| 2999 | dump_off_to_lisp (comp_u_off))); | 3008 | dump_off_to_lisp (comp_u_off))); |
| 3000 | return comp_u_off; | 3009 | return comp_u_off; |
| @@ -5304,8 +5313,25 @@ dump_do_dump_relocation (const uintptr_t dump_base, | |||
| 5304 | if (!comp_u->handle) | 5313 | if (!comp_u->handle) |
| 5305 | error ("%s", dynlib_error ()); | 5314 | error ("%s", dynlib_error ()); |
| 5306 | load_comp_unit (comp_u, true); | 5315 | load_comp_unit (comp_u, true); |
| 5316 | break; | ||
| 5317 | } | ||
| 5318 | case RELOC_NATIVE_SUBR: | ||
| 5319 | { | ||
| 5320 | struct Lisp_Subr *subr = dump_ptr (dump_base, reloc_offset); | ||
| 5321 | Lisp_Object name = intern (subr->symbol_name); | ||
| 5322 | struct Lisp_Native_Comp_Unit *comp_u = | ||
| 5323 | XNATIVE_COMP_UNIT (subr->native_comp_u); | ||
| 5324 | if (!comp_u->handle) | ||
| 5325 | error ("can't relocate native subr with not loaded compilation unit"); | ||
| 5326 | Lisp_Object c_name = Fgethash (name, Vsym_subr_c_name_h, Qnil); | ||
| 5327 | if (NILP (c_name)) | ||
| 5328 | error ("missing label name"); | ||
| 5329 | void *func = dynlib_sym (comp_u->handle, SSDATA (c_name)); | ||
| 5330 | if (!func) | ||
| 5331 | error ("can't function in compilation unit"); | ||
| 5332 | subr->function.a0 = func; | ||
| 5333 | break; | ||
| 5307 | } | 5334 | } |
| 5308 | break; | ||
| 5309 | case RELOC_BIGNUM: | 5335 | case RELOC_BIGNUM: |
| 5310 | { | 5336 | { |
| 5311 | struct Lisp_Bignum *bignum = dump_ptr (dump_base, reloc_offset); | 5337 | struct Lisp_Bignum *bignum = dump_ptr (dump_base, reloc_offset); |