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

ruby-changes:12819

From: ko1 <ko1@a...>
Date: Sun, 16 Aug 2009 03:18:43 +0900 (JST)
Subject: [ruby-changes:12819] Ruby:r24547 (trunk): * vm_insnhelper.c (opt_eq_func): fix optimization bug. This issue

ko1	2009-08-16 03:18:07 +0900 (Sun, 16 Aug 2009)

  New Revision: 24547

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

  Log:
    * vm_insnhelper.c (opt_eq_func): fix optimization bug.  This issue
      was found out and debugged with Takuto Hayashi at Security and
      Programming camp 2009.

  Modified files:
    trunk/ChangeLog
    trunk/vm_insnhelper.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24546)
+++ ChangeLog	(revision 24547)
@@ -1,3 +1,9 @@
+Sun Aug 16 03:06:59 2009  Koichi Sasada  <ko1@a...>
+
+	* vm_insnhelper.c (opt_eq_func): fix optimization bug.  This issue
+	  was found out and debugged with Takuto Hayashi at Security and
+	  Programming camp 2009.
+
 Sun Aug 16 01:10:00 2009  NARUSE, Yui  <naruse@r...>
 
 	* regparse.c (add_ctype_to_cc_by_range): fix the first
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 24546)
+++ vm_insnhelper.c	(revision 24547)
@@ -1547,16 +1547,9 @@
 VALUE
 opt_eq_func(VALUE recv, VALUE obj, IC ic)
 {
-    VALUE val = Qundef;
-
     if (FIXNUM_2_P(recv, obj) &&
 	BASIC_OP_UNREDEFINED_P(BOP_EQ)) {
-	if (recv == obj) {
-	    val = Qtrue;
-	}
-	else {
-	    val = Qfalse;
-	}
+	return (recv == obj) ? Qtrue : Qfalse;
     }
     else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
 	if (HEAP_CLASS_OF(recv) == rb_cFloat &&
@@ -1566,31 +1559,27 @@
 	    double b = RFLOAT_VALUE(obj);
 
 	    if (isnan(a) || isnan(b)) {
-		val = Qfalse;
+		return Qfalse;
 	    }
-	    else if (a == b) {
-		val = Qtrue;
-	    }
-	    else {
-		val = Qfalse;
-	    }
+	    return  (a == b) ? Qtrue : Qfalse;
 	}
 	else if (HEAP_CLASS_OF(recv) == rb_cString &&
 		 HEAP_CLASS_OF(obj) == rb_cString &&
 		 BASIC_OP_UNREDEFINED_P(BOP_EQ)) {
-	    val = rb_str_equal(recv, obj);
+	    return rb_str_equal(recv, obj);
 	}
-	else {
-	    const rb_method_entry_t *me = vm_method_search(idEq, CLASS_OF(recv), ic);
-	    extern VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
+    }
 
-	    if (check_cfunc(me, rb_obj_equal)) {
-		return recv == obj ? Qtrue : Qfalse;
-	    }
+    {
+	const rb_method_entry_t *me = vm_method_search(idEq, CLASS_OF(recv), ic);
+	extern VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
+
+	if (check_cfunc(me, rb_obj_equal)) {
+	    return recv == obj ? Qtrue : Qfalse;
 	}
     }
 
-    return val;
+    return Qundef;
 }
 
 struct opt_case_dispatch_i_arg {

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

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