Reviewers: Kevin Millikin,

Description:
Fix a problem when compiling built-ins with the top-level compiler (i.e.
--always-fast-compiler).

Change: Replace runtime call to NumberAdd for count operations with call to
binary op stub instead.

Description: Until now the top-level compiler always called a runtime function
for count operations. In some places we expected in the JS builtins smis as
arguments. A count operation would convert a smi argument into a heap number as
a result and this can trigger a runtime assert.

Please review this at http://codereview.chromium.org/548029

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/arm/fast-codegen-arm.cc
  M     src/ia32/fast-codegen-ia32.cc
  M     src/x64/fast-codegen-x64.cc


Index: src/ia32/fast-codegen-ia32.cc
===================================================================
--- src/ia32/fast-codegen-ia32.cc       (revision 3600)
+++ src/ia32/fast-codegen-ia32.cc       (working copy)
@@ -1393,14 +1393,13 @@
     }
   }

-  // Call runtime for +1/-1.
+  // Call stub for +1/-1.
   __ push(eax);
   __ push(Immediate(Smi::FromInt(1)));
-  if (expr->op() == Token::INC) {
-    __ CallRuntime(Runtime::kNumberAdd, 2);
-  } else {
-    __ CallRuntime(Runtime::kNumberSub, 2);
-  }
+ GenericBinaryOpStub stub(expr->op() == Token::INC ? Token::ADD : Token::SUB,
+                           NO_OVERWRITE,
+                           NO_GENERIC_BINARY_FLAGS);
+  __ CallStub(&stub);

   // Store the value returned in eax.
   switch (assign_type) {
Index: src/x64/fast-codegen-x64.cc
===================================================================
--- src/x64/fast-codegen-x64.cc (revision 3600)
+++ src/x64/fast-codegen-x64.cc (working copy)
@@ -1412,14 +1412,13 @@
     }
   }

-  // Call runtime for +1/-1.
+  // Call stub for +1/-1.
   __ push(rax);
   __ Push(Smi::FromInt(1));
-  if (expr->op() == Token::INC) {
-    __ CallRuntime(Runtime::kNumberAdd, 2);
-  } else {
-    __ CallRuntime(Runtime::kNumberSub, 2);
-  }
+ GenericBinaryOpStub stub(expr->op() == Token::INC ? Token::ADD : Token::SUB,
+                           NO_OVERWRITE,
+                           NO_GENERIC_BINARY_FLAGS);
+  __ CallStub(&stub);

   // Store the value returned in rax.
   switch (assign_type) {
Index: src/arm/fast-codegen-arm.cc
===================================================================
--- src/arm/fast-codegen-arm.cc (revision 3600)
+++ src/arm/fast-codegen-arm.cc (working copy)
@@ -1424,14 +1424,12 @@
     }
   }

-  // Call runtime for +1/-1.
-  if (expr->op() == Token::INC) {
-    __ mov(ip, Operand(Smi::FromInt(1)));
-  } else {
-    __ mov(ip, Operand(Smi::FromInt(-1)));
-  }
-  __ stm(db_w, sp, ip.bit() | r0.bit());
-  __ CallRuntime(Runtime::kNumberAdd, 2);
+  // Call stub for +1/-1.
+  __ mov(r1, Operand(expr->op() == Token::INC
+                     ? Smi::FromInt(1)
+                     : Smi::FromInt(-1)));
+  GenericBinaryOpStub stub(Token::ADD, NO_OVERWRITE);
+  __ CallStub(&stub);

   // Store the value returned in r0.
   switch (assign_type) {


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

Reply via email to