diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | gc.c | 18 | ||||
-rw-r--r-- | lib/ostruct.rb | 8 | ||||
-rw-r--r-- | lib/pstore.rb | 12 |
4 files changed, 36 insertions, 6 deletions
@@ -1,3 +1,7 @@ +Wed Oct 27 17:27:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * gc.c (gc_sweep): recover ruby_in_compile variable. + Wed Oct 27 09:17:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> * string.c (str_gsub): use a string object for exception safeness. @@ -179,6 +179,7 @@ ruby_xfree(x) RUBY_CRITICAL(free(x)); } +extern int ruby_in_compile; static int dont_gc; static int during_gc; static int need_call_final = 0; @@ -1034,6 +1035,19 @@ gc_sweep() int i; unsigned long live = 0; + if (ruby_in_compile && ruby_parser_stack_on_heap()) { + /* should not reclaim nodes during compilation + if yacc's semantic stack is not allocated on machine stack */ + for (i = 0; i < heaps_used; i++) { + p = heaps[i].slot; pend = p + heaps[i].limit; + while (p < pend) { + if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE) + gc_mark((VALUE)p, 0); + p++; + } + } + } + mark_source_filename(ruby_sourcefile); st_foreach(source_filenames, sweep_source_filename, 0); @@ -1426,10 +1440,10 @@ rb_gc_start() void ruby_set_stack_size(size) - size_t *size; + size_t size; { #ifndef STACK_LEVEL_MAX - STACK_LEVEL_MAX = size; + STACK_LEVEL_MAX = size / sizeof(VALUE); #endif } diff --git a/lib/ostruct.rb b/lib/ostruct.rb index d603c04759..d92ee503ad 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -52,6 +52,13 @@ class OpenStruct end end + def new_ostruct_member(name) + self.instance_eval %{ + def #{name}; @table[:#{name}]; end + def #{name}=(x); @table[:#{name}] = x; end + } + end + def method_missing(mid, *args) # :nodoc: mname = mid.id2name len = args.length @@ -64,6 +71,7 @@ class OpenStruct end mname.chop! @table[mname.intern] = args[0] + self.new_ostruct_member(mname) elsif len == 0 @table[mid] else diff --git a/lib/pstore.rb b/lib/pstore.rb index 50313dcb8f..51cef6e134 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -104,10 +104,14 @@ class PStore commit_new(file) if FileTest.exist?(new_file) content = file.read() else - file = File.open(@filename, File::RDONLY) - file.binmode - file.flock(File::LOCK_SH) - content = (File.read(new_file) rescue file.read()) + begin + file = File.open(@filename, File::RDONLY) + file.binmode + file.flock(File::LOCK_SH) + content = (File.read(new_file) rescue file.read()) + rescue Errno::ENOENT + content = "" + end end if content != "" |