summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-20 08:26:48 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-20 08:26:48 +0000
commit6ffeed5c898cb5dd43d917d3f90459fbc31f8d3f (patch)
tree856d5e112a7c288750c841468d7b11413c4e6b2d /gc.c
parent39563af99459820ada08e30e379c84b4560c3fe9 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index ac05c11..8af89c9 100644
--- a/gc.c
+++ b/gc.c
@@ -235,6 +235,7 @@ typedef struct RVALUE {
} RVALUE;
static RVALUE *freelist = 0;
+static RVALUE *deferred_final_list = 0;
#define HEAPS_INCREMENT 10
static RVALUE **heaps;
@@ -659,8 +660,21 @@ gc_sweep()
int freed = 0;
int i, used = heaps_used;
+ if (ruby_in_compile) {
+ /* sould not reclaim nodes during compilation */
+ for (i = 0; i < used; i++) {
+ p = heaps[i]; pend = p + HEAP_SLOTS;
+ while (p < pend) {
+ if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE)
+ rb_gc_mark(p);
+ p++;
+ }
+ }
+ }
+
freelist = 0;
- final_list = 0;
+ final_list = deferred_final_list;
+ deferred_final_list = 0;
for (i = 0; i < used; i++) {
int n = 0;
@@ -699,9 +713,14 @@ gc_sweep()
during_gc = 0;
/* clear finalization list */
- if (need_call_final) {
+ if (need_call_final && final_list) {
RVALUE *tmp;
+ if (rb_prohibit_interrupt || ruby_in_compile) {
+ deferred_final_list = final_list;
+ return;
+ }
+
for (p = final_list; p; p = tmp) {
tmp = p->as.free.next;
run_final((VALUE)p);
@@ -914,7 +933,7 @@ rb_gc()
# define STACK_END (stack_end)
#endif
- if (dont_gc || during_gc || rb_prohibit_interrupt || ruby_in_compile) {
+ if (dont_gc || during_gc) {
if (!freelist || malloc_memories > GC_MALLOC_LIMIT) {
malloc_memories = 0;
add_heap();