summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-08 08:34:01 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-08 08:34:01 +0000
commit8e3d44e0df5b5ae9e549f5e7bb5840038e9ffcee (patch)
tree6874e8ca952bf47f563d7e781351dfe8f78b10ba
parentece260c8d4a4f49f9125639d1ed73019b73cff96 (diff)
* merge -c 11965
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_5@12013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog13
-rw-r--r--env.h1
-rw-r--r--eval.c3
-rw-r--r--gc.c2
-rw-r--r--parse.y3
5 files changed, 19 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index b6eadcba641..fdc6db9b6b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Sat Mar 3 16:30:39 2007 Akinori MUSHA <knu@iDaemons.org>
+
+ * env.h (SCOPE_CLONE): Introduce a new scope flag to prevent a
+ local_tbl region from getting freed many times; submitted by
+ Chikanaga Tomoyuki <chikanag AT nippon-control-system.co.jp> in
+ [ruby-dev:30460].
+
+ * eval.c (proc_invoke): Ditto.
+
+ * gc.c (obj_free): Ditto.
+
+ * parse.y (top_local_setup_gen): Ditto.
+
Sat Mar 3 15:41:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (stmt, arg): should not omit lhs of OP_ASGN1 even if
diff --git a/env.h b/env.h
index f150f7fb63d..196090f387a 100644
--- a/env.h
+++ b/env.h
@@ -43,6 +43,7 @@ extern struct SCOPE {
#define SCOPE_MALLOC 1
#define SCOPE_NOSTACK 2
#define SCOPE_DONT_RECYCLE 4
+#define SCOPE_CLONE 8
extern int ruby_in_eval;
diff --git a/eval.c b/eval.c
index 83fdbf47b11..6eab561c2b3 100644
--- a/eval.c
+++ b/eval.c
@@ -8496,11 +8496,12 @@ proc_invoke(proc, args, self, klass)
if (klass) _block.frame.last_class = klass;
_block.frame.argc = RARRAY(tmp)->len;
_block.frame.flags = ruby_frame->flags;
- if (_block.frame.argc && (ruby_frame->flags & FRAME_DMETH)) {
+ if (_block.frame.argc && DMETHOD_P()) {
NEWOBJ(scope, struct SCOPE);
OBJSETUP(scope, tmp, T_SCOPE);
scope->local_tbl = _block.scope->local_tbl;
scope->local_vars = _block.scope->local_vars;
+ scope->flags |= SCOPE_CLONE;
_block.scope = scope;
}
/* modify current frame */
diff --git a/gc.c b/gc.c
index 2add5422c9e..f2530f07eff 100644
--- a/gc.c
+++ b/gc.c
@@ -1264,7 +1264,7 @@ obj_free(obj)
if (RANY(obj)->as.scope.local_vars &&
RANY(obj)->as.scope.flags != SCOPE_ALLOCA) {
VALUE *vars = RANY(obj)->as.scope.local_vars-1;
- if (vars[0] == 0)
+ if (!(RANY(obj)->as.scope.flags & SCOPE_CLONE) && vars[0] == 0)
RUBY_CRITICAL(free(RANY(obj)->as.scope.local_tbl));
if (RANY(obj)->as.scope.flags & SCOPE_MALLOC)
RUBY_CRITICAL(free(vars));
diff --git a/parse.y b/parse.y
index 9e65a76f325..d1466e77cac 100644
--- a/parse.y
+++ b/parse.y
@@ -5732,7 +5732,8 @@ top_local_setup()
rb_mem_clear(ruby_scope->local_vars+i, len-i);
}
if (ruby_scope->local_tbl && ruby_scope->local_vars[-1] == 0) {
- xfree(ruby_scope->local_tbl);
+ if (!(ruby_scope->flags & SCOPE_CLONE))
+ xfree(ruby_scope->local_tbl);
}
ruby_scope->local_tbl = local_tbl();
}