Commit 5b4b1514 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[CSA] OOB check for Load/StoreFixedArrayElement from slow to normal assert

This CL enables out-of-bounds checks for debug builds when loading or
storing FixedArray elements. Since "--enable-slow-asserts" is not passed
through to mksnapshot, the OOB checks were basically never executed.

Bug: v8:7853
Change-Id: I81bdd9ac04868f9ffc362c3f4fd8fa3ddd122ee1
Reviewed-on: https://chromium-review.googlesource.com/1103568
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53812}
parent ce3c0064
......@@ -1894,7 +1894,7 @@ TNode<MaybeObject> CodeStubAssembler::LoadArrayElement(
PropertyArray::kLengthAndHashOffset);
// Check that index_node + additional_offset <= object.length.
// TODO(cbruni): Use proper LoadXXLength helpers
CSA_SLOW_ASSERT(
CSA_ASSERT(
this,
IsOffsetInBounds(
offset,
......@@ -1921,6 +1921,12 @@ TNode<Object> CodeStubAssembler::LoadFixedArrayElement(
// This function is currently used for non-FixedArrays (e.g., PropertyArrays)
// and thus the reasonable assert IsFixedArraySubclass(object) is
// untrue. TODO(marja): Fix.
CSA_SLOW_ASSERT(
this, Word32Or(IsHashTable(object),
Word32Or(IsFixedArray(object),
Word32Or(IsPropertyArray(object),
Word32Or(IsEphemeronHashTable(object),
IsContext(object))))));
CSA_ASSERT(this, IsNotWeakFixedArraySubclass(object));
TNode<MaybeObject> element =
LoadArrayElement(object, FixedArray::kHeaderSize, index_node,
......@@ -2517,12 +2523,28 @@ Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node,
FixedArray::kHeaderSize + additional_offset - kHeapObjectTag;
Node* offset = ElementOffsetFromIndex(index_node, HOLEY_ELEMENTS,
parameter_mode, header_size);
// TODO(cbruni): Enable check once we have TNodes in this method. Currently
// the bounds check will fail for PropertyArray due to the different length
// encoding.
// CSA_ASSERT(this,
// IsOffsetInBounds(offset, LoadAndUntagFixedArrayBaseLength(object),
// FixedArray::kHeaderSize));
STATIC_ASSERT(FixedArrayBase::kLengthOffset == WeakFixedArray::kLengthOffset);
STATIC_ASSERT(FixedArrayBase::kLengthOffset ==
PropertyArray::kLengthAndHashOffset);
// Check that index_node + additional_offset <= object.length.
// TODO(cbruni): Use proper LoadXXLength helpers
CSA_ASSERT(
this,
IsOffsetInBounds(
offset,
Select<IntPtrT>(
IsPropertyArray(object),
[=] {
TNode<IntPtrT> length_and_hash = LoadAndUntagObjectField(
object, PropertyArray::kLengthAndHashOffset);
return TNode<IntPtrT>::UncheckedCast(
DecodeWord<PropertyArray::LengthField>(length_and_hash));
},
[=] {
return LoadAndUntagObjectField(object,
FixedArrayBase::kLengthOffset);
}),
FixedArray::kHeaderSize));
if (barrier_mode == SKIP_WRITE_BARRIER) {
return StoreNoWriteBarrier(MachineRepresentation::kTagged, object, offset,
value);
......
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