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 "src/compiler/js-graph.h" | 5 #include "src/compiler/js-graph.h" |
6 #include "src/compiler/js-typed-lowering.h" | 6 #include "src/compiler/js-typed-lowering.h" |
7 #include "src/compiler/machine-operator.h" | 7 #include "src/compiler/machine-operator.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/compiler/opcodes.h" | 9 #include "src/compiler/opcodes.h" |
10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 Node* context() { | 99 Node* context() { |
100 if (context_node == NULL) { | 100 if (context_node == NULL) { |
101 context_node = graph.NewNode(common.Parameter(-1), graph.start()); | 101 context_node = graph.NewNode(common.Parameter(-1), graph.start()); |
102 } | 102 } |
103 return context_node; | 103 return context_node; |
104 } | 104 } |
105 | 105 |
106 Node* control() { return start(); } | 106 Node* control() { return start(); } |
107 | 107 |
108 void CheckPureBinop(IrOpcode::Value expected, Node* node) { | 108 void CheckBinop(IrOpcode::Value expected, Node* node) { |
109 CHECK_EQ(expected, node->opcode()); | 109 CHECK_EQ(expected, node->opcode()); |
110 CHECK_EQ(2, node->InputCount()); // should not have context, effect, etc. | |
111 } | 110 } |
112 | 111 |
113 void CheckPureBinop(const Operator* expected, Node* node) { | 112 void CheckBinop(const Operator* expected, Node* node) { |
114 CHECK_EQ(expected->opcode(), node->op()->opcode()); | 113 CHECK_EQ(expected->opcode(), node->op()->opcode()); |
115 CHECK_EQ(2, node->InputCount()); // should not have context, effect, etc. | |
116 } | 114 } |
117 | 115 |
118 Node* ReduceUnop(const Operator* op, Type* input_type) { | 116 Node* ReduceUnop(const Operator* op, Type* input_type) { |
119 return reduce(Unop(op, Parameter(input_type))); | 117 return reduce(Unop(op, Parameter(input_type))); |
120 } | 118 } |
121 | 119 |
122 Node* ReduceBinop(const Operator* op, Type* left_type, Type* right_type) { | 120 Node* ReduceBinop(const Operator* op, Type* left_type, Type* right_type) { |
123 return reduce(Binop(op, Parameter(left_type, 0), Parameter(right_type, 1))); | 121 return reduce(Binop(op, Parameter(left_type, 0), Parameter(right_type, 1))); |
124 } | 122 } |
125 | 123 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 240 |
243 for (size_t i = 0; i < arraysize(kStringTypes); ++i) { | 241 for (size_t i = 0; i < arraysize(kStringTypes); ++i) { |
244 Node* p0 = R.Parameter(kStringTypes[i], 0); | 242 Node* p0 = R.Parameter(kStringTypes[i], 0); |
245 | 243 |
246 for (size_t j = 0; j < arraysize(kStringTypes); ++j) { | 244 for (size_t j = 0; j < arraysize(kStringTypes); ++j) { |
247 Node* p1 = R.Parameter(kStringTypes[j], 1); | 245 Node* p1 = R.Parameter(kStringTypes[j], 1); |
248 | 246 |
249 Node* add = R.Binop(R.javascript.Add(language_mode), p0, p1); | 247 Node* add = R.Binop(R.javascript.Add(language_mode), p0, p1); |
250 Node* r = R.reduce(add); | 248 Node* r = R.reduce(add); |
251 | 249 |
252 R.CheckPureBinop(IrOpcode::kStringAdd, r); | 250 R.CheckBinop(IrOpcode::kStringAdd, r); |
253 CHECK_EQ(p0, r->InputAt(0)); | 251 CHECK_EQ(p0, r->InputAt(0)); |
254 CHECK_EQ(p1, r->InputAt(1)); | 252 CHECK_EQ(p1, r->InputAt(1)); |
255 } | 253 } |
256 } | 254 } |
257 } | 255 } |
258 #endif | 256 #endif |
259 | 257 |
260 | 258 |
261 TEST_WITH_STRONG(AddNumber1) { | 259 TEST_WITH_STRONG(AddNumber1) { |
262 JSTypedLoweringTester R; | 260 JSTypedLoweringTester R; |
263 for (size_t i = 0; i < arraysize(kNumberTypes); ++i) { | 261 for (size_t i = 0; i < arraysize(kNumberTypes); ++i) { |
264 Node* p0 = R.Parameter(kNumberTypes[i], 0); | 262 Node* p0 = R.Parameter(kNumberTypes[i], 0); |
265 Node* p1 = R.Parameter(kNumberTypes[i], 1); | 263 Node* p1 = R.Parameter(kNumberTypes[i], 1); |
266 Node* add = R.Binop(R.javascript.Add(language_mode), p0, p1); | 264 Node* add = R.Binop(R.javascript.Add(language_mode), p0, p1); |
267 Node* r = R.reduce(add); | 265 Node* r = R.reduce(add); |
268 | 266 |
269 R.CheckPureBinop(IrOpcode::kNumberAdd, r); | 267 R.CheckBinop(IrOpcode::kNumberAdd, r); |
270 CHECK_EQ(p0, r->InputAt(0)); | 268 CHECK_EQ(p0, r->InputAt(0)); |
271 CHECK_EQ(p1, r->InputAt(1)); | 269 CHECK_EQ(p1, r->InputAt(1)); |
272 } | 270 } |
273 } | 271 } |
274 | 272 |
275 | 273 |
276 TEST_WITH_STRONG(NumberBinops) { | 274 TEST_WITH_STRONG(NumberBinops) { |
277 JSTypedLoweringTester R; | 275 JSTypedLoweringTester R; |
278 const Operator* ops[] = { | 276 const Operator* ops[] = { |
279 R.javascript.Add(language_mode), R.simplified.NumberAdd(), | 277 R.javascript.Add(language_mode), R.simplified.NumberAdd(), |
280 R.javascript.Subtract(language_mode), R.simplified.NumberSubtract(), | 278 R.javascript.Subtract(language_mode), R.simplified.NumberSubtract(), |
281 R.javascript.Multiply(language_mode), R.simplified.NumberMultiply(), | 279 R.javascript.Multiply(language_mode), R.simplified.NumberMultiply(), |
282 R.javascript.Divide(language_mode), R.simplified.NumberDivide(), | 280 R.javascript.Divide(language_mode), R.simplified.NumberDivide(), |
283 R.javascript.Modulus(language_mode), R.simplified.NumberModulus(), | 281 R.javascript.Modulus(language_mode), R.simplified.NumberModulus(), |
284 }; | 282 }; |
285 | 283 |
286 for (size_t i = 0; i < arraysize(kNumberTypes); ++i) { | 284 for (size_t i = 0; i < arraysize(kNumberTypes); ++i) { |
287 Node* p0 = R.Parameter(kNumberTypes[i], 0); | 285 Node* p0 = R.Parameter(kNumberTypes[i], 0); |
288 | 286 |
289 for (size_t j = 0; j < arraysize(kNumberTypes); ++j) { | 287 for (size_t j = 0; j < arraysize(kNumberTypes); ++j) { |
290 Node* p1 = R.Parameter(kNumberTypes[j], 1); | 288 Node* p1 = R.Parameter(kNumberTypes[j], 1); |
291 | 289 |
292 for (size_t k = 0; k < arraysize(ops); k += 2) { | 290 for (size_t k = 0; k < arraysize(ops); k += 2) { |
293 Node* add = R.Binop(ops[k], p0, p1); | 291 Node* add = R.Binop(ops[k], p0, p1); |
294 Node* r = R.reduce(add); | 292 Node* r = R.reduce(add); |
295 | 293 |
296 R.CheckPureBinop(ops[k + 1], r); | 294 R.CheckBinop(ops[k + 1], r); |
297 CHECK_EQ(p0, r->InputAt(0)); | 295 CHECK_EQ(p0, r->InputAt(0)); |
298 CHECK_EQ(p1, r->InputAt(1)); | 296 CHECK_EQ(p1, r->InputAt(1)); |
299 } | 297 } |
300 } | 298 } |
301 } | 299 } |
302 } | 300 } |
303 | 301 |
304 | 302 |
305 static void CheckToI32(Node* old_input, Node* new_input, bool is_signed) { | 303 static void CheckToI32(Node* old_input, Node* new_input, bool is_signed) { |
306 Type* old_type = NodeProperties::GetType(old_input); | 304 Type* old_type = NodeProperties::GetType(old_input); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 for (size_t i = 0; i < arraysize(types); ++i) { | 354 for (size_t i = 0; i < arraysize(types); ++i) { |
357 Node* p0 = R.Parameter(types[i], 0); | 355 Node* p0 = R.Parameter(types[i], 0); |
358 | 356 |
359 for (size_t j = 0; j < arraysize(types); ++j) { | 357 for (size_t j = 0; j < arraysize(types); ++j) { |
360 Node* p1 = R.Parameter(types[j], 1); | 358 Node* p1 = R.Parameter(types[j], 1); |
361 | 359 |
362 for (int k = 0; k < R.kNumberOps; k += 2) { | 360 for (int k = 0; k < R.kNumberOps; k += 2) { |
363 Node* add = R.Binop(R.ops[k], p0, p1); | 361 Node* add = R.Binop(R.ops[k], p0, p1); |
364 Node* r = R.reduce(add); | 362 Node* r = R.reduce(add); |
365 | 363 |
366 R.CheckPureBinop(R.ops[k + 1], r); | 364 R.CheckBinop(R.ops[k + 1], r); |
367 Node* r0 = r->InputAt(0); | 365 Node* r0 = r->InputAt(0); |
368 Node* r1 = r->InputAt(1); | 366 Node* r1 = r->InputAt(1); |
369 | 367 |
370 CheckToI32(p0, r0, R.signedness[k]); | 368 CheckToI32(p0, r0, R.signedness[k]); |
371 CheckToI32(p1, r1, false); | 369 CheckToI32(p1, r1, false); |
372 } | 370 } |
373 } | 371 } |
374 } | 372 } |
375 } | 373 } |
376 | 374 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 for (size_t i = 0; i < arraysize(types); ++i) { | 412 for (size_t i = 0; i < arraysize(types); ++i) { |
415 Node* p0 = R.Parameter(types[i], 0); | 413 Node* p0 = R.Parameter(types[i], 0); |
416 | 414 |
417 for (size_t j = 0; j < arraysize(types); ++j) { | 415 for (size_t j = 0; j < arraysize(types); ++j) { |
418 Node* p1 = R.Parameter(types[j], 1); | 416 Node* p1 = R.Parameter(types[j], 1); |
419 | 417 |
420 for (int k = 0; k < R.kNumberOps; k += 2) { | 418 for (int k = 0; k < R.kNumberOps; k += 2) { |
421 Node* add = R.Binop(R.ops[k], p0, p1); | 419 Node* add = R.Binop(R.ops[k], p0, p1); |
422 Node* r = R.reduce(add); | 420 Node* r = R.reduce(add); |
423 | 421 |
424 R.CheckPureBinop(R.ops[k + 1], r); | 422 R.CheckBinop(R.ops[k + 1], r); |
425 | 423 |
426 CheckToI32(p0, r->InputAt(0), R.signedness[k]); | 424 CheckToI32(p0, r->InputAt(0), R.signedness[k]); |
427 CheckToI32(p1, r->InputAt(1), R.signedness[k + 1]); | 425 CheckToI32(p1, r->InputAt(1), R.signedness[k + 1]); |
428 } | 426 } |
429 } | 427 } |
430 } | 428 } |
431 } | 429 } |
432 | 430 |
433 | 431 |
434 TEST(JSToNumber1) { | 432 TEST(JSToNumber1) { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 | 605 |
608 for (size_t i = 0; i < arraysize(kStringTypes); i++) { | 606 for (size_t i = 0; i < arraysize(kStringTypes); i++) { |
609 Node* p0 = R.Parameter(kStringTypes[i], 0); | 607 Node* p0 = R.Parameter(kStringTypes[i], 0); |
610 for (size_t j = 0; j < arraysize(kStringTypes); j++) { | 608 for (size_t j = 0; j < arraysize(kStringTypes); j++) { |
611 Node* p1 = R.Parameter(kStringTypes[j], 1); | 609 Node* p1 = R.Parameter(kStringTypes[j], 1); |
612 | 610 |
613 for (size_t k = 0; k < arraysize(ops); k += 2) { | 611 for (size_t k = 0; k < arraysize(ops); k += 2) { |
614 Node* cmp = R.Binop(ops[k], p0, p1); | 612 Node* cmp = R.Binop(ops[k], p0, p1); |
615 Node* r = R.reduce(cmp); | 613 Node* r = R.reduce(cmp); |
616 | 614 |
617 R.CheckPureBinop(ops[k + 1], r); | 615 R.CheckBinop(ops[k + 1], r); |
618 if (k >= 4) { | 616 if (k >= 4) { |
619 // GreaterThan and GreaterThanOrEqual commute the inputs | 617 // GreaterThan and GreaterThanOrEqual commute the inputs |
620 // and use the LessThan and LessThanOrEqual operators. | 618 // and use the LessThan and LessThanOrEqual operators. |
621 CHECK_EQ(p1, r->InputAt(0)); | 619 CHECK_EQ(p1, r->InputAt(0)); |
622 CHECK_EQ(p0, r->InputAt(1)); | 620 CHECK_EQ(p0, r->InputAt(1)); |
623 } else { | 621 } else { |
624 CHECK_EQ(p0, r->InputAt(0)); | 622 CHECK_EQ(p0, r->InputAt(0)); |
625 CHECK_EQ(p1, r->InputAt(1)); | 623 CHECK_EQ(p1, r->InputAt(1)); |
626 } | 624 } |
627 } | 625 } |
(...skipping 27 matching lines...) Expand all Loading... |
655 R.javascript.GreaterThanOrEqual(language_mode), | 653 R.javascript.GreaterThanOrEqual(language_mode), |
656 R.simplified.NumberLessThanOrEqual()}; | 654 R.simplified.NumberLessThanOrEqual()}; |
657 | 655 |
658 Node* const p0 = R.Parameter(Type::Number(), 0); | 656 Node* const p0 = R.Parameter(Type::Number(), 0); |
659 Node* const p1 = R.Parameter(Type::Number(), 1); | 657 Node* const p1 = R.Parameter(Type::Number(), 1); |
660 | 658 |
661 for (size_t k = 0; k < arraysize(ops); k += 2) { | 659 for (size_t k = 0; k < arraysize(ops); k += 2) { |
662 Node* cmp = R.Binop(ops[k], p0, p1); | 660 Node* cmp = R.Binop(ops[k], p0, p1); |
663 Node* r = R.reduce(cmp); | 661 Node* r = R.reduce(cmp); |
664 | 662 |
665 R.CheckPureBinop(ops[k + 1], r); | 663 R.CheckBinop(ops[k + 1], r); |
666 if (k >= 4) { | 664 if (k >= 4) { |
667 // GreaterThan and GreaterThanOrEqual commute the inputs | 665 // GreaterThan and GreaterThanOrEqual commute the inputs |
668 // and use the LessThan and LessThanOrEqual operators. | 666 // and use the LessThan and LessThanOrEqual operators. |
669 CheckIsConvertedToNumber(p1, r->InputAt(0)); | 667 CheckIsConvertedToNumber(p1, r->InputAt(0)); |
670 CheckIsConvertedToNumber(p0, r->InputAt(1)); | 668 CheckIsConvertedToNumber(p0, r->InputAt(1)); |
671 } else { | 669 } else { |
672 CheckIsConvertedToNumber(p0, r->InputAt(0)); | 670 CheckIsConvertedToNumber(p0, r->InputAt(0)); |
673 CheckIsConvertedToNumber(p1, r->InputAt(1)); | 671 CheckIsConvertedToNumber(p1, r->InputAt(1)); |
674 } | 672 } |
675 } | 673 } |
676 } | 674 } |
677 | 675 |
678 | 676 |
679 TEST_WITH_STRONG(MixedComparison1) { | 677 TEST_WITH_STRONG(MixedComparison1) { |
680 JSTypedLoweringTester R; | 678 JSTypedLoweringTester R; |
681 | 679 |
682 Type* types[] = {Type::Number(), Type::String(), | 680 Type* types[] = {Type::Number(), Type::String(), |
683 Type::Union(Type::Number(), Type::String(), R.main_zone())}; | 681 Type::Union(Type::Number(), Type::String(), R.main_zone())}; |
684 | 682 |
685 for (size_t i = 0; i < arraysize(types); i++) { | 683 for (size_t i = 0; i < arraysize(types); i++) { |
686 Node* p0 = R.Parameter(types[i], 0); | 684 Node* p0 = R.Parameter(types[i], 0); |
687 | 685 |
688 for (size_t j = 0; j < arraysize(types); j++) { | 686 for (size_t j = 0; j < arraysize(types); j++) { |
689 Node* p1 = R.Parameter(types[j], 1); | 687 Node* p1 = R.Parameter(types[j], 1); |
690 { | 688 { |
691 const Operator* less_than = R.javascript.LessThan(language_mode); | 689 const Operator* less_than = R.javascript.LessThan(language_mode); |
692 Node* cmp = R.Binop(less_than, p0, p1); | 690 Node* cmp = R.Binop(less_than, p0, p1); |
693 Node* r = R.reduce(cmp); | 691 Node* r = R.reduce(cmp); |
694 if (types[i]->Is(Type::String()) && types[j]->Is(Type::String())) { | 692 if (types[i]->Is(Type::String()) && types[j]->Is(Type::String())) { |
695 R.CheckPureBinop(R.simplified.StringLessThan(), r); | 693 R.CheckBinop(R.simplified.StringLessThan(), r); |
696 } else if ((types[i]->Is(Type::Number()) && | 694 } else if ((types[i]->Is(Type::Number()) && |
697 types[j]->Is(Type::Number())) || | 695 types[j]->Is(Type::Number())) || |
698 (!is_strong(language_mode) && | 696 (!is_strong(language_mode) && |
699 (!types[i]->Maybe(Type::String()) || | 697 (!types[i]->Maybe(Type::String()) || |
700 !types[j]->Maybe(Type::String())))) { | 698 !types[j]->Maybe(Type::String())))) { |
701 R.CheckPureBinop(R.simplified.NumberLessThan(), r); | 699 R.CheckBinop(R.simplified.NumberLessThan(), r); |
702 } else { | 700 } else { |
703 // No reduction of mixed types. | 701 // No reduction of mixed types. |
704 CHECK_EQ(r->op(), less_than); | 702 CHECK_EQ(r->op(), less_than); |
705 } | 703 } |
706 } | 704 } |
707 } | 705 } |
708 } | 706 } |
709 } | 707 } |
710 | 708 |
711 | 709 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 Node* r, IrOpcode::Value expected) { | 830 Node* r, IrOpcode::Value expected) { |
833 for (int j = 0; j < 2; j++) { | 831 for (int j = 0; j < 2; j++) { |
834 Node* p0 = j == 0 ? l : r; | 832 Node* p0 = j == 0 ? l : r; |
835 Node* p1 = j == 1 ? l : r; | 833 Node* p1 = j == 1 ? l : r; |
836 | 834 |
837 { | 835 { |
838 const Operator* op = | 836 const Operator* op = |
839 strict ? R->javascript.StrictEqual() : R->javascript.Equal(); | 837 strict ? R->javascript.StrictEqual() : R->javascript.Equal(); |
840 Node* eq = R->Binop(op, p0, p1); | 838 Node* eq = R->Binop(op, p0, p1); |
841 Node* r = R->reduce(eq); | 839 Node* r = R->reduce(eq); |
842 R->CheckPureBinop(expected, r); | 840 R->CheckBinop(expected, r); |
843 } | 841 } |
844 | 842 |
845 { | 843 { |
846 const Operator* op = | 844 const Operator* op = |
847 strict ? R->javascript.StrictNotEqual() : R->javascript.NotEqual(); | 845 strict ? R->javascript.StrictNotEqual() : R->javascript.NotEqual(); |
848 Node* ne = R->Binop(op, p0, p1); | 846 Node* ne = R->Binop(op, p0, p1); |
849 Node* n = R->reduce(ne); | 847 Node* n = R->reduce(ne); |
850 CHECK_EQ(IrOpcode::kBooleanNot, n->opcode()); | 848 CHECK_EQ(IrOpcode::kBooleanNot, n->opcode()); |
851 Node* r = n->InputAt(0); | 849 Node* r = n->InputAt(0); |
852 R->CheckPureBinop(expected, r); | 850 R->CheckBinop(expected, r); |
853 } | 851 } |
854 } | 852 } |
855 } | 853 } |
856 | 854 |
857 | 855 |
858 TEST(EqualityForNumbers) { | 856 TEST(EqualityForNumbers) { |
859 JSTypedLoweringTester R; | 857 JSTypedLoweringTester R; |
860 | 858 |
861 Type* simple_number_types[] = {Type::UnsignedSmall(), Type::SignedSmall(), | 859 Type* simple_number_types[] = {Type::UnsignedSmall(), Type::SignedSmall(), |
862 Type::Signed32(), Type::Unsigned32(), | 860 Type::Signed32(), Type::Unsigned32(), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 R.javascript.Modulus(language_mode), R.simplified.NumberModulus(), | 911 R.javascript.Modulus(language_mode), R.simplified.NumberModulus(), |
914 R.javascript.LessThan(language_mode), R.simplified.NumberLessThan(), | 912 R.javascript.LessThan(language_mode), R.simplified.NumberLessThan(), |
915 R.javascript.LessThanOrEqual(language_mode), | 913 R.javascript.LessThanOrEqual(language_mode), |
916 R.simplified.NumberLessThanOrEqual(), | 914 R.simplified.NumberLessThanOrEqual(), |
917 }; | 915 }; |
918 | 916 |
919 for (size_t j = 0; j < arraysize(ops); j += 2) { | 917 for (size_t j = 0; j < arraysize(ops); j += 2) { |
920 BinopEffectsTester B(ops[j], Type::Number(), Type::Number()); | 918 BinopEffectsTester B(ops[j], Type::Number(), Type::Number()); |
921 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); | 919 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); |
922 | 920 |
923 B.R.CheckPureBinop(B.result->opcode(), B.result); | 921 B.R.CheckBinop(B.result->opcode(), B.result); |
924 | 922 |
925 B.CheckNoOp(0); | 923 B.CheckNoOp(0); |
926 B.CheckNoOp(1); | 924 B.CheckNoOp(1); |
927 | 925 |
928 B.CheckEffectsRemoved(); | 926 B.CheckEffectsRemoved(); |
929 } | 927 } |
930 } | 928 } |
931 | 929 |
932 | 930 |
933 TEST(OrderNumberBinopEffects1) { | 931 TEST(OrderNumberBinopEffects1) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 } | 1051 } |
1054 | 1052 |
1055 | 1053 |
1056 TEST(Int32BinopEffects) { | 1054 TEST(Int32BinopEffects) { |
1057 JSBitwiseTypedLoweringTester R(LanguageMode::SLOPPY); | 1055 JSBitwiseTypedLoweringTester R(LanguageMode::SLOPPY); |
1058 for (int j = 0; j < R.kNumberOps; j += 2) { | 1056 for (int j = 0; j < R.kNumberOps; j += 2) { |
1059 bool signed_left = R.signedness[j], signed_right = R.signedness[j + 1]; | 1057 bool signed_left = R.signedness[j], signed_right = R.signedness[j + 1]; |
1060 BinopEffectsTester B(R.ops[j], I32Type(signed_left), I32Type(signed_right)); | 1058 BinopEffectsTester B(R.ops[j], I32Type(signed_left), I32Type(signed_right)); |
1061 CHECK_EQ(R.ops[j + 1]->opcode(), B.result->op()->opcode()); | 1059 CHECK_EQ(R.ops[j + 1]->opcode(), B.result->op()->opcode()); |
1062 | 1060 |
1063 B.R.CheckPureBinop(B.result->opcode(), B.result); | 1061 B.R.CheckBinop(B.result->opcode(), B.result); |
1064 | 1062 |
1065 B.CheckNoOp(0); | 1063 B.CheckNoOp(0); |
1066 B.CheckNoOp(1); | 1064 B.CheckNoOp(1); |
1067 | 1065 |
1068 B.CheckEffectsRemoved(); | 1066 B.CheckEffectsRemoved(); |
1069 } | 1067 } |
1070 | 1068 |
1071 for (int j = 0; j < R.kNumberOps; j += 2) { | 1069 for (int j = 0; j < R.kNumberOps; j += 2) { |
1072 bool signed_left = R.signedness[j], signed_right = R.signedness[j + 1]; | 1070 bool signed_left = R.signedness[j], signed_right = R.signedness[j + 1]; |
1073 BinopEffectsTester B(R.ops[j], Type::Number(), Type::Number()); | 1071 BinopEffectsTester B(R.ops[j], Type::Number(), Type::Number()); |
1074 CHECK_EQ(R.ops[j + 1]->opcode(), B.result->op()->opcode()); | 1072 CHECK_EQ(R.ops[j + 1]->opcode(), B.result->op()->opcode()); |
1075 | 1073 |
1076 B.R.CheckPureBinop(B.result->opcode(), B.result); | 1074 B.R.CheckBinop(B.result->opcode(), B.result); |
1077 | 1075 |
1078 B.CheckConvertedInput(NumberToI32(signed_left), 0, false); | 1076 B.CheckConvertedInput(NumberToI32(signed_left), 0, false); |
1079 B.CheckConvertedInput(NumberToI32(signed_right), 1, false); | 1077 B.CheckConvertedInput(NumberToI32(signed_right), 1, false); |
1080 | 1078 |
1081 B.CheckEffectsRemoved(); | 1079 B.CheckEffectsRemoved(); |
1082 } | 1080 } |
1083 | 1081 |
1084 for (int j = 0; j < R.kNumberOps; j += 2) { | 1082 for (int j = 0; j < R.kNumberOps; j += 2) { |
1085 bool signed_left = R.signedness[j], signed_right = R.signedness[j + 1]; | 1083 bool signed_left = R.signedness[j], signed_right = R.signedness[j + 1]; |
1086 BinopEffectsTester B(R.ops[j], Type::Number(), Type::Primitive()); | 1084 BinopEffectsTester B(R.ops[j], Type::Number(), Type::Primitive()); |
1087 | 1085 |
1088 B.R.CheckPureBinop(B.result->opcode(), B.result); | 1086 B.R.CheckBinop(B.result->opcode(), B.result); |
1089 | 1087 |
1090 Node* i0 = B.CheckConvertedInput(NumberToI32(signed_left), 0, false); | 1088 Node* i0 = B.CheckConvertedInput(NumberToI32(signed_left), 0, false); |
1091 Node* i1 = B.CheckConvertedInput(NumberToI32(signed_right), 1, false); | 1089 Node* i1 = B.CheckConvertedInput(NumberToI32(signed_right), 1, false); |
1092 | 1090 |
1093 CHECK_EQ(B.p0, i0->InputAt(0)); | 1091 CHECK_EQ(B.p0, i0->InputAt(0)); |
1094 Node* ii1 = B.CheckConverted(IrOpcode::kJSToNumber, i1->InputAt(0), true); | 1092 Node* ii1 = B.CheckConverted(IrOpcode::kJSToNumber, i1->InputAt(0), true); |
1095 | 1093 |
1096 CHECK_EQ(B.p1, ii1->InputAt(0)); | 1094 CHECK_EQ(B.p1, ii1->InputAt(0)); |
1097 | 1095 |
1098 B.CheckEffectOrdering(ii1); | 1096 B.CheckEffectOrdering(ii1); |
1099 } | 1097 } |
1100 | 1098 |
1101 for (int j = 0; j < R.kNumberOps; j += 2) { | 1099 for (int j = 0; j < R.kNumberOps; j += 2) { |
1102 bool signed_left = R.signedness[j], signed_right = R.signedness[j + 1]; | 1100 bool signed_left = R.signedness[j], signed_right = R.signedness[j + 1]; |
1103 BinopEffectsTester B(R.ops[j], Type::Primitive(), Type::Number()); | 1101 BinopEffectsTester B(R.ops[j], Type::Primitive(), Type::Number()); |
1104 | 1102 |
1105 B.R.CheckPureBinop(B.result->opcode(), B.result); | 1103 B.R.CheckBinop(B.result->opcode(), B.result); |
1106 | 1104 |
1107 Node* i0 = B.CheckConvertedInput(NumberToI32(signed_left), 0, false); | 1105 Node* i0 = B.CheckConvertedInput(NumberToI32(signed_left), 0, false); |
1108 Node* i1 = B.CheckConvertedInput(NumberToI32(signed_right), 1, false); | 1106 Node* i1 = B.CheckConvertedInput(NumberToI32(signed_right), 1, false); |
1109 | 1107 |
1110 Node* ii0 = B.CheckConverted(IrOpcode::kJSToNumber, i0->InputAt(0), true); | 1108 Node* ii0 = B.CheckConverted(IrOpcode::kJSToNumber, i0->InputAt(0), true); |
1111 CHECK_EQ(B.p1, i1->InputAt(0)); | 1109 CHECK_EQ(B.p1, i1->InputAt(0)); |
1112 | 1110 |
1113 CHECK_EQ(B.p0, ii0->InputAt(0)); | 1111 CHECK_EQ(B.p0, ii0->InputAt(0)); |
1114 | 1112 |
1115 B.CheckEffectOrdering(ii0); | 1113 B.CheckEffectOrdering(ii0); |
1116 } | 1114 } |
1117 | 1115 |
1118 for (int j = 0; j < R.kNumberOps; j += 2) { | 1116 for (int j = 0; j < R.kNumberOps; j += 2) { |
1119 bool signed_left = R.signedness[j], signed_right = R.signedness[j + 1]; | 1117 bool signed_left = R.signedness[j], signed_right = R.signedness[j + 1]; |
1120 BinopEffectsTester B(R.ops[j], Type::Primitive(), Type::Primitive()); | 1118 BinopEffectsTester B(R.ops[j], Type::Primitive(), Type::Primitive()); |
1121 | 1119 |
1122 B.R.CheckPureBinop(B.result->opcode(), B.result); | 1120 B.R.CheckBinop(B.result->opcode(), B.result); |
1123 | 1121 |
1124 Node* i0 = B.CheckConvertedInput(NumberToI32(signed_left), 0, false); | 1122 Node* i0 = B.CheckConvertedInput(NumberToI32(signed_left), 0, false); |
1125 Node* i1 = B.CheckConvertedInput(NumberToI32(signed_right), 1, false); | 1123 Node* i1 = B.CheckConvertedInput(NumberToI32(signed_right), 1, false); |
1126 | 1124 |
1127 Node* ii0 = B.CheckConverted(IrOpcode::kJSToNumber, i0->InputAt(0), true); | 1125 Node* ii0 = B.CheckConverted(IrOpcode::kJSToNumber, i0->InputAt(0), true); |
1128 Node* ii1 = B.CheckConverted(IrOpcode::kJSToNumber, i1->InputAt(0), true); | 1126 Node* ii1 = B.CheckConverted(IrOpcode::kJSToNumber, i1->InputAt(0), true); |
1129 | 1127 |
1130 CHECK_EQ(B.p0, ii0->InputAt(0)); | 1128 CHECK_EQ(B.p0, ii0->InputAt(0)); |
1131 CHECK_EQ(B.p1, ii1->InputAt(0)); | 1129 CHECK_EQ(B.p1, ii1->InputAt(0)); |
1132 | 1130 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 Node* r = R.reduce(cmp); | 1242 Node* r = R.reduce(cmp); |
1245 | 1243 |
1246 const Operator* expected; | 1244 const Operator* expected; |
1247 if (t0->Is(Type::Unsigned32()) && t1->Is(Type::Unsigned32())) { | 1245 if (t0->Is(Type::Unsigned32()) && t1->Is(Type::Unsigned32())) { |
1248 expected = ops[o].uint_op; | 1246 expected = ops[o].uint_op; |
1249 } else if (t0->Is(Type::Signed32()) && t1->Is(Type::Signed32())) { | 1247 } else if (t0->Is(Type::Signed32()) && t1->Is(Type::Signed32())) { |
1250 expected = ops[o].int_op; | 1248 expected = ops[o].int_op; |
1251 } else { | 1249 } else { |
1252 expected = ops[o].num_op; | 1250 expected = ops[o].num_op; |
1253 } | 1251 } |
1254 R.CheckPureBinop(expected, r); | 1252 R.CheckBinop(expected, r); |
1255 if (ops[o].commute) { | 1253 if (ops[o].commute) { |
1256 CHECK_EQ(p1, r->InputAt(0)); | 1254 CHECK_EQ(p1, r->InputAt(0)); |
1257 CHECK_EQ(p0, r->InputAt(1)); | 1255 CHECK_EQ(p0, r->InputAt(1)); |
1258 } else { | 1256 } else { |
1259 CHECK_EQ(p0, r->InputAt(0)); | 1257 CHECK_EQ(p0, r->InputAt(0)); |
1260 CHECK_EQ(p1, r->InputAt(1)); | 1258 CHECK_EQ(p1, r->InputAt(1)); |
1261 } | 1259 } |
1262 } | 1260 } |
1263 } | 1261 } |
1264 } | 1262 } |
1265 } | 1263 } |
OLD | NEW |