comparison src/extents.c @ 5118:e0db3c197671 ben-lisp-object

merge up to latest default branch, doesn't compile yet
author Ben Wing <ben@xemacs.org>
date Sat, 26 Dec 2009 21:18:49 -0600
parents 3742ea8250b5 229bd619740a
children d1247f3cc363
comparison
equal deleted inserted replaced
5117:3742ea8250b5 5118:e0db3c197671
240 /* Holds a marker that moves as elements in the array are inserted and 240 /* Holds a marker that moves as elements in the array are inserted and
241 deleted, similar to standard markers. */ 241 deleted, similar to standard markers. */
242 242
243 typedef struct gap_array_marker 243 typedef struct gap_array_marker
244 { 244 {
245 #ifdef NEW_GC
246 struct lrecord_header header;
247 #endif /* NEW_GC */
245 int pos; 248 int pos;
246 struct gap_array_marker *next; 249 struct gap_array_marker *next;
247 } Gap_Array_Marker; 250 } Gap_Array_Marker;
248 251
249 252
267 */ 270 */
268 271
269 272
270 typedef struct gap_array 273 typedef struct gap_array
271 { 274 {
275 #ifdef NEW_GC
276 struct lrecord_header header;
277 #endif /* NEW_GC */
272 Elemcount gap; 278 Elemcount gap;
273 Elemcount gapsize; 279 Elemcount gapsize;
274 Elemcount numels; 280 Elemcount numels;
275 Bytecount elsize; 281 Bytecount elsize;
276 /* Redundant numbers computed from the others, for marking purposes */ 282 /* Redundant numbers computed from the others, for marking purposes */
279 Gap_Array_Marker *markers; 285 Gap_Array_Marker *markers;
280 /* this is a stretchy array */ 286 /* this is a stretchy array */
281 char array[1]; 287 char array[1];
282 } Gap_Array; 288 } Gap_Array;
283 289
290 #ifndef NEW_GC
284 static Gap_Array_Marker *gap_array_marker_freelist; 291 static Gap_Array_Marker *gap_array_marker_freelist;
292 #endif /* not NEW_GC */
285 293
286 /* Convert a "memory position" (i.e. taking the gap into account) into 294 /* Convert a "memory position" (i.e. taking the gap into account) into
287 the address of the element at (i.e. after) that position. "Memory 295 the address of the element at (i.e. after) that position. "Memory
288 positions" are only used internally and are of type Memxpos. 296 positions" are only used internally and are of type Memxpos.
289 "Array positions" are used externally and are of type int. */ 297 "Array positions" are used externally and are of type int. */
308 /* extent list */ 316 /* extent list */
309 /* ------------------------------- */ 317 /* ------------------------------- */
310 318
311 typedef struct extent_list_marker 319 typedef struct extent_list_marker
312 { 320 {
321 #ifdef NEW_GC
322 struct lrecord_header header;
323 #endif /* NEW_GC */
313 Gap_Array_Marker *m; 324 Gap_Array_Marker *m;
314 int endp; 325 int endp;
315 struct extent_list_marker *next; 326 struct extent_list_marker *next;
316 } Extent_List_Marker; 327 } Extent_List_Marker;
317 328
318 typedef struct extent_list 329 typedef struct extent_list
319 { 330 {
331 #ifdef NEW_GC
332 struct lrecord_header header;
333 #endif /* NEW_GC */
320 Gap_Array *start; 334 Gap_Array *start;
321 Gap_Array *end; 335 Gap_Array *end;
322 Extent_List_Marker *markers; 336 Extent_List_Marker *markers;
323 } Extent_List; 337 } Extent_List;
324 338
339 #ifndef NEW_GC
325 static Extent_List_Marker *extent_list_marker_freelist; 340 static Extent_List_Marker *extent_list_marker_freelist;
341 #endif /* not NEW_GC */
326 342
327 #define EXTENT_LESS_VALS(e,st,nd) ((extent_start (e) < (st)) || \ 343 #define EXTENT_LESS_VALS(e,st,nd) ((extent_start (e) < (st)) || \
328 ((extent_start (e) == (st)) && \ 344 ((extent_start (e) == (st)) && \
329 (extent_end (e) > (nd)))) 345 (extent_end (e) > (nd))))
330 346
375 /* buffer-extent primitives */ 391 /* buffer-extent primitives */
376 /* ------------------------------- */ 392 /* ------------------------------- */
377 393
378 typedef struct stack_of_extents 394 typedef struct stack_of_extents
379 { 395 {
396 #ifdef NEW_GC
397 struct lrecord_header header;
398 #endif /* NEW_GC */
380 Extent_List *extents; 399 Extent_List *extents;
381 Memxpos pos; /* Position of stack of extents. EXTENTS is the list of 400 Memxpos pos; /* Position of stack of extents. EXTENTS is the list of
382 all extents that overlap this position. This position 401 all extents that overlap this position. This position
383 can be -1 if the stack of extents is invalid (this 402 can be -1 if the stack of extents is invalid (this
384 happens when a buffer is first created or a string's 403 happens when a buffer is first created or a string's
567 586
568 /* If we have to get more space, get enough to last a while. We use 587 /* If we have to get more space, get enough to last a while. We use
569 a geometric progression that saves on realloc space. */ 588 a geometric progression that saves on realloc space. */
570 increment += 100 + ga->numels / 8; 589 increment += 100 + ga->numels / 8;
571 590
591 #ifdef NEW_GC
592 ga = (Gap_Array *) mc_realloc (ga,
593 offsetof (Gap_Array, array) +
594 (ga->numels + ga->gapsize + increment) *
595 ga->elsize);
596 #else /* not NEW_GC */
572 ga = (Gap_Array *) xrealloc (ga, 597 ga = (Gap_Array *) xrealloc (ga,
573 offsetof (Gap_Array, array) + 598 offsetof (Gap_Array, array) +
574 (ga->numels + ga->gapsize + increment) * 599 (ga->numels + ga->gapsize + increment) *
575 ga->elsize); 600 ga->elsize);
601 #endif /* not NEW_GC */
576 if (ga == 0) 602 if (ga == 0)
577 memory_full (); 603 memory_full ();
578 604
579 real_gap_loc = ga->gap; 605 real_gap_loc = ga->gap;
580 old_gap_size = ga->gapsize; 606 old_gap_size = ga->gapsize;
662 gap_array_make_marker (Gap_Array *ga, Elemcount pos) 688 gap_array_make_marker (Gap_Array *ga, Elemcount pos)
663 { 689 {
664 Gap_Array_Marker *m; 690 Gap_Array_Marker *m;
665 691
666 assert (pos >= 0 && pos <= ga->numels); 692 assert (pos >= 0 && pos <= ga->numels);
693 #ifdef NEW_GC
694 m = alloc_lrecord_type (Gap_Array_Marker, &lrecord_gap_array_marker);
695 #else /* not NEW_GC */
667 if (gap_array_marker_freelist) 696 if (gap_array_marker_freelist)
668 { 697 {
669 m = gap_array_marker_freelist; 698 m = gap_array_marker_freelist;
670 gap_array_marker_freelist = gap_array_marker_freelist->next; 699 gap_array_marker_freelist = gap_array_marker_freelist->next;
671 } 700 }
672 else 701 else
673 m = xnew (Gap_Array_Marker); 702 m = xnew (Gap_Array_Marker);
703 #endif /* not NEW_GC */
674 704
675 m->pos = GAP_ARRAY_ARRAY_TO_MEMORY_POS (ga, pos); 705 m->pos = GAP_ARRAY_ARRAY_TO_MEMORY_POS (ga, pos);
676 m->next = ga->markers; 706 m->next = ga->markers;
677 ga->markers = m; 707 ga->markers = m;
678 return m; 708 return m;
688 assert (p); 718 assert (p);
689 if (prev) 719 if (prev)
690 prev->next = p->next; 720 prev->next = p->next;
691 else 721 else
692 ga->markers = p->next; 722 ga->markers = p->next;
723 #ifndef NEW_GC
693 m->next = gap_array_marker_freelist; 724 m->next = gap_array_marker_freelist;
694 m->pos = 0xDEADBEEF; /* -559038737 base 10 */ 725 m->pos = 0xDEADBEEF; /* -559038737 base 10 */
695 gap_array_marker_freelist = m; 726 gap_array_marker_freelist = m;
696 } 727 #endif /* not NEW_GC */
697 728 }
729
730 #ifndef NEW_GC
698 static void 731 static void
699 gap_array_delete_all_markers (Gap_Array *ga) 732 gap_array_delete_all_markers (Gap_Array *ga)
700 { 733 {
701 Gap_Array_Marker *p, *next; 734 Gap_Array_Marker *p, *next;
702 735
706 p->next = gap_array_marker_freelist; 739 p->next = gap_array_marker_freelist;
707 p->pos = 0xDEADBEEF; /* -559038737 as an int */ 740 p->pos = 0xDEADBEEF; /* -559038737 as an int */
708 gap_array_marker_freelist = p; 741 gap_array_marker_freelist = p;
709 } 742 }
710 } 743 }
744 #endif /* not NEW_GC */
711 745
712 static void 746 static void
713 gap_array_move_marker (Gap_Array *ga, Gap_Array_Marker *m, Elemcount pos) 747 gap_array_move_marker (Gap_Array *ga, Gap_Array_Marker *m, Elemcount pos)
714 { 748 {
715 assert (pos >= 0 && pos <= ga->numels); 749 assert (pos >= 0 && pos <= ga->numels);
720 GAP_ARRAY_MEMORY_TO_ARRAY_POS (ga, (m)->pos) 754 GAP_ARRAY_MEMORY_TO_ARRAY_POS (ga, (m)->pos)
721 755
722 static Gap_Array * 756 static Gap_Array *
723 make_gap_array (Elemcount elsize) 757 make_gap_array (Elemcount elsize)
724 { 758 {
759 #ifdef NEW_GC
760 Gap_Array *ga = alloc_lrecord_type (Gap_Array, &lrecord_gap_array);
761 #else /* not NEW_GC */
725 Gap_Array *ga = xnew_and_zero (Gap_Array); 762 Gap_Array *ga = xnew_and_zero (Gap_Array);
763 #endif /* not NEW_GC */
726 ga->elsize = elsize; 764 ga->elsize = elsize;
727 return ga; 765 return ga;
728 } 766 }
729 767
768 #ifndef NEW_GC
730 static void 769 static void
731 free_gap_array (Gap_Array *ga) 770 free_gap_array (Gap_Array *ga)
732 { 771 {
733 gap_array_delete_all_markers (ga); 772 gap_array_delete_all_markers (ga);
734 xfree (ga, Gap_Array *); 773 xfree (ga, Gap_Array *);
735 } 774 }
775 #endif /* not NEW_GC */
736 776
737 777
738 /************************************************************************/ 778 /************************************************************************/
739 /* Extent list primitives */ 779 /* Extent list primitives */
740 /************************************************************************/ 780 /************************************************************************/
885 static Extent_List_Marker * 925 static Extent_List_Marker *
886 extent_list_make_marker (Extent_List *el, int pos, int endp) 926 extent_list_make_marker (Extent_List *el, int pos, int endp)
887 { 927 {
888 Extent_List_Marker *m; 928 Extent_List_Marker *m;
889 929
930 #ifdef NEW_GC
931 m = alloc_lrecord_type (Extent_List_Marker, &lrecord_extent_list_marker);
932 #else /* not NEW_GC */
890 if (extent_list_marker_freelist) 933 if (extent_list_marker_freelist)
891 { 934 {
892 m = extent_list_marker_freelist; 935 m = extent_list_marker_freelist;
893 extent_list_marker_freelist = extent_list_marker_freelist->next; 936 extent_list_marker_freelist = extent_list_marker_freelist->next;
894 } 937 }
895 else 938 else
896 m = xnew (Extent_List_Marker); 939 m = xnew (Extent_List_Marker);
940 #endif /* not NEW_GC */
897 941
898 m->m = gap_array_make_marker (endp ? el->end : el->start, pos); 942 m->m = gap_array_make_marker (endp ? el->end : el->start, pos);
899 m->endp = endp; 943 m->endp = endp;
900 m->next = el->markers; 944 m->next = el->markers;
901 el->markers = m; 945 el->markers = m;
915 assert (p); 959 assert (p);
916 if (prev) 960 if (prev)
917 prev->next = p->next; 961 prev->next = p->next;
918 else 962 else
919 el->markers = p->next; 963 el->markers = p->next;
964 #ifdef NEW_GC
965 gap_array_delete_marker (m->endp ? el->end : el->start, m->m);
966 #else /* not NEW_GC */
920 m->next = extent_list_marker_freelist; 967 m->next = extent_list_marker_freelist;
921 extent_list_marker_freelist = m; 968 extent_list_marker_freelist = m;
922 gap_array_delete_marker (m->endp ? el->end : el->start, m->m); 969 gap_array_delete_marker (m->endp ? el->end : el->start, m->m);
970 #endif /* not NEW_GC */
923 } 971 }
924 972
925 #define extent_list_marker_pos(el, mkr) \ 973 #define extent_list_marker_pos(el, mkr) \
926 gap_array_marker_pos ((mkr)->endp ? (el)->end : (el)->start, (mkr)->m) 974 gap_array_marker_pos ((mkr)->endp ? (el)->end : (el)->start, (mkr)->m)
927 975
928 static Extent_List * 976 static Extent_List *
929 allocate_extent_list (void) 977 allocate_extent_list (void)
930 { 978 {
979 #ifdef NEW_GC
980 Extent_List *el = alloc_lrecord_type (Extent_List, &lrecord_extent_list);
981 #else /* not NEW_GC */
931 Extent_List *el = xnew (Extent_List); 982 Extent_List *el = xnew (Extent_List);
983 #endif /* not NEW_GC */
932 el->start = make_gap_array (sizeof (EXTENT)); 984 el->start = make_gap_array (sizeof (EXTENT));
933 el->end = make_gap_array (sizeof (EXTENT)); 985 el->end = make_gap_array (sizeof (EXTENT));
934 el->markers = 0; 986 el->markers = 0;
935 return el; 987 return el;
936 } 988 }
937 989
990 #ifndef NEW_GC
938 static void 991 static void
939 free_extent_list (Extent_List *el) 992 free_extent_list (Extent_List *el)
940 { 993 {
941 free_gap_array (el->start); 994 free_gap_array (el->start);
942 free_gap_array (el->end); 995 free_gap_array (el->end);
943 xfree (el, Extent_List *); 996 xfree (el, Extent_List *);
944 } 997 }
998 #endif /* not NEW_GC */
945 999
946 1000
947 /************************************************************************/ 1001 /************************************************************************/
948 /* Auxiliary extent structure */ 1002 /* Auxiliary extent structure */
949 /************************************************************************/ 1003 /************************************************************************/
975 mark_object (data->before_change_functions); 1029 mark_object (data->before_change_functions);
976 mark_object (data->after_change_functions); 1030 mark_object (data->after_change_functions);
977 return data->parent; 1031 return data->parent;
978 } 1032 }
979 1033
980 DEFINE_NONDUMPABLE_INTERNAL_LISP_OBJECT ("extent-auxiliary", 1034 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("extent-auxiliary",
981 extent_auxiliary, 1035 extent_auxiliary,
982 struct extent_auxiliary, 1036 mark_extent_auxiliary,
983 extent_auxiliary_description, 1037 extent_auxiliary_description,
984 mark_extent_auxiliary); 1038 struct extent_auxiliary);
985 void 1039 void
986 allocate_extent_auxiliary (EXTENT ext) 1040 allocate_extent_auxiliary (EXTENT ext)
987 { 1041 {
988 Lisp_Object obj = ALLOC_LISP_OBJECT (extent_auxiliary); 1042 Lisp_Object obj = ALLOC_LISP_OBJECT (extent_auxiliary);
989 struct extent_auxiliary *data = XEXTENT_AUXILIARY (obj); 1043 struct extent_auxiliary *data = XEXTENT_AUXILIARY (obj);
1018 (Generally it won't if there haven't been any extents added to the 1072 (Generally it won't if there haven't been any extents added to the
1019 string.) So use the _force version if you need the extent_info 1073 string.) So use the _force version if you need the extent_info
1020 structure to be there. */ 1074 structure to be there. */
1021 1075
1022 static struct stack_of_extents *allocate_soe (void); 1076 static struct stack_of_extents *allocate_soe (void);
1077 #ifndef NEW_GC
1023 static void free_soe (struct stack_of_extents *soe); 1078 static void free_soe (struct stack_of_extents *soe);
1079 #endif /* not NEW_GC */
1024 static void soe_invalidate (Lisp_Object obj); 1080 static void soe_invalidate (Lisp_Object obj);
1025 1081
1026 extern const struct sized_memory_description gap_array_marker_description; 1082 extern const struct sized_memory_description gap_array_marker_description;
1027 1083
1028 static const struct memory_description gap_array_marker_description_1[] = { 1084 static const struct memory_description gap_array_marker_description_1[] = {
1085 #ifdef NEW_GC
1086 { XD_LISP_OBJECT, offsetof (Gap_Array_Marker, next) },
1087 #else /* not NEW_GC */
1029 { XD_BLOCK_PTR, offsetof (Gap_Array_Marker, next), 1, 1088 { XD_BLOCK_PTR, offsetof (Gap_Array_Marker, next), 1,
1030 { &gap_array_marker_description } }, 1089 { &gap_array_marker_description } },
1090 #endif /* not NEW_GC */
1031 { XD_END } 1091 { XD_END }
1032 }; 1092 };
1033 1093
1094 #ifdef NEW_GC
1095 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("gap-array-marker", gap_array_marker,
1096 0, gap_array_marker_description_1,
1097 struct gap_array_marker);
1098 #else /* not NEW_GC */
1034 const struct sized_memory_description gap_array_marker_description = { 1099 const struct sized_memory_description gap_array_marker_description = {
1035 sizeof (Gap_Array_Marker), 1100 sizeof (Gap_Array_Marker),
1036 gap_array_marker_description_1 1101 gap_array_marker_description_1
1037 }; 1102 };
1103 #endif /* not NEW_GC */
1038 1104
1039 static const struct memory_description lispobj_gap_array_description_1[] = { 1105 static const struct memory_description lispobj_gap_array_description_1[] = {
1040 { XD_ELEMCOUNT, offsetof (Gap_Array, gap) }, 1106 { XD_ELEMCOUNT, offsetof (Gap_Array, gap) },
1041 { XD_BYTECOUNT, offsetof (Gap_Array, offset_past_gap) }, 1107 { XD_BYTECOUNT, offsetof (Gap_Array, offset_past_gap) },
1042 { XD_ELEMCOUNT, offsetof (Gap_Array, els_past_gap) }, 1108 { XD_ELEMCOUNT, offsetof (Gap_Array, els_past_gap) },
1109 #ifdef NEW_GC
1110 { XD_LISP_OBJECT, offsetof (Gap_Array, markers) },
1111 #else /* not NEW_GC */
1043 { XD_BLOCK_PTR, offsetof (Gap_Array, markers), 1, 1112 { XD_BLOCK_PTR, offsetof (Gap_Array, markers), 1,
1044 { &gap_array_marker_description }, XD_FLAG_NO_KKCC }, 1113 { &gap_array_marker_description }, XD_FLAG_NO_KKCC },
1114 #endif /* not NEW_GC */
1045 { XD_BLOCK_ARRAY, offsetof (Gap_Array, array), XD_INDIRECT (0, 0), 1115 { XD_BLOCK_ARRAY, offsetof (Gap_Array, array), XD_INDIRECT (0, 0),
1046 { &lisp_object_description } }, 1116 { &lisp_object_description } },
1047 { XD_BLOCK_ARRAY, XD_INDIRECT (1, offsetof (Gap_Array, array)), 1117 { XD_BLOCK_ARRAY, XD_INDIRECT (1, offsetof (Gap_Array, array)),
1048 XD_INDIRECT (2, 0), { &lisp_object_description } }, 1118 XD_INDIRECT (2, 0), { &lisp_object_description } },
1049 { XD_END } 1119 { XD_END }
1050 }; 1120 };
1051 1121
1122 #ifdef NEW_GC
1123
1124 static Bytecount
1125 size_gap_array (const void *lheader)
1126 {
1127 Gap_Array *ga = (Gap_Array *) lheader;
1128 return offsetof (Gap_Array, array) + (ga->numels + ga->gapsize) * ga->elsize;
1129 }
1130
1131 DEFINE_NODUMP_SIZABLE_INTERNAL_LISP_OBJECT ("gap-array", gap_array,
1132 0,
1133 lispobj_gap_array_description_1,
1134 size_gap_array,
1135 struct gap_array);
1136 #else /* not NEW_GC */
1052 static const struct sized_memory_description lispobj_gap_array_description = { 1137 static const struct sized_memory_description lispobj_gap_array_description = {
1053 sizeof (Gap_Array), 1138 sizeof (Gap_Array),
1054 lispobj_gap_array_description_1 1139 lispobj_gap_array_description_1
1055 }; 1140 };
1056 1141
1057 extern const struct sized_memory_description extent_list_marker_description; 1142 extern const struct sized_memory_description extent_list_marker_description;
1143 #endif /* not NEW_GC */
1058 1144
1059 static const struct memory_description extent_list_marker_description_1[] = { 1145 static const struct memory_description extent_list_marker_description_1[] = {
1146 #ifdef NEW_GC
1147 { XD_LISP_OBJECT, offsetof (Extent_List_Marker, m) },
1148 { XD_LISP_OBJECT, offsetof (Extent_List_Marker, next) },
1149 #else /* not NEW_GC */
1060 { XD_BLOCK_PTR, offsetof (Extent_List_Marker, m), 1, 1150 { XD_BLOCK_PTR, offsetof (Extent_List_Marker, m), 1,
1061 { &gap_array_marker_description } }, 1151 { &gap_array_marker_description } },
1062 { XD_BLOCK_PTR, offsetof (Extent_List_Marker, next), 1, 1152 { XD_BLOCK_PTR, offsetof (Extent_List_Marker, next), 1,
1063 { &extent_list_marker_description } }, 1153 { &extent_list_marker_description } },
1154 #endif /* not NEW_GC */
1064 { XD_END } 1155 { XD_END }
1065 }; 1156 };
1066 1157
1158 #ifdef NEW_GC
1159 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("extent-list-marker",
1160 extent_list_marker,
1161 0, extent_list_marker_description_1,
1162 struct extent_list_marker);
1163 #else /* not NEW_GC */
1067 const struct sized_memory_description extent_list_marker_description = { 1164 const struct sized_memory_description extent_list_marker_description = {
1068 sizeof (Extent_List_Marker), 1165 sizeof (Extent_List_Marker),
1069 extent_list_marker_description_1 1166 extent_list_marker_description_1
1070 }; 1167 };
1168 #endif /* not NEW_GC */
1071 1169
1072 static const struct memory_description extent_list_description_1[] = { 1170 static const struct memory_description extent_list_description_1[] = {
1171 #ifdef NEW_GC
1172 { XD_LISP_OBJECT, offsetof (Extent_List, start) },
1173 { XD_LISP_OBJECT, offsetof (Extent_List, end) },
1174 { XD_LISP_OBJECT, offsetof (Extent_List, markers) },
1175 #else /* not NEW_GC */
1073 { XD_BLOCK_PTR, offsetof (Extent_List, start), 1, 1176 { XD_BLOCK_PTR, offsetof (Extent_List, start), 1,
1074 { &lispobj_gap_array_description } }, 1177 { &lispobj_gap_array_description } },
1075 { XD_BLOCK_PTR, offsetof (Extent_List, end), 1, 1178 { XD_BLOCK_PTR, offsetof (Extent_List, end), 1,
1076 { &lispobj_gap_array_description }, XD_FLAG_NO_KKCC }, 1179 { &lispobj_gap_array_description }, XD_FLAG_NO_KKCC },
1077 { XD_BLOCK_PTR, offsetof (Extent_List, markers), 1, 1180 { XD_BLOCK_PTR, offsetof (Extent_List, markers), 1,
1078 { &extent_list_marker_description }, XD_FLAG_NO_KKCC }, 1181 { &extent_list_marker_description }, XD_FLAG_NO_KKCC },
1182 #endif /* not NEW_GC */
1079 { XD_END } 1183 { XD_END }
1080 }; 1184 };
1081 1185
1186 #ifdef NEW_GC
1187 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("extent-list", extent_list,
1188 0, extent_list_description_1,
1189 struct extent_list);
1190 #else /* not NEW_GC */
1082 static const struct sized_memory_description extent_list_description = { 1191 static const struct sized_memory_description extent_list_description = {
1083 sizeof (Extent_List), 1192 sizeof (Extent_List),
1084 extent_list_description_1 1193 extent_list_description_1
1085 }; 1194 };
1195 #endif /* not NEW_GC */
1086 1196
1087 static const struct memory_description stack_of_extents_description_1[] = { 1197 static const struct memory_description stack_of_extents_description_1[] = {
1198 #ifdef NEW_GC
1199 { XD_LISP_OBJECT, offsetof (Stack_Of_Extents, extents) },
1200 #else /* not NEW_GC */
1088 { XD_BLOCK_PTR, offsetof (Stack_Of_Extents, extents), 1, 1201 { XD_BLOCK_PTR, offsetof (Stack_Of_Extents, extents), 1,
1089 { &extent_list_description } }, 1202 { &extent_list_description } },
1203 #endif /* not NEW_GC */
1090 { XD_END } 1204 { XD_END }
1091 }; 1205 };
1092 1206
1207 #ifdef NEW_GC
1208 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("stack-of-extents", stack_of_extents,
1209 0, stack_of_extents_description_1,
1210 struct stack_of_extents);
1211 #else /* not NEW_GC */
1093 static const struct sized_memory_description stack_of_extents_description = { 1212 static const struct sized_memory_description stack_of_extents_description = {
1094 sizeof (Stack_Of_Extents), 1213 sizeof (Stack_Of_Extents),
1095 stack_of_extents_description_1 1214 stack_of_extents_description_1
1096 }; 1215 };
1216 #endif /* not NEW_GC */
1097 1217
1098 static const struct memory_description extent_info_description [] = { 1218 static const struct memory_description extent_info_description [] = {
1219 #ifdef NEW_GC
1220 { XD_LISP_OBJECT, offsetof (struct extent_info, extents) },
1221 { XD_LISP_OBJECT, offsetof (struct extent_info, soe) },
1222 #else /* not NEW_GC */
1099 { XD_BLOCK_PTR, offsetof (struct extent_info, extents), 1, 1223 { XD_BLOCK_PTR, offsetof (struct extent_info, extents), 1,
1100 { &extent_list_description } }, 1224 { &extent_list_description } },
1101 { XD_BLOCK_PTR, offsetof (struct extent_info, soe), 1, 1225 { XD_BLOCK_PTR, offsetof (struct extent_info, soe), 1,
1102 { &stack_of_extents_description }, XD_FLAG_NO_KKCC }, 1226 { &stack_of_extents_description }, XD_FLAG_NO_KKCC },
1227 #endif /* not NEW_GC */
1103 { XD_END } 1228 { XD_END }
1104 }; 1229 };
1105 1230
1106 static Lisp_Object 1231 static Lisp_Object
1107 mark_extent_info (Lisp_Object obj) 1232 mark_extent_info (Lisp_Object obj)
1131 } 1256 }
1132 1257
1133 return Qnil; 1258 return Qnil;
1134 } 1259 }
1135 1260
1261 #ifdef NEW_GC
1262 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("extent-info", extent_info,
1263 mark_extent_info,
1264 extent_info_description,
1265 struct extent_info);
1266 #else /* not NEW_GC */
1136 static void 1267 static void
1137 finalize_extent_info (void *header, int for_disksave) 1268 finalize_extent_info (void *header, int for_disksave)
1138 { 1269 {
1139 struct extent_info *data = (struct extent_info *) header; 1270 struct extent_info *data = (struct extent_info *) header;
1140 1271
1141 if (for_disksave) 1272 if (for_disksave)
1142 return; 1273 return;
1143 1274
1275 data->soe = 0;
1276 data->extents = 0;
1144 if (data->soe) 1277 if (data->soe)
1145 { 1278 {
1146 free_soe (data->soe); 1279 free_soe (data->soe);
1147 data->soe = 0; 1280 data->soe = 0;
1148 } 1281 }
1151 free_extent_list (data->extents); 1284 free_extent_list (data->extents);
1152 data->extents = 0; 1285 data->extents = 0;
1153 } 1286 }
1154 } 1287 }
1155 1288
1156 DEFINE_NONDUMPABLE_LISP_OBJECT ("extent-info", extent_info, 1289 DEFINE_NODUMP_LISP_OBJECT ("extent-info", extent_info,
1157 mark_extent_info, 0, 1290 mark_extent_info, 0,
1158 finalize_extent_info, 0, 0, 1291 finalize_extent_info, 0, 0,
1159 extent_info_description, 1292 extent_info_description,
1160 struct extent_info); 1293 struct extent_info);
1294 #endif /* not NEW_GC */
1161 1295
1162 static Lisp_Object 1296 static Lisp_Object
1163 allocate_extent_info (void) 1297 allocate_extent_info (void)
1164 { 1298 {
1165 Lisp_Object obj = ALLOC_LISP_OBJECT (extent_info); 1299 Lisp_Object obj = ALLOC_LISP_OBJECT (extent_info);
1175 { 1309 {
1176 struct extent_info *data = XEXTENT_INFO (extent_info); 1310 struct extent_info *data = XEXTENT_INFO (extent_info);
1177 1311
1178 if (data->soe) 1312 if (data->soe)
1179 { 1313 {
1314 #ifndef NEW_GC
1180 free_soe (data->soe); 1315 free_soe (data->soe);
1316 #endif /* not NEW_GC */
1181 data->soe = 0; 1317 data->soe = 0;
1182 } 1318 }
1183 } 1319 }
1184 1320
1185 1321
1301 /* No need to do detach_extent(). Just nuke the damn things, 1437 /* No need to do detach_extent(). Just nuke the damn things,
1302 which results in the equivalent but faster. */ 1438 which results in the equivalent but faster. */
1303 set_extent_start (e, -1); 1439 set_extent_start (e, -1);
1304 set_extent_end (e, -1); 1440 set_extent_end (e, -1);
1305 } 1441 }
1442
1443 /* But we need to clear all the lists containing extents or
1444 havoc will result. */
1445 extent_list_delete_all (data->extents);
1306 } 1446 }
1307
1308 /* But we need to clear all the lists containing extents or
1309 havoc will result. */
1310 extent_list_delete_all (data->extents);
1311 soe_invalidate (object); 1447 soe_invalidate (object);
1312 } 1448 }
1313 } 1449 }
1314 1450
1315 1451
1320 } 1456 }
1321 1457
1322 void 1458 void
1323 uninit_buffer_extents (struct buffer *b) 1459 uninit_buffer_extents (struct buffer *b)
1324 { 1460 {
1461 #ifndef NEW_GC
1325 struct extent_info *data = XEXTENT_INFO (b->extent_info); 1462 struct extent_info *data = XEXTENT_INFO (b->extent_info);
1463 #endif /* not NEW_GC */
1326 1464
1327 /* Don't destroy the extents here -- there may still be children 1465 /* Don't destroy the extents here -- there may still be children
1328 extents pointing to the extents. */ 1466 extents pointing to the extents. */
1329 detach_all_extents (wrap_buffer (b)); 1467 detach_all_extents (wrap_buffer (b));
1468 #ifndef NEW_GC
1330 finalize_extent_info (data, 0); 1469 finalize_extent_info (data, 0);
1470 #endif /* not NEW_GC */
1331 } 1471 }
1332 1472
1333 /* Retrieve the extent list that an extent is a member of; the 1473 /* Retrieve the extent list that an extent is a member of; the
1334 return value will never be 0 except in destroyed buffers (in which 1474 return value will never be 0 except in destroyed buffers (in which
1335 case the only extents that can refer to this buffer are detached 1475 case the only extents that can refer to this buffer are detached
1643 } 1783 }
1644 1784
1645 static struct stack_of_extents * 1785 static struct stack_of_extents *
1646 allocate_soe (void) 1786 allocate_soe (void)
1647 { 1787 {
1788 #ifdef NEW_GC
1789 struct stack_of_extents *soe =
1790 alloc_lrecord_type (struct stack_of_extents, &lrecord_stack_of_extents);
1791 #else /* not NEW_GC */
1648 struct stack_of_extents *soe = xnew_and_zero (struct stack_of_extents); 1792 struct stack_of_extents *soe = xnew_and_zero (struct stack_of_extents);
1793 #endif /* not NEW_GC */
1649 soe->extents = allocate_extent_list (); 1794 soe->extents = allocate_extent_list ();
1650 soe->pos = -1; 1795 soe->pos = -1;
1651 return soe; 1796 return soe;
1652 } 1797 }
1653 1798
1799 #ifndef NEW_GC
1654 static void 1800 static void
1655 free_soe (struct stack_of_extents *soe) 1801 free_soe (struct stack_of_extents *soe)
1656 { 1802 {
1657 free_extent_list (soe->extents); 1803 free_extent_list (soe->extents);
1658 xfree (soe, struct stack_of_extents *); 1804 xfree (soe, struct stack_of_extents *);
1659 } 1805 }
1806 #endif /* not NEW_GC */
1660 1807
1661 /* ------------------------------- */ 1808 /* ------------------------------- */
1662 /* other primitives */ 1809 /* other primitives */
1663 /* ------------------------------- */ 1810 /* ------------------------------- */
1664 1811
1763 1910
1764 /* Check for syntax table property change */ 1911 /* Check for syntax table property change */
1765 if (NILP (property) ? !NILP (Fextent_property (wrap_extent (extent), 1912 if (NILP (property) ? !NILP (Fextent_property (wrap_extent (extent),
1766 Qsyntax_table, Qnil)) : 1913 Qsyntax_table, Qnil)) :
1767 EQ (property, Qsyntax_table)) 1914 EQ (property, Qsyntax_table))
1768 signal_syntax_table_extent_changed (extent); 1915 signal_syntax_cache_extent_changed (extent);
1769 } 1916 }
1770 1917
1771 /* Make note that a change has happened in EXTENT. The change was either 1918 /* Make note that a change has happened in EXTENT. The change was either
1772 to a property or to the endpoints (but not both at once). If PROPERTY 1919 to a property or to the endpoints (but not both at once). If PROPERTY
1773 is non-nil, the change happened to that property; otherwise, the change 1920 is non-nil, the change happened to that property; otherwise, the change
3311 extent_plist (Lisp_Object obj) 3458 extent_plist (Lisp_Object obj)
3312 { 3459 {
3313 return Fextent_properties (obj); 3460 return Fextent_properties (obj);
3314 } 3461 }
3315 3462
3316 DEFINE_BASIC_LISP_OBJECT_WITH_PROPS ("extent", extent, 3463 DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT_WITH_PROPS ("extent", extent,
3317 mark_extent, 3464 mark_extent,
3318 print_extent, 3465 print_extent,
3319 /* NOTE: If you declare a 3466 /* NOTE: If you declare a
3320 finalization method here, 3467 finalization method here,
3321 it will NOT be called. 3468 it will NOT be called.
7291 syms_of_extents (void) 7438 syms_of_extents (void)
7292 { 7439 {
7293 INIT_LISP_OBJECT (extent); 7440 INIT_LISP_OBJECT (extent);
7294 INIT_LISP_OBJECT (extent_info); 7441 INIT_LISP_OBJECT (extent_info);
7295 INIT_LISP_OBJECT (extent_auxiliary); 7442 INIT_LISP_OBJECT (extent_auxiliary);
7443 #ifdef NEW_GC
7444 INIT_LISP_OBJECT (gap_array_marker);
7445 INIT_LISP_OBJECT (gap_array);
7446 INIT_LISP_OBJECT (extent_list_marker);
7447 INIT_LISP_OBJECT (extent_list);
7448 INIT_LISP_OBJECT (stack_of_extents);
7449 #endif /* NEW_GC */
7296 7450
7297 DEFSYMBOL (Qextentp); 7451 DEFSYMBOL (Qextentp);
7298 DEFSYMBOL (Qextent_live_p); 7452 DEFSYMBOL (Qextent_live_p);
7299 7453
7300 DEFSYMBOL (Qall_extents_closed); 7454 DEFSYMBOL (Qall_extents_closed);