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

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

Issue 2035383003: [turbofan] Type feedback for numeric comparisons. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase, pure ops Created 4 years, 6 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
« no previous file with comments | « src/compiler/verifier.cc ('k') | test/unittests/compiler/js-operator-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "src/compilation-dependencies.h" 5 #include "src/compilation-dependencies.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/js-typed-lowering.h" 7 #include "src/compiler/js-typed-lowering.h"
8 #include "src/compiler/machine-operator.h" 8 #include "src/compiler/machine-operator.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 #include "src/compiler/opcodes.h" 10 #include "src/compiler/opcodes.h"
(...skipping 29 matching lines...) Expand all
40 const Operator* binop; 40 const Operator* binop;
41 const Operator* unop; 41 const Operator* unop;
42 JSOperatorBuilder javascript; 42 JSOperatorBuilder javascript;
43 MachineOperatorBuilder machine; 43 MachineOperatorBuilder machine;
44 SimplifiedOperatorBuilder simplified; 44 SimplifiedOperatorBuilder simplified;
45 CommonOperatorBuilder common; 45 CommonOperatorBuilder common;
46 CompilationDependencies deps; 46 CompilationDependencies deps;
47 Graph graph; 47 Graph graph;
48 Typer typer; 48 Typer typer;
49 Node* context_node; 49 Node* context_node;
50 BinaryOperationHints const hints = BinaryOperationHints::Any(); 50 BinaryOperationHints const binop_hints = BinaryOperationHints::Any();
51 CompareOperationHints const compare_hints = CompareOperationHints::Any();
51 52
52 Node* Parameter(Type* t, int32_t index = 0) { 53 Node* Parameter(Type* t, int32_t index = 0) {
53 Node* n = graph.NewNode(common.Parameter(index), graph.start()); 54 Node* n = graph.NewNode(common.Parameter(index), graph.start());
54 NodeProperties::SetType(n, t); 55 NodeProperties::SetType(n, t);
55 return n; 56 return n;
56 } 57 }
57 58
58 Node* UndefinedConstant() { 59 Node* UndefinedConstant() {
59 Handle<HeapObject> value = isolate->factory()->undefined_value(); 60 Handle<HeapObject> value = isolate->factory()->undefined_value();
60 return graph.NewNode(common.HeapConstant(value)); 61 return graph.NewNode(common.HeapConstant(value));
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 249
249 R.CheckBinop(IrOpcode::kNumberAdd, r); 250 R.CheckBinop(IrOpcode::kNumberAdd, r);
250 CHECK_EQ(p0, r->InputAt(0)); 251 CHECK_EQ(p0, r->InputAt(0));
251 CHECK_EQ(p1, r->InputAt(1)); 252 CHECK_EQ(p1, r->InputAt(1));
252 } 253 }
253 } 254 }
254 255
255 TEST(NumberBinops) { 256 TEST(NumberBinops) {
256 JSTypedLoweringTester R; 257 JSTypedLoweringTester R;
257 const Operator* ops[] = { 258 const Operator* ops[] = {
258 R.javascript.Add(R.hints), R.simplified.NumberAdd(), 259 R.javascript.Add(R.binop_hints), R.simplified.NumberAdd(),
259 R.javascript.Subtract(R.hints), R.simplified.NumberSubtract(), 260 R.javascript.Subtract(R.binop_hints), R.simplified.NumberSubtract(),
260 R.javascript.Multiply(R.hints), R.simplified.NumberMultiply(), 261 R.javascript.Multiply(R.binop_hints), R.simplified.NumberMultiply(),
261 R.javascript.Divide(R.hints), R.simplified.NumberDivide(), 262 R.javascript.Divide(R.binop_hints), R.simplified.NumberDivide(),
262 R.javascript.Modulus(R.hints), R.simplified.NumberModulus(), 263 R.javascript.Modulus(R.binop_hints), R.simplified.NumberModulus(),
263 }; 264 };
264 265
265 for (size_t i = 0; i < arraysize(kNumberTypes); ++i) { 266 for (size_t i = 0; i < arraysize(kNumberTypes); ++i) {
266 Node* p0 = R.Parameter(kNumberTypes[i], 0); 267 Node* p0 = R.Parameter(kNumberTypes[i], 0);
267 268
268 for (size_t j = 0; j < arraysize(kNumberTypes); ++j) { 269 for (size_t j = 0; j < arraysize(kNumberTypes); ++j) {
269 Node* p1 = R.Parameter(kNumberTypes[j], 1); 270 Node* p1 = R.Parameter(kNumberTypes[j], 1);
270 271
271 for (size_t k = 0; k < arraysize(ops); k += 2) { 272 for (size_t k = 0; k < arraysize(ops); k += 2) {
272 Node* add = R.Binop(ops[k], p0, p1); 273 Node* add = R.Binop(ops[k], p0, p1);
(...skipping 21 matching lines...) Expand all
294 CHECK_EQ(e, v); 295 CHECK_EQ(e, v);
295 } 296 }
296 } 297 }
297 298
298 299
299 // A helper class for testing lowering of bitwise shift operators. 300 // A helper class for testing lowering of bitwise shift operators.
300 class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester { 301 class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester {
301 public: 302 public:
302 JSBitwiseShiftTypedLoweringTester() : JSTypedLoweringTester() { 303 JSBitwiseShiftTypedLoweringTester() : JSTypedLoweringTester() {
303 int i = 0; 304 int i = 0;
304 set(i++, javascript.ShiftLeft(hints), true); 305 set(i++, javascript.ShiftLeft(binop_hints), true);
305 set(i++, simplified.NumberShiftLeft(), false); 306 set(i++, simplified.NumberShiftLeft(), false);
306 set(i++, javascript.ShiftRight(hints), true); 307 set(i++, javascript.ShiftRight(binop_hints), true);
307 set(i++, simplified.NumberShiftRight(), false); 308 set(i++, simplified.NumberShiftRight(), false);
308 set(i++, javascript.ShiftRightLogical(hints), false); 309 set(i++, javascript.ShiftRightLogical(binop_hints), false);
309 set(i++, simplified.NumberShiftRightLogical(), false); 310 set(i++, simplified.NumberShiftRightLogical(), false);
310 } 311 }
311 static const int kNumberOps = 6; 312 static const int kNumberOps = 6;
312 const Operator* ops[kNumberOps]; 313 const Operator* ops[kNumberOps];
313 bool signedness[kNumberOps]; 314 bool signedness[kNumberOps];
314 315
315 private: 316 private:
316 void set(int idx, const Operator* op, bool s) { 317 void set(int idx, const Operator* op, bool s) {
317 ops[idx] = op; 318 ops[idx] = op;
318 signedness[idx] = s; 319 signedness[idx] = s;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 351 }
351 } 352 }
352 } 353 }
353 354
354 355
355 // A helper class for testing lowering of bitwise operators. 356 // A helper class for testing lowering of bitwise operators.
356 class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester { 357 class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester {
357 public: 358 public:
358 JSBitwiseTypedLoweringTester() : JSTypedLoweringTester() { 359 JSBitwiseTypedLoweringTester() : JSTypedLoweringTester() {
359 int i = 0; 360 int i = 0;
360 set(i++, javascript.BitwiseOr(hints), true); 361 set(i++, javascript.BitwiseOr(binop_hints), true);
361 set(i++, simplified.NumberBitwiseOr(), true); 362 set(i++, simplified.NumberBitwiseOr(), true);
362 set(i++, javascript.BitwiseXor(hints), true); 363 set(i++, javascript.BitwiseXor(binop_hints), true);
363 set(i++, simplified.NumberBitwiseXor(), true); 364 set(i++, simplified.NumberBitwiseXor(), true);
364 set(i++, javascript.BitwiseAnd(hints), true); 365 set(i++, javascript.BitwiseAnd(binop_hints), true);
365 set(i++, simplified.NumberBitwiseAnd(), true); 366 set(i++, simplified.NumberBitwiseAnd(), true);
366 } 367 }
367 static const int kNumberOps = 6; 368 static const int kNumberOps = 6;
368 const Operator* ops[kNumberOps]; 369 const Operator* ops[kNumberOps];
369 bool signedness[kNumberOps]; 370 bool signedness[kNumberOps];
370 371
371 private: 372 private:
372 void set(int idx, const Operator* op, bool s) { 373 void set(int idx, const Operator* op, bool s) {
373 ops[idx] = op; 374 ops[idx] = op;
374 signedness[idx] = s; 375 signedness[idx] = s;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 CHECK_EQ(n, add->InputAt(0)); 565 CHECK_EQ(n, add->InputAt(0));
565 CHECK_EQ(r, add->InputAt(1)); 566 CHECK_EQ(r, add->InputAt(1));
566 R.CheckEffectInput(R.start(), effect_use); 567 R.CheckEffectInput(R.start(), effect_use);
567 } 568 }
568 } 569 }
569 570
570 TEST(StringComparison) { 571 TEST(StringComparison) {
571 JSTypedLoweringTester R; 572 JSTypedLoweringTester R;
572 573
573 const Operator* ops[] = { 574 const Operator* ops[] = {
574 R.javascript.LessThan(), R.simplified.StringLessThan(), 575 R.javascript.LessThan(CompareOperationHints::Any()),
575 R.javascript.LessThanOrEqual(), R.simplified.StringLessThanOrEqual(), 576 R.simplified.StringLessThan(),
576 R.javascript.GreaterThan(), R.simplified.StringLessThan(), 577 R.javascript.LessThanOrEqual(CompareOperationHints::Any()),
577 R.javascript.GreaterThanOrEqual(), R.simplified.StringLessThanOrEqual()}; 578 R.simplified.StringLessThanOrEqual(),
579 R.javascript.GreaterThan(CompareOperationHints::Any()),
580 R.simplified.StringLessThan(),
581 R.javascript.GreaterThanOrEqual(CompareOperationHints::Any()),
582 R.simplified.StringLessThanOrEqual()};
578 583
579 for (size_t i = 0; i < arraysize(kStringTypes); i++) { 584 for (size_t i = 0; i < arraysize(kStringTypes); i++) {
580 Node* p0 = R.Parameter(kStringTypes[i], 0); 585 Node* p0 = R.Parameter(kStringTypes[i], 0);
581 for (size_t j = 0; j < arraysize(kStringTypes); j++) { 586 for (size_t j = 0; j < arraysize(kStringTypes); j++) {
582 Node* p1 = R.Parameter(kStringTypes[j], 1); 587 Node* p1 = R.Parameter(kStringTypes[j], 1);
583 588
584 for (size_t k = 0; k < arraysize(ops); k += 2) { 589 for (size_t k = 0; k < arraysize(ops); k += 2) {
585 Node* cmp = R.Binop(ops[k], p0, p1); 590 Node* cmp = R.Binop(ops[k], p0, p1);
586 Node* r = R.reduce(cmp); 591 Node* r = R.reduce(cmp);
587 592
(...skipping 23 matching lines...) Expand all
611 if (converted->opcode() == IrOpcode::kNumberConstant) return; 616 if (converted->opcode() == IrOpcode::kNumberConstant) return;
612 CHECK_EQ(IrOpcode::kJSToNumber, converted->opcode()); 617 CHECK_EQ(IrOpcode::kJSToNumber, converted->opcode());
613 CHECK_EQ(val, converted->InputAt(0)); 618 CHECK_EQ(val, converted->InputAt(0));
614 } 619 }
615 } 620 }
616 621
617 TEST(NumberComparison) { 622 TEST(NumberComparison) {
618 JSTypedLoweringTester R; 623 JSTypedLoweringTester R;
619 624
620 const Operator* ops[] = { 625 const Operator* ops[] = {
621 R.javascript.LessThan(), R.simplified.NumberLessThan(), 626 R.javascript.LessThan(CompareOperationHints::Any()),
622 R.javascript.LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(), 627 R.simplified.NumberLessThan(),
623 R.javascript.GreaterThan(), R.simplified.NumberLessThan(), 628 R.javascript.LessThanOrEqual(CompareOperationHints::Any()),
624 R.javascript.GreaterThanOrEqual(), R.simplified.NumberLessThanOrEqual()}; 629 R.simplified.NumberLessThanOrEqual(),
630 R.javascript.GreaterThan(CompareOperationHints::Any()),
631 R.simplified.NumberLessThan(),
632 R.javascript.GreaterThanOrEqual(CompareOperationHints::Any()),
633 R.simplified.NumberLessThanOrEqual()};
625 634
626 Node* const p0 = R.Parameter(Type::Number(), 0); 635 Node* const p0 = R.Parameter(Type::Number(), 0);
627 Node* const p1 = R.Parameter(Type::Number(), 1); 636 Node* const p1 = R.Parameter(Type::Number(), 1);
628 637
629 for (size_t k = 0; k < arraysize(ops); k += 2) { 638 for (size_t k = 0; k < arraysize(ops); k += 2) {
630 Node* cmp = R.Binop(ops[k], p0, p1); 639 Node* cmp = R.Binop(ops[k], p0, p1);
631 Node* r = R.reduce(cmp); 640 Node* r = R.reduce(cmp);
632 641
633 R.CheckBinop(ops[k + 1], r); 642 R.CheckBinop(ops[k + 1], r);
634 if (k >= 4) { 643 if (k >= 4) {
(...skipping 13 matching lines...) Expand all
648 657
649 Type* types[] = {Type::Number(), Type::String(), 658 Type* types[] = {Type::Number(), Type::String(),
650 Type::Union(Type::Number(), Type::String(), R.main_zone())}; 659 Type::Union(Type::Number(), Type::String(), R.main_zone())};
651 660
652 for (size_t i = 0; i < arraysize(types); i++) { 661 for (size_t i = 0; i < arraysize(types); i++) {
653 Node* p0 = R.Parameter(types[i], 0); 662 Node* p0 = R.Parameter(types[i], 0);
654 663
655 for (size_t j = 0; j < arraysize(types); j++) { 664 for (size_t j = 0; j < arraysize(types); j++) {
656 Node* p1 = R.Parameter(types[j], 1); 665 Node* p1 = R.Parameter(types[j], 1);
657 { 666 {
658 const Operator* less_than = R.javascript.LessThan(); 667 const Operator* less_than =
668 R.javascript.LessThan(CompareOperationHints::Any());
659 Node* cmp = R.Binop(less_than, p0, p1); 669 Node* cmp = R.Binop(less_than, p0, p1);
660 Node* r = R.reduce(cmp); 670 Node* r = R.reduce(cmp);
661 if (types[i]->Is(Type::String()) && types[j]->Is(Type::String())) { 671 if (types[i]->Is(Type::String()) && types[j]->Is(Type::String())) {
662 R.CheckBinop(R.simplified.StringLessThan(), r); 672 R.CheckBinop(R.simplified.StringLessThan(), r);
663 } else if ((types[i]->Is(Type::Number()) && 673 } else if ((types[i]->Is(Type::Number()) &&
664 types[j]->Is(Type::Number())) || 674 types[j]->Is(Type::Number())) ||
665 (!types[i]->Maybe(Type::String()) || 675 (!types[i]->Maybe(Type::String()) ||
666 !types[j]->Maybe(Type::String()))) { 676 !types[j]->Maybe(Type::String()))) {
667 R.CheckBinop(R.simplified.NumberLessThan(), r); 677 R.CheckBinop(R.simplified.NumberLessThan(), r);
668 } else { 678 } else {
(...skipping 24 matching lines...) Expand all
693 break; 703 break;
694 case 1: 704 case 1:
695 CHECK_EQ(1, OperatorProperties::GetFrameStateInputCount( 705 CHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(
696 R.javascript.ToNumber())); 706 R.javascript.ToNumber()));
697 effect_use = R.graph.NewNode(R.javascript.ToNumber(), ton, R.context(), 707 effect_use = R.graph.NewNode(R.javascript.ToNumber(), ton, R.context(),
698 frame_state, ton, R.start()); 708 frame_state, ton, R.start());
699 break; 709 break;
700 case 2: 710 case 2:
701 effect_use = R.graph.NewNode(R.common.EffectPhi(1), ton, R.start()); 711 effect_use = R.graph.NewNode(R.common.EffectPhi(1), ton, R.start());
702 case 3: 712 case 3:
703 effect_use = 713 effect_use = R.graph.NewNode(R.javascript.Add(R.binop_hints), ton, ton,
704 R.graph.NewNode(R.javascript.Add(R.hints), ton, ton, R.context(), 714 R.context(), frame_state, frame_state, ton,
705 frame_state, frame_state, ton, R.start()); 715 R.start());
706 break; 716 break;
707 case 4: 717 case 4:
708 effect_use = 718 effect_use = R.graph.NewNode(R.javascript.Add(R.binop_hints), p0, p0,
709 R.graph.NewNode(R.javascript.Add(R.hints), p0, p0, R.context(), 719 R.context(), frame_state, frame_state, ton,
710 frame_state, frame_state, ton, R.start()); 720 R.start());
711 break; 721 break;
712 case 5: 722 case 5:
713 effect_use = R.graph.NewNode(R.common.Return(), p0, ton, R.start()); 723 effect_use = R.graph.NewNode(R.common.Return(), p0, ton, R.start());
714 break; 724 break;
715 case 6: 725 case 6:
716 effect_use = R.graph.NewNode(R.common.Return(), ton, ton, R.start()); 726 effect_use = R.graph.NewNode(R.common.Return(), ton, ton, R.start());
717 } 727 }
718 728
719 R.CheckEffectInput(R.start(), ton); 729 R.CheckEffectInput(R.start(), ton);
720 if (effect_use != NULL) R.CheckEffectInput(ton, effect_use); 730 if (effect_use != NULL) R.CheckEffectInput(ton, effect_use);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 804
795 // Helper function for strict and non-strict equality reductions. 805 // Helper function for strict and non-strict equality reductions.
796 void CheckEqualityReduction(JSTypedLoweringTester* R, bool strict, Node* l, 806 void CheckEqualityReduction(JSTypedLoweringTester* R, bool strict, Node* l,
797 Node* r, IrOpcode::Value expected) { 807 Node* r, IrOpcode::Value expected) {
798 for (int j = 0; j < 2; j++) { 808 for (int j = 0; j < 2; j++) {
799 Node* p0 = j == 0 ? l : r; 809 Node* p0 = j == 0 ? l : r;
800 Node* p1 = j == 1 ? l : r; 810 Node* p1 = j == 1 ? l : r;
801 811
802 { 812 {
803 const Operator* op = 813 const Operator* op =
804 strict ? R->javascript.StrictEqual() : R->javascript.Equal(); 814 strict ? R->javascript.StrictEqual(CompareOperationHints::Any())
815 : R->javascript.Equal(CompareOperationHints::Any());
805 Node* eq = R->Binop(op, p0, p1); 816 Node* eq = R->Binop(op, p0, p1);
806 Node* r = R->reduce(eq); 817 Node* r = R->reduce(eq);
807 R->CheckBinop(expected, r); 818 R->CheckBinop(expected, r);
808 } 819 }
809 820
810 { 821 {
811 const Operator* op = 822 const Operator* op =
812 strict ? R->javascript.StrictNotEqual() : R->javascript.NotEqual(); 823 strict ? R->javascript.StrictNotEqual(CompareOperationHints::Any())
824 : R->javascript.NotEqual(CompareOperationHints::Any());
813 Node* ne = R->Binop(op, p0, p1); 825 Node* ne = R->Binop(op, p0, p1);
814 Node* n = R->reduce(ne); 826 Node* n = R->reduce(ne);
815 CHECK_EQ(IrOpcode::kBooleanNot, n->opcode()); 827 CHECK_EQ(IrOpcode::kBooleanNot, n->opcode());
816 Node* r = n->InputAt(0); 828 Node* r = n->InputAt(0);
817 R->CheckBinop(expected, r); 829 R->CheckBinop(expected, r);
818 } 830 }
819 } 831 }
820 } 832 }
821 833
822 834
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 Node* p1 = R.Parameter(Type::String()); 881 Node* p1 = R.Parameter(Type::String());
870 882
871 CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kStringEqual); 883 CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kStringEqual);
872 CheckEqualityReduction(&R, false, p0, p1, IrOpcode::kStringEqual); 884 CheckEqualityReduction(&R, false, p0, p1, IrOpcode::kStringEqual);
873 } 885 }
874 886
875 TEST(RemovePureNumberBinopEffects) { 887 TEST(RemovePureNumberBinopEffects) {
876 JSTypedLoweringTester R; 888 JSTypedLoweringTester R;
877 889
878 const Operator* ops[] = { 890 const Operator* ops[] = {
879 R.javascript.Equal(), R.simplified.NumberEqual(), 891 R.javascript.Equal(R.compare_hints),
880 R.javascript.Add(R.hints), R.simplified.NumberAdd(), 892 R.simplified.NumberEqual(),
881 R.javascript.Subtract(R.hints), R.simplified.NumberSubtract(), 893 R.javascript.Add(R.binop_hints),
882 R.javascript.Multiply(R.hints), R.simplified.NumberMultiply(), 894 R.simplified.NumberAdd(),
883 R.javascript.Divide(R.hints), R.simplified.NumberDivide(), 895 R.javascript.Subtract(R.binop_hints),
884 R.javascript.Modulus(R.hints), R.simplified.NumberModulus(), 896 R.simplified.NumberSubtract(),
885 R.javascript.LessThan(), R.simplified.NumberLessThan(), 897 R.javascript.Multiply(R.binop_hints),
886 R.javascript.LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(), 898 R.simplified.NumberMultiply(),
899 R.javascript.Divide(R.binop_hints),
900 R.simplified.NumberDivide(),
901 R.javascript.Modulus(R.binop_hints),
902 R.simplified.NumberModulus(),
903 R.javascript.LessThan(R.compare_hints),
904 R.simplified.NumberLessThan(),
905 R.javascript.LessThanOrEqual(R.compare_hints),
906 R.simplified.NumberLessThanOrEqual(),
887 }; 907 };
888 908
889 for (size_t j = 0; j < arraysize(ops); j += 2) { 909 for (size_t j = 0; j < arraysize(ops); j += 2) {
890 BinopEffectsTester B(ops[j], Type::Number(), Type::Number()); 910 BinopEffectsTester B(ops[j], Type::Number(), Type::Number());
891 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); 911 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode());
892 912
893 B.R.CheckBinop(B.result->opcode(), B.result); 913 B.R.CheckBinop(B.result->opcode(), B.result);
894 914
895 B.CheckNoOp(0); 915 B.CheckNoOp(0);
896 B.CheckNoOp(1); 916 B.CheckNoOp(1);
897 917
898 B.CheckEffectsRemoved(); 918 B.CheckEffectsRemoved();
899 } 919 }
900 } 920 }
901 921
902 922
903 TEST(OrderNumberBinopEffects1) { 923 TEST(OrderNumberBinopEffects1) {
904 JSTypedLoweringTester R; 924 JSTypedLoweringTester R;
905 925
906 const Operator* ops[] = { 926 const Operator* ops[] = {
907 R.javascript.Subtract(R.hints), R.simplified.NumberSubtract(), 927 R.javascript.Subtract(R.binop_hints), R.simplified.NumberSubtract(),
908 R.javascript.Multiply(R.hints), R.simplified.NumberMultiply(), 928 R.javascript.Multiply(R.binop_hints), R.simplified.NumberMultiply(),
909 R.javascript.Divide(R.hints), R.simplified.NumberDivide(), 929 R.javascript.Divide(R.binop_hints), R.simplified.NumberDivide(),
910 }; 930 };
911 931
912 for (size_t j = 0; j < arraysize(ops); j += 2) { 932 for (size_t j = 0; j < arraysize(ops); j += 2) {
913 BinopEffectsTester B(ops[j], Type::Symbol(), Type::Symbol()); 933 BinopEffectsTester B(ops[j], Type::Symbol(), Type::Symbol());
914 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); 934 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode());
915 935
916 Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true); 936 Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true);
917 Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true); 937 Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true);
918 938
919 CHECK_EQ(B.p0, i0->InputAt(0)); 939 CHECK_EQ(B.p0, i0->InputAt(0));
920 CHECK_EQ(B.p1, i1->InputAt(0)); 940 CHECK_EQ(B.p1, i1->InputAt(0));
921 941
922 // Effects should be ordered start -> i0 -> i1 -> effect_use 942 // Effects should be ordered start -> i0 -> i1 -> effect_use
923 B.CheckEffectOrdering(i0, i1); 943 B.CheckEffectOrdering(i0, i1);
924 } 944 }
925 } 945 }
926 946
927 947
928 TEST(OrderNumberBinopEffects2) { 948 TEST(OrderNumberBinopEffects2) {
929 JSTypedLoweringTester R; 949 JSTypedLoweringTester R;
930 950
931 const Operator* ops[] = { 951 const Operator* ops[] = {
932 R.javascript.Add(R.hints), R.simplified.NumberAdd(), 952 R.javascript.Add(R.binop_hints), R.simplified.NumberAdd(),
933 R.javascript.Subtract(R.hints), R.simplified.NumberSubtract(), 953 R.javascript.Subtract(R.binop_hints), R.simplified.NumberSubtract(),
934 R.javascript.Multiply(R.hints), R.simplified.NumberMultiply(), 954 R.javascript.Multiply(R.binop_hints), R.simplified.NumberMultiply(),
935 R.javascript.Divide(R.hints), R.simplified.NumberDivide(), 955 R.javascript.Divide(R.binop_hints), R.simplified.NumberDivide(),
936 }; 956 };
937 957
938 for (size_t j = 0; j < arraysize(ops); j += 2) { 958 for (size_t j = 0; j < arraysize(ops); j += 2) {
939 BinopEffectsTester B(ops[j], Type::Number(), Type::Symbol()); 959 BinopEffectsTester B(ops[j], Type::Number(), Type::Symbol());
940 960
941 Node* i0 = B.CheckNoOp(0); 961 Node* i0 = B.CheckNoOp(0);
942 Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true); 962 Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true);
943 963
944 CHECK_EQ(B.p0, i0); 964 CHECK_EQ(B.p0, i0);
945 CHECK_EQ(B.p1, i1->InputAt(0)); 965 CHECK_EQ(B.p1, i1->InputAt(0));
(...skipping 14 matching lines...) Expand all
960 // Effects should be ordered start -> i0 -> effect_use 980 // Effects should be ordered start -> i0 -> effect_use
961 B.CheckEffectOrdering(i0); 981 B.CheckEffectOrdering(i0);
962 } 982 }
963 } 983 }
964 984
965 985
966 TEST(OrderCompareEffects) { 986 TEST(OrderCompareEffects) {
967 JSTypedLoweringTester R; 987 JSTypedLoweringTester R;
968 988
969 const Operator* ops[] = { 989 const Operator* ops[] = {
970 R.javascript.GreaterThan(), R.simplified.NumberLessThan(), 990 R.javascript.GreaterThan(R.compare_hints), R.simplified.NumberLessThan(),
971 R.javascript.GreaterThanOrEqual(), R.simplified.NumberLessThanOrEqual(), 991 R.javascript.GreaterThanOrEqual(R.compare_hints),
992 R.simplified.NumberLessThanOrEqual(),
972 }; 993 };
973 994
974 for (size_t j = 0; j < arraysize(ops); j += 2) { 995 for (size_t j = 0; j < arraysize(ops); j += 2) {
975 BinopEffectsTester B(ops[j], Type::Symbol(), Type::String()); 996 BinopEffectsTester B(ops[j], Type::Symbol(), Type::String());
976 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); 997 CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode());
977 998
978 Node* i0 = B.CheckConvertedInput(IrOpcode::kStringToNumber, 0, false); 999 Node* i0 = B.CheckConvertedInput(IrOpcode::kStringToNumber, 0, false);
979 Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true); 1000 Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true);
980 1001
981 // Inputs should be commuted. 1002 // Inputs should be commuted.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 1192
1172 struct Entry { 1193 struct Entry {
1173 const Operator* js_op; 1194 const Operator* js_op;
1174 const Operator* uint_op; 1195 const Operator* uint_op;
1175 const Operator* int_op; 1196 const Operator* int_op;
1176 const Operator* num_op; 1197 const Operator* num_op;
1177 bool commute; 1198 bool commute;
1178 }; 1199 };
1179 1200
1180 Entry ops[] = { 1201 Entry ops[] = {
1181 {R.javascript.LessThan(), R.machine.Uint32LessThan(), 1202 {R.javascript.LessThan(R.compare_hints), R.machine.Uint32LessThan(),
1182 R.machine.Int32LessThan(), R.simplified.NumberLessThan(), false}, 1203 R.machine.Int32LessThan(), R.simplified.NumberLessThan(), false},
1183 {R.javascript.LessThanOrEqual(), R.machine.Uint32LessThanOrEqual(), 1204 {R.javascript.LessThanOrEqual(R.compare_hints),
1184 R.machine.Int32LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(), 1205 R.machine.Uint32LessThanOrEqual(), R.machine.Int32LessThanOrEqual(),
1185 false}, 1206 R.simplified.NumberLessThanOrEqual(), false},
1186 {R.javascript.GreaterThan(), R.machine.Uint32LessThan(), 1207 {R.javascript.GreaterThan(R.compare_hints), R.machine.Uint32LessThan(),
1187 R.machine.Int32LessThan(), R.simplified.NumberLessThan(), true}, 1208 R.machine.Int32LessThan(), R.simplified.NumberLessThan(), true},
1188 {R.javascript.GreaterThanOrEqual(), R.machine.Uint32LessThanOrEqual(), 1209 {R.javascript.GreaterThanOrEqual(R.compare_hints),
1189 R.machine.Int32LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(), 1210 R.machine.Uint32LessThanOrEqual(), R.machine.Int32LessThanOrEqual(),
1190 true}}; 1211 R.simplified.NumberLessThanOrEqual(), true}};
1191 1212
1192 for (size_t o = 0; o < arraysize(ops); o++) { 1213 for (size_t o = 0; o < arraysize(ops); o++) {
1193 for (size_t i = 0; i < arraysize(kNumberTypes); i++) { 1214 for (size_t i = 0; i < arraysize(kNumberTypes); i++) {
1194 Type* t0 = kNumberTypes[i]; 1215 Type* t0 = kNumberTypes[i];
1195 Node* p0 = R.Parameter(t0, 0); 1216 Node* p0 = R.Parameter(t0, 0);
1196 1217
1197 for (size_t j = 0; j < arraysize(kNumberTypes); j++) { 1218 for (size_t j = 0; j < arraysize(kNumberTypes); j++) {
1198 Type* t1 = kNumberTypes[j]; 1219 Type* t1 = kNumberTypes[j];
1199 Node* p1 = R.Parameter(t1, 1); 1220 Node* p1 = R.Parameter(t1, 1);
1200 1221
(...skipping 17 matching lines...) Expand all
1218 CHECK_EQ(p1, r->InputAt(1)); 1239 CHECK_EQ(p1, r->InputAt(1));
1219 } 1240 }
1220 } 1241 }
1221 } 1242 }
1222 } 1243 }
1223 } 1244 }
1224 1245
1225 } // namespace compiler 1246 } // namespace compiler
1226 } // namespace internal 1247 } // namespace internal
1227 } // namespace v8 1248 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | test/unittests/compiler/js-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698