aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorJoseph Arceneaux1992-10-02 19:59:42 +0000
committerJoseph Arceneaux1992-10-02 19:59:42 +0000
commitd5e35230b582132c7246f117c118151500cfa595 (patch)
tree2240c60991cb771f3857e47aa42e9905c188472a /src/alloc.c
parent8d4e077b7093e6d58ea94253265d6a3de22f3c9c (diff)
downloademacs-d5e35230b582132c7246f117c118151500cfa595.tar.gz
emacs-d5e35230b582132c7246f117c118151500cfa595.zip
* alloc.c: #include "intervals.h".
(init_intervals, make_interval, mark_interval, mark_interval_tree): New functions conditionally defined. (make_uninit_string): Call INITIALIZE_INTERVAL. (INIT_INTERVALS, UNMARK_BALANCE_INTERVALS, MARK_INTERVAL_TREE): New macros, conditionally defined. (mark_object): Call MARK_INTERVAL_TREE in case Lisp_String. (gc_sweep): If text properties are in use, place all unmarked intervals on the free list. Call UNMARK_BALANCE_INTERVALS on `buffer->intervals' when unmarking `buffer'. (compact_strings): Include INTERVAL_PTR_SIZE in calculation for target of bcopy when relocating strings. (init_alloc_once): Call INIT_INTERVALS. (make_pure_string): Include INTERVAL_PTR_SIZE in calculation of `size'.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c152
1 files changed, 150 insertions, 2 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 9cf149e51d1..aa5e44550d4 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -20,6 +20,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 20
21#include "config.h" 21#include "config.h"
22#include "lisp.h" 22#include "lisp.h"
23#include "intervals.h"
23#include "puresize.h" 24#include "puresize.h"
24#ifndef standalone 25#ifndef standalone
25#include "buffer.h" 26#include "buffer.h"
@@ -176,6 +177,111 @@ xrealloc (block, size)
176 return val; 177 return val;
177} 178}
178 179
180#ifdef USE_TEXT_PROPERTIES
181#define INTERVAL_BLOCK_SIZE \
182 ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval))
183
184struct interval_block
185 {
186 struct interval_block *next;
187 struct interval intervals[INTERVAL_BLOCK_SIZE];
188 };
189
190struct interval_block *interval_block;
191static int interval_block_index;
192
193INTERVAL interval_free_list;
194
195static void
196init_intervals ()
197{
198 interval_block
199 = (struct interval_block *) malloc (sizeof (struct interval_block));
200 interval_block->next = 0;
201 bzero (interval_block->intervals, sizeof interval_block->intervals);
202 interval_block_index = 0;
203 interval_free_list = 0;
204}
205
206#define INIT_INTERVALS init_intervals ()
207
208INTERVAL
209make_interval ()
210{
211 INTERVAL val;
212
213 if (interval_free_list)
214 {
215 val = interval_free_list;
216 interval_free_list = interval_free_list->parent;
217 }
218 else
219 {
220 if (interval_block_index == INTERVAL_BLOCK_SIZE)
221 {
222 register struct interval_block *newi
223 = (struct interval_block *) malloc (sizeof (struct interval_block));
224
225 if (!newi)
226 memory_full ();
227
228 VALIDATE_LISP_STORAGE (newi, sizeof *newi);
229 newi->next = interval_block;
230 interval_block = newi;
231 interval_block_index = 0;
232 }
233 val = &interval_block->intervals[interval_block_index++];
234 }
235 consing_since_gc += sizeof (struct interval);
236 RESET_INTERVAL (val);
237 return val;
238}
239
240static int total_free_intervals, total_intervals;
241
242/* Mark the pointers of one interval. */
243
244static void
245mark_interval (i)
246 register INTERVAL i;
247{
248 if (XMARKBIT (i->plist))
249 abort ();
250 mark_object (&i->plist);
251 XMARK (i->plist);
252}
253
254static void
255mark_interval_tree (tree)
256 register INTERVAL tree;
257{
258 if (XMARKBIT (tree->plist))
259 return;
260
261 traverse_intervals (tree, 1, &mark_interval);
262}
263
264#define MARK_INTERVAL_TREE(i) \
265 { if (!NULL_INTERVAL_P (i)) mark_interval_tree (i); }
266
267#define UNMARK_BALANCE_INTERVALS(i) \
268{ \
269 if (! NULL_INTERVAL_P (i)) \
270 { \
271 XUNMARK ((Lisp_Object) (i->parent)); \
272 i = balance_intervals (i); \
273 } \
274}
275
276#else /* no interval use */
277
278#define INIT_INTERVALS
279
280#define UNMARK_BALANCE_INTERVALS(i)
281#define MARK_INTERVAL_TREE(i)
282
283#endif /* no interval use */
284
179#ifdef LISP_FLOAT_TYPE 285#ifdef LISP_FLOAT_TYPE
180/* Allocation of float cells, just like conses */ 286/* Allocation of float cells, just like conses */
181/* We store float cells inside of float_blocks, allocating a new 287/* We store float cells inside of float_blocks, allocating a new
@@ -741,6 +847,7 @@ make_uninit_string (length)
741 847
742 XSTRING (val)->size = length; 848 XSTRING (val)->size = length;
743 XSTRING (val)->data[length] = 0; 849 XSTRING (val)->data[length] = 0;
850 INITIALIZE_INTERVAL (XSTRING (val), NULL_INTERVAL);
744 851
745 return val; 852 return val;
746} 853}
@@ -833,7 +940,7 @@ make_pure_string (data, length)
833 int length; 940 int length;
834{ 941{
835 register Lisp_Object new; 942 register Lisp_Object new;
836 register int size = sizeof (int) + length + 1; 943 register int size = sizeof (int) + INTERVAL_PTR_SIZE + length + 1;
837 944
838 if (pureptr + size > PURESIZE) 945 if (pureptr + size > PURESIZE)
839 error ("Pure Lisp storage exhausted"); 946 error ("Pure Lisp storage exhausted");
@@ -1302,6 +1409,7 @@ mark_object (objptr)
1302 { 1409 {
1303 register struct Lisp_String *ptr = XSTRING (obj); 1410 register struct Lisp_String *ptr = XSTRING (obj);
1304 1411
1412 MARK_INTERVAL_TREE (ptr->intervals);
1305 if (ptr->size & MARKBIT) 1413 if (ptr->size & MARKBIT)
1306 /* A large string. Just set ARRAY_MARK_FLAG. */ 1414 /* A large string. Just set ARRAY_MARK_FLAG. */
1307 ptr->size |= ARRAY_MARK_FLAG; 1415 ptr->size |= ARRAY_MARK_FLAG;
@@ -1488,6 +1596,8 @@ mark_buffer (buf)
1488 mark_object (&buffer->name); 1596 mark_object (&buffer->name);
1489 XMARK (buffer->name); 1597 XMARK (buffer->name);
1490 1598
1599 MARK_INTERVAL_TREE (buffer->intervals);
1600
1491#if 0 1601#if 0
1492 mark_object (buffer->syntax_table); 1602 mark_object (buffer->syntax_table);
1493 1603
@@ -1584,6 +1694,40 @@ gc_sweep ()
1584 } 1694 }
1585#endif /* LISP_FLOAT_TYPE */ 1695#endif /* LISP_FLOAT_TYPE */
1586 1696
1697#ifdef USE_TEXT_PROPERTIES
1698 /* Put all unmarked intervals on free list */
1699 {
1700 register struct interval_block *iblk;
1701 register int lim = interval_block_index;
1702 register int num_free = 0, num_used = 0;
1703
1704 interval_free_list = 0;
1705
1706 for (iblk = interval_block; iblk; iblk = iblk->next)
1707 {
1708 register int i;
1709
1710 for (i = 0; i < lim; i++)
1711 {
1712 if (! XMARKBIT (iblk->intervals[i].plist))
1713 {
1714 iblk->intervals[i].parent = interval_free_list;
1715 interval_free_list = &iblk->intervals[i];
1716 num_free++;
1717 }
1718 else
1719 {
1720 num_used++;
1721 XUNMARK (iblk->intervals[i].plist);
1722 }
1723 }
1724 lim = INTERVAL_BLOCK_SIZE;
1725 }
1726 total_intervals = num_used;
1727 total_free_intervals = num_free;
1728 }
1729#endif /* USE_TEXT_PROPERTIES */
1730
1587 /* Put all unmarked symbols on free list */ 1731 /* Put all unmarked symbols on free list */
1588 { 1732 {
1589 register struct symbol_block *sblk; 1733 register struct symbol_block *sblk;
@@ -1670,6 +1814,7 @@ gc_sweep ()
1670 else 1814 else
1671 { 1815 {
1672 XUNMARK (buffer->name); 1816 XUNMARK (buffer->name);
1817 UNMARK_BALANCE_INTERVALS (buffer->intervals);
1673 1818
1674#if 0 1819#if 0
1675 /* Each `struct Lisp_String *' was turned into a Lisp_Object 1820 /* Each `struct Lisp_String *' was turned into a Lisp_Object
@@ -1805,7 +1950,8 @@ compact_strings ()
1805 1950
1806 /* Copy the string itself to the new place. */ 1951 /* Copy the string itself to the new place. */
1807 if (nextstr != newaddr) 1952 if (nextstr != newaddr)
1808 bcopy (nextstr, newaddr, size + 1 + sizeof (int)); 1953 bcopy (nextstr, newaddr, size + 1 + sizeof (int)
1954 + INTERVAL_PTR_SIZE);
1809 1955
1810 /* Go through NEXTSTR's chain of references 1956 /* Go through NEXTSTR's chain of references
1811 and make each slot in the chain point to 1957 and make each slot in the chain point to
@@ -1882,6 +2028,8 @@ init_alloc_once ()
1882#ifdef LISP_FLOAT_TYPE 2028#ifdef LISP_FLOAT_TYPE
1883 init_float (); 2029 init_float ();
1884#endif /* LISP_FLOAT_TYPE */ 2030#endif /* LISP_FLOAT_TYPE */
2031 INIT_INTERVALS;
2032
1885 ignore_warnings = 0; 2033 ignore_warnings = 0;
1886 gcprolist = 0; 2034 gcprolist = 0;
1887 staticidx = 0; 2035 staticidx = 0;