diff options
author | shirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-22 04:25:18 +0000 |
---|---|---|
committer | shirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-22 04:25:18 +0000 |
commit | ca2fce0cf286cc505aa8f134275616a5d903fa8d (patch) | |
tree | afcac7b894c39586d36fd4cbc77460ea37952bba /gc.c | |
parent | f9e621372df2551fa269f3c814246eca1e34e4fb (diff) |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -292,8 +292,11 @@ int *ruby_initial_gc_stress_ptr = &rb_objspace.gc_stress; #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) 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) 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; |