Revision: 4290
Author: [email protected]
Date: Fri Mar 26 00:55:38 2010
Log: Land http://codereview.chromium.org/1311003/diff/8001/9001 to allows
us to push to trunk. Corrected the ASSERT from the review.
Review URL: http://codereview.chromium.org/1404001
http://code.google.com/p/v8/source/detail?r=4290
Modified:
/branches/bleeding_edge/src/arm/codegen-arm.cc
/branches/bleeding_edge/src/arm/codegen-arm.h
/branches/bleeding_edge/src/ia32/codegen-ia32.cc
/branches/bleeding_edge/src/ia32/codegen-ia32.h
/branches/bleeding_edge/src/x64/codegen-x64.cc
/branches/bleeding_edge/src/x64/codegen-x64.h
=======================================
--- /branches/bleeding_edge/src/arm/codegen-arm.cc Thu Mar 25 05:04:34 2010
+++ /branches/bleeding_edge/src/arm/codegen-arm.cc Fri Mar 26 00:55:38 2010
@@ -3996,14 +3996,7 @@
}
-void CodeGenerator::VisitBinaryOperation(BinaryOperation* node) {
-#ifdef DEBUG
- int original_height = frame_->height();
-#endif
- VirtualFrame::SpilledScope spilled_scope;
- Comment cmnt(masm_, "[ BinaryOperation");
- Token::Value op = node->op();
-
+void CodeGenerator::GenerateLogicalBooleanOperation(BinaryOperation* node)
{
// According to ECMA-262 section 11.11, page 58, the binary logical
// operators must yield the result of one of the two expressions
// before any ToBoolean() conversions. This means that the value
@@ -4015,8 +4008,7 @@
// after evaluating the left hand side (due to the shortcut
// semantics), but the compiler must (statically) know if the result
// of compiling the binary operation is materialized or not.
-
- if (op == Token::AND) {
+ if (node->op() == Token::AND) {
JumpTarget is_true;
LoadConditionAndSpill(node->left(),
&is_true,
@@ -4062,7 +4054,8 @@
ASSERT(!has_valid_frame() && !has_cc() && !is_true.is_linked());
}
- } else if (op == Token::OR) {
+ } else {
+ ASSERT(node->op() == Token::OR);
JumpTarget is_false;
LoadConditionAndSpill(node->left(),
true_target(),
@@ -4107,7 +4100,19 @@
// Nothing to do.
ASSERT(!has_valid_frame() && !has_cc() && !is_false.is_linked());
}
-
+ }
+}
+
+
+void CodeGenerator::VisitBinaryOperation(BinaryOperation* node) {
+#ifdef DEBUG
+ int original_height = frame_->height();
+#endif
+ VirtualFrame::SpilledScope spilled_scope;
+ Comment cmnt(masm_, "[ BinaryOperation");
+
+ if (node->op() == Token::AND || node->op() == Token::OR) {
+ GenerateLogicalBooleanOperation(node);
} else {
// Optimize for the case where (at least) one of the expressions
// is a literal small integer.
=======================================
--- /branches/bleeding_edge/src/arm/codegen-arm.h Tue Mar 23 06:38:04 2010
+++ /branches/bleeding_edge/src/arm/codegen-arm.h Fri Mar 26 00:55:38 2010
@@ -306,6 +306,9 @@
void ToBoolean(JumpTarget* true_target, JumpTarget* false_target);
+ // Generate code that computes a shortcutting logical operation.
+ void GenerateLogicalBooleanOperation(BinaryOperation* node);
+
void GenericBinaryOperation(Token::Value op,
OverwriteMode overwrite_mode,
int known_rhs = kUnknownIntValue);
=======================================
--- /branches/bleeding_edge/src/ia32/codegen-ia32.cc Thu Mar 25 06:35:05
2010
+++ /branches/bleeding_edge/src/ia32/codegen-ia32.cc Fri Mar 26 00:55:38
2010
@@ -7424,10 +7424,8 @@
}
}
-void CodeGenerator::VisitBinaryOperation(BinaryOperation* node) {
- Comment cmnt(masm_, "[ BinaryOperation");
- Token::Value op = node->op();
-
+
+void CodeGenerator::GenerateLogicalBooleanOperation(BinaryOperation* node)
{
// According to ECMA-262 section 11.11, page 58, the binary logical
// operators must yield the result of one of the two expressions
// before any ToBoolean() conversions. This means that the value
@@ -7437,7 +7435,7 @@
// control flow), we force the right hand side to do the same. This
// is necessary because we assume that if we get control flow on the
// last path out of an expression we got it on all paths.
- if (op == Token::AND) {
+ if (node->op() == Token::AND) {
ASSERT(!in_safe_int32_mode());
JumpTarget is_true;
ControlDestination dest(&is_true, destination()->false_target(), true);
@@ -7501,7 +7499,8 @@
exit.Bind();
}
- } else if (op == Token::OR) {
+ } else {
+ ASSERT(node->op() == Token::OR);
ASSERT(!in_safe_int32_mode());
JumpTarget is_false;
ControlDestination dest(destination()->true_target(), &is_false,
false);
@@ -7563,7 +7562,15 @@
// Exit (always with a materialized value).
exit.Bind();
}
-
+ }
+}
+
+
+void CodeGenerator::VisitBinaryOperation(BinaryOperation* node) {
+ Comment cmnt(masm_, "[ BinaryOperation");
+
+ if (node->op() == Token::AND || node->op() == Token::OR) {
+ GenerateLogicalBooleanOperation(node);
} else if (in_safe_int32_mode()) {
Visit(node->left());
Visit(node->right());
=======================================
--- /branches/bleeding_edge/src/ia32/codegen-ia32.h Thu Mar 25 06:22:37 2010
+++ /branches/bleeding_edge/src/ia32/codegen-ia32.h Fri Mar 26 00:55:38 2010
@@ -489,6 +489,9 @@
// control destination.
void ToBoolean(ControlDestination* destination);
+ // Generate code that computes a shortcutting logical operation.
+ void GenerateLogicalBooleanOperation(BinaryOperation* node);
+
void GenericBinaryOperation(
Token::Value op,
StaticType* type,
=======================================
--- /branches/bleeding_edge/src/x64/codegen-x64.cc Thu Mar 25 05:44:15 2010
+++ /branches/bleeding_edge/src/x64/codegen-x64.cc Fri Mar 26 00:55:38 2010
@@ -3281,13 +3281,7 @@
}
-void CodeGenerator::VisitBinaryOperation(BinaryOperation* node) {
- // TODO(X64): This code was copied verbatim from codegen-ia32.
- // Either find a reason to change it or move it to a shared location.
-
- Comment cmnt(masm_, "[ BinaryOperation");
- Token::Value op = node->op();
-
+void CodeGenerator::GenerateLogicalBooleanOperation(BinaryOperation* node)
{
// According to ECMA-262 section 11.11, page 58, the binary logical
// operators must yield the result of one of the two expressions
// before any ToBoolean() conversions. This means that the value
@@ -3297,7 +3291,7 @@
// control flow), we force the right hand side to do the same. This
// is necessary because we assume that if we get control flow on the
// last path out of an expression we got it on all paths.
- if (op == Token::AND) {
+ if (node->op() == Token::AND) {
JumpTarget is_true;
ControlDestination dest(&is_true, destination()->false_target(), true);
LoadCondition(node->left(), &dest, false);
@@ -3360,7 +3354,8 @@
exit.Bind();
}
- } else if (op == Token::OR) {
+ } else {
+ ASSERT(node->op() == Token::OR);
JumpTarget is_false;
ControlDestination dest(destination()->true_target(), &is_false,
false);
LoadCondition(node->left(), &dest, false);
@@ -3421,7 +3416,14 @@
// Exit (always with a materialized value).
exit.Bind();
}
-
+ }
+}
+
+void CodeGenerator::VisitBinaryOperation(BinaryOperation* node) {
+ Comment cmnt(masm_, "[ BinaryOperation");
+
+ if (node->op() == Token::AND || node->op() == Token::OR) {
+ GenerateLogicalBooleanOperation(node);
} else {
// NOTE: The code below assumes that the slow cases (calls to runtime)
// never return a constant/immutable object.
=======================================
--- /branches/bleeding_edge/src/x64/codegen-x64.h Thu Mar 25 05:44:15 2010
+++ /branches/bleeding_edge/src/x64/codegen-x64.h Fri Mar 26 00:55:38 2010
@@ -454,6 +454,9 @@
// control destination.
void ToBoolean(ControlDestination* destination);
+ // Generate code that computes a shortcutting logical operation.
+ void GenerateLogicalBooleanOperation(BinaryOperation* node);
+
void GenericBinaryOperation(
Token::Value op,
StaticType* type,
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
To unsubscribe from this group, send email to v8-dev+unsubscribegooglegroups.com or reply
to this email with the words "REMOVE ME" as the subject.