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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yugui 2011-05-28 23:18:15 +00:00
parent f0a2b08d02
commit 1c0add85ca
9 changed files with 26 additions and 14 deletions

View file

@ -1,3 +1,11 @@
Sun Feb 20 16:26:45 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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@gmail.com>
* signal.c (sig_trap): avoid pthread_sigmask(xx, &mask, &mask) usage

View file

@ -5173,7 +5173,7 @@ get_exception_sym2type(VALUE sym)
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;
}

View file

@ -336,7 +336,8 @@ rb_check_type(VALUE x, int t)
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);

View file

@ -3637,10 +3637,14 @@ exec_recursive_i(VALUE tag, struct exec_recursive_params *p)
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 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
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 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
else {
result = exec_recursive_i(0, &p);
}
return result;
}
*(volatile struct exec_recursive_params *)&p;
return result;
}
/*

View file

@ -310,7 +310,8 @@ rb_class_name(VALUE klass)
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 *

View file

@ -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"

2
vm.c
View file

@ -1443,7 +1443,7 @@ rb_thread_current_status(const rb_thread_t *th)
}
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));
}

View file

@ -1014,7 +1014,8 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char
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 */

View file

@ -1142,7 +1142,7 @@ vm_check_if_namespace(VALUE klass)
default:
str = rb_inspect(klass);
rb_raise(rb_eTypeError, "%s is not a class/module",
RSTRING_PTR(RB_GC_GUARD(str)));
StringValuePtr(str));
}
}