diff options
| author | Paul Eggert | 2019-03-11 11:07:30 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-03-11 11:08:14 -0700 |
| commit | 1d65985a2b758ba41fe4a7965a282861d7b23d0a (patch) | |
| tree | e99b7e64c7825f13871e9132e69718e602d5b8d7 /src | |
| parent | 7fddde1f06def311c198303e6ac5a26256f17eb7 (diff) | |
| download | emacs-1d65985a2b758ba41fe4a7965a282861d7b23d0a.tar.gz emacs-1d65985a2b758ba41fe4a7965a282861d7b23d0a.zip | |
Reindent pdumper per usual Emacs style
* src/pdumper.c, src/pdumper.h: Reindent.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pdumper.c | 733 | ||||
| -rw-r--r-- | src/pdumper.h | 8 |
2 files changed, 330 insertions, 411 deletions
diff --git a/src/pdumper.c b/src/pdumper.c index 36a06d98288..56ac531363d 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -130,13 +130,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 130 | and have the same layout, where pointers are either 32 or 64 bits | 130 | and have the same layout, where pointers are either 32 or 64 bits |
| 131 | long, and where bytes have eight bits --- that is, a | 131 | long, and where bytes have eight bits --- that is, a |
| 132 | general-purpose computer made after 1990. */ | 132 | general-purpose computer made after 1990. */ |
| 133 | verify (sizeof (ptrdiff_t) == sizeof (void*)); | 133 | verify (sizeof (ptrdiff_t) == sizeof (void *)); |
| 134 | verify (sizeof (intptr_t) == sizeof (ptrdiff_t)); | 134 | verify (sizeof (intptr_t) == sizeof (ptrdiff_t)); |
| 135 | verify (sizeof (void (*)(void)) == sizeof (void*)); | 135 | verify (sizeof (void (*)(void)) == sizeof (void *)); |
| 136 | verify (sizeof (ptrdiff_t) <= sizeof (Lisp_Object)); | 136 | verify (sizeof (ptrdiff_t) <= sizeof (Lisp_Object)); |
| 137 | verify (sizeof (ptrdiff_t) <= sizeof (EMACS_INT)); | 137 | verify (sizeof (ptrdiff_t) <= sizeof (EMACS_INT)); |
| 138 | verify (sizeof (off_t) == sizeof (int32_t) || | 138 | verify (sizeof (off_t) == sizeof (int32_t) |
| 139 | sizeof (off_t) == sizeof (int64_t)); | 139 | || sizeof (off_t) == sizeof (int64_t)); |
| 140 | verify (CHAR_BIT == 8); | 140 | verify (CHAR_BIT == 8); |
| 141 | 141 | ||
| 142 | #define DIVIDE_ROUND_UP(x, y) (((x) + (y) - 1) / (y)) | 142 | #define DIVIDE_ROUND_UP(x, y) (((x) + (y) - 1) / (y)) |
| @@ -207,15 +207,13 @@ enum dump_reloc_type | |||
| 207 | RELOC_DUMP_TO_DUMP_PTR_RAW, | 207 | RELOC_DUMP_TO_DUMP_PTR_RAW, |
| 208 | /* dump_mpz = [rebuild bignum] */ | 208 | /* dump_mpz = [rebuild bignum] */ |
| 209 | RELOC_BIGNUM, | 209 | RELOC_BIGNUM, |
| 210 | /* dump_lv = make_lisp_ptr ( | 210 | /* dump_lv = make_lisp_ptr (dump_lv + dump_base, |
| 211 | dump_lv + dump_base, | 211 | type - RELOC_DUMP_TO_DUMP_LV) |
| 212 | type - RELOC_DUMP_TO_DUMP_LV) | ||
| 213 | (Special case for symbols: make_lisp_symbol) | 212 | (Special case for symbols: make_lisp_symbol) |
| 214 | Must be second-last. */ | 213 | Must be second-last. */ |
| 215 | RELOC_DUMP_TO_DUMP_LV, | 214 | RELOC_DUMP_TO_DUMP_LV, |
| 216 | /* dump_lv = make_lisp_ptr ( | 215 | /* dump_lv = make_lisp_ptr (dump_lv + emacs_basis(), |
| 217 | dump_lv + emacs_basis(), | 216 | type - RELOC_DUMP_TO_DUMP_LV) |
| 218 | type - RELOC_DUMP_TO_DUMP_LV) | ||
| 219 | (Special case for symbols: make_lisp_symbol.) | 217 | (Special case for symbols: make_lisp_symbol.) |
| 220 | Must be last. */ | 218 | Must be last. */ |
| 221 | RELOC_DUMP_TO_EMACS_LV = RELOC_DUMP_TO_DUMP_LV + 8, | 219 | RELOC_DUMP_TO_EMACS_LV = RELOC_DUMP_TO_DUMP_LV + 8, |
| @@ -336,11 +334,12 @@ dump_reloc_set_offset (struct dump_reloc *reloc, dump_off offset) | |||
| 336 | error ("dump relocation out of range"); | 334 | error ("dump relocation out of range"); |
| 337 | } | 335 | } |
| 338 | 336 | ||
| 339 | static void dump_fingerprint (const char* label, const uint8_t* xfingerprint) { | 337 | static void |
| 338 | dump_fingerprint (const char *label, const uint8_t *xfingerprint) | ||
| 339 | { | ||
| 340 | fprintf (stderr, "%s: ", label); | 340 | fprintf (stderr, "%s: ", label); |
| 341 | for (int i = 0; i <32; ++i) { | 341 | for (int i = 0; i < 32; ++i) |
| 342 | fprintf (stderr, "%02x", (unsigned) xfingerprint[i]); | 342 | fprintf (stderr, "%02x", (unsigned) xfingerprint[i]); |
| 343 | } | ||
| 344 | fprintf (stderr, "\n"); | 343 | fprintf (stderr, "\n"); |
| 345 | } | 344 | } |
| 346 | 345 | ||
| @@ -604,8 +603,8 @@ struct link_weight | |||
| 604 | /* Dump file creation */ | 603 | /* Dump file creation */ |
| 605 | 604 | ||
| 606 | static dump_off dump_object (struct dump_context *ctx, Lisp_Object object); | 605 | static dump_off dump_object (struct dump_context *ctx, Lisp_Object object); |
| 607 | static dump_off dump_object_for_offset ( | 606 | static dump_off dump_object_for_offset (struct dump_context *ctx, |
| 608 | struct dump_context *ctx, Lisp_Object object); | 607 | Lisp_Object object); |
| 609 | 608 | ||
| 610 | /* Like the Lisp function `push'. Return NEWELT. */ | 609 | /* Like the Lisp function `push'. Return NEWELT. */ |
| 611 | static Lisp_Object | 610 | static Lisp_Object |
| @@ -694,7 +693,7 @@ _Noreturn | |||
| 694 | static void | 693 | static void |
| 695 | error_unsupported_dump_object (struct dump_context *ctx, | 694 | error_unsupported_dump_object (struct dump_context *ctx, |
| 696 | Lisp_Object object, | 695 | Lisp_Object object, |
| 697 | const char* msg) | 696 | const char *msg) |
| 698 | { | 697 | { |
| 699 | if (dump_tracking_referrers_p (ctx)) | 698 | if (dump_tracking_referrers_p (ctx)) |
| 700 | print_paths_to_root (ctx, object); | 699 | print_paths_to_root (ctx, object); |
| @@ -732,9 +731,9 @@ dump_builtin_symbol_p (Lisp_Object object) | |||
| 732 | { | 731 | { |
| 733 | if (!SYMBOLP (object)) | 732 | if (!SYMBOLP (object)) |
| 734 | return false; | 733 | return false; |
| 735 | char* bp = (char*) lispsym; | 734 | char *bp = (char *) lispsym; |
| 736 | struct Lisp_Symbol *s = XSYMBOL (object); | 735 | struct Lisp_Symbol *s = XSYMBOL (object); |
| 737 | char* sp = (char*) s; | 736 | char *sp = (char *) s; |
| 738 | return bp <= sp && sp < bp + sizeof (lispsym); | 737 | return bp <= sp && sp < bp + sizeof (lispsym); |
| 739 | } | 738 | } |
| 740 | 739 | ||
| @@ -959,16 +958,16 @@ dump_note_reachable (struct dump_context *ctx, Lisp_Object object) | |||
| 959 | 958 | ||
| 960 | /* If this object lives in the Emacs image and not on the heap, return | 959 | /* If this object lives in the Emacs image and not on the heap, return |
| 961 | a pointer to the object data. Otherwise, return NULL. */ | 960 | a pointer to the object data. Otherwise, return NULL. */ |
| 962 | static void* | 961 | static void * |
| 963 | dump_object_emacs_ptr (Lisp_Object lv) | 962 | dump_object_emacs_ptr (Lisp_Object lv) |
| 964 | { | 963 | { |
| 965 | if (SUBRP (lv)) | 964 | if (SUBRP (lv)) |
| 966 | return XSUBR (lv); | 965 | return XSUBR (lv); |
| 967 | if (dump_builtin_symbol_p (lv)) | 966 | if (dump_builtin_symbol_p (lv)) |
| 968 | return XSYMBOL (lv); | 967 | return XSYMBOL (lv); |
| 969 | if (XTYPE (lv) == Lisp_Vectorlike && | 968 | if (XTYPE (lv) == Lisp_Vectorlike |
| 970 | PSEUDOVECTOR_TYPEP (&XVECTOR (lv)->header, PVEC_THREAD) && | 969 | && PSEUDOVECTOR_TYPEP (&XVECTOR (lv)->header, PVEC_THREAD) |
| 971 | main_thread_p (XTHREAD (lv))) | 970 | && main_thread_p (XTHREAD (lv))) |
| 972 | return XTHREAD (lv); | 971 | return XTHREAD (lv); |
| 973 | return NULL; | 972 | return NULL; |
| 974 | } | 973 | } |
| @@ -995,11 +994,10 @@ dump_queue_empty_p (struct dump_queue *dump_queue) | |||
| 995 | Fhash_table_count (dump_queue->link_weights))); | 994 | Fhash_table_count (dump_queue->link_weights))); |
| 996 | if (!is_empty) | 995 | if (!is_empty) |
| 997 | { | 996 | { |
| 998 | eassert ( | 997 | eassert (!dump_tailq_empty_p (&dump_queue->zero_weight_objects) |
| 999 | !dump_tailq_empty_p (&dump_queue->zero_weight_objects) || | 998 | || !dump_tailq_empty_p (&dump_queue->one_weight_normal_objects) |
| 1000 | !dump_tailq_empty_p (&dump_queue->one_weight_normal_objects) || | 999 | || !dump_tailq_empty_p (&dump_queue->one_weight_strong_objects) |
| 1001 | !dump_tailq_empty_p (&dump_queue->one_weight_strong_objects) || | 1000 | || !dump_tailq_empty_p (&dump_queue->fancy_weight_objects)); |
| 1002 | !dump_tailq_empty_p (&dump_queue->fancy_weight_objects)); | ||
| 1003 | } | 1001 | } |
| 1004 | else | 1002 | else |
| 1005 | { | 1003 | { |
| @@ -1085,16 +1083,16 @@ dump_queue_enqueue (struct dump_queue *dump_queue, | |||
| 1085 | the object will have a single weight. Put the object | 1083 | the object will have a single weight. Put the object |
| 1086 | on the appropriate single-weight queue. */ | 1084 | on the appropriate single-weight queue. */ |
| 1087 | weights = Qnil; | 1085 | weights = Qnil; |
| 1086 | struct dump_tailq *tailq; | ||
| 1088 | if (!use_single_queues) | 1087 | if (!use_single_queues) |
| 1089 | dump_tailq_prepend (&dump_queue->fancy_weight_objects, object); | 1088 | tailq = &dump_queue->fancy_weight_objects; |
| 1090 | else if (weight.value == WEIGHT_NORMAL.value) | 1089 | else if (weight.value == WEIGHT_NORMAL.value) |
| 1091 | dump_tailq_prepend ( | 1090 | tailq = &dump_queue->one_weight_normal_objects; |
| 1092 | &dump_queue->one_weight_normal_objects, object); | ||
| 1093 | else if (weight.value == WEIGHT_STRONG.value) | 1091 | else if (weight.value == WEIGHT_STRONG.value) |
| 1094 | dump_tailq_prepend ( | 1092 | tailq = &dump_queue->one_weight_strong_objects; |
| 1095 | &dump_queue->one_weight_strong_objects, object); | ||
| 1096 | else | 1093 | else |
| 1097 | emacs_abort (); | 1094 | emacs_abort (); |
| 1095 | dump_tailq_prepend (tailq, object); | ||
| 1098 | } | 1096 | } |
| 1099 | else if (use_single_queues && NILP (XCDR (weights))) | 1097 | else if (use_single_queues && NILP (XCDR (weights))) |
| 1100 | dump_tailq_prepend (&dump_queue->fancy_weight_objects, object); | 1098 | dump_tailq_prepend (&dump_queue->fancy_weight_objects, object); |
| @@ -1169,8 +1167,7 @@ dump_queue_scan_fancy (struct dump_queue *dump_queue, | |||
| 1169 | while (!NILP (*cons_ptr)) | 1167 | while (!NILP (*cons_ptr)) |
| 1170 | { | 1168 | { |
| 1171 | Lisp_Object queued_object = XCAR (*cons_ptr); | 1169 | Lisp_Object queued_object = XCAR (*cons_ptr); |
| 1172 | float score = dump_queue_compute_score ( | 1170 | float score = dump_queue_compute_score (dump_queue, queued_object, basis); |
| 1173 | dump_queue, queued_object, basis); | ||
| 1174 | if (first || score >= highest_score) | 1171 | if (first || score >= highest_score) |
| 1175 | { | 1172 | { |
| 1176 | highest_score_cons_ptr = cons_ptr; | 1173 | highest_score_cons_ptr = cons_ptr; |
| @@ -1206,12 +1203,11 @@ dump_queue_sequence (struct dump_queue *dump_queue, | |||
| 1206 | We organize these queues so that score is strictly decreasing, so | 1203 | We organize these queues so that score is strictly decreasing, so |
| 1207 | examining the head is sufficient. */ | 1204 | examining the head is sufficient. */ |
| 1208 | static void | 1205 | static void |
| 1209 | dump_queue_find_score_of_one_weight_queue ( | 1206 | dump_queue_find_score_of_one_weight_queue (struct dump_queue *dump_queue, |
| 1210 | struct dump_queue *dump_queue, | 1207 | dump_off basis, |
| 1211 | dump_off basis, | 1208 | struct dump_tailq *one_weight_queue, |
| 1212 | struct dump_tailq *one_weight_queue, | 1209 | float *out_score, |
| 1213 | float *out_score, | 1210 | int *out_sequence) |
| 1214 | int *out_sequence) | ||
| 1215 | { | 1211 | { |
| 1216 | /* Transparently discard stale objects from the head of this queue. */ | 1212 | /* Transparently discard stale objects from the head of this queue. */ |
| 1217 | do | 1213 | do |
| @@ -1248,27 +1244,27 @@ dump_queue_dequeue (struct dump_queue *dump_queue, dump_off basis) | |||
| 1248 | eassert (EQ (Fhash_table_count (dump_queue->sequence_numbers), | 1244 | eassert (EQ (Fhash_table_count (dump_queue->sequence_numbers), |
| 1249 | Fhash_table_count (dump_queue->link_weights))); | 1245 | Fhash_table_count (dump_queue->link_weights))); |
| 1250 | 1246 | ||
| 1251 | eassert ( | 1247 | eassert (XFIXNUM (Fhash_table_count (dump_queue->sequence_numbers)) |
| 1252 | XFIXNUM (Fhash_table_count (dump_queue->sequence_numbers)) | 1248 | <= (dump_tailq_length (&dump_queue->fancy_weight_objects) |
| 1253 | <= (dump_tailq_length (&dump_queue->fancy_weight_objects) + | 1249 | + dump_tailq_length (&dump_queue->zero_weight_objects) |
| 1254 | dump_tailq_length (&dump_queue->zero_weight_objects) + | 1250 | + dump_tailq_length (&dump_queue->one_weight_normal_objects) |
| 1255 | dump_tailq_length (&dump_queue->one_weight_normal_objects) + | 1251 | + dump_tailq_length (&dump_queue->one_weight_strong_objects))); |
| 1256 | dump_tailq_length (&dump_queue->one_weight_strong_objects))); | ||
| 1257 | 1252 | ||
| 1258 | bool dump_object_counts = true; | 1253 | bool dump_object_counts = true; |
| 1259 | if (dump_object_counts) | 1254 | if (dump_object_counts) |
| 1260 | dump_trace ( | 1255 | dump_trace |
| 1261 | "dump_queue_dequeue basis=%d fancy=%u zero=%u " | 1256 | ("dump_queue_dequeue basis=%d fancy=%u zero=%u " |
| 1262 | "normal=%u strong=%u hash=%u\n", | 1257 | "normal=%u strong=%u hash=%u\n", |
| 1263 | basis, | 1258 | basis, |
| 1264 | (unsigned) dump_tailq_length (&dump_queue->fancy_weight_objects), | 1259 | (unsigned) dump_tailq_length (&dump_queue->fancy_weight_objects), |
| 1265 | (unsigned) dump_tailq_length (&dump_queue->zero_weight_objects), | 1260 | (unsigned) dump_tailq_length (&dump_queue->zero_weight_objects), |
| 1266 | (unsigned) dump_tailq_length (&dump_queue->one_weight_normal_objects), | 1261 | (unsigned) dump_tailq_length (&dump_queue->one_weight_normal_objects), |
| 1267 | (unsigned) dump_tailq_length (&dump_queue->one_weight_strong_objects), | 1262 | (unsigned) dump_tailq_length (&dump_queue->one_weight_strong_objects), |
| 1268 | (unsigned) XFIXNUM (Fhash_table_count (dump_queue->link_weights))); | 1263 | (unsigned) XFIXNUM (Fhash_table_count (dump_queue->link_weights))); |
| 1269 | 1264 | ||
| 1270 | static const int nr_candidates = 3; | 1265 | static const int nr_candidates = 3; |
| 1271 | struct candidate { | 1266 | struct candidate |
| 1267 | { | ||
| 1272 | float score; | 1268 | float score; |
| 1273 | dump_off sequence; | 1269 | dump_off sequence; |
| 1274 | } candidates[nr_candidates]; | 1270 | } candidates[nr_candidates]; |
| @@ -1279,10 +1275,8 @@ dump_queue_dequeue (struct dump_queue *dump_queue, dump_off basis) | |||
| 1279 | { | 1275 | { |
| 1280 | if (candidates[0].sequence < 0) | 1276 | if (candidates[0].sequence < 0) |
| 1281 | *fancy_cons = XCDR (*fancy_cons); /* Discard stale object. */ | 1277 | *fancy_cons = XCDR (*fancy_cons); /* Discard stale object. */ |
| 1282 | candidates[0].score = dump_queue_scan_fancy ( | 1278 | candidates[0].score = dump_queue_scan_fancy (dump_queue, basis, |
| 1283 | dump_queue, | 1279 | &fancy_cons); |
| 1284 | basis, | ||
| 1285 | &fancy_cons); | ||
| 1286 | candidates[0].sequence = | 1280 | candidates[0].sequence = |
| 1287 | candidates[0].score > -INFINITY | 1281 | candidates[0].score > -INFINITY |
| 1288 | ? dump_queue_sequence (dump_queue, XCAR (*fancy_cons)) | 1282 | ? dump_queue_sequence (dump_queue, XCAR (*fancy_cons)) |
| @@ -1290,29 +1284,27 @@ dump_queue_dequeue (struct dump_queue *dump_queue, dump_off basis) | |||
| 1290 | } | 1284 | } |
| 1291 | while (candidates[0].sequence < 0); | 1285 | while (candidates[0].sequence < 0); |
| 1292 | 1286 | ||
| 1293 | dump_queue_find_score_of_one_weight_queue ( | 1287 | dump_queue_find_score_of_one_weight_queue |
| 1294 | dump_queue, | 1288 | (dump_queue, basis, |
| 1295 | basis, | 1289 | &dump_queue->one_weight_normal_objects, |
| 1296 | &dump_queue->one_weight_normal_objects, | 1290 | &candidates[1].score, |
| 1297 | &candidates[1].score, | 1291 | &candidates[1].sequence); |
| 1298 | &candidates[1].sequence); | ||
| 1299 | 1292 | ||
| 1300 | dump_queue_find_score_of_one_weight_queue ( | 1293 | dump_queue_find_score_of_one_weight_queue |
| 1301 | dump_queue, | 1294 | (dump_queue, basis, |
| 1302 | basis, | 1295 | &dump_queue->one_weight_strong_objects, |
| 1303 | &dump_queue->one_weight_strong_objects, | 1296 | &candidates[2].score, |
| 1304 | &candidates[2].score, | 1297 | &candidates[2].sequence); |
| 1305 | &candidates[2].sequence); | ||
| 1306 | 1298 | ||
| 1307 | int best = -1; | 1299 | int best = -1; |
| 1308 | for (int i = 0; i < nr_candidates; ++i) | 1300 | for (int i = 0; i < nr_candidates; ++i) |
| 1309 | { | 1301 | { |
| 1310 | eassert (candidates[i].sequence >= 0); | 1302 | eassert (candidates[i].sequence >= 0); |
| 1311 | if (candidates[i].score > -INFINITY && | 1303 | if (candidates[i].score > -INFINITY |
| 1312 | (best < 0 || | 1304 | && (best < 0 |
| 1313 | candidates[i].score > candidates[best].score || | 1305 | || candidates[i].score > candidates[best].score |
| 1314 | (candidates[i].score == candidates[best].score | 1306 | || (candidates[i].score == candidates[best].score |
| 1315 | && candidates[i].sequence < candidates[best].sequence))) | 1307 | && candidates[i].sequence < candidates[best].sequence))) |
| 1316 | best = i; | 1308 | best = i; |
| 1317 | } | 1309 | } |
| 1318 | 1310 | ||
| @@ -1355,13 +1347,12 @@ dump_queue_dequeue (struct dump_queue *dump_queue, dump_off basis) | |||
| 1355 | dump_off_from_lisp (XCAR (basis_weight_pair)); | 1347 | dump_off_from_lisp (XCAR (basis_weight_pair)); |
| 1356 | dump_off link_weight = | 1348 | dump_off link_weight = |
| 1357 | dump_off_from_lisp (XCDR (basis_weight_pair)); | 1349 | dump_off_from_lisp (XCDR (basis_weight_pair)); |
| 1358 | dump_trace ( | 1350 | dump_trace |
| 1359 | " link_basis=%d distance=%d weight=%d contrib=%f\n", | 1351 | (" link_basis=%d distance=%d weight=%d contrib=%f\n", |
| 1360 | link_basis, | 1352 | link_basis, |
| 1361 | basis - link_basis, | 1353 | basis - link_basis, |
| 1362 | link_weight, | 1354 | link_weight, |
| 1363 | (double) dump_calc_link_score ( | 1355 | (double) dump_calc_link_score (basis, link_basis, link_weight)); |
| 1364 | basis, link_basis, link_weight)); | ||
| 1365 | } | 1356 | } |
| 1366 | } | 1357 | } |
| 1367 | 1358 | ||
| @@ -1379,8 +1370,8 @@ dump_object_needs_dumping_p (Lisp_Object object) | |||
| 1379 | associated data too, and these data-carrying objects need to be | 1370 | associated data too, and these data-carrying objects need to be |
| 1380 | included in the dump despite all references to them being | 1371 | included in the dump despite all references to them being |
| 1381 | bitwise-invariant. */ | 1372 | bitwise-invariant. */ |
| 1382 | return !dump_object_self_representing_p (object) || | 1373 | return (!dump_object_self_representing_p (object) |
| 1383 | dump_object_emacs_ptr (object); | 1374 | || dump_object_emacs_ptr (object)); |
| 1384 | } | 1375 | } |
| 1385 | 1376 | ||
| 1386 | static void | 1377 | static void |
| @@ -1555,10 +1546,8 @@ dump_reloc_dump_to_emacs_lv (struct dump_context *ctx, | |||
| 1555 | been adjusted to account for the location of the running Emacs and | 1546 | been adjusted to account for the location of the running Emacs and |
| 1556 | dump file). */ | 1547 | dump file). */ |
| 1557 | static void | 1548 | static void |
| 1558 | dump_emacs_reloc_copy_from_dump (struct dump_context *ctx, | 1549 | dump_emacs_reloc_copy_from_dump (struct dump_context *ctx, dump_off dump_offset, |
| 1559 | dump_off dump_offset, | 1550 | void *emacs_ptr, dump_off size) |
| 1560 | void* emacs_ptr, | ||
| 1561 | dump_off size) | ||
| 1562 | { | 1551 | { |
| 1563 | eassert (size >= 0); | 1552 | eassert (size >= 0); |
| 1564 | eassert (size < (1 << EMACS_RELOC_LENGTH_BITS)); | 1553 | eassert (size < (1 << EMACS_RELOC_LENGTH_BITS)); |
| @@ -1624,8 +1613,7 @@ DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_bool, bool); | |||
| 1624 | into the dump. */ | 1613 | into the dump. */ |
| 1625 | static void | 1614 | static void |
| 1626 | dump_emacs_reloc_to_dump_ptr_raw (struct dump_context *ctx, | 1615 | dump_emacs_reloc_to_dump_ptr_raw (struct dump_context *ctx, |
| 1627 | const void* emacs_ptr, | 1616 | const void *emacs_ptr, dump_off dump_offset) |
| 1628 | dump_off dump_offset) | ||
| 1629 | { | 1617 | { |
| 1630 | if (!ctx->flags.dump_object_contents) | 1618 | if (!ctx->flags.dump_object_contents) |
| 1631 | return; | 1619 | return; |
| @@ -1657,13 +1645,12 @@ dump_emacs_reloc_to_lv (struct dump_context *ctx, | |||
| 1657 | right type, but we might as well maintain the invariant | 1645 | right type, but we might as well maintain the invariant |
| 1658 | that the types on ctx->emacs_relocs correspond to the types | 1646 | that the types on ctx->emacs_relocs correspond to the types |
| 1659 | of emacs_relocs we actually emit. */ | 1647 | of emacs_relocs we actually emit. */ |
| 1660 | dump_push ( | 1648 | dump_push (&ctx->emacs_relocs, |
| 1661 | &ctx->emacs_relocs, | 1649 | list3 (make_fixnum (dump_object_emacs_ptr (value) |
| 1662 | list3 (make_fixnum (dump_object_emacs_ptr (value) | 1650 | ? RELOC_EMACS_EMACS_LV |
| 1663 | ? RELOC_EMACS_EMACS_LV | 1651 | : RELOC_EMACS_DUMP_LV), |
| 1664 | : RELOC_EMACS_DUMP_LV), | 1652 | dump_off_to_lisp (emacs_offset (emacs_ptr)), |
| 1665 | dump_off_to_lisp (emacs_offset (emacs_ptr)), | 1653 | value)); |
| 1666 | value)); | ||
| 1667 | dump_enqueue_object (ctx, value, WEIGHT_NONE); | 1654 | dump_enqueue_object (ctx, value, WEIGHT_NONE); |
| 1668 | } | 1655 | } |
| 1669 | } | 1656 | } |
| @@ -1671,8 +1658,7 @@ dump_emacs_reloc_to_lv (struct dump_context *ctx, | |||
| 1671 | /* Add an emacs relocation that makes a raw pointer in Emacs point | 1658 | /* Add an emacs relocation that makes a raw pointer in Emacs point |
| 1672 | back into the Emacs image. */ | 1659 | back into the Emacs image. */ |
| 1673 | static void | 1660 | static void |
| 1674 | dump_emacs_reloc_to_emacs_ptr_raw (struct dump_context *ctx, | 1661 | dump_emacs_reloc_to_emacs_ptr_raw (struct dump_context *ctx, void *emacs_ptr, |
| 1675 | void* emacs_ptr, | ||
| 1676 | void *target_emacs_ptr) | 1662 | void *target_emacs_ptr) |
| 1677 | { | 1663 | { |
| 1678 | if (!ctx->flags.dump_object_contents) | 1664 | if (!ctx->flags.dump_object_contents) |
| @@ -1720,12 +1706,11 @@ dump_remember_fixup_lv (struct dump_context *ctx, | |||
| 1720 | return; | 1706 | return; |
| 1721 | 1707 | ||
| 1722 | dump_push (&ctx->fixups, | 1708 | dump_push (&ctx->fixups, |
| 1723 | list3 ( | 1709 | list3 (make_fixnum (fixup_subtype == LV_FIXUP_LISP_OBJECT |
| 1724 | make_fixnum (fixup_subtype == LV_FIXUP_LISP_OBJECT | 1710 | ? DUMP_FIXUP_LISP_OBJECT |
| 1725 | ? DUMP_FIXUP_LISP_OBJECT | 1711 | : DUMP_FIXUP_LISP_OBJECT_RAW), |
| 1726 | : DUMP_FIXUP_LISP_OBJECT_RAW), | 1712 | dump_off_to_lisp (dump_offset), |
| 1727 | dump_off_to_lisp (dump_offset), | 1713 | value)); |
| 1728 | value)); | ||
| 1729 | } | 1714 | } |
| 1730 | 1715 | ||
| 1731 | /* Remember to fix up the dump file such that the pointer-sized value | 1716 | /* Remember to fix up the dump file such that the pointer-sized value |
| @@ -1741,16 +1726,15 @@ dump_remember_fixup_ptr_raw (struct dump_context *ctx, | |||
| 1741 | 1726 | ||
| 1742 | /* We should not be generating relocations into the | 1727 | /* We should not be generating relocations into the |
| 1743 | to-be-copied-into-Emacs dump region. */ | 1728 | to-be-copied-into-Emacs dump region. */ |
| 1744 | eassert (ctx->header.discardable_start == 0 || | 1729 | eassert (ctx->header.discardable_start == 0 |
| 1745 | new_dump_offset < ctx->header.discardable_start || | 1730 | || new_dump_offset < ctx->header.discardable_start |
| 1746 | (ctx->header.cold_start != 0 && | 1731 | || (ctx->header.cold_start != 0 |
| 1747 | new_dump_offset >= ctx->header.cold_start)); | 1732 | && new_dump_offset >= ctx->header.cold_start)); |
| 1748 | 1733 | ||
| 1749 | dump_push (&ctx->fixups, | 1734 | dump_push (&ctx->fixups, |
| 1750 | list3 ( | 1735 | list3 (make_fixnum (DUMP_FIXUP_PTR_DUMP_RAW), |
| 1751 | make_fixnum (DUMP_FIXUP_PTR_DUMP_RAW), | 1736 | dump_off_to_lisp (dump_offset), |
| 1752 | dump_off_to_lisp (dump_offset), | 1737 | dump_off_to_lisp (new_dump_offset))); |
| 1753 | dump_off_to_lisp (new_dump_offset))); | ||
| 1754 | } | 1738 | } |
| 1755 | 1739 | ||
| 1756 | static void | 1740 | static void |
| @@ -1870,8 +1854,8 @@ dump_field_lv_or_rawptr (struct dump_context *ctx, | |||
| 1870 | intptr_t out_value; | 1854 | intptr_t out_value; |
| 1871 | dump_off out_field_offset = ctx->obj_offset + relpos; | 1855 | dump_off out_field_offset = ctx->obj_offset + relpos; |
| 1872 | dump_off target_offset = dump_recall_object (ctx, value); | 1856 | dump_off target_offset = dump_recall_object (ctx, value); |
| 1873 | if (DANGEROUS && | 1857 | if (DANGEROUS |
| 1874 | target_offset > 0 && dump_object_emacs_ptr (value) == NULL) | 1858 | && target_offset > 0 && dump_object_emacs_ptr (value) == NULL) |
| 1875 | { | 1859 | { |
| 1876 | /* We've already dumped the referenced object, so we can emit | 1860 | /* We've already dumped the referenced object, so we can emit |
| 1877 | the value and a relocation directly instead of indirecting | 1861 | the value and a relocation directly instead of indirecting |
| @@ -1970,7 +1954,7 @@ dump_field_ptr_to_dump_offset (struct dump_context *ctx, | |||
| 1970 | dump_off relpos = field_relpos (in_start, in_field); | 1954 | dump_off relpos = field_relpos (in_start, in_field); |
| 1971 | dump_reloc_dump_to_dump_ptr_raw (ctx, ctx->obj_offset + relpos); | 1955 | dump_reloc_dump_to_dump_ptr_raw (ctx, ctx->obj_offset + relpos); |
| 1972 | intptr_t outval = target_dump_offset; | 1956 | intptr_t outval = target_dump_offset; |
| 1973 | memcpy ((char*) out + relpos, &outval, sizeof (outval)); | 1957 | memcpy ((char *) out + relpos, &outval, sizeof (outval)); |
| 1974 | } | 1958 | } |
| 1975 | 1959 | ||
| 1976 | /* Mark a field as pointing to a place inside Emacs. | 1960 | /* Mark a field as pointing to a place inside Emacs. |
| @@ -2001,14 +1985,13 @@ dump_field_emacs_ptr (struct dump_context *ctx, | |||
| 2001 | rel_emacs_ptr = emacs_offset ((void *)abs_emacs_ptr); | 1985 | rel_emacs_ptr = emacs_offset ((void *)abs_emacs_ptr); |
| 2002 | dump_reloc_dump_to_emacs_ptr_raw (ctx, ctx->obj_offset + relpos); | 1986 | dump_reloc_dump_to_emacs_ptr_raw (ctx, ctx->obj_offset + relpos); |
| 2003 | } | 1987 | } |
| 2004 | cpyptr ((char*) out + relpos, &rel_emacs_ptr); | 1988 | cpyptr ((char *) out + relpos, &rel_emacs_ptr); |
| 2005 | } | 1989 | } |
| 2006 | 1990 | ||
| 2007 | static void | 1991 | static void |
| 2008 | _dump_object_start_pseudovector ( | 1992 | _dump_object_start_pseudovector (struct dump_context *ctx, |
| 2009 | struct dump_context *ctx, | 1993 | union vectorlike_header *out_hdr, |
| 2010 | union vectorlike_header *out_hdr, | 1994 | const union vectorlike_header *in_hdr) |
| 2011 | const union vectorlike_header *in_hdr) | ||
| 2012 | { | 1995 | { |
| 2013 | eassert (in_hdr->size & PSEUDOVECTOR_FLAG); | 1996 | eassert (in_hdr->size & PSEUDOVECTOR_FLAG); |
| 2014 | ptrdiff_t vec_size = vectorlike_nbytes (in_hdr); | 1997 | ptrdiff_t vec_size = vectorlike_nbytes (in_hdr); |
| @@ -2032,10 +2015,9 @@ finish_dump_pvec (struct dump_context *ctx, | |||
| 2032 | } | 2015 | } |
| 2033 | 2016 | ||
| 2034 | static void | 2017 | static void |
| 2035 | dump_pseudovector_lisp_fields ( | 2018 | dump_pseudovector_lisp_fields (struct dump_context *ctx, |
| 2036 | struct dump_context *ctx, | 2019 | union vectorlike_header *out_hdr, |
| 2037 | union vectorlike_header *out_hdr, | 2020 | const union vectorlike_header *in_hdr) |
| 2038 | const union vectorlike_header *in_hdr) | ||
| 2039 | { | 2021 | { |
| 2040 | const struct Lisp_Vector *in = (const struct Lisp_Vector *) in_hdr; | 2022 | const struct Lisp_Vector *in = (const struct Lisp_Vector *) in_hdr; |
| 2041 | struct Lisp_Vector *out = (struct Lisp_Vector *) out_hdr; | 2023 | struct Lisp_Vector *out = (struct Lisp_Vector *) out_hdr; |
| @@ -2079,10 +2061,8 @@ dump_interval_tree (struct dump_context *ctx, | |||
| 2079 | if (!tree->up_obj) | 2061 | if (!tree->up_obj) |
| 2080 | { | 2062 | { |
| 2081 | eassert (parent_offset != 0); | 2063 | eassert (parent_offset != 0); |
| 2082 | dump_field_ptr_to_dump_offset ( | 2064 | dump_field_ptr_to_dump_offset (ctx, &out, tree, &tree->up.interval, |
| 2083 | ctx, &out, | 2065 | parent_offset); |
| 2084 | tree, &tree->up.interval, | ||
| 2085 | parent_offset); | ||
| 2086 | } | 2066 | } |
| 2087 | else | 2067 | else |
| 2088 | dump_field_lv (ctx, &out, tree, &tree->up.obj, WEIGHT_STRONG); | 2068 | dump_field_lv (ctx, &out, tree, &tree->up.obj, WEIGHT_STRONG); |
| @@ -2095,15 +2075,15 @@ dump_interval_tree (struct dump_context *ctx, | |||
| 2095 | dump_field_lv (ctx, &out, tree, &tree->plist, WEIGHT_STRONG); | 2075 | dump_field_lv (ctx, &out, tree, &tree->plist, WEIGHT_STRONG); |
| 2096 | dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); | 2076 | dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); |
| 2097 | if (tree->left) | 2077 | if (tree->left) |
| 2098 | dump_remember_fixup_ptr_raw ( | 2078 | dump_remember_fixup_ptr_raw |
| 2099 | ctx, | 2079 | (ctx, |
| 2100 | offset + dump_offsetof (struct interval, left), | 2080 | offset + dump_offsetof (struct interval, left), |
| 2101 | dump_interval_tree (ctx, tree->left, offset)); | 2081 | dump_interval_tree (ctx, tree->left, offset)); |
| 2102 | if (tree->right) | 2082 | if (tree->right) |
| 2103 | dump_remember_fixup_ptr_raw ( | 2083 | dump_remember_fixup_ptr_raw |
| 2104 | ctx, | 2084 | (ctx, |
| 2105 | offset + dump_offsetof (struct interval, right), | 2085 | offset + dump_offsetof (struct interval, right), |
| 2106 | dump_interval_tree (ctx, tree->right, offset)); | 2086 | dump_interval_tree (ctx, tree->right, offset)); |
| 2107 | return offset; | 2087 | return offset; |
| 2108 | } | 2088 | } |
| 2109 | 2089 | ||
| @@ -2140,15 +2120,15 @@ dump_string (struct dump_context *ctx, const struct Lisp_String *string) | |||
| 2140 | dump_field_fixup_later (ctx, &out, string, &string->u.s.data); | 2120 | dump_field_fixup_later (ctx, &out, string, &string->u.s.data); |
| 2141 | dump_remember_cold_op (ctx, | 2121 | dump_remember_cold_op (ctx, |
| 2142 | COLD_OP_STRING, | 2122 | COLD_OP_STRING, |
| 2143 | make_lisp_ptr ((void*) string, Lisp_String)); | 2123 | make_lisp_ptr ((void *) string, Lisp_String)); |
| 2144 | } | 2124 | } |
| 2145 | 2125 | ||
| 2146 | dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); | 2126 | dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); |
| 2147 | if (string->u.s.intervals) | 2127 | if (string->u.s.intervals) |
| 2148 | dump_remember_fixup_ptr_raw ( | 2128 | dump_remember_fixup_ptr_raw |
| 2149 | ctx, | 2129 | (ctx, |
| 2150 | offset + dump_offsetof (struct Lisp_String, u.s.intervals), | 2130 | offset + dump_offsetof (struct Lisp_String, u.s.intervals), |
| 2151 | dump_interval_tree (ctx, string->u.s.intervals, 0)); | 2131 | dump_interval_tree (ctx, string->u.s.intervals, 0)); |
| 2152 | 2132 | ||
| 2153 | return offset; | 2133 | return offset; |
| 2154 | } | 2134 | } |
| @@ -2166,16 +2146,10 @@ dump_marker (struct dump_context *ctx, const struct Lisp_Marker *marker) | |||
| 2166 | DUMP_FIELD_COPY (out, marker, insertion_type); | 2146 | DUMP_FIELD_COPY (out, marker, insertion_type); |
| 2167 | if (marker->buffer) | 2147 | if (marker->buffer) |
| 2168 | { | 2148 | { |
| 2169 | dump_field_lv_rawptr ( | 2149 | dump_field_lv_rawptr (ctx, out, marker, &marker->buffer, |
| 2170 | ctx, out, | 2150 | Lisp_Vectorlike, WEIGHT_NORMAL); |
| 2171 | marker, &marker->buffer, | 2151 | dump_field_lv_rawptr (ctx, out, marker, &marker->next, |
| 2172 | Lisp_Vectorlike, | 2152 | Lisp_Vectorlike, WEIGHT_STRONG); |
| 2173 | WEIGHT_NORMAL); | ||
| 2174 | dump_field_lv_rawptr ( | ||
| 2175 | ctx, out, | ||
| 2176 | marker, &marker->next, | ||
| 2177 | Lisp_Vectorlike, | ||
| 2178 | WEIGHT_STRONG); | ||
| 2179 | DUMP_FIELD_COPY (out, marker, charpos); | 2153 | DUMP_FIELD_COPY (out, marker, charpos); |
| 2180 | DUMP_FIELD_COPY (out, marker, bytepos); | 2154 | DUMP_FIELD_COPY (out, marker, bytepos); |
| 2181 | } | 2155 | } |
| @@ -2249,14 +2223,13 @@ dump_bignum (struct dump_context *ctx, Lisp_Object object) | |||
| 2249 | dump_remember_cold_op (ctx, COLD_OP_BIGNUM, object); | 2223 | dump_remember_cold_op (ctx, COLD_OP_BIGNUM, object); |
| 2250 | 2224 | ||
| 2251 | /* Write the offset of that exported blob here. */ | 2225 | /* Write the offset of that exported blob here. */ |
| 2252 | dump_off value_offset = | 2226 | dump_off value_offset |
| 2253 | bignum_offset + | 2227 | = (bignum_offset |
| 2254 | (dump_off) offsetof (struct Lisp_Bignum, value); | 2228 | + (dump_off) offsetof (struct Lisp_Bignum, value)); |
| 2255 | dump_push (&ctx->fixups, | 2229 | dump_push (&ctx->fixups, |
| 2256 | list3 ( | 2230 | list3 (make_fixnum (DUMP_FIXUP_BIGNUM_DATA), |
| 2257 | make_fixnum (DUMP_FIXUP_BIGNUM_DATA), | 2231 | dump_off_to_lisp (value_offset), |
| 2258 | dump_off_to_lisp (value_offset), | 2232 | object)); |
| 2259 | object)); | ||
| 2260 | 2233 | ||
| 2261 | /* When we load the dump, slurp the data blob and turn it into a | 2234 | /* When we load the dump, slurp the data blob and turn it into a |
| 2262 | real bignum. Attach the relocation to the start of the | 2235 | real bignum. Attach the relocation to the start of the |
| @@ -2412,10 +2385,10 @@ dump_blv (struct dump_context *ctx, | |||
| 2412 | dump_field_lv (ctx, &out, blv, &blv->valcell, WEIGHT_STRONG); | 2385 | dump_field_lv (ctx, &out, blv, &blv->valcell, WEIGHT_STRONG); |
| 2413 | dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); | 2386 | dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); |
| 2414 | if (blv->fwd) | 2387 | if (blv->fwd) |
| 2415 | dump_remember_fixup_ptr_raw ( | 2388 | dump_remember_fixup_ptr_raw |
| 2416 | ctx, | 2389 | (ctx, |
| 2417 | offset + dump_offsetof (struct Lisp_Buffer_Local_Value, fwd), | 2390 | offset + dump_offsetof (struct Lisp_Buffer_Local_Value, fwd), |
| 2418 | dump_fwd (ctx, blv->fwd)); | 2391 | dump_fwd (ctx, blv->fwd)); |
| 2419 | return offset; | 2392 | return offset; |
| 2420 | } | 2393 | } |
| 2421 | 2394 | ||
| @@ -2425,8 +2398,7 @@ dump_recall_symbol_aux (struct dump_context *ctx, Lisp_Object symbol) | |||
| 2425 | Lisp_Object symbol_aux = ctx->symbol_aux; | 2398 | Lisp_Object symbol_aux = ctx->symbol_aux; |
| 2426 | if (NILP (symbol_aux)) | 2399 | if (NILP (symbol_aux)) |
| 2427 | return 0; | 2400 | return 0; |
| 2428 | return dump_off_from_lisp ( | 2401 | return dump_off_from_lisp (Fgethash (symbol, symbol_aux, make_fixnum (0))); |
| 2429 | Fgethash (symbol, symbol_aux, make_fixnum (0))); | ||
| 2430 | } | 2402 | } |
| 2431 | 2403 | ||
| 2432 | static void | 2404 | static void |
| @@ -2438,9 +2410,7 @@ dump_remember_symbol_aux (struct dump_context *ctx, | |||
| 2438 | } | 2410 | } |
| 2439 | 2411 | ||
| 2440 | static void | 2412 | static void |
| 2441 | dump_pre_dump_symbol ( | 2413 | dump_pre_dump_symbol (struct dump_context *ctx, struct Lisp_Symbol *symbol) |
| 2442 | struct dump_context *ctx, | ||
| 2443 | struct Lisp_Symbol *symbol) | ||
| 2444 | { | 2414 | { |
| 2445 | Lisp_Object symbol_lv = make_lisp_symbol (symbol); | 2415 | Lisp_Object symbol_lv = make_lisp_symbol (symbol); |
| 2446 | eassert (!dump_recall_symbol_aux (ctx, symbol_lv)); | 2416 | eassert (!dump_recall_symbol_aux (ctx, symbol_lv)); |
| @@ -2448,16 +2418,12 @@ dump_pre_dump_symbol ( | |||
| 2448 | switch (symbol->u.s.redirect) | 2418 | switch (symbol->u.s.redirect) |
| 2449 | { | 2419 | { |
| 2450 | case SYMBOL_LOCALIZED: | 2420 | case SYMBOL_LOCALIZED: |
| 2451 | dump_remember_symbol_aux ( | 2421 | dump_remember_symbol_aux (ctx, symbol_lv, |
| 2452 | ctx, | 2422 | dump_blv (ctx, symbol->u.s.val.blv)); |
| 2453 | symbol_lv, | ||
| 2454 | dump_blv (ctx, symbol->u.s.val.blv)); | ||
| 2455 | break; | 2423 | break; |
| 2456 | case SYMBOL_FORWARDED: | 2424 | case SYMBOL_FORWARDED: |
| 2457 | dump_remember_symbol_aux ( | 2425 | dump_remember_symbol_aux (ctx, symbol_lv, |
| 2458 | ctx, | 2426 | dump_fwd (ctx, symbol->u.s.val.fwd)); |
| 2459 | symbol_lv, | ||
| 2460 | dump_fwd (ctx, symbol->u.s.val.fwd)); | ||
| 2461 | break; | 2427 | break; |
| 2462 | default: | 2428 | default: |
| 2463 | break; | 2429 | break; |
| @@ -2481,8 +2447,8 @@ dump_symbol (struct dump_context *ctx, | |||
| 2481 | { | 2447 | { |
| 2482 | if (offset != DUMP_OBJECT_ON_SYMBOL_QUEUE) | 2448 | if (offset != DUMP_OBJECT_ON_SYMBOL_QUEUE) |
| 2483 | { | 2449 | { |
| 2484 | eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE || | 2450 | eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE |
| 2485 | offset == DUMP_OBJECT_NOT_SEEN); | 2451 | || offset == DUMP_OBJECT_NOT_SEEN); |
| 2486 | DUMP_CLEAR_REFERRER (ctx); | 2452 | DUMP_CLEAR_REFERRER (ctx); |
| 2487 | struct dump_flags old_flags = ctx->flags; | 2453 | struct dump_flags old_flags = ctx->flags; |
| 2488 | ctx->flags.dump_object_contents = false; | 2454 | ctx->flags.dump_object_contents = false; |
| @@ -2540,21 +2506,21 @@ dump_symbol (struct dump_context *ctx, | |||
| 2540 | { | 2506 | { |
| 2541 | case SYMBOL_LOCALIZED: | 2507 | case SYMBOL_LOCALIZED: |
| 2542 | aux_offset = dump_recall_symbol_aux (ctx, make_lisp_symbol (symbol)); | 2508 | aux_offset = dump_recall_symbol_aux (ctx, make_lisp_symbol (symbol)); |
| 2543 | dump_remember_fixup_ptr_raw ( | 2509 | dump_remember_fixup_ptr_raw |
| 2544 | ctx, | 2510 | (ctx, |
| 2545 | offset + dump_offsetof (struct Lisp_Symbol, u.s.val.blv), | 2511 | offset + dump_offsetof (struct Lisp_Symbol, u.s.val.blv), |
| 2546 | (aux_offset | 2512 | (aux_offset |
| 2547 | ? aux_offset | 2513 | ? aux_offset |
| 2548 | : dump_blv (ctx, symbol->u.s.val.blv))); | 2514 | : dump_blv (ctx, symbol->u.s.val.blv))); |
| 2549 | break; | 2515 | break; |
| 2550 | case SYMBOL_FORWARDED: | 2516 | case SYMBOL_FORWARDED: |
| 2551 | aux_offset = dump_recall_symbol_aux (ctx, make_lisp_symbol (symbol)); | 2517 | aux_offset = dump_recall_symbol_aux (ctx, make_lisp_symbol (symbol)); |
| 2552 | dump_remember_fixup_ptr_raw ( | 2518 | dump_remember_fixup_ptr_raw |
| 2553 | ctx, | 2519 | (ctx, |
| 2554 | offset + dump_offsetof (struct Lisp_Symbol, u.s.val.fwd), | 2520 | offset + dump_offsetof (struct Lisp_Symbol, u.s.val.fwd), |
| 2555 | (aux_offset | 2521 | (aux_offset |
| 2556 | ? aux_offset | 2522 | ? aux_offset |
| 2557 | : dump_fwd (ctx, symbol->u.s.val.fwd))); | 2523 | : dump_fwd (ctx, symbol->u.s.val.fwd))); |
| 2558 | break; | 2524 | break; |
| 2559 | default: | 2525 | default: |
| 2560 | break; | 2526 | break; |
| @@ -2563,9 +2529,8 @@ dump_symbol (struct dump_context *ctx, | |||
| 2563 | } | 2529 | } |
| 2564 | 2530 | ||
| 2565 | static dump_off | 2531 | static dump_off |
| 2566 | dump_vectorlike_generic ( | 2532 | dump_vectorlike_generic (struct dump_context *ctx, |
| 2567 | struct dump_context *ctx, | 2533 | const union vectorlike_header *header) |
| 2568 | const union vectorlike_header *header) | ||
| 2569 | { | 2534 | { |
| 2570 | #if CHECK_STRUCTS && !defined (HASH_vectorlike_header_00A5A4BFB2) | 2535 | #if CHECK_STRUCTS && !defined (HASH_vectorlike_header_00A5A4BFB2) |
| 2571 | # error "vectorlike_header changed. See CHECK_STRUCTS comment." | 2536 | # error "vectorlike_header changed. See CHECK_STRUCTS comment." |
| @@ -2586,9 +2551,8 @@ dump_vectorlike_generic ( | |||
| 2586 | we'll count on sizeof(Lisp_Object) >= GCALIGN builds to catch | 2551 | we'll count on sizeof(Lisp_Object) >= GCALIGN builds to catch |
| 2587 | this class of problem. | 2552 | this class of problem. |
| 2588 | */ | 2553 | */ |
| 2589 | eassert ( | 2554 | eassert ((size & PSEUDOVECTOR_REST_MASK) >> PSEUDOVECTOR_REST_BITS |
| 2590 | ((size & PSEUDOVECTOR_REST_MASK) >> PSEUDOVECTOR_REST_BITS) | 2555 | <= (sizeof (Lisp_Object) < GCALIGNMENT)); |
| 2591 | <= (sizeof (Lisp_Object) < GCALIGNMENT) ? 1 : 0); | ||
| 2592 | size &= PSEUDOVECTOR_SIZE_MASK; | 2556 | size &= PSEUDOVECTOR_SIZE_MASK; |
| 2593 | } | 2557 | } |
| 2594 | 2558 | ||
| @@ -2608,7 +2572,7 @@ dump_vectorlike_generic ( | |||
| 2608 | /* Don't use sizeof(out), since that incorporates unwanted | 2572 | /* Don't use sizeof(out), since that incorporates unwanted |
| 2609 | padding. Instead, use the size through the last non-Lisp | 2573 | padding. Instead, use the size through the last non-Lisp |
| 2610 | field. */ | 2574 | field. */ |
| 2611 | size_t sz = (char*)&out.min_char + sizeof (out.min_char) - (char*)&out; | 2575 | size_t sz = (char *)&out.min_char + sizeof (out.min_char) - (char *)&out; |
| 2612 | eassert (sz < DUMP_OFF_MAX); | 2576 | eassert (sz < DUMP_OFF_MAX); |
| 2613 | dump_object_start (ctx, &out, (dump_off) sz); | 2577 | dump_object_start (ctx, &out, (dump_off) sz); |
| 2614 | DUMP_FIELD_COPY (&out, sct, header.size); | 2578 | DUMP_FIELD_COPY (&out, sct, header.size); |
| @@ -2631,8 +2595,8 @@ dump_vectorlike_generic ( | |||
| 2631 | scribble beyond that start. */ | 2595 | scribble beyond that start. */ |
| 2632 | dump_off prefix_size = ctx->offset - prefix_start_offset; | 2596 | dump_off prefix_size = ctx->offset - prefix_start_offset; |
| 2633 | eassert (prefix_size > 0); | 2597 | eassert (prefix_size > 0); |
| 2634 | dump_off skip_start = ptrdiff_t_to_dump_off ( | 2598 | dump_off skip_start = ptrdiff_t_to_dump_off ((char *) &v->contents[skip] |
| 2635 | (char*) &v->contents[skip] - (char*) v); | 2599 | - (char *) v); |
| 2636 | eassert (skip_start >= prefix_size); | 2600 | eassert (skip_start >= prefix_size); |
| 2637 | dump_write_zero (ctx, skip_start - prefix_size); | 2601 | dump_write_zero (ctx, skip_start - prefix_size); |
| 2638 | 2602 | ||
| @@ -2672,10 +2636,10 @@ dump_hash_table_stable_p (const struct Lisp_Hash_Table *hash) | |||
| 2672 | if (!NILP (HASH_HASH (hash, i))) | 2636 | if (!NILP (HASH_HASH (hash, i))) |
| 2673 | { | 2637 | { |
| 2674 | Lisp_Object key = HASH_KEY (hash, i); | 2638 | Lisp_Object key = HASH_KEY (hash, i); |
| 2675 | bool key_stable = (dump_builtin_symbol_p (key) || | 2639 | bool key_stable = (dump_builtin_symbol_p (key) |
| 2676 | FIXNUMP (key) || | 2640 | || FIXNUMP (key) |
| 2677 | (is_equal && STRINGP (key)) || | 2641 | || (is_equal && STRINGP (key)) |
| 2678 | ((is_equal || is_eql) && FLOATP (key))); | 2642 | || ((is_equal || is_eql) && FLOATP (key))); |
| 2679 | if (!key_stable) | 2643 | if (!key_stable) |
| 2680 | return false; | 2644 | return false; |
| 2681 | } | 2645 | } |
| @@ -2713,10 +2677,8 @@ check_hash_table_rehash (Lisp_Object table_orig) | |||
| 2713 | Lisp_Object key_value_pair = dump_pop (&expected_contents); | 2677 | Lisp_Object key_value_pair = dump_pop (&expected_contents); |
| 2714 | Lisp_Object key = XCAR (key_value_pair); | 2678 | Lisp_Object key = XCAR (key_value_pair); |
| 2715 | Lisp_Object expected_value = XCDR (key_value_pair); | 2679 | Lisp_Object expected_value = XCDR (key_value_pair); |
| 2716 | Lisp_Object found_value = Fgethash ( | 2680 | Lisp_Object arbitrary = Qdump_emacs_portable__sort_predicate_copied; |
| 2717 | key, | 2681 | Lisp_Object found_value = Fgethash (key, table_rehashed, arbitrary); |
| 2718 | table_rehashed, | ||
| 2719 | Qdump_emacs_portable__sort_predicate_copied /* arbitrary */); | ||
| 2720 | eassert (EQ (expected_value, found_value)); | 2682 | eassert (EQ (expected_value, found_value)); |
| 2721 | Fremhash (key, table_rehashed); | 2683 | Fremhash (key, table_rehashed); |
| 2722 | } | 2684 | } |
| @@ -2740,13 +2702,13 @@ dump_hash_table (struct dump_context *ctx, | |||
| 2740 | because we need to assemble a list of weak tables) punt the hash | 2702 | because we need to assemble a list of weak tables) punt the hash |
| 2741 | table to the end of the dump, where we can lump all such hash | 2703 | table to the end of the dump, where we can lump all such hash |
| 2742 | tables together. */ | 2704 | tables together. */ |
| 2743 | if (!(is_stable || !NILP (hash_in->weak)) && | 2705 | if (!(is_stable || !NILP (hash_in->weak)) |
| 2744 | ctx->flags.defer_hash_tables) | 2706 | && ctx->flags.defer_hash_tables) |
| 2745 | { | 2707 | { |
| 2746 | if (offset != DUMP_OBJECT_ON_HASH_TABLE_QUEUE) | 2708 | if (offset != DUMP_OBJECT_ON_HASH_TABLE_QUEUE) |
| 2747 | { | 2709 | { |
| 2748 | eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE || | 2710 | eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE |
| 2749 | offset == DUMP_OBJECT_NOT_SEEN); | 2711 | || offset == DUMP_OBJECT_NOT_SEEN); |
| 2750 | /* We still want to dump the actual keys and values now. */ | 2712 | /* We still want to dump the actual keys and values now. */ |
| 2751 | dump_enqueue_object (ctx, hash_in->key_and_value, WEIGHT_NONE); | 2713 | dump_enqueue_object (ctx, hash_in->key_and_value, WEIGHT_NONE); |
| 2752 | /* We'll get to the rest later. */ | 2714 | /* We'll get to the rest later. */ |
| @@ -2758,7 +2720,7 @@ dump_hash_table (struct dump_context *ctx, | |||
| 2758 | } | 2720 | } |
| 2759 | 2721 | ||
| 2760 | if (PDUMPER_CHECK_REHASHING) | 2722 | if (PDUMPER_CHECK_REHASHING) |
| 2761 | check_hash_table_rehash (make_lisp_ptr ((void*)hash_in, Lisp_Vectorlike)); | 2723 | check_hash_table_rehash (make_lisp_ptr ((void *) hash_in, Lisp_Vectorlike)); |
| 2762 | 2724 | ||
| 2763 | struct Lisp_Hash_Table hash_munged = *hash_in; | 2725 | struct Lisp_Hash_Table hash_munged = *hash_in; |
| 2764 | struct Lisp_Hash_Table *hash = &hash_munged; | 2726 | struct Lisp_Hash_Table *hash = &hash_munged; |
| @@ -2819,13 +2781,13 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) | |||
| 2819 | if (buffer->base_buffer) | 2781 | if (buffer->base_buffer) |
| 2820 | { | 2782 | { |
| 2821 | eassert (buffer->base_buffer->base_buffer == NULL); | 2783 | eassert (buffer->base_buffer->base_buffer == NULL); |
| 2822 | base_offset = dump_object_for_offset ( | 2784 | base_offset = dump_object_for_offset |
| 2823 | ctx, | 2785 | (ctx, |
| 2824 | make_lisp_ptr (buffer->base_buffer, Lisp_Vectorlike)); | 2786 | make_lisp_ptr (buffer->base_buffer, Lisp_Vectorlike)); |
| 2825 | } | 2787 | } |
| 2826 | 2788 | ||
| 2827 | eassert ((base_offset == 0 && buffer->text == &in_buffer->own_text) || | 2789 | eassert ((base_offset == 0 && buffer->text == &in_buffer->own_text) |
| 2828 | (base_offset > 0 && buffer->text != &in_buffer->own_text)); | 2790 | || (base_offset > 0 && buffer->text != &in_buffer->own_text)); |
| 2829 | 2791 | ||
| 2830 | START_DUMP_PVEC (ctx, &buffer->header, struct buffer, out); | 2792 | START_DUMP_PVEC (ctx, &buffer->header, struct buffer, out); |
| 2831 | dump_pseudovector_lisp_fields (ctx, &out->header, &buffer->header); | 2793 | dump_pseudovector_lisp_fields (ctx, &out->header, &buffer->header); |
| @@ -2839,10 +2801,9 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) | |||
| 2839 | if (BUFFER_LIVE_P (buffer)) | 2801 | if (BUFFER_LIVE_P (buffer)) |
| 2840 | { | 2802 | { |
| 2841 | dump_field_fixup_later (ctx, out, buffer, &buffer->own_text.beg); | 2803 | dump_field_fixup_later (ctx, out, buffer, &buffer->own_text.beg); |
| 2842 | dump_remember_cold_op ( | 2804 | dump_remember_cold_op (ctx, COLD_OP_BUFFER, |
| 2843 | ctx, | 2805 | make_lisp_ptr ((void *) in_buffer, |
| 2844 | COLD_OP_BUFFER, | 2806 | Lisp_Vectorlike)); |
| 2845 | make_lisp_ptr ((void*) in_buffer, Lisp_Vectorlike)); | ||
| 2846 | } | 2807 | } |
| 2847 | else | 2808 | else |
| 2848 | eassert (buffer->own_text.beg == NULL); | 2809 | eassert (buffer->own_text.beg == NULL); |
| @@ -2870,10 +2831,10 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) | |||
| 2870 | } | 2831 | } |
| 2871 | 2832 | ||
| 2872 | eassert (ctx->obj_offset > 0); | 2833 | eassert (ctx->obj_offset > 0); |
| 2873 | dump_remember_fixup_ptr_raw ( | 2834 | dump_remember_fixup_ptr_raw |
| 2874 | ctx, | 2835 | (ctx, |
| 2875 | ctx->obj_offset + dump_offsetof (struct buffer, text), | 2836 | ctx->obj_offset + dump_offsetof (struct buffer, text), |
| 2876 | base_offset + dump_offsetof (struct buffer, own_text)); | 2837 | base_offset + dump_offsetof (struct buffer, own_text)); |
| 2877 | 2838 | ||
| 2878 | dump_field_lv_rawptr (ctx, out, buffer, &buffer->next, | 2839 | dump_field_lv_rawptr (ctx, out, buffer, &buffer->next, |
| 2879 | Lisp_Vectorlike, WEIGHT_NORMAL); | 2840 | Lisp_Vectorlike, WEIGHT_NORMAL); |
| @@ -2887,9 +2848,8 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) | |||
| 2887 | if (buffer->base_buffer) | 2848 | if (buffer->base_buffer) |
| 2888 | { | 2849 | { |
| 2889 | eassert (ctx->obj_offset != base_offset); | 2850 | eassert (ctx->obj_offset != base_offset); |
| 2890 | dump_field_ptr_to_dump_offset ( | 2851 | dump_field_ptr_to_dump_offset (ctx, out, buffer, &buffer->base_buffer, |
| 2891 | ctx, out, buffer, &buffer->base_buffer, | 2852 | base_offset); |
| 2892 | base_offset); | ||
| 2893 | } | 2853 | } |
| 2894 | 2854 | ||
| 2895 | DUMP_FIELD_COPY (out, buffer, indirections); | 2855 | DUMP_FIELD_COPY (out, buffer, indirections); |
| @@ -2924,10 +2884,10 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) | |||
| 2924 | WEIGHT_STRONG); | 2884 | WEIGHT_STRONG); |
| 2925 | dump_off offset = finish_dump_pvec (ctx, &out->header); | 2885 | dump_off offset = finish_dump_pvec (ctx, &out->header); |
| 2926 | if (!buffer->base_buffer && buffer->own_text.intervals) | 2886 | if (!buffer->base_buffer && buffer->own_text.intervals) |
| 2927 | dump_remember_fixup_ptr_raw ( | 2887 | dump_remember_fixup_ptr_raw |
| 2928 | ctx, | 2888 | (ctx, |
| 2929 | offset + dump_offsetof (struct buffer, own_text.intervals), | 2889 | offset + dump_offsetof (struct buffer, own_text.intervals), |
| 2930 | dump_interval_tree (ctx, buffer->own_text.intervals, 0)); | 2890 | dump_interval_tree (ctx, buffer->own_text.intervals, 0)); |
| 2931 | 2891 | ||
| 2932 | return offset; | 2892 | return offset; |
| 2933 | } | 2893 | } |
| @@ -3003,8 +2963,8 @@ dump_vectorlike (struct dump_context *ctx, | |||
| 3003 | harmless data carriers that we can dump like other Lisp | 2963 | harmless data carriers that we can dump like other Lisp |
| 3004 | objects. Fonts themselves are window-system-specific and | 2964 | objects. Fonts themselves are window-system-specific and |
| 3005 | need to be recreated on each startup. */ | 2965 | need to be recreated on each startup. */ |
| 3006 | if ((v->header.size & PSEUDOVECTOR_SIZE_MASK) != FONT_SPEC_MAX && | 2966 | if ((v->header.size & PSEUDOVECTOR_SIZE_MASK) != FONT_SPEC_MAX |
| 3007 | (v->header.size & PSEUDOVECTOR_SIZE_MASK) != FONT_ENTITY_MAX) | 2967 | && (v->header.size & PSEUDOVECTOR_SIZE_MASK) != FONT_ENTITY_MAX) |
| 3008 | error_unsupported_dump_object(ctx, lv, "font"); | 2968 | error_unsupported_dump_object(ctx, lv, "font"); |
| 3009 | FALLTHROUGH; | 2969 | FALLTHROUGH; |
| 3010 | case PVEC_NORMAL_VECTOR: | 2970 | case PVEC_NORMAL_VECTOR: |
| @@ -3118,8 +3078,8 @@ dump_object (struct dump_context *ctx, Lisp_Object object) | |||
| 3118 | { | 3078 | { |
| 3119 | if (offset != DUMP_OBJECT_ON_COLD_QUEUE) | 3079 | if (offset != DUMP_OBJECT_ON_COLD_QUEUE) |
| 3120 | { | 3080 | { |
| 3121 | eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE || | 3081 | eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE |
| 3122 | offset == DUMP_OBJECT_NOT_SEEN); | 3082 | || offset == DUMP_OBJECT_NOT_SEEN); |
| 3123 | offset = DUMP_OBJECT_ON_COLD_QUEUE; | 3083 | offset = DUMP_OBJECT_ON_COLD_QUEUE; |
| 3124 | dump_remember_object (ctx, object, offset); | 3084 | dump_remember_object (ctx, object, offset); |
| 3125 | dump_remember_cold_op (ctx, COLD_OP_OBJECT, object); | 3085 | dump_remember_cold_op (ctx, COLD_OP_OBJECT, object); |
| @@ -3127,13 +3087,13 @@ dump_object (struct dump_context *ctx, Lisp_Object object) | |||
| 3127 | return offset; | 3087 | return offset; |
| 3128 | } | 3088 | } |
| 3129 | 3089 | ||
| 3130 | void* obj_in_emacs = dump_object_emacs_ptr (object); | 3090 | void *obj_in_emacs = dump_object_emacs_ptr (object); |
| 3131 | if (obj_in_emacs && ctx->flags.defer_copied_objects) | 3091 | if (obj_in_emacs && ctx->flags.defer_copied_objects) |
| 3132 | { | 3092 | { |
| 3133 | if (offset != DUMP_OBJECT_ON_COPIED_QUEUE) | 3093 | if (offset != DUMP_OBJECT_ON_COPIED_QUEUE) |
| 3134 | { | 3094 | { |
| 3135 | eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE || | 3095 | eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE |
| 3136 | offset == DUMP_OBJECT_NOT_SEEN); | 3096 | || offset == DUMP_OBJECT_NOT_SEEN); |
| 3137 | /* Even though we're not going to dump this object right | 3097 | /* Even though we're not going to dump this object right |
| 3138 | away, we still want to scan and enqueue its | 3098 | away, we still want to scan and enqueue its |
| 3139 | referents. */ | 3099 | referents. */ |
| @@ -3265,10 +3225,10 @@ dump_finalizer_list_head_ptr (struct dump_context *ctx, | |||
| 3265 | { | 3225 | { |
| 3266 | struct Lisp_Finalizer *value = *ptr; | 3226 | struct Lisp_Finalizer *value = *ptr; |
| 3267 | if (value != &finalizers && value != &doomed_finalizers) | 3227 | if (value != &finalizers && value != &doomed_finalizers) |
| 3268 | dump_emacs_reloc_to_dump_ptr_raw ( | 3228 | dump_emacs_reloc_to_dump_ptr_raw |
| 3269 | ctx, ptr, | 3229 | (ctx, ptr, |
| 3270 | dump_object_for_offset (ctx, | 3230 | dump_object_for_offset (ctx, |
| 3271 | make_lisp_ptr (value, Lisp_Vectorlike))); | 3231 | make_lisp_ptr (value, Lisp_Vectorlike))); |
| 3272 | } | 3232 | } |
| 3273 | 3233 | ||
| 3274 | static void | 3234 | static void |
| @@ -3280,19 +3240,13 @@ dump_metadata_for_pdumper (struct dump_context *ctx) | |||
| 3280 | 3240 | ||
| 3281 | for (int i = 0; i < nr_remembered_data; ++i) | 3241 | for (int i = 0; i < nr_remembered_data; ++i) |
| 3282 | { | 3242 | { |
| 3283 | dump_emacs_reloc_to_emacs_ptr_raw ( | 3243 | dump_emacs_reloc_to_emacs_ptr_raw (ctx, &remembered_data[i].mem, |
| 3284 | ctx, | 3244 | remembered_data[i].mem); |
| 3285 | &remembered_data[i].mem, | 3245 | dump_emacs_reloc_immediate_int (ctx, &remembered_data[i].sz, |
| 3286 | remembered_data[i].mem); | 3246 | remembered_data[i].sz); |
| 3287 | dump_emacs_reloc_immediate_int ( | ||
| 3288 | ctx, | ||
| 3289 | &remembered_data[i].sz, | ||
| 3290 | remembered_data[i].sz); | ||
| 3291 | } | 3247 | } |
| 3292 | dump_emacs_reloc_immediate_int ( | 3248 | dump_emacs_reloc_immediate_int (ctx, &nr_remembered_data, |
| 3293 | ctx, | 3249 | nr_remembered_data); |
| 3294 | &nr_remembered_data, | ||
| 3295 | nr_remembered_data); | ||
| 3296 | } | 3250 | } |
| 3297 | 3251 | ||
| 3298 | /* Sort the list of copied objects in CTX. */ | 3252 | /* Sort the list of copied objects in CTX. */ |
| @@ -3380,10 +3334,10 @@ dump_cold_string (struct dump_context *ctx, Lisp_Object string) | |||
| 3380 | error ("string too large"); | 3334 | error ("string too large"); |
| 3381 | dump_off total_size = ptrdiff_t_to_dump_off (SBYTES (string) + 1); | 3335 | dump_off total_size = ptrdiff_t_to_dump_off (SBYTES (string) + 1); |
| 3382 | eassert (total_size > 0); | 3336 | eassert (total_size > 0); |
| 3383 | dump_remember_fixup_ptr_raw ( | 3337 | dump_remember_fixup_ptr_raw |
| 3384 | ctx, | 3338 | (ctx, |
| 3385 | string_offset + dump_offsetof (struct Lisp_String, u.s.data), | 3339 | string_offset + dump_offsetof (struct Lisp_String, u.s.data), |
| 3386 | ctx->offset); | 3340 | ctx->offset); |
| 3387 | dump_write (ctx, XSTRING (string)->u.s.data, total_size); | 3341 | dump_write (ctx, XSTRING (string)->u.s.data, total_size); |
| 3388 | } | 3342 | } |
| 3389 | 3343 | ||
| @@ -3395,10 +3349,10 @@ dump_cold_charset (struct dump_context *ctx, Lisp_Object data) | |||
| 3395 | int cs_i = XFIXNUM (XCAR (data)); | 3349 | int cs_i = XFIXNUM (XCAR (data)); |
| 3396 | DISALLOW_IMPLICIT_CONVERSION; | 3350 | DISALLOW_IMPLICIT_CONVERSION; |
| 3397 | dump_off cs_dump_offset = dump_off_from_lisp (XCDR (data)); | 3351 | dump_off cs_dump_offset = dump_off_from_lisp (XCDR (data)); |
| 3398 | dump_remember_fixup_ptr_raw ( | 3352 | dump_remember_fixup_ptr_raw |
| 3399 | ctx, | 3353 | (ctx, |
| 3400 | cs_dump_offset + dump_offsetof (struct charset, code_space_mask), | 3354 | cs_dump_offset + dump_offsetof (struct charset, code_space_mask), |
| 3401 | ctx->offset); | 3355 | ctx->offset); |
| 3402 | struct charset *cs = charset_table + cs_i; | 3356 | struct charset *cs = charset_table + cs_i; |
| 3403 | dump_write (ctx, cs->code_space_mask, 256); | 3357 | dump_write (ctx, cs->code_space_mask, 256); |
| 3404 | } | 3358 | } |
| @@ -3421,10 +3375,10 @@ dump_cold_buffer (struct dump_context *ctx, Lisp_Object data) | |||
| 3421 | + 1; | 3375 | + 1; |
| 3422 | if (nbytes > DUMP_OFF_MAX) | 3376 | if (nbytes > DUMP_OFF_MAX) |
| 3423 | error ("buffer too large"); | 3377 | error ("buffer too large"); |
| 3424 | dump_remember_fixup_ptr_raw ( | 3378 | dump_remember_fixup_ptr_raw |
| 3425 | ctx, | 3379 | (ctx, |
| 3426 | buffer_offset + dump_offsetof (struct buffer, own_text.beg), | 3380 | buffer_offset + dump_offsetof (struct buffer, own_text.beg), |
| 3427 | ctx->offset); | 3381 | ctx->offset); |
| 3428 | dump_write (ctx, b->own_text.beg, ptrdiff_t_to_dump_off (nbytes)); | 3382 | dump_write (ctx, b->own_text.beg, ptrdiff_t_to_dump_off (nbytes)); |
| 3429 | } | 3383 | } |
| 3430 | 3384 | ||
| @@ -3436,10 +3390,10 @@ dump_cold_bignum (struct dump_context *ctx, Lisp_Object object) | |||
| 3436 | eassert (sz_nlimbs < DUMP_OFF_MAX); | 3390 | eassert (sz_nlimbs < DUMP_OFF_MAX); |
| 3437 | dump_align_output (ctx, alignof (mp_limb_t)); | 3391 | dump_align_output (ctx, alignof (mp_limb_t)); |
| 3438 | dump_off nlimbs = (dump_off) sz_nlimbs; | 3392 | dump_off nlimbs = (dump_off) sz_nlimbs; |
| 3439 | Lisp_Object descriptor = list2 ( | 3393 | Lisp_Object descriptor |
| 3440 | dump_off_to_lisp (ctx->offset), | 3394 | = list2 (dump_off_to_lisp (ctx->offset), |
| 3441 | dump_off_to_lisp ((mpz_sgn (bignum->value) < 0 | 3395 | dump_off_to_lisp ((mpz_sgn (bignum->value) < 0 |
| 3442 | ? -nlimbs : nlimbs))); | 3396 | ? -nlimbs : nlimbs))); |
| 3443 | Fputhash (object, descriptor, ctx->bignum_data); | 3397 | Fputhash (object, descriptor, ctx->bignum_data); |
| 3444 | for (mp_size_t i = 0; i < nlimbs; ++i) | 3398 | for (mp_size_t i = 0; i < nlimbs; ++i) |
| 3445 | { | 3399 | { |
| @@ -3608,8 +3562,8 @@ dump_drain_user_remembered_data_cold (struct dump_context *ctx) | |||
| 3608 | Lisp_Subr structures always live in Emacs, not | 3562 | Lisp_Subr structures always live in Emacs, not |
| 3609 | the dump. | 3563 | the dump. |
| 3610 | */ | 3564 | */ |
| 3611 | dump_emacs_reloc_to_emacs_ptr_raw ( | 3565 | dump_emacs_reloc_to_emacs_ptr_raw |
| 3612 | ctx, mem, dump_object_emacs_ptr (lv)); | 3566 | (ctx, mem, dump_object_emacs_ptr (lv)); |
| 3613 | } | 3567 | } |
| 3614 | else | 3568 | else |
| 3615 | { | 3569 | { |
| @@ -3650,16 +3604,15 @@ dump_check_dump_off (struct dump_context *ctx, dump_off dump_offset) | |||
| 3650 | static void | 3604 | static void |
| 3651 | dump_check_emacs_off (dump_off emacs_off) | 3605 | dump_check_emacs_off (dump_off emacs_off) |
| 3652 | { | 3606 | { |
| 3653 | eassert (labs (emacs_off) <= 60*1024*1024); | 3607 | eassert (labs (emacs_off) <= 60 * 1024 * 1024); |
| 3654 | } | 3608 | } |
| 3655 | 3609 | ||
| 3656 | static struct dump_reloc | 3610 | static struct dump_reloc |
| 3657 | dump_decode_dump_reloc (Lisp_Object lreloc) | 3611 | dump_decode_dump_reloc (Lisp_Object lreloc) |
| 3658 | { | 3612 | { |
| 3659 | struct dump_reloc reloc; | 3613 | struct dump_reloc reloc; |
| 3660 | dump_reloc_set_type ( | 3614 | dump_reloc_set_type (&reloc, |
| 3661 | &reloc, | 3615 | (enum dump_reloc_type) XFIXNUM (dump_pop (&lreloc))); |
| 3662 | (enum dump_reloc_type) XFIXNUM (dump_pop (&lreloc))); | ||
| 3663 | eassert (reloc.type <= RELOC_DUMP_TO_EMACS_LV + Lisp_Float); | 3616 | eassert (reloc.type <= RELOC_DUMP_TO_EMACS_LV + Lisp_Float); |
| 3664 | dump_reloc_set_offset (&reloc, dump_off_from_lisp (dump_pop (&lreloc))); | 3617 | dump_reloc_set_offset (&reloc, dump_off_from_lisp (dump_pop (&lreloc))); |
| 3665 | eassert (NILP (lreloc)); | 3618 | eassert (NILP (lreloc)); |
| @@ -3688,8 +3641,7 @@ dump_check_overlap_dump_reloc (Lisp_Object lreloc_a, | |||
| 3688 | { | 3641 | { |
| 3689 | struct dump_reloc reloc_a = dump_decode_dump_reloc (lreloc_a); | 3642 | struct dump_reloc reloc_a = dump_decode_dump_reloc (lreloc_a); |
| 3690 | struct dump_reloc reloc_b = dump_decode_dump_reloc (lreloc_b); | 3643 | struct dump_reloc reloc_b = dump_decode_dump_reloc (lreloc_b); |
| 3691 | eassert (dump_reloc_get_offset (reloc_a) < | 3644 | eassert (dump_reloc_get_offset (reloc_a) < dump_reloc_get_offset (reloc_b)); |
| 3692 | dump_reloc_get_offset (reloc_b)); | ||
| 3693 | return Qnil; | 3645 | return Qnil; |
| 3694 | } | 3646 | } |
| 3695 | #endif | 3647 | #endif |
| @@ -3816,8 +3768,8 @@ dump_merge_emacs_relocs (Lisp_Object lreloc_a, Lisp_Object lreloc_b) | |||
| 3816 | } | 3768 | } |
| 3817 | #endif | 3769 | #endif |
| 3818 | 3770 | ||
| 3819 | if (XFIXNUM (XCAR (lreloc_a)) != RELOC_EMACS_COPY_FROM_DUMP || | 3771 | if (XFIXNUM (XCAR (lreloc_a)) != RELOC_EMACS_COPY_FROM_DUMP |
| 3820 | XFIXNUM (XCAR (lreloc_b)) != RELOC_EMACS_COPY_FROM_DUMP) | 3772 | || XFIXNUM (XCAR (lreloc_b)) != RELOC_EMACS_COPY_FROM_DUMP) |
| 3821 | return Qnil; | 3773 | return Qnil; |
| 3822 | 3774 | ||
| 3823 | struct emacs_reloc reloc_a = decode_emacs_reloc (NULL, lreloc_a); | 3775 | struct emacs_reloc reloc_a = decode_emacs_reloc (NULL, lreloc_a); |
| @@ -3868,9 +3820,9 @@ drain_reloc_list (struct dump_context *ctx, | |||
| 3868 | { | 3820 | { |
| 3869 | Lisp_Object reloc = dump_pop (&relocs); | 3821 | Lisp_Object reloc = dump_pop (&relocs); |
| 3870 | Lisp_Object merged; | 3822 | Lisp_Object merged; |
| 3871 | while (merger != NULL && | 3823 | while (merger != NULL |
| 3872 | !NILP (relocs) && | 3824 | && !NILP (relocs) |
| 3873 | ((merged = merger (reloc, XCAR (relocs))), !NILP (merged))) | 3825 | && (merged = merger (reloc, XCAR (relocs)), !NILP (merged))) |
| 3874 | { | 3826 | { |
| 3875 | reloc = merged; | 3827 | reloc = merged; |
| 3876 | relocs = XCDR (relocs); | 3828 | relocs = XCDR (relocs); |
| @@ -3895,7 +3847,7 @@ dump_do_fixup (struct dump_context *ctx, | |||
| 3895 | dump_off prev_dump_fixup_offset = | 3847 | dump_off prev_dump_fixup_offset = |
| 3896 | dump_off_from_lisp (XCAR (XCDR (prev_fixup))); | 3848 | dump_off_from_lisp (XCAR (XCDR (prev_fixup))); |
| 3897 | eassert (dump_fixup_offset - prev_dump_fixup_offset | 3849 | eassert (dump_fixup_offset - prev_dump_fixup_offset |
| 3898 | >= sizeof (void*)); | 3850 | >= sizeof (void *)); |
| 3899 | } | 3851 | } |
| 3900 | #endif | 3852 | #endif |
| 3901 | Lisp_Object arg = dump_pop (&fixup); | 3853 | Lisp_Object arg = dump_pop (&fixup); |
| @@ -4053,10 +4005,12 @@ types. */) | |||
| 4053 | error ("No other Lisp threads can be running when this function is called"); | 4005 | error ("No other Lisp threads can be running when this function is called"); |
| 4054 | 4006 | ||
| 4055 | /* Clear out any detritus in memory. */ | 4007 | /* Clear out any detritus in memory. */ |
| 4056 | do { | 4008 | do |
| 4057 | number_finalizers_run = 0; | 4009 | { |
| 4058 | garbage_collect (); | 4010 | number_finalizers_run = 0; |
| 4059 | } while (number_finalizers_run); | 4011 | garbage_collect (); |
| 4012 | } | ||
| 4013 | while (number_finalizers_run); | ||
| 4060 | 4014 | ||
| 4061 | ptrdiff_t count = SPECPDL_INDEX (); | 4015 | ptrdiff_t count = SPECPDL_INDEX (); |
| 4062 | 4016 | ||
| @@ -4166,13 +4120,15 @@ types. */) | |||
| 4166 | objects to the queue by side effect during dumping. | 4120 | objects to the queue by side effect during dumping. |
| 4167 | We accumulate some types of objects in special lists to get more | 4121 | We accumulate some types of objects in special lists to get more |
| 4168 | locality for these object types at runtime. */ | 4122 | locality for these object types at runtime. */ |
| 4169 | do { | 4123 | do |
| 4170 | dump_drain_deferred_hash_tables (ctx); | 4124 | { |
| 4171 | dump_drain_deferred_symbols (ctx); | 4125 | dump_drain_deferred_hash_tables (ctx); |
| 4172 | dump_drain_normal_queue (ctx); | 4126 | dump_drain_deferred_symbols (ctx); |
| 4173 | } while (!dump_queue_empty_p (&ctx->dump_queue) || | 4127 | dump_drain_normal_queue (ctx); |
| 4174 | !NILP (ctx->deferred_hash_tables) || | 4128 | } |
| 4175 | !NILP (ctx->deferred_symbols)); | 4129 | while (!dump_queue_empty_p (&ctx->dump_queue) |
| 4130 | || !NILP (ctx->deferred_hash_tables) | ||
| 4131 | || !NILP (ctx->deferred_symbols)); | ||
| 4176 | 4132 | ||
| 4177 | dump_sort_copied_objects (ctx); | 4133 | dump_sort_copied_objects (ctx); |
| 4178 | 4134 | ||
| @@ -4231,27 +4187,16 @@ types. */) | |||
| 4231 | /* Emit instructions for Emacs to execute when loading the dump. | 4187 | /* Emit instructions for Emacs to execute when loading the dump. |
| 4232 | Note that this relocation information ends up in the cold section | 4188 | Note that this relocation information ends up in the cold section |
| 4233 | of the dump. */ | 4189 | of the dump. */ |
| 4234 | drain_reloc_list ( | 4190 | drain_reloc_list (ctx, dump_emit_dump_reloc, emacs_reloc_merger, |
| 4235 | ctx, | 4191 | &ctx->dump_relocs, &ctx->header.dump_relocs); |
| 4236 | dump_emit_dump_reloc, | ||
| 4237 | emacs_reloc_merger, | ||
| 4238 | &ctx->dump_relocs, | ||
| 4239 | &ctx->header.dump_relocs); | ||
| 4240 | unsigned number_hot_relocations = ctx->number_hot_relocations; | 4192 | unsigned number_hot_relocations = ctx->number_hot_relocations; |
| 4241 | ctx->number_hot_relocations = 0; | 4193 | ctx->number_hot_relocations = 0; |
| 4242 | unsigned number_discardable_relocations = ctx->number_discardable_relocations; | 4194 | unsigned number_discardable_relocations = ctx->number_discardable_relocations; |
| 4243 | ctx->number_discardable_relocations = 0; | 4195 | ctx->number_discardable_relocations = 0; |
| 4244 | drain_reloc_list ( | 4196 | drain_reloc_list (ctx, dump_emit_dump_reloc, emacs_reloc_merger, |
| 4245 | ctx, | 4197 | &ctx->object_starts, &ctx->header.object_starts); |
| 4246 | dump_emit_dump_reloc, | 4198 | drain_reloc_list (ctx, dump_emit_emacs_reloc, dump_merge_emacs_relocs, |
| 4247 | emacs_reloc_merger, | 4199 | &ctx->emacs_relocs, &ctx->header.emacs_relocs); |
| 4248 | &ctx->object_starts, | ||
| 4249 | &ctx->header.object_starts); | ||
| 4250 | drain_reloc_list ( | ||
| 4251 | ctx, dump_emit_emacs_reloc, | ||
| 4252 | dump_merge_emacs_relocs, | ||
| 4253 | &ctx->emacs_relocs, | ||
| 4254 | &ctx->header.emacs_relocs); | ||
| 4255 | 4200 | ||
| 4256 | const dump_off cold_end = ctx->offset; | 4201 | const dump_off cold_end = ctx->offset; |
| 4257 | 4202 | ||
| @@ -4337,14 +4282,15 @@ pdumper_remember_scalar_impl (void *mem, ptrdiff_t nbytes) | |||
| 4337 | } | 4282 | } |
| 4338 | 4283 | ||
| 4339 | void | 4284 | void |
| 4340 | pdumper_remember_lv_ptr_raw_impl (void* ptr, enum Lisp_Type type) | 4285 | pdumper_remember_lv_ptr_raw_impl (void *ptr, enum Lisp_Type type) |
| 4341 | { | 4286 | { |
| 4342 | pdumper_remember_user_data_1 (ptr, -type); | 4287 | pdumper_remember_user_data_1 (ptr, -type); |
| 4343 | } | 4288 | } |
| 4344 | 4289 | ||
| 4345 | 4290 | ||
| 4346 | /* Dump runtime */ | 4291 | /* Dump runtime */ |
| 4347 | enum dump_memory_protection { | 4292 | enum dump_memory_protection |
| 4293 | { | ||
| 4348 | DUMP_MEMORY_ACCESS_NONE = 1, | 4294 | DUMP_MEMORY_ACCESS_NONE = 1, |
| 4349 | DUMP_MEMORY_ACCESS_READ = 2, | 4295 | DUMP_MEMORY_ACCESS_READ = 2, |
| 4350 | DUMP_MEMORY_ACCESS_READWRITE = 3, | 4296 | DUMP_MEMORY_ACCESS_READWRITE = 3, |
| @@ -4438,9 +4384,9 @@ dump_anonymous_allocate_posix (void *base, | |||
| 4438 | { | 4384 | { |
| 4439 | retry = false; | 4385 | retry = false; |
| 4440 | ret = mmap (base, size, mem_prot, mem_flags, -1, 0); | 4386 | ret = mmap (base, size, mem_prot, mem_flags, -1, 0); |
| 4441 | if (ret == MAP_FAILED && | 4387 | if (ret == MAP_FAILED |
| 4442 | errno == EINVAL && | 4388 | && errno == EINVAL |
| 4443 | (mem_flags & MAP_POPULATE)) | 4389 | && (mem_flags & MAP_POPULATE)) |
| 4444 | { | 4390 | { |
| 4445 | /* This system didn't understand MAP_POPULATE, so try | 4391 | /* This system didn't understand MAP_POPULATE, so try |
| 4446 | again without it. */ | 4392 | again without it. */ |
| @@ -4492,12 +4438,8 @@ dump_anonymous_release (void *addr, size_t size) | |||
| 4492 | } | 4438 | } |
| 4493 | 4439 | ||
| 4494 | static void * | 4440 | static void * |
| 4495 | dump_map_file_w32 ( | 4441 | dump_map_file_w32 (void *base, int fd, off_t offset, size_t size, |
| 4496 | void *base, | 4442 | enum dump_memory_protection protection) |
| 4497 | int fd, | ||
| 4498 | off_t offset, | ||
| 4499 | size_t size, | ||
| 4500 | enum dump_memory_protection protection) | ||
| 4501 | { | 4443 | { |
| 4502 | #if VM_SUPPORTED != VM_MS_WINDOWS | 4444 | #if VM_SUPPORTED != VM_MS_WINDOWS |
| 4503 | (void) base; | 4445 | (void) base; |
| @@ -4522,13 +4464,12 @@ dump_map_file_w32 ( | |||
| 4522 | if (file == INVALID_HANDLE_VALUE) | 4464 | if (file == INVALID_HANDLE_VALUE) |
| 4523 | goto out; | 4465 | goto out; |
| 4524 | 4466 | ||
| 4525 | section = CreateFileMapping ( | 4467 | section = CreateFileMapping (file, |
| 4526 | file, | 4468 | /*lpAttributes=*/NULL, |
| 4527 | /*lpAttributes=*/NULL, | 4469 | PAGE_READONLY, |
| 4528 | PAGE_READONLY, | 4470 | /*dwMaximumSizeHigh=*/0, |
| 4529 | /*dwMaximumSizeHigh=*/0, | 4471 | /*dwMaximumSizeLow=*/0, |
| 4530 | /*dwMaximumSizeLow=*/0, | 4472 | /*lpName=*/NULL); |
| 4531 | /*lpName=*/NULL); | ||
| 4532 | if (!section) | 4473 | if (!section) |
| 4533 | { | 4474 | { |
| 4534 | errno = EINVAL; | 4475 | errno = EINVAL; |
| @@ -4566,12 +4507,8 @@ dump_map_file_w32 ( | |||
| 4566 | } | 4507 | } |
| 4567 | 4508 | ||
| 4568 | static void * | 4509 | static void * |
| 4569 | dump_map_file_posix ( | 4510 | dump_map_file_posix (void *base, int fd, off_t offset, size_t size, |
| 4570 | void *base, | 4511 | enum dump_memory_protection protection) |
| 4571 | int fd, | ||
| 4572 | off_t offset, | ||
| 4573 | size_t size, | ||
| 4574 | enum dump_memory_protection protection) | ||
| 4575 | { | 4512 | { |
| 4576 | #if VM_SUPPORTED != VM_POSIX | 4513 | #if VM_SUPPORTED != VM_POSIX |
| 4577 | (void) base; | 4514 | (void) base; |
| @@ -4615,12 +4552,8 @@ dump_map_file_posix ( | |||
| 4615 | 4552 | ||
| 4616 | /* Map a file into memory. */ | 4553 | /* Map a file into memory. */ |
| 4617 | static void * | 4554 | static void * |
| 4618 | dump_map_file ( | 4555 | dump_map_file (void *base, int fd, off_t offset, size_t size, |
| 4619 | void *base, | 4556 | enum dump_memory_protection protection) |
| 4620 | int fd, | ||
| 4621 | off_t offset, | ||
| 4622 | size_t size, | ||
| 4623 | enum dump_memory_protection protection) | ||
| 4624 | { | 4557 | { |
| 4625 | void *ret = NULL; | 4558 | void *ret = NULL; |
| 4626 | if (VM_SUPPORTED == VM_MS_WINDOWS) | 4559 | if (VM_SUPPORTED == VM_MS_WINDOWS) |
| @@ -4662,7 +4595,8 @@ struct dump_memory_map_spec | |||
| 4662 | enum dump_memory_protection protection; | 4595 | enum dump_memory_protection protection; |
| 4663 | }; | 4596 | }; |
| 4664 | 4597 | ||
| 4665 | struct dump_memory_map { | 4598 | struct dump_memory_map |
| 4599 | { | ||
| 4666 | struct dump_memory_map_spec spec; | 4600 | struct dump_memory_map_spec spec; |
| 4667 | void *mapping; /* Actual mapped memory. */ | 4601 | void *mapping; /* Actual mapped memory. */ |
| 4668 | void (*release)(struct dump_memory_map *); | 4602 | void (*release)(struct dump_memory_map *); |
| @@ -4715,7 +4649,8 @@ dump_mmap_release (struct dump_memory_map *map) | |||
| 4715 | } | 4649 | } |
| 4716 | 4650 | ||
| 4717 | /* Allows heap-allocated dump_mmap to "free" maps individually. */ | 4651 | /* Allows heap-allocated dump_mmap to "free" maps individually. */ |
| 4718 | struct dump_memory_map_heap_control_block { | 4652 | struct dump_memory_map_heap_control_block |
| 4653 | { | ||
| 4719 | int refcount; | 4654 | int refcount; |
| 4720 | void *mem; | 4655 | void *mem; |
| 4721 | }; | 4656 | }; |
| @@ -4736,10 +4671,8 @@ dump_mmap_release_heap (struct dump_memory_map *map) | |||
| 4736 | 4671 | ||
| 4737 | /* Implement dump_mmap using malloc and read. */ | 4672 | /* Implement dump_mmap using malloc and read. */ |
| 4738 | static bool | 4673 | static bool |
| 4739 | dump_mmap_contiguous_heap ( | 4674 | dump_mmap_contiguous_heap (struct dump_memory_map *maps, int nr_maps, |
| 4740 | struct dump_memory_map *maps, | 4675 | size_t total_size) |
| 4741 | int nr_maps, | ||
| 4742 | size_t total_size) | ||
| 4743 | { | 4676 | { |
| 4744 | bool ret = false; | 4677 | bool ret = false; |
| 4745 | struct dump_memory_map_heap_control_block *cb = calloc (1, sizeof (*cb)); | 4678 | struct dump_memory_map_heap_control_block *cb = calloc (1, sizeof (*cb)); |
| @@ -4807,10 +4740,8 @@ needs_mmap_retry_p (void) | |||
| 4807 | } | 4740 | } |
| 4808 | 4741 | ||
| 4809 | static bool | 4742 | static bool |
| 4810 | dump_mmap_contiguous_vm ( | 4743 | dump_mmap_contiguous_vm (struct dump_memory_map *maps, int nr_maps, |
| 4811 | struct dump_memory_map *maps, | 4744 | size_t total_size) |
| 4812 | int nr_maps, | ||
| 4813 | size_t total_size) | ||
| 4814 | { | 4745 | { |
| 4815 | bool ret = false; | 4746 | bool ret = false; |
| 4816 | void *resv = NULL; | 4747 | void *resv = NULL; |
| @@ -4855,19 +4786,18 @@ dump_mmap_contiguous_vm ( | |||
| 4855 | continue; | 4786 | continue; |
| 4856 | 4787 | ||
| 4857 | if (spec.fd < 0) | 4788 | if (spec.fd < 0) |
| 4858 | map->mapping = dump_anonymous_allocate ( | 4789 | map->mapping = dump_anonymous_allocate (mem, spec.size, |
| 4859 | mem, spec.size, spec.protection); | 4790 | spec.protection); |
| 4860 | else | 4791 | else |
| 4861 | map->mapping = dump_map_file ( | 4792 | map->mapping = dump_map_file (mem, spec.fd, spec.offset, |
| 4862 | mem, spec.fd, spec.offset, spec.size, spec.protection); | 4793 | spec.size, spec.protection); |
| 4863 | mem += spec.size; | 4794 | mem += spec.size; |
| 4864 | if (need_retry && | 4795 | if (need_retry && map->mapping == NULL |
| 4865 | map->mapping == NULL && | 4796 | && (errno == EBUSY |
| 4866 | (errno == EBUSY | ||
| 4867 | #ifdef CYGWIN | 4797 | #ifdef CYGWIN |
| 4868 | || errno == EINVAL | 4798 | || errno == EINVAL |
| 4869 | #endif | 4799 | #endif |
| 4870 | )) | 4800 | )) |
| 4871 | { | 4801 | { |
| 4872 | retry = true; | 4802 | retry = true; |
| 4873 | continue; | 4803 | continue; |
| @@ -4910,9 +4840,7 @@ dump_mmap_contiguous_vm ( | |||
| 4910 | 4840 | ||
| 4911 | Return true on success or false on failure with errno set. */ | 4841 | Return true on success or false on failure with errno set. */ |
| 4912 | static bool | 4842 | static bool |
| 4913 | dump_mmap_contiguous ( | 4843 | dump_mmap_contiguous (struct dump_memory_map *maps, int nr_maps) |
| 4914 | struct dump_memory_map *maps, | ||
| 4915 | int nr_maps) | ||
| 4916 | { | 4844 | { |
| 4917 | if (!nr_maps) | 4845 | if (!nr_maps) |
| 4918 | return true; | 4846 | return true; |
| @@ -4936,7 +4864,8 @@ dump_mmap_contiguous ( | |||
| 4936 | 4864 | ||
| 4937 | typedef uint_fast32_t dump_bitset_word; | 4865 | typedef uint_fast32_t dump_bitset_word; |
| 4938 | 4866 | ||
| 4939 | struct dump_bitset { | 4867 | struct dump_bitset |
| 4868 | { | ||
| 4940 | dump_bitset_word *restrict bits; | 4869 | dump_bitset_word *restrict bits; |
| 4941 | ptrdiff_t number_words; | 4870 | ptrdiff_t number_words; |
| 4942 | }; | 4871 | }; |
| @@ -4981,7 +4910,7 @@ dump_bitset__set_bit_value (struct dump_bitset *bitset, | |||
| 4981 | { | 4910 | { |
| 4982 | int xword_size = sizeof (bitset->bits[0]); | 4911 | int xword_size = sizeof (bitset->bits[0]); |
| 4983 | int bits_per_word = xword_size * CHAR_BIT; | 4912 | int bits_per_word = xword_size * CHAR_BIT; |
| 4984 | dump_bitset_word * slot = dump_bitset__bit_slot (bitset, bit_number); | 4913 | dump_bitset_word *slot = dump_bitset__bit_slot (bitset, bit_number); |
| 4985 | dump_bitset_word bit = 1; | 4914 | dump_bitset_word bit = 1; |
| 4986 | bit <<= bit_number % bits_per_word; | 4915 | bit <<= bit_number % bits_per_word; |
| 4987 | if (bit_is_set) | 4916 | if (bit_is_set) |
| @@ -5082,8 +5011,8 @@ static const struct dump_reloc * | |||
| 5082 | dump_find_relocation (const struct dump_table_locator *const table, | 5011 | dump_find_relocation (const struct dump_table_locator *const table, |
| 5083 | const dump_off key) | 5012 | const dump_off key) |
| 5084 | { | 5013 | { |
| 5085 | const struct dump_reloc *const relocs = dump_ptr ( | 5014 | const struct dump_reloc *const relocs = dump_ptr (dump_public.start, |
| 5086 | dump_public.start, table->offset); | 5015 | table->offset); |
| 5087 | const struct dump_reloc *found = NULL; | 5016 | const struct dump_reloc *found = NULL; |
| 5088 | ptrdiff_t idx_left = 0; | 5017 | ptrdiff_t idx_left = 0; |
| 5089 | ptrdiff_t idx_right = table->nr_entries; | 5018 | ptrdiff_t idx_right = table->nr_entries; |
| @@ -5100,8 +5029,8 @@ dump_find_relocation (const struct dump_table_locator *const table, | |||
| 5100 | { | 5029 | { |
| 5101 | found = mid; | 5030 | found = mid; |
| 5102 | idx_right = idx_mid; | 5031 | idx_right = idx_mid; |
| 5103 | if (idx_right <= idx_left || | 5032 | if (idx_right <= idx_left |
| 5104 | key > dump_reloc_get_offset (relocs[idx_right - 1])) | 5033 | || key > dump_reloc_get_offset (relocs[idx_right - 1])) |
| 5105 | break; | 5034 | break; |
| 5106 | } | 5035 | } |
| 5107 | } | 5036 | } |
| @@ -5120,8 +5049,7 @@ pdumper_cold_object_p_impl (const void *obj) | |||
| 5120 | { | 5049 | { |
| 5121 | eassert (pdumper_object_p (obj)); | 5050 | eassert (pdumper_object_p (obj)); |
| 5122 | eassert (pdumper_object_p_precise (obj)); | 5051 | eassert (pdumper_object_p_precise (obj)); |
| 5123 | dump_off offset = ptrdiff_t_to_dump_off ( | 5052 | dump_off offset = ptrdiff_t_to_dump_off ((uintptr_t) obj - dump_public.start); |
| 5124 | (uintptr_t) obj - dump_public.start); | ||
| 5125 | return offset >= dump_private.header.cold_start; | 5053 | return offset >= dump_private.header.cold_start; |
| 5126 | } | 5054 | } |
| 5127 | 5055 | ||
| @@ -5129,8 +5057,7 @@ enum Lisp_Type | |||
| 5129 | pdumper_find_object_type_impl (const void *obj) | 5057 | pdumper_find_object_type_impl (const void *obj) |
| 5130 | { | 5058 | { |
| 5131 | eassert (pdumper_object_p (obj)); | 5059 | eassert (pdumper_object_p (obj)); |
| 5132 | dump_off offset = ptrdiff_t_to_dump_off ( | 5060 | dump_off offset = ptrdiff_t_to_dump_off ((uintptr_t) obj - dump_public.start); |
| 5133 | (uintptr_t) obj - dump_public.start); | ||
| 5134 | if (offset % DUMP_ALIGNMENT != 0) | 5061 | if (offset % DUMP_ALIGNMENT != 0) |
| 5135 | return PDUMPER_NO_OBJECT; | 5062 | return PDUMPER_NO_OBJECT; |
| 5136 | const struct dump_reloc *reloc = | 5063 | const struct dump_reloc *reloc = |
| @@ -5182,9 +5109,8 @@ dump_read_all (int fd, void *buf, size_t bytes_to_read) | |||
| 5182 | /* Some platforms accept only int-sized values to read. */ | 5109 | /* Some platforms accept only int-sized values to read. */ |
| 5183 | unsigned chunk_to_read = INT_MAX; | 5110 | unsigned chunk_to_read = INT_MAX; |
| 5184 | if (bytes_to_read - bytes_read < chunk_to_read) | 5111 | if (bytes_to_read - bytes_read < chunk_to_read) |
| 5185 | chunk_to_read = (unsigned)(bytes_to_read - bytes_read); | 5112 | chunk_to_read = (unsigned) (bytes_to_read - bytes_read); |
| 5186 | ssize_t chunk = | 5113 | ssize_t chunk = read (fd, (char *) buf + bytes_read, chunk_to_read); |
| 5187 | read (fd, (char*) buf + bytes_read, chunk_to_read); | ||
| 5188 | if (chunk < 0) | 5114 | if (chunk < 0) |
| 5189 | return chunk; | 5115 | return chunk; |
| 5190 | if (chunk == 0) | 5116 | if (chunk == 0) |
| @@ -5200,25 +5126,24 @@ dump_read_all (int fd, void *buf, size_t bytes_to_read) | |||
| 5200 | static int | 5126 | static int |
| 5201 | dump_reloc_size (const struct dump_reloc reloc) | 5127 | dump_reloc_size (const struct dump_reloc reloc) |
| 5202 | { | 5128 | { |
| 5203 | if (sizeof (Lisp_Object) == sizeof (void*)) | 5129 | if (sizeof (Lisp_Object) == sizeof (void *)) |
| 5204 | return sizeof (Lisp_Object); | 5130 | return sizeof (Lisp_Object); |
| 5205 | if (reloc.type == RELOC_DUMP_TO_EMACS_PTR_RAW || | 5131 | if (reloc.type == RELOC_DUMP_TO_EMACS_PTR_RAW |
| 5206 | reloc.type == RELOC_DUMP_TO_DUMP_PTR_RAW) | 5132 | || reloc.type == RELOC_DUMP_TO_DUMP_PTR_RAW) |
| 5207 | return sizeof (void*); | 5133 | return sizeof (void *); |
| 5208 | return sizeof (Lisp_Object); | 5134 | return sizeof (Lisp_Object); |
| 5209 | } | 5135 | } |
| 5210 | 5136 | ||
| 5211 | static Lisp_Object | 5137 | static Lisp_Object |
| 5212 | dump_make_lv_from_reloc ( | 5138 | dump_make_lv_from_reloc (const uintptr_t dump_base, |
| 5213 | const uintptr_t dump_base, | 5139 | const struct dump_reloc reloc) |
| 5214 | const struct dump_reloc reloc) | ||
| 5215 | { | 5140 | { |
| 5216 | const dump_off reloc_offset = dump_reloc_get_offset (reloc); | 5141 | const dump_off reloc_offset = dump_reloc_get_offset (reloc); |
| 5217 | uintptr_t value = dump_read_word_from_dump (dump_base, reloc_offset); | 5142 | uintptr_t value = dump_read_word_from_dump (dump_base, reloc_offset); |
| 5218 | enum Lisp_Type lisp_type; | 5143 | enum Lisp_Type lisp_type; |
| 5219 | 5144 | ||
| 5220 | if (RELOC_DUMP_TO_DUMP_LV <= reloc.type && | 5145 | if (RELOC_DUMP_TO_DUMP_LV <= reloc.type |
| 5221 | reloc.type < RELOC_DUMP_TO_EMACS_LV) | 5146 | && reloc.type < RELOC_DUMP_TO_EMACS_LV) |
| 5222 | { | 5147 | { |
| 5223 | lisp_type = reloc.type - RELOC_DUMP_TO_DUMP_LV; | 5148 | lisp_type = reloc.type - RELOC_DUMP_TO_DUMP_LV; |
| 5224 | value += dump_base; | 5149 | value += dump_base; |
| @@ -5245,9 +5170,8 @@ dump_make_lv_from_reloc ( | |||
| 5245 | 5170 | ||
| 5246 | /* Actually apply a dump relocation. */ | 5171 | /* Actually apply a dump relocation. */ |
| 5247 | static inline void | 5172 | static inline void |
| 5248 | dump_do_dump_relocation ( | 5173 | dump_do_dump_relocation (const uintptr_t dump_base, |
| 5249 | const uintptr_t dump_base, | 5174 | const struct dump_reloc reloc) |
| 5250 | const struct dump_reloc reloc) | ||
| 5251 | { | 5175 | { |
| 5252 | const dump_off reloc_offset = dump_reloc_get_offset (reloc); | 5176 | const dump_off reloc_offset = dump_reloc_get_offset (reloc); |
| 5253 | 5177 | ||
| @@ -5294,9 +5218,8 @@ dump_do_dump_relocation ( | |||
| 5294 | } | 5218 | } |
| 5295 | 5219 | ||
| 5296 | static void | 5220 | static void |
| 5297 | dump_do_all_dump_relocations ( | 5221 | dump_do_all_dump_relocations (const struct dump_header *const header, |
| 5298 | const struct dump_header *const header, | 5222 | const uintptr_t dump_base) |
| 5299 | const uintptr_t dump_base) | ||
| 5300 | { | 5223 | { |
| 5301 | struct dump_reloc *r = dump_ptr (dump_base, header->dump_relocs.offset); | 5224 | struct dump_reloc *r = dump_ptr (dump_base, header->dump_relocs.offset); |
| 5302 | dump_off nr_entries = header->dump_relocs.nr_entries; | 5225 | dump_off nr_entries = header->dump_relocs.nr_entries; |
| @@ -5305,9 +5228,8 @@ dump_do_all_dump_relocations ( | |||
| 5305 | } | 5228 | } |
| 5306 | 5229 | ||
| 5307 | static void | 5230 | static void |
| 5308 | dump_do_emacs_relocation ( | 5231 | dump_do_emacs_relocation (const uintptr_t dump_base, |
| 5309 | const uintptr_t dump_base, | 5232 | const struct emacs_reloc reloc) |
| 5310 | const struct emacs_reloc reloc) | ||
| 5311 | { | 5233 | { |
| 5312 | ptrdiff_t pval; | 5234 | ptrdiff_t pval; |
| 5313 | Lisp_Object lv; | 5235 | Lisp_Object lv; |
| @@ -5356,9 +5278,8 @@ dump_do_emacs_relocation ( | |||
| 5356 | } | 5278 | } |
| 5357 | 5279 | ||
| 5358 | static void | 5280 | static void |
| 5359 | dump_do_all_emacs_relocations ( | 5281 | dump_do_all_emacs_relocations (const struct dump_header *const header, |
| 5360 | const struct dump_header *const header, | 5282 | const uintptr_t dump_base) |
| 5361 | const uintptr_t dump_base) | ||
| 5362 | { | 5283 | { |
| 5363 | const dump_off nr_entries = header->emacs_relocs.nr_entries; | 5284 | const dump_off nr_entries = header->emacs_relocs.nr_entries; |
| 5364 | struct emacs_reloc *r = dump_ptr (dump_base, header->emacs_relocs.offset); | 5285 | struct emacs_reloc *r = dump_ptr (dump_base, header->emacs_relocs.offset); |
| @@ -5429,9 +5350,9 @@ pdumper_load (const char *dump_filename) | |||
| 5429 | 5350 | ||
| 5430 | if (memcmp (header->magic, dump_magic, sizeof (dump_magic)) != 0) | 5351 | if (memcmp (header->magic, dump_magic, sizeof (dump_magic)) != 0) |
| 5431 | { | 5352 | { |
| 5432 | if (header->magic[0] == '!' && | 5353 | if (header->magic[0] == '!' |
| 5433 | ((header->magic[0] = dump_magic[0]), | 5354 | && (header->magic[0] = dump_magic[0], |
| 5434 | memcmp (header->magic, dump_magic, sizeof (dump_magic)) == 0)) | 5355 | memcmp (header->magic, dump_magic, sizeof (dump_magic)) == 0)) |
| 5435 | { | 5356 | { |
| 5436 | err = PDUMPER_LOAD_FAILED_DUMP; | 5357 | err = PDUMPER_LOAD_FAILED_DUMP; |
| 5437 | goto out; | 5358 | goto out; |
| @@ -5459,9 +5380,7 @@ pdumper_load (const char *dump_filename) | |||
| 5459 | adj_discardable_start = header->discardable_start; | 5380 | adj_discardable_start = header->discardable_start; |
| 5460 | dump_page_size = dump_get_page_size (); | 5381 | dump_page_size = dump_get_page_size (); |
| 5461 | /* Snap to next page boundary. */ | 5382 | /* Snap to next page boundary. */ |
| 5462 | adj_discardable_start = ROUNDUP ( | 5383 | adj_discardable_start = ROUNDUP (adj_discardable_start, dump_page_size); |
| 5463 | adj_discardable_start, | ||
| 5464 | dump_page_size); | ||
| 5465 | eassert (adj_discardable_start % dump_page_size == 0); | 5384 | eassert (adj_discardable_start % dump_page_size == 0); |
| 5466 | eassert (adj_discardable_start <= header->cold_start); | 5385 | eassert (adj_discardable_start <= header->cold_start); |
| 5467 | 5386 | ||
diff --git a/src/pdumper.h b/src/pdumper.h index 7be8a8f8775..ab2f426c1e9 100644 --- a/src/pdumper.h +++ b/src/pdumper.h | |||
| @@ -63,14 +63,13 @@ pdumper_remember_scalar (void *data, ptrdiff_t nbytes) | |||
| 63 | #endif | 63 | #endif |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | extern void pdumper_remember_lv_ptr_raw_impl ( | 66 | extern void pdumper_remember_lv_ptr_raw_impl (void *ptr, enum Lisp_Type type); |
| 67 | void *ptr, enum Lisp_Type type); | ||
| 68 | 67 | ||
| 69 | /* Remember the pointer at *PTR. *PTR must be null or point to a Lisp | 68 | /* Remember the pointer at *PTR. *PTR must be null or point to a Lisp |
| 70 | object. TYPE is the rough type of Lisp object to which *PTR | 69 | object. TYPE is the rough type of Lisp object to which *PTR |
| 71 | points. */ | 70 | points. */ |
| 72 | INLINE void | 71 | INLINE void |
| 73 | pdumper_remember_lv_ptr_raw (void* ptr, enum Lisp_Type type) | 72 | pdumper_remember_lv_ptr_raw (void *ptr, enum Lisp_Type type) |
| 74 | { | 73 | { |
| 75 | #ifdef HAVE_PDUMPER | 74 | #ifdef HAVE_PDUMPER |
| 76 | pdumper_remember_lv_ptr_raw_impl (ptr, type); | 75 | pdumper_remember_lv_ptr_raw_impl (ptr, type); |
| @@ -130,7 +129,8 @@ enum pdumper_load_result | |||
| 130 | 129 | ||
| 131 | enum pdumper_load_result pdumper_load (const char *dump_filename); | 130 | enum pdumper_load_result pdumper_load (const char *dump_filename); |
| 132 | 131 | ||
| 133 | struct pdumper_loaded_dump { | 132 | struct pdumper_loaded_dump |
| 133 | { | ||
| 134 | uintptr_t start; | 134 | uintptr_t start; |
| 135 | uintptr_t end; | 135 | uintptr_t end; |
| 136 | }; | 136 | }; |