Commit e0e08d52 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[heap] Remove unused code for TypedArrays in RightTrim.

This code is never used, and we don't right trim TypedArrays.

Bug: 
Change-Id: Ic3e32b194fb10ecd067449c755b1982c87c98257
Reviewed-on: https://chromium-review.googlesource.com/721541Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48623}
parent ef2a8705
......@@ -2903,12 +2903,8 @@ void Heap::RightTrimFixedArray(FixedArrayBase* object, int elements_to_trim) {
DCHECK_GE(elements_to_trim, 0);
int bytes_to_trim;
if (object->IsFixedTypedArrayBase()) {
InstanceType type = object->map()->instance_type();
bytes_to_trim =
FixedTypedArrayBase::TypedArraySize(type, len) -
FixedTypedArrayBase::TypedArraySize(type, len - elements_to_trim);
} else if (object->IsByteArray()) {
DCHECK(!object->IsFixedTypedArrayBase());
if (object->IsByteArray()) {
int new_size = ByteArray::SizeFor(len - elements_to_trim);
bytes_to_trim = ByteArray::SizeFor(len) - new_size;
DCHECK_GE(bytes_to_trim, 0);
......
......@@ -4742,58 +4742,6 @@ TEST(WritableVsImmortalRoots) {
}
}
static void TestRightTrimFixedTypedArray(i::ExternalArrayType type,
int initial_length,
int elements_to_trim) {
v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
Handle<FixedTypedArrayBase> array =
factory->NewFixedTypedArray(initial_length, type, true);
int old_size = array->size();
heap->RightTrimFixedArray(*array, elements_to_trim);
// Check that free space filler is at the right place and did not smash the
// array header.
CHECK(array->IsFixedArrayBase());
CHECK_EQ(initial_length - elements_to_trim, array->length());
int new_size = array->size();
if (new_size != old_size) {
// Free space filler should be created in this case.
Address next_obj_address = array->address() + array->size();
CHECK(HeapObject::FromAddress(next_obj_address)->IsFiller());
}
CcTest::CollectAllAvailableGarbage();
}
TEST(Regress472513) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
// The combination of type/initial_length/elements_to_trim triggered
// typed array header smashing with free space filler (crbug/472513).
// 64-bit cases.
TestRightTrimFixedTypedArray(i::kExternalUint8Array, 32, 6);
TestRightTrimFixedTypedArray(i::kExternalUint8Array, 32 - 7, 6);
TestRightTrimFixedTypedArray(i::kExternalUint16Array, 16, 6);
TestRightTrimFixedTypedArray(i::kExternalUint16Array, 16 - 3, 6);
TestRightTrimFixedTypedArray(i::kExternalUint32Array, 8, 6);
TestRightTrimFixedTypedArray(i::kExternalUint32Array, 8 - 1, 6);
// 32-bit cases.
TestRightTrimFixedTypedArray(i::kExternalUint8Array, 16, 3);
TestRightTrimFixedTypedArray(i::kExternalUint8Array, 16 - 3, 3);
TestRightTrimFixedTypedArray(i::kExternalUint16Array, 8, 3);
TestRightTrimFixedTypedArray(i::kExternalUint16Array, 8 - 1, 3);
TestRightTrimFixedTypedArray(i::kExternalUint32Array, 4, 3);
}
TEST(WeakFixedArray) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
......
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