Commit dc3fc764 authored by Théotime Grohens's avatar Théotime Grohens Committed by Commit Bot

[dataview] Add non-Smi deopts in TurboFan DataView inlining

This CL tries to reduce as much as possible the emission of Float64
operations in the inlining of DataView methods.

It adds CheckSmi calls guarding the main variables that the
methods use, and deopts back to the baseline when outside of Smi range.
This should happen extremely rarely anyway, since we don't allow
ArrayBuffers to be larger than that by default.

Change-Id: I26fdd7b6884507a3a555dea114cf30da487dd34c
Reviewed-on: https://chromium-review.googlesource.com/1151194Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Théotime Grohens <theotime@google.com>
Cr-Commit-Position: refs/heads/master@{#54721}
parent 12a63796
......@@ -6632,7 +6632,7 @@ Reduction JSCallReducer::ReduceArrayBufferViewAccessor(
}
namespace {
int ExternalArrayElementSize(const ExternalArrayType element_type) {
uint32_t ExternalArrayElementSize(const ExternalArrayType element_type) {
switch (element_type) {
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
case kExternal##Type##Array: \
......@@ -6699,23 +6699,34 @@ Reduction JSCallReducer::ReduceDataViewPrototypeGet(
p.feedback()),
check_neutered, effect, control);
// Get the byte offset and byte length of the {receiver}.
// Get the byte offset and byte length of the {receiver},
// and deopt if they aren't Smis.
Node* byte_offset = effect =
graph()->NewNode(simplified()->LoadField(
AccessBuilder::ForJSArrayBufferViewByteOffset()),
receiver, effect, control);
byte_offset = effect = graph()->NewNode(
simplified()->CheckSmi(p.feedback()), byte_offset, effect, control);
Node* byte_length = effect =
graph()->NewNode(simplified()->LoadField(
AccessBuilder::ForJSArrayBufferViewByteLength()),
receiver, effect, control);
byte_length = effect = graph()->NewNode(
simplified()->CheckSmi(p.feedback()), byte_length, effect, control);
// The end offset is the offset plus the element size
// of the type that we want to load.
int element_size = ExternalArrayElementSize(element_type);
uint32_t element_size = ExternalArrayElementSize(element_type);
Node* end_offset = graph()->NewNode(simplified()->NumberAdd(), offset,
jsgraph()->Constant(element_size));
// Also deopt if this is not a Smi to avoid Float64 math.
end_offset = effect = graph()->NewNode(simplified()->CheckSmi(p.feedback()),
end_offset, effect, control);
// We need to check that {end_offset} <= {byte_length}.
Node* check_bounds = graph()->NewNode(simplified()->NumberLessThanOrEqual(),
end_offset, byte_length);
......@@ -6811,23 +6822,34 @@ Reduction JSCallReducer::ReduceDataViewPrototypeSet(
p.feedback()),
check_neutered, effect, control);
// Get the byte offset and byte length of the {receiver}.
// Get the byte offset and byte length of the {receiver},
// and deopt if they aren't Smis.
Node* byte_offset = effect =
graph()->NewNode(simplified()->LoadField(
AccessBuilder::ForJSArrayBufferViewByteOffset()),
receiver, effect, control);
byte_offset = effect = graph()->NewNode(
simplified()->CheckSmi(p.feedback()), byte_offset, effect, control);
Node* byte_length = effect =
graph()->NewNode(simplified()->LoadField(
AccessBuilder::ForJSArrayBufferViewByteLength()),
receiver, effect, control);
byte_length = effect = graph()->NewNode(
simplified()->CheckSmi(p.feedback()), byte_length, effect, control);
// The end offset is the offset plus the element size
// of the type that we want to store.
int element_size = ExternalArrayElementSize(element_type);
uint32_t element_size = ExternalArrayElementSize(element_type);
Node* end_offset = graph()->NewNode(simplified()->NumberAdd(), offset,
jsgraph()->Constant(element_size));
// Also deopt if this is not a Smi to avoid Float64 math.
end_offset = effect = graph()->NewNode(simplified()->CheckSmi(p.feedback()),
end_offset, effect, control);
// We need to check that {end_offset} <= {byte_length}.
Node* check_bounds = graph()->NewNode(simplified()->NumberLessThanOrEqual(),
end_offset, byte_length);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment