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); |