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

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

Issue 1189153002: Revert of [strong] Implement strong mode restrictions on property access (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 | « test/unittests/compiler/js-type-feedback-unittest.cc ('k') | no next file » | 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/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // JSLoadProperty 643 // JSLoadProperty
644 644
645 645
646 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) { 646 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) {
647 const size_t kLength = 17; 647 const size_t kLength = 17;
648 double backing_store[kLength]; 648 double backing_store[kLength];
649 Handle<JSArrayBuffer> buffer = 649 Handle<JSArrayBuffer> buffer =
650 NewArrayBuffer(backing_store, sizeof(backing_store)); 650 NewArrayBuffer(backing_store, sizeof(backing_store));
651 ResolvedFeedbackSlot feedback; 651 ResolvedFeedbackSlot feedback;
652 TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) { 652 TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
653 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { 653 Handle<JSTypedArray> array =
654 Handle<JSTypedArray> array = 654 factory()->NewJSTypedArray(type, buffer, 0, kLength);
655 factory()->NewJSTypedArray(type, buffer, 0, kLength); 655 int const element_size = static_cast<int>(array->element_size());
656 int const element_size = static_cast<int>(array->element_size());
657 656
658 Node* key = Parameter( 657 Node* key = Parameter(
659 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone())); 658 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone()));
660 Node* base = HeapConstant(array); 659 Node* base = HeapConstant(array);
661 Node* vector = UndefinedConstant(); 660 Node* vector = UndefinedConstant();
662 Node* context = UndefinedConstant(); 661 Node* context = UndefinedConstant();
663 Node* effect = graph()->start(); 662 Node* effect = graph()->start();
664 Node* control = graph()->start(); 663 Node* control = graph()->start();
665 Reduction r = Reduce( 664 Reduction r = Reduce(graph()->NewNode(
666 graph()->NewNode(javascript()->LoadProperty(feedback, language_mode), 665 javascript()->LoadProperty(feedback), base, key, vector, context,
667 base, key, vector, context, EmptyFrameState(), 666 EmptyFrameState(), EmptyFrameState(), effect, control));
668 EmptyFrameState(), effect, control));
669 667
670 Matcher<Node*> offset_matcher = 668 Matcher<Node*> offset_matcher =
671 element_size == 1 669 element_size == 1
672 ? key 670 ? key
673 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size))); 671 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size)));
674 672
675 ASSERT_TRUE(r.Changed()); 673 ASSERT_TRUE(r.Changed());
676 EXPECT_THAT( 674 EXPECT_THAT(
677 r.replacement(), 675 r.replacement(),
678 IsLoadBuffer(BufferAccess(type), 676 IsLoadBuffer(BufferAccess(type),
679 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 677 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
680 offset_matcher, 678 offset_matcher,
681 IsNumberConstant(array->byte_length()->Number()), effect, 679 IsNumberConstant(array->byte_length()->Number()), effect,
682 control)); 680 control));
683 }
684 } 681 }
685 } 682 }
686 683
687 684
688 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArrayWithSafeKey) { 685 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArrayWithSafeKey) {
689 const size_t kLength = 17; 686 const size_t kLength = 17;
690 double backing_store[kLength]; 687 double backing_store[kLength];
691 Handle<JSArrayBuffer> buffer = 688 Handle<JSArrayBuffer> buffer =
692 NewArrayBuffer(backing_store, sizeof(backing_store)); 689 NewArrayBuffer(backing_store, sizeof(backing_store));
693 ResolvedFeedbackSlot feedback; 690 ResolvedFeedbackSlot feedback;
694 TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) { 691 TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
695 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { 692 Handle<JSTypedArray> array =
696 Handle<JSTypedArray> array = 693 factory()->NewJSTypedArray(type, buffer, 0, kLength);
697 factory()->NewJSTypedArray(type, buffer, 0, kLength); 694 ElementAccess access = AccessBuilder::ForTypedArrayElement(type, true);
698 ElementAccess access = AccessBuilder::ForTypedArrayElement(type, true);
699 695
700 int min = random_number_generator()->NextInt(static_cast<int>(kLength)); 696 int min = random_number_generator()->NextInt(static_cast<int>(kLength));
701 int max = random_number_generator()->NextInt(static_cast<int>(kLength)); 697 int max = random_number_generator()->NextInt(static_cast<int>(kLength));
702 if (min > max) std::swap(min, max); 698 if (min > max) std::swap(min, max);
703 Node* key = Parameter(Type::Range(min, max, zone())); 699 Node* key = Parameter(Type::Range(min, max, zone()));
704 Node* base = HeapConstant(array); 700 Node* base = HeapConstant(array);
705 Node* vector = UndefinedConstant(); 701 Node* vector = UndefinedConstant();
706 Node* context = UndefinedConstant(); 702 Node* context = UndefinedConstant();
707 Node* effect = graph()->start(); 703 Node* effect = graph()->start();
708 Node* control = graph()->start(); 704 Node* control = graph()->start();
709 Reduction r = Reduce( 705 Reduction r = Reduce(graph()->NewNode(
710 graph()->NewNode(javascript()->LoadProperty(feedback, language_mode), 706 javascript()->LoadProperty(feedback), base, key, vector, context,
711 base, key, vector, context, EmptyFrameState(), 707 EmptyFrameState(), EmptyFrameState(), effect, control));
712 EmptyFrameState(), effect, control));
713 708
714 ASSERT_TRUE(r.Changed()); 709 ASSERT_TRUE(r.Changed());
715 EXPECT_THAT( 710 EXPECT_THAT(
716 r.replacement(), 711 r.replacement(),
717 IsLoadElement(access, 712 IsLoadElement(access,
718 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 713 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
719 key, effect, control)); 714 key, effect, control));
720 }
721 } 715 }
722 } 716 }
723 717
724 718
725 // ----------------------------------------------------------------------------- 719 // -----------------------------------------------------------------------------
726 // JSStoreProperty 720 // JSStoreProperty
727 721
728 722
729 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) { 723 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) {
730 const size_t kLength = 17; 724 const size_t kLength = 17;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 IsNumberConstant(IsNaN()) // -- 878 IsNumberConstant(IsNaN()) // --
885 }; 879 };
886 880
887 ResolvedFeedbackSlot feedback; 881 ResolvedFeedbackSlot feedback;
888 Node* global = Parameter(Type::GlobalObject()); 882 Node* global = Parameter(Type::GlobalObject());
889 Node* vector = UndefinedConstant(); 883 Node* vector = UndefinedConstant();
890 Node* context = UndefinedConstant(); 884 Node* context = UndefinedConstant();
891 Node* effect = graph()->start(); 885 Node* effect = graph()->start();
892 Node* control = graph()->start(); 886 Node* control = graph()->start();
893 887
894 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { 888 for (size_t i = 0; i < arraysize(names); i++) {
895 for (size_t i = 0; i < arraysize(names); i++) { 889 Unique<Name> name = Unique<Name>::CreateImmovable(names[i]);
896 Unique<Name> name = Unique<Name>::CreateImmovable(names[i]); 890 Reduction r = Reduce(graph()->NewNode(
897 Reduction r = Reduce(graph()->NewNode( 891 javascript()->LoadNamed(name, feedback), global, vector, context,
898 javascript()->LoadNamed(name, feedback, language_mode), global, 892 EmptyFrameState(), EmptyFrameState(), effect, control));
899 vector, context, EmptyFrameState(), EmptyFrameState(), effect,
900 control));
901 893
902 ASSERT_TRUE(r.Changed()); 894 ASSERT_TRUE(r.Changed());
903 EXPECT_THAT(r.replacement(), matches[i]); 895 EXPECT_THAT(r.replacement(), matches[i]);
904 }
905 } 896 }
906 } 897 }
907 898
908 899
909 // ----------------------------------------------------------------------------- 900 // -----------------------------------------------------------------------------
910 // JSLoadDynamicGlobal 901 // JSLoadDynamicGlobal
911 902
912 903
913 TEST_F(JSTypedLoweringTest, JSLoadDynamicGlobal) { 904 TEST_F(JSTypedLoweringTest, JSLoadDynamicGlobal) {
914 Node* const context = Parameter(Type::Any()); 905 Node* const context = Parameter(Type::Any());
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 EXPECT_THAT(r.replacement(), 1087 EXPECT_THAT(r.replacement(),
1097 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( 1088 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor(
1098 Context::MIN_CONTEXT_SLOTS)), 1089 Context::MIN_CONTEXT_SLOTS)),
1099 effect, control), 1090 effect, control),
1100 _)); 1091 _));
1101 } 1092 }
1102 1093
1103 } // namespace compiler 1094 } // namespace compiler
1104 } // namespace internal 1095 } // namespace internal
1105 } // namespace v8 1096 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/js-type-feedback-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698