| 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-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 // TODO(mstarzinger): This lowering is not correct if: | 559 // TODO(mstarzinger): This lowering is not correct if: |
| 560 // a) The typed array or it's buffer is neutered. | 560 // a) The typed array or it's buffer is neutered. |
| 561 if (base_type->IsConstant() && key_type->Is(Type::Integral32()) && | 561 if (base_type->IsConstant() && key_type->Is(Type::Integral32()) && |
| 562 base_type->AsConstant()->Value()->IsJSTypedArray()) { | 562 base_type->AsConstant()->Value()->IsJSTypedArray()) { |
| 563 // JSLoadProperty(typed-array, int32) | 563 // JSLoadProperty(typed-array, int32) |
| 564 Handle<JSTypedArray> array = | 564 Handle<JSTypedArray> array = |
| 565 Handle<JSTypedArray>::cast(base_type->AsConstant()->Value()); | 565 Handle<JSTypedArray>::cast(base_type->AsConstant()->Value()); |
| 566 if (IsExternalArrayElementsKind(array->map()->elements_kind())) { | 566 if (IsExternalArrayElementsKind(array->map()->elements_kind())) { |
| 567 ExternalArrayType type = array->type(); | 567 ExternalArrayType type = array->type(); |
| 568 uint32_t byte_length; | 568 uint32_t byte_length; |
| 569 if (array->byte_length()->ToUint32(&byte_length)) { | 569 if (array->byte_length()->ToUint32(&byte_length) && |
| 570 byte_length <= static_cast<uint32_t>(kMaxInt)) { |
| 570 Handle<ExternalArray> elements = | 571 Handle<ExternalArray> elements = |
| 571 Handle<ExternalArray>::cast(handle(array->elements())); | 572 Handle<ExternalArray>::cast(handle(array->elements())); |
| 572 Node* pointer = jsgraph()->IntPtrConstant( | 573 Node* pointer = jsgraph()->IntPtrConstant( |
| 573 bit_cast<intptr_t>(elements->external_pointer())); | 574 bit_cast<intptr_t>(elements->external_pointer())); |
| 574 Node* length = jsgraph()->Uint32Constant( | 575 Node* length = jsgraph()->Uint32Constant( |
| 575 static_cast<uint32_t>(byte_length / array->element_size())); | 576 static_cast<uint32_t>(byte_length / array->element_size())); |
| 576 Node* effect = NodeProperties::GetEffectInput(node); | 577 Node* effect = NodeProperties::GetEffectInput(node); |
| 577 Node* control = NodeProperties::GetControlInput(node); | 578 Node* control = NodeProperties::GetControlInput(node); |
| 578 Node* load = graph()->NewNode( | 579 Node* load = graph()->NewNode( |
| 579 simplified()->LoadElement( | 580 simplified()->LoadElement( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 596 // TODO(mstarzinger): This lowering is not correct if: | 597 // TODO(mstarzinger): This lowering is not correct if: |
| 597 // a) The typed array or its buffer is neutered. | 598 // a) The typed array or its buffer is neutered. |
| 598 if (key_type->Is(Type::Integral32()) && base_type->IsConstant() && | 599 if (key_type->Is(Type::Integral32()) && base_type->IsConstant() && |
| 599 base_type->AsConstant()->Value()->IsJSTypedArray()) { | 600 base_type->AsConstant()->Value()->IsJSTypedArray()) { |
| 600 // JSStoreProperty(typed-array, int32, value) | 601 // JSStoreProperty(typed-array, int32, value) |
| 601 Handle<JSTypedArray> array = | 602 Handle<JSTypedArray> array = |
| 602 Handle<JSTypedArray>::cast(base_type->AsConstant()->Value()); | 603 Handle<JSTypedArray>::cast(base_type->AsConstant()->Value()); |
| 603 if (IsExternalArrayElementsKind(array->map()->elements_kind())) { | 604 if (IsExternalArrayElementsKind(array->map()->elements_kind())) { |
| 604 ExternalArrayType type = array->type(); | 605 ExternalArrayType type = array->type(); |
| 605 uint32_t byte_length; | 606 uint32_t byte_length; |
| 606 if (array->byte_length()->ToUint32(&byte_length)) { | 607 if (array->byte_length()->ToUint32(&byte_length) && |
| 608 byte_length <= static_cast<uint32_t>(kMaxInt)) { |
| 607 Handle<ExternalArray> elements = | 609 Handle<ExternalArray> elements = |
| 608 Handle<ExternalArray>::cast(handle(array->elements())); | 610 Handle<ExternalArray>::cast(handle(array->elements())); |
| 609 Node* pointer = jsgraph()->IntPtrConstant( | 611 Node* pointer = jsgraph()->IntPtrConstant( |
| 610 bit_cast<intptr_t>(elements->external_pointer())); | 612 bit_cast<intptr_t>(elements->external_pointer())); |
| 611 Node* length = jsgraph()->Uint32Constant( | 613 Node* length = jsgraph()->Uint32Constant( |
| 612 static_cast<uint32_t>(byte_length / array->element_size())); | 614 static_cast<uint32_t>(byte_length / array->element_size())); |
| 613 Node* effect = NodeProperties::GetEffectInput(node); | 615 Node* effect = NodeProperties::GetEffectInput(node); |
| 614 Node* control = NodeProperties::GetControlInput(node); | 616 Node* control = NodeProperties::GetControlInput(node); |
| 615 Node* store = graph()->NewNode( | 617 Node* store = graph()->NewNode( |
| 616 simplified()->StoreElement( | 618 simplified()->StoreElement( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 return JSBuiltinReducer(jsgraph()).Reduce(node); | 718 return JSBuiltinReducer(jsgraph()).Reduce(node); |
| 717 default: | 719 default: |
| 718 break; | 720 break; |
| 719 } | 721 } |
| 720 return NoChange(); | 722 return NoChange(); |
| 721 } | 723 } |
| 722 | 724 |
| 723 } // namespace compiler | 725 } // namespace compiler |
| 724 } // namespace internal | 726 } // namespace internal |
| 725 } // namespace v8 | 727 } // namespace v8 |
| OLD | NEW |