Mercurial > emacs
comparison src/alloc.c @ 10389:162b3e6c4610
(DONT_COPY_FLAG): New bit flag.
(mark_object, gc_sweep, compact_strings): Use it.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Wed, 11 Jan 1995 01:19:09 +0000 |
| parents | ef58c7a5a4d6 |
| children | c121703d35c7 |
comparison
equal
deleted
inserted
replaced
| 10388:0ae5926bdee7 | 10389:162b3e6c4610 |
|---|---|
| 104 /* Maximum amount of C stack to save when a GC happens. */ | 104 /* Maximum amount of C stack to save when a GC happens. */ |
| 105 | 105 |
| 106 #ifndef MAX_SAVE_STACK | 106 #ifndef MAX_SAVE_STACK |
| 107 #define MAX_SAVE_STACK 16000 | 107 #define MAX_SAVE_STACK 16000 |
| 108 #endif | 108 #endif |
| 109 | |
| 110 /* Define DONT_COPY_FLAG to be the bit in a small string that was placed | |
| 111 in the low bit of the size field when marking small strings. */ | |
| 112 #ifndef DONT_COPY_FLAG | |
| 113 #define DONT_COPY_FLAG PSEUDO_VECTOR_FLAG | |
| 114 #endif /* no DONT_COPY_FLAG */ | |
| 109 | 115 |
| 110 /* Buffer in which we save a copy of the C stack at each GC. */ | 116 /* Buffer in which we save a copy of the C stack at each GC. */ |
| 111 | 117 |
| 112 char *stack_copy; | 118 char *stack_copy; |
| 113 int stack_copy_size; | 119 int stack_copy_size; |
| 1512 XSETFASTINT (*objptr, ptr->size); | 1518 XSETFASTINT (*objptr, ptr->size); |
| 1513 XMARK (*objptr); | 1519 XMARK (*objptr); |
| 1514 } | 1520 } |
| 1515 else | 1521 else |
| 1516 XSETFASTINT (*objptr, ptr->size); | 1522 XSETFASTINT (*objptr, ptr->size); |
| 1517 if ((EMACS_INT) objptr & 1) abort (); | 1523 |
| 1524 if ((EMACS_INT) objptr & DONT_COPY_FLAG) | |
| 1525 abort (); | |
| 1518 ptr->size = (EMACS_INT) objptr & ~MARKBIT; | 1526 ptr->size = (EMACS_INT) objptr & ~MARKBIT; |
| 1519 if ((EMACS_INT) objptr & MARKBIT) | 1527 if ((EMACS_INT) objptr & MARKBIT) |
| 1520 ptr->size ++; | 1528 ptr->size |= DONT_COPY_FLAG; |
| 1521 } | 1529 } |
| 1522 } | 1530 } |
| 1523 break; | 1531 break; |
| 1524 | 1532 |
| 1525 case Lisp_Vectorlike: | 1533 case Lisp_Vectorlike: |
| 2033 { | 2041 { |
| 2034 s = (struct Lisp_String *) &sb->chars[0]; | 2042 s = (struct Lisp_String *) &sb->chars[0]; |
| 2035 if (s->size & ARRAY_MARK_FLAG) | 2043 if (s->size & ARRAY_MARK_FLAG) |
| 2036 { | 2044 { |
| 2037 ((struct Lisp_String *)(&sb->chars[0]))->size | 2045 ((struct Lisp_String *)(&sb->chars[0]))->size |
| 2038 &= ~ARRAY_MARK_FLAG & ~MARKBIT; | 2046 &= ~ARRAY_MARK_FLAG & ~MARKBIT & ~DONT_COPY_FLAG; |
| 2039 UNMARK_BALANCE_INTERVALS (s->intervals); | 2047 UNMARK_BALANCE_INTERVALS (s->intervals); |
| 2040 total_string_size += ((struct Lisp_String *)(&sb->chars[0]))->size; | 2048 total_string_size += ((struct Lisp_String *)(&sb->chars[0]))->size; |
| 2041 prev = sb, sb = sb->next; | 2049 prev = sb, sb = sb->next; |
| 2042 } | 2050 } |
| 2043 else | 2051 else |
| 2083 register struct Lisp_String *newaddr; | 2091 register struct Lisp_String *newaddr; |
| 2084 register EMACS_INT size = nextstr->size; | 2092 register EMACS_INT size = nextstr->size; |
| 2085 | 2093 |
| 2086 /* NEXTSTR is the old address of the next string. | 2094 /* NEXTSTR is the old address of the next string. |
| 2087 Just skip it if it isn't marked. */ | 2095 Just skip it if it isn't marked. */ |
| 2088 if ((EMACS_UINT) size > STRING_BLOCK_SIZE) | 2096 if (((EMACS_UINT) size & ~DONT_COPY_FLAG) > STRING_BLOCK_SIZE) |
| 2089 { | 2097 { |
| 2090 /* It is marked, so its size field is really a chain of refs. | 2098 /* It is marked, so its size field is really a chain of refs. |
| 2091 Find the end of the chain, where the actual size lives. */ | 2099 Find the end of the chain, where the actual size lives. */ |
| 2092 while ((EMACS_UINT) size > STRING_BLOCK_SIZE) | 2100 while (((EMACS_UINT) size & ~DONT_COPY_FLAG) > STRING_BLOCK_SIZE) |
| 2093 { | 2101 { |
| 2094 if (size & 1) size ^= MARKBIT | 1; | 2102 if (size & DONT_COPY_FLAG) |
| 2103 size ^= MARKBIT | DONT_COPY_FLAG; | |
| 2095 size = *(EMACS_INT *)size & ~MARKBIT; | 2104 size = *(EMACS_INT *)size & ~MARKBIT; |
| 2096 } | 2105 } |
| 2097 | 2106 |
| 2098 total_string_size += size; | 2107 total_string_size += size; |
| 2099 | 2108 |
| 2123 | 2132 |
| 2124 /* Go through NEXTSTR's chain of references | 2133 /* Go through NEXTSTR's chain of references |
| 2125 and make each slot in the chain point to | 2134 and make each slot in the chain point to |
| 2126 the new address of this string. */ | 2135 the new address of this string. */ |
| 2127 size = newaddr->size; | 2136 size = newaddr->size; |
| 2128 while ((EMACS_UINT) size > STRING_BLOCK_SIZE) | 2137 while (((EMACS_UINT) size & ~DONT_COPY_FLAG) > STRING_BLOCK_SIZE) |
| 2129 { | 2138 { |
| 2130 register Lisp_Object *objptr; | 2139 register Lisp_Object *objptr; |
| 2131 if (size & 1) size ^= MARKBIT | 1; | 2140 if (size & DONT_COPY_FLAG) |
| 2141 size ^= MARKBIT | DONT_COPY_FLAG; | |
| 2132 objptr = (Lisp_Object *)size; | 2142 objptr = (Lisp_Object *)size; |
| 2133 | 2143 |
| 2134 size = XFASTINT (*objptr) & ~MARKBIT; | 2144 size = XFASTINT (*objptr) & ~MARKBIT; |
| 2135 if (XMARKBIT (*objptr)) | 2145 if (XMARKBIT (*objptr)) |
| 2136 { | 2146 { |
