[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp 506febd 1/4: Remove `Vcomp_sym_subr_c_name_h'
From: |
Andrea Corallo |
Subject: |
feature/native-comp 506febd 1/4: Remove `Vcomp_sym_subr_c_name_h' |
Date: |
Thu, 11 Jun 2020 13:33:49 -0400 (EDT) |
branch: feature/native-comp
commit 506febd5e72b0cd48acdf8887fb95701004b6e43
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
Remove `Vcomp_sym_subr_c_name_h'
Given there's no more unique relation symbol-name -> c-name remove
`Vcomp_sym_subr_c_name_h' and store the c_name directly in struct
Lisp_Subr. The old approach would have failed dumping two functions
with the same symbol-name.
* src/lisp.h (struct Lisp_Subr): Add 'native_c_name' field.
* src/pdumper.c (dump_subr): Update hash + dump 'native_c_name'.
(dump_cold_native_subr): dump 'native_c_name'.
(dump_do_dump_relocation): Update logic for reviving using
'native_c_name'.
* src/comp.c (make_subr): Update for 'native_c_name' field.
(Fcomp__register_lambda, Fcomp__register_subr): Clean-up code for
'Vcomp_sym_subr_c_name_h' removal.
(syms_of_comp): Remove 'Vcomp_sym_subr_c_name_h'.
---
src/comp.c | 9 +--------
src/lisp.h | 1 +
src/pdumper.c | 27 +++++++++++++++++++--------
3 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/src/comp.c b/src/comp.c
index af61d76..0f7c041 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -4567,6 +4567,7 @@ make_subr (Lisp_Object symbol_name, Lisp_Object minarg,
Lisp_Object maxarg,
x->s.native_intspec = intspec;
x->s.doc = XFIXNUM (doc_idx);
x->s.native_comp_u[0] = comp_u;
+ x->s.native_c_name[0] = xstrdup (SSDATA (c_name));
Lisp_Object tem;
XSETSUBR (tem, &x->s);
@@ -4595,9 +4596,6 @@ DEFUN ("comp--register-lambda", Fcomp__register_lambda,
Scomp__register_lambda,
from dump. See 'dump_do_dump_relocation'. */
eassert (NILP (Fgethash (c_name, cu->lambda_c_name_idx_h, Qnil)));
Fputhash (c_name, reloc_idx, cu->lambda_c_name_idx_h);
- /* The key is not really important as long is the same as
- symbol_name so use c_name. */
- Fputhash (Fintern (c_name, Qnil), c_name, Vcomp_sym_subr_c_name_h);
/* Do the real relocation fixup. */
cu->data_imp_relocs[XFIXNUM (reloc_idx)] = tem;
@@ -4618,7 +4616,6 @@ DEFUN ("comp--register-subr", Fcomp__register_subr,
Scomp__register_subr,
set_symbol_function (name, tem);
LOADHIST_ATTACH (Fcons (Qdefun, name));
- Fputhash (name, c_name, Vcomp_sym_subr_c_name_h);
return tem;
}
@@ -4820,10 +4817,6 @@ syms_of_comp (void)
to be necessarily exposed to lisp but can easy debug for now. */
DEFVAR_LISP ("comp-subr-list", Vcomp_subr_list,
doc: /* List of all defined subrs. */);
- DEFVAR_LISP ("comp-sym-subr-c-name-h", Vcomp_sym_subr_c_name_h,
- doc: /* Hash table symbol-function -> function-c-name. For
- internal use during dump reload */);
- Vcomp_sym_subr_c_name_h = CALLN (Fmake_hash_table, QCtest, Qeq);
DEFVAR_LISP ("comp-abi-hash", Vcomp_abi_hash,
doc: /* String signing the ABI exposed to .eln files. */);
Vcomp_abi_hash = Qnil;
diff --git a/src/lisp.h b/src/lisp.h
index d39300e..55055fe 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2095,6 +2095,7 @@ struct Lisp_Subr
};
EMACS_INT doc;
Lisp_Object native_comp_u[NATIVE_COMP_FLAG];
+ const char *native_c_name[NATIVE_COMP_FLAG];
} GCALIGNED_STRUCT;
union Aligned_Lisp_Subr
{
diff --git a/src/pdumper.c b/src/pdumper.c
index 3089adb..e6c877c 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2937,7 +2937,7 @@ dump_bool_vector (struct dump_context *ctx, const struct
Lisp_Vector *v)
static dump_off
dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr)
{
-#if CHECK_STRUCTS && !defined (HASH_Lisp_Subr_99B6674034)
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Subr_92BED44D81)
# error "Lisp_Subr changed. See CHECK_STRUCTS comment in config.h."
#endif
struct Lisp_Subr out;
@@ -2964,7 +2964,11 @@ dump_subr (struct dump_context *ctx, const struct
Lisp_Subr *subr)
}
DUMP_FIELD_COPY (&out, subr, doc);
if (NATIVE_COMP_FLAG)
- dump_field_lv (ctx, &out, subr, &subr->native_comp_u[0], WEIGHT_NORMAL);
+ {
+ dump_field_lv (ctx, &out, subr, &subr->native_comp_u[0], WEIGHT_NORMAL);
+ if (!NILP (subr->native_comp_u[0]))
+ dump_field_fixup_later (ctx, &out, subr, &subr->native_c_name[0]);
+ }
dump_off subr_off = dump_object_finish (ctx, &out, sizeof (out));
if (NATIVE_COMP_FLAG
@@ -3493,6 +3497,15 @@ dump_cold_native_subr (struct dump_context *ctx,
Lisp_Object subr)
ALLOW_IMPLICIT_CONVERSION;
dump_write (ctx, symbol_name, 1 + strlen (symbol_name));
DISALLOW_IMPLICIT_CONVERSION;
+
+ dump_remember_fixup_ptr_raw
+ (ctx,
+ subr_offset + dump_offsetof (struct Lisp_Subr, native_c_name[0]),
+ ctx->offset);
+ const char *c_name = XSUBR (subr)->native_c_name[0];
+ ALLOW_IMPLICIT_CONVERSION;
+ dump_write (ctx, c_name, 1 + strlen (c_name));
+ DISALLOW_IMPLICIT_CONVERSION;
}
static void
@@ -5342,20 +5355,18 @@ dump_do_dump_relocation (const uintptr_t dump_base,
a 'top_level_run' mechanism, we revive them one-by-one
here. */
struct Lisp_Subr *subr = dump_ptr (dump_base, reloc_offset);
- Lisp_Object name = intern (subr->symbol_name);
struct Lisp_Native_Comp_Unit *comp_u =
XNATIVE_COMP_UNIT (subr->native_comp_u[0]);
if (!comp_u->handle)
error ("can't relocate native subr with not loaded compilation unit");
- Lisp_Object c_name = Fgethash (name, Vcomp_sym_subr_c_name_h, Qnil);
- if (NILP (c_name))
- error ("missing label name");
- void *func = dynlib_sym (comp_u->handle, SSDATA (c_name));
+ const char *c_name = subr->native_c_name[0];
+ eassert (c_name);
+ void *func = dynlib_sym (comp_u->handle, c_name);
if (!func)
error ("can't find function in compilation unit");
subr->function.a0 = func;
Lisp_Object lambda_data_idx =
- Fgethash (c_name, comp_u->lambda_c_name_idx_h, Qnil);
+ Fgethash (build_string (c_name), comp_u->lambda_c_name_idx_h, Qnil);
if (!NILP (lambda_data_idx))
{
/* This is an anonymous lambda.