aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2007-09-29 20:55:05 +0000
committerStefan Monnier2007-09-29 20:55:05 +0000
commitb9466edba14f4158ce1dd182b43973b37da98093 (patch)
tree8c9d50997ec8c2c35fdf5a1ef34c0ea4f4a8461a /src
parent9c545a55349f4edc19da0fa54e1e3f822ce04b61 (diff)
downloademacs-b9466edba14f4158ce1dd182b43973b37da98093.tar.gz
emacs-b9466edba14f4158ce1dd182b43973b37da98093.zip
(DECL_ALIGN, USE_LSB_TAG): Move logic to before definition of
Lisp elements such as tags. (XHASH): New macro. (EQ): Use it. (SREF, SSET, STRING_COPYIN): Use SDATA. (VOID_TO_LISP, CVOID_TO_LISP, LISP_TO_VOID, LISP_TO_CVOID): Remove.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/lisp.h167
2 files changed, 81 insertions, 93 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0d6fadaefec..d91aa11e9dd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
12007-09-29 Stefan Monnier <monnier@iro.umontreal.ca> 12007-09-29 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * lisp.h (DECL_ALIGN, USE_LSB_TAG): Move logic to before definition of
4 Lisp elements such as tags.
5 (XHASH): New macro.
6 (EQ): Use it.
7 (SREF, SSET, STRING_COPYIN): Use SDATA.
8 (VOID_TO_LISP, CVOID_TO_LISP, LISP_TO_VOID, LISP_TO_CVOID): Remove.
9
3 * alloc.c (mark_terminal): Remove left-over declaration. 10 * alloc.c (mark_terminal): Remove left-over declaration.
4 (enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE. 11 (enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
5 (allocate_vectorlike): Remove type argument. Adjust callers. 12 (allocate_vectorlike): Remove type argument. Adjust callers.
diff --git a/src/lisp.h b/src/lisp.h
index 65ea46fae1f..b30af269508 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -113,6 +113,57 @@ extern void die P_((const char *, const char *, int)) NO_RETURN;
113#define eassert(cond) CHECK(cond,"assertion failed") 113#define eassert(cond) CHECK(cond,"assertion failed")
114#endif 114#endif
115#endif /* ENABLE_CHECKING */ 115#endif /* ENABLE_CHECKING */
116
117/***** Select the tagging scheme. *****/
118/* There are basically two options that control the tagging scheme:
119 - NO_UNION_TYPE says that Lisp_Object should be an integer instead
120 of a union.
121 - USE_LSB_TAG means that we can assume the least 3 bits of pointers are
122 always 0, and we can thus use them to hold tag bits, without
123 restricting our addressing space.
124
125 If USE_LSB_TAG is not set, then we use the top 3 bits for tagging, thus
126 restricting our possible address range. Currently USE_LSB_TAG is not
127 allowed together with a union. This is not due to any fundamental
128 technical (or political ;-) problem: nobody wrote the code to do it yet.
129
130 USE_LSB_TAG not only requires the least 3 bits of pointers returned by
131 malloc to be 0 but also needs to be able to impose a mult-of-8 alignment
132 on the few static Lisp_Objects used: all the defsubr as well
133 as the two special buffers buffer_defaults and buffer_local_symbols. */
134
135/* First, try and define DECL_ALIGN(type,var) which declares a static
136 variable VAR of type TYPE with the added requirement that it be
137 TYPEBITS-aligned. */
138#ifndef NO_DECL_ALIGN
139# ifndef DECL_ALIGN
140/* What compiler directive should we use for non-gcc compilers? -stef */
141# if defined (__GNUC__)
142# define DECL_ALIGN(type, var) \
143 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
144# endif
145# endif
146#endif
147
148/* Let's USE_LSB_TAG on systems where we know malloc returns mult-of-8. */
149#if defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ || defined MAC_OSX
150/* We also need to be able to specify mult-of-8 alignment on static vars. */
151# if defined DECL_ALIGN
152/* We currently do not support USE_LSB_TAG with a union Lisp_Object. */
153# if defined NO_UNION_TYPE
154# define USE_LSB_TAG
155# endif
156# endif
157#endif
158
159/* If we cannot use 8-byte alignment, make DECL_ALIGN a no-op. */
160#ifndef DECL_ALIGN
161# ifdef USE_LSB_TAG
162# error "USE_LSB_TAG used without defining DECL_ALIGN"
163# endif
164# define DECL_ALIGN(type, var) type var
165#endif
166
116 167
117/* Define the fundamental Lisp data structures. */ 168/* Define the fundamental Lisp data structures. */
118 169
@@ -194,7 +245,7 @@ union Lisp_Object
194 { 245 {
195 /* Used for comparing two Lisp_Objects; 246 /* Used for comparing two Lisp_Objects;
196 also, positive integers can be accessed fast this way. */ 247 also, positive integers can be accessed fast this way. */
197 EMACS_INT i; 248 EMACS_UINT i;
198 249
199 struct 250 struct
200 { 251 {
@@ -216,7 +267,7 @@ union Lisp_Object
216 { 267 {
217 /* Used for comparing two Lisp_Objects; 268 /* Used for comparing two Lisp_Objects;
218 also, positive integers can be accessed fast this way. */ 269 also, positive integers can be accessed fast this way. */
219 EMACS_INT i; 270 EMACS_UINT i;
220 271
221 struct 272 struct
222 { 273 {
@@ -247,12 +298,10 @@ LISP_MAKE_RVALUE (Lisp_Object o)
247#define LISP_MAKE_RVALUE(o) (o) 298#define LISP_MAKE_RVALUE(o) (o)
248#endif 299#endif
249 300
250#endif /* NO_UNION_TYPE */ 301#else /* NO_UNION_TYPE */
251
252 302
253/* If union type is not wanted, define Lisp_Object as just a number. */ 303/* If union type is not wanted, define Lisp_Object as just a number. */
254 304
255#ifdef NO_UNION_TYPE
256typedef EMACS_INT Lisp_Object; 305typedef EMACS_INT Lisp_Object;
257#define LISP_MAKE_RVALUE(o) (0+(o)) 306#define LISP_MAKE_RVALUE(o) (0+(o))
258#endif /* NO_UNION_TYPE */ 307#endif /* NO_UNION_TYPE */
@@ -310,63 +359,15 @@ enum pvec_type
310 of bool vectors. This should not vary across implementations. */ 359 of bool vectors. This should not vary across implementations. */
311#define BOOL_VECTOR_BITS_PER_CHAR 8 360#define BOOL_VECTOR_BITS_PER_CHAR 8
312 361
313/***** Select the tagging scheme. *****/
314/* There are basically two options that control the tagging scheme:
315 - NO_UNION_TYPE says that Lisp_Object should be an integer instead
316 of a union.
317 - USE_LSB_TAG means that we can assume the least 3 bits of pointers are
318 always 0, and we can thus use them to hold tag bits, without
319 restricting our addressing space.
320
321 If USE_LSB_TAG is not set, then we use the top 3 bits for tagging, thus
322 restricting our possible address range. Currently USE_LSB_TAG is not
323 allowed together with a union. This is not due to any fundamental
324 technical (or political ;-) problem: nobody wrote the code to do it yet.
325
326 USE_LSB_TAG not only requires the least 3 bits of pointers returned by
327 malloc to be 0 but also needs to be able to impose a mult-of-8 alignment
328 on the few static Lisp_Objects used: all the defsubr as well
329 as the two special buffers buffer_defaults and buffer_local_symbols. */
330
331/* First, try and define DECL_ALIGN(type,var) which declares a static
332 variable VAR of type TYPE with the added requirement that it be
333 TYPEBITS-aligned. */
334#ifndef NO_DECL_ALIGN
335# ifndef DECL_ALIGN
336/* What compiler directive should we use for non-gcc compilers? -stef */
337# if defined (__GNUC__)
338# define DECL_ALIGN(type, var) \
339 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
340# endif
341# endif
342#endif
343
344/* Let's USE_LSB_TAG on systems where we know malloc returns mult-of-8. */
345#if defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ || defined MAC_OSX
346/* We also need to be able to specify mult-of-8 alignment on static vars. */
347# if defined DECL_ALIGN
348/* We currently do not support USE_LSB_TAG with a union Lisp_Object. */
349# if defined NO_UNION_TYPE
350# define USE_LSB_TAG
351# endif
352# endif
353#endif
354
355/* If we cannot use 8-byte alignment, make DECL_ALIGN a no-op. */
356#ifndef DECL_ALIGN
357# ifdef USE_LSB_TAG
358# error "USE_LSB_TAG used without defining DECL_ALIGN"
359# endif
360# define DECL_ALIGN(type, var) type var
361#endif
362
363
364/* These macros extract various sorts of values from a Lisp_Object. 362/* These macros extract various sorts of values from a Lisp_Object.
365 For example, if tem is a Lisp_Object whose type is Lisp_Cons, 363 For example, if tem is a Lisp_Object whose type is Lisp_Cons,
366 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */ 364 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
367 365
368#ifdef NO_UNION_TYPE 366#ifdef NO_UNION_TYPE
369 367
368/* Return a perfect hash of the Lisp_Object representation. */
369#define XHASH(a) (a)
370
370#ifdef USE_LSB_TAG 371#ifdef USE_LSB_TAG
371 372
372#define TYPEMASK ((((EMACS_INT) 1) << GCTYPEBITS) - 1) 373#define TYPEMASK ((((EMACS_INT) 1) << GCTYPEBITS) - 1)
@@ -428,10 +429,10 @@ enum pvec_type
428 429
429#endif /* not USE_LSB_TAG */ 430#endif /* not USE_LSB_TAG */
430 431
431#define EQ(x, y) ((x) == (y))
432
433#else /* not NO_UNION_TYPE */ 432#else /* not NO_UNION_TYPE */
434 433
434#define XHASH(a) ((a).i)
435
435#define XTYPE(a) ((enum Lisp_Type) (a).u.type) 436#define XTYPE(a) ((enum Lisp_Type) (a).u.type)
436 437
437/* For integers known to be positive, XFASTINT provides fast retrieval 438/* For integers known to be positive, XFASTINT provides fast retrieval
@@ -460,10 +461,10 @@ enum pvec_type
460extern Lisp_Object make_number P_ ((EMACS_INT)); 461extern Lisp_Object make_number P_ ((EMACS_INT));
461#endif 462#endif
462 463
463#define EQ(x, y) ((x).i == (y).i)
464
465#endif /* NO_UNION_TYPE */ 464#endif /* NO_UNION_TYPE */
466 465
466#define EQ(x, y) (XHASH (x) == XHASH (y))
467
467/* During garbage collection, XGCTYPE must be used for extracting types 468/* During garbage collection, XGCTYPE must be used for extracting types
468 so that the mark bit is ignored. XMARKBIT accesses the markbit. 469 so that the mark bit is ignored. XMARKBIT accesses the markbit.
469 Markbits are used only in particular slots of particular structure types. 470 Markbits are used only in particular slots of particular structure types.
@@ -583,9 +584,9 @@ extern size_t pure_size;
583 584
584/* Convenience macros for dealing with Lisp strings. */ 585/* Convenience macros for dealing with Lisp strings. */
585 586
586#define SREF(string, index) (XSTRING (string)->data[index] + 0)
587#define SSET(string, index, new) (XSTRING (string)->data[index] = (new))
588#define SDATA(string) (XSTRING (string)->data + 0) 587#define SDATA(string) (XSTRING (string)->data + 0)
588#define SREF(string, index) (SDATA (string)[index] + 0)
589#define SSET(string, index, new) (SDATA (string)[index] = (new))
589#define SCHARS(string) (XSTRING (string)->size + 0) 590#define SCHARS(string) (XSTRING (string)->size + 0)
590#define SBYTES(string) (STRING_BYTES (XSTRING (string)) + 0) 591#define SBYTES(string) (STRING_BYTES (XSTRING (string)) + 0)
591 592
@@ -593,7 +594,7 @@ extern size_t pure_size;
593 (XSTRING (string)->size = (newsize)) 594 (XSTRING (string)->size = (newsize))
594 595
595#define STRING_COPYIN(string, index, new, count) \ 596#define STRING_COPYIN(string, index, new, count) \
596 bcopy (new, XSTRING (string)->data + index, count) 597 bcopy (new, SDATA (string) + index, count)
597 598
598/* Type checking. */ 599/* Type checking. */
599 600
@@ -1127,8 +1128,16 @@ struct Lisp_Marker
1127 /* 1 means normal insertion at the marker's position 1128 /* 1 means normal insertion at the marker's position
1128 leaves the marker after the inserted text. */ 1129 leaves the marker after the inserted text. */
1129 unsigned int insertion_type : 1; 1130 unsigned int insertion_type : 1;
1130 /* This is the buffer that the marker points into, 1131 /* This is the buffer that the marker points into, or 0 if it points nowhere.
1131 or 0 if it points nowhere. */ 1132 Note: a chain of markers can contain markers pointing into different
1133 buffers (the chain is per buffer_text rather than per buffer, so it's
1134 shared between indirect buffers). */
1135 /* This is used for (other than NULL-checking):
1136 - Fmarker_buffer
1137 - Fset_marker: check eq(oldbuf, newbuf) to avoid unchain+rechain.
1138 - unchain_marker: to find the list from which to unchain.
1139 - Fkill_buffer: to unchain the markers of current indirect buffer.
1140 */
1132 struct buffer *buffer; 1141 struct buffer *buffer;
1133 1142
1134 /* The remaining fields are meaningless in a marker that 1143 /* The remaining fields are meaningless in a marker that
@@ -1384,34 +1393,6 @@ typedef unsigned char UCHAR;
1384 We need one more byte for string terminator `\0'. */ 1393 We need one more byte for string terminator `\0'. */
1385#define KEY_DESCRIPTION_SIZE ((2 * 6) + 1 + (CHARACTERBITS / 3) + 1 + 1) 1394#define KEY_DESCRIPTION_SIZE ((2 * 6) + 1 + (CHARACTERBITS / 3) + 1 + 1)
1386 1395
1387#ifdef USE_X_TOOLKIT
1388#ifdef NO_UNION_TYPE
1389/* Use this for turning a (void *) into a Lisp_Object, as when the
1390 Lisp_Object is passed into a toolkit callback function. */
1391#define VOID_TO_LISP(larg,varg) \
1392 do { ((larg) = ((Lisp_Object) (varg))); } while (0)
1393#define CVOID_TO_LISP VOID_TO_LISP
1394
1395/* Use this for turning a Lisp_Object into a (void *), as when the
1396 Lisp_Object is passed into a toolkit callback function. */
1397#define LISP_TO_VOID(larg) ((void *) (larg))
1398#define LISP_TO_CVOID(varg) ((const void *) (larg))
1399
1400#else /* not NO_UNION_TYPE */
1401/* Use this for turning a (void *) into a Lisp_Object, as when the
1402 Lisp_Object is passed into a toolkit callback function. */
1403#define VOID_TO_LISP(larg,varg) \
1404 do { ((larg).v = (void *) (varg)); } while (0)
1405#define CVOID_TO_LISP(larg,varg) \
1406 do { ((larg).cv = (const void *) (varg)); } while (0)
1407
1408/* Use this for turning a Lisp_Object into a (void *), as when the
1409 Lisp_Object is passed into a toolkit callback function. */
1410#define LISP_TO_VOID(larg) ((larg).v)
1411#define LISP_TO_CVOID(larg) ((larg).cv)
1412#endif /* not NO_UNION_TYPE */
1413#endif /* USE_X_TOOLKIT */
1414
1415 1396
1416/* The glyph datatype, used to represent characters on the display. */ 1397/* The glyph datatype, used to represent characters on the display. */
1417 1398