OLD | NEW |
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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 factory()->NewJSTypedArray(type, buffer, 0, kLength); | 725 factory()->NewJSTypedArray(type, buffer, 0, kLength); |
726 int const element_size = static_cast<int>(array->element_size()); | 726 int const element_size = static_cast<int>(array->element_size()); |
727 | 727 |
728 Node* key = Parameter( | 728 Node* key = Parameter( |
729 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone())); | 729 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone())); |
730 Node* base = HeapConstant(array); | 730 Node* base = HeapConstant(array); |
731 Node* value = Parameter(Type::PlainPrimitive()); | 731 Node* value = Parameter(Type::PlainPrimitive()); |
732 Node* context = UndefinedConstant(); | 732 Node* context = UndefinedConstant(); |
733 Node* effect = graph()->start(); | 733 Node* effect = graph()->start(); |
734 Node* control = graph()->start(); | 734 Node* control = graph()->start(); |
735 // TODO(mstarzinger): Once the effect-control-linearizer provides a frame | |
736 // state we can get rid of this checkpoint again. The reducer won't care. | |
737 Node* checkpoint = graph()->NewNode(common()->Checkpoint(), | |
738 EmptyFrameState(), effect, control); | |
739 VectorSlotPair feedback; | 735 VectorSlotPair feedback; |
740 const Operator* op = javascript()->StoreProperty(language_mode, feedback); | 736 const Operator* op = javascript()->StoreProperty(language_mode, feedback); |
741 Node* node = graph()->NewNode(op, base, key, value, context, | 737 Node* node = graph()->NewNode(op, base, key, value, context, |
742 EmptyFrameState(), checkpoint, control); | 738 EmptyFrameState(), effect, control); |
743 Reduction r = Reduce(node); | 739 Reduction r = Reduce(node); |
744 | 740 |
745 Matcher<Node*> offset_matcher = | 741 Matcher<Node*> offset_matcher = |
746 element_size == 1 | 742 element_size == 1 |
747 ? key | 743 ? key |
748 : IsNumberShiftLeft( | 744 : IsNumberShiftLeft( |
749 key, IsNumberConstant(WhichPowerOf2(element_size))); | 745 key, IsNumberConstant(WhichPowerOf2(element_size))); |
750 | 746 |
751 Matcher<Node*> value_matcher = IsPlainPrimitiveToNumber(value); | 747 Matcher<Node*> value_matcher = IsPlainPrimitiveToNumber(value); |
752 | 748 |
753 ASSERT_TRUE(r.Changed()); | 749 ASSERT_TRUE(r.Changed()); |
754 EXPECT_THAT( | 750 EXPECT_THAT( |
755 r.replacement(), | 751 r.replacement(), |
756 IsStoreBuffer( | 752 IsStoreBuffer( |
757 BufferAccess(type), | 753 BufferAccess(type), |
758 IsPointerConstant(bit_cast<intptr_t>(&backing_store[0])), | 754 IsPointerConstant(bit_cast<intptr_t>(&backing_store[0])), |
759 offset_matcher, IsNumberConstant(array->byte_length()->Number()), | 755 offset_matcher, IsNumberConstant(array->byte_length()->Number()), |
760 value_matcher, checkpoint, control)); | 756 value_matcher, effect, control)); |
761 } | 757 } |
762 } | 758 } |
763 } | 759 } |
764 | 760 |
765 | 761 |
766 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithSafeKey) { | 762 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithSafeKey) { |
767 const size_t kLength = 17; | 763 const size_t kLength = 17; |
768 double backing_store[kLength]; | 764 double backing_store[kLength]; |
769 Handle<JSArrayBuffer> buffer = | 765 Handle<JSArrayBuffer> buffer = |
770 NewArrayBuffer(backing_store, sizeof(backing_store)); | 766 NewArrayBuffer(backing_store, sizeof(backing_store)); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 EmptyFrameState(), effect, control)); | 1014 EmptyFrameState(), effect, control)); |
1019 ASSERT_TRUE(r.Changed()); | 1015 ASSERT_TRUE(r.Changed()); |
1020 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( | 1016 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( |
1021 NumberOperationHint::kNumberOrOddball, lhs, | 1017 NumberOperationHint::kNumberOrOddball, lhs, |
1022 rhs, effect, control)); | 1018 rhs, effect, control)); |
1023 } | 1019 } |
1024 | 1020 |
1025 } // namespace compiler | 1021 } // namespace compiler |
1026 } // namespace internal | 1022 } // namespace internal |
1027 } // namespace v8 | 1023 } // namespace v8 |
OLD | NEW |