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

Unified Diff: src/compiler/simplified-lowering.cc

Issue 579723004: Introduce simplified BooleanToNumber operator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 6 years, 3 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 | « src/compiler/opcodes.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index d1f2ee3bd1ec142819a2d4de28f31724851c21de..89c58685f1b43cbfd6b767f9160b3567eeb5fb49 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -432,6 +432,24 @@ class RepresentationSelector {
}
break;
}
+ case IrOpcode::kBooleanToNumber: {
+ if (lower()) {
+ MachineTypeUnion input = GetInfo(node->InputAt(0))->output;
+ if (input & kRepBit) {
+ // BooleanToNumber(x: kRepBit) => x
+ DeferReplacement(node, node->InputAt(0));
+ } else {
+ // BooleanToNumber(x: kRepTagged) => WordEqual(x, #true)
+ node->set_op(lowering->machine()->WordEqual());
+ node->AppendInput(jsgraph_->zone(), jsgraph_->TrueConstant());
+ }
+ } else {
+ // No input representation requirement; adapt during lowering.
+ ProcessInput(node, 0, kTypeBool);
+ SetOutput(node, kMachInt32);
+ }
+ break;
+ }
case IrOpcode::kNumberEqual:
case IrOpcode::kNumberLessThan:
case IrOpcode::kNumberLessThanOrEqual: {
« no previous file with comments | « src/compiler/opcodes.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698