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

Side by Side Diff: test/cctest/compiler/test-simplified-lowering.cc

Issue 1348073002: [turbofan] Get rid of type lower bounds. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 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
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 <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/graph-reducer.h" 10 #include "src/compiler/graph-reducer.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // TODO(titzer): factor these tests out to test-run-simplifiedops.cc. 94 // TODO(titzer): factor these tests out to test-run-simplifiedops.cc.
95 // TODO(titzer): test tagged representation for input to NumberToInt32. 95 // TODO(titzer): test tagged representation for input to NumberToInt32.
96 TEST(RunNumberToInt32_float64) { 96 TEST(RunNumberToInt32_float64) {
97 // TODO(titzer): explicit load/stores here are only because of representations 97 // TODO(titzer): explicit load/stores here are only because of representations
98 double input; 98 double input;
99 int32_t result; 99 int32_t result;
100 SimplifiedLoweringTester<Object*> t; 100 SimplifiedLoweringTester<Object*> t;
101 FieldAccess load = {kUntaggedBase, 0, Handle<Name>(), Type::Number(), 101 FieldAccess load = {kUntaggedBase, 0, Handle<Name>(), Type::Number(),
102 kMachFloat64}; 102 kMachFloat64};
103 Node* loaded = t.LoadField(load, t.PointerConstant(&input)); 103 Node* loaded = t.LoadField(load, t.PointerConstant(&input));
104 NodeProperties::SetBounds(loaded, Bounds(Type::Number())); 104 NodeProperties::SetType(loaded, Type::Number());
105 Node* convert = t.NumberToInt32(loaded); 105 Node* convert = t.NumberToInt32(loaded);
106 FieldAccess store = {kUntaggedBase, 0, Handle<Name>(), Type::Signed32(), 106 FieldAccess store = {kUntaggedBase, 0, Handle<Name>(), Type::Signed32(),
107 kMachInt32}; 107 kMachInt32};
108 t.StoreField(store, t.PointerConstant(&result), convert); 108 t.StoreField(store, t.PointerConstant(&result), convert);
109 t.Return(t.jsgraph.TrueConstant()); 109 t.Return(t.jsgraph.TrueConstant());
110 t.LowerAllNodes(); 110 t.LowerAllNodes();
111 t.GenerateCode(); 111 t.GenerateCode();
112 112
113 FOR_FLOAT64_INPUTS(i) { 113 FOR_FLOAT64_INPUTS(i) {
114 input = *i; 114 input = *i;
115 int32_t expected = DoubleToInt32(*i); 115 int32_t expected = DoubleToInt32(*i);
116 t.Call(); 116 t.Call();
117 CHECK_EQ(expected, result); 117 CHECK_EQ(expected, result);
118 } 118 }
119 } 119 }
120 120
121 121
122 // TODO(titzer): test tagged representation for input to NumberToUint32. 122 // TODO(titzer): test tagged representation for input to NumberToUint32.
123 TEST(RunNumberToUint32_float64) { 123 TEST(RunNumberToUint32_float64) {
124 // TODO(titzer): explicit load/stores here are only because of representations 124 // TODO(titzer): explicit load/stores here are only because of representations
125 double input; 125 double input;
126 uint32_t result; 126 uint32_t result;
127 SimplifiedLoweringTester<Object*> t; 127 SimplifiedLoweringTester<Object*> t;
128 FieldAccess load = {kUntaggedBase, 0, Handle<Name>(), Type::Number(), 128 FieldAccess load = {kUntaggedBase, 0, Handle<Name>(), Type::Number(),
129 kMachFloat64}; 129 kMachFloat64};
130 Node* loaded = t.LoadField(load, t.PointerConstant(&input)); 130 Node* loaded = t.LoadField(load, t.PointerConstant(&input));
131 NodeProperties::SetBounds(loaded, Bounds(Type::Number())); 131 NodeProperties::SetType(loaded, Type::Number());
132 Node* convert = t.NumberToUint32(loaded); 132 Node* convert = t.NumberToUint32(loaded);
133 FieldAccess store = {kUntaggedBase, 0, Handle<Name>(), Type::Unsigned32(), 133 FieldAccess store = {kUntaggedBase, 0, Handle<Name>(), Type::Unsigned32(),
134 kMachUint32}; 134 kMachUint32};
135 t.StoreField(store, t.PointerConstant(&result), convert); 135 t.StoreField(store, t.PointerConstant(&result), convert);
136 t.Return(t.jsgraph.TrueConstant()); 136 t.Return(t.jsgraph.TrueConstant());
137 t.LowerAllNodes(); 137 t.LowerAllNodes();
138 t.GenerateCode(); 138 t.GenerateCode();
139 139
140 FOR_FLOAT64_INPUTS(i) { 140 FOR_FLOAT64_INPUTS(i) {
141 input = *i; 141 input = *i;
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(1), ret); 684 end = graph()->NewNode(common()->End(1), 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 typer.Run();
690 NodeProperties::SetBounds(p0, Bounds(p0_type)); 690 NodeProperties::SetType(p0, p0_type);
691 NodeProperties::SetBounds(p1, Bounds(p1_type)); 691 NodeProperties::SetType(p1, p1_type);
692 NodeProperties::SetBounds(p2, Bounds(p2_type)); 692 NodeProperties::SetType(p2, p2_type);
693 } 693 }
694 694
695 void CheckLoweringBinop(IrOpcode::Value expected, const Operator* op) { 695 void CheckLoweringBinop(IrOpcode::Value expected, const Operator* op) {
696 Node* node = Return(graph()->NewNode(op, p0, p1)); 696 Node* node = Return(graph()->NewNode(op, p0, p1));
697 Lower(); 697 Lower();
698 CHECK_EQ(expected, node->opcode()); 698 CHECK_EQ(expected, node->opcode());
699 } 699 }
700 700
701 void CheckLoweringTruncatedBinop(IrOpcode::Value expected, const Operator* op, 701 void CheckLoweringTruncatedBinop(IrOpcode::Value expected, const Operator* op,
702 const Operator* trunc) { 702 const Operator* trunc) {
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 t.Lower(); 1113 t.Lower();
1114 CheckChangeOf(IrOpcode::kChangeTaggedToUint32, t.p0, use->InputAt(0)); 1114 CheckChangeOf(IrOpcode::kChangeTaggedToUint32, t.p0, use->InputAt(0));
1115 } 1115 }
1116 1116
1117 1117
1118 TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32) { 1118 TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32) {
1119 // NumberToUint32(x: kRepFloat64) used as kMachUint32 1119 // NumberToUint32(x: kRepFloat64) used as kMachUint32
1120 TestingGraph t(Type::Number()); 1120 TestingGraph t(Type::Number());
1121 Node* p0 = t.ExampleWithOutput(kMachFloat64); 1121 Node* p0 = t.ExampleWithOutput(kMachFloat64);
1122 // TODO(titzer): run the typer here, or attach machine type to param. 1122 // TODO(titzer): run the typer here, or attach machine type to param.
1123 NodeProperties::SetBounds(p0, Bounds(Type::Number())); 1123 NodeProperties::SetType(p0, Type::Number());
1124 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), p0); 1124 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), p0);
1125 Node* use = t.Use(trunc, kMachUint32); 1125 Node* use = t.Use(trunc, kMachUint32);
1126 t.Return(use); 1126 t.Return(use);
1127 t.Lower(); 1127 t.Lower();
1128 CheckChangeOf(IrOpcode::kTruncateFloat64ToInt32, p0, use->InputAt(0)); 1128 CheckChangeOf(IrOpcode::kTruncateFloat64ToInt32, p0, use->InputAt(0));
1129 } 1129 }
1130 1130
1131 1131
1132 TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32_with_change) { 1132 TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32_with_change) {
1133 // NumberToInt32(x: kTypeNumber | kRepTagged) used as kMachUint32 1133 // NumberToInt32(x: kTypeNumber | kRepTagged) used as kMachUint32
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 TestingGraph t(d.arg1, d.arg2, Type::Boolean()); 1974 TestingGraph t(d.arg1, d.arg2, Type::Boolean());
1975 1975
1976 Node* br = t.graph()->NewNode(t.common()->Branch(), t.p2, t.start); 1976 Node* br = t.graph()->NewNode(t.common()->Branch(), t.p2, t.start);
1977 Node* tb = t.graph()->NewNode(t.common()->IfTrue(), br); 1977 Node* tb = t.graph()->NewNode(t.common()->IfTrue(), br);
1978 Node* fb = t.graph()->NewNode(t.common()->IfFalse(), br); 1978 Node* fb = t.graph()->NewNode(t.common()->IfFalse(), br);
1979 Node* m = t.graph()->NewNode(t.common()->Merge(2), tb, fb); 1979 Node* m = t.graph()->NewNode(t.common()->Merge(2), tb, fb);
1980 1980
1981 Node* phi = 1981 Node* phi =
1982 t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), t.p0, t.p1, m); 1982 t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), t.p0, t.p1, m);
1983 1983
1984 Bounds phi_bounds = Bounds::Either(Bounds(d.arg1), Bounds(d.arg2), z); 1984 Type* phi_type = Type::Union(d.arg1, d.arg2, z);
1985 NodeProperties::SetBounds(phi, phi_bounds); 1985 NodeProperties::SetType(phi, phi_type);
1986 1986
1987 Node* use = t.Use(phi, d.use); 1987 Node* use = t.Use(phi, d.use);
1988 t.Return(use); 1988 t.Return(use);
1989 t.Lower(); 1989 t.Lower();
1990 1990
1991 CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); 1991 CHECK_EQ(d.expected, OpParameter<MachineType>(phi));
1992 } 1992 }
1993 } 1993 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-js-typed-lowering.cc ('k') | test/unittests/compiler/graph-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698