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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/compiler/control-builders.h" | 7 #include "src/compiler/control-builders.h" |
8 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
9 #include "src/compiler/graph-visualizer.h" | 9 #include "src/compiler/graph-visualizer.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 template <typename ReturnType> | 29 template <typename ReturnType> |
30 class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { | 30 class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { |
31 public: | 31 public: |
32 SimplifiedLoweringTester(MachineType p0 = kMachNone, | 32 SimplifiedLoweringTester(MachineType p0 = kMachNone, |
33 MachineType p1 = kMachNone, | 33 MachineType p1 = kMachNone, |
34 MachineType p2 = kMachNone, | 34 MachineType p2 = kMachNone, |
35 MachineType p3 = kMachNone, | 35 MachineType p3 = kMachNone, |
36 MachineType p4 = kMachNone) | 36 MachineType p4 = kMachNone) |
37 : GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4), | 37 : GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4), |
38 typer(this->zone()), | 38 typer(this->graph(), MaybeHandle<Context>()), |
39 jsgraph(this->graph(), this->common(), &typer), | 39 jsgraph(this->graph(), this->common()), |
40 lowering(&jsgraph) {} | 40 lowering(&jsgraph) {} |
41 | 41 |
42 Typer typer; | 42 Typer typer; |
43 JSGraph jsgraph; | 43 JSGraph jsgraph; |
44 SimplifiedLowering lowering; | 44 SimplifiedLowering lowering; |
45 | 45 |
46 void LowerAllNodes() { | 46 void LowerAllNodes() { |
47 this->End(); | 47 this->End(); |
| 48 typer.Run(); |
48 lowering.LowerAllNodes(); | 49 lowering.LowerAllNodes(); |
49 } | 50 } |
50 | 51 |
51 Factory* factory() { return this->isolate()->factory(); } | 52 Factory* factory() { return this->isolate()->factory(); } |
52 Heap* heap() { return this->isolate()->heap(); } | 53 Heap* heap() { return this->isolate()->heap(); } |
53 }; | 54 }; |
54 | 55 |
55 | 56 |
56 // TODO(dcarney): find a home for these functions. | 57 // TODO(dcarney): find a home for these functions. |
57 namespace { | 58 namespace { |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 Typer typer; | 608 Typer typer; |
608 JSGraph jsgraph; | 609 JSGraph jsgraph; |
609 Node* p0; | 610 Node* p0; |
610 Node* p1; | 611 Node* p1; |
611 Node* start; | 612 Node* start; |
612 Node* end; | 613 Node* end; |
613 Node* ret; | 614 Node* ret; |
614 | 615 |
615 explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None()) | 616 explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None()) |
616 : GraphAndBuilders(main_zone()), | 617 : GraphAndBuilders(main_zone()), |
617 typer(main_zone()), | 618 typer(graph(), MaybeHandle<Context>()), |
618 jsgraph(graph(), common(), &typer) { | 619 jsgraph(graph(), common()) { |
619 start = graph()->NewNode(common()->Start(2)); | 620 start = graph()->NewNode(common()->Start(2)); |
620 graph()->SetStart(start); | 621 graph()->SetStart(start); |
621 ret = | 622 ret = |
622 graph()->NewNode(common()->Return(), jsgraph.Constant(0), start, start); | 623 graph()->NewNode(common()->Return(), jsgraph.Constant(0), start, start); |
623 end = graph()->NewNode(common()->End(), ret); | 624 end = graph()->NewNode(common()->End(), ret); |
624 graph()->SetEnd(end); | 625 graph()->SetEnd(end); |
625 p0 = graph()->NewNode(common()->Parameter(0), start); | 626 p0 = graph()->NewNode(common()->Parameter(0), start); |
626 p1 = graph()->NewNode(common()->Parameter(1), start); | 627 p1 = graph()->NewNode(common()->Parameter(1), start); |
| 628 typer.Run(); |
627 NodeProperties::SetBounds(p0, Bounds(p0_type)); | 629 NodeProperties::SetBounds(p0, Bounds(p0_type)); |
628 NodeProperties::SetBounds(p1, Bounds(p1_type)); | 630 NodeProperties::SetBounds(p1, Bounds(p1_type)); |
629 } | 631 } |
630 | 632 |
631 void CheckLoweringBinop(IrOpcode::Value expected, Operator* op) { | 633 void CheckLoweringBinop(IrOpcode::Value expected, Operator* op) { |
632 Node* node = Return(graph()->NewNode(op, p0, p1)); | 634 Node* node = Return(graph()->NewNode(op, p0, p1)); |
633 Lower(); | 635 Lower(); |
634 CHECK_EQ(expected, node->opcode()); | 636 CHECK_EQ(expected, node->opcode()); |
635 } | 637 } |
636 | 638 |
637 void CheckLoweringTruncatedBinop(IrOpcode::Value expected, Operator* op, | 639 void CheckLoweringTruncatedBinop(IrOpcode::Value expected, Operator* op, |
638 Operator* trunc) { | 640 Operator* trunc) { |
639 Node* node = graph()->NewNode(op, p0, p1); | 641 Node* node = graph()->NewNode(op, p0, p1); |
640 Return(graph()->NewNode(trunc, node)); | 642 Return(graph()->NewNode(trunc, node)); |
641 Lower(); | 643 Lower(); |
642 CHECK_EQ(expected, node->opcode()); | 644 CHECK_EQ(expected, node->opcode()); |
643 } | 645 } |
644 | 646 |
645 void Lower() { | 647 void Lower() { |
646 SimplifiedLowering lowering(&jsgraph); | 648 SimplifiedLowering(&jsgraph).LowerAllNodes(); |
647 lowering.LowerAllNodes(); | |
648 } | 649 } |
649 | 650 |
650 // Inserts the node as the return value of the graph. | 651 // Inserts the node as the return value of the graph. |
651 Node* Return(Node* node) { | 652 Node* Return(Node* node) { |
652 ret->ReplaceInput(0, node); | 653 ret->ReplaceInput(0, node); |
653 return node; | 654 return node; |
654 } | 655 } |
655 | 656 |
656 // Inserts the node as the effect input to the return of the graph. | 657 // Inserts the node as the effect input to the return of the graph. |
657 void Effect(Node* node) { ret->ReplaceInput(1, node); } | 658 void Effect(Node* node) { ret->ReplaceInput(1, node); } |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 | 1342 |
1342 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, | 1343 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, |
1343 t.p1, t.start, t.start); | 1344 t.p1, t.start, t.start); |
1344 t.Effect(store); | 1345 t.Effect(store); |
1345 t.Lower(); | 1346 t.Lower(); |
1346 | 1347 |
1347 CHECK_EQ(IrOpcode::kStore, store->opcode()); | 1348 CHECK_EQ(IrOpcode::kStore, store->opcode()); |
1348 CHECK_EQ(t.p0, store->InputAt(0)); | 1349 CHECK_EQ(t.p0, store->InputAt(0)); |
1349 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2)); | 1350 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2)); |
1350 } | 1351 } |
OLD | NEW |