| 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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 NewArrayBuffer(backing_store, sizeof(backing_store)); | 710 NewArrayBuffer(backing_store, sizeof(backing_store)); |
| 711 TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) { | 711 TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) { |
| 712 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 712 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 713 Handle<JSTypedArray> array = | 713 Handle<JSTypedArray> array = |
| 714 factory()->NewJSTypedArray(type, buffer, 0, kLength); | 714 factory()->NewJSTypedArray(type, buffer, 0, kLength); |
| 715 int const element_size = static_cast<int>(array->element_size()); | 715 int const element_size = static_cast<int>(array->element_size()); |
| 716 | 716 |
| 717 Node* key = Parameter( | 717 Node* key = Parameter( |
| 718 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone())); | 718 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone())); |
| 719 Node* base = HeapConstant(array); | 719 Node* base = HeapConstant(array); |
| 720 Node* value = Parameter(Type::Any()); | 720 Node* value = Parameter(Type::PlainPrimitive()); |
| 721 Node* context = UndefinedConstant(); | 721 Node* context = UndefinedConstant(); |
| 722 Node* effect = graph()->start(); | 722 Node* effect = graph()->start(); |
| 723 Node* control = graph()->start(); | 723 Node* control = graph()->start(); |
| 724 // TODO(mstarzinger): Once the effect-control-linearizer provides a frame | 724 // TODO(mstarzinger): Once the effect-control-linearizer provides a frame |
| 725 // state we can get rid of this checkpoint again. The reducer won't care. | 725 // state we can get rid of this checkpoint again. The reducer won't care. |
| 726 Node* checkpoint = graph()->NewNode(common()->Checkpoint(), | 726 Node* checkpoint = graph()->NewNode(common()->Checkpoint(), |
| 727 EmptyFrameState(), effect, control); | 727 EmptyFrameState(), effect, control); |
| 728 VectorSlotPair feedback; | 728 VectorSlotPair feedback; |
| 729 const Operator* op = javascript()->StoreProperty(language_mode, feedback); | 729 const Operator* op = javascript()->StoreProperty(language_mode, feedback); |
| 730 Node* node = graph()->NewNode(op, base, key, value, context, | 730 Node* node = graph()->NewNode(op, base, key, value, context, |
| 731 EmptyFrameState(), checkpoint, control); | 731 EmptyFrameState(), checkpoint, control); |
| 732 Reduction r = Reduce(node); | 732 Reduction r = Reduce(node); |
| 733 | 733 |
| 734 Matcher<Node*> offset_matcher = | 734 Matcher<Node*> offset_matcher = |
| 735 element_size == 1 | 735 element_size == 1 |
| 736 ? key | 736 ? key |
| 737 : IsNumberShiftLeft( | 737 : IsNumberShiftLeft( |
| 738 key, IsNumberConstant(WhichPowerOf2(element_size))); | 738 key, IsNumberConstant(WhichPowerOf2(element_size))); |
| 739 | 739 |
| 740 Matcher<Node*> value_matcher = | 740 Matcher<Node*> value_matcher = IsPlainPrimitiveToNumber(value); |
| 741 IsToNumber(value, context, checkpoint, control); | |
| 742 Matcher<Node*> effect_matcher = value_matcher; | |
| 743 Matcher<Node*> control_matcher = IsIfSuccess(value_matcher); | |
| 744 | 741 |
| 745 ASSERT_TRUE(r.Changed()); | 742 ASSERT_TRUE(r.Changed()); |
| 746 EXPECT_THAT( | 743 EXPECT_THAT( |
| 747 r.replacement(), | 744 r.replacement(), |
| 748 IsStoreBuffer( | 745 IsStoreBuffer( |
| 749 BufferAccess(type), | 746 BufferAccess(type), |
| 750 IsPointerConstant(bit_cast<intptr_t>(&backing_store[0])), | 747 IsPointerConstant(bit_cast<intptr_t>(&backing_store[0])), |
| 751 offset_matcher, IsNumberConstant(array->byte_length()->Number()), | 748 offset_matcher, IsNumberConstant(array->byte_length()->Number()), |
| 752 value_matcher, effect_matcher, control_matcher)); | 749 value_matcher, checkpoint, control)); |
| 753 } | 750 } |
| 754 } | 751 } |
| 755 } | 752 } |
| 756 | 753 |
| 757 | 754 |
| 758 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithSafeKey) { | 755 TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithSafeKey) { |
| 759 const size_t kLength = 17; | 756 const size_t kLength = 17; |
| 760 double backing_store[kLength]; | 757 double backing_store[kLength]; |
| 761 Handle<JSArrayBuffer> buffer = | 758 Handle<JSArrayBuffer> buffer = |
| 762 NewArrayBuffer(backing_store, sizeof(backing_store)); | 759 NewArrayBuffer(backing_store, sizeof(backing_store)); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 EmptyFrameState(), effect, control)); | 1007 EmptyFrameState(), effect, control)); |
| 1011 ASSERT_TRUE(r.Changed()); | 1008 ASSERT_TRUE(r.Changed()); |
| 1012 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( | 1009 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( |
| 1013 NumberOperationHint::kNumberOrOddball, lhs, | 1010 NumberOperationHint::kNumberOrOddball, lhs, |
| 1014 rhs, effect, control)); | 1011 rhs, effect, control)); |
| 1015 } | 1012 } |
| 1016 | 1013 |
| 1017 } // namespace compiler | 1014 } // namespace compiler |
| 1018 } // namespace internal | 1015 } // namespace internal |
| 1019 } // namespace v8 | 1016 } // namespace v8 |
| OLD | NEW |