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

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

Issue 2695553002: [turbofan] Add support for JSArrayBufferView intrinsics. (Closed)
Patch Set: Created 3 years, 10 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/js-intrinsic-lowering.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-intrinsic-lowering.cc
diff --git a/src/compiler/js-intrinsic-lowering.cc b/src/compiler/js-intrinsic-lowering.cc
index 31cfe1116daed9117578f3c33e47c45ea3a64a9e..fd222d71fd1135ac2c0c5b33f47ad38865b99578 100644
--- a/src/compiler/js-intrinsic-lowering.cc
+++ b/src/compiler/js-intrinsic-lowering.cc
@@ -76,8 +76,17 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
return ReduceCall(node);
case Runtime::kInlineGetSuperConstructor:
return ReduceGetSuperConstructor(node);
+ case Runtime::kInlineArrayBufferViewGetByteLength:
+ return ReduceArrayBufferViewField(
+ node, AccessBuilder::ForJSArrayBufferViewByteLength());
+ case Runtime::kInlineArrayBufferViewGetByteOffset:
+ return ReduceArrayBufferViewField(
+ node, AccessBuilder::ForJSArrayBufferViewByteOffset());
case Runtime::kInlineMaxSmi:
return ReduceMaxSmi(node);
+ case Runtime::kInlineTypedArrayGetLength:
+ return ReduceArrayBufferViewField(node,
+ AccessBuilder::ForJSTypedArrayLength());
case Runtime::kInlineTypedArrayMaxSizeInHeap:
return ReduceTypedArrayMaxSizeInHeap(node);
case Runtime::kInlineJSCollectionGetTable:
@@ -321,6 +330,32 @@ Reduction JSIntrinsicLowering::ReduceGetSuperConstructor(Node* node) {
active_function_map, effect, control);
}
+Reduction JSIntrinsicLowering::ReduceArrayBufferViewField(
+ Node* node, FieldAccess const& access) {
+ Node* receiver = NodeProperties::GetValueInput(node, 0);
+ Node* effect = NodeProperties::GetEffectInput(node);
+ Node* control = NodeProperties::GetControlInput(node);
+
+ // Load the {receiver}s field.
+ Node* value = effect = graph()->NewNode(simplified()->LoadField(access),
+ receiver, effect, control);
+
+ // Check if the {receiver}s buffer was neutered.
+ Node* receiver_buffer = effect = graph()->NewNode(
+ simplified()->LoadField(AccessBuilder::ForJSArrayBufferViewBuffer()),
+ receiver, effect, control);
+ Node* check = effect = graph()->NewNode(
+ simplified()->ArrayBufferWasNeutered(), receiver_buffer, effect, control);
+
+ // Default to zero if the {receiver}s buffer was neutered.
+ value = graph()->NewNode(
+ common()->Select(MachineRepresentation::kTagged, BranchHint::kFalse),
+ check, jsgraph()->ZeroConstant(), value);
+
+ ReplaceWithValue(node, value, effect, control);
+ return Replace(value);
+}
+
Reduction JSIntrinsicLowering::ReduceMaxSmi(Node* node) {
Node* value = jsgraph()->Constant(Smi::kMaxValue);
ReplaceWithValue(node, value);
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698