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

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

Issue 1131263002: [turbofan] Work towards fixing asm.js heap access. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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/simplified-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/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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 value, effect, control)); 634 value, effect, control));
635 } 635 }
636 } 636 }
637 } 637 }
638 638
639 639
640 // ----------------------------------------------------------------------------- 640 // -----------------------------------------------------------------------------
641 // JSLoadProperty 641 // JSLoadProperty
642 642
643 643
644 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) {
645 const size_t kLength = 17;
646 double backing_store[kLength];
647 Handle<JSArrayBuffer> buffer =
648 NewArrayBuffer(backing_store, sizeof(backing_store));
649 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(),
650 FeedbackVectorICSlot::Invalid());
651 TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
652 Handle<JSTypedArray> array =
653 factory()->NewJSTypedArray(type, buffer, 0, kLength);
654 int const element_size = static_cast<int>(array->element_size());
655
656 Node* key = Parameter(
657 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone()));
658 Node* base = HeapConstant(array);
659 Node* context = UndefinedConstant();
660 Node* effect = graph()->start();
661 Node* control = graph()->start();
662 Reduction r =
663 Reduce(graph()->NewNode(javascript()->LoadProperty(feedback), base, key,
664 context, EmptyFrameState(), effect, control));
665
666 Matcher<Node*> offset_matcher =
667 element_size == 1
668 ? key
669 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size)));
670
671 ASSERT_TRUE(r.Changed());
672 EXPECT_THAT(
673 r.replacement(),
674 IsLoadBuffer(BufferAccess(type),
675 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
676 offset_matcher,
677 IsNumberConstant(array->byte_length()->Number()), effect,
678 control));
679 }
680 }
681
682
683 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArrayWithSafeKey) { 644 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArrayWithSafeKey) {
684 const size_t kLength = 17; 645 const size_t kLength = 17;
685 double backing_store[kLength]; 646 double backing_store[kLength];
686 Handle<JSArrayBuffer> buffer = 647 Handle<JSArrayBuffer> buffer =
687 NewArrayBuffer(backing_store, sizeof(backing_store)); 648 NewArrayBuffer(backing_store, sizeof(backing_store));
688 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(), 649 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(),
689 FeedbackVectorICSlot::Invalid()); 650 FeedbackVectorICSlot::Invalid());
690 TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) { 651 TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
691 Handle<JSTypedArray> array = 652 Handle<JSTypedArray> array =
692 factory()->NewJSTypedArray(type, buffer, 0, kLength); 653 factory()->NewJSTypedArray(type, buffer, 0, kLength);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 EXPECT_THAT(r.replacement(), 948 EXPECT_THAT(r.replacement(),
988 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( 949 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor(
989 Context::MIN_CONTEXT_SLOTS)), 950 Context::MIN_CONTEXT_SLOTS)),
990 effect, control), 951 effect, control),
991 _)); 952 _));
992 } 953 }
993 954
994 } // namespace compiler 955 } // namespace compiler
995 } // namespace internal 956 } // namespace internal
996 } // namespace v8 957 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | test/unittests/compiler/simplified-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698