Skip to content

Commit

Permalink
matz
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Nov 20, 2000
1 parent 676e14b commit 87dc439
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Mon Nov 20 13:45:21 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* gc.c (gc_sweep): defer finalization in GC during compilation or
interrupt prohibit section.

* gc.c (gc_sweep): mark all nodes before sweeping if GC happened
during compilation.

* eval.c (rb_eval): should treat class variables specially in a
method defined in the singleton class.

Expand Down
25 changes: 22 additions & 3 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 87dc439

Please sign in to comment.