Index: src/compiler/js-typed-lowering.cc |
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc |
index 05e8ede0fd3d33d59eb3bfe8c0ba0ef86becfc58..557b0278be8ac653df3eb34f1471d2d0099d5d97 100644 |
--- a/src/compiler/js-typed-lowering.cc |
+++ b/src/compiler/js-typed-lowering.cc |
@@ -541,21 +541,24 @@ Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { |
Handle<JSTypedArray>::cast(base_type->AsConstant()->Value()); |
if (IsExternalArrayElementsKind(array->map()->elements_kind())) { |
ExternalArrayType type = array->type(); |
- uint32_t length; |
- CHECK(array->length()->ToUint32(&length)); |
- Node* elements = graph()->NewNode( |
- simplified()->LoadField(AccessBuilder::ForJSObjectElements()), base, |
- graph()->start()); |
- Node* pointer = graph()->NewNode( |
- simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()), |
- elements, elements); |
- Node* effect = NodeProperties::GetEffectInput(node); |
- Node* control = NodeProperties::GetControlInput(node); |
- Node* load = graph()->NewNode( |
- simplified()->LoadElement( |
- AccessBuilder::ForTypedArrayElement(type, true)), |
- pointer, key, jsgraph()->Uint32Constant(length), effect, control); |
- return ReplaceEagerly(node, load); |
+ uint32_t byte_length; |
+ if (array->byte_length()->ToUint32(&byte_length)) { |
+ Node* elements = graph()->NewNode( |
+ simplified()->LoadField(AccessBuilder::ForJSObjectElements()), base, |
+ graph()->start()); |
+ Node* pointer = graph()->NewNode( |
+ simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()), |
+ elements, elements); |
+ Node* length = jsgraph()->Uint32Constant( |
+ static_cast<uint32_t>(byte_length / array->element_size())); |
+ Node* effect = NodeProperties::GetEffectInput(node); |
+ Node* control = NodeProperties::GetControlInput(node); |
+ Node* load = graph()->NewNode( |
+ simplified()->LoadElement( |
+ AccessBuilder::ForTypedArrayElement(type, true)), |
+ pointer, key, length, effect, control); |
+ return ReplaceEagerly(node, load); |
+ } |
} |
} |
return NoChange(); |
@@ -577,22 +580,24 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { |
Handle<JSTypedArray>::cast(base_type->AsConstant()->Value()); |
if (IsExternalArrayElementsKind(array->map()->elements_kind())) { |
ExternalArrayType type = array->type(); |
- uint32_t length; |
- CHECK(array->length()->ToUint32(&length)); |
- Node* elements = graph()->NewNode( |
- simplified()->LoadField(AccessBuilder::ForJSObjectElements()), base, |
- graph()->start()); |
- Node* pointer = graph()->NewNode( |
- simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()), |
- elements, elements); |
- Node* effect = NodeProperties::GetEffectInput(node); |
- Node* control = NodeProperties::GetControlInput(node); |
- Node* store = |
- graph()->NewNode(simplified()->StoreElement( |
- AccessBuilder::ForTypedArrayElement(type, true)), |
- pointer, key, jsgraph()->Uint32Constant(length), |
- value, effect, control); |
- return ReplaceEagerly(node, store); |
+ uint32_t byte_length; |
+ if (array->byte_length()->ToUint32(&byte_length)) { |
+ Node* elements = graph()->NewNode( |
+ simplified()->LoadField(AccessBuilder::ForJSObjectElements()), base, |
+ graph()->start()); |
+ Node* pointer = graph()->NewNode( |
+ simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()), |
+ elements, elements); |
+ Node* length = jsgraph()->Uint32Constant( |
+ static_cast<uint32_t>(byte_length / array->element_size())); |
+ Node* effect = NodeProperties::GetEffectInput(node); |
+ Node* control = NodeProperties::GetControlInput(node); |
+ Node* store = graph()->NewNode( |
+ simplified()->StoreElement( |
+ AccessBuilder::ForTypedArrayElement(type, true)), |
+ pointer, key, length, value, effect, control); |
+ return ReplaceEagerly(node, store); |
+ } |
} |
} |
return NoChange(); |