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

ruby-changes:29393

From: nobu <ko1@a...>
Date: Thu, 20 Jun 2013 01:07:52 +0900 (JST)
Subject: [ruby-changes:29393] nobu:r41445 (trunk): gc.c: refine macros

nobu	2013-06-20 01:07:41 +0900 (Thu, 20 Jun 2013)

  New Revision: 41445

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

  Log:
    gc.c: refine macros
    
    * gc.c (MARKED_IN_BITMAP, FL_TEST2): return boolean value since always
      used as boolean value.
    * gc.c (MARK_IN_BITMAP, CLEAR_IN_BITMAP): evaluate bits once.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41444)
+++ ChangeLog	(revision 41445)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jun 20 01:07:39 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* gc.c (MARKED_IN_BITMAP, FL_TEST2): return boolean value since always
+	  used as boolean value.
+
+	* gc.c (MARK_IN_BITMAP, CLEAR_IN_BITMAP): evaluate bits once.
+
 Thu Jun 20 00:05:07 2013  Koichi Sasada  <ko1@a...>
 
 	* gc.c (RVALUE_PROMOTED): fix type.
Index: gc.c
===================================================================
--- gc.c	(revision 41444)
+++ gc.c	(revision 41445)
@@ -445,9 +445,9 @@ VALUE *ruby_initial_gc_stress_ptr = &rb_ https://github.com/ruby/ruby/blob/trunk/gc.c#L445
 #define BITMAP_OFFSET(p) (NUM_IN_SLOT(p) & ((sizeof(uintptr_t) * CHAR_BIT)-1))
 #define BITMAP_BIT(p) ((uintptr_t)1 << BITMAP_OFFSET(p))
 /* Marking */
-#define MARKED_IN_BITMAP(bits, p) (bits[BITMAP_INDEX(p)] & BITMAP_BIT(p))
-#define MARK_IN_BITMAP(bits, p) (bits[BITMAP_INDEX(p)] = bits[BITMAP_INDEX(p)] | BITMAP_BIT(p))
-#define CLEAR_IN_BITMAP(bits, p) (bits[BITMAP_INDEX(p)] = bits[BITMAP_INDEX(p)] & ~BITMAP_BIT(p))
+#define MARKED_IN_BITMAP(bits, p) (((bits)[BITMAP_INDEX(p)] & BITMAP_BIT(p)) != 0)
+#define MARK_IN_BITMAP(bits, p) ((bits)[BITMAP_INDEX(p)] |= BITMAP_BIT(p))
+#define CLEAR_IN_BITMAP(bits, p) ((bits)[BITMAP_INDEX(p)] &= ~BITMAP_BIT(p))
 
 
 #ifndef HEAP_ALIGN_LOG
@@ -513,7 +513,7 @@ static void rgengc_remember(rb_objspace_ https://github.com/ruby/ruby/blob/trunk/gc.c#L513
 static void rgengc_mark_and_rememberset_clear(rb_objspace_t *objspace);
 static size_t rgengc_rememberset_mark(rb_objspace_t *objspace);
 
-#define FL_TEST2(x,f)         ((RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) ? (rb_bug("FL_TEST2: SPECIAL_CONST"), 0) : FL_TEST_RAW((x),(f)))
+#define FL_TEST2(x,f)         ((RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) ? (rb_bug("FL_TEST2: SPECIAL_CONST"), 0) : FL_TEST_RAW((x),(f)) != 0)
 #define FL_SET2(x,f)          do {if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) rb_bug("FL_SET2: SPECIAL_CONST");   RBASIC(x)->flags |= (f);} while (0)
 #define FL_UNSET2(x,f)        do {if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) rb_bug("FL_UNSET2: SPECIAL_CONST"); RBASIC(x)->flags &= ~(f);} while (0)
 

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

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