ruby-changes:26117
From: nobu <ko1@a...>
Date: Tue, 4 Dec 2012 16:23:31 +0900 (JST)
Subject: [ruby-changes:26117] nobu:r38174 (trunk): marshal.c: GC guard
nobu 2012-12-04 16:23:20 +0900 (Tue, 04 Dec 2012) New Revision: 38174 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38174 Log: marshal.c: GC guard * marshal.c (w_object, marshal_dump, r_object0, marshal_load): use RB_GC_GUARD() (directly or indirectly) instead of volatile. * variable.c (rb_path_to_class): prevent the arguemnt from GC. Modified files: trunk/ChangeLog trunk/marshal.c trunk/variable.c Index: ChangeLog =================================================================== --- ChangeLog (revision 38173) +++ ChangeLog (revision 38174) @@ -1,3 +1,10 @@ +Tue Dec 4 16:23:12 2012 Nobuyoshi Nakada <nobu@r...> + + * marshal.c (w_object, marshal_dump, r_object0, marshal_load): use + RB_GC_GUARD() (directly or indirectly) instead of volatile. + + * variable.c (rb_path_to_class): prevent the arguemnt from GC. + Tue Dec 04 13:55:07 2012 Koichi Sasada <ko1@a...> * vm_opts.h: enable optimization - operand unifications. Index: variable.c =================================================================== --- variable.c (revision 38173) +++ variable.c (revision 38174) @@ -354,6 +354,7 @@ rb_raise(rb_eTypeError, "%s does not refer to class/module", path); } } + RB_GC_GUARD(pathname); return c; } Index: marshal.c =================================================================== --- marshal.c (revision 38173) +++ marshal.c (revision 38174) @@ -645,7 +645,7 @@ arg->infection |= (int)FL_TEST(obj, MARSHAL_INFECTION); if (rb_obj_respond_to(obj, s_mdump, TRUE)) { - volatile VALUE v; + VALUE v; st_add_direct(arg->data, obj, arg->data->num_entries); @@ -711,8 +711,9 @@ } w_byte(TYPE_CLASS, arg); { - volatile VALUE path = class2path(obj); + VALUE path = class2path(obj); w_bytes(RSTRING_PTR(path), RSTRING_LEN(path), arg); + RB_GC_GUARD(path); } break; @@ -721,6 +722,7 @@ { VALUE path = class2path(obj); w_bytes(RSTRING_PTR(path), RSTRING_LEN(path), arg); + RB_GC_GUARD(path); } break; @@ -849,6 +851,7 @@ rb_obj_classname(obj)); break; } + RB_GC_GUARD(obj); } if (hasiv) { w_ivar(obj, ivtbl, &c_arg); @@ -918,7 +921,7 @@ VALUE obj, port, a1, a2; int limit = -1; struct dump_arg *arg; - volatile VALUE wrapper; + VALUE wrapper; port = Qnil; rb_scan_args(argc, argv, "12", &obj, &a1, &a2); @@ -1553,7 +1556,7 @@ { long len; BDIGIT *digits; - volatile VALUE data; + VALUE data; NEWOBJ_OF(big, struct RBignum, rb_cBignum, T_BIGNUM); RBIGNUM_SET_SIGN(big, (r_byte(arg) == '+')); @@ -1566,6 +1569,7 @@ #endif digits = RBIGNUM_DIGITS(big); MEMCPY(digits, RSTRING_PTR(data), char, len * 2); + rb_str_resize(data, 0L); #if SIZEOF_BDIGITS > SIZEOF_SHORT MEMZERO((char *)digits + len * 2, char, RBIGNUM_LEN(big) * sizeof(BDIGIT) - len * 2); @@ -1601,7 +1605,7 @@ case TYPE_REGEXP: { - volatile VALUE str = r_bytes(arg); + VALUE str = r_bytes(arg); int options = r_byte(arg); int has_encoding = FALSE; st_index_t idx = r_prepare(arg); @@ -1798,7 +1802,7 @@ case TYPE_MODULE_OLD: { - volatile VALUE str = r_bytes(arg); + VALUE str = r_bytes(arg); v = rb_path_to_class(str); v = r_entry(v, arg); @@ -1808,7 +1812,7 @@ case TYPE_CLASS: { - volatile VALUE str = r_bytes(arg); + VALUE str = r_bytes(arg); v = path2class(str); v = r_entry(v, arg); @@ -1818,7 +1822,7 @@ case TYPE_MODULE: { - volatile VALUE str = r_bytes(arg); + VALUE str = r_bytes(arg); v = path2module(str); v = r_entry(v, arg); @@ -1890,7 +1894,7 @@ VALUE port, proc; int major, minor, infection = 0; VALUE v; - volatile VALUE wrapper; + VALUE wrapper; struct load_arg *arg; rb_scan_args(argc, argv, "11", &port, &proc); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/