Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: src/arm/fast-codegen-arm.cc

Issue 342019: Add binary operations to fast compiler. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/fast-codegen-arm.cc
===================================================================
--- src/arm/fast-codegen-arm.cc (revision 3171)
+++ src/arm/fast-codegen-arm.cc (working copy)
@@ -607,7 +607,7 @@
for (int i = 0; i < arg_count; i++) {
Visit(args->at(i));
ASSERT(args->at(i)->location().is_value());
- // If location is temporary, it is already on the stack,
+ // If location is value, it is already on the stack,
// so nothing to do here.
}
@@ -648,11 +648,57 @@
void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) {
- // Compile a short-circuited boolean or operation in a non-test
- // context.
- ASSERT(expr->op() == Token::OR);
+ switch (expr->op()) {
+ case Token::COMMA:
+ ASSERT(expr->left()->location().is_effect());
+ ASSERT_EQ(expr->right()->location().type(), expr->location().type());
+ Visit(expr->left());
+ Visit(expr->right());
+ break;
+
+ case Token::OR:
+ case Token::AND:
+ EmitLogicalOperation(expr);
+ break;
+
+ case Token::ADD:
+ case Token::SUB:
+ case Token::DIV:
+ case Token::MOD:
+ case Token::MUL:
+ case Token::BIT_OR:
+ case Token::BIT_AND:
+ case Token::BIT_XOR:
+ case Token::SHL:
+ case Token::SHR:
+ case Token::SAR: {
+ ASSERT(expr->left()->location().is_value());
+ ASSERT(expr->right()->location().is_value());
+
+ Visit(expr->left());
+ Visit(expr->right());
+ __ pop(r0);
+ __ pop(r1);
+ GenericBinaryOpStub stub(expr->op(),
+ NO_OVERWRITE);
+ __ CallStub(&stub);
+ Move(expr->location(), r0);
+
+ break;
+ }
+ default:
+ UNREACHABLE();
+ }
+}
+
+
+void FastCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) {
+ // Compile a short-circuited boolean operation in a non-test context.
+
// Compile (e0 || e1) as if it were
// (let (temp = e0) temp ? temp : e1).
+ // Compile (e0 && e1) as if it were
+ // (let (temp = e0) !temp ? temp : e1).
Label done;
Location destination = expr->location();
@@ -675,9 +721,13 @@
}
}
// The left-hand value is in on top of the stack. It is duplicated on the
- // stack iff the destination location is temporary.
+ // stack iff the destination location is value.
__ CallRuntime(Runtime::kToBool, 1);
- __ LoadRoot(ip, Heap::kTrueValueRootIndex);
+ if (expr->op() == Token::OR) {
+ __ LoadRoot(ip, Heap::kTrueValueRootIndex);
+ } else {
+ __ LoadRoot(ip, Heap::kFalseValueRootIndex);
+ }
__ cmp(r0, ip);
__ b(eq, &done);
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698