aboutsummaryrefslogtreecommitdiffstats
path: root/src/pdumper.c
diff options
context:
space:
mode:
authorVibhav Pant2020-08-21 14:04:35 +0530
committerVibhav Pant2020-08-21 14:04:35 +0530
commitf0f8d7b82492e741950c363a03b886965c91b1b0 (patch)
tree19b716830b1ebabc0d7d75949c4e6800c0f104ad /src/pdumper.c
parent9e64a087c4d167e7ec1c4e22bea3e6af53b563de (diff)
parentc818c29771d3cb51875643b2f6c894073e429dd2 (diff)
downloademacs-feature/native-comp-macos-fixes.tar.gz
emacs-feature/native-comp-macos-fixes.zip
Merge branch 'feature/native-comp' into feature/native-comp-macos-fixesfeature/native-comp-macos-fixes
Diffstat (limited to 'src/pdumper.c')
-rw-r--r--src/pdumper.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/pdumper.c b/src/pdumper.c
index 629d0969346..9c615a9a1a7 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -4903,14 +4903,19 @@ struct dump_bitset
4903}; 4903};
4904 4904
4905static bool 4905static bool
4906dump_bitset_init (struct dump_bitset *bitset, size_t number_bits) 4906dump_bitsets_init (struct dump_bitset bitset[2], size_t number_bits)
4907{ 4907{
4908 int xword_size = sizeof (bitset->bits[0]); 4908 int xword_size = sizeof (bitset[0].bits[0]);
4909 int bits_per_word = xword_size * CHAR_BIT; 4909 int bits_per_word = xword_size * CHAR_BIT;
4910 ptrdiff_t words_needed = divide_round_up (number_bits, bits_per_word); 4910 ptrdiff_t words_needed = divide_round_up (number_bits, bits_per_word);
4911 bitset->number_words = words_needed; 4911 dump_bitset_word *bits = calloc (words_needed, 2 * xword_size);
4912 bitset->bits = calloc (words_needed, xword_size); 4912 if (!bits)
4913 return bitset->bits != NULL; 4913 return false;
4914 bitset[0].bits = bits;
4915 bitset[0].number_words = bitset[1].number_words = words_needed;
4916 bitset[1].bits = memset (bits + words_needed, UCHAR_MAX,
4917 words_needed * xword_size);
4918 return true;
4914} 4919}
4915 4920
4916static dump_bitset_word * 4921static dump_bitset_word *
@@ -4971,7 +4976,7 @@ struct pdumper_loaded_dump_private
4971 /* Copy of the header we read from the dump. */ 4976 /* Copy of the header we read from the dump. */
4972 struct dump_header header; 4977 struct dump_header header;
4973 /* Mark bits for objects in the dump; used during GC. */ 4978 /* Mark bits for objects in the dump; used during GC. */
4974 struct dump_bitset mark_bits; 4979 struct dump_bitset mark_bits, last_mark_bits;
4975 /* Time taken to load the dump. */ 4980 /* Time taken to load the dump. */
4976 double load_time; 4981 double load_time;
4977 /* Dump file name. */ 4982 /* Dump file name. */
@@ -5094,6 +5099,10 @@ pdumper_find_object_type_impl (const void *obj)
5094 dump_off offset = ptrdiff_t_to_dump_off ((uintptr_t) obj - dump_public.start); 5099 dump_off offset = ptrdiff_t_to_dump_off ((uintptr_t) obj - dump_public.start);
5095 if (offset % DUMP_ALIGNMENT != 0) 5100 if (offset % DUMP_ALIGNMENT != 0)
5096 return PDUMPER_NO_OBJECT; 5101 return PDUMPER_NO_OBJECT;
5102 ptrdiff_t bitno = offset / DUMP_ALIGNMENT;
5103 if (offset < dump_private.header.discardable_start
5104 && !dump_bitset_bit_set_p (&dump_private.last_mark_bits, bitno))
5105 return PDUMPER_NO_OBJECT;
5097 const struct dump_reloc *reloc = 5106 const struct dump_reloc *reloc =
5098 dump_find_relocation (&dump_private.header.object_starts, offset); 5107 dump_find_relocation (&dump_private.header.object_starts, offset);
5099 return (reloc != NULL && dump_reloc_get_offset (*reloc) == offset) 5108 return (reloc != NULL && dump_reloc_get_offset (*reloc) == offset)
@@ -5122,12 +5131,16 @@ pdumper_set_marked_impl (const void *obj)
5122 eassert (offset < dump_private.header.cold_start); 5131 eassert (offset < dump_private.header.cold_start);
5123 eassert (offset < dump_private.header.discardable_start); 5132 eassert (offset < dump_private.header.discardable_start);
5124 ptrdiff_t bitno = offset / DUMP_ALIGNMENT; 5133 ptrdiff_t bitno = offset / DUMP_ALIGNMENT;
5134 eassert (dump_bitset_bit_set_p (&dump_private.last_mark_bits, bitno));
5125 dump_bitset_set_bit (&dump_private.mark_bits, bitno); 5135 dump_bitset_set_bit (&dump_private.mark_bits, bitno);
5126} 5136}
5127 5137
5128void 5138void
5129pdumper_clear_marks_impl (void) 5139pdumper_clear_marks_impl (void)
5130{ 5140{
5141 dump_bitset_word *swap = dump_private.last_mark_bits.bits;
5142 dump_private.last_mark_bits.bits = dump_private.mark_bits.bits;
5143 dump_private.mark_bits.bits = swap;
5131 dump_bitset_clear (&dump_private.mark_bits); 5144 dump_bitset_clear (&dump_private.mark_bits);
5132} 5145}
5133 5146
@@ -5249,9 +5262,13 @@ dump_do_dump_relocation (const uintptr_t dump_base,
5249 { 5262 {
5250 fclose (file); 5263 fclose (file);
5251 installation_state = INSTALLED; 5264 installation_state = INSTALLED;
5265 fixup_eln_load_path (XCAR (comp_u->file));
5252 } 5266 }
5253 else 5267 else
5254 installation_state = LOCAL_BUILD; 5268 {
5269 installation_state = LOCAL_BUILD;
5270 fixup_eln_load_path (XCDR (comp_u->file));
5271 }
5255 } 5272 }
5256 5273
5257 comp_u->file = 5274 comp_u->file =
@@ -5423,7 +5440,7 @@ pdumper_load (const char *dump_filename, char *argv0, char const *original_pwd)
5423 int dump_page_size; 5440 int dump_page_size;
5424 dump_off adj_discardable_start; 5441 dump_off adj_discardable_start;
5425 5442
5426 struct dump_bitset mark_bits; 5443 struct dump_bitset mark_bits[2];
5427 size_t mark_bits_needed; 5444 size_t mark_bits_needed;
5428 5445
5429 struct dump_header header_buf = { 0 }; 5446 struct dump_header header_buf = { 0 };
@@ -5537,7 +5554,7 @@ pdumper_load (const char *dump_filename, char *argv0, char const *original_pwd)
5537 err = PDUMPER_LOAD_ERROR; 5554 err = PDUMPER_LOAD_ERROR;
5538 mark_bits_needed = 5555 mark_bits_needed =
5539 divide_round_up (header->discardable_start, DUMP_ALIGNMENT); 5556 divide_round_up (header->discardable_start, DUMP_ALIGNMENT);
5540 if (!dump_bitset_init (&mark_bits, mark_bits_needed)) 5557 if (!dump_bitsets_init (mark_bits, mark_bits_needed))
5541 goto out; 5558 goto out;
5542 5559
5543 /* Point of no return. */ 5560 /* Point of no return. */
@@ -5545,7 +5562,8 @@ pdumper_load (const char *dump_filename, char *argv0, char const *original_pwd)
5545 dump_base = (uintptr_t) sections[DS_HOT].mapping; 5562 dump_base = (uintptr_t) sections[DS_HOT].mapping;
5546 gflags.dumped_with_pdumper_ = true; 5563 gflags.dumped_with_pdumper_ = true;
5547 dump_private.header = *header; 5564 dump_private.header = *header;
5548 dump_private.mark_bits = mark_bits; 5565 dump_private.mark_bits = mark_bits[0];
5566 dump_private.last_mark_bits = mark_bits[1];
5549 dump_public.start = dump_base; 5567 dump_public.start = dump_base;
5550 dump_public.end = dump_public.start + dump_size; 5568 dump_public.end = dump_public.start + dump_size;
5551 5569