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

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

Issue 999173003: [turbofan] Remove indirection in JSToBoolean/JSUnaryNot lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comment. Created 5 years, 9 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/cctest/compiler/test-simplified-lowering.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/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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 Type::String()}; 500 Type::String()};
501 501
502 for (size_t i = 0; i < arraysize(others); i++) { 502 for (size_t i = 0; i < arraysize(others); i++) {
503 Type* t = Type::Union(Type::Number(), others[i], R.main_zone()); 503 Type* t = Type::Union(Type::Number(), others[i], R.main_zone());
504 Node* r = R.ReduceUnop(R.javascript.ToNumber(), t); 504 Node* r = R.ReduceUnop(R.javascript.ToNumber(), t);
505 CHECK_EQ(IrOpcode::kJSToNumber, r->opcode()); 505 CHECK_EQ(IrOpcode::kJSToNumber, r->opcode());
506 } 506 }
507 } 507 }
508 508
509 509
510 TEST(JSToBoolean) {
511 JSTypedLoweringTester R;
512 const Operator* op = R.javascript.ToBoolean();
513
514 { // ToBoolean(undefined)
515 Node* r = R.ReduceUnop(op, Type::Undefined());
516 R.CheckFalse(r);
517 }
518
519 { // ToBoolean(null)
520 Node* r = R.ReduceUnop(op, Type::Null());
521 R.CheckFalse(r);
522 }
523
524 { // ToBoolean(boolean)
525 Node* r = R.ReduceUnop(op, Type::Boolean());
526 CHECK_EQ(IrOpcode::kParameter, r->opcode());
527 }
528
529 { // ToBoolean(object)
530 Node* r = R.ReduceUnop(op, Type::DetectableObject());
531 R.CheckTrue(r);
532 }
533
534 { // ToBoolean(undetectable)
535 Node* r = R.ReduceUnop(op, Type::Undetectable());
536 R.CheckFalse(r);
537 }
538
539 { // ToBoolean(object)
540 Node* r = R.ReduceUnop(op, Type::Object());
541 CHECK_EQ(IrOpcode::kAnyToBoolean, r->opcode());
542 }
543 }
544
545
546 TEST(JSToString1) { 510 TEST(JSToString1) {
547 JSTypedLoweringTester R; 511 JSTypedLoweringTester R;
548 512
549 for (size_t i = 0; i < arraysize(kStringTypes); i++) { 513 for (size_t i = 0; i < arraysize(kStringTypes); i++) {
550 Node* r = R.ReduceUnop(R.javascript.ToString(), kStringTypes[i]); 514 Node* r = R.ReduceUnop(R.javascript.ToString(), kStringTypes[i]);
551 CHECK_EQ(IrOpcode::kParameter, r->opcode()); 515 CHECK_EQ(IrOpcode::kParameter, r->opcode());
552 } 516 }
553 517
554 const Operator* op = R.javascript.ToString(); 518 const Operator* op = R.javascript.ToString();
555 519
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 681 }
718 } else { 682 } else {
719 CHECK_EQ(cmp, r); // No reduction of mixed types. 683 CHECK_EQ(cmp, r); // No reduction of mixed types.
720 } 684 }
721 } 685 }
722 } 686 }
723 } 687 }
724 } 688 }
725 689
726 690
727 TEST(UnaryNot) {
728 JSTypedLoweringTester R;
729 const Operator* opnot = R.javascript.UnaryNot();
730
731 for (size_t i = 0; i < arraysize(kJSTypes); i++) {
732 Node* orig = R.Unop(opnot, R.Parameter(kJSTypes[i]));
733 Node* r = R.reduce(orig);
734
735 if (r == orig && orig->opcode() == IrOpcode::kJSToBoolean) {
736 // The original node was turned into a ToBoolean.
737 CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode());
738 } else if (r->opcode() != IrOpcode::kHeapConstant) {
739 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode());
740 }
741 }
742 }
743
744
745 TEST(RemoveToNumberEffects) { 691 TEST(RemoveToNumberEffects) {
746 FLAG_turbo_deoptimization = true; 692 FLAG_turbo_deoptimization = true;
747 693
748 JSTypedLoweringTester R; 694 JSTypedLoweringTester R;
749 695
750 Node* effect_use = NULL; 696 Node* effect_use = NULL;
751 for (int i = 0; i < 10; i++) { 697 for (int i = 0; i < 10; i++) {
752 Node* p0 = R.Parameter(Type::Number()); 698 Node* p0 = R.Parameter(Type::Number());
753 Node* ton = R.Unop(R.javascript.ToNumber(), p0); 699 Node* ton = R.Unop(R.javascript.ToNumber(), p0);
754 Node* frame_state = R.EmptyFrameState(R.context()); 700 Node* frame_state = R.EmptyFrameState(R.context());
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 CHECK_EQ(p1, r->InputAt(0)); 1237 CHECK_EQ(p1, r->InputAt(0));
1292 CHECK_EQ(p0, r->InputAt(1)); 1238 CHECK_EQ(p0, r->InputAt(1));
1293 } else { 1239 } else {
1294 CHECK_EQ(p0, r->InputAt(0)); 1240 CHECK_EQ(p0, r->InputAt(0));
1295 CHECK_EQ(p1, r->InputAt(1)); 1241 CHECK_EQ(p1, r->InputAt(1));
1296 } 1242 }
1297 } 1243 }
1298 } 1244 }
1299 } 1245 }
1300 } 1246 }
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698