diff options
| author | Richard M. Stallman | 1996-12-07 21:12:17 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-12-07 21:12:17 +0000 |
| commit | 147268711e45b597d710d4daf5da209ca6175a8a (patch) | |
| tree | 5def9bb8612cf2cbef4143a6e81381143ff83702 /src/bytecode.c | |
| parent | 8abd035b441792eafa46e3b40e9b0bb1f305dab9 (diff) | |
| download | emacs-147268711e45b597d710d4daf5da209ca6175a8a.tar.gz emacs-147268711e45b597d710d4daf5da209ca6175a8a.zip | |
(MAYBE_GC): New macro.
(Fbyte_code): Use MAYBE_GC in every goto opcode.
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index ae290c27352..92406a78c32 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -251,6 +251,13 @@ Lisp_Object Qbytecode; | |||
| 251 | 251 | ||
| 252 | #define TOP (*stackp) | 252 | #define TOP (*stackp) |
| 253 | 253 | ||
| 254 | /* Garbage collect if we have consed enough since the last time. | ||
| 255 | We do this at every branch, to avoid loops that never GC. */ | ||
| 256 | |||
| 257 | #define MAYBE_GC() \ | ||
| 258 | if (consing_since_gc > gc_cons_threshold) \ | ||
| 259 | Fgarbage_collect (); | ||
| 260 | |||
| 254 | DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0, | 261 | DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0, |
| 255 | "Function used internally in byte-compiled code.\n\ | 262 | "Function used internally in byte-compiled code.\n\ |
| 256 | The first argument, BYTESTR, is a string of byte code;\n\ | 263 | The first argument, BYTESTR, is a string of byte code;\n\ |
| @@ -431,12 +438,14 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 431 | break; | 438 | break; |
| 432 | 439 | ||
| 433 | case Bgoto: | 440 | case Bgoto: |
| 441 | MAYBE_GC (); | ||
| 434 | QUIT; | 442 | QUIT; |
| 435 | op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ | 443 | op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ |
| 436 | pc = XSTRING (string_saved)->data + op; | 444 | pc = XSTRING (string_saved)->data + op; |
| 437 | break; | 445 | break; |
| 438 | 446 | ||
| 439 | case Bgotoifnil: | 447 | case Bgotoifnil: |
| 448 | MAYBE_GC (); | ||
| 440 | op = FETCH2; | 449 | op = FETCH2; |
| 441 | if (NILP (POP)) | 450 | if (NILP (POP)) |
| 442 | { | 451 | { |
| @@ -446,6 +455,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 446 | break; | 455 | break; |
| 447 | 456 | ||
| 448 | case Bgotoifnonnil: | 457 | case Bgotoifnonnil: |
| 458 | MAYBE_GC (); | ||
| 449 | op = FETCH2; | 459 | op = FETCH2; |
| 450 | if (!NILP (POP)) | 460 | if (!NILP (POP)) |
| 451 | { | 461 | { |
| @@ -455,6 +465,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 455 | break; | 465 | break; |
| 456 | 466 | ||
| 457 | case Bgotoifnilelsepop: | 467 | case Bgotoifnilelsepop: |
| 468 | MAYBE_GC (); | ||
| 458 | op = FETCH2; | 469 | op = FETCH2; |
| 459 | if (NILP (TOP)) | 470 | if (NILP (TOP)) |
| 460 | { | 471 | { |
| @@ -465,6 +476,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 465 | break; | 476 | break; |
| 466 | 477 | ||
| 467 | case Bgotoifnonnilelsepop: | 478 | case Bgotoifnonnilelsepop: |
| 479 | MAYBE_GC (); | ||
| 468 | op = FETCH2; | 480 | op = FETCH2; |
| 469 | if (!NILP (TOP)) | 481 | if (!NILP (TOP)) |
| 470 | { | 482 | { |
| @@ -475,11 +487,13 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 475 | break; | 487 | break; |
| 476 | 488 | ||
| 477 | case BRgoto: | 489 | case BRgoto: |
| 490 | MAYBE_GC (); | ||
| 478 | QUIT; | 491 | QUIT; |
| 479 | pc += (int) *pc - 127; | 492 | pc += (int) *pc - 127; |
| 480 | break; | 493 | break; |
| 481 | 494 | ||
| 482 | case BRgotoifnil: | 495 | case BRgotoifnil: |
| 496 | MAYBE_GC (); | ||
| 483 | if (NILP (POP)) | 497 | if (NILP (POP)) |
| 484 | { | 498 | { |
| 485 | QUIT; | 499 | QUIT; |
| @@ -489,6 +503,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 489 | break; | 503 | break; |
| 490 | 504 | ||
| 491 | case BRgotoifnonnil: | 505 | case BRgotoifnonnil: |
| 506 | MAYBE_GC (); | ||
| 492 | if (!NILP (POP)) | 507 | if (!NILP (POP)) |
| 493 | { | 508 | { |
| 494 | QUIT; | 509 | QUIT; |
| @@ -498,6 +513,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 498 | break; | 513 | break; |
| 499 | 514 | ||
| 500 | case BRgotoifnilelsepop: | 515 | case BRgotoifnilelsepop: |
| 516 | MAYBE_GC (); | ||
| 501 | op = *pc++; | 517 | op = *pc++; |
| 502 | if (NILP (TOP)) | 518 | if (NILP (TOP)) |
| 503 | { | 519 | { |
| @@ -508,6 +524,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 508 | break; | 524 | break; |
| 509 | 525 | ||
| 510 | case BRgotoifnonnilelsepop: | 526 | case BRgotoifnonnilelsepop: |
| 527 | MAYBE_GC (); | ||
| 511 | op = *pc++; | 528 | op = *pc++; |
| 512 | if (!NILP (TOP)) | 529 | if (!NILP (TOP)) |
| 513 | { | 530 | { |