| Index: src/compiler/js-typed-lowering.cc
|
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
|
| index 4c166e0dc53d3b2e6dd2319873de41bd230417cc..ca677ac7da40e1c801e2db15974a9ada4bc690f4 100644
|
| --- a/src/compiler/js-typed-lowering.cc
|
| +++ b/src/compiler/js-typed-lowering.cc
|
| @@ -499,6 +499,43 @@ Reduction JSTypedLowering::ReduceJSToBooleanInput(Node* input) {
|
| }
|
|
|
|
|
| +Reduction JSTypedLowering::ReduceJSPropertyLoad(Node* node) {
|
| + Node* key = NodeProperties::GetValueInput(node, 1);
|
| + Node* base = NodeProperties::GetValueInput(node, 0);
|
| + Type* key_type = NodeProperties::GetBounds(key).upper;
|
| + Type* base_type = NodeProperties::GetBounds(base).upper;
|
| + // TODO(mstarzinger): This lowering is not correct if:
|
| + // a) The typed array turns external (i.e. MaterializeArrayBuffer)
|
| + // b) The typed array or it's buffer is neutered.
|
| + // c) The index is out of bounds.
|
| + if (base_type->IsConstant() && key_type->Is(Type::Integral32()) &&
|
| + base_type->AsConstant()->Value()->IsJSTypedArray()) {
|
| + // JSLoadProperty(typed-array, int32)
|
| + JSTypedArray* array = JSTypedArray::cast(*base_type->AsConstant()->Value());
|
| + ElementsKind elements_kind = array->map()->elements_kind();
|
| + ExternalArrayType type = array->type();
|
| + ElementAccess element_access;
|
| + Node* elements =
|
| + graph()->NewNode(simplified()->LoadField(Access::ForJSObjectElements()),
|
| + base, NodeProperties::GetEffectInput(node));
|
| + if (IsExternalArrayElementsKind(elements_kind)) {
|
| + elements = graph()->NewNode(
|
| + simplified()->LoadField(Access::ForExternalArrayPointer()), elements,
|
| + NodeProperties::GetEffectInput(node));
|
| + element_access = Access::ForTypedArrayElement(type, true);
|
| + } else {
|
| + DCHECK(IsFixedTypedArrayElementsKind(elements_kind));
|
| + element_access = Access::ForTypedArrayElement(type, false);
|
| + }
|
| + Node* value =
|
| + graph()->NewNode(simplified()->LoadElement(element_access), elements,
|
| + key, NodeProperties::GetEffectInput(node));
|
| + return ReplaceEagerly(node, value);
|
| + }
|
| + return NoChange();
|
| +}
|
| +
|
| +
|
| static Reduction ReplaceWithReduction(Node* node, Reduction reduction) {
|
| if (reduction.Changed()) {
|
| NodeProperties::ReplaceWithValue(node, reduction.replacement());
|
| @@ -573,6 +610,8 @@ Reduction JSTypedLowering::Reduce(Node* node) {
|
| case IrOpcode::kJSToString:
|
| return ReplaceWithReduction(node,
|
| ReduceJSToStringInput(node->InputAt(0)));
|
| + case IrOpcode::kJSLoadProperty:
|
| + return ReduceJSPropertyLoad(node);
|
| default:
|
| break;
|
| }
|
|
|