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

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

Issue 470593002: Unify MachineType and RepType. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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/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 11 matching lines...) Expand all
22 #include "test/cctest/compiler/codegen-tester.h" 22 #include "test/cctest/compiler/codegen-tester.h"
23 #include "test/cctest/compiler/graph-builder-tester.h" 23 #include "test/cctest/compiler/graph-builder-tester.h"
24 #include "test/cctest/compiler/value-helper.h" 24 #include "test/cctest/compiler/value-helper.h"
25 25
26 using namespace v8::internal; 26 using namespace v8::internal;
27 using namespace v8::internal::compiler; 27 using namespace v8::internal::compiler;
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 = kMachineLast, 32 SimplifiedLoweringTester(MachineType p0 = kMachNone,
33 MachineType p1 = kMachineLast, 33 MachineType p1 = kMachNone,
34 MachineType p2 = kMachineLast, 34 MachineType p2 = kMachNone,
35 MachineType p3 = kMachineLast, 35 MachineType p3 = kMachNone,
36 MachineType p4 = kMachineLast) 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->zone()),
39 source_positions(this->graph()), 39 source_positions(this->graph()),
40 jsgraph(this->graph(), this->common(), &typer), 40 jsgraph(this->graph(), this->common(), &typer),
41 lowering(&jsgraph, &source_positions) {} 41 lowering(&jsgraph, &source_positions) {}
42 42
43 Typer typer; 43 Typer typer;
44 SourcePositionTable source_positions; 44 SourcePositionTable source_positions;
45 JSGraph jsgraph; 45 JSGraph jsgraph;
46 SimplifiedLowering lowering; 46 SimplifiedLowering lowering;
47 47
48 void LowerAllNodes() { 48 void LowerAllNodes() {
49 this->End(); 49 this->End();
50 lowering.LowerAllNodes(); 50 lowering.LowerAllNodes();
51 } 51 }
52 52
53 Factory* factory() { return this->isolate()->factory(); } 53 Factory* factory() { return this->isolate()->factory(); }
54 Heap* heap() { return this->isolate()->heap(); } 54 Heap* heap() { return this->isolate()->heap(); }
55 }; 55 };
56 56
57 57
58 // TODO(dcarney): find a home for these functions. 58 // TODO(dcarney): find a home for these functions.
59 namespace { 59 namespace {
60 60
61 FieldAccess ForJSObjectMap() { 61 FieldAccess ForJSObjectMap() {
62 FieldAccess access = {kTaggedBase, JSObject::kMapOffset, Handle<Name>(), 62 FieldAccess access = {kTaggedBase, JSObject::kMapOffset, Handle<Name>(),
63 Type::Any(), kMachineTagged}; 63 Type::Any(), kMachAnyTagged};
64 return access; 64 return access;
65 } 65 }
66 66
67 67
68 FieldAccess ForJSObjectProperties() { 68 FieldAccess ForJSObjectProperties() {
69 FieldAccess access = {kTaggedBase, JSObject::kPropertiesOffset, 69 FieldAccess access = {kTaggedBase, JSObject::kPropertiesOffset,
70 Handle<Name>(), Type::Any(), kMachineTagged}; 70 Handle<Name>(), Type::Any(), kMachAnyTagged};
71 return access; 71 return access;
72 } 72 }
73 73
74 74
75 FieldAccess ForArrayBufferBackingStore() { 75 FieldAccess ForArrayBufferBackingStore() {
76 FieldAccess access = { 76 FieldAccess access = {
77 kTaggedBase, JSArrayBuffer::kBackingStoreOffset, 77 kTaggedBase, JSArrayBuffer::kBackingStoreOffset,
78 Handle<Name>(), Type::UntaggedPtr(), 78 Handle<Name>(), Type::UntaggedPtr(),
79 MachineOperatorBuilder::pointer_rep(), 79 MachineOperatorBuilder::pointer_rep(),
80 }; 80 };
81 return access; 81 return access;
82 } 82 }
83 83
84 84
85 ElementAccess ForFixedArrayElement() { 85 ElementAccess ForFixedArrayElement() {
86 ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), 86 ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(),
87 kMachineTagged}; 87 kMachAnyTagged};
88 return access; 88 return access;
89 } 89 }
90 90
91 91
92 ElementAccess ForBackingStoreElement(MachineType rep) { 92 ElementAccess ForBackingStoreElement(MachineType rep) {
93 ElementAccess access = {kUntaggedBase, 93 ElementAccess access = {kUntaggedBase,
94 kNonHeapObjectHeaderSize - kHeapObjectTag, 94 kNonHeapObjectHeaderSize - kHeapObjectTag,
95 Type::Any(), rep}; 95 Type::Any(), rep};
96 return access; 96 return access;
97 } 97 }
98 } 98 }
99 99
100 100
101 // Create a simple JSObject with a unique map. 101 // Create a simple JSObject with a unique map.
102 static Handle<JSObject> TestObject() { 102 static Handle<JSObject> TestObject() {
103 static int index = 0; 103 static int index = 0;
104 char buffer[50]; 104 char buffer[50];
105 v8::base::OS::SNPrintF(buffer, 50, "({'a_%d':1})", index++); 105 v8::base::OS::SNPrintF(buffer, 50, "({'a_%d':1})", index++);
106 return Handle<JSObject>::cast(v8::Utils::OpenHandle(*CompileRun(buffer))); 106 return Handle<JSObject>::cast(v8::Utils::OpenHandle(*CompileRun(buffer)));
107 } 107 }
108 108
109 109
110 TEST(RunLoadMap) { 110 TEST(RunLoadMap) {
111 SimplifiedLoweringTester<Object*> t(kMachineTagged); 111 SimplifiedLoweringTester<Object*> t(kMachAnyTagged);
112 FieldAccess access = ForJSObjectMap(); 112 FieldAccess access = ForJSObjectMap();
113 Node* load = t.LoadField(access, t.Parameter(0)); 113 Node* load = t.LoadField(access, t.Parameter(0));
114 t.Return(load); 114 t.Return(load);
115 115
116 t.LowerAllNodes(); 116 t.LowerAllNodes();
117 t.GenerateCode(); 117 t.GenerateCode();
118 118
119 if (Pipeline::SupportedTarget()) { 119 if (Pipeline::SupportedTarget()) {
120 Handle<JSObject> src = TestObject(); 120 Handle<JSObject> src = TestObject();
121 Handle<Map> src_map(src->map()); 121 Handle<Map> src_map(src->map());
122 Object* result = t.Call(*src); // TODO(titzer): raw pointers in call 122 Object* result = t.Call(*src); // TODO(titzer): raw pointers in call
123 CHECK_EQ(*src_map, result); 123 CHECK_EQ(*src_map, result);
124 } 124 }
125 } 125 }
126 126
127 127
128 TEST(RunStoreMap) { 128 TEST(RunStoreMap) {
129 SimplifiedLoweringTester<int32_t> t(kMachineTagged, kMachineTagged); 129 SimplifiedLoweringTester<int32_t> t(kMachAnyTagged, kMachAnyTagged);
130 FieldAccess access = ForJSObjectMap(); 130 FieldAccess access = ForJSObjectMap();
131 t.StoreField(access, t.Parameter(1), t.Parameter(0)); 131 t.StoreField(access, t.Parameter(1), t.Parameter(0));
132 t.Return(t.jsgraph.TrueConstant()); 132 t.Return(t.jsgraph.TrueConstant());
133 133
134 t.LowerAllNodes(); 134 t.LowerAllNodes();
135 t.GenerateCode(); 135 t.GenerateCode();
136 136
137 if (Pipeline::SupportedTarget()) { 137 if (Pipeline::SupportedTarget()) {
138 Handle<JSObject> src = TestObject(); 138 Handle<JSObject> src = TestObject();
139 Handle<Map> src_map(src->map()); 139 Handle<Map> src_map(src->map());
140 Handle<JSObject> dst = TestObject(); 140 Handle<JSObject> dst = TestObject();
141 CHECK(src->map() != dst->map()); 141 CHECK(src->map() != dst->map());
142 t.Call(*src_map, *dst); // TODO(titzer): raw pointers in call 142 t.Call(*src_map, *dst); // TODO(titzer): raw pointers in call
143 CHECK(*src_map == dst->map()); 143 CHECK(*src_map == dst->map());
144 } 144 }
145 } 145 }
146 146
147 147
148 TEST(RunLoadProperties) { 148 TEST(RunLoadProperties) {
149 SimplifiedLoweringTester<Object*> t(kMachineTagged); 149 SimplifiedLoweringTester<Object*> t(kMachAnyTagged);
150 FieldAccess access = ForJSObjectProperties(); 150 FieldAccess access = ForJSObjectProperties();
151 Node* load = t.LoadField(access, t.Parameter(0)); 151 Node* load = t.LoadField(access, t.Parameter(0));
152 t.Return(load); 152 t.Return(load);
153 153
154 t.LowerAllNodes(); 154 t.LowerAllNodes();
155 t.GenerateCode(); 155 t.GenerateCode();
156 156
157 if (Pipeline::SupportedTarget()) { 157 if (Pipeline::SupportedTarget()) {
158 Handle<JSObject> src = TestObject(); 158 Handle<JSObject> src = TestObject();
159 Handle<FixedArray> src_props(src->properties()); 159 Handle<FixedArray> src_props(src->properties());
160 Object* result = t.Call(*src); // TODO(titzer): raw pointers in call 160 Object* result = t.Call(*src); // TODO(titzer): raw pointers in call
161 CHECK_EQ(*src_props, result); 161 CHECK_EQ(*src_props, result);
162 } 162 }
163 } 163 }
164 164
165 165
166 TEST(RunLoadStoreMap) { 166 TEST(RunLoadStoreMap) {
167 SimplifiedLoweringTester<Object*> t(kMachineTagged, kMachineTagged); 167 SimplifiedLoweringTester<Object*> t(kMachAnyTagged, kMachAnyTagged);
168 FieldAccess access = ForJSObjectMap(); 168 FieldAccess access = ForJSObjectMap();
169 Node* load = t.LoadField(access, t.Parameter(0)); 169 Node* load = t.LoadField(access, t.Parameter(0));
170 t.StoreField(access, t.Parameter(1), load); 170 t.StoreField(access, t.Parameter(1), load);
171 t.Return(load); 171 t.Return(load);
172 172
173 t.LowerAllNodes(); 173 t.LowerAllNodes();
174 t.GenerateCode(); 174 t.GenerateCode();
175 175
176 if (Pipeline::SupportedTarget()) { 176 if (Pipeline::SupportedTarget()) {
177 Handle<JSObject> src = TestObject(); 177 Handle<JSObject> src = TestObject();
178 Handle<Map> src_map(src->map()); 178 Handle<Map> src_map(src->map());
179 Handle<JSObject> dst = TestObject(); 179 Handle<JSObject> dst = TestObject();
180 CHECK(src->map() != dst->map()); 180 CHECK(src->map() != dst->map());
181 Object* result = t.Call(*src, *dst); // TODO(titzer): raw pointers in call 181 Object* result = t.Call(*src, *dst); // TODO(titzer): raw pointers in call
182 CHECK(result->IsMap()); 182 CHECK(result->IsMap());
183 CHECK_EQ(*src_map, result); 183 CHECK_EQ(*src_map, result);
184 CHECK(*src_map == dst->map()); 184 CHECK(*src_map == dst->map());
185 } 185 }
186 } 186 }
187 187
188 188
189 TEST(RunLoadStoreFixedArrayIndex) { 189 TEST(RunLoadStoreFixedArrayIndex) {
190 SimplifiedLoweringTester<Object*> t(kMachineTagged); 190 SimplifiedLoweringTester<Object*> t(kMachAnyTagged);
191 ElementAccess access = ForFixedArrayElement(); 191 ElementAccess access = ForFixedArrayElement();
192 Node* load = t.LoadElement(access, t.Parameter(0), t.Int32Constant(0)); 192 Node* load = t.LoadElement(access, t.Parameter(0), t.Int32Constant(0));
193 t.StoreElement(access, t.Parameter(0), t.Int32Constant(1), load); 193 t.StoreElement(access, t.Parameter(0), t.Int32Constant(1), load);
194 t.Return(load); 194 t.Return(load);
195 195
196 t.LowerAllNodes(); 196 t.LowerAllNodes();
197 t.GenerateCode(); 197 t.GenerateCode();
198 198
199 if (Pipeline::SupportedTarget()) { 199 if (Pipeline::SupportedTarget()) {
200 Handle<FixedArray> array = t.factory()->NewFixedArray(2); 200 Handle<FixedArray> array = t.factory()->NewFixedArray(2);
201 Handle<JSObject> src = TestObject(); 201 Handle<JSObject> src = TestObject();
202 Handle<JSObject> dst = TestObject(); 202 Handle<JSObject> dst = TestObject();
203 array->set(0, *src); 203 array->set(0, *src);
204 array->set(1, *dst); 204 array->set(1, *dst);
205 Object* result = t.Call(*array); 205 Object* result = t.Call(*array);
206 CHECK_EQ(*src, result); 206 CHECK_EQ(*src, result);
207 CHECK_EQ(*src, array->get(0)); 207 CHECK_EQ(*src, array->get(0));
208 CHECK_EQ(*src, array->get(1)); 208 CHECK_EQ(*src, array->get(1));
209 } 209 }
210 } 210 }
211 211
212 212
213 TEST(RunLoadStoreArrayBuffer) { 213 TEST(RunLoadStoreArrayBuffer) {
214 SimplifiedLoweringTester<Object*> t(kMachineTagged); 214 SimplifiedLoweringTester<Object*> t(kMachAnyTagged);
215 const int index = 12; 215 const int index = 12;
216 ElementAccess buffer_access = ForBackingStoreElement(kMachineWord8); 216 ElementAccess buffer_access = ForBackingStoreElement(kMachInt8);
217 Node* backing_store = 217 Node* backing_store =
218 t.LoadField(ForArrayBufferBackingStore(), t.Parameter(0)); 218 t.LoadField(ForArrayBufferBackingStore(), t.Parameter(0));
219 Node* load = 219 Node* load =
220 t.LoadElement(buffer_access, backing_store, t.Int32Constant(index)); 220 t.LoadElement(buffer_access, backing_store, t.Int32Constant(index));
221 t.StoreElement(buffer_access, backing_store, t.Int32Constant(index + 1), 221 t.StoreElement(buffer_access, backing_store, t.Int32Constant(index + 1),
222 load); 222 load);
223 t.Return(t.jsgraph.TrueConstant()); 223 t.Return(t.jsgraph.TrueConstant());
224 224
225 t.LowerAllNodes(); 225 t.LowerAllNodes();
226 t.GenerateCode(); 226 t.GenerateCode();
(...skipping 18 matching lines...) Expand all
245 } 245 }
246 } 246 }
247 247
248 248
249 TEST(RunLoadFieldFromUntaggedBase) { 249 TEST(RunLoadFieldFromUntaggedBase) {
250 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; 250 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)};
251 251
252 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { 252 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {
253 int offset = static_cast<int>(i * sizeof(Smi*)); 253 int offset = static_cast<int>(i * sizeof(Smi*));
254 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), 254 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(),
255 Type::Integral32(), kMachineTagged}; 255 Type::Integral32(), kMachAnyTagged};
256 256
257 SimplifiedLoweringTester<Object*> t; 257 SimplifiedLoweringTester<Object*> t;
258 Node* load = t.LoadField(access, t.PointerConstant(smis)); 258 Node* load = t.LoadField(access, t.PointerConstant(smis));
259 t.Return(load); 259 t.Return(load);
260 t.LowerAllNodes(); 260 t.LowerAllNodes();
261 261
262 if (!Pipeline::SupportedTarget()) continue; 262 if (!Pipeline::SupportedTarget()) continue;
263 263
264 for (int j = -5; j <= 5; j++) { 264 for (int j = -5; j <= 5; j++) {
265 Smi* expected = Smi::FromInt(j); 265 Smi* expected = Smi::FromInt(j);
266 smis[i] = expected; 266 smis[i] = expected;
267 CHECK_EQ(expected, t.Call()); 267 CHECK_EQ(expected, t.Call());
268 } 268 }
269 } 269 }
270 } 270 }
271 271
272 272
273 TEST(RunStoreFieldToUntaggedBase) { 273 TEST(RunStoreFieldToUntaggedBase) {
274 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; 274 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)};
275 275
276 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { 276 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {
277 int offset = static_cast<int>(i * sizeof(Smi*)); 277 int offset = static_cast<int>(i * sizeof(Smi*));
278 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), 278 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(),
279 Type::Integral32(), kMachineTagged}; 279 Type::Integral32(), kMachAnyTagged};
280 280
281 SimplifiedLoweringTester<Object*> t(kMachineTagged); 281 SimplifiedLoweringTester<Object*> t(kMachAnyTagged);
282 Node* p0 = t.Parameter(0); 282 Node* p0 = t.Parameter(0);
283 t.StoreField(access, t.PointerConstant(smis), p0); 283 t.StoreField(access, t.PointerConstant(smis), p0);
284 t.Return(p0); 284 t.Return(p0);
285 t.LowerAllNodes(); 285 t.LowerAllNodes();
286 286
287 if (!Pipeline::SupportedTarget()) continue; 287 if (!Pipeline::SupportedTarget()) continue;
288 288
289 for (int j = -5; j <= 5; j++) { 289 for (int j = -5; j <= 5; j++) {
290 Smi* expected = Smi::FromInt(j); 290 Smi* expected = Smi::FromInt(j);
291 smis[i] = Smi::FromInt(-100); 291 smis[i] = Smi::FromInt(-100);
292 CHECK_EQ(expected, t.Call(expected)); 292 CHECK_EQ(expected, t.Call(expected));
293 CHECK_EQ(expected, smis[i]); 293 CHECK_EQ(expected, smis[i]);
294 } 294 }
295 } 295 }
296 } 296 }
297 297
298 298
299 TEST(RunLoadElementFromUntaggedBase) { 299 TEST(RunLoadElementFromUntaggedBase) {
300 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), 300 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3),
301 Smi::FromInt(4), Smi::FromInt(5)}; 301 Smi::FromInt(4), Smi::FromInt(5)};
302 302
303 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes 303 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes
304 for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index 304 for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index
305 int offset = static_cast<int>(i * sizeof(Smi*)); 305 int offset = static_cast<int>(i * sizeof(Smi*));
306 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), 306 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(),
307 kMachineTagged}; 307 kMachAnyTagged};
308 308
309 SimplifiedLoweringTester<Object*> t; 309 SimplifiedLoweringTester<Object*> t;
310 Node* load = t.LoadElement(access, t.PointerConstant(smis), 310 Node* load = t.LoadElement(access, t.PointerConstant(smis),
311 t.Int32Constant(static_cast<int>(j))); 311 t.Int32Constant(static_cast<int>(j)));
312 t.Return(load); 312 t.Return(load);
313 t.LowerAllNodes(); 313 t.LowerAllNodes();
314 314
315 if (!Pipeline::SupportedTarget()) continue; 315 if (!Pipeline::SupportedTarget()) continue;
316 316
317 for (int k = -5; k <= 5; k++) { 317 for (int k = -5; k <= 5; k++) {
318 Smi* expected = Smi::FromInt(k); 318 Smi* expected = Smi::FromInt(k);
319 smis[i + j] = expected; 319 smis[i + j] = expected;
320 CHECK_EQ(expected, t.Call()); 320 CHECK_EQ(expected, t.Call());
321 } 321 }
322 } 322 }
323 } 323 }
324 } 324 }
325 325
326 326
327 TEST(RunStoreElementFromUntaggedBase) { 327 TEST(RunStoreElementFromUntaggedBase) {
328 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), 328 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3),
329 Smi::FromInt(4), Smi::FromInt(5)}; 329 Smi::FromInt(4), Smi::FromInt(5)};
330 330
331 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes 331 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes
332 for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index 332 for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index
333 int offset = static_cast<int>(i * sizeof(Smi*)); 333 int offset = static_cast<int>(i * sizeof(Smi*));
334 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), 334 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(),
335 kMachineTagged}; 335 kMachAnyTagged};
336 336
337 SimplifiedLoweringTester<Object*> t(kMachineTagged); 337 SimplifiedLoweringTester<Object*> t(kMachAnyTagged);
338 Node* p0 = t.Parameter(0); 338 Node* p0 = t.Parameter(0);
339 t.StoreElement(access, t.PointerConstant(smis), 339 t.StoreElement(access, t.PointerConstant(smis),
340 t.Int32Constant(static_cast<int>(j)), p0); 340 t.Int32Constant(static_cast<int>(j)), p0);
341 t.Return(p0); 341 t.Return(p0);
342 t.LowerAllNodes(); 342 t.LowerAllNodes();
343 343
344 if (!Pipeline::SupportedTarget()) continue; 344 if (!Pipeline::SupportedTarget()) continue;
345 345
346 for (int k = -5; k <= 5; k++) { 346 for (int k = -5; k <= 5; k++) {
347 Smi* expected = Smi::FromInt(k); 347 Smi* expected = Smi::FromInt(k);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 } 552 }
553 } 553 }
554 } 554 }
555 } 555 }
556 } 556 }
557 557
558 558
559 TEST(RunAccessTests_uint8) { 559 TEST(RunAccessTests_uint8) {
560 uint8_t data[] = {0x07, 0x16, 0x25, 0x34, 0x43, 0x99, 560 uint8_t data[] = {0x07, 0x16, 0x25, 0x34, 0x43, 0x99,
561 0xab, 0x78, 0x89, 0x19, 0x2b, 0x38}; 561 0xab, 0x78, 0x89, 0x19, 0x2b, 0x38};
562 RunAccessTest<uint8_t>(kMachineWord8, data, ARRAY_SIZE(data)); 562 RunAccessTest<uint8_t>(kMachInt8, data, ARRAY_SIZE(data));
563 } 563 }
564 564
565 565
566 TEST(RunAccessTests_uint16) { 566 TEST(RunAccessTests_uint16) {
567 uint16_t data[] = {0x071a, 0x162b, 0x253c, 0x344d, 0x435e, 0x7777}; 567 uint16_t data[] = {0x071a, 0x162b, 0x253c, 0x344d, 0x435e, 0x7777};
568 RunAccessTest<uint16_t>(kMachineWord16, data, ARRAY_SIZE(data)); 568 RunAccessTest<uint16_t>(kMachInt16, data, ARRAY_SIZE(data));
569 } 569 }
570 570
571 571
572 TEST(RunAccessTests_int32) { 572 TEST(RunAccessTests_int32) {
573 int32_t data[] = {-211, 211, 628347, 2000000000, -2000000000, -1, -100000034}; 573 int32_t data[] = {-211, 211, 628347, 2000000000, -2000000000, -1, -100000034};
574 RunAccessTest<int32_t>(kMachineWord32, data, ARRAY_SIZE(data)); 574 RunAccessTest<int32_t>(kMachInt32, data, ARRAY_SIZE(data));
575 } 575 }
576 576
577 577
578 #define V8_2PART_INT64(a, b) (((static_cast<int64_t>(a) << 32) + 0x##b##u)) 578 #define V8_2PART_INT64(a, b) (((static_cast<int64_t>(a) << 32) + 0x##b##u))
579 579
580 580
581 TEST(RunAccessTests_int64) { 581 TEST(RunAccessTests_int64) {
582 if (kPointerSize != 8) return; 582 if (kPointerSize != 8) return;
583 int64_t data[] = {V8_2PART_INT64(0x10111213, 14151617), 583 int64_t data[] = {V8_2PART_INT64(0x10111213, 14151617),
584 V8_2PART_INT64(0x20212223, 24252627), 584 V8_2PART_INT64(0x20212223, 24252627),
585 V8_2PART_INT64(0x30313233, 34353637), 585 V8_2PART_INT64(0x30313233, 34353637),
586 V8_2PART_INT64(0xa0a1a2a3, a4a5a6a7), 586 V8_2PART_INT64(0xa0a1a2a3, a4a5a6a7),
587 V8_2PART_INT64(0xf0f1f2f3, f4f5f6f7)}; 587 V8_2PART_INT64(0xf0f1f2f3, f4f5f6f7)};
588 RunAccessTest<int64_t>(kMachineWord64, data, ARRAY_SIZE(data)); 588 RunAccessTest<int64_t>(kMachInt64, data, ARRAY_SIZE(data));
589 } 589 }
590 590
591 591
592 TEST(RunAccessTests_float64) { 592 TEST(RunAccessTests_float64) {
593 double data[] = {1.25, -1.25, 2.75, 11.0, 11100.8}; 593 double data[] = {1.25, -1.25, 2.75, 11.0, 11100.8};
594 RunAccessTest<double>(kMachineFloat64, data, ARRAY_SIZE(data)); 594 RunAccessTest<double>(kMachFloat64, data, ARRAY_SIZE(data));
595 } 595 }
596 596
597 597
598 TEST(RunAccessTests_Smi) { 598 TEST(RunAccessTests_Smi) {
599 Smi* data[] = {Smi::FromInt(-1), Smi::FromInt(-9), 599 Smi* data[] = {Smi::FromInt(-1), Smi::FromInt(-9),
600 Smi::FromInt(0), Smi::FromInt(666), 600 Smi::FromInt(0), Smi::FromInt(666),
601 Smi::FromInt(77777), Smi::FromInt(Smi::kMaxValue)}; 601 Smi::FromInt(77777), Smi::FromInt(Smi::kMaxValue)};
602 RunAccessTest<Smi*>(kMachineTagged, data, ARRAY_SIZE(data)); 602 RunAccessTest<Smi*>(kMachAnyTagged, data, ARRAY_SIZE(data));
603 } 603 }
604 604
605 605
606 // Fills in most of the nodes of the graph in order to make tests shorter. 606 // Fills in most of the nodes of the graph in order to make tests shorter.
607 class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { 607 class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
608 public: 608 public:
609 Typer typer; 609 Typer typer;
610 JSGraph jsgraph; 610 JSGraph jsgraph;
611 Node* p0; 611 Node* p0;
612 Node* p1; 612 Node* p1;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 651
652 // Inserts the node as the return value of the graph. 652 // Inserts the node as the return value of the graph.
653 Node* Return(Node* node) { 653 Node* Return(Node* node) {
654 ret->ReplaceInput(0, node); 654 ret->ReplaceInput(0, node);
655 return node; 655 return node;
656 } 656 }
657 657
658 // Inserts the node as the effect input to the return of the graph. 658 // Inserts the node as the effect input to the return of the graph.
659 void Effect(Node* node) { ret->ReplaceInput(1, node); } 659 void Effect(Node* node) { ret->ReplaceInput(1, node); }
660 660
661 Node* ExampleWithOutput(RepType type) { 661 Node* ExampleWithOutput(MachineType type) {
662 // TODO(titzer): use parameters with guaranteed representations. 662 // TODO(titzer): use parameters with guaranteed representations.
663 if (type & tInt32) { 663 if (type & kTypeInt32) {
664 return graph()->NewNode(machine()->Int32Add(), jsgraph.Int32Constant(1), 664 return graph()->NewNode(machine()->Int32Add(), jsgraph.Int32Constant(1),
665 jsgraph.Int32Constant(1)); 665 jsgraph.Int32Constant(1));
666 } else if (type & tUint32) { 666 } else if (type & kTypeUint32) {
667 return graph()->NewNode(machine()->Word32Shr(), jsgraph.Int32Constant(1), 667 return graph()->NewNode(machine()->Word32Shr(), jsgraph.Int32Constant(1),
668 jsgraph.Int32Constant(1)); 668 jsgraph.Int32Constant(1));
669 } else if (type & rFloat64) { 669 } else if (type & kRepFloat64) {
670 return graph()->NewNode(machine()->Float64Add(), 670 return graph()->NewNode(machine()->Float64Add(),
671 jsgraph.Float64Constant(1), 671 jsgraph.Float64Constant(1),
672 jsgraph.Float64Constant(1)); 672 jsgraph.Float64Constant(1));
673 } else if (type & rBit) { 673 } else if (type & kRepBit) {
674 return graph()->NewNode(machine()->Word32Equal(), 674 return graph()->NewNode(machine()->Word32Equal(),
675 jsgraph.Int32Constant(1), 675 jsgraph.Int32Constant(1),
676 jsgraph.Int32Constant(1)); 676 jsgraph.Int32Constant(1));
677 } else if (type & rWord64) { 677 } else if (type & kRepWord64) {
678 return graph()->NewNode(machine()->Int64Add(), Int64Constant(1), 678 return graph()->NewNode(machine()->Int64Add(), Int64Constant(1),
679 Int64Constant(1)); 679 Int64Constant(1));
680 } else { 680 } else {
681 CHECK(type & rTagged); 681 CHECK(type & kRepTagged);
682 return p0; 682 return p0;
683 } 683 }
684 } 684 }
685 685
686 Node* Use(Node* node, RepType type) { 686 Node* Use(Node* node, MachineType type) {
687 if (type & tInt32) { 687 if (type & kTypeInt32) {
688 return graph()->NewNode(machine()->Int32LessThan(), node, 688 return graph()->NewNode(machine()->Int32LessThan(), node,
689 jsgraph.Int32Constant(1)); 689 jsgraph.Int32Constant(1));
690 } else if (type & tUint32) { 690 } else if (type & kTypeUint32) {
691 return graph()->NewNode(machine()->Uint32LessThan(), node, 691 return graph()->NewNode(machine()->Uint32LessThan(), node,
692 jsgraph.Int32Constant(1)); 692 jsgraph.Int32Constant(1));
693 } else if (type & rFloat64) { 693 } else if (type & kRepFloat64) {
694 return graph()->NewNode(machine()->Float64Add(), node, 694 return graph()->NewNode(machine()->Float64Add(), node,
695 jsgraph.Float64Constant(1)); 695 jsgraph.Float64Constant(1));
696 } else if (type & rWord64) { 696 } else if (type & kRepWord64) {
697 return graph()->NewNode(machine()->Int64LessThan(), node, 697 return graph()->NewNode(machine()->Int64LessThan(), node,
698 Int64Constant(1)); 698 Int64Constant(1));
699 } else { 699 } else {
700 return graph()->NewNode(simplified()->ReferenceEqual(Type::Any()), node, 700 return graph()->NewNode(simplified()->ReferenceEqual(Type::Any()), node,
701 jsgraph.TrueConstant()); 701 jsgraph.TrueConstant());
702 } 702 }
703 } 703 }
704 704
705 Node* Branch(Node* cond) { 705 Node* Branch(Node* cond) {
706 Node* br = graph()->NewNode(common()->Branch(), cond, start); 706 Node* br = graph()->NewNode(common()->Branch(), cond, start);
707 Node* tb = graph()->NewNode(common()->IfTrue(), br); 707 Node* tb = graph()->NewNode(common()->IfTrue(), br);
708 Node* fb = graph()->NewNode(common()->IfFalse(), br); 708 Node* fb = graph()->NewNode(common()->IfFalse(), br);
709 Node* m = graph()->NewNode(common()->Merge(2), tb, fb); 709 Node* m = graph()->NewNode(common()->Merge(2), tb, fb);
710 NodeProperties::ReplaceControlInput(ret, m); 710 NodeProperties::ReplaceControlInput(ret, m);
711 return br; 711 return br;
712 } 712 }
713 713
714 Node* Int64Constant(int64_t v) { 714 Node* Int64Constant(int64_t v) {
715 return graph()->NewNode(common()->Int64Constant(v)); 715 return graph()->NewNode(common()->Int64Constant(v));
716 } 716 }
717 717
718 SimplifiedOperatorBuilder* simplified() { return &main_simplified_; } 718 SimplifiedOperatorBuilder* simplified() { return &main_simplified_; }
719 MachineOperatorBuilder* machine() { return &main_machine_; } 719 MachineOperatorBuilder* machine() { return &main_machine_; }
720 CommonOperatorBuilder* common() { return &main_common_; } 720 CommonOperatorBuilder* common() { return &main_common_; }
721 Graph* graph() { return main_graph_; } 721 Graph* graph() { return main_graph_; }
722 }; 722 };
723 723
724 724
725 TEST(LowerBooleanNot_bit_bit) { 725 TEST(LowerBooleanNot_bit_bit) {
726 // BooleanNot(x: rBit) used as rBit 726 // BooleanNot(x: kRepBit) used as kRepBit
727 TestingGraph t(Type::Boolean()); 727 TestingGraph t(Type::Boolean());
728 Node* b = t.ExampleWithOutput(rBit); 728 Node* b = t.ExampleWithOutput(kRepBit);
729 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); 729 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b);
730 Node* use = t.Branch(inv); 730 Node* use = t.Branch(inv);
731 t.Lower(); 731 t.Lower();
732 Node* cmp = use->InputAt(0); 732 Node* cmp = use->InputAt(0);
733 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode()); 733 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode());
734 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); 734 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1));
735 Node* f = t.jsgraph.Int32Constant(0); 735 Node* f = t.jsgraph.Int32Constant(0);
736 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); 736 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1));
737 } 737 }
738 738
739 739
740 TEST(LowerBooleanNot_bit_tagged) { 740 TEST(LowerBooleanNot_bit_tagged) {
741 // BooleanNot(x: rBit) used as rTagged 741 // BooleanNot(x: kRepBit) used as kRepTagged
742 TestingGraph t(Type::Boolean()); 742 TestingGraph t(Type::Boolean());
743 Node* b = t.ExampleWithOutput(rBit); 743 Node* b = t.ExampleWithOutput(kRepBit);
744 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); 744 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b);
745 Node* use = t.Use(inv, rTagged); 745 Node* use = t.Use(inv, kRepTagged);
746 t.Return(use); 746 t.Return(use);
747 t.Lower(); 747 t.Lower();
748 CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode()); 748 CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode());
749 Node* cmp = use->InputAt(0)->InputAt(0); 749 Node* cmp = use->InputAt(0)->InputAt(0);
750 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode()); 750 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode());
751 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); 751 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1));
752 Node* f = t.jsgraph.Int32Constant(0); 752 Node* f = t.jsgraph.Int32Constant(0);
753 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); 753 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1));
754 } 754 }
755 755
756 756
757 TEST(LowerBooleanNot_tagged_bit) { 757 TEST(LowerBooleanNot_tagged_bit) {
758 // BooleanNot(x: rTagged) used as rBit 758 // BooleanNot(x: kRepTagged) used as kRepBit
759 TestingGraph t(Type::Boolean()); 759 TestingGraph t(Type::Boolean());
760 Node* b = t.p0; 760 Node* b = t.p0;
761 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); 761 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b);
762 Node* use = t.Branch(inv); 762 Node* use = t.Branch(inv);
763 t.Lower(); 763 t.Lower();
764 Node* cmp = use->InputAt(0); 764 Node* cmp = use->InputAt(0);
765 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode()); 765 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode());
766 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); 766 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1));
767 Node* f = t.jsgraph.FalseConstant(); 767 Node* f = t.jsgraph.FalseConstant();
768 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); 768 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1));
769 } 769 }
770 770
771 771
772 TEST(LowerBooleanNot_tagged_tagged) { 772 TEST(LowerBooleanNot_tagged_tagged) {
773 // BooleanNot(x: rTagged) used as rTagged 773 // BooleanNot(x: kRepTagged) used as kRepTagged
774 TestingGraph t(Type::Boolean()); 774 TestingGraph t(Type::Boolean());
775 Node* b = t.p0; 775 Node* b = t.p0;
776 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); 776 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b);
777 Node* use = t.Use(inv, rTagged); 777 Node* use = t.Use(inv, kRepTagged);
778 t.Return(use); 778 t.Return(use);
779 t.Lower(); 779 t.Lower();
780 CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode()); 780 CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode());
781 Node* cmp = use->InputAt(0)->InputAt(0); 781 Node* cmp = use->InputAt(0)->InputAt(0);
782 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode()); 782 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode());
783 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); 783 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1));
784 Node* f = t.jsgraph.FalseConstant(); 784 Node* f = t.jsgraph.FalseConstant();
785 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); 785 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1));
786 } 786 }
787 787
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 } 872 }
873 873
874 874
875 static void CheckChangeOf(IrOpcode::Value change, Node* of, Node* node) { 875 static void CheckChangeOf(IrOpcode::Value change, Node* of, Node* node) {
876 CHECK_EQ(change, node->opcode()); 876 CHECK_EQ(change, node->opcode());
877 CHECK_EQ(of, node->InputAt(0)); 877 CHECK_EQ(of, node->InputAt(0));
878 } 878 }
879 879
880 880
881 TEST(LowerNumberToInt32_to_nop) { 881 TEST(LowerNumberToInt32_to_nop) {
882 // NumberToInt32(x: rTagged | tInt32) used as rTagged 882 // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepTagged
883 TestingGraph t(Type::Signed32()); 883 TestingGraph t(Type::Signed32());
884 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); 884 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0);
885 Node* use = t.Use(trunc, rTagged); 885 Node* use = t.Use(trunc, kRepTagged);
886 t.Return(use); 886 t.Return(use);
887 t.Lower(); 887 t.Lower();
888 CHECK_EQ(t.p0, use->InputAt(0)); 888 CHECK_EQ(t.p0, use->InputAt(0));
889 } 889 }
890 890
891 891
892 TEST(LowerNumberToInt32_to_ChangeTaggedToFloat64) { 892 TEST(LowerNumberToInt32_to_ChangeTaggedToFloat64) {
893 // NumberToInt32(x: rTagged | tInt32) used as rFloat64 893 // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepFloat64
894 TestingGraph t(Type::Signed32()); 894 TestingGraph t(Type::Signed32());
895 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); 895 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0);
896 Node* use = t.Use(trunc, rFloat64); 896 Node* use = t.Use(trunc, kRepFloat64);
897 t.Return(use); 897 t.Return(use);
898 t.Lower(); 898 t.Lower();
899 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p0, use->InputAt(0)); 899 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p0, use->InputAt(0));
900 } 900 }
901 901
902 902
903 TEST(LowerNumberToInt32_to_ChangeTaggedToInt32) { 903 TEST(LowerNumberToInt32_to_ChangeTaggedToInt32) {
904 // NumberToInt32(x: rTagged | tInt32) used as rWord32 904 // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepWord32
905 TestingGraph t(Type::Signed32()); 905 TestingGraph t(Type::Signed32());
906 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); 906 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0);
907 Node* use = t.Use(trunc, tInt32); 907 Node* use = t.Use(trunc, kTypeInt32);
908 t.Return(use); 908 t.Return(use);
909 t.Lower(); 909 t.Lower();
910 CheckChangeOf(IrOpcode::kChangeTaggedToInt32, t.p0, use->InputAt(0)); 910 CheckChangeOf(IrOpcode::kChangeTaggedToInt32, t.p0, use->InputAt(0));
911 } 911 }
912 912
913 913
914 TEST(LowerNumberToInt32_to_ChangeFloat64ToTagged) { 914 TEST(LowerNumberToInt32_to_ChangeFloat64ToTagged) {
915 // TODO(titzer): NumberToInt32(x: rFloat64 | tInt32) used as rTagged 915 // TODO(titzer): NumberToInt32(x: kRepFloat64 | kTypeInt32) used as kRepTagged
916 } 916 }
917 917
918 918
919 TEST(LowerNumberToInt32_to_ChangeFloat64ToInt32) { 919 TEST(LowerNumberToInt32_to_ChangeFloat64ToInt32) {
920 // TODO(titzer): NumberToInt32(x: rFloat64 | tInt32) used as rWord32 | tInt32 920 // TODO(titzer): NumberToInt32(x: kRepFloat64 | kTypeInt32) used as kRepWord32
921 // | kTypeInt32
921 } 922 }
922 923
923 924
924 TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32) { 925 TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32) {
925 // TODO(titzer): NumberToInt32(x: rFloat64) used as rWord32 | tUint32 926 // TODO(titzer): NumberToInt32(x: kRepFloat64) used as kRepWord32 |
927 // kTypeUint32
926 } 928 }
927 929
928 930
929 TEST(LowerNumberToUint32_to_nop) { 931 TEST(LowerNumberToUint32_to_nop) {
930 // NumberToUint32(x: rTagged | tUint32) used as rTagged 932 // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepTagged
931 TestingGraph t(Type::Unsigned32()); 933 TestingGraph t(Type::Unsigned32());
932 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); 934 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0);
933 Node* use = t.Use(trunc, rTagged); 935 Node* use = t.Use(trunc, kRepTagged);
934 t.Return(use); 936 t.Return(use);
935 t.Lower(); 937 t.Lower();
936 CHECK_EQ(t.p0, use->InputAt(0)); 938 CHECK_EQ(t.p0, use->InputAt(0));
937 } 939 }
938 940
939 941
940 TEST(LowerNumberToUint32_to_ChangeTaggedToFloat64) { 942 TEST(LowerNumberToUint32_to_ChangeTaggedToFloat64) {
941 // NumberToUint32(x: rTagged | tUint32) used as rWord32 943 // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepWord32
942 TestingGraph t(Type::Unsigned32()); 944 TestingGraph t(Type::Unsigned32());
943 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); 945 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0);
944 Node* use = t.Use(trunc, rFloat64); 946 Node* use = t.Use(trunc, kRepFloat64);
945 t.Return(use); 947 t.Return(use);
946 t.Lower(); 948 t.Lower();
947 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p0, use->InputAt(0)); 949 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p0, use->InputAt(0));
948 } 950 }
949 951
950 952
951 TEST(LowerNumberToUint32_to_ChangeTaggedToUint32) { 953 TEST(LowerNumberToUint32_to_ChangeTaggedToUint32) {
952 // NumberToUint32(x: rTagged | tUint32) used as rWord32 954 // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepWord32
953 TestingGraph t(Type::Unsigned32()); 955 TestingGraph t(Type::Unsigned32());
954 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); 956 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0);
955 Node* use = t.Use(trunc, tUint32); 957 Node* use = t.Use(trunc, kTypeUint32);
956 t.Return(use); 958 t.Return(use);
957 t.Lower(); 959 t.Lower();
958 CheckChangeOf(IrOpcode::kChangeTaggedToUint32, t.p0, use->InputAt(0)); 960 CheckChangeOf(IrOpcode::kChangeTaggedToUint32, t.p0, use->InputAt(0));
959 } 961 }
960 962
961 963
962 TEST(LowerNumberToUint32_to_ChangeFloat64ToTagged) { 964 TEST(LowerNumberToUint32_to_ChangeFloat64ToTagged) {
963 // TODO(titzer): NumberToUint32(x: rFloat64 | tUint32) used as rTagged 965 // TODO(titzer): NumberToUint32(x: kRepFloat64 | kTypeUint32) used as
966 // kRepTagged
964 } 967 }
965 968
966 969
967 TEST(LowerNumberToUint32_to_ChangeFloat64ToUint32) { 970 TEST(LowerNumberToUint32_to_ChangeFloat64ToUint32) {
968 // TODO(titzer): NumberToUint32(x: rFloat64 | tUint32) used as rWord32 971 // TODO(titzer): NumberToUint32(x: kRepFloat64 | kTypeUint32) used as
972 // kRepWord32
969 } 973 }
970 974
971 975
972 TEST(LowerNumberToUint32_to_TruncateFloat64ToUint32) { 976 TEST(LowerNumberToUint32_to_TruncateFloat64ToUint32) {
973 // TODO(titzer): NumberToUint32(x: rFloat64) used as rWord32 977 // TODO(titzer): NumberToUint32(x: kRepFloat64) used as kRepWord32
974 } 978 }
975 979
976 980
977 TEST(LowerReferenceEqual_to_wordeq) { 981 TEST(LowerReferenceEqual_to_wordeq) {
978 TestingGraph t(Type::Any(), Type::Any()); 982 TestingGraph t(Type::Any(), Type::Any());
979 IrOpcode::Value opcode = 983 IrOpcode::Value opcode =
980 static_cast<IrOpcode::Value>(t.machine()->WordEqual()->opcode()); 984 static_cast<IrOpcode::Value>(t.machine()->WordEqual()->opcode());
981 t.CheckLoweringBinop(opcode, t.simplified()->ReferenceEqual(Type::Any())); 985 t.CheckLoweringBinop(opcode, t.simplified()->ReferenceEqual(Type::Any()));
982 } 986 }
983 987
984 988
985 TEST(LowerStringOps_to_rtcalls) { 989 TEST(LowerStringOps_to_rtcalls) {
986 if (false) { // TODO(titzer): lower StringOps to runtime calls 990 if (false) { // TODO(titzer): lower StringOps to runtime calls
987 TestingGraph t(Type::String(), Type::String()); 991 TestingGraph t(Type::String(), Type::String());
988 t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringEqual()); 992 t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringEqual());
989 t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringLessThan()); 993 t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringLessThan());
990 t.CheckLoweringBinop(IrOpcode::kCall, 994 t.CheckLoweringBinop(IrOpcode::kCall,
991 t.simplified()->StringLessThanOrEqual()); 995 t.simplified()->StringLessThanOrEqual());
992 t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringAdd()); 996 t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringAdd());
993 } 997 }
994 } 998 }
995 999
996 1000
997 void CheckChangeInsertion(IrOpcode::Value expected, RepType from, RepType to) { 1001 void CheckChangeInsertion(IrOpcode::Value expected, MachineType from,
1002 MachineType to) {
998 TestingGraph t(Type::Any()); 1003 TestingGraph t(Type::Any());
999 Node* in = t.ExampleWithOutput(from); 1004 Node* in = t.ExampleWithOutput(from);
1000 Node* use = t.Use(in, to); 1005 Node* use = t.Use(in, to);
1001 t.Return(use); 1006 t.Return(use);
1002 t.Lower(); 1007 t.Lower();
1003 CHECK_EQ(expected, use->InputAt(0)->opcode()); 1008 CHECK_EQ(expected, use->InputAt(0)->opcode());
1004 CHECK_EQ(in, use->InputAt(0)->InputAt(0)); 1009 CHECK_EQ(in, use->InputAt(0)->InputAt(0));
1005 } 1010 }
1006 1011
1007 1012
1008 TEST(InsertBasicChanges) { 1013 TEST(InsertBasicChanges) {
1009 if (false) { 1014 if (false) {
1010 // TODO(titzer): these changes need the output to have the right type. 1015 // TODO(titzer): these changes need the output to have the right type.
1011 CheckChangeInsertion(IrOpcode::kChangeFloat64ToInt32, rFloat64, tInt32); 1016 CheckChangeInsertion(IrOpcode::kChangeFloat64ToInt32, kRepFloat64,
1012 CheckChangeInsertion(IrOpcode::kChangeFloat64ToUint32, rFloat64, tUint32); 1017 kTypeInt32);
1013 CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, rTagged, tInt32); 1018 CheckChangeInsertion(IrOpcode::kChangeFloat64ToUint32, kRepFloat64,
1014 CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, rTagged, tUint32); 1019 kTypeUint32);
1020 CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, kRepTagged,
1021 kTypeInt32);
1022 CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, kRepTagged,
1023 kTypeUint32);
1015 } 1024 }
1016 1025
1017 CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, rFloat64, rTagged); 1026 CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, kRepFloat64,
1018 CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, rTagged, rFloat64); 1027 kRepTagged);
1028 CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, kRepTagged,
1029 kRepFloat64);
1019 1030
1020 CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, tInt32, rFloat64); 1031 CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, kTypeInt32,
1021 CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, tInt32, rTagged); 1032 kRepFloat64);
1033 CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, kTypeInt32, kRepTagged);
1022 1034
1023 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, tUint32, rFloat64); 1035 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, kTypeUint32,
1024 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, tUint32, rTagged); 1036 kRepFloat64);
1037 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, kTypeUint32,
1038 kRepTagged);
1025 } 1039 }
1026 1040
1027 1041
1028 static void CheckChangesAroundBinop(TestingGraph* t, Operator* op, 1042 static void CheckChangesAroundBinop(TestingGraph* t, Operator* op,
1029 IrOpcode::Value input_change, 1043 IrOpcode::Value input_change,
1030 IrOpcode::Value output_change) { 1044 IrOpcode::Value output_change) {
1031 Node* binop = t->graph()->NewNode(op, t->p0, t->p1); 1045 Node* binop = t->graph()->NewNode(op, t->p0, t->p1);
1032 t->Return(binop); 1046 t->Return(binop);
1033 t->Lower(); 1047 t->Lower();
1034 CHECK_EQ(input_change, binop->InputAt(0)->opcode()); 1048 CHECK_EQ(input_change, binop->InputAt(0)->opcode());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 Int32Matcher index = Int32Matcher(load_or_store->InputAt(1)); 1130 Int32Matcher index = Int32Matcher(load_or_store->InputAt(1));
1117 CHECK(index.Is(access.offset - access.tag())); 1131 CHECK(index.Is(access.offset - access.tag()));
1118 } 1132 }
1119 1133
1120 1134
1121 Node* CheckElementAccessArithmetic(ElementAccess access, Node* load_or_store) { 1135 Node* CheckElementAccessArithmetic(ElementAccess access, Node* load_or_store) {
1122 Int32BinopMatcher index(load_or_store->InputAt(1)); 1136 Int32BinopMatcher index(load_or_store->InputAt(1));
1123 CHECK_EQ(IrOpcode::kInt32Add, index.node()->opcode()); 1137 CHECK_EQ(IrOpcode::kInt32Add, index.node()->opcode());
1124 CHECK(index.right().Is(access.header_size - access.tag())); 1138 CHECK(index.right().Is(access.header_size - access.tag()));
1125 1139
1126 int element_size = 0; 1140 int element_size = ElementSizeOf(access.machine_type);
1127 switch (access.representation) {
1128 case kMachineTagged:
1129 element_size = kPointerSize;
1130 break;
1131 case kMachineWord8:
1132 element_size = 1;
1133 break;
1134 case kMachineWord16:
1135 element_size = 2;
1136 break;
1137 case kMachineWord32:
1138 element_size = 4;
1139 break;
1140 case kMachineWord64:
1141 case kMachineFloat64:
1142 element_size = 8;
1143 break;
1144 case kMachineLast:
1145 UNREACHABLE();
1146 break;
1147 }
1148 1141
1149 if (element_size != 1) { 1142 if (element_size != 1) {
1150 Int32BinopMatcher mul(index.left().node()); 1143 Int32BinopMatcher mul(index.left().node());
1151 CHECK_EQ(IrOpcode::kInt32Mul, mul.node()->opcode()); 1144 CHECK_EQ(IrOpcode::kInt32Mul, mul.node()->opcode());
1152 CHECK(mul.right().Is(element_size)); 1145 CHECK(mul.right().Is(element_size));
1153 return mul.left().node(); 1146 return mul.left().node();
1154 } else { 1147 } else {
1155 return index.left().node(); 1148 return index.left().node();
1156 } 1149 }
1157 } 1150 }
1158 1151
1159 1152
1160 static const MachineType machine_reps[] = {kMachineWord8, kMachineWord16, 1153 static const MachineType machine_reps[] = {
1161 kMachineWord32, kMachineWord64, 1154 kRepBit, kMachInt8, kMachInt16, kMachInt32,
1162 kMachineFloat64, kMachineTagged}; 1155 kMachInt64, kMachFloat64, kMachAnyTagged};
1163
1164
1165 // Representation types corresponding to those above.
1166 static const RepType rep_types[] = {static_cast<RepType>(rWord32 | tUint32),
1167 static_cast<RepType>(rWord32 | tUint32),
1168 static_cast<RepType>(rWord32 | tInt32),
1169 static_cast<RepType>(rWord64),
1170 static_cast<RepType>(rFloat64 | tNumber),
1171 static_cast<RepType>(rTagged | tAny)};
1172 1156
1173 1157
1174 TEST(LowerLoadField_to_load) { 1158 TEST(LowerLoadField_to_load) {
1175 TestingGraph t(Type::Any(), Type::Signed32()); 1159 TestingGraph t(Type::Any(), Type::Signed32());
1176 1160
1177 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { 1161 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) {
1178 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 1162 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
1179 Handle<Name>::null(), Type::Any(), machine_reps[i]}; 1163 Handle<Name>::null(), Type::Any(), machine_reps[i]};
1180 1164
1181 Node* load = 1165 Node* load =
1182 t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); 1166 t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start);
1183 Node* use = t.Use(load, rep_types[i]); 1167 Node* use = t.Use(load, machine_reps[i]);
1184 t.Return(use); 1168 t.Return(use);
1185 t.Lower(); 1169 t.Lower();
1186 CHECK_EQ(IrOpcode::kLoad, load->opcode()); 1170 CHECK_EQ(IrOpcode::kLoad, load->opcode());
1187 CHECK_EQ(t.p0, load->InputAt(0)); 1171 CHECK_EQ(t.p0, load->InputAt(0));
1188 CheckFieldAccessArithmetic(access, load); 1172 CheckFieldAccessArithmetic(access, load);
1189 1173
1190 MachineType rep = OpParameter<MachineType>(load); 1174 MachineType rep = OpParameter<MachineType>(load);
1191 CHECK_EQ(machine_reps[i], rep); 1175 CHECK_EQ(machine_reps[i], rep);
1192 } 1176 }
1193 } 1177 }
1194 1178
1195 1179
1196 TEST(LowerStoreField_to_store) { 1180 TEST(LowerStoreField_to_store) {
1197 TestingGraph t(Type::Any(), Type::Signed32()); 1181 TestingGraph t(Type::Any(), Type::Signed32());
1198 1182
1199 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { 1183 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) {
1200 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 1184 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
1201 Handle<Name>::null(), Type::Any(), machine_reps[i]}; 1185 Handle<Name>::null(), Type::Any(), machine_reps[i]};
1202 1186
1203 1187
1204 Node* val = t.ExampleWithOutput(rep_types[i]); 1188 Node* val = t.ExampleWithOutput(machine_reps[i]);
1205 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, 1189 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0,
1206 val, t.start, t.start); 1190 val, t.start, t.start);
1207 t.Effect(store); 1191 t.Effect(store);
1208 t.Lower(); 1192 t.Lower();
1209 CHECK_EQ(IrOpcode::kStore, store->opcode()); 1193 CHECK_EQ(IrOpcode::kStore, store->opcode());
1210 CHECK_EQ(val, store->InputAt(2)); 1194 CHECK_EQ(val, store->InputAt(2));
1211 CheckFieldAccessArithmetic(access, store); 1195 CheckFieldAccessArithmetic(access, store);
1212 1196
1213 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); 1197 StoreRepresentation rep = OpParameter<StoreRepresentation>(store);
1214 if (rep_types[i] & rTagged) { 1198 if (machine_reps[i] & kRepTagged) {
1215 CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind); 1199 CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind);
1216 } 1200 }
1217 CHECK_EQ(machine_reps[i], rep.rep); 1201 CHECK_EQ(machine_reps[i], rep.machine_type);
1218 } 1202 }
1219 } 1203 }
1220 1204
1221 1205
1222 TEST(LowerLoadElement_to_load) { 1206 TEST(LowerLoadElement_to_load) {
1223 TestingGraph t(Type::Any(), Type::Signed32()); 1207 TestingGraph t(Type::Any(), Type::Signed32());
1224 1208
1225 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { 1209 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) {
1226 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 1210 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
1227 Type::Any(), machine_reps[i]}; 1211 Type::Any(), machine_reps[i]};
1228 1212
1229 Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, 1213 Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0,
1230 t.p1, t.start); 1214 t.p1, t.start);
1231 Node* use = t.Use(load, rep_types[i]); 1215 Node* use = t.Use(load, machine_reps[i]);
1232 t.Return(use); 1216 t.Return(use);
1233 t.Lower(); 1217 t.Lower();
1234 CHECK_EQ(IrOpcode::kLoad, load->opcode()); 1218 CHECK_EQ(IrOpcode::kLoad, load->opcode());
1235 CHECK_EQ(t.p0, load->InputAt(0)); 1219 CHECK_EQ(t.p0, load->InputAt(0));
1236 CheckElementAccessArithmetic(access, load); 1220 CheckElementAccessArithmetic(access, load);
1237 1221
1238 MachineType rep = OpParameter<MachineType>(load); 1222 MachineType rep = OpParameter<MachineType>(load);
1239 CHECK_EQ(machine_reps[i], rep); 1223 CHECK_EQ(machine_reps[i], rep);
1240 } 1224 }
1241 } 1225 }
1242 1226
1243 1227
1244 TEST(LowerStoreElement_to_store) { 1228 TEST(LowerStoreElement_to_store) {
1245 TestingGraph t(Type::Any(), Type::Signed32()); 1229 TestingGraph t(Type::Any(), Type::Signed32());
1246 1230
1247 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { 1231 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) {
1248 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 1232 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
1249 Type::Any(), machine_reps[i]}; 1233 Type::Any(), machine_reps[i]};
1250 1234
1251 Node* val = t.ExampleWithOutput(rep_types[i]); 1235 Node* val = t.ExampleWithOutput(machine_reps[i]);
1252 Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, 1236 Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0,
1253 t.p1, val, t.start, t.start); 1237 t.p1, val, t.start, t.start);
1254 t.Effect(store); 1238 t.Effect(store);
1255 t.Lower(); 1239 t.Lower();
1256 CHECK_EQ(IrOpcode::kStore, store->opcode()); 1240 CHECK_EQ(IrOpcode::kStore, store->opcode());
1257 CHECK_EQ(val, store->InputAt(2)); 1241 CHECK_EQ(val, store->InputAt(2));
1258 CheckElementAccessArithmetic(access, store); 1242 CheckElementAccessArithmetic(access, store);
1259 1243
1260 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); 1244 StoreRepresentation rep = OpParameter<StoreRepresentation>(store);
1261 if (rep_types[i] & rTagged) { 1245 if (machine_reps[i] & kRepTagged) {
1262 CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind); 1246 CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind);
1263 } 1247 }
1264 CHECK_EQ(machine_reps[i], rep.rep); 1248 CHECK_EQ(machine_reps[i], rep.machine_type);
1265 } 1249 }
1266 } 1250 }
1267 1251
1268 1252
1269 TEST(InsertChangeForLoadElementIndex) { 1253 TEST(InsertChangeForLoadElementIndex) {
1270 // LoadElement(obj: Tagged, index: tInt32 | rTagged) => 1254 // LoadElement(obj: Tagged, index: kTypeInt32 | kRepTagged) =>
1271 // Load(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k)) 1255 // Load(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k))
1272 TestingGraph t(Type::Any(), Type::Signed32()); 1256 TestingGraph t(Type::Any(), Type::Signed32());
1273 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), 1257 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
1274 kMachineTagged}; 1258 kMachAnyTagged};
1275 1259
1276 Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, 1260 Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0,
1277 t.p1, t.start); 1261 t.p1, t.start);
1278 t.Return(load); 1262 t.Return(load);
1279 t.Lower(); 1263 t.Lower();
1280 CHECK_EQ(IrOpcode::kLoad, load->opcode()); 1264 CHECK_EQ(IrOpcode::kLoad, load->opcode());
1281 CHECK_EQ(t.p0, load->InputAt(0)); 1265 CHECK_EQ(t.p0, load->InputAt(0));
1282 1266
1283 Node* index = CheckElementAccessArithmetic(access, load); 1267 Node* index = CheckElementAccessArithmetic(access, load);
1284 CheckChangeOf(IrOpcode::kChangeTaggedToInt32, t.p1, index); 1268 CheckChangeOf(IrOpcode::kChangeTaggedToInt32, t.p1, index);
1285 } 1269 }
1286 1270
1287 1271
1288 TEST(InsertChangeForStoreElementIndex) { 1272 TEST(InsertChangeForStoreElementIndex) {
1289 // StoreElement(obj: Tagged, index: tInt32 | rTagged, val) => 1273 // StoreElement(obj: Tagged, index: kTypeInt32 | kRepTagged, val) =>
1290 // Store(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k), val) 1274 // Store(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k), val)
1291 TestingGraph t(Type::Any(), Type::Signed32()); 1275 TestingGraph t(Type::Any(), Type::Signed32());
1292 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), 1276 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
1293 kMachineTagged}; 1277 kMachAnyTagged};
1294 1278
1295 Node* store = 1279 Node* store =
1296 t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, t.p1, 1280 t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, t.p1,
1297 t.jsgraph.TrueConstant(), t.start, t.start); 1281 t.jsgraph.TrueConstant(), t.start, t.start);
1298 t.Effect(store); 1282 t.Effect(store);
1299 t.Lower(); 1283 t.Lower();
1300 CHECK_EQ(IrOpcode::kStore, store->opcode()); 1284 CHECK_EQ(IrOpcode::kStore, store->opcode());
1301 CHECK_EQ(t.p0, store->InputAt(0)); 1285 CHECK_EQ(t.p0, store->InputAt(0));
1302 1286
1303 Node* index = CheckElementAccessArithmetic(access, store); 1287 Node* index = CheckElementAccessArithmetic(access, store);
1304 CheckChangeOf(IrOpcode::kChangeTaggedToInt32, t.p1, index); 1288 CheckChangeOf(IrOpcode::kChangeTaggedToInt32, t.p1, index);
1305 } 1289 }
1306 1290
1307 1291
1308 TEST(InsertChangeForLoadElement) { 1292 TEST(InsertChangeForLoadElement) {
1309 // TODO(titzer): test all load/store representation change insertions. 1293 // TODO(titzer): test all load/store representation change insertions.
1310 TestingGraph t(Type::Any(), Type::Signed32()); 1294 TestingGraph t(Type::Any(), Type::Signed32());
1311 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), 1295 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
1312 kMachineFloat64}; 1296 kMachFloat64};
1313 1297
1314 Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, 1298 Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0,
1315 t.p1, t.start); 1299 t.p1, t.start);
1316 t.Return(load); 1300 t.Return(load);
1317 t.Lower(); 1301 t.Lower();
1318 CHECK_EQ(IrOpcode::kLoad, load->opcode()); 1302 CHECK_EQ(IrOpcode::kLoad, load->opcode());
1319 CHECK_EQ(t.p0, load->InputAt(0)); 1303 CHECK_EQ(t.p0, load->InputAt(0));
1320 CheckChangeOf(IrOpcode::kChangeFloat64ToTagged, load, t.ret->InputAt(0)); 1304 CheckChangeOf(IrOpcode::kChangeFloat64ToTagged, load, t.ret->InputAt(0));
1321 } 1305 }
1322 1306
1323 1307
1324 TEST(InsertChangeForLoadField) { 1308 TEST(InsertChangeForLoadField) {
1325 // TODO(titzer): test all load/store representation change insertions. 1309 // TODO(titzer): test all load/store representation change insertions.
1326 TestingGraph t(Type::Any(), Type::Signed32()); 1310 TestingGraph t(Type::Any(), Type::Signed32());
1327 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 1311 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
1328 Handle<Name>::null(), Type::Any(), kMachineFloat64}; 1312 Handle<Name>::null(), Type::Any(), kMachFloat64};
1329 1313
1330 Node* load = 1314 Node* load =
1331 t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); 1315 t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start);
1332 t.Return(load); 1316 t.Return(load);
1333 t.Lower(); 1317 t.Lower();
1334 CHECK_EQ(IrOpcode::kLoad, load->opcode()); 1318 CHECK_EQ(IrOpcode::kLoad, load->opcode());
1335 CHECK_EQ(t.p0, load->InputAt(0)); 1319 CHECK_EQ(t.p0, load->InputAt(0));
1336 CheckChangeOf(IrOpcode::kChangeFloat64ToTagged, load, t.ret->InputAt(0)); 1320 CheckChangeOf(IrOpcode::kChangeFloat64ToTagged, load, t.ret->InputAt(0));
1337 } 1321 }
1338 1322
1339 1323
1340 TEST(InsertChangeForStoreElement) { 1324 TEST(InsertChangeForStoreElement) {
1341 // TODO(titzer): test all load/store representation change insertions. 1325 // TODO(titzer): test all load/store representation change insertions.
1342 TestingGraph t(Type::Any(), Type::Signed32()); 1326 TestingGraph t(Type::Any(), Type::Signed32());
1343 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), 1327 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
1344 kMachineFloat64}; 1328 kMachFloat64};
1345 1329
1346 Node* store = 1330 Node* store =
1347 t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, 1331 t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0,
1348 t.jsgraph.Int32Constant(0), t.p1, t.start, t.start); 1332 t.jsgraph.Int32Constant(0), t.p1, t.start, t.start);
1349 t.Effect(store); 1333 t.Effect(store);
1350 t.Lower(); 1334 t.Lower();
1351 1335
1352 CHECK_EQ(IrOpcode::kStore, store->opcode()); 1336 CHECK_EQ(IrOpcode::kStore, store->opcode());
1353 CHECK_EQ(t.p0, store->InputAt(0)); 1337 CHECK_EQ(t.p0, store->InputAt(0));
1354 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2)); 1338 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2));
1355 } 1339 }
1356 1340
1357 1341
1358 TEST(InsertChangeForStoreField) { 1342 TEST(InsertChangeForStoreField) {
1359 // TODO(titzer): test all load/store representation change insertions. 1343 // TODO(titzer): test all load/store representation change insertions.
1360 TestingGraph t(Type::Any(), Type::Signed32()); 1344 TestingGraph t(Type::Any(), Type::Signed32());
1361 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, 1345 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
1362 Handle<Name>::null(), Type::Any(), kMachineFloat64}; 1346 Handle<Name>::null(), Type::Any(), kMachFloat64};
1363 1347
1364 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, 1348 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0,
1365 t.p1, t.start, t.start); 1349 t.p1, t.start, t.start);
1366 t.Effect(store); 1350 t.Effect(store);
1367 t.Lower(); 1351 t.Lower();
1368 1352
1369 CHECK_EQ(IrOpcode::kStore, store->opcode()); 1353 CHECK_EQ(IrOpcode::kStore, store->opcode());
1370 CHECK_EQ(t.p0, store->InputAt(0)); 1354 CHECK_EQ(t.p0, store->InputAt(0));
1371 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2)); 1355 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2));
1372 } 1356 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-scheduler.cc ('k') | test/cctest/compiler/test-structured-ifbuilder-fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698