ruby-changes:19720
From: yugui <ko1@a...>
Date: Sun, 29 May 2011 08:18:27 +0900 (JST)
Subject: [ruby-changes:19720] yugui:r31765 (ruby_1_9_2): merges r30922 and r30924 from trunk into ruby_1_9_2.
yugui 2011-05-29 08:18:15 +0900 (Sun, 29 May 2011) New Revision: 31765 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31765 Log: merges r30922 and r30924 from trunk into ruby_1_9_2. -- * prevent temporary objects from GC, and should not use RSTRING_PTR() for function calls since it evaluates the argument a couple of times. -- * thread.c (exec_recursive): prevent temporary objects from GC. Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/compile.c branches/ruby_1_9_2/error.c branches/ruby_1_9_2/thread.c branches/ruby_1_9_2/variable.c branches/ruby_1_9_2/version.h branches/ruby_1_9_2/vm.c branches/ruby_1_9_2/vm_eval.c branches/ruby_1_9_2/vm_insnhelper.c Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 31764) +++ ruby_1_9_2/ChangeLog (revision 31765) @@ -1,3 +1,11 @@ +Sun Feb 20 16:26:45 2011 Nobuyoshi Nakada <nobu@r...> + + * thread.c (exec_recursive): prevent temporary objects from GC. + + * prevent temporary objects from GC, and should not use + RSTRING_PTR() for function calls since it evaluates the argument + a couple of times. + Sun Feb 20 02:14:09 2011 KOSAKI Motohiro <kosaki.motohiro@g...> * signal.c (sig_trap): avoid pthread_sigmask(xx, &mask, &mask) usage Index: ruby_1_9_2/variable.c =================================================================== --- ruby_1_9_2/variable.c (revision 31764) +++ ruby_1_9_2/variable.c (revision 31765) @@ -310,7 +310,8 @@ const char * rb_class2name(VALUE klass) { - return RSTRING_PTR(rb_class_name(klass)); + VALUE name = rb_class_name(klass); + return RSTRING_PTR(name); } const char * Index: ruby_1_9_2/compile.c =================================================================== --- ruby_1_9_2/compile.c (revision 31764) +++ ruby_1_9_2/compile.c (revision 31765) @@ -5173,7 +5173,7 @@ if (sym == symNext) return CATCH_TYPE_NEXT; sym_inspect = rb_inspect(sym); rb_raise(rb_eSyntaxError, "invalid exception symbol: %s", - RSTRING_PTR(RB_GC_GUARD(sym_inspect))); + StringValuePtr(sym_inspect)); return 0; } Index: ruby_1_9_2/vm_eval.c =================================================================== --- ruby_1_9_2/vm_eval.c (revision 31764) +++ ruby_1_9_2/vm_eval.c (revision 31765) @@ -1014,7 +1014,8 @@ th->base_block = 0; if (0) { /* for debug */ - printf("%s\n", RSTRING_PTR(rb_iseq_disasm(iseqval))); + VALUE disasm = rb_iseq_disasm(iseqval); + printf("%s\n", StringValuePtr(disasm)); } /* save new env */ Index: ruby_1_9_2/thread.c =================================================================== --- ruby_1_9_2/thread.c (revision 31764) +++ ruby_1_9_2/thread.c (revision 31765) @@ -3637,10 +3637,14 @@ static VALUE exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE arg, int outer) { + VALUE result = Qundef; struct exec_recursive_params p; int outermost; p.list = recursive_list_access(); p.objid = rb_obj_id(obj); + p.obj = obj; + p.pairid = pairid; + p.arg = arg; outermost = outer && !recursive_check(p.list, ID2SYM(recursive_key), 0); if (recursive_check(p.list, p.objid, pairid)) { @@ -3650,11 +3654,7 @@ return (*func)(obj, arg, TRUE); } else { - VALUE result = Qundef; p.func = func; - p.obj = obj; - p.pairid = pairid; - p.arg = arg; if (outermost) { recursive_push(p.list, ID2SYM(recursive_key), 0); @@ -3667,8 +3667,9 @@ else { result = exec_recursive_i(0, &p); } - return result; } + *(volatile struct exec_recursive_params *)&p; + return result; } /* Index: ruby_1_9_2/error.c =================================================================== --- ruby_1_9_2/error.c (revision 31764) +++ ruby_1_9_2/error.c (revision 31765) @@ -336,7 +336,8 @@ etype = "Symbol"; } else if (rb_special_const_p(x)) { - etype = RSTRING_PTR(rb_obj_as_string(x)); + x = rb_obj_as_string(x); + etype = StringValuePtr(x); } else { etype = rb_obj_classname(x); Index: ruby_1_9_2/vm.c =================================================================== --- ruby_1_9_2/vm.c (revision 31764) +++ ruby_1_9_2/vm.c (revision 31765) @@ -1443,7 +1443,7 @@ } else if (cfp->me->def->original_id) { str = rb_sprintf("`%s#%s' (cfunc)", - RSTRING_PTR(rb_class_name(cfp->me->klass)), + rb_class2name(cfp->me->klass), rb_id2name(cfp->me->def->original_id)); } Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 31764) +++ ruby_1_9_2/version.h (revision 31765) @@ -1,13 +1,13 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 204 +#define RUBY_PATCHLEVEL 205 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_YEAR 2011 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 12 -#define RUBY_RELEASE_DATE "2011-05-12" +#define RUBY_RELEASE_DAY 28 +#define RUBY_RELEASE_DATE "2011-05-28" #include "ruby/version.h" Index: ruby_1_9_2/vm_insnhelper.c =================================================================== --- ruby_1_9_2/vm_insnhelper.c (revision 31764) +++ ruby_1_9_2/vm_insnhelper.c (revision 31765) @@ -1142,7 +1142,7 @@ default: str = rb_inspect(klass); rb_raise(rb_eTypeError, "%s is not a class/module", - RSTRING_PTR(RB_GC_GUARD(str))); + StringValuePtr(str)); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/