[前][次][番号順一覧][スレッド一覧]

ruby-changes:28025

From: nobu <ko1@a...>
Date: Wed, 3 Apr 2013 16:35:45 +0900 (JST)
Subject: [ruby-changes:28025] nobu:r40077 (trunk): bignum.c: hide intermediate Bignums

nobu	2013-04-03 16:35:35 +0900 (Wed, 03 Apr 2013)

  New Revision: 40077

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40077

  Log:
    bignum.c: hide intermediate Bignums
    
    * bignum.c (rb_big_eq): hide intermediate Bignums not just freeing
      memory.  [ruby-core:53893] [Bug #8204]
    * object.c (rb_obj_hide): hide an object by clearing klass.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c
    trunk/internal.h
    trunk/object.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40076)
+++ ChangeLog	(revision 40077)
@@ -1,4 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Wed Apr  3 16:34:24 2013  Nobuyoshi Nakada  <nobu@r...>
+Wed Apr  3 16:35:32 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* bignum.c (rb_big_eq): hide intermediate Bignums not just freeing
+	  memory.  [ruby-core:53893] [Bug #8204]
+
+	* object.c (rb_obj_hide): hide an object by clearing klass.
 
 	* bignum.c (rb_big_eq): test as Fixnum if possible and get rid of zero
 	  length Bignum.  [ruby-core:53893] [Bug #8204]
Index: object.c
===================================================================
--- object.c	(revision 40076)
+++ object.c	(revision 40077)
@@ -43,6 +43,15 @@ static ID id_const_missing; https://github.com/ruby/ruby/blob/trunk/object.c#L43
     (!SPECIAL_CONST_P(obj) && \
      (BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE))
 
+VALUE
+rb_obj_hide(VALUE obj)
+{
+    if (!SPECIAL_CONST_P(obj)) {
+	RBASIC(obj)->klass = 0;
+    }
+    return obj;
+}
+
 /*
  *  call-seq:
  *     obj === other   -> true or false
Index: internal.h
===================================================================
--- internal.h	(revision 40076)
+++ internal.h	(revision 40077)
@@ -196,6 +196,7 @@ VALUE rb_int_pred(VALUE num); https://github.com/ruby/ruby/blob/trunk/internal.h#L196
 
 /* object.c */
 VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
+VALUE rb_obj_hide(VALUE obj);
 
 /* parse.y */
 VALUE rb_parser_get_yydebug(VALUE);
Index: bignum.c
===================================================================
--- bignum.c	(revision 40076)
+++ bignum.c	(revision 40077)
@@ -1095,6 +1095,8 @@ big2str_karatsuba(VALUE x, int base, cha https://github.com/ruby/ruby/blob/trunk/bignum.c#L1095
 
     b = power_cache_get_power(base, n1, &m1);
     bigdivmod(x, b, &q, &r);
+    rb_obj_hide(q);
+    rb_obj_hide(r);
     lh = big2str_karatsuba(q, base, ptr, (len - m1)/2,
 			   len - m1, hbase, trim);
     rb_big_resize(q, 0);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]