/
fix_use_allocationtype_kold_in_v8_scriptormodule_legacy_lifetime.patch
56 lines (49 loc) · 2.67 KB
/
fix_use_allocationtype_kold_in_v8_scriptormodule_legacy_lifetime.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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);