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/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
7 #include "src/compiler/js-builtin-reducer.h" | 7 #include "src/compiler/js-builtin-reducer.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/node-aux-data-inl.h" | 9 #include "src/compiler/node-aux-data-inl.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 return Changed(node); | 724 return Changed(node); |
725 } | 725 } |
726 return NoChange(); | 726 return NoChange(); |
727 } | 727 } |
728 | 728 |
729 | 729 |
730 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { | 730 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { |
731 Node* key = NodeProperties::GetValueInput(node, 1); | 731 Node* key = NodeProperties::GetValueInput(node, 1); |
732 Node* base = NodeProperties::GetValueInput(node, 0); | 732 Node* base = NodeProperties::GetValueInput(node, 0); |
733 Type* key_type = NodeProperties::GetBounds(key).upper; | 733 Type* key_type = NodeProperties::GetBounds(key).upper; |
734 Type* base_type = NodeProperties::GetBounds(base).upper; | |
735 // TODO(mstarzinger): This lowering is not correct if: | 734 // TODO(mstarzinger): This lowering is not correct if: |
736 // a) The typed array or it's buffer is neutered. | 735 // a) The typed array or it's buffer is neutered. |
737 if (base_type->IsConstant() && | 736 HeapObjectMatcher<Object> mbase(base); |
738 base_type->AsConstant()->Value()->IsJSTypedArray()) { | 737 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { |
739 Handle<JSTypedArray> const array = | 738 Handle<JSTypedArray> const array = |
740 Handle<JSTypedArray>::cast(base_type->AsConstant()->Value()); | 739 Handle<JSTypedArray>::cast(mbase.Value().handle()); |
741 array->GetBuffer()->set_is_neuterable(false); | 740 array->GetBuffer()->set_is_neuterable(false); |
742 BufferAccess const access(array->type()); | 741 BufferAccess const access(array->type()); |
743 size_t const k = ElementSizeLog2Of(access.machine_type()); | 742 size_t const k = ElementSizeLog2Of(access.machine_type()); |
744 double const byte_length = array->byte_length()->Number(); | 743 double const byte_length = array->byte_length()->Number(); |
745 CHECK_LT(k, arraysize(shifted_int32_ranges_)); | 744 CHECK_LT(k, arraysize(shifted_int32_ranges_)); |
746 if (IsExternalArrayElementsKind(array->map()->elements_kind()) && | 745 if (IsExternalArrayElementsKind(array->map()->elements_kind()) && |
747 access.external_array_type() != kExternalUint8ClampedArray && | 746 access.external_array_type() != kExternalUint8ClampedArray && |
748 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { | 747 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { |
749 // JSLoadProperty(typed-array, int32) | 748 // JSLoadProperty(typed-array, int32) |
750 Handle<ExternalArray> elements = | 749 Handle<ExternalArray> elements = |
(...skipping 19 matching lines...) Expand all Loading... |
770 } | 769 } |
771 return NoChange(); | 770 return NoChange(); |
772 } | 771 } |
773 | 772 |
774 | 773 |
775 Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { | 774 Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { |
776 Node* key = NodeProperties::GetValueInput(node, 1); | 775 Node* key = NodeProperties::GetValueInput(node, 1); |
777 Node* base = NodeProperties::GetValueInput(node, 0); | 776 Node* base = NodeProperties::GetValueInput(node, 0); |
778 Node* value = NodeProperties::GetValueInput(node, 2); | 777 Node* value = NodeProperties::GetValueInput(node, 2); |
779 Type* key_type = NodeProperties::GetBounds(key).upper; | 778 Type* key_type = NodeProperties::GetBounds(key).upper; |
780 Type* base_type = NodeProperties::GetBounds(base).upper; | |
781 Type* value_type = NodeProperties::GetBounds(value).upper; | 779 Type* value_type = NodeProperties::GetBounds(value).upper; |
782 // TODO(mstarzinger): This lowering is not correct if: | 780 // TODO(mstarzinger): This lowering is not correct if: |
783 // a) The typed array or its buffer is neutered. | 781 // a) The typed array or its buffer is neutered. |
784 if (base_type->IsConstant() && | 782 HeapObjectMatcher<Object> mbase(base); |
785 base_type->AsConstant()->Value()->IsJSTypedArray()) { | 783 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { |
786 Handle<JSTypedArray> const array = | 784 Handle<JSTypedArray> const array = |
787 Handle<JSTypedArray>::cast(base_type->AsConstant()->Value()); | 785 Handle<JSTypedArray>::cast(mbase.Value().handle()); |
788 array->GetBuffer()->set_is_neuterable(false); | 786 array->GetBuffer()->set_is_neuterable(false); |
789 BufferAccess const access(array->type()); | 787 BufferAccess const access(array->type()); |
790 size_t const k = ElementSizeLog2Of(access.machine_type()); | 788 size_t const k = ElementSizeLog2Of(access.machine_type()); |
791 double const byte_length = array->byte_length()->Number(); | 789 double const byte_length = array->byte_length()->Number(); |
792 CHECK_LT(k, arraysize(shifted_int32_ranges_)); | 790 CHECK_LT(k, arraysize(shifted_int32_ranges_)); |
793 if (IsExternalArrayElementsKind(array->map()->elements_kind()) && | 791 if (IsExternalArrayElementsKind(array->map()->elements_kind()) && |
794 access.external_array_type() != kExternalUint8ClampedArray && | 792 access.external_array_type() != kExternalUint8ClampedArray && |
795 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { | 793 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { |
796 // JSLoadProperty(typed-array, int32) | 794 // JSLoadProperty(typed-array, int32) |
797 Handle<ExternalArray> elements = | 795 Handle<ExternalArray> elements = |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 | 982 |
985 Node* JSTypedLowering::Word32Shl(Node* const lhs, int32_t const rhs) { | 983 Node* JSTypedLowering::Word32Shl(Node* const lhs, int32_t const rhs) { |
986 if (rhs == 0) return lhs; | 984 if (rhs == 0) return lhs; |
987 return graph()->NewNode(machine()->Word32Shl(), lhs, | 985 return graph()->NewNode(machine()->Word32Shl(), lhs, |
988 jsgraph()->Int32Constant(rhs)); | 986 jsgraph()->Int32Constant(rhs)); |
989 } | 987 } |
990 | 988 |
991 } // namespace compiler | 989 } // namespace compiler |
992 } // namespace internal | 990 } // namespace internal |
993 } // namespace v8 | 991 } // namespace v8 |
OLD | NEW |