Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/src/extents.c Sat Dec 26 00:20:27 2009 -0600 +++ b/src/extents.c Sat Dec 26 21:18:49 2009 -0600 @@ -242,6 +242,9 @@ typedef struct gap_array_marker { +#ifdef NEW_GC + struct lrecord_header header; +#endif /* NEW_GC */ int pos; struct gap_array_marker *next; } Gap_Array_Marker; @@ -269,6 +272,9 @@ typedef struct gap_array { +#ifdef NEW_GC + struct lrecord_header header; +#endif /* NEW_GC */ Elemcount gap; Elemcount gapsize; Elemcount numels; @@ -281,7 +287,9 @@ char array[1]; } Gap_Array; +#ifndef NEW_GC static Gap_Array_Marker *gap_array_marker_freelist; +#endif /* not NEW_GC */ /* Convert a "memory position" (i.e. taking the gap into account) into the address of the element at (i.e. after) that position. "Memory @@ -310,6 +318,9 @@ typedef struct extent_list_marker { +#ifdef NEW_GC + struct lrecord_header header; +#endif /* NEW_GC */ Gap_Array_Marker *m; int endp; struct extent_list_marker *next; @@ -317,12 +328,17 @@ typedef struct extent_list { +#ifdef NEW_GC + struct lrecord_header header; +#endif /* NEW_GC */ Gap_Array *start; Gap_Array *end; Extent_List_Marker *markers; } Extent_List; +#ifndef NEW_GC static Extent_List_Marker *extent_list_marker_freelist; +#endif /* not NEW_GC */ #define EXTENT_LESS_VALS(e,st,nd) ((extent_start (e) < (st)) || \ ((extent_start (e) == (st)) && \ @@ -377,6 +393,9 @@ typedef struct stack_of_extents { +#ifdef NEW_GC + struct lrecord_header header; +#endif /* NEW_GC */ Extent_List *extents; Memxpos pos; /* Position of stack of extents. EXTENTS is the list of all extents that overlap this position. This position @@ -569,10 +588,17 @@ a geometric progression that saves on realloc space. */ increment += 100 + ga->numels / 8; +#ifdef NEW_GC + ga = (Gap_Array *) mc_realloc (ga, + offsetof (Gap_Array, array) + + (ga->numels + ga->gapsize + increment) * + ga->elsize); +#else /* not NEW_GC */ ga = (Gap_Array *) xrealloc (ga, offsetof (Gap_Array, array) + (ga->numels + ga->gapsize + increment) * ga->elsize); +#endif /* not NEW_GC */ if (ga == 0) memory_full (); @@ -664,6 +690,9 @@ Gap_Array_Marker *m; assert (pos >= 0 && pos <= ga->numels); +#ifdef NEW_GC + m = alloc_lrecord_type (Gap_Array_Marker, &lrecord_gap_array_marker); +#else /* not NEW_GC */ if (gap_array_marker_freelist) { m = gap_array_marker_freelist; @@ -671,6 +700,7 @@ } else m = xnew (Gap_Array_Marker); +#endif /* not NEW_GC */ m->pos = GAP_ARRAY_ARRAY_TO_MEMORY_POS (ga, pos); m->next = ga->markers; @@ -690,11 +720,14 @@ prev->next = p->next; else ga->markers = p->next; +#ifndef NEW_GC m->next = gap_array_marker_freelist; m->pos = 0xDEADBEEF; /* -559038737 base 10 */ gap_array_marker_freelist = m; -} - +#endif /* not NEW_GC */ +} + +#ifndef NEW_GC static void gap_array_delete_all_markers (Gap_Array *ga) { @@ -708,6 +741,7 @@ gap_array_marker_freelist = p; } } +#endif /* not NEW_GC */ static void gap_array_move_marker (Gap_Array *ga, Gap_Array_Marker *m, Elemcount pos) @@ -722,17 +756,23 @@ static Gap_Array * make_gap_array (Elemcount elsize) { +#ifdef NEW_GC + Gap_Array *ga = alloc_lrecord_type (Gap_Array, &lrecord_gap_array); +#else /* not NEW_GC */ Gap_Array *ga = xnew_and_zero (Gap_Array); +#endif /* not NEW_GC */ ga->elsize = elsize; return ga; } +#ifndef NEW_GC static void free_gap_array (Gap_Array *ga) { gap_array_delete_all_markers (ga); xfree (ga, Gap_Array *); } +#endif /* not NEW_GC */ /************************************************************************/ @@ -887,6 +927,9 @@ { Extent_List_Marker *m; +#ifdef NEW_GC + m = alloc_lrecord_type (Extent_List_Marker, &lrecord_extent_list_marker); +#else /* not NEW_GC */ if (extent_list_marker_freelist) { m = extent_list_marker_freelist; @@ -894,6 +937,7 @@ } else m = xnew (Extent_List_Marker); +#endif /* not NEW_GC */ m->m = gap_array_make_marker (endp ? el->end : el->start, pos); m->endp = endp; @@ -917,9 +961,13 @@ prev->next = p->next; else el->markers = p->next; +#ifdef NEW_GC + gap_array_delete_marker (m->endp ? el->end : el->start, m->m); +#else /* not NEW_GC */ m->next = extent_list_marker_freelist; extent_list_marker_freelist = m; gap_array_delete_marker (m->endp ? el->end : el->start, m->m); +#endif /* not NEW_GC */ } #define extent_list_marker_pos(el, mkr) \ @@ -928,13 +976,18 @@ static Extent_List * allocate_extent_list (void) { +#ifdef NEW_GC + Extent_List *el = alloc_lrecord_type (Extent_List, &lrecord_extent_list); +#else /* not NEW_GC */ Extent_List *el = xnew (Extent_List); +#endif /* not NEW_GC */ el->start = make_gap_array (sizeof (EXTENT)); el->end = make_gap_array (sizeof (EXTENT)); el->markers = 0; return el; } +#ifndef NEW_GC static void free_extent_list (Extent_List *el) { @@ -942,6 +995,7 @@ free_gap_array (el->end); xfree (el, Extent_List *); } +#endif /* not NEW_GC */ /************************************************************************/ @@ -977,11 +1031,11 @@ return data->parent; } -DEFINE_NONDUMPABLE_INTERNAL_LISP_OBJECT ("extent-auxiliary", - extent_auxiliary, - struct extent_auxiliary, - extent_auxiliary_description, - mark_extent_auxiliary); +DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("extent-auxiliary", + extent_auxiliary, + mark_extent_auxiliary, + extent_auxiliary_description, + struct extent_auxiliary); void allocate_extent_auxiliary (EXTENT ext) { @@ -1020,28 +1074,44 @@ structure to be there. */ static struct stack_of_extents *allocate_soe (void); +#ifndef NEW_GC static void free_soe (struct stack_of_extents *soe); +#endif /* not NEW_GC */ static void soe_invalidate (Lisp_Object obj); extern const struct sized_memory_description gap_array_marker_description; static const struct memory_description gap_array_marker_description_1[] = { +#ifdef NEW_GC + { XD_LISP_OBJECT, offsetof (Gap_Array_Marker, next) }, +#else /* not NEW_GC */ { XD_BLOCK_PTR, offsetof (Gap_Array_Marker, next), 1, { &gap_array_marker_description } }, +#endif /* not NEW_GC */ { XD_END } }; +#ifdef NEW_GC +DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("gap-array-marker", gap_array_marker, + 0, gap_array_marker_description_1, + struct gap_array_marker); +#else /* not NEW_GC */ const struct sized_memory_description gap_array_marker_description = { sizeof (Gap_Array_Marker), gap_array_marker_description_1 }; +#endif /* not NEW_GC */ static const struct memory_description lispobj_gap_array_description_1[] = { { XD_ELEMCOUNT, offsetof (Gap_Array, gap) }, { XD_BYTECOUNT, offsetof (Gap_Array, offset_past_gap) }, { XD_ELEMCOUNT, offsetof (Gap_Array, els_past_gap) }, +#ifdef NEW_GC + { XD_LISP_OBJECT, offsetof (Gap_Array, markers) }, +#else /* not NEW_GC */ { XD_BLOCK_PTR, offsetof (Gap_Array, markers), 1, { &gap_array_marker_description }, XD_FLAG_NO_KKCC }, +#endif /* not NEW_GC */ { XD_BLOCK_ARRAY, offsetof (Gap_Array, array), XD_INDIRECT (0, 0), { &lisp_object_description } }, { XD_BLOCK_ARRAY, XD_INDIRECT (1, offsetof (Gap_Array, array)), @@ -1049,57 +1119,112 @@ { XD_END } }; +#ifdef NEW_GC + +static Bytecount +size_gap_array (const void *lheader) +{ + Gap_Array *ga = (Gap_Array *) lheader; + return offsetof (Gap_Array, array) + (ga->numels + ga->gapsize) * ga->elsize; +} + +DEFINE_NODUMP_SIZABLE_INTERNAL_LISP_OBJECT ("gap-array", gap_array, + 0, + lispobj_gap_array_description_1, + size_gap_array, + struct gap_array); +#else /* not NEW_GC */ static const struct sized_memory_description lispobj_gap_array_description = { sizeof (Gap_Array), lispobj_gap_array_description_1 }; extern const struct sized_memory_description extent_list_marker_description; +#endif /* not NEW_GC */ static const struct memory_description extent_list_marker_description_1[] = { +#ifdef NEW_GC + { XD_LISP_OBJECT, offsetof (Extent_List_Marker, m) }, + { XD_LISP_OBJECT, offsetof (Extent_List_Marker, next) }, +#else /* not NEW_GC */ { XD_BLOCK_PTR, offsetof (Extent_List_Marker, m), 1, { &gap_array_marker_description } }, { XD_BLOCK_PTR, offsetof (Extent_List_Marker, next), 1, { &extent_list_marker_description } }, +#endif /* not NEW_GC */ { XD_END } }; +#ifdef NEW_GC +DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("extent-list-marker", + extent_list_marker, + 0, extent_list_marker_description_1, + struct extent_list_marker); +#else /* not NEW_GC */ const struct sized_memory_description extent_list_marker_description = { sizeof (Extent_List_Marker), extent_list_marker_description_1 }; +#endif /* not NEW_GC */ static const struct memory_description extent_list_description_1[] = { +#ifdef NEW_GC + { XD_LISP_OBJECT, offsetof (Extent_List, start) }, + { XD_LISP_OBJECT, offsetof (Extent_List, end) }, + { XD_LISP_OBJECT, offsetof (Extent_List, markers) }, +#else /* not NEW_GC */ { XD_BLOCK_PTR, offsetof (Extent_List, start), 1, { &lispobj_gap_array_description } }, { XD_BLOCK_PTR, offsetof (Extent_List, end), 1, { &lispobj_gap_array_description }, XD_FLAG_NO_KKCC }, { XD_BLOCK_PTR, offsetof (Extent_List, markers), 1, { &extent_list_marker_description }, XD_FLAG_NO_KKCC }, +#endif /* not NEW_GC */ { XD_END } }; +#ifdef NEW_GC +DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("extent-list", extent_list, + 0, extent_list_description_1, + struct extent_list); +#else /* not NEW_GC */ static const struct sized_memory_description extent_list_description = { sizeof (Extent_List), extent_list_description_1 }; +#endif /* not NEW_GC */ static const struct memory_description stack_of_extents_description_1[] = { +#ifdef NEW_GC + { XD_LISP_OBJECT, offsetof (Stack_Of_Extents, extents) }, +#else /* not NEW_GC */ { XD_BLOCK_PTR, offsetof (Stack_Of_Extents, extents), 1, { &extent_list_description } }, +#endif /* not NEW_GC */ { XD_END } }; +#ifdef NEW_GC +DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("stack-of-extents", stack_of_extents, + 0, stack_of_extents_description_1, + struct stack_of_extents); +#else /* not NEW_GC */ static const struct sized_memory_description stack_of_extents_description = { sizeof (Stack_Of_Extents), stack_of_extents_description_1 }; +#endif /* not NEW_GC */ static const struct memory_description extent_info_description [] = { +#ifdef NEW_GC + { XD_LISP_OBJECT, offsetof (struct extent_info, extents) }, + { XD_LISP_OBJECT, offsetof (struct extent_info, soe) }, +#else /* not NEW_GC */ { XD_BLOCK_PTR, offsetof (struct extent_info, extents), 1, { &extent_list_description } }, { XD_BLOCK_PTR, offsetof (struct extent_info, soe), 1, { &stack_of_extents_description }, XD_FLAG_NO_KKCC }, +#endif /* not NEW_GC */ { XD_END } }; @@ -1133,6 +1258,12 @@ return Qnil; } +#ifdef NEW_GC +DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("extent-info", extent_info, + mark_extent_info, + extent_info_description, + struct extent_info); +#else /* not NEW_GC */ static void finalize_extent_info (void *header, int for_disksave) { @@ -1141,6 +1272,8 @@ if (for_disksave) return; + data->soe = 0; + data->extents = 0; if (data->soe) { free_soe (data->soe); @@ -1153,11 +1286,12 @@ } } -DEFINE_NONDUMPABLE_LISP_OBJECT ("extent-info", extent_info, +DEFINE_NODUMP_LISP_OBJECT ("extent-info", extent_info, mark_extent_info, 0, finalize_extent_info, 0, 0, extent_info_description, struct extent_info); +#endif /* not NEW_GC */ static Lisp_Object allocate_extent_info (void) @@ -1177,7 +1311,9 @@ if (data->soe) { +#ifndef NEW_GC free_soe (data->soe); +#endif /* not NEW_GC */ data->soe = 0; } } @@ -1303,11 +1439,11 @@ set_extent_start (e, -1); set_extent_end (e, -1); } + + /* But we need to clear all the lists containing extents or + havoc will result. */ + extent_list_delete_all (data->extents); } - - /* But we need to clear all the lists containing extents or - havoc will result. */ - extent_list_delete_all (data->extents); soe_invalidate (object); } } @@ -1322,12 +1458,16 @@ void uninit_buffer_extents (struct buffer *b) { +#ifndef NEW_GC struct extent_info *data = XEXTENT_INFO (b->extent_info); +#endif /* not NEW_GC */ /* Don't destroy the extents here -- there may still be children extents pointing to the extents. */ detach_all_extents (wrap_buffer (b)); +#ifndef NEW_GC finalize_extent_info (data, 0); +#endif /* not NEW_GC */ } /* Retrieve the extent list that an extent is a member of; the @@ -1645,18 +1785,25 @@ static struct stack_of_extents * allocate_soe (void) { +#ifdef NEW_GC + struct stack_of_extents *soe = + alloc_lrecord_type (struct stack_of_extents, &lrecord_stack_of_extents); +#else /* not NEW_GC */ struct stack_of_extents *soe = xnew_and_zero (struct stack_of_extents); +#endif /* not NEW_GC */ soe->extents = allocate_extent_list (); soe->pos = -1; return soe; } +#ifndef NEW_GC static void free_soe (struct stack_of_extents *soe) { free_extent_list (soe->extents); xfree (soe, struct stack_of_extents *); } +#endif /* not NEW_GC */ /* ------------------------------- */ /* other primitives */ @@ -1765,7 +1912,7 @@ if (NILP (property) ? !NILP (Fextent_property (wrap_extent (extent), Qsyntax_table, Qnil)) : EQ (property, Qsyntax_table)) - signal_syntax_table_extent_changed (extent); + signal_syntax_cache_extent_changed (extent); } /* Make note that a change has happened in EXTENT. The change was either @@ -3313,7 +3460,7 @@ return Fextent_properties (obj); } -DEFINE_BASIC_LISP_OBJECT_WITH_PROPS ("extent", extent, +DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT_WITH_PROPS ("extent", extent, mark_extent, print_extent, /* NOTE: If you declare a @@ -7293,6 +7440,13 @@ INIT_LISP_OBJECT (extent); INIT_LISP_OBJECT (extent_info); INIT_LISP_OBJECT (extent_auxiliary); +#ifdef NEW_GC + INIT_LISP_OBJECT (gap_array_marker); + INIT_LISP_OBJECT (gap_array); + INIT_LISP_OBJECT (extent_list_marker); + INIT_LISP_OBJECT (extent_list); + INIT_LISP_OBJECT (stack_of_extents); +#endif /* NEW_GC */ DEFSYMBOL (Qextentp); DEFSYMBOL (Qextent_live_p);