Unify invalid size error handling.
Bug: chromium:1198188 Change-Id: Iaf2cdd85124295d842ff6bb139ab0d85371c08ae Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2833920 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Hannes Payer <hpayer@chromium.org> Cr-Commit-Position: refs/heads/master@{#74028}
This commit is contained in:
parent
d90be52e98
commit
70cb6f50d2
@ -128,7 +128,7 @@ Handle<FixedArrayBase> FactoryBase<Impl>::NewFixedDoubleArray(
|
||||
int length, AllocationType allocation) {
|
||||
if (length == 0) return impl()->empty_fixed_array();
|
||||
if (length < 0 || length > FixedDoubleArray::kMaxLength) {
|
||||
FATAL("Fatal JavaScript invalid array length %d error", length);
|
||||
FATAL("Fatal JavaScript invalid size error %d", length);
|
||||
UNREACHABLE();
|
||||
}
|
||||
int size = FixedDoubleArray::SizeFor(length);
|
||||
@ -173,7 +173,7 @@ template <typename Impl>
|
||||
Handle<ByteArray> FactoryBase<Impl>::NewByteArray(int length,
|
||||
AllocationType allocation) {
|
||||
if (length < 0 || length > ByteArray::kMaxLength) {
|
||||
FATAL("Fatal JavaScript invalid array length %d error", length);
|
||||
FATAL("Fatal JavaScript invalid size error %d", length);
|
||||
UNREACHABLE();
|
||||
}
|
||||
int size = ByteArray::SizeFor(length);
|
||||
@ -191,7 +191,7 @@ Handle<BytecodeArray> FactoryBase<Impl>::NewBytecodeArray(
|
||||
int length, const byte* raw_bytecodes, int frame_size, int parameter_count,
|
||||
Handle<FixedArray> constant_pool) {
|
||||
if (length < 0 || length > BytecodeArray::kMaxLength) {
|
||||
FATAL("Fatal JavaScript invalid array length %d error", length);
|
||||
FATAL("Fatal JavaScript invalid size error %d", length);
|
||||
UNREACHABLE();
|
||||
}
|
||||
// Bytecode array is AllocationType::kOld, so constant pool array should be
|
||||
@ -694,7 +694,7 @@ template <typename Impl>
|
||||
Handle<FreshlyAllocatedBigInt> FactoryBase<Impl>::NewBigInt(
|
||||
int length, AllocationType allocation) {
|
||||
if (length < 0 || length > BigInt::kMaxLength) {
|
||||
FATAL("Fatal JavaScript invalid BigInt length %d error", length);
|
||||
FATAL("Fatal JavaScript invalid size error %d", length);
|
||||
UNREACHABLE();
|
||||
}
|
||||
HeapObject result = AllocateRawWithImmortalMap(
|
||||
@ -829,7 +829,7 @@ template <typename Impl>
|
||||
HeapObject FactoryBase<Impl>::AllocateRawFixedArray(int length,
|
||||
AllocationType allocation) {
|
||||
if (length < 0 || length > FixedArray::kMaxLength) {
|
||||
FATAL("Fatal JavaScript invalid array length %d error", length);
|
||||
FATAL("Fatal JavaScript invalid size error %d", length);
|
||||
UNREACHABLE();
|
||||
}
|
||||
return AllocateRawArray(FixedArray::SizeFor(length), allocation);
|
||||
@ -839,7 +839,7 @@ template <typename Impl>
|
||||
HeapObject FactoryBase<Impl>::AllocateRawWeakArrayList(
|
||||
int capacity, AllocationType allocation) {
|
||||
if (capacity < 0 || capacity > WeakArrayList::kMaxCapacity) {
|
||||
FATAL("Fatal JavaScript invalid WeakArray capacity %d error", capacity);
|
||||
FATAL("Fatal JavaScript invalid size error %d", capacity);
|
||||
UNREACHABLE();
|
||||
}
|
||||
return AllocateRawArray(WeakArrayList::SizeForCapacity(capacity), allocation);
|
||||
@ -885,7 +885,7 @@ FactoryBase<Impl>::NewSwissNameDictionaryWithCapacity(
|
||||
}
|
||||
|
||||
if (capacity < 0 || capacity > SwissNameDictionary::MaxCapacity()) {
|
||||
FATAL("Fatal JavaScript invalid dictionary capacity %d error", capacity);
|
||||
FATAL("Fatal JavaScript invalid size error %d", capacity);
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ MaybeHandle<FixedArray> Factory::TryNewFixedArray(
|
||||
Handle<FixedArray> Factory::NewUninitializedFixedArray(int length) {
|
||||
if (length == 0) return empty_fixed_array();
|
||||
if (length < 0 || length > FixedArray::kMaxLength) {
|
||||
FATAL("Fatal JavaScript invalid array length %d error", length);
|
||||
FATAL("Fatal JavaScript invalid size error %d", length);
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ using NewUninitializedFixedArrayTest = TestWithIsolateAndZone;
|
||||
|
||||
TEST_F(NewUninitializedFixedArrayTest, ThrowOnNegativeLength) {
|
||||
ASSERT_DEATH_IF_SUPPORTED({ factory()->NewUninitializedFixedArray(-1); },
|
||||
"Fatal JavaScript invalid array length -1 error");
|
||||
"Fatal JavaScript invalid size error -1");
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -13,7 +13,7 @@ using NewFixedDoubleArrayTest = TestWithIsolateAndZone;
|
||||
|
||||
TEST_F(NewFixedDoubleArrayTest, ThrowOnNegativeLength) {
|
||||
ASSERT_DEATH_IF_SUPPORTED({ factory()->NewFixedDoubleArray(-1); },
|
||||
"Fatal JavaScript invalid array length -1 error");
|
||||
"Fatal JavaScript invalid size error -1");
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
Loading…
Reference in New Issue
Block a user