ruby-changes:26497
From: shirosaki <ko1@a...>
Date: Sat, 22 Dec 2012 13:25:30 +0900 (JST)
Subject: [ruby-changes:26497] shirosaki:r38548 (trunk): * gc.c (obj_id_to_ref): add a macro to treat Bignum object id.
shirosaki 2012-12-22 13:25:18 +0900 (Sat, 22 Dec 2012) New Revision: 38548 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38548 Log: * gc.c (obj_id_to_ref): add a macro to treat Bignum object id. This follows the change r38493. * gc.c (id2ref): fix for working fine with Bignum object id on x64 Windows. * gc.c (wmap_finalize): ditto. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 38547) +++ ChangeLog (revision 38548) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Dec 22 13:15:08 2012 Hiroshi Shirosaki <h.shirosaki@g...> + + * gc.c (obj_id_to_ref): add a macro to treat Bignum object id. + This follows the change r38493. + + * gc.c (id2ref): fix for working fine with Bignum object id on x64 + Windows. + * gc.c (wmap_finalize): ditto. + Sat Dec 22 11:30:21 2012 Masaki Matsushita <glass.saga@g...> * struct.c (make_struct): remove junk ID check to allow members who Index: gc.c =================================================================== --- gc.c (revision 38547) +++ gc.c (revision 38548) @@ -292,8 +292,11 @@ int *ruby_initial_gc_stress_ptr = &rb_ob https://github.com/ruby/ruby/blob/trunk/gc.c#L292 #if SIZEOF_LONG == SIZEOF_VOIDP # define nonspecial_obj_id(obj) (VALUE)((SIGNED_VALUE)(obj)|FIXNUM_FLAG) +# define obj_id_to_ref(objid) ((objid) ^ FIXNUM_FLAG) /* unset FIXNUM_FLAG */ #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP # define nonspecial_obj_id(obj) LL2NUM((SIGNED_VALUE)(obj) / 2) +# define obj_id_to_ref(objid) (FIXNUM_P(objid) ? \ + ((objid) ^ FIXNUM_FLAG) : (NUM2PTR(objid) << 1)) #else # error not supported #endif @@ -1630,7 +1633,7 @@ id2ref(VALUE obj, VALUE objid) https://github.com/ruby/ruby/blob/trunk/gc.c#L1633 if (ptr == Qnil) return Qnil; if (FIXNUM_P(ptr)) return (VALUE)ptr; if (FLONUM_P(ptr)) return (VALUE)ptr; - ptr = objid ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */ + ptr = obj_id_to_ref(objid); if ((ptr % sizeof(RVALUE)) == (4 << 2)) { ID symid = ptr / sizeof(RVALUE); @@ -3795,7 +3798,7 @@ wmap_finalize(VALUE self, VALUE objid) https://github.com/ruby/ruby/blob/trunk/gc.c#L3798 TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); /* Get reference from object id. */ - obj = objid ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */ + obj = obj_id_to_ref(objid); /* obj is original referenced object and/or weak reference. */ orig = (st_data_t)obj; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/