diff options
| author | Dave Love | 2003-01-30 14:15:58 +0000 |
|---|---|---|
| committer | Dave Love | 2003-01-30 14:15:58 +0000 |
| commit | 2c5bd60800ce4f2702f263eda2145be342208ffe (patch) | |
| tree | b9275a6764a1ed436d56307f515dc89be8b5cfcb /src/alloc.c | |
| parent | 100dcd40b8240c5ddb3c7b1984409e0c5440347e (diff) | |
| download | emacs-2c5bd60800ce4f2702f263eda2145be342208ffe.tar.gz emacs-2c5bd60800ce4f2702f263eda2145be342208ffe.zip | |
(Vgc_elapsed, gcs_done): New variables.
(Fgarbage_collect): Use them.
(init_alloc, syms_of_alloc): Set them up.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/alloc.c b/src/alloc.c index fb15f883175..61ea3565153 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -256,6 +256,9 @@ Lisp_Object Qgc_cons_threshold, Qchar_table_extra_slots; | |||
| 256 | 256 | ||
| 257 | Lisp_Object Vpost_gc_hook, Qpost_gc_hook; | 257 | Lisp_Object Vpost_gc_hook, Qpost_gc_hook; |
| 258 | 258 | ||
| 259 | Lisp_Object Vgc_elapsed; /* accumulated elapsed time in GC */ | ||
| 260 | EMACS_INT gcs_done; /* accumulated GCs */ | ||
| 261 | |||
| 259 | static void mark_buffer P_ ((Lisp_Object)); | 262 | static void mark_buffer P_ ((Lisp_Object)); |
| 260 | static void mark_kboards P_ ((void)); | 263 | static void mark_kboards P_ ((void)); |
| 261 | static void gc_sweep P_ ((void)); | 264 | static void gc_sweep P_ ((void)); |
| @@ -645,8 +648,8 @@ lisp_free (block) | |||
| 645 | elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT | 648 | elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT |
| 646 | pairs; unfortunately, we have no idea what C library functions | 649 | pairs; unfortunately, we have no idea what C library functions |
| 647 | might call malloc, so we can't really protect them unless you're | 650 | might call malloc, so we can't really protect them unless you're |
| 648 | using GNU malloc. Fortunately, most of the major operating can use | 651 | using GNU malloc. Fortunately, most of the major operating systems |
| 649 | GNU malloc. */ | 652 | can use GNU malloc. */ |
| 650 | 653 | ||
| 651 | #ifndef SYSTEM_MALLOC | 654 | #ifndef SYSTEM_MALLOC |
| 652 | #ifndef DOUG_LEA_MALLOC | 655 | #ifndef DOUG_LEA_MALLOC |
| @@ -1236,7 +1239,7 @@ string_bytes (s) | |||
| 1236 | return nbytes; | 1239 | return nbytes; |
| 1237 | } | 1240 | } |
| 1238 | 1241 | ||
| 1239 | /* Check validity Lisp strings' string_bytes member in B. */ | 1242 | /* Check validity of Lisp strings' string_bytes member in B. */ |
| 1240 | 1243 | ||
| 1241 | void | 1244 | void |
| 1242 | check_sblock (b) | 1245 | check_sblock (b) |
| @@ -4085,6 +4088,9 @@ Garbage collection happens automatically if you cons more than | |||
| 4085 | int message_p; | 4088 | int message_p; |
| 4086 | Lisp_Object total[8]; | 4089 | Lisp_Object total[8]; |
| 4087 | int count = SPECPDL_INDEX (); | 4090 | int count = SPECPDL_INDEX (); |
| 4091 | EMACS_TIME t1, t2, t3; | ||
| 4092 | |||
| 4093 | EMACS_GET_TIME (t1); | ||
| 4088 | 4094 | ||
| 4089 | /* Can't GC if pure storage overflowed because we can't determine | 4095 | /* Can't GC if pure storage overflowed because we can't determine |
| 4090 | if something is a pure object or not. */ | 4096 | if something is a pure object or not. */ |
| @@ -4370,7 +4376,16 @@ Garbage collection happens automatically if you cons more than | |||
| 4370 | safe_run_hooks (Qpost_gc_hook); | 4376 | safe_run_hooks (Qpost_gc_hook); |
| 4371 | unbind_to (count, Qnil); | 4377 | unbind_to (count, Qnil); |
| 4372 | } | 4378 | } |
| 4373 | 4379 | ||
| 4380 | /* Accumulate statistics. */ | ||
| 4381 | EMACS_GET_TIME (t2); | ||
| 4382 | EMACS_SUB_TIME (t3, t2, t1); | ||
| 4383 | if (FLOATP (Vgc_elapsed)) | ||
| 4384 | XSETFLOAT (Vgc_elapsed, make_float (XFLOAT_DATA (Vgc_elapsed) + | ||
| 4385 | EMACS_SECS (t3) + | ||
| 4386 | EMACS_USECS (t3) * 1.0e-6)); | ||
| 4387 | gcs_done++; | ||
| 4388 | |||
| 4374 | return Flist (sizeof total / sizeof *total, total); | 4389 | return Flist (sizeof total / sizeof *total, total); |
| 4375 | } | 4390 | } |
| 4376 | 4391 | ||
| @@ -5525,6 +5540,8 @@ init_alloc () | |||
| 5525 | setjmp_tested_p = longjmps_done = 0; | 5540 | setjmp_tested_p = longjmps_done = 0; |
| 5526 | #endif | 5541 | #endif |
| 5527 | #endif | 5542 | #endif |
| 5543 | Vgc_elapsed = make_float (0.0); | ||
| 5544 | gcs_done = 0; | ||
| 5528 | } | 5545 | } |
| 5529 | 5546 | ||
| 5530 | void | 5547 | void |
| @@ -5614,6 +5631,14 @@ which includes both saved text and other data. */); | |||
| 5614 | staticpro (&Qchar_table_extra_slots); | 5631 | staticpro (&Qchar_table_extra_slots); |
| 5615 | Qchar_table_extra_slots = intern ("char-table-extra-slots"); | 5632 | Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
| 5616 | 5633 | ||
| 5634 | DEFVAR_LISP ("gc-elapsed", &Vgc_elapsed, | ||
| 5635 | doc: /* Accumulated time elapsed in garbage collections. | ||
| 5636 | The time is in seconds as a floating point value. | ||
| 5637 | Programs may reset this to get statistics in a specific period. */); | ||
| 5638 | DEFVAR_INT ("gcs-done", &gcs_done, | ||
| 5639 | doc: /* Accumulated number of garbage collections done. | ||
| 5640 | Programs may reset this to get statistics in a specific period. */); | ||
| 5641 | |||
| 5617 | defsubr (&Scons); | 5642 | defsubr (&Scons); |
| 5618 | defsubr (&Slist); | 5643 | defsubr (&Slist); |
| 5619 | defsubr (&Svector); | 5644 | defsubr (&Svector); |