| 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/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-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
| 9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
| 10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 if (IsExternalArrayElementsKind(array->map()->elements_kind()) && | 768 if (IsExternalArrayElementsKind(array->map()->elements_kind()) && |
| 769 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { | 769 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { |
| 770 // JSLoadProperty(typed-array, int32) | 770 // JSLoadProperty(typed-array, int32) |
| 771 Handle<ExternalArray> elements = | 771 Handle<ExternalArray> elements = |
| 772 Handle<ExternalArray>::cast(handle(array->elements())); | 772 Handle<ExternalArray>::cast(handle(array->elements())); |
| 773 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer()); | 773 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer()); |
| 774 Node* length = jsgraph()->Constant(byte_length); | 774 Node* length = jsgraph()->Constant(byte_length); |
| 775 Node* effect = NodeProperties::GetEffectInput(node); | 775 Node* effect = NodeProperties::GetEffectInput(node); |
| 776 Node* control = NodeProperties::GetControlInput(node); | 776 Node* control = NodeProperties::GetControlInput(node); |
| 777 // Check if we can avoid the bounds check. | 777 // Check if we can avoid the bounds check. |
| 778 if (key_type->Min() >= 0 && | 778 if (key_type->Min() >= 0 && key_type->Max() < array->length_value()) { |
| 779 key_type->Max() < array->length()->Number()) { | |
| 780 Node* load = graph()->NewNode( | 779 Node* load = graph()->NewNode( |
| 781 simplified()->LoadElement( | 780 simplified()->LoadElement( |
| 782 AccessBuilder::ForTypedArrayElement(array->type(), true)), | 781 AccessBuilder::ForTypedArrayElement(array->type(), true)), |
| 783 buffer, key, effect, control); | 782 buffer, key, effect, control); |
| 784 ReplaceWithValue(node, load, load); | 783 ReplaceWithValue(node, load, load); |
| 785 return Replace(load); | 784 return Replace(load); |
| 786 } | 785 } |
| 787 // Compute byte offset. | 786 // Compute byte offset. |
| 788 Node* offset = Word32Shl(key, static_cast<int>(k)); | 787 Node* offset = Word32Shl(key, static_cast<int>(k)); |
| 789 Node* load = graph()->NewNode(simplified()->LoadBuffer(access), buffer, | 788 Node* load = graph()->NewNode(simplified()->LoadBuffer(access), buffer, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 } | 838 } |
| 840 // For integer-typed arrays, convert to the integer type. | 839 // For integer-typed arrays, convert to the integer type. |
| 841 if (TypeOf(access.machine_type()) == kTypeInt32 && | 840 if (TypeOf(access.machine_type()) == kTypeInt32 && |
| 842 !value_type->Is(Type::Signed32())) { | 841 !value_type->Is(Type::Signed32())) { |
| 843 value = graph()->NewNode(simplified()->NumberToInt32(), value); | 842 value = graph()->NewNode(simplified()->NumberToInt32(), value); |
| 844 } else if (TypeOf(access.machine_type()) == kTypeUint32 && | 843 } else if (TypeOf(access.machine_type()) == kTypeUint32 && |
| 845 !value_type->Is(Type::Unsigned32())) { | 844 !value_type->Is(Type::Unsigned32())) { |
| 846 value = graph()->NewNode(simplified()->NumberToUint32(), value); | 845 value = graph()->NewNode(simplified()->NumberToUint32(), value); |
| 847 } | 846 } |
| 848 // Check if we can avoid the bounds check. | 847 // Check if we can avoid the bounds check. |
| 849 if (key_type->Min() >= 0 && | 848 if (key_type->Min() >= 0 && key_type->Max() < array->length_value()) { |
| 850 key_type->Max() < array->length()->Number()) { | |
| 851 node->set_op(simplified()->StoreElement( | 849 node->set_op(simplified()->StoreElement( |
| 852 AccessBuilder::ForTypedArrayElement(array->type(), true))); | 850 AccessBuilder::ForTypedArrayElement(array->type(), true))); |
| 853 node->ReplaceInput(0, buffer); | 851 node->ReplaceInput(0, buffer); |
| 854 DCHECK_EQ(key, node->InputAt(1)); | 852 DCHECK_EQ(key, node->InputAt(1)); |
| 855 node->ReplaceInput(2, value); | 853 node->ReplaceInput(2, value); |
| 856 node->ReplaceInput(3, effect); | 854 node->ReplaceInput(3, effect); |
| 857 node->ReplaceInput(4, control); | 855 node->ReplaceInput(4, control); |
| 858 node->TrimInputCount(5); | 856 node->TrimInputCount(5); |
| 859 RelaxControls(node); | 857 RelaxControls(node); |
| 860 return Changed(node); | 858 return Changed(node); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 } | 1201 } |
| 1204 | 1202 |
| 1205 | 1203 |
| 1206 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1204 MachineOperatorBuilder* JSTypedLowering::machine() const { |
| 1207 return jsgraph()->machine(); | 1205 return jsgraph()->machine(); |
| 1208 } | 1206 } |
| 1209 | 1207 |
| 1210 } // namespace compiler | 1208 } // namespace compiler |
| 1211 } // namespace internal | 1209 } // namespace internal |
| 1212 } // namespace v8 | 1210 } // namespace v8 |
| OLD | NEW |