Revision: 4978
Author: [email protected]
Date: Tue Jun 29 07:15:34 2010
Log: X64: Make the ToBoolean inline code do even less if the value is known to be a smi.

Review URL: http://codereview.chromium.org/2834028
http://code.google.com/p/v8/source/detail?r=4978

Modified:
 /branches/bleeding_edge/src/regexp.js
 /branches/bleeding_edge/src/x64/codegen-x64.cc

=======================================
--- /branches/bleeding_edge/src/regexp.js       Fri Jun 25 00:51:46 2010
+++ /branches/bleeding_edge/src/regexp.js       Tue Jun 29 07:15:34 2010
@@ -296,14 +296,14 @@
     return cache.answer;
   }

-  // Remove irrelevant preceeding '.*' in a test regexp. The expression
-  // checks whether this.source starts with '.*' and that the third
+  // Remove irrelevant preceeding '.*' in a test regexp. The expression
+  // checks whether this.source starts with '.*' and that the third
   // char is not a '?'
   if (%_StringCharCodeAt(this.source,0) == 46 && // '.'
-      %_StringCharCodeAt(this.source,1) == 42 && // '*'
-      %_StringCharCodeAt(this.source,2) != 63) { // '?'
+      %_StringCharCodeAt(this.source,1) == 42 && // '*'
+      %_StringCharCodeAt(this.source,2) != 63) { // '?'
     if (!%_ObjectEquals(regexp_key, this)) {
-      regexp_key = this;
+      regexp_key = this;
regexp_val = new $RegExp(this.source.substring(2, this.source.length),
                                (this.global ? 'g' : '')
                                + (this.ignoreCase ? 'i' : '')
@@ -311,7 +311,7 @@
     }
     if (!regexp_val.test(s)) return false;
   }
-
+
   var length = s.length;
   var i = this.global ? TO_INTEGER(lastIndex) : 0;

=======================================
--- /branches/bleeding_edge/src/x64/codegen-x64.cc      Tue Jun 29 07:03:11 2010
+++ /branches/bleeding_edge/src/x64/codegen-x64.cc      Tue Jun 29 07:15:34 2010
@@ -5342,13 +5342,18 @@
     }
     // Smi => false iff zero.
     __ SmiCompare(value.reg(), Smi::FromInt(0));
-    dest->false_target()->Branch(equal);
-    Condition is_smi = masm_->CheckSmi(value.reg());
-    dest->true_target()->Branch(is_smi);
-    __ xorpd(xmm0, xmm0);
-    __ ucomisd(xmm0, FieldOperand(value.reg(), HeapNumber::kValueOffset));
-    value.Unuse();
-    dest->Split(not_zero);
+    if (value.is_smi()) {
+      value.Unuse();
+      dest->Split(not_zero);
+    } else {
+      dest->false_target()->Branch(equal);
+      Condition is_smi = masm_->CheckSmi(value.reg());
+      dest->true_target()->Branch(is_smi);
+      __ xorpd(xmm0, xmm0);
+ __ ucomisd(xmm0, FieldOperand(value.reg(), HeapNumber::kValueOffset));
+      value.Unuse();
+      dest->Split(not_zero);
+    }
   } else {
     // Fast case checks.
     // 'false' => false.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to