OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/compiler/control-builders.h" | 7 #include "src/compiler/control-builders.h" |
8 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
9 #include "src/compiler/graph-visualizer.h" | 9 #include "src/compiler/graph-visualizer.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 if (i == (index + 1)) expected = index; | 240 if (i == (index + 1)) expected = index; |
241 CHECK_EQ(data[i], expected); | 241 CHECK_EQ(data[i], expected); |
242 } | 242 } |
243 } | 243 } |
244 } | 244 } |
245 | 245 |
246 | 246 |
247 TEST(RunLoadFieldFromUntaggedBase) { | 247 TEST(RunLoadFieldFromUntaggedBase) { |
248 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; | 248 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; |
249 | 249 |
250 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { | 250 for (size_t i = 0; i < arraysize(smis); i++) { |
251 int offset = static_cast<int>(i * sizeof(Smi*)); | 251 int offset = static_cast<int>(i * sizeof(Smi*)); |
252 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), | 252 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), |
253 Type::Integral32(), kMachAnyTagged}; | 253 Type::Integral32(), kMachAnyTagged}; |
254 | 254 |
255 SimplifiedLoweringTester<Object*> t; | 255 SimplifiedLoweringTester<Object*> t; |
256 Node* load = t.LoadField(access, t.PointerConstant(smis)); | 256 Node* load = t.LoadField(access, t.PointerConstant(smis)); |
257 t.Return(load); | 257 t.Return(load); |
258 t.LowerAllNodes(); | 258 t.LowerAllNodes(); |
259 | 259 |
260 if (!Pipeline::SupportedTarget()) continue; | 260 if (!Pipeline::SupportedTarget()) continue; |
261 | 261 |
262 for (int j = -5; j <= 5; j++) { | 262 for (int j = -5; j <= 5; j++) { |
263 Smi* expected = Smi::FromInt(j); | 263 Smi* expected = Smi::FromInt(j); |
264 smis[i] = expected; | 264 smis[i] = expected; |
265 CHECK_EQ(expected, t.Call()); | 265 CHECK_EQ(expected, t.Call()); |
266 } | 266 } |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 | 270 |
271 TEST(RunStoreFieldToUntaggedBase) { | 271 TEST(RunStoreFieldToUntaggedBase) { |
272 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; | 272 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; |
273 | 273 |
274 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { | 274 for (size_t i = 0; i < arraysize(smis); i++) { |
275 int offset = static_cast<int>(i * sizeof(Smi*)); | 275 int offset = static_cast<int>(i * sizeof(Smi*)); |
276 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), | 276 FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), |
277 Type::Integral32(), kMachAnyTagged}; | 277 Type::Integral32(), kMachAnyTagged}; |
278 | 278 |
279 SimplifiedLoweringTester<Object*> t(kMachAnyTagged); | 279 SimplifiedLoweringTester<Object*> t(kMachAnyTagged); |
280 Node* p0 = t.Parameter(0); | 280 Node* p0 = t.Parameter(0); |
281 t.StoreField(access, t.PointerConstant(smis), p0); | 281 t.StoreField(access, t.PointerConstant(smis), p0); |
282 t.Return(p0); | 282 t.Return(p0); |
283 t.LowerAllNodes(); | 283 t.LowerAllNodes(); |
284 | 284 |
285 if (!Pipeline::SupportedTarget()) continue; | 285 if (!Pipeline::SupportedTarget()) continue; |
286 | 286 |
287 for (int j = -5; j <= 5; j++) { | 287 for (int j = -5; j <= 5; j++) { |
288 Smi* expected = Smi::FromInt(j); | 288 Smi* expected = Smi::FromInt(j); |
289 smis[i] = Smi::FromInt(-100); | 289 smis[i] = Smi::FromInt(-100); |
290 CHECK_EQ(expected, t.Call(expected)); | 290 CHECK_EQ(expected, t.Call(expected)); |
291 CHECK_EQ(expected, smis[i]); | 291 CHECK_EQ(expected, smis[i]); |
292 } | 292 } |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 | 296 |
297 TEST(RunLoadElementFromUntaggedBase) { | 297 TEST(RunLoadElementFromUntaggedBase) { |
298 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), | 298 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), |
299 Smi::FromInt(4), Smi::FromInt(5)}; | 299 Smi::FromInt(4), Smi::FromInt(5)}; |
300 | 300 |
301 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes | 301 for (size_t i = 0; i < arraysize(smis); i++) { // for header sizes |
302 for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index | 302 for (size_t j = 0; (i + j) < arraysize(smis); j++) { // for element index |
303 int offset = static_cast<int>(i * sizeof(Smi*)); | 303 int offset = static_cast<int>(i * sizeof(Smi*)); |
304 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), | 304 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), |
305 kMachAnyTagged}; | 305 kMachAnyTagged}; |
306 | 306 |
307 SimplifiedLoweringTester<Object*> t; | 307 SimplifiedLoweringTester<Object*> t; |
308 Node* load = t.LoadElement(access, t.PointerConstant(smis), | 308 Node* load = t.LoadElement(access, t.PointerConstant(smis), |
309 t.Int32Constant(static_cast<int>(j))); | 309 t.Int32Constant(static_cast<int>(j))); |
310 t.Return(load); | 310 t.Return(load); |
311 t.LowerAllNodes(); | 311 t.LowerAllNodes(); |
312 | 312 |
313 if (!Pipeline::SupportedTarget()) continue; | 313 if (!Pipeline::SupportedTarget()) continue; |
314 | 314 |
315 for (int k = -5; k <= 5; k++) { | 315 for (int k = -5; k <= 5; k++) { |
316 Smi* expected = Smi::FromInt(k); | 316 Smi* expected = Smi::FromInt(k); |
317 smis[i + j] = expected; | 317 smis[i + j] = expected; |
318 CHECK_EQ(expected, t.Call()); | 318 CHECK_EQ(expected, t.Call()); |
319 } | 319 } |
320 } | 320 } |
321 } | 321 } |
322 } | 322 } |
323 | 323 |
324 | 324 |
325 TEST(RunStoreElementFromUntaggedBase) { | 325 TEST(RunStoreElementFromUntaggedBase) { |
326 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), | 326 Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), |
327 Smi::FromInt(4), Smi::FromInt(5)}; | 327 Smi::FromInt(4), Smi::FromInt(5)}; |
328 | 328 |
329 for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes | 329 for (size_t i = 0; i < arraysize(smis); i++) { // for header sizes |
330 for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index | 330 for (size_t j = 0; (i + j) < arraysize(smis); j++) { // for element index |
331 int offset = static_cast<int>(i * sizeof(Smi*)); | 331 int offset = static_cast<int>(i * sizeof(Smi*)); |
332 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), | 332 ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), |
333 kMachAnyTagged}; | 333 kMachAnyTagged}; |
334 | 334 |
335 SimplifiedLoweringTester<Object*> t(kMachAnyTagged); | 335 SimplifiedLoweringTester<Object*> t(kMachAnyTagged); |
336 Node* p0 = t.Parameter(0); | 336 Node* p0 = t.Parameter(0); |
337 t.StoreElement(access, t.PointerConstant(smis), | 337 t.StoreElement(access, t.PointerConstant(smis), |
338 t.Int32Constant(static_cast<int>(j)), p0); | 338 t.Int32Constant(static_cast<int>(j)), p0); |
339 t.Return(p0); | 339 t.Return(p0); |
340 t.LowerAllNodes(); | 340 t.LowerAllNodes(); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 } | 550 } |
551 } | 551 } |
552 } | 552 } |
553 } | 553 } |
554 } | 554 } |
555 | 555 |
556 | 556 |
557 TEST(RunAccessTests_uint8) { | 557 TEST(RunAccessTests_uint8) { |
558 uint8_t data[] = {0x07, 0x16, 0x25, 0x34, 0x43, 0x99, | 558 uint8_t data[] = {0x07, 0x16, 0x25, 0x34, 0x43, 0x99, |
559 0xab, 0x78, 0x89, 0x19, 0x2b, 0x38}; | 559 0xab, 0x78, 0x89, 0x19, 0x2b, 0x38}; |
560 RunAccessTest<uint8_t>(kMachInt8, data, ARRAY_SIZE(data)); | 560 RunAccessTest<uint8_t>(kMachInt8, data, arraysize(data)); |
561 } | 561 } |
562 | 562 |
563 | 563 |
564 TEST(RunAccessTests_uint16) { | 564 TEST(RunAccessTests_uint16) { |
565 uint16_t data[] = {0x071a, 0x162b, 0x253c, 0x344d, 0x435e, 0x7777}; | 565 uint16_t data[] = {0x071a, 0x162b, 0x253c, 0x344d, 0x435e, 0x7777}; |
566 RunAccessTest<uint16_t>(kMachInt16, data, ARRAY_SIZE(data)); | 566 RunAccessTest<uint16_t>(kMachInt16, data, arraysize(data)); |
567 } | 567 } |
568 | 568 |
569 | 569 |
570 TEST(RunAccessTests_int32) { | 570 TEST(RunAccessTests_int32) { |
571 int32_t data[] = {-211, 211, 628347, 2000000000, -2000000000, -1, -100000034}; | 571 int32_t data[] = {-211, 211, 628347, 2000000000, -2000000000, -1, -100000034}; |
572 RunAccessTest<int32_t>(kMachInt32, data, ARRAY_SIZE(data)); | 572 RunAccessTest<int32_t>(kMachInt32, data, arraysize(data)); |
573 } | 573 } |
574 | 574 |
575 | 575 |
576 #define V8_2PART_INT64(a, b) (((static_cast<int64_t>(a) << 32) + 0x##b##u)) | 576 #define V8_2PART_INT64(a, b) (((static_cast<int64_t>(a) << 32) + 0x##b##u)) |
577 | 577 |
578 | 578 |
579 TEST(RunAccessTests_int64) { | 579 TEST(RunAccessTests_int64) { |
580 if (kPointerSize != 8) return; | 580 if (kPointerSize != 8) return; |
581 int64_t data[] = {V8_2PART_INT64(0x10111213, 14151617), | 581 int64_t data[] = {V8_2PART_INT64(0x10111213, 14151617), |
582 V8_2PART_INT64(0x20212223, 24252627), | 582 V8_2PART_INT64(0x20212223, 24252627), |
583 V8_2PART_INT64(0x30313233, 34353637), | 583 V8_2PART_INT64(0x30313233, 34353637), |
584 V8_2PART_INT64(0xa0a1a2a3, a4a5a6a7), | 584 V8_2PART_INT64(0xa0a1a2a3, a4a5a6a7), |
585 V8_2PART_INT64(0xf0f1f2f3, f4f5f6f7)}; | 585 V8_2PART_INT64(0xf0f1f2f3, f4f5f6f7)}; |
586 RunAccessTest<int64_t>(kMachInt64, data, ARRAY_SIZE(data)); | 586 RunAccessTest<int64_t>(kMachInt64, data, arraysize(data)); |
587 } | 587 } |
588 | 588 |
589 | 589 |
590 TEST(RunAccessTests_float64) { | 590 TEST(RunAccessTests_float64) { |
591 double data[] = {1.25, -1.25, 2.75, 11.0, 11100.8}; | 591 double data[] = {1.25, -1.25, 2.75, 11.0, 11100.8}; |
592 RunAccessTest<double>(kMachFloat64, data, ARRAY_SIZE(data)); | 592 RunAccessTest<double>(kMachFloat64, data, arraysize(data)); |
593 } | 593 } |
594 | 594 |
595 | 595 |
596 TEST(RunAccessTests_Smi) { | 596 TEST(RunAccessTests_Smi) { |
597 Smi* data[] = {Smi::FromInt(-1), Smi::FromInt(-9), | 597 Smi* data[] = {Smi::FromInt(-1), Smi::FromInt(-9), |
598 Smi::FromInt(0), Smi::FromInt(666), | 598 Smi::FromInt(0), Smi::FromInt(666), |
599 Smi::FromInt(77777), Smi::FromInt(Smi::kMaxValue)}; | 599 Smi::FromInt(77777), Smi::FromInt(Smi::kMaxValue)}; |
600 RunAccessTest<Smi*>(kMachAnyTagged, data, ARRAY_SIZE(data)); | 600 RunAccessTest<Smi*>(kMachAnyTagged, data, arraysize(data)); |
601 } | 601 } |
602 | 602 |
603 | 603 |
604 // Fills in most of the nodes of the graph in order to make tests shorter. | 604 // Fills in most of the nodes of the graph in order to make tests shorter. |
605 class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { | 605 class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { |
606 public: | 606 public: |
607 Typer typer; | 607 Typer typer; |
608 JSGraph jsgraph; | 608 JSGraph jsgraph; |
609 Node* p0; | 609 Node* p0; |
610 Node* p1; | 610 Node* p1; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 t.CheckLoweringBinop(IrOpcode::kUint32LessThan, | 806 t.CheckLoweringBinop(IrOpcode::kUint32LessThan, |
807 t.simplified()->NumberLessThan()); | 807 t.simplified()->NumberLessThan()); |
808 t.CheckLoweringBinop(IrOpcode::kUint32LessThanOrEqual, | 808 t.CheckLoweringBinop(IrOpcode::kUint32LessThanOrEqual, |
809 t.simplified()->NumberLessThanOrEqual()); | 809 t.simplified()->NumberLessThanOrEqual()); |
810 } | 810 } |
811 | 811 |
812 | 812 |
813 TEST(LowerNumberCmp_to_float64) { | 813 TEST(LowerNumberCmp_to_float64) { |
814 static Type* types[] = {Type::Number(), Type::Any()}; | 814 static Type* types[] = {Type::Number(), Type::Any()}; |
815 | 815 |
816 for (size_t i = 0; i < ARRAY_SIZE(types); i++) { | 816 for (size_t i = 0; i < arraysize(types); i++) { |
817 TestingGraph t(types[i], types[i]); | 817 TestingGraph t(types[i], types[i]); |
818 | 818 |
819 t.CheckLoweringBinop(IrOpcode::kFloat64Equal, | 819 t.CheckLoweringBinop(IrOpcode::kFloat64Equal, |
820 t.simplified()->NumberEqual()); | 820 t.simplified()->NumberEqual()); |
821 t.CheckLoweringBinop(IrOpcode::kFloat64LessThan, | 821 t.CheckLoweringBinop(IrOpcode::kFloat64LessThan, |
822 t.simplified()->NumberLessThan()); | 822 t.simplified()->NumberLessThan()); |
823 t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual, | 823 t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual, |
824 t.simplified()->NumberLessThanOrEqual()); | 824 t.simplified()->NumberLessThanOrEqual()); |
825 } | 825 } |
826 } | 826 } |
(...skipping 15 matching lines...) Expand all Loading... |
842 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add, | 842 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add, |
843 t.simplified()->NumberAdd(), | 843 t.simplified()->NumberAdd(), |
844 t.simplified()->NumberToUint32()); | 844 t.simplified()->NumberToUint32()); |
845 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub, | 845 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub, |
846 t.simplified()->NumberSubtract(), | 846 t.simplified()->NumberSubtract(), |
847 t.simplified()->NumberToUint32()); | 847 t.simplified()->NumberToUint32()); |
848 } | 848 } |
849 | 849 |
850 | 850 |
851 TEST(LowerNumberAddSub_to_float64) { | 851 TEST(LowerNumberAddSub_to_float64) { |
852 for (size_t i = 0; i < ARRAY_SIZE(test_types); i++) { | 852 for (size_t i = 0; i < arraysize(test_types); i++) { |
853 TestingGraph t(test_types[i], test_types[i]); | 853 TestingGraph t(test_types[i], test_types[i]); |
854 | 854 |
855 t.CheckLoweringBinop(IrOpcode::kFloat64Add, t.simplified()->NumberAdd()); | 855 t.CheckLoweringBinop(IrOpcode::kFloat64Add, t.simplified()->NumberAdd()); |
856 t.CheckLoweringBinop(IrOpcode::kFloat64Sub, | 856 t.CheckLoweringBinop(IrOpcode::kFloat64Sub, |
857 t.simplified()->NumberSubtract()); | 857 t.simplified()->NumberSubtract()); |
858 } | 858 } |
859 } | 859 } |
860 | 860 |
861 | 861 |
862 TEST(LowerNumberDivMod_to_float64) { | 862 TEST(LowerNumberDivMod_to_float64) { |
863 for (size_t i = 0; i < ARRAY_SIZE(test_types); i++) { | 863 for (size_t i = 0; i < arraysize(test_types); i++) { |
864 TestingGraph t(test_types[i], test_types[i]); | 864 TestingGraph t(test_types[i], test_types[i]); |
865 | 865 |
866 t.CheckLoweringBinop(IrOpcode::kFloat64Div, t.simplified()->NumberDivide()); | 866 t.CheckLoweringBinop(IrOpcode::kFloat64Div, t.simplified()->NumberDivide()); |
867 t.CheckLoweringBinop(IrOpcode::kFloat64Mod, | 867 t.CheckLoweringBinop(IrOpcode::kFloat64Mod, |
868 t.simplified()->NumberModulus()); | 868 t.simplified()->NumberModulus()); |
869 } | 869 } |
870 } | 870 } |
871 | 871 |
872 | 872 |
873 static void CheckChangeOf(IrOpcode::Value change, Node* of, Node* node) { | 873 static void CheckChangeOf(IrOpcode::Value change, Node* of, Node* node) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 | 1050 |
1051 TEST(InsertChangesAroundInt32Binops) { | 1051 TEST(InsertChangesAroundInt32Binops) { |
1052 TestingGraph t(Type::Signed32(), Type::Signed32()); | 1052 TestingGraph t(Type::Signed32(), Type::Signed32()); |
1053 | 1053 |
1054 Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(), | 1054 Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(), |
1055 t.machine()->Int32Mul(), t.machine()->Int32Div(), | 1055 t.machine()->Int32Mul(), t.machine()->Int32Div(), |
1056 t.machine()->Int32Mod(), t.machine()->Word32And(), | 1056 t.machine()->Int32Mod(), t.machine()->Word32And(), |
1057 t.machine()->Word32Or(), t.machine()->Word32Xor(), | 1057 t.machine()->Word32Or(), t.machine()->Word32Xor(), |
1058 t.machine()->Word32Shl(), t.machine()->Word32Sar()}; | 1058 t.machine()->Word32Shl(), t.machine()->Word32Sar()}; |
1059 | 1059 |
1060 for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { | 1060 for (size_t i = 0; i < arraysize(ops); i++) { |
1061 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, | 1061 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, |
1062 IrOpcode::kChangeInt32ToTagged); | 1062 IrOpcode::kChangeInt32ToTagged); |
1063 } | 1063 } |
1064 } | 1064 } |
1065 | 1065 |
1066 | 1066 |
1067 TEST(InsertChangesAroundInt32Cmp) { | 1067 TEST(InsertChangesAroundInt32Cmp) { |
1068 TestingGraph t(Type::Signed32(), Type::Signed32()); | 1068 TestingGraph t(Type::Signed32(), Type::Signed32()); |
1069 | 1069 |
1070 Operator* ops[] = {t.machine()->Int32LessThan(), | 1070 Operator* ops[] = {t.machine()->Int32LessThan(), |
1071 t.machine()->Int32LessThanOrEqual()}; | 1071 t.machine()->Int32LessThanOrEqual()}; |
1072 | 1072 |
1073 for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { | 1073 for (size_t i = 0; i < arraysize(ops); i++) { |
1074 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, | 1074 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, |
1075 IrOpcode::kChangeBitToBool); | 1075 IrOpcode::kChangeBitToBool); |
1076 } | 1076 } |
1077 } | 1077 } |
1078 | 1078 |
1079 | 1079 |
1080 TEST(InsertChangesAroundUint32Cmp) { | 1080 TEST(InsertChangesAroundUint32Cmp) { |
1081 TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); | 1081 TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); |
1082 | 1082 |
1083 Operator* ops[] = {t.machine()->Uint32LessThan(), | 1083 Operator* ops[] = {t.machine()->Uint32LessThan(), |
1084 t.machine()->Uint32LessThanOrEqual()}; | 1084 t.machine()->Uint32LessThanOrEqual()}; |
1085 | 1085 |
1086 for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { | 1086 for (size_t i = 0; i < arraysize(ops); i++) { |
1087 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32, | 1087 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32, |
1088 IrOpcode::kChangeBitToBool); | 1088 IrOpcode::kChangeBitToBool); |
1089 } | 1089 } |
1090 } | 1090 } |
1091 | 1091 |
1092 | 1092 |
1093 TEST(InsertChangesAroundFloat64Binops) { | 1093 TEST(InsertChangesAroundFloat64Binops) { |
1094 TestingGraph t(Type::Number(), Type::Number()); | 1094 TestingGraph t(Type::Number(), Type::Number()); |
1095 | 1095 |
1096 Operator* ops[] = { | 1096 Operator* ops[] = { |
1097 t.machine()->Float64Add(), t.machine()->Float64Sub(), | 1097 t.machine()->Float64Add(), t.machine()->Float64Sub(), |
1098 t.machine()->Float64Mul(), t.machine()->Float64Div(), | 1098 t.machine()->Float64Mul(), t.machine()->Float64Div(), |
1099 t.machine()->Float64Mod(), | 1099 t.machine()->Float64Mod(), |
1100 }; | 1100 }; |
1101 | 1101 |
1102 for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { | 1102 for (size_t i = 0; i < arraysize(ops); i++) { |
1103 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, | 1103 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, |
1104 IrOpcode::kChangeFloat64ToTagged); | 1104 IrOpcode::kChangeFloat64ToTagged); |
1105 } | 1105 } |
1106 } | 1106 } |
1107 | 1107 |
1108 | 1108 |
1109 TEST(InsertChangesAroundFloat64Cmp) { | 1109 TEST(InsertChangesAroundFloat64Cmp) { |
1110 TestingGraph t(Type::Number(), Type::Number()); | 1110 TestingGraph t(Type::Number(), Type::Number()); |
1111 | 1111 |
1112 Operator* ops[] = {t.machine()->Float64Equal(), | 1112 Operator* ops[] = {t.machine()->Float64Equal(), |
1113 t.machine()->Float64LessThan(), | 1113 t.machine()->Float64LessThan(), |
1114 t.machine()->Float64LessThanOrEqual()}; | 1114 t.machine()->Float64LessThanOrEqual()}; |
1115 | 1115 |
1116 for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { | 1116 for (size_t i = 0; i < arraysize(ops); i++) { |
1117 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, | 1117 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, |
1118 IrOpcode::kChangeBitToBool); | 1118 IrOpcode::kChangeBitToBool); |
1119 } | 1119 } |
1120 } | 1120 } |
1121 | 1121 |
1122 | 1122 |
1123 void CheckFieldAccessArithmetic(FieldAccess access, Node* load_or_store) { | 1123 void CheckFieldAccessArithmetic(FieldAccess access, Node* load_or_store) { |
1124 Int32Matcher index = Int32Matcher(load_or_store->InputAt(1)); | 1124 Int32Matcher index = Int32Matcher(load_or_store->InputAt(1)); |
1125 CHECK(index.Is(access.offset - access.tag())); | 1125 CHECK(index.Is(access.offset - access.tag())); |
1126 } | 1126 } |
(...skipping 18 matching lines...) Expand all Loading... |
1145 | 1145 |
1146 | 1146 |
1147 static const MachineType machine_reps[] = { | 1147 static const MachineType machine_reps[] = { |
1148 kRepBit, kMachInt8, kMachInt16, kMachInt32, | 1148 kRepBit, kMachInt8, kMachInt16, kMachInt32, |
1149 kMachInt64, kMachFloat64, kMachAnyTagged}; | 1149 kMachInt64, kMachFloat64, kMachAnyTagged}; |
1150 | 1150 |
1151 | 1151 |
1152 TEST(LowerLoadField_to_load) { | 1152 TEST(LowerLoadField_to_load) { |
1153 TestingGraph t(Type::Any(), Type::Signed32()); | 1153 TestingGraph t(Type::Any(), Type::Signed32()); |
1154 | 1154 |
1155 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { | 1155 for (size_t i = 0; i < arraysize(machine_reps); i++) { |
1156 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 1156 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
1157 Handle<Name>::null(), Type::Any(), machine_reps[i]}; | 1157 Handle<Name>::null(), Type::Any(), machine_reps[i]}; |
1158 | 1158 |
1159 Node* load = | 1159 Node* load = |
1160 t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); | 1160 t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); |
1161 Node* use = t.Use(load, machine_reps[i]); | 1161 Node* use = t.Use(load, machine_reps[i]); |
1162 t.Return(use); | 1162 t.Return(use); |
1163 t.Lower(); | 1163 t.Lower(); |
1164 CHECK_EQ(IrOpcode::kLoad, load->opcode()); | 1164 CHECK_EQ(IrOpcode::kLoad, load->opcode()); |
1165 CHECK_EQ(t.p0, load->InputAt(0)); | 1165 CHECK_EQ(t.p0, load->InputAt(0)); |
1166 CheckFieldAccessArithmetic(access, load); | 1166 CheckFieldAccessArithmetic(access, load); |
1167 | 1167 |
1168 MachineType rep = OpParameter<MachineType>(load); | 1168 MachineType rep = OpParameter<MachineType>(load); |
1169 CHECK_EQ(machine_reps[i], rep); | 1169 CHECK_EQ(machine_reps[i], rep); |
1170 } | 1170 } |
1171 } | 1171 } |
1172 | 1172 |
1173 | 1173 |
1174 TEST(LowerStoreField_to_store) { | 1174 TEST(LowerStoreField_to_store) { |
1175 TestingGraph t(Type::Any(), Type::Signed32()); | 1175 TestingGraph t(Type::Any(), Type::Signed32()); |
1176 | 1176 |
1177 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { | 1177 for (size_t i = 0; i < arraysize(machine_reps); i++) { |
1178 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 1178 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
1179 Handle<Name>::null(), Type::Any(), machine_reps[i]}; | 1179 Handle<Name>::null(), Type::Any(), machine_reps[i]}; |
1180 | 1180 |
1181 | 1181 |
1182 Node* val = t.ExampleWithOutput(machine_reps[i]); | 1182 Node* val = t.ExampleWithOutput(machine_reps[i]); |
1183 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, | 1183 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, |
1184 val, t.start, t.start); | 1184 val, t.start, t.start); |
1185 t.Effect(store); | 1185 t.Effect(store); |
1186 t.Lower(); | 1186 t.Lower(); |
1187 CHECK_EQ(IrOpcode::kStore, store->opcode()); | 1187 CHECK_EQ(IrOpcode::kStore, store->opcode()); |
1188 CHECK_EQ(val, store->InputAt(2)); | 1188 CHECK_EQ(val, store->InputAt(2)); |
1189 CheckFieldAccessArithmetic(access, store); | 1189 CheckFieldAccessArithmetic(access, store); |
1190 | 1190 |
1191 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); | 1191 StoreRepresentation rep = OpParameter<StoreRepresentation>(store); |
1192 if (machine_reps[i] & kRepTagged) { | 1192 if (machine_reps[i] & kRepTagged) { |
1193 CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind); | 1193 CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind); |
1194 } | 1194 } |
1195 CHECK_EQ(machine_reps[i], rep.machine_type); | 1195 CHECK_EQ(machine_reps[i], rep.machine_type); |
1196 } | 1196 } |
1197 } | 1197 } |
1198 | 1198 |
1199 | 1199 |
1200 TEST(LowerLoadElement_to_load) { | 1200 TEST(LowerLoadElement_to_load) { |
1201 TestingGraph t(Type::Any(), Type::Signed32()); | 1201 TestingGraph t(Type::Any(), Type::Signed32()); |
1202 | 1202 |
1203 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { | 1203 for (size_t i = 0; i < arraysize(machine_reps); i++) { |
1204 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 1204 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
1205 Type::Any(), machine_reps[i]}; | 1205 Type::Any(), machine_reps[i]}; |
1206 | 1206 |
1207 Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, | 1207 Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, |
1208 t.p1, t.start); | 1208 t.p1, t.start); |
1209 Node* use = t.Use(load, machine_reps[i]); | 1209 Node* use = t.Use(load, machine_reps[i]); |
1210 t.Return(use); | 1210 t.Return(use); |
1211 t.Lower(); | 1211 t.Lower(); |
1212 CHECK_EQ(IrOpcode::kLoad, load->opcode()); | 1212 CHECK_EQ(IrOpcode::kLoad, load->opcode()); |
1213 CHECK_EQ(t.p0, load->InputAt(0)); | 1213 CHECK_EQ(t.p0, load->InputAt(0)); |
1214 CheckElementAccessArithmetic(access, load); | 1214 CheckElementAccessArithmetic(access, load); |
1215 | 1215 |
1216 MachineType rep = OpParameter<MachineType>(load); | 1216 MachineType rep = OpParameter<MachineType>(load); |
1217 CHECK_EQ(machine_reps[i], rep); | 1217 CHECK_EQ(machine_reps[i], rep); |
1218 } | 1218 } |
1219 } | 1219 } |
1220 | 1220 |
1221 | 1221 |
1222 TEST(LowerStoreElement_to_store) { | 1222 TEST(LowerStoreElement_to_store) { |
1223 TestingGraph t(Type::Any(), Type::Signed32()); | 1223 TestingGraph t(Type::Any(), Type::Signed32()); |
1224 | 1224 |
1225 for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { | 1225 for (size_t i = 0; i < arraysize(machine_reps); i++) { |
1226 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 1226 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
1227 Type::Any(), machine_reps[i]}; | 1227 Type::Any(), machine_reps[i]}; |
1228 | 1228 |
1229 Node* val = t.ExampleWithOutput(machine_reps[i]); | 1229 Node* val = t.ExampleWithOutput(machine_reps[i]); |
1230 Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, | 1230 Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, |
1231 t.p1, val, t.start, t.start); | 1231 t.p1, val, t.start, t.start); |
1232 t.Effect(store); | 1232 t.Effect(store); |
1233 t.Lower(); | 1233 t.Lower(); |
1234 CHECK_EQ(IrOpcode::kStore, store->opcode()); | 1234 CHECK_EQ(IrOpcode::kStore, store->opcode()); |
1235 CHECK_EQ(val, store->InputAt(2)); | 1235 CHECK_EQ(val, store->InputAt(2)); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 | 1341 |
1342 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, | 1342 Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, |
1343 t.p1, t.start, t.start); | 1343 t.p1, t.start, t.start); |
1344 t.Effect(store); | 1344 t.Effect(store); |
1345 t.Lower(); | 1345 t.Lower(); |
1346 | 1346 |
1347 CHECK_EQ(IrOpcode::kStore, store->opcode()); | 1347 CHECK_EQ(IrOpcode::kStore, store->opcode()); |
1348 CHECK_EQ(t.p0, store->InputAt(0)); | 1348 CHECK_EQ(t.p0, store->InputAt(0)); |
1349 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2)); | 1349 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2)); |
1350 } | 1350 } |
OLD | NEW |