OLD | NEW |
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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 MachineTypeUnion output : 15; // Output type of the node. | 63 MachineTypeUnion output : 15; // Output type of the node. |
64 }; | 64 }; |
65 | 65 |
66 RepresentationSelector(JSGraph* jsgraph, Zone* zone, | 66 RepresentationSelector(JSGraph* jsgraph, Zone* zone, |
67 RepresentationChanger* changer) | 67 RepresentationChanger* changer) |
68 : jsgraph_(jsgraph), | 68 : jsgraph_(jsgraph), |
69 count_(jsgraph->graph()->NodeCount()), | 69 count_(jsgraph->graph()->NodeCount()), |
70 info_(zone->NewArray<NodeInfo>(count_)), | 70 info_(zone->NewArray<NodeInfo>(count_)), |
71 nodes_(zone), | 71 nodes_(zone), |
72 replacements_(zone), | 72 replacements_(zone), |
73 contains_js_nodes_(false), | |
74 phase_(PROPAGATE), | 73 phase_(PROPAGATE), |
75 changer_(changer), | 74 changer_(changer), |
76 queue_(zone) { | 75 queue_(zone) { |
77 memset(info_, 0, sizeof(NodeInfo) * count_); | 76 memset(info_, 0, sizeof(NodeInfo) * count_); |
78 | 77 |
79 Factory* f = zone->isolate()->factory(); | 78 Factory* f = zone->isolate()->factory(); |
80 safe_int_additive_range_ = | 79 safe_int_additive_range_ = |
81 Type::Range(f->NewNumber(-std::pow(2.0, 52.0)), | 80 Type::Range(f->NewNumber(-std::pow(2.0, 52.0)), |
82 f->NewNumber(std::pow(2.0, 52.0)), zone); | 81 f->NewNumber(std::pow(2.0, 52.0)), zone); |
83 } | 82 } |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // JavaScript operators. | 507 // JavaScript operators. |
509 //------------------------------------------------------------------ | 508 //------------------------------------------------------------------ |
510 // For now, we assume that all JS operators were too complex to lower | 509 // For now, we assume that all JS operators were too complex to lower |
511 // to Simplified and that they will always require tagged value inputs | 510 // to Simplified and that they will always require tagged value inputs |
512 // and produce tagged value outputs. | 511 // and produce tagged value outputs. |
513 // TODO(turbofan): it might be possible to lower some JSOperators here, | 512 // TODO(turbofan): it might be possible to lower some JSOperators here, |
514 // but that responsibility really lies in the typed lowering phase. | 513 // but that responsibility really lies in the typed lowering phase. |
515 #define DEFINE_JS_CASE(x) case IrOpcode::k##x: | 514 #define DEFINE_JS_CASE(x) case IrOpcode::k##x: |
516 JS_OP_LIST(DEFINE_JS_CASE) | 515 JS_OP_LIST(DEFINE_JS_CASE) |
517 #undef DEFINE_JS_CASE | 516 #undef DEFINE_JS_CASE |
518 contains_js_nodes_ = true; | |
519 VisitInputs(node); | 517 VisitInputs(node); |
520 return SetOutput(node, kRepTagged); | 518 return SetOutput(node, kRepTagged); |
521 | 519 |
522 //------------------------------------------------------------------ | 520 //------------------------------------------------------------------ |
523 // Simplified operators. | 521 // Simplified operators. |
524 //------------------------------------------------------------------ | 522 //------------------------------------------------------------------ |
525 case IrOpcode::kBooleanNot: { | 523 case IrOpcode::kBooleanNot: { |
526 if (lower()) { | 524 if (lower()) { |
527 MachineTypeUnion input = GetInfo(node->InputAt(0))->output; | 525 MachineTypeUnion input = GetInfo(node->InputAt(0))->output; |
528 if (input & kRepBit) { | 526 if (input & kRepBit) { |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 os << static_cast<MachineType>(info); | 1023 os << static_cast<MachineType>(info); |
1026 } | 1024 } |
1027 } | 1025 } |
1028 | 1026 |
1029 private: | 1027 private: |
1030 JSGraph* jsgraph_; | 1028 JSGraph* jsgraph_; |
1031 int count_; // number of nodes in the graph | 1029 int count_; // number of nodes in the graph |
1032 NodeInfo* info_; // node id -> usage information | 1030 NodeInfo* info_; // node id -> usage information |
1033 NodeVector nodes_; // collected nodes | 1031 NodeVector nodes_; // collected nodes |
1034 NodeVector replacements_; // replacements to be done after lowering | 1032 NodeVector replacements_; // replacements to be done after lowering |
1035 bool contains_js_nodes_; // {true} if a JS operator was seen | |
1036 Phase phase_; // current phase of algorithm | 1033 Phase phase_; // current phase of algorithm |
1037 RepresentationChanger* changer_; // for inserting representation changes | 1034 RepresentationChanger* changer_; // for inserting representation changes |
1038 ZoneQueue<Node*> queue_; // queue for traversing the graph | 1035 ZoneQueue<Node*> queue_; // queue for traversing the graph |
1039 Type* safe_int_additive_range_; | 1036 Type* safe_int_additive_range_; |
1040 | 1037 |
1041 NodeInfo* GetInfo(Node* node) { | 1038 NodeInfo* GetInfo(Node* node) { |
1042 DCHECK(node->id() >= 0); | 1039 DCHECK(node->id() >= 0); |
1043 DCHECK(node->id() < count_); | 1040 DCHECK(node->id() < count_); |
1044 return &info_[node->id()]; | 1041 return &info_[node->id()]; |
1045 } | 1042 } |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 | 1472 |
1476 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 1473 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
1477 node->set_op(machine()->IntLessThanOrEqual()); | 1474 node->set_op(machine()->IntLessThanOrEqual()); |
1478 node->ReplaceInput(0, StringComparison(node, true)); | 1475 node->ReplaceInput(0, StringComparison(node, true)); |
1479 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1476 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1480 } | 1477 } |
1481 | 1478 |
1482 } // namespace compiler | 1479 } // namespace compiler |
1483 } // namespace internal | 1480 } // namespace internal |
1484 } // namespace v8 | 1481 } // namespace v8 |
OLD | NEW |