Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use allocationtype kold in v8 scriptormodule legacy lifetime (#3…
- Loading branch information
1 parent
dd4eae8
commit b61805b
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
patches/v8/fix_use_allocationtype_kold_in_v8_scriptormodule_legacy_lifetime.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: VerteDinde <khammond@slack-corp.com> | ||
Date: Tue, 4 Jan 2022 14:55:00 -0800 | ||
Subject: fix: use allocationtype kold in v8 scriptormodule legacy lifetime | ||
|
||
Changed in this CL: https://chromium-review.googlesource.com/c/v8/v8/+/3211575 | ||
Upstream proposed fix: https://chromium-review.googlesource.com/c/v8/v8/+/3354087 | ||
|
||
Enabling V8_SCRIPTORMODULE_LEGACY_LIFETIME is necessary to fix ESM in | ||
Node.js, but Blink expects old allocations so we change this in the | ||
interim while Node.js works to remove their usage of WeakRefs to | ||
ScriptOrModule. | ||
|
||
This patch can be removed when the upsteam fix is merged, or | ||
when support is added in Node.js | ||
|
||
diff --git a/src/heap/factory-base.cc b/src/heap/factory-base.cc | ||
index 89eb0defc2c1f1d2f6f59c3fb107d844e0c7f986..509cc193f339fc2d44ee493c6fe6c17c024b55fb 100644 | ||
--- a/src/heap/factory-base.cc | ||
+++ b/src/heap/factory-base.cc | ||
@@ -247,7 +247,7 @@ Handle<Script> FactoryBase<Impl>::NewScriptWithId( | ||
// Create and initialize script object. | ||
ReadOnlyRoots roots = read_only_roots(); | ||
#ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME | ||
- Handle<ArrayList> list = NewArrayList(0); | ||
+ Handle<ArrayList> list = NewArrayList(0, AllocationType::kOld); | ||
#endif | ||
Handle<Script> script = handle( | ||
NewStructInternal<Script>(SCRIPT_TYPE, AllocationType::kOld), isolate()); | ||
@@ -283,8 +283,10 @@ Handle<Script> FactoryBase<Impl>::NewScriptWithId( | ||
} | ||
|
||
template <typename Impl> | ||
-Handle<ArrayList> FactoryBase<Impl>::NewArrayList(int size) { | ||
- Handle<FixedArray> fixed_array = NewFixedArray(size + ArrayList::kFirstIndex); | ||
+Handle<ArrayList> FactoryBase<Impl>::NewArrayList(int size, | ||
+ AllocationType allocation) { | ||
+ Handle<FixedArray> fixed_array = | ||
+ NewFixedArray(size + ArrayList::kFirstIndex, allocation); | ||
fixed_array->set_map_no_write_barrier(read_only_roots().array_list_map()); | ||
Handle<ArrayList> result = Handle<ArrayList>::cast(fixed_array); | ||
result->SetLength(0); | ||
diff --git a/src/heap/factory-base.h b/src/heap/factory-base.h | ||
index 9e45c00a6c7d3dbc44d8f13383a22a40f757d5a7..23bd405d5d660556e23bff23986013fe3b0c627d 100644 | ||
--- a/src/heap/factory-base.h | ||
+++ b/src/heap/factory-base.h | ||
@@ -157,7 +157,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase | ||
Handle<Script> NewScriptWithId(Handle<PrimitiveHeapObject> source, | ||
int script_id); | ||
|
||
- Handle<ArrayList> NewArrayList(int size); | ||
+ Handle<ArrayList> NewArrayList( | ||
+ int size, AllocationType allocation = AllocationType::kYoung); | ||
|
||
Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral( | ||
FunctionLiteral* literal, Handle<Script> script, bool is_toplevel); |