Revision: 3610
Author: [email protected]
Date: Thu Jan 14 09:22:59 2010
Log: Fix a problem when compiling built-ins with the top-level compiler.

Replace runtime call to NumberAdd with call to binary op stub.

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.
If we perform a count operation before all smis would get converted into
heap numbers by the runtime number add function and result in a runtime
assert.

Also: Add missing debugger information in the top-level compiler for
do-while loops.


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

Modified:
 /branches/bleeding_edge/src/arm/fast-codegen-arm.cc
 /branches/bleeding_edge/src/ast.h
 /branches/bleeding_edge/src/fast-codegen.cc
 /branches/bleeding_edge/src/fast-codegen.h
 /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc
 /branches/bleeding_edge/src/x64/fast-codegen-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/fast-codegen-arm.cc Wed Jan 13 04:13:37 2010 +++ /branches/bleeding_edge/src/arm/fast-codegen-arm.cc Thu Jan 14 09:22:59 2010
@@ -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) {
=======================================
--- /branches/bleeding_edge/src/ast.h   Wed Jan 13 08:21:06 2010
+++ /branches/bleeding_edge/src/ast.h   Thu Jan 14 09:22:59 2010
@@ -1184,6 +1184,9 @@
   bool is_prefix() const { return is_prefix_; }
   bool is_postfix() const { return !is_prefix_; }
   Token::Value op() const { return op_; }
+  Token::Value binary_op() {
+    return op_ == Token::INC ? Token::ADD : Token::SUB;
+  }
   Expression* expression() const { return expression_; }

   virtual void MarkAsStatement() { is_prefix_ = true; }
=======================================
--- /branches/bleeding_edge/src/fast-codegen.cc Wed Jan 13 03:29:08 2010
+++ /branches/bleeding_edge/src/fast-codegen.cc Thu Jan 14 09:22:59 2010
@@ -181,6 +181,13 @@
     CodeGenerator::RecordPositions(masm_, stmt->statement_pos());
   }
 }
+
+
+void FastCodeGenerator::SetStatementPosition(int pos) {
+  if (FLAG_debug_info) {
+    CodeGenerator::RecordPositions(masm_, pos);
+  }
+}


 void FastCodeGenerator::SetSourcePosition(int pos) {
@@ -358,8 +365,6 @@

   EmitReturnSequence(stmt->statement_pos());
 }
-
-


 void FastCodeGenerator::VisitWithEnterStatement(WithEnterStatement* stmt) {
@@ -412,6 +417,7 @@
   __ bind(&stack_check_success);

   __ bind(loop_statement.continue_target());
+  SetStatementPosition(stmt->condition_position());
   VisitForControl(stmt->cond(), &body, loop_statement.break_target());

   __ bind(&stack_limit_hit);
=======================================
--- /branches/bleeding_edge/src/fast-codegen.h  Wed Jan 13 03:29:08 2010
+++ /branches/bleeding_edge/src/fast-codegen.h  Thu Jan 14 09:22:59 2010
@@ -296,6 +296,7 @@
   void SetFunctionPosition(FunctionLiteral* fun);
   void SetReturnPosition(FunctionLiteral* fun);
   void SetStatementPosition(Statement* stmt);
+  void SetStatementPosition(int pos);
   void SetSourcePosition(int pos);

   // Non-local control flow support.
=======================================
--- /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc Wed Jan 13 04:13:37 2010 +++ /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc Thu Jan 14 09:22:59 2010
@@ -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->binary_op(),
+                           NO_OVERWRITE,
+                           NO_GENERIC_BINARY_FLAGS);
+  __ CallStub(&stub);

   // Store the value returned in eax.
   switch (assign_type) {
=======================================
--- /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Wed Jan 13 04:13:37 2010 +++ /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Thu Jan 14 09:22:59 2010
@@ -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->binary_op(),
+                           NO_OVERWRITE,
+                           NO_GENERIC_BINARY_FLAGS);
+  __ CallStub(&stub);

   // Store the value returned in rax.
   switch (assign_type) {
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to