OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/representation-change.h" | 5 #include "src/compiler/representation-change.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
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" |
11 #include "src/compiler/machine-operator.h" | 11 #include "src/compiler/machine-operator.h" |
| 12 #include "src/compiler/node-matchers.h" |
12 | 13 |
13 namespace v8 { | 14 namespace v8 { |
14 namespace internal { | 15 namespace internal { |
15 namespace compiler { | 16 namespace compiler { |
16 | 17 |
17 const char* Truncation::description() const { | 18 const char* Truncation::description() const { |
18 switch (kind()) { | 19 switch (kind()) { |
19 case TruncationKind::kNone: | 20 case TruncationKind::kNone: |
20 return "no-value-use"; | 21 return "no-value-use"; |
21 case TruncationKind::kBool: | 22 case TruncationKind::kBool: |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 } | 688 } |
688 return jsgraph()->graph()->NewNode(op, node); | 689 return jsgraph()->graph()->NewNode(op, node); |
689 } | 690 } |
690 | 691 |
691 | 692 |
692 Node* RepresentationChanger::GetBitRepresentationFor( | 693 Node* RepresentationChanger::GetBitRepresentationFor( |
693 Node* node, MachineRepresentation output_rep, Type* output_type) { | 694 Node* node, MachineRepresentation output_rep, Type* output_type) { |
694 // Eagerly fold representation changes for constants. | 695 // Eagerly fold representation changes for constants. |
695 switch (node->opcode()) { | 696 switch (node->opcode()) { |
696 case IrOpcode::kHeapConstant: { | 697 case IrOpcode::kHeapConstant: { |
697 Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(node); | 698 HeapObjectMatcher m(node); |
698 return jsgraph()->Int32Constant(value->BooleanValue() ? 1 : 0); | 699 if (m.Is(factory()->false_value())) { |
| 700 return jsgraph()->Int32Constant(0); |
| 701 } else if (m.Is(factory()->true_value())) { |
| 702 return jsgraph()->Int32Constant(1); |
| 703 } |
699 } | 704 } |
700 default: | 705 default: |
701 break; | 706 break; |
702 } | 707 } |
703 // Select the correct X -> Bit operator. | 708 // Select the correct X -> Bit operator. |
704 const Operator* op; | 709 const Operator* op; |
705 if (output_type->Is(Type::None())) { | 710 if (output_type->Is(Type::None())) { |
706 // This is an impossible value; it should not be used at runtime. | 711 // This is an impossible value; it should not be used at runtime. |
707 // We just provide a dummy value here. | 712 // We just provide a dummy value here. |
708 return jsgraph()->Int32Constant(0); | 713 return jsgraph()->Int32Constant(0); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 node); | 1012 node); |
1008 } | 1013 } |
1009 | 1014 |
1010 Node* RepresentationChanger::InsertChangeUint32ToFloat64(Node* node) { | 1015 Node* RepresentationChanger::InsertChangeUint32ToFloat64(Node* node) { |
1011 return jsgraph()->graph()->NewNode(machine()->ChangeUint32ToFloat64(), node); | 1016 return jsgraph()->graph()->NewNode(machine()->ChangeUint32ToFloat64(), node); |
1012 } | 1017 } |
1013 | 1018 |
1014 } // namespace compiler | 1019 } // namespace compiler |
1015 } // namespace internal | 1020 } // namespace internal |
1016 } // namespace v8 | 1021 } // namespace v8 |
OLD | NEW |