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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 HeapObjectMatcher mbase(base); | 825 HeapObjectMatcher mbase(base); |
826 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { | 826 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { |
827 Handle<JSTypedArray> const array = | 827 Handle<JSTypedArray> const array = |
828 Handle<JSTypedArray>::cast(mbase.Value().handle()); | 828 Handle<JSTypedArray>::cast(mbase.Value().handle()); |
829 if (!array->GetBuffer()->was_neutered()) { | 829 if (!array->GetBuffer()->was_neutered()) { |
830 array->GetBuffer()->set_is_neuterable(false); | 830 array->GetBuffer()->set_is_neuterable(false); |
831 BufferAccess const access(array->type()); | 831 BufferAccess const access(array->type()); |
832 size_t const k = ElementSizeLog2Of(access.machine_type()); | 832 size_t const k = ElementSizeLog2Of(access.machine_type()); |
833 double const byte_length = array->byte_length()->Number(); | 833 double const byte_length = array->byte_length()->Number(); |
834 CHECK_LT(k, arraysize(shifted_int32_ranges_)); | 834 CHECK_LT(k, arraysize(shifted_int32_ranges_)); |
835 if (IsExternalArrayElementsKind(array->map()->elements_kind()) && | 835 if (key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { |
836 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { | |
837 // JSLoadProperty(typed-array, int32) | 836 // JSLoadProperty(typed-array, int32) |
838 Handle<ExternalArray> elements = | 837 Handle<FixedTypedArrayBase> elements = |
839 Handle<ExternalArray>::cast(handle(array->elements())); | 838 Handle<FixedTypedArrayBase>::cast(handle(array->elements())); |
840 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer()); | 839 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer()); |
841 Node* length = jsgraph()->Constant(byte_length); | 840 Node* length = jsgraph()->Constant(byte_length); |
842 Node* effect = NodeProperties::GetEffectInput(node); | 841 Node* effect = NodeProperties::GetEffectInput(node); |
843 Node* control = NodeProperties::GetControlInput(node); | 842 Node* control = NodeProperties::GetControlInput(node); |
844 // Check if we can avoid the bounds check. | 843 // Check if we can avoid the bounds check. |
845 if (key_type->Min() >= 0 && key_type->Max() < array->length_value()) { | 844 if (key_type->Min() >= 0 && key_type->Max() < array->length_value()) { |
846 Node* load = graph()->NewNode( | 845 Node* load = graph()->NewNode( |
847 simplified()->LoadElement( | 846 simplified()->LoadElement( |
848 AccessBuilder::ForTypedArrayElement(array->type(), true)), | 847 AccessBuilder::ForTypedArrayElement(array->type(), true)), |
849 buffer, key, effect, control); | 848 buffer, key, effect, control); |
(...skipping 22 matching lines...) Expand all Loading... |
872 HeapObjectMatcher mbase(base); | 871 HeapObjectMatcher mbase(base); |
873 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { | 872 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { |
874 Handle<JSTypedArray> const array = | 873 Handle<JSTypedArray> const array = |
875 Handle<JSTypedArray>::cast(mbase.Value().handle()); | 874 Handle<JSTypedArray>::cast(mbase.Value().handle()); |
876 if (!array->GetBuffer()->was_neutered()) { | 875 if (!array->GetBuffer()->was_neutered()) { |
877 array->GetBuffer()->set_is_neuterable(false); | 876 array->GetBuffer()->set_is_neuterable(false); |
878 BufferAccess const access(array->type()); | 877 BufferAccess const access(array->type()); |
879 size_t const k = ElementSizeLog2Of(access.machine_type()); | 878 size_t const k = ElementSizeLog2Of(access.machine_type()); |
880 double const byte_length = array->byte_length()->Number(); | 879 double const byte_length = array->byte_length()->Number(); |
881 CHECK_LT(k, arraysize(shifted_int32_ranges_)); | 880 CHECK_LT(k, arraysize(shifted_int32_ranges_)); |
882 if (IsExternalArrayElementsKind(array->map()->elements_kind()) && | 881 if (access.external_array_type() != kExternalUint8ClampedArray && |
883 access.external_array_type() != kExternalUint8ClampedArray && | |
884 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { | 882 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { |
885 // JSLoadProperty(typed-array, int32) | 883 // JSLoadProperty(typed-array, int32) |
886 Handle<ExternalArray> elements = | 884 Handle<FixedTypedArrayBase> elements = |
887 Handle<ExternalArray>::cast(handle(array->elements())); | 885 Handle<FixedTypedArrayBase>::cast(handle(array->elements())); |
888 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer()); | 886 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer()); |
889 Node* length = jsgraph()->Constant(byte_length); | 887 Node* length = jsgraph()->Constant(byte_length); |
890 Node* context = NodeProperties::GetContextInput(node); | 888 Node* context = NodeProperties::GetContextInput(node); |
891 Node* effect = NodeProperties::GetEffectInput(node); | 889 Node* effect = NodeProperties::GetEffectInput(node); |
892 Node* control = NodeProperties::GetControlInput(node); | 890 Node* control = NodeProperties::GetControlInput(node); |
893 // Convert to a number first. | 891 // Convert to a number first. |
894 if (!value_type->Is(Type::Number())) { | 892 if (!value_type->Is(Type::Number())) { |
895 Reduction number_reduction = ReduceJSToNumberInput(value); | 893 Reduction number_reduction = ReduceJSToNumberInput(value); |
896 if (number_reduction.Changed()) { | 894 if (number_reduction.Changed()) { |
897 value = number_reduction.replacement(); | 895 value = number_reduction.replacement(); |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 } | 1707 } |
1710 | 1708 |
1711 | 1709 |
1712 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1710 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1713 return jsgraph()->machine(); | 1711 return jsgraph()->machine(); |
1714 } | 1712 } |
1715 | 1713 |
1716 } // namespace compiler | 1714 } // namespace compiler |
1717 } // namespace internal | 1715 } // namespace internal |
1718 } // namespace v8 | 1716 } // namespace v8 |
OLD | NEW |