| 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/access-builder.h" | 7 #include "src/compiler/access-builder.h" | 
| 8 #include "src/compiler/change-lowering.h" | 8 #include "src/compiler/change-lowering.h" | 
| 9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" | 
| 10 #include "src/compiler/generic-node-inl.h" | 10 #include "src/compiler/generic-node-inl.h" | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 30 | 30 | 
| 31 template <typename ReturnType> | 31 template <typename ReturnType> | 
| 32 class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { | 32 class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { | 
| 33  public: | 33  public: | 
| 34   SimplifiedLoweringTester(MachineType p0 = kMachNone, | 34   SimplifiedLoweringTester(MachineType p0 = kMachNone, | 
| 35                            MachineType p1 = kMachNone, | 35                            MachineType p1 = kMachNone, | 
| 36                            MachineType p2 = kMachNone, | 36                            MachineType p2 = kMachNone, | 
| 37                            MachineType p3 = kMachNone, | 37                            MachineType p3 = kMachNone, | 
| 38                            MachineType p4 = kMachNone) | 38                            MachineType p4 = kMachNone) | 
| 39       : GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4), | 39       : GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4), | 
| 40         typer(this->zone()), | 40         typer(this->graph(), MaybeHandle<Context>()), | 
| 41         javascript(this->zone()), | 41         javascript(this->zone()), | 
| 42         jsgraph(this->graph(), this->common(), &javascript, &typer, | 42         jsgraph(this->graph(), this->common(), &javascript, this->machine()), | 
| 43                 this->machine()), |  | 
| 44         lowering(&jsgraph) {} | 43         lowering(&jsgraph) {} | 
| 45 | 44 | 
| 46   Typer typer; | 45   Typer typer; | 
| 47   JSOperatorBuilder javascript; | 46   JSOperatorBuilder javascript; | 
| 48   JSGraph jsgraph; | 47   JSGraph jsgraph; | 
| 49   SimplifiedLowering lowering; | 48   SimplifiedLowering lowering; | 
| 50 | 49 | 
| 51   void LowerAllNodes() { | 50   void LowerAllNodes() { | 
| 52     this->End(); | 51     this->End(); | 
|  | 52     typer.Run(); | 
| 53     lowering.LowerAllNodes(); | 53     lowering.LowerAllNodes(); | 
| 54   } | 54   } | 
| 55 | 55 | 
| 56   void LowerAllNodesAndLowerChanges() { | 56   void LowerAllNodesAndLowerChanges() { | 
| 57     this->End(); | 57     this->End(); | 
| 58     typer.Run(jsgraph.graph(), MaybeHandle<Context>()); | 58     typer.Run(); | 
| 59     lowering.LowerAllNodes(); | 59     lowering.LowerAllNodes(); | 
| 60 | 60 | 
| 61     Zone* zone = this->zone(); | 61     Zone* zone = this->zone(); | 
| 62     CompilationInfo info(zone->isolate(), zone); | 62     CompilationInfo info(zone->isolate(), zone); | 
| 63     Linkage linkage( | 63     Linkage linkage( | 
| 64         &info, Linkage::GetSimplifiedCDescriptor(zone, this->machine_sig_)); | 64         &info, Linkage::GetSimplifiedCDescriptor(zone, this->machine_sig_)); | 
| 65     ChangeLowering lowering(&jsgraph, &linkage); | 65     ChangeLowering lowering(&jsgraph, &linkage); | 
| 66     GraphReducer reducer(this->graph()); | 66     GraphReducer reducer(this->graph()); | 
| 67     reducer.AddReducer(&lowering); | 67     reducer.AddReducer(&lowering); | 
| 68     reducer.ReduceGraph(); | 68     reducer.ReduceGraph(); | 
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 667   Node* p0; | 667   Node* p0; | 
| 668   Node* p1; | 668   Node* p1; | 
| 669   Node* p2; | 669   Node* p2; | 
| 670   Node* start; | 670   Node* start; | 
| 671   Node* end; | 671   Node* end; | 
| 672   Node* ret; | 672   Node* ret; | 
| 673 | 673 | 
| 674   explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None(), | 674   explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None(), | 
| 675                         Type* p2_type = Type::None()) | 675                         Type* p2_type = Type::None()) | 
| 676       : GraphAndBuilders(main_zone()), | 676       : GraphAndBuilders(main_zone()), | 
| 677         typer(main_zone()), | 677         typer(graph(), MaybeHandle<Context>()), | 
| 678         javascript(main_zone()), | 678         javascript(main_zone()), | 
| 679         jsgraph(graph(), common(), &javascript, &typer, machine()) { | 679         jsgraph(graph(), common(), &javascript, machine()) { | 
| 680     start = graph()->NewNode(common()->Start(2)); | 680     start = graph()->NewNode(common()->Start(2)); | 
| 681     graph()->SetStart(start); | 681     graph()->SetStart(start); | 
| 682     ret = | 682     ret = | 
| 683         graph()->NewNode(common()->Return(), jsgraph.Constant(0), start, start); | 683         graph()->NewNode(common()->Return(), jsgraph.Constant(0), start, start); | 
| 684     end = graph()->NewNode(common()->End(), ret); | 684     end = graph()->NewNode(common()->End(), ret); | 
| 685     graph()->SetEnd(end); | 685     graph()->SetEnd(end); | 
| 686     p0 = graph()->NewNode(common()->Parameter(0), start); | 686     p0 = graph()->NewNode(common()->Parameter(0), start); | 
| 687     p1 = graph()->NewNode(common()->Parameter(1), start); | 687     p1 = graph()->NewNode(common()->Parameter(1), start); | 
| 688     p2 = graph()->NewNode(common()->Parameter(2), start); | 688     p2 = graph()->NewNode(common()->Parameter(2), start); | 
|  | 689     typer.Run(); | 
| 689     NodeProperties::SetBounds(p0, Bounds(p0_type)); | 690     NodeProperties::SetBounds(p0, Bounds(p0_type)); | 
| 690     NodeProperties::SetBounds(p1, Bounds(p1_type)); | 691     NodeProperties::SetBounds(p1, Bounds(p1_type)); | 
| 691     NodeProperties::SetBounds(p2, Bounds(p2_type)); | 692     NodeProperties::SetBounds(p2, Bounds(p2_type)); | 
| 692   } | 693   } | 
| 693 | 694 | 
| 694   void CheckLoweringBinop(IrOpcode::Value expected, const Operator* op) { | 695   void CheckLoweringBinop(IrOpcode::Value expected, const Operator* op) { | 
| 695     Node* node = Return(graph()->NewNode(op, p0, p1)); | 696     Node* node = Return(graph()->NewNode(op, p0, p1)); | 
| 696     Lower(); | 697     Lower(); | 
| 697     CHECK_EQ(expected, node->opcode()); | 698     CHECK_EQ(expected, node->opcode()); | 
| 698   } | 699   } | 
| 699 | 700 | 
| 700   void CheckLoweringTruncatedBinop(IrOpcode::Value expected, const Operator* op, | 701   void CheckLoweringTruncatedBinop(IrOpcode::Value expected, const Operator* op, | 
| 701                                    const Operator* trunc) { | 702                                    const Operator* trunc) { | 
| 702     Node* node = graph()->NewNode(op, p0, p1); | 703     Node* node = graph()->NewNode(op, p0, p1); | 
| 703     Return(graph()->NewNode(trunc, node)); | 704     Return(graph()->NewNode(trunc, node)); | 
| 704     Lower(); | 705     Lower(); | 
| 705     CHECK_EQ(expected, node->opcode()); | 706     CHECK_EQ(expected, node->opcode()); | 
| 706   } | 707   } | 
| 707 | 708 | 
| 708   void Lower() { | 709   void Lower() { | 
| 709     SimplifiedLowering lowering(&jsgraph); | 710     SimplifiedLowering(&jsgraph).LowerAllNodes(); | 
| 710     lowering.LowerAllNodes(); |  | 
| 711   } | 711   } | 
| 712 | 712 | 
| 713   // Inserts the node as the return value of the graph. | 713   // Inserts the node as the return value of the graph. | 
| 714   Node* Return(Node* node) { | 714   Node* Return(Node* node) { | 
| 715     ret->ReplaceInput(0, node); | 715     ret->ReplaceInput(0, node); | 
| 716     return node; | 716     return node; | 
| 717   } | 717   } | 
| 718 | 718 | 
| 719   // Inserts the node as the effect input to the return of the graph. | 719   // Inserts the node as the effect input to the return of the graph. | 
| 720   void Effect(Node* node) { ret->ReplaceInput(1, node); } | 720   void Effect(Node* node) { ret->ReplaceInput(1, node); } | 
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1533   CHECK_EQ(IrOpcode::kStore, store->opcode()); | 1533   CHECK_EQ(IrOpcode::kStore, store->opcode()); | 
| 1534   CHECK_EQ(t.p0, store->InputAt(0)); | 1534   CHECK_EQ(t.p0, store->InputAt(0)); | 
| 1535   CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2)); | 1535   CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2)); | 
| 1536 } | 1536 } | 
| 1537 | 1537 | 
| 1538 | 1538 | 
| 1539 TEST(UpdatePhi) { | 1539 TEST(UpdatePhi) { | 
| 1540   TestingGraph t(Type::Any(), Type::Signed32()); | 1540   TestingGraph t(Type::Any(), Type::Signed32()); | 
| 1541   static const MachineType kMachineTypes[] = {kMachInt32, kMachUint32, | 1541   static const MachineType kMachineTypes[] = {kMachInt32, kMachUint32, | 
| 1542                                               kMachFloat64}; | 1542                                               kMachFloat64}; | 
|  | 1543   Type* kTypes[] = {Type::Signed32(), Type::Unsigned32(), Type::Number()}; | 
| 1543 | 1544 | 
| 1544   for (size_t i = 0; i < arraysize(kMachineTypes); i++) { | 1545   for (size_t i = 0; i < arraysize(kMachineTypes); i++) { | 
| 1545     FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 1546     FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 
| 1546                           Handle<Name>::null(), Type::Any(), kMachineTypes[i]}; | 1547                           Handle<Name>::null(), kTypes[i], kMachineTypes[i]}; | 
| 1547 | 1548 | 
| 1548     Node* load0 = | 1549     Node* load0 = | 
| 1549         t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); | 1550         t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); | 
| 1550     Node* load1 = | 1551     Node* load1 = | 
| 1551         t.graph()->NewNode(t.simplified()->LoadField(access), t.p1, t.start); | 1552         t.graph()->NewNode(t.simplified()->LoadField(access), t.p1, t.start); | 
| 1552     Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0, | 1553     Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0, | 
| 1553                                    load1, t.start); | 1554                                    load1, t.start); | 
| 1554     t.Return(t.Use(phi, kMachineTypes[i])); | 1555     t.Return(t.Use(phi, kMachineTypes[i])); | 
| 1555     t.Lower(); | 1556     t.Lower(); | 
| 1556 | 1557 | 
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1924     TestingGraph t(Type::Unsigned32()); | 1925     TestingGraph t(Type::Unsigned32()); | 
| 1925     Node* k = t.jsgraph.Constant(0); | 1926     Node* k = t.jsgraph.Constant(0); | 
| 1926     Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(), t.p0, k); | 1927     Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(), t.p0, k); | 
| 1927     Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), mod); | 1928     Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), mod); | 
| 1928     t.Return(trunc); | 1929     t.Return(trunc); | 
| 1929     t.Lower(); | 1930     t.Lower(); | 
| 1930 | 1931 | 
| 1931     CHECK_EQ(IrOpcode::kFloat64Mod, mod->opcode()); | 1932     CHECK_EQ(IrOpcode::kFloat64Mod, mod->opcode()); | 
| 1932   } | 1933   } | 
| 1933 } | 1934 } | 
| OLD | NEW | 
|---|