Skip to content

Commit ac87061

Browse files
joyeecheungnodejs-github-bot
authored andcommitted
build: fix pointer compression builds
- Remove usage of deprecated V8::InitializeSandbox(). - External code space and pointer compression shared cage must be enabled when pointer compression builds are enabled. - We cannot enable the sandbox because that requires allocating the array buffer backing stores in the sandbox - we currently have many backing stores tied to pointers from C++ land that are not even necessarily dynamic (e.g. in static storage). Until we manage to get rid of all those, sandbox cannot be enabled. Note that enabling pointer compression without enabling sandbox is unsupported by V8, and can be broken at any time. PR-URL: #58171 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent db2aae8 commit ac87061

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

common.gypi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
# Variables controlling external defines exposed in public headers.
8181
'v8_enable_map_packing%': 0,
8282
'v8_enable_pointer_compression_shared_cage%': 0,
83+
'v8_enable_external_code_space%': 0,
8384
'v8_enable_sandbox%': 0,
8485
'v8_enable_v8_checks%': 0,
8586
'v8_enable_zone_compression%': 0,
@@ -113,6 +114,7 @@
113114
['target_arch in "arm ia32 mips mipsel"', {
114115
'v8_enable_pointer_compression': 0,
115116
'v8_enable_31bit_smis_on_64bit_arch': 0,
117+
'v8_enable_external_code_space': 0,
116118
'v8_enable_sandbox': 0
117119
}],
118120
['target_arch in "ppc64 s390x"', {
@@ -456,6 +458,9 @@
456458
['v8_enable_sandbox == 1', {
457459
'defines': ['V8_ENABLE_SANDBOX',],
458460
}],
461+
['v8_enable_external_code_space == 1', {
462+
'defines': ['V8_EXTERNAL_CODE_SPACE',],
463+
}],
459464
['v8_deprecation_warnings == 1', {
460465
'defines': ['V8_DEPRECATION_WARNINGS',],
461466
}],

configure.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,15 @@ def configure_v8(o, configs):
17181718
o['variables']['v8_enable_maglev'] = B(not options.v8_disable_maglev and
17191719
o['variables']['target_arch'] in maglev_enabled_architectures)
17201720
o['variables']['v8_enable_pointer_compression'] = 1 if options.enable_pointer_compression else 0
1721-
o['variables']['v8_enable_sandbox'] = 1 if options.enable_pointer_compression else 0
1721+
# Using the sandbox requires always allocating array buffer backing stores in the sandbox.
1722+
# We currently have many backing stores tied to pointers from C++ land that are not
1723+
# even necessarily dynamic (e.g. in static storage) for fast communication between JS and C++.
1724+
# Until we manage to get rid of all those, v8_enable_sandbox cannot be used.
1725+
# Note that enabling pointer compression without enabling sandbox is unsupported by V8,
1726+
# so this can be broken at any time.
1727+
o['variables']['v8_enable_sandbox'] = 0
1728+
o['variables']['v8_enable_pointer_compression_shared_cage'] = 1 if options.enable_pointer_compression else 0
1729+
o['variables']['v8_enable_external_code_space'] = 1 if options.enable_pointer_compression else 0
17221730
o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0
17231731
o['variables']['v8_enable_extensible_ro_snapshot'] = 0
17241732
o['variables']['v8_trace_maps'] = 1 if options.trace_maps else 0

test/cctest/node_test_fixture.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ void NodeTestEnvironment::SetUp() {
2121
NodeZeroIsolateTestFixture::platform.reset(
2222
new node::NodePlatform(kV8ThreadPoolSize, tracing_controller));
2323
v8::V8::InitializePlatform(NodeZeroIsolateTestFixture::platform.get());
24-
#ifdef V8_ENABLE_SANDBOX
25-
ASSERT_TRUE(v8::V8::InitializeSandbox());
26-
#endif
2724
cppgc::InitializeProcess(
2825
NodeZeroIsolateTestFixture::platform->GetPageAllocator());
2926

tools/v8_gypfiles/features.gypi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@
242242
# Sets -DV8_ENABLE_SANDBOX.
243243
'v8_enable_sandbox%': 0,
244244

245+
# Enable support for external code range relative to the pointer compression
246+
# cage.
247+
# Sets -DV8_EXTERNAL_CODE_SPACE.
248+
'v8_enable_external_code_space%': 0,
249+
245250
# Experimental feature for collecting per-class zone memory stats.
246251
# Requires use_rtti = true
247252
'v8_enable_precise_zone_stats%': 0,
@@ -374,6 +379,9 @@
374379
['v8_enable_sandbox==1', {
375380
'defines': ['V8_ENABLE_SANDBOX',],
376381
}],
382+
['v8_enable_external_code_space==1', {
383+
'defines': ['V8_EXTERNAL_CODE_SPACE',],
384+
}],
377385
['v8_enable_object_print==1', {
378386
'defines': ['OBJECT_PRINT',],
379387
}],

0 commit comments

Comments
 (0)