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

@ -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;
}
/*