diff options
| author | Stefan Monnier | 2011-02-17 21:07:36 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2011-02-17 21:07:36 -0500 |
| commit | b286858c7a0d5dafa302b9e88970c13385358a6a (patch) | |
| tree | 37aca1554bbef09ef09256d7162e619222dbb4a1 /src/bytecode.c | |
| parent | 3804652098c7c8824f332e92846a3b8896b9e683 (diff) | |
| download | emacs-b286858c7a0d5dafa302b9e88970c13385358a6a.tar.gz emacs-b286858c7a0d5dafa302b9e88970c13385358a6a.zip | |
Don't GC-scan stack data redundantly.
* src/alloc.c (Fgarbage_collect): When using stack scanning, don't
redundantly scan byte-code stacks, catchlist, and handlerlist.
* src/bytecode.c (BYTE_MAINTAIN_TOP): New macros.
(struct byte_stack): Only define `top' and `bottom' if used.
(mark_byte_stack): Only define if used.
(BEFORE_POTENTIAL_GC, AFTER_POTENTIAL_GC): Nullify if BYTE_MAINTAIN_TOP
is not set.
(Fbyte_code): Don't set `bottom' unless BYTE_MAINTAIN_TOP is set.
* src/lisp.h (BYTE_MARK_STACK): New macro.
(mark_byte_stack): Only declare if BYTE_MARK_STACK is set.
* src/term.c (OUTPUT_IF): Use OUTPUT.
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index a88df080c5a..cf4a1fc225f 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -229,6 +229,8 @@ Lisp_Object Qbytecode; | |||
| 229 | #define Bconstant 0300 | 229 | #define Bconstant 0300 |
| 230 | #define CONSTANTLIM 0100 | 230 | #define CONSTANTLIM 0100 |
| 231 | 231 | ||
| 232 | /* Whether to maintain a `top' and `bottom' field in the stack frame. */ | ||
| 233 | #define BYTE_MAINTAIN_TOP (BYTE_CODE_SAFE || BYTE_MARK_STACK) | ||
| 232 | 234 | ||
| 233 | /* Structure describing a value stack used during byte-code execution | 235 | /* Structure describing a value stack used during byte-code execution |
| 234 | in Fbyte_code. */ | 236 | in Fbyte_code. */ |
| @@ -241,7 +243,9 @@ struct byte_stack | |||
| 241 | 243 | ||
| 242 | /* Top and bottom of stack. The bottom points to an area of memory | 244 | /* Top and bottom of stack. The bottom points to an area of memory |
| 243 | allocated with alloca in Fbyte_code. */ | 245 | allocated with alloca in Fbyte_code. */ |
| 246 | #if BYTE_MAINTAIN_TOP | ||
| 244 | Lisp_Object *top, *bottom; | 247 | Lisp_Object *top, *bottom; |
| 248 | #endif | ||
| 245 | 249 | ||
| 246 | /* The string containing the byte-code, and its current address. | 250 | /* The string containing the byte-code, and its current address. |
| 247 | Storing this here protects it from GC because mark_byte_stack | 251 | Storing this here protects it from GC because mark_byte_stack |
| @@ -268,6 +272,7 @@ struct byte_stack *byte_stack_list; | |||
| 268 | 272 | ||
| 269 | /* Mark objects on byte_stack_list. Called during GC. */ | 273 | /* Mark objects on byte_stack_list. Called during GC. */ |
| 270 | 274 | ||
| 275 | #if BYTE_MARK_STACK | ||
| 271 | void | 276 | void |
| 272 | mark_byte_stack (void) | 277 | mark_byte_stack (void) |
| 273 | { | 278 | { |
| @@ -292,7 +297,7 @@ mark_byte_stack (void) | |||
| 292 | mark_object (stack->constants); | 297 | mark_object (stack->constants); |
| 293 | } | 298 | } |
| 294 | } | 299 | } |
| 295 | 300 | #endif | |
| 296 | 301 | ||
| 297 | /* Unmark objects in the stacks on byte_stack_list. Relocate program | 302 | /* Unmark objects in the stacks on byte_stack_list. Relocate program |
| 298 | counters. Called when GC has completed. */ | 303 | counters. Called when GC has completed. */ |
| @@ -346,8 +351,13 @@ unmark_byte_stack (void) | |||
| 346 | /* Actions that must be performed before and after calling a function | 351 | /* Actions that must be performed before and after calling a function |
| 347 | that might GC. */ | 352 | that might GC. */ |
| 348 | 353 | ||
| 354 | #if !BYTE_MAINTAIN_TOP | ||
| 355 | #define BEFORE_POTENTIAL_GC() ((void)0) | ||
| 356 | #define AFTER_POTENTIAL_GC() ((void)0) | ||
| 357 | #else | ||
| 349 | #define BEFORE_POTENTIAL_GC() stack.top = top | 358 | #define BEFORE_POTENTIAL_GC() stack.top = top |
| 350 | #define AFTER_POTENTIAL_GC() stack.top = NULL | 359 | #define AFTER_POTENTIAL_GC() stack.top = NULL |
| 360 | #endif | ||
| 351 | 361 | ||
| 352 | /* Garbage collect if we have consed enough since the last time. | 362 | /* Garbage collect if we have consed enough since the last time. |
| 353 | We do this at every branch, to avoid loops that never GC. */ | 363 | We do this at every branch, to avoid loops that never GC. */ |
| @@ -447,10 +457,13 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 447 | stack.byte_string = bytestr; | 457 | stack.byte_string = bytestr; |
| 448 | stack.pc = stack.byte_string_start = SDATA (bytestr); | 458 | stack.pc = stack.byte_string_start = SDATA (bytestr); |
| 449 | stack.constants = vector; | 459 | stack.constants = vector; |
| 450 | stack.bottom = (Lisp_Object *) alloca (XFASTINT (maxdepth) | 460 | top = (Lisp_Object *) alloca (XFASTINT (maxdepth) |
| 451 | * sizeof (Lisp_Object)); | 461 | * sizeof (Lisp_Object)); |
| 452 | top = stack.bottom - 1; | 462 | #if BYTE_MAINTAIN_TOP |
| 463 | stack.bottom = top; | ||
| 453 | stack.top = NULL; | 464 | stack.top = NULL; |
| 465 | #endif | ||
| 466 | top -= 1; | ||
| 454 | stack.next = byte_stack_list; | 467 | stack.next = byte_stack_list; |
| 455 | byte_stack_list = &stack; | 468 | byte_stack_list = &stack; |
| 456 | 469 | ||