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
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3610
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
}
}
- // 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) {
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; }
}
+void FastCodeGenerator::SetStatementPosition(int pos) {
+ if (FLAG_debug_info) {
+ CodeGenerator::RecordPositions(masm_, pos);
+ }
+}
+
+
void FastCodeGenerator::SetSourcePosition(int pos) {
if (FLAG_debug_info && pos != RelocInfo::kNoPosition) {
masm_->RecordPosition(pos);
}
-
-
void FastCodeGenerator::VisitWithEnterStatement(WithEnterStatement* stmt) {
Comment cmnt(masm_, "[ WithEnterStatement");
SetStatementPosition(stmt);
__ 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);
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.
}
}
- // 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) {
}
}
- // 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) {