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

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

Issue 2494753003: [turbofan] Introduce an ExternalPointer type. (Closed)
Patch Set: Stronger ducktape. Created 4 years, 1 month 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/compiler/js-typed-lowering.h" 5 #include "src/compiler/js-typed-lowering.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/compilation-dependencies.h" 7 #include "src/compilation-dependencies.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/js-operator.h" 10 #include "src/compiler/js-operator.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 zone()); 63 zone());
64 return reducer.Reduce(node); 64 return reducer.Reduce(node);
65 } 65 }
66 66
67 Handle<JSArrayBuffer> NewArrayBuffer(void* bytes, size_t byte_length) { 67 Handle<JSArrayBuffer> NewArrayBuffer(void* bytes, size_t byte_length) {
68 Handle<JSArrayBuffer> buffer = factory()->NewJSArrayBuffer(); 68 Handle<JSArrayBuffer> buffer = factory()->NewJSArrayBuffer();
69 JSArrayBuffer::Setup(buffer, isolate(), true, bytes, byte_length); 69 JSArrayBuffer::Setup(buffer, isolate(), true, bytes, byte_length);
70 return buffer; 70 return buffer;
71 } 71 }
72 72
73 Matcher<Node*> IsIntPtrConstant(intptr_t value) {
74 return sizeof(value) == 4 ? IsInt32Constant(static_cast<int32_t>(value))
75 : IsInt64Constant(static_cast<int64_t>(value));
76 }
77
78 JSOperatorBuilder* javascript() { return &javascript_; } 73 JSOperatorBuilder* javascript() { return &javascript_; }
79 74
80 private: 75 private:
81 JSOperatorBuilder javascript_; 76 JSOperatorBuilder javascript_;
82 CompilationDependencies deps_; 77 CompilationDependencies deps_;
83 }; 78 };
84 79
85 80
86 // ----------------------------------------------------------------------------- 81 // -----------------------------------------------------------------------------
87 // JSToBoolean 82 // JSToBoolean
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 Matcher<Node*> offset_matcher = 557 Matcher<Node*> offset_matcher =
563 element_size == 1 558 element_size == 1
564 ? key 559 ? key
565 : IsNumberShiftLeft(key, 560 : IsNumberShiftLeft(key,
566 IsNumberConstant(WhichPowerOf2(element_size))); 561 IsNumberConstant(WhichPowerOf2(element_size)));
567 562
568 ASSERT_TRUE(r.Changed()); 563 ASSERT_TRUE(r.Changed());
569 EXPECT_THAT( 564 EXPECT_THAT(
570 r.replacement(), 565 r.replacement(),
571 IsLoadBuffer(BufferAccess(type), 566 IsLoadBuffer(BufferAccess(type),
572 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 567 IsPointerConstant(bit_cast<intptr_t>(&backing_store[0])),
573 offset_matcher, 568 offset_matcher,
574 IsNumberConstant(array->byte_length()->Number()), effect, 569 IsNumberConstant(array->byte_length()->Number()), effect,
575 control)); 570 control));
576 } 571 }
577 } 572 }
578 573
579 574
580 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArrayWithSafeKey) { 575 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArrayWithSafeKey) {
581 const size_t kLength = 17; 576 const size_t kLength = 17;
582 double backing_store[kLength]; 577 double backing_store[kLength];
(...skipping 15 matching lines...) Expand all
598 Node* effect = graph()->start(); 593 Node* effect = graph()->start();
599 Node* control = graph()->start(); 594 Node* control = graph()->start();
600 Reduction r = Reduce(graph()->NewNode(javascript()->LoadProperty(feedback), 595 Reduction r = Reduce(graph()->NewNode(javascript()->LoadProperty(feedback),
601 base, key, vector, context, 596 base, key, vector, context,
602 EmptyFrameState(), effect, control)); 597 EmptyFrameState(), effect, control));
603 598
604 ASSERT_TRUE(r.Changed()); 599 ASSERT_TRUE(r.Changed());
605 EXPECT_THAT( 600 EXPECT_THAT(
606 r.replacement(), 601 r.replacement(),
607 IsLoadElement(access, 602 IsLoadElement(access,
608 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 603 IsPointerConstant(bit_cast<intptr_t>(&backing_store[0])),
609 key, effect, control)); 604 key, effect, control));
610 } 605 }
611 } 606 }
612 607
613 608
614 // ----------------------------------------------------------------------------- 609 // -----------------------------------------------------------------------------
615 // JSStoreProperty 610 // JSStoreProperty
616 611
617 612
618 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) { 613 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) {
(...skipping 24 matching lines...) Expand all
643 638
644 Matcher<Node*> offset_matcher = 639 Matcher<Node*> offset_matcher =
645 element_size == 1 640 element_size == 1
646 ? key 641 ? key
647 : IsNumberShiftLeft( 642 : IsNumberShiftLeft(
648 key, IsNumberConstant(WhichPowerOf2(element_size))); 643 key, IsNumberConstant(WhichPowerOf2(element_size)));
649 644
650 ASSERT_TRUE(r.Changed()); 645 ASSERT_TRUE(r.Changed());
651 EXPECT_THAT( 646 EXPECT_THAT(
652 r.replacement(), 647 r.replacement(),
653 IsStoreBuffer(BufferAccess(type), 648 IsStoreBuffer(
654 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 649 BufferAccess(type),
655 offset_matcher, 650 IsPointerConstant(bit_cast<intptr_t>(&backing_store[0])),
656 IsNumberConstant(array->byte_length()->Number()), value, 651 offset_matcher, IsNumberConstant(array->byte_length()->Number()),
657 effect, control)); 652 value, effect, control));
658 } 653 }
659 } 654 }
660 } 655 }
661 656
662 657
663 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithConversion) { 658 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithConversion) {
664 const size_t kLength = 17; 659 const size_t kLength = 17;
665 double backing_store[kLength]; 660 double backing_store[kLength];
666 Handle<JSArrayBuffer> buffer = 661 Handle<JSArrayBuffer> buffer =
667 NewArrayBuffer(backing_store, sizeof(backing_store)); 662 NewArrayBuffer(backing_store, sizeof(backing_store));
(...skipping 28 matching lines...) Expand all
696 key, IsNumberConstant(WhichPowerOf2(element_size))); 691 key, IsNumberConstant(WhichPowerOf2(element_size)));
697 692
698 Matcher<Node*> value_matcher = 693 Matcher<Node*> value_matcher =
699 IsToNumber(value, context, checkpoint, control); 694 IsToNumber(value, context, checkpoint, control);
700 Matcher<Node*> effect_matcher = value_matcher; 695 Matcher<Node*> effect_matcher = value_matcher;
701 Matcher<Node*> control_matcher = IsIfSuccess(value_matcher); 696 Matcher<Node*> control_matcher = IsIfSuccess(value_matcher);
702 697
703 ASSERT_TRUE(r.Changed()); 698 ASSERT_TRUE(r.Changed());
704 EXPECT_THAT( 699 EXPECT_THAT(
705 r.replacement(), 700 r.replacement(),
706 IsStoreBuffer(BufferAccess(type), 701 IsStoreBuffer(
707 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 702 BufferAccess(type),
708 offset_matcher, 703 IsPointerConstant(bit_cast<intptr_t>(&backing_store[0])),
709 IsNumberConstant(array->byte_length()->Number()), 704 offset_matcher, IsNumberConstant(array->byte_length()->Number()),
710 value_matcher, effect_matcher, control_matcher)); 705 value_matcher, effect_matcher, control_matcher));
711 } 706 }
712 } 707 }
713 } 708 }
714 709
715 710
716 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithSafeKey) { 711 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithSafeKey) {
717 const size_t kLength = 17; 712 const size_t kLength = 17;
718 double backing_store[kLength]; 713 double backing_store[kLength];
719 Handle<JSArrayBuffer> buffer = 714 Handle<JSArrayBuffer> buffer =
720 NewArrayBuffer(backing_store, sizeof(backing_store)); 715 NewArrayBuffer(backing_store, sizeof(backing_store));
(...skipping 16 matching lines...) Expand all
737 VectorSlotPair feedback; 732 VectorSlotPair feedback;
738 const Operator* op = javascript()->StoreProperty(language_mode, feedback); 733 const Operator* op = javascript()->StoreProperty(language_mode, feedback);
739 Node* node = graph()->NewNode(op, base, key, value, vector, context, 734 Node* node = graph()->NewNode(op, base, key, value, vector, context,
740 EmptyFrameState(), effect, control); 735 EmptyFrameState(), effect, control);
741 Reduction r = Reduce(node); 736 Reduction r = Reduce(node);
742 737
743 ASSERT_TRUE(r.Changed()); 738 ASSERT_TRUE(r.Changed());
744 EXPECT_THAT( 739 EXPECT_THAT(
745 r.replacement(), 740 r.replacement(),
746 IsStoreElement( 741 IsStoreElement(
747 access, IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 742 access, IsPointerConstant(bit_cast<intptr_t>(&backing_store[0])),
748 key, value, effect, control)); 743 key, value, effect, control));
749 } 744 }
750 } 745 }
751 } 746 }
752 747
753 748
754 // ----------------------------------------------------------------------------- 749 // -----------------------------------------------------------------------------
755 // JSLoadNamed 750 // JSLoadNamed
756 751
757 752
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 EmptyFrameState(), effect, control)); 1002 EmptyFrameState(), effect, control));
1008 ASSERT_TRUE(r.Changed()); 1003 ASSERT_TRUE(r.Changed());
1009 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( 1004 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor(
1010 NumberOperationHint::kNumberOrOddball, lhs, 1005 NumberOperationHint::kNumberOrOddball, lhs,
1011 rhs, effect, control)); 1006 rhs, effect, control));
1012 } 1007 }
1013 1008
1014 } // namespace compiler 1009 } // namespace compiler
1015 } // namespace internal 1010 } // namespace internal
1016 } // namespace v8 1011 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/escape-analysis-unittest.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698