Skip to content

Commit 3f954ac

Browse files
joyeecheungaduh95
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 7be7097 commit 3f954ac

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
@@ -82,6 +82,7 @@
8282
'v8_enable_direct_local%': 0,
8383
'v8_enable_map_packing%': 0,
8484
'v8_enable_pointer_compression_shared_cage%': 0,
85+
'v8_enable_external_code_space%': 0,
8586
'v8_enable_sandbox%': 0,
8687
'v8_enable_v8_checks%': 0,
8788
'v8_enable_zone_compression%': 0,
@@ -115,6 +116,7 @@
115116
['target_arch in "arm ia32 mips mipsel ppc"', {
116117
'v8_enable_pointer_compression': 0,
117118
'v8_enable_31bit_smis_on_64bit_arch': 0,
119+
'v8_enable_external_code_space': 0,
118120
'v8_enable_sandbox': 0
119121
}],
120122
['target_arch in "ppc64 s390x"', {
@@ -458,6 +460,9 @@
458460
['v8_enable_sandbox == 1', {
459461
'defines': ['V8_ENABLE_SANDBOX',],
460462
}],
463+
['v8_enable_external_code_space == 1', {
464+
'defines': ['V8_EXTERNAL_CODE_SPACE',],
465+
}],
461466
['v8_deprecation_warnings == 1', {
462467
'defines': ['V8_DEPRECATION_WARNINGS',],
463468
}],

configure.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,15 @@ def configure_v8(o, configs):
17101710
o['variables']['v8_use_siphash'] = 0 if options.without_siphash else 1
17111711
o['variables']['v8_enable_maglev'] = 1 if options.v8_enable_maglev else 0
17121712
o['variables']['v8_enable_pointer_compression'] = 1 if options.enable_pointer_compression else 0
1713-
o['variables']['v8_enable_sandbox'] = 1 if options.enable_pointer_compression else 0
1713+
# Using the sandbox requires always allocating array buffer backing stores in the sandbox.
1714+
# We currently have many backing stores tied to pointers from C++ land that are not
1715+
# even necessarily dynamic (e.g. in static storage) for fast communication between JS and C++.
1716+
# Until we manage to get rid of all those, v8_enable_sandbox cannot be used.
1717+
# Note that enabling pointer compression without enabling sandbox is unsupported by V8,
1718+
# so this can be broken at any time.
1719+
o['variables']['v8_enable_sandbox'] = 0
1720+
o['variables']['v8_enable_pointer_compression_shared_cage'] = 1 if options.enable_pointer_compression else 0
1721+
o['variables']['v8_enable_external_code_space'] = 1 if options.enable_pointer_compression else 0
17141722
o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0
17151723
o['variables']['v8_enable_shared_ro_heap'] = 0 if options.enable_pointer_compression or options.disable_shared_ro_heap else 1
17161724
o['variables']['v8_enable_extensible_ro_snapshot'] = 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
@@ -252,6 +252,11 @@
252252
# Sets -DV8_ENABLE_SANDBOX.
253253
'v8_enable_sandbox%': 0,
254254

255+
# Enable support for external code range relative to the pointer compression
256+
# cage.
257+
# Sets -DV8_EXTERNAL_CODE_SPACE.
258+
'v8_enable_external_code_space%': 0,
259+
255260
# Experimental feature for collecting per-class zone memory stats.
256261
# Requires use_rtti = true
257262
'v8_enable_precise_zone_stats%': 0,
@@ -384,6 +389,9 @@
384389
['v8_enable_sandbox==1', {
385390
'defines': ['V8_ENABLE_SANDBOX',],
386391
}],
392+
['v8_enable_external_code_space==1', {
393+
'defines': ['V8_EXTERNAL_CODE_SPACE',],
394+
}],
387395
['v8_enable_object_print==1', {
388396
'defines': ['OBJECT_PRINT',],
389397
}],

0 commit comments

Comments
 (0)