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

Unified Diff: src/compiler/effect-control-linearizer.cc

Issue 2203693002: [turbofan] Introduce initial support for TypedArrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5254
Patch Set: Fix Retain Created 4 years, 4 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 | « src/compiler/effect-control-linearizer.h ('k') | src/compiler/instruction-selector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/effect-control-linearizer.cc
diff --git a/src/compiler/effect-control-linearizer.cc b/src/compiler/effect-control-linearizer.cc
index 1b6752ab153c019aa3062cc96c4fb5ae17826281..220487c66fb36c699f8ec627a4f48e8185a41553 100644
--- a/src/compiler/effect-control-linearizer.cc
+++ b/src/compiler/effect-control-linearizer.cc
@@ -722,6 +722,12 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kTransitionElementsKind:
state = LowerTransitionElementsKind(node, *effect, *control);
break;
+ case IrOpcode::kLoadTypedElement:
+ state = LowerLoadTypedElement(node, *effect, *control);
+ break;
+ case IrOpcode::kStoreTypedElement:
+ state = LowerStoreTypedElement(node, *effect, *control);
+ break;
default:
return false;
}
@@ -2619,6 +2625,59 @@ EffectControlLinearizer::LowerTransitionElementsKind(Node* node, Node* effect,
return ValueEffectControl(nullptr, effect, control);
}
+EffectControlLinearizer::ValueEffectControl
+EffectControlLinearizer::LowerLoadTypedElement(Node* node, Node* effect,
+ Node* control) {
+ ExternalArrayType array_type = ExternalArrayTypeOf(node->op());
+ Node* buffer = node->InputAt(0);
+ Node* base = node->InputAt(1);
+ Node* external = node->InputAt(2);
+ Node* index = node->InputAt(3);
+
+ // We need to keep the {buffer} alive so that the GC will not release the
+ // ArrayBuffer (if there's any) as long as we are still operating on it.
+ effect = graph()->NewNode(common()->Retain(), buffer, effect);
+
+ // Compute the effective storage pointer.
+ Node* storage = effect = graph()->NewNode(machine()->UnsafePointerAdd(), base,
+ external, effect, control);
+
+ // Perform the actual typed element access.
+ Node* value = effect = graph()->NewNode(
+ simplified()->LoadElement(
+ AccessBuilder::ForTypedArrayElement(array_type, true)),
+ storage, index, effect, control);
+
+ return ValueEffectControl(value, effect, control);
+}
+
+EffectControlLinearizer::ValueEffectControl
+EffectControlLinearizer::LowerStoreTypedElement(Node* node, Node* effect,
+ Node* control) {
+ ExternalArrayType array_type = ExternalArrayTypeOf(node->op());
+ Node* buffer = node->InputAt(0);
+ Node* base = node->InputAt(1);
+ Node* external = node->InputAt(2);
+ Node* index = node->InputAt(3);
+ Node* value = node->InputAt(4);
+
+ // We need to keep the {buffer} alive so that the GC will not release the
+ // ArrayBuffer (if there's any) as long as we are still operating on it.
+ effect = graph()->NewNode(common()->Retain(), buffer, effect);
+
+ // Compute the effective storage pointer.
+ Node* storage = effect = graph()->NewNode(machine()->UnsafePointerAdd(), base,
+ external, effect, control);
+
+ // Perform the actual typed element access.
+ effect = graph()->NewNode(
+ simplified()->StoreElement(
+ AccessBuilder::ForTypedArrayElement(array_type, true)),
+ storage, index, value, effect, control);
+
+ return ValueEffectControl(nullptr, effect, control);
+}
+
Factory* EffectControlLinearizer::factory() const {
return isolate()->factory();
}
« no previous file with comments | « src/compiler/effect-control-linearizer.h ('k') | src/compiler/instruction-selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698