mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
39563af994
commit
6ffeed5c89
2 changed files with 28 additions and 3 deletions
|
@ -1,5 +1,11 @@
|
||||||
Mon Nov 20 13:45:21 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
|
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
|
* eval.c (rb_eval): should treat class variables specially in a
|
||||||
method defined in the singleton class.
|
method defined in the singleton class.
|
||||||
|
|
||||||
|
|
25
gc.c
25
gc.c
|
@ -235,6 +235,7 @@ typedef struct RVALUE {
|
||||||
} RVALUE;
|
} RVALUE;
|
||||||
|
|
||||||
static RVALUE *freelist = 0;
|
static RVALUE *freelist = 0;
|
||||||
|
static RVALUE *deferred_final_list = 0;
|
||||||
|
|
||||||
#define HEAPS_INCREMENT 10
|
#define HEAPS_INCREMENT 10
|
||||||
static RVALUE **heaps;
|
static RVALUE **heaps;
|
||||||
|
@ -659,8 +660,21 @@ gc_sweep()
|
||||||
int freed = 0;
|
int freed = 0;
|
||||||
int i, used = heaps_used;
|
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;
|
freelist = 0;
|
||||||
final_list = 0;
|
final_list = deferred_final_list;
|
||||||
|
deferred_final_list = 0;
|
||||||
for (i = 0; i < used; i++) {
|
for (i = 0; i < used; i++) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
|
@ -699,9 +713,14 @@ gc_sweep()
|
||||||
during_gc = 0;
|
during_gc = 0;
|
||||||
|
|
||||||
/* clear finalization list */
|
/* clear finalization list */
|
||||||
if (need_call_final) {
|
if (need_call_final && final_list) {
|
||||||
RVALUE *tmp;
|
RVALUE *tmp;
|
||||||
|
|
||||||
|
if (rb_prohibit_interrupt || ruby_in_compile) {
|
||||||
|
deferred_final_list = final_list;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (p = final_list; p; p = tmp) {
|
for (p = final_list; p; p = tmp) {
|
||||||
tmp = p->as.free.next;
|
tmp = p->as.free.next;
|
||||||
run_final((VALUE)p);
|
run_final((VALUE)p);
|
||||||
|
@ -914,7 +933,7 @@ rb_gc()
|
||||||
# define STACK_END (stack_end)
|
# define STACK_END (stack_end)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dont_gc || during_gc || rb_prohibit_interrupt || ruby_in_compile) {
|
if (dont_gc || during_gc) {
|
||||||
if (!freelist || malloc_memories > GC_MALLOC_LIMIT) {
|
if (!freelist || malloc_memories > GC_MALLOC_LIMIT) {
|
||||||
malloc_memories = 0;
|
malloc_memories = 0;
|
||||||
add_heap();
|
add_heap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue