diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2021-12-31 17:24:31 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2022-01-24 11:41:46 +0100 |
commit | 65caf5b205d22f76bb4ec85cfe597b621a83afb3 (patch) | |
tree | 8a4b71295d56f76ad0fee6c4471aa036c6e7e226 /src/pdumper.c | |
parent | ce1de3a8d9723305f48fd4527fbceaff3cec50ba (diff) | |
download | emacs-65caf5b205d22f76bb4ec85cfe597b621a83afb3.tar.gz |
Pin bytecode strings to avoid copy at call time
Avoid making a copy (in the interpreter C stack frame) of the bytecode
string by making sure it won't be moved by the GC. This is done by
reallocating it to the heap normally only used for large strings,
which isn't compacted.
This requires that we retain an explicit reference to the bytecode
string object (`bytestr`) lest it be GCed away should all other
references vanish during execution. We allocate an extra stack slot
for that, as we already do for the constant vector object.
* src/alloc.c (allocate_string_data): Add `immovable` argument.
(resize_string_data, make_clear_multibyte_string): Use it.
(pin_string): New.
* src/pdumper.c (dump_string): Fix incorrect comment.
Update hash for Lisp_String (only comments changed, not contents).
* src/lread.c (read1):
* src/alloc.c (Fmake_byte_code, purecopy):
* src/bytecode.c (Fbyte_code): Pin bytecode on object creation.
(exec_byte_code): Don't copy bytecode. Retain `bytestr` explicitly.
* src/lisp.h (Lisp_String): Explain special size_byte values.
(string_immovable_p): New.
Diffstat (limited to 'src/pdumper.c')
-rw-r--r-- | src/pdumper.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pdumper.c b/src/pdumper.c index eeebb7ed0e8..60280fcb043 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2068,7 +2068,7 @@ dump_interval_tree (struct dump_context *ctx, static dump_off dump_string (struct dump_context *ctx, const struct Lisp_String *string) { -#if CHECK_STRUCTS && !defined (HASH_Lisp_String_348C2B2FDB) +#if CHECK_STRUCTS && !defined (HASH_Lisp_String_C2CAF90352) # error "Lisp_String changed. See CHECK_STRUCTS comment in config.h." #endif /* If we have text properties, write them _after_ the string so that @@ -2079,7 +2079,7 @@ dump_string (struct dump_context *ctx, const struct Lisp_String *string) we seldom write to string data and never relocate it, so lumping it together at the end of the dump saves on COW faults. - If, however, the string's size_byte field is -1, the string data + If, however, the string's size_byte field is -2, the string data is actually a pointer to Emacs data segment, so we can do even better by emitting a relocation instead of bothering to copy the string data. */ |