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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 1257223002: Revert of Remove ExternalArray, derived types, and element kinds (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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/access-builder.cc ('k') | src/contexts.h » ('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-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
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 (key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { 835 if (IsExternalArrayElementsKind(array->map()->elements_kind()) &&
836 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) {
836 // JSLoadProperty(typed-array, int32) 837 // JSLoadProperty(typed-array, int32)
837 Handle<FixedTypedArrayBase> elements = 838 Handle<ExternalArray> elements =
838 Handle<FixedTypedArrayBase>::cast(handle(array->elements())); 839 Handle<ExternalArray>::cast(handle(array->elements()));
839 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer()); 840 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer());
840 Node* length = jsgraph()->Constant(byte_length); 841 Node* length = jsgraph()->Constant(byte_length);
841 Node* effect = NodeProperties::GetEffectInput(node); 842 Node* effect = NodeProperties::GetEffectInput(node);
842 Node* control = NodeProperties::GetControlInput(node); 843 Node* control = NodeProperties::GetControlInput(node);
843 // Check if we can avoid the bounds check. 844 // Check if we can avoid the bounds check.
844 if (key_type->Min() >= 0 && key_type->Max() < array->length_value()) { 845 if (key_type->Min() >= 0 && key_type->Max() < array->length_value()) {
845 Node* load = graph()->NewNode( 846 Node* load = graph()->NewNode(
846 simplified()->LoadElement( 847 simplified()->LoadElement(
847 AccessBuilder::ForTypedArrayElement(array->type(), true)), 848 AccessBuilder::ForTypedArrayElement(array->type(), true)),
848 buffer, key, effect, control); 849 buffer, key, effect, control);
(...skipping 22 matching lines...) Expand all
871 HeapObjectMatcher mbase(base); 872 HeapObjectMatcher mbase(base);
872 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { 873 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) {
873 Handle<JSTypedArray> const array = 874 Handle<JSTypedArray> const array =
874 Handle<JSTypedArray>::cast(mbase.Value().handle()); 875 Handle<JSTypedArray>::cast(mbase.Value().handle());
875 if (!array->GetBuffer()->was_neutered()) { 876 if (!array->GetBuffer()->was_neutered()) {
876 array->GetBuffer()->set_is_neuterable(false); 877 array->GetBuffer()->set_is_neuterable(false);
877 BufferAccess const access(array->type()); 878 BufferAccess const access(array->type());
878 size_t const k = ElementSizeLog2Of(access.machine_type()); 879 size_t const k = ElementSizeLog2Of(access.machine_type());
879 double const byte_length = array->byte_length()->Number(); 880 double const byte_length = array->byte_length()->Number();
880 CHECK_LT(k, arraysize(shifted_int32_ranges_)); 881 CHECK_LT(k, arraysize(shifted_int32_ranges_));
881 if (access.external_array_type() != kExternalUint8ClampedArray && 882 if (IsExternalArrayElementsKind(array->map()->elements_kind()) &&
883 access.external_array_type() != kExternalUint8ClampedArray &&
882 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { 884 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) {
883 // JSLoadProperty(typed-array, int32) 885 // JSLoadProperty(typed-array, int32)
884 Handle<FixedTypedArrayBase> elements = 886 Handle<ExternalArray> elements =
885 Handle<FixedTypedArrayBase>::cast(handle(array->elements())); 887 Handle<ExternalArray>::cast(handle(array->elements()));
886 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer()); 888 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer());
887 Node* length = jsgraph()->Constant(byte_length); 889 Node* length = jsgraph()->Constant(byte_length);
888 Node* context = NodeProperties::GetContextInput(node); 890 Node* context = NodeProperties::GetContextInput(node);
889 Node* effect = NodeProperties::GetEffectInput(node); 891 Node* effect = NodeProperties::GetEffectInput(node);
890 Node* control = NodeProperties::GetControlInput(node); 892 Node* control = NodeProperties::GetControlInput(node);
891 // Convert to a number first. 893 // Convert to a number first.
892 if (!value_type->Is(Type::Number())) { 894 if (!value_type->Is(Type::Number())) {
893 Reduction number_reduction = ReduceJSToNumberInput(value); 895 Reduction number_reduction = ReduceJSToNumberInput(value);
894 if (number_reduction.Changed()) { 896 if (number_reduction.Changed()) {
895 value = number_reduction.replacement(); 897 value = number_reduction.replacement();
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 } 1709 }
1708 1710
1709 1711
1710 MachineOperatorBuilder* JSTypedLowering::machine() const { 1712 MachineOperatorBuilder* JSTypedLowering::machine() const {
1711 return jsgraph()->machine(); 1713 return jsgraph()->machine();
1712 } 1714 }
1713 1715
1714 } // namespace compiler 1716 } // namespace compiler
1715 } // namespace internal 1717 } // namespace internal
1716 } // namespace v8 1718 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/access-builder.cc ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698