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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/opcodes.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/simplified-lowering.h" 5 #include "src/compiler/simplified-lowering.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/graph-inl.h" 10 #include "src/compiler/graph-inl.h"
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 node->set_op(lowering->machine()->WordEqual()); 425 node->set_op(lowering->machine()->WordEqual());
426 node->AppendInput(jsgraph_->zone(), jsgraph_->FalseConstant()); 426 node->AppendInput(jsgraph_->zone(), jsgraph_->FalseConstant());
427 } 427 }
428 } else { 428 } else {
429 // No input representation requirement; adapt during lowering. 429 // No input representation requirement; adapt during lowering.
430 ProcessInput(node, 0, kTypeBool); 430 ProcessInput(node, 0, kTypeBool);
431 SetOutput(node, kRepBit); 431 SetOutput(node, kRepBit);
432 } 432 }
433 break; 433 break;
434 } 434 }
435 case IrOpcode::kBooleanToNumber: {
436 if (lower()) {
437 MachineTypeUnion input = GetInfo(node->InputAt(0))->output;
438 if (input & kRepBit) {
439 // BooleanToNumber(x: kRepBit) => x
440 DeferReplacement(node, node->InputAt(0));
441 } else {
442 // BooleanToNumber(x: kRepTagged) => WordEqual(x, #true)
443 node->set_op(lowering->machine()->WordEqual());
444 node->AppendInput(jsgraph_->zone(), jsgraph_->TrueConstant());
445 }
446 } else {
447 // No input representation requirement; adapt during lowering.
448 ProcessInput(node, 0, kTypeBool);
449 SetOutput(node, kMachInt32);
450 }
451 break;
452 }
435 case IrOpcode::kNumberEqual: 453 case IrOpcode::kNumberEqual:
436 case IrOpcode::kNumberLessThan: 454 case IrOpcode::kNumberLessThan:
437 case IrOpcode::kNumberLessThanOrEqual: { 455 case IrOpcode::kNumberLessThanOrEqual: {
438 // Number comparisons reduce to integer comparisons for integer inputs. 456 // Number comparisons reduce to integer comparisons for integer inputs.
439 if (BothInputsAre(node, Type::Signed32())) { 457 if (BothInputsAre(node, Type::Signed32())) {
440 // => signed Int32Cmp 458 // => signed Int32Cmp
441 VisitInt32Cmp(node); 459 VisitInt32Cmp(node);
442 if (lower()) node->set_op(Int32Op(node)); 460 if (lower()) node->set_op(Int32Op(node));
443 } else if (BothInputsAre(node, Type::Unsigned32())) { 461 } else if (BothInputsAre(node, Type::Unsigned32())) {
444 // => unsigned Int32Cmp 462 // => unsigned Int32Cmp
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { 921 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) {
904 node->set_op(machine()->IntLessThanOrEqual()); 922 node->set_op(machine()->IntLessThanOrEqual());
905 node->ReplaceInput(0, StringComparison(node, true)); 923 node->ReplaceInput(0, StringComparison(node, true));
906 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); 924 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL));
907 } 925 }
908 926
909 927
910 } // namespace compiler 928 } // namespace compiler
911 } // namespace internal 929 } // namespace internal
912 } // namespace v8 930 } // namespace v8
OLDNEW
« 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