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

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

Issue 792463003: [turbofan] Turn JSToBoolean and JSUnaryNot into pure operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
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/v8.h" 5 #include "src/v8.h"
6 #include "test/cctest/cctest.h" 6 #include "test/cctest/cctest.h"
7 7
8 #include "src/compiler/graph-inl.h" 8 #include "src/compiler/graph-inl.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 540
541 TEST(JSToBoolean_replacement) { 541 TEST(JSToBoolean_replacement) {
542 JSTypedLoweringTester R; 542 JSTypedLoweringTester R;
543 543
544 Type* types[] = {Type::Null(), Type::Undefined(), 544 Type* types[] = {Type::Null(), Type::Undefined(),
545 Type::Boolean(), Type::OrderedNumber(), 545 Type::Boolean(), Type::OrderedNumber(),
546 Type::DetectableObject(), Type::Undetectable()}; 546 Type::DetectableObject(), Type::Undetectable()};
547 547
548 for (size_t i = 0; i < arraysize(types); i++) { 548 for (size_t i = 0; i < arraysize(types); i++) {
549 Node* n = R.Parameter(types[i]); 549 Node* n = R.Parameter(types[i]);
550 Node* c = R.graph.NewNode(R.javascript.ToBoolean(), n, R.context(), 550 Node* c = R.graph.NewNode(R.javascript.ToBoolean(), n, R.context());
551 R.start(), R.start());
552 Node* effect_use = R.UseForEffect(c);
553 Node* add = R.graph.NewNode(R.simplified.ReferenceEqual(Type::Any()), n, c);
554
555 R.CheckEffectInput(c, effect_use);
556 Node* r = R.reduce(c); 551 Node* r = R.reduce(c);
557 552
558 if (types[i]->Is(Type::Boolean())) { 553 if (types[i]->Is(Type::Boolean())) {
559 CHECK_EQ(n, r); 554 CHECK_EQ(n, r);
560 } else if (types[i]->Is(Type::OrderedNumber())) { 555 } else if (types[i]->Is(Type::OrderedNumber())) {
561 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); 556 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode());
562 } else { 557 } else {
563 CHECK_EQ(IrOpcode::kHeapConstant, r->opcode()); 558 CHECK_EQ(IrOpcode::kHeapConstant, r->opcode());
564 } 559 }
565
566 CHECK_EQ(n, add->InputAt(0));
567 CHECK_EQ(r, add->InputAt(1));
568 R.CheckEffectInput(R.start(), effect_use);
569 } 560 }
570 } 561 }
571 562
572 563
573 TEST(JSToString1) { 564 TEST(JSToString1) {
574 JSTypedLoweringTester R; 565 JSTypedLoweringTester R;
575 566
576 for (size_t i = 0; i < arraysize(kStringTypes); i++) { 567 for (size_t i = 0; i < arraysize(kStringTypes); i++) {
577 Node* r = R.ReduceUnop(R.javascript.ToString(), kStringTypes[i]); 568 Node* r = R.ReduceUnop(R.javascript.ToString(), kStringTypes[i]);
578 CHECK_EQ(IrOpcode::kParameter, r->opcode()); 569 CHECK_EQ(IrOpcode::kParameter, r->opcode());
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 741 }
751 } 742 }
752 743
753 744
754 TEST(UnaryNot) { 745 TEST(UnaryNot) {
755 JSTypedLoweringTester R; 746 JSTypedLoweringTester R;
756 const Operator* opnot = R.javascript.UnaryNot(); 747 const Operator* opnot = R.javascript.UnaryNot();
757 748
758 for (size_t i = 0; i < arraysize(kJSTypes); i++) { 749 for (size_t i = 0; i < arraysize(kJSTypes); i++) {
759 Node* orig = R.Unop(opnot, R.Parameter(kJSTypes[i])); 750 Node* orig = R.Unop(opnot, R.Parameter(kJSTypes[i]));
760 Node* use = R.graph.NewNode(R.common.Return(), orig);
761 Node* r = R.reduce(orig); 751 Node* r = R.reduce(orig);
762 // TODO(titzer): test will break if/when js-typed-lowering constant folds.
763 CHECK_EQ(IrOpcode::kBooleanNot, use->InputAt(0)->opcode());
764 752
765 if (r == orig && orig->opcode() == IrOpcode::kJSToBoolean) { 753 if (r == orig && orig->opcode() == IrOpcode::kJSToBoolean) {
766 // The original node was turned into a ToBoolean. 754 // The original node was turned into a ToBoolean.
767 CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode()); 755 CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode());
768 } else { 756 } else if (r->opcode() != IrOpcode::kHeapConstant) {
769 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); 757 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode());
770 } 758 }
771 } 759 }
772 } 760 }
773 761
774 762
775 TEST(RemoveToNumberEffects) { 763 TEST(RemoveToNumberEffects) {
776 FLAG_turbo_deoptimization = true; 764 FLAG_turbo_deoptimization = true;
777 765
778 JSTypedLoweringTester R; 766 JSTypedLoweringTester R;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 Node* ii1 = B.CheckConverted(IrOpcode::kJSToNumber, i1->InputAt(0), true); 1167 Node* ii1 = B.CheckConverted(IrOpcode::kJSToNumber, i1->InputAt(0), true);
1180 1168
1181 CHECK_EQ(B.p0, ii0->InputAt(0)); 1169 CHECK_EQ(B.p0, ii0->InputAt(0));
1182 CHECK_EQ(B.p1, ii1->InputAt(0)); 1170 CHECK_EQ(B.p1, ii1->InputAt(0));
1183 1171
1184 B.CheckEffectOrdering(ii0, ii1); 1172 B.CheckEffectOrdering(ii0, ii1);
1185 } 1173 }
1186 } 1174 }
1187 1175
1188 1176
1189 TEST(UnaryNotEffects) {
1190 JSTypedLoweringTester R;
1191 const Operator* opnot = R.javascript.UnaryNot();
1192
1193 for (size_t i = 0; i < arraysize(kJSTypes); i++) {
1194 Node* p0 = R.Parameter(kJSTypes[i], 0);
1195 Node* orig = R.Unop(opnot, p0);
1196 Node* effect_use = R.UseForEffect(orig);
1197 Node* value_use = R.graph.NewNode(R.common.Return(), orig);
1198 Node* r = R.reduce(orig);
1199 // TODO(titzer): test will break if/when js-typed-lowering constant folds.
1200 CHECK_EQ(IrOpcode::kBooleanNot, value_use->InputAt(0)->opcode());
1201
1202 if (r == orig && orig->opcode() == IrOpcode::kJSToBoolean) {
1203 // The original node was turned into a ToBoolean, which has an effect.
1204 CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode());
1205 R.CheckEffectInput(R.start(), orig);
1206 R.CheckEffectInput(orig, effect_use);
1207 } else {
1208 // effect should have been removed from this node.
1209 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode());
1210 R.CheckEffectInput(R.start(), effect_use);
1211 }
1212 }
1213 }
1214
1215
1216 TEST(Int32AddNarrowing) { 1177 TEST(Int32AddNarrowing) {
1217 { 1178 {
1218 JSBitwiseTypedLoweringTester R; 1179 JSBitwiseTypedLoweringTester R;
1219 1180
1220 for (int o = 0; o < R.kNumberOps; o += 2) { 1181 for (int o = 0; o < R.kNumberOps; o += 2) {
1221 for (size_t i = 0; i < arraysize(kInt32Types); i++) { 1182 for (size_t i = 0; i < arraysize(kInt32Types); i++) {
1222 Node* n0 = R.Parameter(kInt32Types[i]); 1183 Node* n0 = R.Parameter(kInt32Types[i]);
1223 for (size_t j = 0; j < arraysize(kInt32Types); j++) { 1184 for (size_t j = 0; j < arraysize(kInt32Types); j++) {
1224 Node* n1 = R.Parameter(kInt32Types[j]); 1185 Node* n1 = R.Parameter(kInt32Types[j]);
1225 Node* one = R.graph.NewNode(R.common.NumberConstant(1)); 1186 Node* one = R.graph.NewNode(R.common.NumberConstant(1));
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 CHECK_EQ(p1, r->InputAt(0)); 1294 CHECK_EQ(p1, r->InputAt(0));
1334 CHECK_EQ(p0, r->InputAt(1)); 1295 CHECK_EQ(p0, r->InputAt(1));
1335 } else { 1296 } else {
1336 CHECK_EQ(p0, r->InputAt(0)); 1297 CHECK_EQ(p0, r->InputAt(0));
1337 CHECK_EQ(p1, r->InputAt(1)); 1298 CHECK_EQ(p1, r->InputAt(1));
1338 } 1299 }
1339 } 1300 }
1340 } 1301 }
1341 } 1302 }
1342 } 1303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698