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

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 646483003: [turbofan] Fix typed lowering of typed array loads/stores. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix win64. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/factory.cc » ('j') | src/factory.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | src/factory.cc » ('j') | src/factory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698