Commit d6f8af01 authored by Romain Pokrzywka's avatar Romain Pokrzywka Committed by V8 LUCI CQ

[heap] Fix NewArrayList tripping DCHECK with LocalFactory

LocalFactory::AllocateRaw() only allows the kOld and kSharedOld
allocation types, but NewArrayList() calls NewFixedArray() without
an explicit allocation argument, which then defaults to kYoung.

Add an allocation argument to NewArrayList() with the same default
value as for NewFixedArray() and pass kOld when calling it from
NewScriptWithId() to avoid tripping the DCHECK with LocalFactory.

Follow-up to https://crrev.com/c/3211575

Bug: chromium:1244145
Change-Id: I88d394bda250c45bf49141b78c09f6ca4a61dbe3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3354087Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78540}
parent 2cc1b981
...@@ -250,7 +250,7 @@ Handle<Script> FactoryBase<Impl>::NewScriptWithId( ...@@ -250,7 +250,7 @@ Handle<Script> FactoryBase<Impl>::NewScriptWithId(
// Create and initialize script object. // Create and initialize script object.
ReadOnlyRoots roots = read_only_roots(); ReadOnlyRoots roots = read_only_roots();
#ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME #ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME
Handle<ArrayList> list = NewArrayList(0); Handle<ArrayList> list = NewArrayList(0, AllocationType::kOld);
#endif #endif
Handle<Script> script = handle( Handle<Script> script = handle(
NewStructInternal<Script>(SCRIPT_TYPE, AllocationType::kOld), isolate()); NewStructInternal<Script>(SCRIPT_TYPE, AllocationType::kOld), isolate());
...@@ -286,8 +286,10 @@ Handle<Script> FactoryBase<Impl>::NewScriptWithId( ...@@ -286,8 +286,10 @@ Handle<Script> FactoryBase<Impl>::NewScriptWithId(
} }
template <typename Impl> template <typename Impl>
Handle<ArrayList> FactoryBase<Impl>::NewArrayList(int size) { Handle<ArrayList> FactoryBase<Impl>::NewArrayList(int size,
Handle<FixedArray> fixed_array = NewFixedArray(size + ArrayList::kFirstIndex); AllocationType allocation) {
Handle<FixedArray> fixed_array =
NewFixedArray(size + ArrayList::kFirstIndex, allocation);
fixed_array->set_map_no_write_barrier(read_only_roots().array_list_map()); fixed_array->set_map_no_write_barrier(read_only_roots().array_list_map());
Handle<ArrayList> result = Handle<ArrayList>::cast(fixed_array); Handle<ArrayList> result = Handle<ArrayList>::cast(fixed_array);
result->SetLength(0); result->SetLength(0);
......
...@@ -157,7 +157,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase ...@@ -157,7 +157,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase
Handle<Script> NewScriptWithId(Handle<PrimitiveHeapObject> source, Handle<Script> NewScriptWithId(Handle<PrimitiveHeapObject> source,
int script_id); int script_id);
Handle<ArrayList> NewArrayList(int size); Handle<ArrayList> NewArrayList(
int size, AllocationType allocation = AllocationType::kYoung);
Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral( Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral(
FunctionLiteral* literal, Handle<Script> script, bool is_toplevel); FunctionLiteral* literal, Handle<Script> script, bool is_toplevel);
......
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