aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorStefan Monnier2011-02-21 17:34:51 -0500
committerStefan Monnier2011-02-21 17:34:51 -0500
commitf619ad4ca2ce943d53589469c010e451afab97dd (patch)
treee1b71f79518372ecab4c677ae948504450d8bf5d /src/bytecode.c
parenta647cb26b695a542e3a546104afdf4c7c47eb061 (diff)
parent9f8370e63f65f76887b319ab6a0368d4a332777c (diff)
downloademacs-f619ad4ca2ce943d53589469c010e451afab97dd.tar.gz
emacs-f619ad4ca2ce943d53589469c010e451afab97dd.zip
Merge from trunk
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index b2e9e3c5b56..639c543dbf9 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -51,7 +51,7 @@ by Hallvard:
51 * 51 *
52 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram. 52 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
53 */ 53 */
54#define BYTE_CODE_SAFE 54/* #define BYTE_CODE_SAFE 1 */
55/* #define BYTE_CODE_METER */ 55/* #define BYTE_CODE_METER */
56 56
57 57
@@ -236,6 +236,8 @@ extern Lisp_Object Qand_optional, Qand_rest;
236#define Bconstant 0300 236#define Bconstant 0300
237#define CONSTANTLIM 0100 237#define CONSTANTLIM 0100
238 238
239/* Whether to maintain a `top' and `bottom' field in the stack frame. */
240#define BYTE_MAINTAIN_TOP (BYTE_CODE_SAFE || BYTE_MARK_STACK)
239 241
240/* Structure describing a value stack used during byte-code execution 242/* Structure describing a value stack used during byte-code execution
241 in Fbyte_code. */ 243 in Fbyte_code. */
@@ -248,7 +250,9 @@ struct byte_stack
248 250
249 /* Top and bottom of stack. The bottom points to an area of memory 251 /* Top and bottom of stack. The bottom points to an area of memory
250 allocated with alloca in Fbyte_code. */ 252 allocated with alloca in Fbyte_code. */
253#if BYTE_MAINTAIN_TOP
251 Lisp_Object *top, *bottom; 254 Lisp_Object *top, *bottom;
255#endif
252 256
253 /* The string containing the byte-code, and its current address. 257 /* The string containing the byte-code, and its current address.
254 Storing this here protects it from GC because mark_byte_stack 258 Storing this here protects it from GC because mark_byte_stack
@@ -275,6 +279,7 @@ struct byte_stack *byte_stack_list;
275 279
276/* Mark objects on byte_stack_list. Called during GC. */ 280/* Mark objects on byte_stack_list. Called during GC. */
277 281
282#if BYTE_MARK_STACK
278void 283void
279mark_byte_stack (void) 284mark_byte_stack (void)
280{ 285{
@@ -299,7 +304,7 @@ mark_byte_stack (void)
299 mark_object (stack->constants); 304 mark_object (stack->constants);
300 } 305 }
301} 306}
302 307#endif
303 308
304/* Unmark objects in the stacks on byte_stack_list. Relocate program 309/* Unmark objects in the stacks on byte_stack_list. Relocate program
305 counters. Called when GC has completed. */ 310 counters. Called when GC has completed. */
@@ -353,8 +358,13 @@ unmark_byte_stack (void)
353/* Actions that must be performed before and after calling a function 358/* Actions that must be performed before and after calling a function
354 that might GC. */ 359 that might GC. */
355 360
361#if !BYTE_MAINTAIN_TOP
362#define BEFORE_POTENTIAL_GC() ((void)0)
363#define AFTER_POTENTIAL_GC() ((void)0)
364#else
356#define BEFORE_POTENTIAL_GC() stack.top = top 365#define BEFORE_POTENTIAL_GC() stack.top = top
357#define AFTER_POTENTIAL_GC() stack.top = NULL 366#define AFTER_POTENTIAL_GC() stack.top = NULL
367#endif
358 368
359/* Garbage collect if we have consed enough since the last time. 369/* Garbage collect if we have consed enough since the last time.
360 We do this at every branch, to avoid loops that never GC. */ 370 We do this at every branch, to avoid loops that never GC. */
@@ -478,10 +488,13 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
478 stack.byte_string = bytestr; 488 stack.byte_string = bytestr;
479 stack.pc = stack.byte_string_start = SDATA (bytestr); 489 stack.pc = stack.byte_string_start = SDATA (bytestr);
480 stack.constants = vector; 490 stack.constants = vector;
481 stack.bottom = (Lisp_Object *) alloca (XFASTINT (maxdepth) 491 top = (Lisp_Object *) alloca (XFASTINT (maxdepth)
482 * sizeof (Lisp_Object)); 492 * sizeof (Lisp_Object));
483 top = stack.bottom - 1; 493#if BYTE_MAINTAIN_TOP
494 stack.bottom = top;
484 stack.top = NULL; 495 stack.top = NULL;
496#endif
497 top -= 1;
485 stack.next = byte_stack_list; 498 stack.next = byte_stack_list;
486 byte_stack_list = &stack; 499 byte_stack_list = &stack;
487 500
@@ -1468,7 +1481,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1468 CHECK_CHARACTER (TOP); 1481 CHECK_CHARACTER (TOP);
1469 AFTER_POTENTIAL_GC (); 1482 AFTER_POTENTIAL_GC ();
1470 c = XFASTINT (TOP); 1483 c = XFASTINT (TOP);
1471 if (NILP (current_buffer->enable_multibyte_characters)) 1484 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
1472 MAKE_CHAR_MULTIBYTE (c); 1485 MAKE_CHAR_MULTIBYTE (c);
1473 XSETFASTINT (TOP, syntax_code_spec[(int) SYNTAX (c)]); 1486 XSETFASTINT (TOP, syntax_code_spec[(int) SYNTAX (c)]);
1474 } 1487 }