diff options
| author | Paul Eggert | 2020-05-26 15:47:59 -0700 |
|---|---|---|
| committer | Paul Eggert | 2020-05-26 15:48:31 -0700 |
| commit | 0fc4989f34bdaf1bc443d05ece886ea91e7bc9cc (patch) | |
| tree | eb37822b28a5ffc655030c24c973572883fa4b0a /src | |
| parent | 5467aac131fb49ff2af57ca21d7ec9cba7c19c82 (diff) | |
| download | emacs-0fc4989f34bdaf1bc443d05ece886ea91e7bc9cc.tar.gz emacs-0fc4989f34bdaf1bc443d05ece886ea91e7bc9cc.zip | |
Tweak GC performance if !USE_LSB_TAG
Performance issue reported by Eli Zaretskii (Bug#41321#149).
* src/alloc.c (GC_OBJECT_ALIGNMENT_MINIMUM): New constant.
(maybe_lisp_pointer): Use it instead of GCALIGNMENT.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/alloc.c b/src/alloc.c index f8609398a3f..e241b9933a4 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -4687,16 +4687,33 @@ mark_maybe_objects (Lisp_Object const *array, ptrdiff_t nelts) | |||
| 4687 | mark_maybe_object (*array); | 4687 | mark_maybe_object (*array); |
| 4688 | } | 4688 | } |
| 4689 | 4689 | ||
| 4690 | /* A lower bound on the alignment of Lisp objects that need marking. | ||
| 4691 | Although 1 is safe, higher values speed up mark_maybe_pointer. | ||
| 4692 | If USE_LSB_TAG, this value is typically GCALIGNMENT; otherwise, | ||
| 4693 | it's determined by the natural alignment of Lisp structs. | ||
| 4694 | All vectorlike objects have alignment at least that of union | ||
| 4695 | vectorlike_header and it's unlikely they all have alignment greater, | ||
| 4696 | so use the union as a safe and likely-accurate standin for | ||
| 4697 | vectorlike objects. */ | ||
| 4698 | |||
| 4699 | enum { GC_OBJECT_ALIGNMENT_MINIMUM | ||
| 4700 | = max (GCALIGNMENT, | ||
| 4701 | min (alignof (union vectorlike_header), | ||
| 4702 | min (min (alignof (struct Lisp_Cons), | ||
| 4703 | alignof (struct Lisp_Float)), | ||
| 4704 | min (alignof (struct Lisp_String), | ||
| 4705 | alignof (struct Lisp_Symbol))))) }; | ||
| 4706 | |||
| 4690 | /* Return true if P might point to Lisp data that can be garbage | 4707 | /* Return true if P might point to Lisp data that can be garbage |
| 4691 | collected, and false otherwise (i.e., false if it is easy to see | 4708 | collected, and false otherwise (i.e., false if it is easy to see |
| 4692 | that P cannot point to Lisp data that can be garbage collected). | 4709 | that P cannot point to Lisp data that can be garbage collected). |
| 4693 | Symbols are implemented via offsets not pointers, but the offsets | 4710 | Symbols are implemented via offsets not pointers, but the offsets |
| 4694 | are also multiples of GCALIGNMENT. */ | 4711 | are also multiples of GC_OBJECT_ALIGNMENT_MINIMUM. */ |
| 4695 | 4712 | ||
| 4696 | static bool | 4713 | static bool |
| 4697 | maybe_lisp_pointer (void *p) | 4714 | maybe_lisp_pointer (void *p) |
| 4698 | { | 4715 | { |
| 4699 | return (uintptr_t) p % GCALIGNMENT == 0; | 4716 | return (uintptr_t) p % GC_OBJECT_ALIGNMENT_MINIMUM == 0; |
| 4700 | } | 4717 | } |
| 4701 | 4718 | ||
| 4702 | /* If P points to Lisp data, mark that as live if it isn't already | 4719 | /* If P points to Lisp data, mark that as live if it isn't already |