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

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

Issue 425003004: Implement representation selection as part of SimplifiedLowering. Representation selection also req… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. 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/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
10 #include "src/compiler/pipeline.h" 11 #include "src/compiler/pipeline.h"
12 #include "src/compiler/representation-change.h"
11 #include "src/compiler/simplified-lowering.h" 13 #include "src/compiler/simplified-lowering.h"
12 #include "src/compiler/simplified-node-factory.h" 14 #include "src/compiler/simplified-node-factory.h"
13 #include "src/compiler/typer.h" 15 #include "src/compiler/typer.h"
14 #include "src/compiler/verifier.h" 16 #include "src/compiler/verifier.h"
15 #include "src/execution.h" 17 #include "src/execution.h"
16 #include "src/parser.h" 18 #include "src/parser.h"
17 #include "src/rewriter.h" 19 #include "src/rewriter.h"
18 #include "src/scopes.h" 20 #include "src/scopes.h"
19 #include "test/cctest/cctest.h" 21 #include "test/cctest/cctest.h"
20 #include "test/cctest/compiler/codegen-tester.h" 22 #include "test/cctest/compiler/codegen-tester.h"
(...skipping 16 matching lines...) Expand all
37 typer(this->zone()), 39 typer(this->zone()),
38 source_positions(this->graph()), 40 source_positions(this->graph()),
39 jsgraph(this->graph(), this->common(), &typer), 41 jsgraph(this->graph(), this->common(), &typer),
40 lowering(&jsgraph, &source_positions) {} 42 lowering(&jsgraph, &source_positions) {}
41 43
42 Typer typer; 44 Typer typer;
43 SourcePositionTable source_positions; 45 SourcePositionTable source_positions;
44 JSGraph jsgraph; 46 JSGraph jsgraph;
45 SimplifiedLowering lowering; 47 SimplifiedLowering lowering;
46 48
47 // Close graph and lower one node. 49 void LowerAllNodes() {
48 void Lower(Node* node) {
49 this->End(); 50 this->End();
50 if (node == NULL) { 51 lowering.LowerAllNodes();
51 lowering.LowerAllNodes();
52 } else {
53 lowering.Lower(node);
54 }
55 }
56
57 // Close graph and lower all nodes.
58 void LowerAllNodes() { Lower(NULL); }
59
60 void StoreFloat64(Node* node, double* ptr) {
61 Node* ptr_node = this->PointerConstant(ptr);
62 this->Store(kMachineFloat64, ptr_node, node);
63 }
64
65 Node* LoadInt32(int32_t* ptr) {
66 Node* ptr_node = this->PointerConstant(ptr);
67 return this->Load(kMachineWord32, ptr_node);
68 }
69
70 Node* LoadUint32(uint32_t* ptr) {
71 Node* ptr_node = this->PointerConstant(ptr);
72 return this->Load(kMachineWord32, ptr_node);
73 }
74
75 Node* LoadFloat64(double* ptr) {
76 Node* ptr_node = this->PointerConstant(ptr);
77 return this->Load(kMachineFloat64, ptr_node);
78 } 52 }
79 53
80 Factory* factory() { return this->isolate()->factory(); } 54 Factory* factory() { return this->isolate()->factory(); }
81 Heap* heap() { return this->isolate()->heap(); } 55 Heap* heap() { return this->isolate()->heap(); }
82 }; 56 };
83 57
84 58
85 // TODO(dcarney): find a home for these functions. 59 // TODO(dcarney): find a home for these functions.
86 namespace { 60 namespace {
87 61
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 109
136 110
137 TEST(RunLoadMap) { 111 TEST(RunLoadMap) {
138 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); 112 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged);
139 FieldAccess access = ForJSObjectMap(); 113 FieldAccess access = ForJSObjectMap();
140 Node* load = t.LoadField(access, t.Parameter(0)); 114 Node* load = t.LoadField(access, t.Parameter(0));
141 t.Return(load); 115 t.Return(load);
142 116
143 t.LowerAllNodes(); 117 t.LowerAllNodes();
144 118
145 if (!Pipeline::SupportedTarget()) return; 119 if (Pipeline::SupportedTarget()) {
146 120 t.GenerateCode();
147 Handle<JSObject> src = TestObject(); 121 Handle<JSObject> src = TestObject();
148 Handle<Map> src_map(src->map()); 122 Handle<Map> src_map(src->map());
149 Object* result = t.Call(*src); 123 Object* result = t.Call(*src); // TODO(titzer): raw pointers in call
150 CHECK_EQ(*src_map, result); 124 CHECK_EQ(*src_map, result);
125 }
151 } 126 }
152 127
153 128
154 TEST(RunStoreMap) { 129 TEST(RunStoreMap) {
155 SimplifiedGraphBuilderTester<int32_t> t(kMachineTagged, kMachineTagged); 130 SimplifiedGraphBuilderTester<int32_t> t(kMachineTagged, kMachineTagged);
156 FieldAccess access = ForJSObjectMap(); 131 FieldAccess access = ForJSObjectMap();
157 t.StoreField(access, t.Parameter(1), t.Parameter(0)); 132 t.StoreField(access, t.Parameter(1), t.Parameter(0));
158 t.Return(t.Int32Constant(0)); 133 t.Return(t.jsgraph.TrueConstant());
159 134
160 t.LowerAllNodes(); 135 t.LowerAllNodes();
161 136
162 if (!Pipeline::SupportedTarget()) return; 137 if (Pipeline::SupportedTarget()) {
163 138 t.GenerateCode();
164 Handle<JSObject> src = TestObject(); 139 Handle<JSObject> src = TestObject();
165 Handle<Map> src_map(src->map()); 140 Handle<Map> src_map(src->map());
166 Handle<JSObject> dst = TestObject(); 141 Handle<JSObject> dst = TestObject();
167 CHECK(src->map() != dst->map()); 142 CHECK(src->map() != dst->map());
168 t.Call(*src_map, *dst); 143 t.Call(*src_map, *dst); // TODO(titzer): raw pointers in call
169 CHECK(*src_map == dst->map()); 144 CHECK(*src_map == dst->map());
145 }
170 } 146 }
171 147
172 148
173 TEST(RunLoadProperties) { 149 TEST(RunLoadProperties) {
174 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); 150 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged);
175 FieldAccess access = ForJSObjectProperties(); 151 FieldAccess access = ForJSObjectProperties();
176 Node* load = t.LoadField(access, t.Parameter(0)); 152 Node* load = t.LoadField(access, t.Parameter(0));
177 t.Return(load); 153 t.Return(load);
178 154
179 t.LowerAllNodes(); 155 t.LowerAllNodes();
180 156
181 if (!Pipeline::SupportedTarget()) return; 157 if (Pipeline::SupportedTarget()) {
182 158 t.GenerateCode();
183 Handle<JSObject> src = TestObject(); 159 Handle<JSObject> src = TestObject();
184 Handle<FixedArray> src_props(src->properties()); 160 Handle<FixedArray> src_props(src->properties());
185 Object* result = t.Call(*src); 161 Object* result = t.Call(*src); // TODO(titzer): raw pointers in call
186 CHECK_EQ(*src_props, result); 162 CHECK_EQ(*src_props, result);
163 }
187 } 164 }
188 165
189 166
190 TEST(RunLoadStoreMap) { 167 TEST(RunLoadStoreMap) {
191 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged, kMachineTagged); 168 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged, kMachineTagged);
192 FieldAccess access = ForJSObjectMap(); 169 FieldAccess access = ForJSObjectMap();
193 Node* load = t.LoadField(access, t.Parameter(0)); 170 Node* load = t.LoadField(access, t.Parameter(0));
194 t.StoreField(access, t.Parameter(1), load); 171 t.StoreField(access, t.Parameter(1), load);
195 t.Return(load); 172 t.Return(load);
196 173
197 t.LowerAllNodes(); 174 t.LowerAllNodes();
198 175
199 if (!Pipeline::SupportedTarget()) return; 176 if (Pipeline::SupportedTarget()) {
200 177 t.GenerateCode();
201 Handle<JSObject> src = TestObject(); 178 Handle<JSObject> src = TestObject();
202 Handle<Map> src_map(src->map()); 179 Handle<Map> src_map(src->map());
203 Handle<JSObject> dst = TestObject(); 180 Handle<JSObject> dst = TestObject();
204 CHECK(src->map() != dst->map()); 181 CHECK(src->map() != dst->map());
205 Object* result = t.Call(*src, *dst); 182 Object* result = t.Call(*src, *dst); // TODO(titzer): raw pointers in call
206 CHECK(result->IsMap()); 183 CHECK(result->IsMap());
207 CHECK_EQ(*src_map, result); 184 CHECK_EQ(*src_map, result);
208 CHECK(*src_map == dst->map()); 185 CHECK(*src_map == dst->map());
186 }
209 } 187 }
210 188
211 189
212 TEST(RunLoadStoreFixedArrayIndex) { 190 TEST(RunLoadStoreFixedArrayIndex) {
213 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged); 191 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged);
214 ElementAccess access = ForFixedArrayElement(); 192 ElementAccess access = ForFixedArrayElement();
215 Node* load = t.LoadElement(access, t.Parameter(0), t.Int32Constant(0)); 193 Node* load = t.LoadElement(access, t.Parameter(0), t.Int32Constant(0));
216 t.StoreElement(access, t.Parameter(0), t.Int32Constant(1), load); 194 t.StoreElement(access, t.Parameter(0), t.Int32Constant(1), load);
217 t.Return(load); 195 t.Return(load);
218 196
219 t.LowerAllNodes(); 197 t.LowerAllNodes();
220 198
221 if (!Pipeline::SupportedTarget()) return; 199 if (Pipeline::SupportedTarget()) {
222 200 t.GenerateCode();
223 Handle<FixedArray> array = t.factory()->NewFixedArray(2); 201 Handle<FixedArray> array = t.factory()->NewFixedArray(2);
224 Handle<JSObject> src = TestObject(); 202 Handle<JSObject> src = TestObject();
225 Handle<JSObject> dst = TestObject(); 203 Handle<JSObject> dst = TestObject();
226 array->set(0, *src); 204 array->set(0, *src);
227 array->set(1, *dst); 205 array->set(1, *dst);
228 Object* result = t.Call(*array); 206 Object* result = t.Call(*array);
229 CHECK_EQ(*src, result); 207 CHECK_EQ(*src, result);
230 CHECK_EQ(*src, array->get(0)); 208 CHECK_EQ(*src, array->get(0));
231 CHECK_EQ(*src, array->get(1)); 209 CHECK_EQ(*src, array->get(1));
210 }
232 } 211 }
233 212
234 213
235 TEST(RunLoadStoreArrayBuffer) { 214 TEST(RunLoadStoreArrayBuffer) {
236 SimplifiedGraphBuilderTester<int32_t> t(kMachineTagged); 215 SimplifiedGraphBuilderTester<Object*> t(kMachineTagged);
237 const int index = 12; 216 const int index = 12;
238 FieldAccess access = ForArrayBufferBackingStore();
239 Node* backing_store = t.LoadField(access, t.Parameter(0));
240 ElementAccess buffer_access = ForBackingStoreElement(kMachineWord8); 217 ElementAccess buffer_access = ForBackingStoreElement(kMachineWord8);
218 Node* backing_store =
219 t.LoadField(ForArrayBufferBackingStore(), t.Parameter(0));
241 Node* load = 220 Node* load =
242 t.LoadElement(buffer_access, backing_store, t.Int32Constant(index)); 221 t.LoadElement(buffer_access, backing_store, t.Int32Constant(index));
243 t.StoreElement(buffer_access, backing_store, t.Int32Constant(index + 1), 222 t.StoreElement(buffer_access, backing_store, t.Int32Constant(index + 1),
244 load); 223 load);
245 t.Return(load); 224 t.Return(t.jsgraph.TrueConstant());
246 225
247 t.LowerAllNodes(); 226 t.LowerAllNodes();
248 227
249 if (!Pipeline::SupportedTarget()) return; 228 if (Pipeline::SupportedTarget()) {
229 t.GenerateCode();
230 Handle<JSArrayBuffer> array = t.factory()->NewJSArrayBuffer();
231 const int array_length = 2 * index;
232 Runtime::SetupArrayBufferAllocatingData(t.isolate(), array, array_length);
233 uint8_t* data = reinterpret_cast<uint8_t*>(array->backing_store());
234 for (int i = 0; i < array_length; i++) {
235 data[i] = i;
236 }
250 237
251 Handle<JSArrayBuffer> array = t.factory()->NewJSArrayBuffer(); 238 // TODO(titzer): raw pointers in call
252 const int array_length = 2 * index; 239 Object* result = t.Call(*array);
253 Runtime::SetupArrayBufferAllocatingData(t.isolate(), array, array_length); 240 CHECK_EQ(t.isolate()->heap()->true_value(), result);
254 uint8_t* data = reinterpret_cast<uint8_t*>(array->backing_store()); 241 for (int i = 0; i < array_length; i++) {
255 for (int i = 0; i < array_length; i++) { 242 uint8_t expected = i;
256 data[i] = i; 243 if (i == (index + 1)) expected = index;
257 } 244 CHECK_EQ(data[i], expected);
258 int32_t result = t.Call(*array); 245 }
259 CHECK_EQ(index, result);
260 for (int i = 0; i < array_length; i++) {
261 uint8_t expected = i;
262 if (i == (index + 1)) expected = result;
263 CHECK_EQ(data[i], expected);
264 } 246 }
265 } 247 }
266 248
267
268 TEST(RunCopyFixedArray) {
269 SimplifiedGraphBuilderTester<int32_t> t(kMachineTagged, kMachineTagged);
270
271 const int kArraySize = 15;
272 Node* one = t.Int32Constant(1);
273 Node* index = t.Int32Constant(0);
274 Node* limit = t.Int32Constant(kArraySize);
275 t.environment()->Push(index);
276 {
277 LoopBuilder loop(&t);
278 loop.BeginLoop();
279 // Loop exit condition.
280 index = t.environment()->Top();
281 Node* condition = t.Int32LessThan(index, limit);
282 loop.BreakUnless(condition);
283 // src[index] = dst[index].
284 index = t.environment()->Pop();
285 ElementAccess access = ForFixedArrayElement();
286 Node* src = t.Parameter(0);
287 Node* load = t.LoadElement(access, src, index);
288 Node* dst = t.Parameter(1);
289 t.StoreElement(access, dst, index, load);
290 // index++
291 index = t.Int32Add(index, one);
292 t.environment()->Push(index);
293 // continue.
294 loop.EndBody();
295 loop.EndLoop();
296 }
297 index = t.environment()->Pop();
298 t.Return(index);
299
300 t.LowerAllNodes();
301
302 if (!Pipeline::SupportedTarget()) return;
303
304 Handle<FixedArray> src = t.factory()->NewFixedArray(kArraySize);
305 Handle<FixedArray> src_copy = t.factory()->NewFixedArray(kArraySize);
306 Handle<FixedArray> dst = t.factory()->NewFixedArray(kArraySize);
307 for (int i = 0; i < kArraySize; i++) {
308 src->set(i, *TestObject());
309 src_copy->set(i, src->get(i));
310 dst->set(i, *TestObject());
311 CHECK_NE(src_copy->get(i), dst->get(i));
312 }
313 CHECK_EQ(kArraySize, t.Call(*src, *dst));
314 for (int i = 0; i < kArraySize; i++) {
315 CHECK_EQ(src_copy->get(i), dst->get(i));
316 }
317 }
318
319 249
320 TEST(RunLoadFieldFromUntaggedBase) { 250 TEST(RunLoadFieldFromUntaggedBase) {
321 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; 251 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)};
322 252
323 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { 253 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {
324 int offset = static_cast<int>(i * sizeof(Smi*)); 254 int offset = static_cast<int>(i * sizeof(Smi*));
325 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), 255 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(),
326 Type::Integral32(), kMachineTagged}; 256 Type::Integral32(), kMachineTagged};
327 257
328 SimplifiedGraphBuilderTester<Object*> t; 258 SimplifiedGraphBuilderTester<Object*> t;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 Smi* expected = Smi::FromInt(k); 348 Smi* expected = Smi::FromInt(k);
419 smis[i + j] = Smi::FromInt(-100); 349 smis[i + j] = Smi::FromInt(-100);
420 CHECK_EQ(expected, t.Call(expected)); 350 CHECK_EQ(expected, t.Call(expected));
421 CHECK_EQ(expected, smis[i + j]); 351 CHECK_EQ(expected, smis[i + j]);
422 } 352 }
423 353
424 // TODO(titzer): assert the contents of the array. 354 // TODO(titzer): assert the contents of the array.
425 } 355 }
426 } 356 }
427 } 357 }
358
359
360 // A helper class for accessing fields and elements of various types, on both
361 // tagged and untagged base pointers. Contains both tagged and untagged buffers
362 // for testing direct memory access from generated code.
363 template <typename E>
364 class AccessTester : public HandleAndZoneScope {
365 public:
366 bool tagged;
367 MachineRepresentation rep;
368 E* original_elements;
369 int num_elements;
370 E* untagged_array;
371 Handle<ByteArray> tagged_array; // TODO(titzer): use FixedArray for tagged.
372
373 AccessTester(bool t, MachineRepresentation r, E* orig, int num)
374 : tagged(t),
375 rep(r),
376 original_elements(orig),
377 num_elements(num),
378 untagged_array(static_cast<E*>(malloc(ByteSize()))),
379 tagged_array(main_isolate()->factory()->NewByteArray(ByteSize())) {
380 Reinitialize();
381 }
382
383 ~AccessTester() { free(untagged_array); }
384
385 size_t ByteSize() { return num_elements * sizeof(E); }
386
387 // Nuke both {untagged_array} and {tagged_array} with {original_elements}.
388 void Reinitialize() {
389 memcpy(untagged_array, original_elements, ByteSize());
390 CHECK_EQ(ByteSize(), tagged_array->length());
391 E* raw = reinterpret_cast<E*>(tagged_array->GetDataStartAddress());
392 memcpy(raw, original_elements, ByteSize());
393 }
394
395 // Create and run code that copies the element in either {untagged_array}
396 // or {tagged_array} at index {from_index} to index {to_index}.
397 void RunCopyElement(int from_index, int to_index) {
398 // TODO(titzer): test element and field accesses where the base is not
399 // a constant in the code.
400 BoundsCheck(from_index);
401 BoundsCheck(to_index);
402 ElementAccess access = GetElementAccess();
403
404 SimplifiedGraphBuilderTester<Object*> t;
405 Node* ptr = GetBaseNode(&t);
406 Node* load = t.LoadElement(access, ptr, t.Int32Constant(from_index));
407 t.StoreElement(access, ptr, t.Int32Constant(to_index), load);
408 t.Return(t.jsgraph.TrueConstant());
409 t.LowerAllNodes();
410 t.GenerateCode();
411
412 if (Pipeline::SupportedTarget()) {
413 Object* result = t.Call();
414 CHECK_EQ(t.isolate()->heap()->true_value(), result);
415 }
416 }
417
418 // Create and run code that copies the field in either {untagged_array}
419 // or {tagged_array} at index {from_index} to index {to_index}.
420 void RunCopyField(int from_index, int to_index) {
421 BoundsCheck(from_index);
422 BoundsCheck(to_index);
423 FieldAccess from_access = GetFieldAccess(from_index);
424 FieldAccess to_access = GetFieldAccess(to_index);
425
426 SimplifiedGraphBuilderTester<Object*> t;
427 Node* ptr = GetBaseNode(&t);
428 Node* load = t.LoadField(from_access, ptr);
429 t.StoreField(to_access, ptr, load);
430 t.Return(t.jsgraph.TrueConstant());
431 t.LowerAllNodes();
432 t.GenerateCode();
433
434 if (Pipeline::SupportedTarget()) {
435 Object* result = t.Call();
436 CHECK_EQ(t.isolate()->heap()->true_value(), result);
437 }
438 }
439
440 // Create and run code that copies the elements from {this} to {that}.
441 void RunCopyElements(AccessTester<E>* that) {
442 SimplifiedGraphBuilderTester<Object*> t;
443
444 Node* one = t.Int32Constant(1);
445 Node* index = t.Int32Constant(0);
446 Node* limit = t.Int32Constant(num_elements);
447 t.environment()->Push(index);
448 Node* src = this->GetBaseNode(&t);
449 Node* dst = that->GetBaseNode(&t);
450 {
451 LoopBuilder loop(&t);
452 loop.BeginLoop();
453 // Loop exit condition
454 index = t.environment()->Top();
455 Node* condition = t.Int32LessThan(index, limit);
456 loop.BreakUnless(condition);
457 // dst[index] = src[index]
458 index = t.environment()->Pop();
459 Node* load = t.LoadElement(this->GetElementAccess(), src, index);
460 t.StoreElement(that->GetElementAccess(), dst, index, load);
461 // index++
462 index = t.Int32Add(index, one);
463 t.environment()->Push(index);
464 // continue
465 loop.EndBody();
466 loop.EndLoop();
467 }
468 index = t.environment()->Pop();
469 t.Return(t.jsgraph.TrueConstant());
470 t.LowerAllNodes();
471 t.GenerateCode();
472
473 if (Pipeline::SupportedTarget()) {
474 Object* result = t.Call();
475 CHECK_EQ(t.isolate()->heap()->true_value(), result);
476 }
477 }
478
479 E GetElement(int index) {
480 BoundsCheck(index);
481 if (tagged) {
482 E* raw = reinterpret_cast<E*>(tagged_array->GetDataStartAddress());
483 return raw[index];
484 } else {
485 return untagged_array[index];
486 }
487 }
488
489 private:
490 ElementAccess GetElementAccess() {
491 ElementAccess access = {tagged ? kTaggedBase : kUntaggedBase,
492 tagged ? FixedArrayBase::kHeaderSize : 0,
493 Type::Any(), rep};
494 return access;
495 }
496
497 FieldAccess GetFieldAccess(int field) {
498 int offset = field * sizeof(E);
499 FieldAccess access = {tagged ? kTaggedBase : kUntaggedBase,
500 offset + (tagged ? FixedArrayBase::kHeaderSize : 0),
501 Handle<Name>(), Type::Any(), rep};
502 return access;
503 }
504
505 template <typename T>
506 Node* GetBaseNode(SimplifiedGraphBuilderTester<T>* t) {
507 return tagged ? t->HeapConstant(tagged_array)
508 : t->PointerConstant(untagged_array);
509 }
510
511 void BoundsCheck(int index) {
512 CHECK_GE(index, 0);
513 CHECK_LT(index, num_elements);
514 CHECK_EQ(ByteSize(), tagged_array->length());
515 }
516 };
517
518
519 template <typename E>
520 static void RunAccessTest(MachineRepresentation rep, E* original_elements,
521 size_t num) {
522 int num_elements = static_cast<int>(num);
523
524 for (int taggedness = 0; taggedness < 2; taggedness++) {
525 AccessTester<E> a(taggedness == 1, rep, original_elements, num_elements);
526 for (int field = 0; field < 2; field++) {
527 for (int i = 0; i < num_elements - 1; i++) {
528 a.Reinitialize();
529 if (field == 0) {
530 a.RunCopyField(i, i + 1); // Test field read/write.
531 } else {
532 a.RunCopyElement(i, i + 1); // Test element read/write.
533 }
534 if (Pipeline::SupportedTarget()) { // verify.
535 for (int j = 0; j < num_elements; j++) {
536 E expect =
537 j == (i + 1) ? original_elements[i] : original_elements[j];
538 CHECK_EQ(expect, a.GetElement(j));
539 }
540 }
541 }
542 }
543 }
544 // Test array copy.
545 for (int tf = 0; tf < 2; tf++) {
546 for (int tt = 0; tt < 2; tt++) {
547 AccessTester<E> a(tf == 1, rep, original_elements, num_elements);
548 AccessTester<E> b(tt == 1, rep, original_elements, num_elements);
549 a.RunCopyElements(&b);
550 if (Pipeline::SupportedTarget()) { // verify.
551 for (int i = 0; i < num_elements; i++) {
552 CHECK_EQ(a.GetElement(i), b.GetElement(i));
553 }
554 }
555 }
556 }
557 }
558
559
560 TEST(RunAccessTests_uint8) {
561 uint8_t data[] = {0x07, 0x16, 0x25, 0x34, 0x43, 0x99,
562 0xab, 0x78, 0x89, 0x19, 0x2b, 0x38};
563 RunAccessTest<uint8_t>(kMachineWord8, data, ARRAY_SIZE(data));
564 }
565
566
567 TEST(RunAccessTests_uint16) {
568 uint16_t data[] = {0x071a, 0x162b, 0x253c, 0x344d, 0x435e, 0x7777};
569 RunAccessTest<uint16_t>(kMachineWord16, data, ARRAY_SIZE(data));
570 }
571
572
573 TEST(RunAccessTests_int32) {
574 int32_t data[] = {0xf10733aa, 0xf21644bb, 0xf32555cc,
575 0xf43466dd, 0xf54377ee, 0x34455667};
576 RunAccessTest<int32_t>(kMachineWord32, data, ARRAY_SIZE(data));
577 }
578
579
580 TEST(RunAccessTests_int64) {
581 if (kPointerSize != 8) return;
582 int64_t data[] = {0x1011121314151617L, 0x2021222324252627L,
583 0x3031323334353637L, 0xa0a1a2a3a4a5a6a7L,
584 0xf0f1f2f3f4f5f6f7L};
585 RunAccessTest<int64_t>(kMachineWord64, data, ARRAY_SIZE(data));
586 }
587
588
589 TEST(RunAccessTests_float64) {
590 double data[] = {1.25, -1.25, 2.75, 11.0, 11100.8};
591 RunAccessTest<double>(kMachineFloat64, data, ARRAY_SIZE(data));
592 }
593
594
595 TEST(RunAccessTests_Smi) {
596 Smi* data[] = {Smi::FromInt(-1), Smi::FromInt(-9),
597 Smi::FromInt(0), Smi::FromInt(666),
598 Smi::FromInt(77777), Smi::FromInt(Smi::kMaxValue)};
599 RunAccessTest<Smi*>(kMachineTagged, data, ARRAY_SIZE(data));
600 }
601
602
603 // Fills in most of the nodes of the graph in order to make tests shorter.
604 class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
605 public:
606 Typer typer;
607 JSGraph jsgraph;
608 Node* p0;
609 Node* p1;
610 Node* start;
611 Node* end;
612 Node* ret;
613
614 TestingGraph(Type* p0_type, Type* p1_type = Type::None())
615 : GraphAndBuilders(main_zone()),
616 typer(main_zone()),
617 jsgraph(graph(), common(), &typer) {
618 start = graph()->NewNode(common()->Start(2));
619 graph()->SetStart(start);
620 ret =
621 graph()->NewNode(common()->Return(), jsgraph.Constant(0), start, start);
622 end = graph()->NewNode(common()->End(), ret);
623 graph()->SetEnd(end);
624 p0 = graph()->NewNode(common()->Parameter(0), start);
625 p1 = graph()->NewNode(common()->Parameter(1), start);
626 NodeProperties::SetBounds(p0, Bounds(p0_type));
627 NodeProperties::SetBounds(p1, Bounds(p1_type));
628 }
629
630 void CheckLoweringBinop(IrOpcode::Value expected, Operator* op) {
631 Node* node = Return(graph()->NewNode(op, p0, p1));
632 Lower();
633 CHECK_EQ(expected, node->opcode());
634 }
635
636 void CheckLoweringTruncatedBinop(IrOpcode::Value expected, Operator* op,
637 Operator* trunc) {
638 Node* node = graph()->NewNode(op, p0, p1);
639 Return(graph()->NewNode(trunc, node));
640 Lower();
641 CHECK_EQ(expected, node->opcode());
642 }
643
644 void Lower() {
645 SimplifiedLowering lowering(&jsgraph, NULL);
646 lowering.LowerAllNodes();
647 }
648
649 // Inserts the node as the return value of the graph.
650 Node* Return(Node* node) {
651 ret->ReplaceInput(0, node);
652 return node;
653 }
654
655 Node* ExampleWithOutput(RepType type) {
656 // TODO(titzer): use parameters with guaranteed representations.
657 if (type & tInt32) {
658 return graph()->NewNode(machine()->Int32Add(), jsgraph.Int32Constant(1),
659 jsgraph.Int32Constant(1));
660 } else if (type & tUint32) {
661 return graph()->NewNode(machine()->Word32Sar(), jsgraph.Int32Constant(1),
662 jsgraph.Int32Constant(1));
663 } else if (type & rFloat64) {
664 return graph()->NewNode(machine()->Float64Add(),
665 jsgraph.Float64Constant(1),
666 jsgraph.Float64Constant(1));
667 } else if (type & rBit) {
668 return graph()->NewNode(machine()->Word32Equal(),
669 jsgraph.Int32Constant(1),
670 jsgraph.Int32Constant(1));
671 } else {
672 CHECK_EQ(rTagged, type);
673 return p0;
674 }
675 }
676
677 Node* Use(Node* node, RepType type) {
678 if (type & tInt32) {
679 return graph()->NewNode(machine()->Int32LessThan(), node,
680 jsgraph.Int32Constant(1));
681 } else if (type & tUint32) {
682 return graph()->NewNode(machine()->Uint32LessThan(), node,
683 jsgraph.Int32Constant(1));
684 } else if (type & rFloat64) {
685 return graph()->NewNode(machine()->Float64Add(), node,
686 jsgraph.Float64Constant(1));
687 } else {
688 return graph()->NewNode(simplified()->ReferenceEqual(Type::Any()), node,
689 jsgraph.TrueConstant());
690 }
691 }
692
693 Node* Branch(Node* cond) {
694 Node* br = graph()->NewNode(common()->Branch(), cond, start);
695 Node* tb = graph()->NewNode(common()->IfTrue(), br);
696 Node* fb = graph()->NewNode(common()->IfFalse(), br);
697 Node* m = graph()->NewNode(common()->Merge(2), tb, fb);
698 ret->ReplaceInput(NodeProperties::FirstControlIndex(ret), m);
699 return br;
700 }
701
702 SimplifiedOperatorBuilder* simplified() { return &main_simplified_; }
703 MachineOperatorBuilder* machine() { return &main_machine_; }
704 CommonOperatorBuilder* common() { return &main_common_; }
705 Graph* graph() { return main_graph_; }
706 };
707
708
709 #define TODO_TITZER
710
711 TEST(LowerBooleanNot_bit_bit) {
712 // BooleanNot(x: rBit) used as rBit
713 TestingGraph t(Type::Boolean());
714 Node* b = t.ExampleWithOutput(rBit);
715 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b);
716 Node* use = t.Branch(inv);
717 t.Lower();
718 Node* cmp = use->InputAt(0);
719 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode());
720 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1));
721 Node* f = t.jsgraph.Int32Constant(0);
722 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1));
723 }
724
725
726 TEST(LowerBooleanNot_bit_tagged) {
727 // BooleanNot(x: rBit) used as rTagged
728 TestingGraph t(Type::Boolean());
729 Node* b = t.ExampleWithOutput(rBit);
730 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b);
731 Node* use = t.Use(inv, rTagged);
732 t.Return(use);
733 t.Lower();
734 CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode());
735 Node* cmp = use->InputAt(0)->InputAt(0);
736 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode());
737 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1));
738 Node* f = t.jsgraph.Int32Constant(0);
739 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1));
740 }
741
742
743 TEST(LowerBooleanNot_tagged_bit) {
744 // BooleanNot(x: rTagged) used as rBit
745 TestingGraph t(Type::Boolean());
746 Node* b = t.p0;
747 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b);
748 Node* use = t.Branch(inv);
749 t.Lower();
750 Node* cmp = use->InputAt(0);
751 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode());
752 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1));
753 Node* f = t.jsgraph.FalseConstant();
754 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1));
755 }
756
757
758 TEST(LowerBooleanNot_tagged_tagged) {
759 // BooleanNot(x: rTagged) used as rTagged
760 TestingGraph t(Type::Boolean());
761 Node* b = t.p0;
762 Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b);
763 Node* use = t.Use(inv, rTagged);
764 t.Return(use);
765 t.Lower();
766 CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode());
767 Node* cmp = use->InputAt(0)->InputAt(0);
768 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode());
769 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1));
770 Node* f = t.jsgraph.FalseConstant();
771 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1));
772 }
773
774
775 static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(),
776 Type::Number(), Type::Any()};
777
778
779 TEST(LowerNumberCmp_to_int32) {
780 TestingGraph t(Type::Signed32(), Type::Signed32());
781
782 t.CheckLoweringBinop(IrOpcode::kWord32Equal, t.simplified()->NumberEqual());
783 t.CheckLoweringBinop(IrOpcode::kInt32LessThan,
784 t.simplified()->NumberLessThan());
785 t.CheckLoweringBinop(IrOpcode::kInt32LessThanOrEqual,
786 t.simplified()->NumberLessThanOrEqual());
787 }
788
789
790 TEST(LowerNumberCmp_to_uint32) {
791 TestingGraph t(Type::Unsigned32(), Type::Unsigned32());
792
793 t.CheckLoweringBinop(IrOpcode::kWord32Equal, t.simplified()->NumberEqual());
794 t.CheckLoweringBinop(IrOpcode::kUint32LessThan,
795 t.simplified()->NumberLessThan());
796 t.CheckLoweringBinop(IrOpcode::kUint32LessThanOrEqual,
797 t.simplified()->NumberLessThanOrEqual());
798 }
799
800
801 TEST(LowerNumberCmp_to_float64) {
802 static Type* types[] = {Type::Number(), Type::Any()};
803
804 for (size_t i = 0; i < ARRAY_SIZE(types); i++) {
805 TestingGraph t(types[i], types[i]);
806
807 t.CheckLoweringBinop(IrOpcode::kFloat64Equal,
808 t.simplified()->NumberEqual());
809 t.CheckLoweringBinop(IrOpcode::kFloat64LessThan,
810 t.simplified()->NumberLessThan());
811 t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual,
812 t.simplified()->NumberLessThanOrEqual());
813 }
814 }
815
816
817 TEST(LowerNumberAddSub_to_int32) {
818 TestingGraph t(Type::Signed32(), Type::Signed32());
819 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add,
820 t.simplified()->NumberAdd(),
821 t.simplified()->NumberToInt32());
822 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub,
823 t.simplified()->NumberSubtract(),
824 t.simplified()->NumberToInt32());
825 }
826
827
828 TEST(LowerNumberAddSub_to_uint32) {
829 TestingGraph t(Type::Unsigned32(), Type::Unsigned32());
830 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add,
831 t.simplified()->NumberAdd(),
832 t.simplified()->NumberToUint32());
833 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub,
834 t.simplified()->NumberSubtract(),
835 t.simplified()->NumberToUint32());
836 }
837
838
839 TEST(LowerNumberAddSub_to_float64) {
840 for (size_t i = 0; i < ARRAY_SIZE(test_types); i++) {
841 TestingGraph t(test_types[i], test_types[i]);
842
843 t.CheckLoweringBinop(IrOpcode::kFloat64Add, t.simplified()->NumberAdd());
844 t.CheckLoweringBinop(IrOpcode::kFloat64Sub,
845 t.simplified()->NumberSubtract());
846 }
847 }
848
849
850 TEST(LowerNumberDivMod_to_float64) {
851 for (size_t i = 0; i < ARRAY_SIZE(test_types); i++) {
852 TestingGraph t(test_types[i], test_types[i]);
853
854 t.CheckLoweringBinop(IrOpcode::kFloat64Div, t.simplified()->NumberDivide());
855 t.CheckLoweringBinop(IrOpcode::kFloat64Mod,
856 t.simplified()->NumberModulus());
857 }
858 }
859
860
861 TEST(LowerNumberToInt32_to_nop) {
862 // NumberToInt32(x: rTagged | tInt32) used as rTagged
863 TestingGraph t(Type::Signed32());
864 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0);
865 Node* use = t.Use(trunc, rTagged);
866 t.Return(use);
867 t.Lower();
868 CHECK_EQ(t.p0, use->InputAt(0));
869 }
870
871
872 TEST(LowerNumberToInt32_to_ChangeTaggedToFloat64) {
873 // NumberToInt32(x: rTagged | tInt32) used as rFloat64
874 TestingGraph t(Type::Signed32());
875 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0);
876 Node* use = t.Use(trunc, rFloat64);
877 t.Return(use);
878 t.Lower();
879 CHECK_EQ(IrOpcode::kChangeTaggedToFloat64, use->InputAt(0)->opcode());
880 CHECK_EQ(t.p0, use->InputAt(0)->InputAt(0));
881 }
882
883
884 TEST(LowerNumberToInt32_to_ChangeTaggedToInt32) {
885 // NumberToInt32(x: rTagged | tInt32) used as rWord32
886 TestingGraph t(Type::Signed32());
887 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0);
888 Node* use = t.Use(trunc, tInt32);
889 t.Return(use);
890 t.Lower();
891 CHECK_EQ(IrOpcode::kChangeTaggedToInt32, use->InputAt(0)->opcode());
892 CHECK_EQ(t.p0, use->InputAt(0)->InputAt(0));
893 }
894
895
896 TEST(LowerNumberToInt32_to_ChangeFloat64ToTagged) {
897 // NumberToInt32(x: rFloat64 | tInt32) used as rTagged
898 TODO_TITZER;
899 }
900
901
902 TEST(LowerNumberToInt32_to_ChangeFloat64ToInt32) {
903 // NumberToInt32(x: rFloat64 | tInt32) used as rWord32 | tInt32
904 TODO_TITZER;
905 }
906
907
908 TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32) {
909 // NumberToInt32(x: rFloat64) used as rWord32 | tUint32
910 TODO_TITZER;
911 }
912
913
914 TEST(LowerNumberToUint32_to_nop) {
915 // NumberToUint32(x: rTagged | tUint32) used as rTagged
916 TestingGraph t(Type::Unsigned32());
917 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0);
918 Node* use = t.Use(trunc, rTagged);
919 t.Return(use);
920 t.Lower();
921 CHECK_EQ(t.p0, use->InputAt(0));
922 }
923
924
925 TEST(LowerNumberToUint32_to_ChangeTaggedToFloat64) {
926 // NumberToUint32(x: rTagged | tUint32) used as rWord32
927 TestingGraph t(Type::Unsigned32());
928 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0);
929 Node* use = t.Use(trunc, rFloat64);
930 t.Return(use);
931 t.Lower();
932 CHECK_EQ(IrOpcode::kChangeTaggedToFloat64, use->InputAt(0)->opcode());
933 CHECK_EQ(t.p0, use->InputAt(0)->InputAt(0));
934 }
935
936
937 TEST(LowerNumberToUint32_to_ChangeTaggedToUint32) {
938 // NumberToUint32(x: rTagged | tUint32) used as rWord32
939 TestingGraph t(Type::Unsigned32());
940 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0);
941 Node* use = t.Use(trunc, tUint32);
942 t.Return(use);
943 t.Lower();
944 CHECK_EQ(IrOpcode::kChangeTaggedToUint32, use->InputAt(0)->opcode());
945 CHECK_EQ(t.p0, use->InputAt(0)->InputAt(0));
946 }
947
948
949 TEST(LowerNumberToUint32_to_ChangeFloat64ToTagged) {
950 // NumberToUint32(x: rFloat64 | tUint32) used as rTagged
951 TODO_TITZER;
952 }
953
954
955 TEST(LowerNumberToUint32_to_ChangeFloat64ToUint32) {
956 // NumberToUint32(x: rFloat64 | tUint32) used as rWord32
957 TODO_TITZER;
958 }
959
960
961 TEST(LowerNumberToUint32_to_TruncateFloat64ToUint32) {
962 // NumberToUint32(x: rFloat64) used as rWord32
963 TODO_TITZER;
964 }
965
966
967 TEST(LowerReferenceEqual_to_wordeq) {
968 TestingGraph t(Type::Any(), Type::Any());
969 IrOpcode::Value opcode =
970 static_cast<IrOpcode::Value>(t.machine()->WordEqual()->opcode());
971 t.CheckLoweringBinop(opcode, t.simplified()->ReferenceEqual(Type::Any()));
972 }
973
974
975 TEST(LowerStringOps_to_rtcalls) {
976 if (false) { // TODO(titzer): lower StringOps to runtime calls
977 TestingGraph t(Type::String(), Type::String());
978 t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringEqual());
979 t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringLessThan());
980 t.CheckLoweringBinop(IrOpcode::kCall,
981 t.simplified()->StringLessThanOrEqual());
982 t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringAdd());
983 }
984 }
985
986
987 TEST(LowerLoadField_to_load) { TODO_TITZER; }
988
989
990 TEST(LowerStoreField_to_store) { TODO_TITZER; }
991
992
993 TEST(LowerStoreField_to_store_wb) { TODO_TITZER; }
994
995
996 TEST(LowerLoadElement_to_load) { TODO_TITZER; }
997
998
999 TEST(LowerStoreElement_to_store) { TODO_TITZER; }
1000
1001
1002 TEST(LowerStoreElement_to_store_wb) { TODO_TITZER; }
1003
1004
1005 void CheckChangeInsertion(IrOpcode::Value expected, RepType from, RepType to) {
1006 TestingGraph t(Type::Any());
1007 Node* in = t.ExampleWithOutput(from);
1008 Node* use = t.Use(in, to);
1009 t.Return(use);
1010 t.Lower();
1011 CHECK_EQ(expected, use->InputAt(0)->opcode());
1012 CHECK_EQ(in, use->InputAt(0)->InputAt(0));
1013 }
1014
1015
1016 TEST(InsertBasicChanges) {
1017 CheckChangeInsertion(IrOpcode::kChangeFloat64ToInt32, rFloat64, tInt32);
1018 CheckChangeInsertion(IrOpcode::kChangeFloat64ToUint32, rFloat64, tUint32);
1019 CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, rFloat64, rTagged);
1020
1021 CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, rTagged, tInt32);
1022 CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, rTagged, tUint32);
1023 CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, rTagged, rFloat64);
1024
1025 CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, tInt32, rFloat64);
1026 CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, tInt32, rTagged);
1027
1028 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, tUint32, rFloat64);
1029 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, tUint32, rTagged);
1030 }
1031
1032
1033 static void CheckChangesAroundBinop(TestingGraph* t, Operator* op,
1034 IrOpcode::Value input_change,
1035 IrOpcode::Value output_change) {
1036 Node* binop = t->graph()->NewNode(op, t->p0, t->p1);
1037 t->Return(binop);
1038 t->Lower();
1039 CHECK_EQ(input_change, binop->InputAt(0)->opcode());
1040 CHECK_EQ(input_change, binop->InputAt(1)->opcode());
1041 CHECK_EQ(t->p0, binop->InputAt(0)->InputAt(0));
1042 CHECK_EQ(t->p1, binop->InputAt(1)->InputAt(0));
1043 CHECK_EQ(output_change, t->ret->InputAt(0)->opcode());
1044 CHECK_EQ(binop, t->ret->InputAt(0)->InputAt(0));
1045 }
1046
1047
1048 TEST(InsertChangesAroundInt32Binops) {
1049 TestingGraph t(Type::Signed32(), Type::Signed32());
1050
1051 Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(),
1052 t.machine()->Int32Mul(), t.machine()->Int32Div(),
1053 t.machine()->Int32Mod(), t.machine()->Word32And(),
1054 t.machine()->Word32Or(), t.machine()->Word32Xor(),
1055 t.machine()->Word32Shl(), t.machine()->Word32Sar()};
1056
1057 for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
1058 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
1059 IrOpcode::kChangeInt32ToTagged);
1060 }
1061 }
1062
1063
1064 TEST(InsertChangesAroundInt32Cmp) {
1065 TestingGraph t(Type::Signed32(), Type::Signed32());
1066
1067 Operator* ops[] = {t.machine()->Int32LessThan(),
1068 t.machine()->Int32LessThanOrEqual()};
1069
1070 for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
1071 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
1072 IrOpcode::kChangeBitToBool);
1073 }
1074 }
1075
1076
1077 TEST(InsertChangesAroundUint32Cmp) {
1078 TestingGraph t(Type::Unsigned32(), Type::Unsigned32());
1079
1080 Operator* ops[] = {t.machine()->Uint32LessThan(),
1081 t.machine()->Uint32LessThanOrEqual()};
1082
1083 for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
1084 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32,
1085 IrOpcode::kChangeBitToBool);
1086 }
1087 }
1088
1089
1090 TEST(InsertChangesAroundFloat64Binops) {
1091 TestingGraph t(Type::Number(), Type::Number());
1092
1093 Operator* ops[] = {
1094 t.machine()->Float64Add(), t.machine()->Float64Sub(),
1095 t.machine()->Float64Mul(), t.machine()->Float64Div(),
1096 t.machine()->Float64Mod(),
1097 };
1098
1099 for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
1100 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64,
1101 IrOpcode::kChangeFloat64ToTagged);
1102 }
1103 }
1104
1105
1106 TEST(InsertChangesAroundFloat64Cmp) {
1107 TestingGraph t(Type::Number(), Type::Number());
1108
1109 Operator* ops[] = {t.machine()->Float64Equal(),
1110 t.machine()->Float64LessThan(),
1111 t.machine()->Float64LessThanOrEqual()};
1112
1113 for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
1114 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64,
1115 IrOpcode::kChangeBitToBool);
1116 }
1117 }
1118
1119
1120 TEST(InsertChangesForElementAccessIndex) { TODO_TITZER; }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698