Skip to content

Commit bda0629

Browse files
joyeecheungmarco-ippolito
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 978e931 commit bda0629

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
'v8_enable_direct_local%': 0,
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,
@@ -114,6 +115,7 @@
114115
'v8_enable_pointer_compression': 0,
115116
'v8_enable_pointer_compression_shared_cage': 0,
116117
'v8_enable_31bit_smis_on_64bit_arch': 0,
118+
'v8_enable_external_code_space': 0,
117119
'v8_enable_sandbox': 0
118120
}],
119121
['target_arch in "ppc64 s390x"', {
@@ -424,6 +426,9 @@
424426
['v8_enable_sandbox == 1', {
425427
'defines': ['V8_ENABLE_SANDBOX',],
426428
}],
429+
['v8_enable_external_code_space == 1', {
430+
'defines': ['V8_EXTERNAL_CODE_SPACE',],
431+
}],
427432
['v8_deprecation_warnings == 1', {
428433
'defines': ['V8_DEPRECATION_WARNINGS',],
429434
}],

configure.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,15 @@ def configure_v8(o):
16081608
o['variables']['v8_use_siphash'] = 0 if options.without_siphash else 1
16091609
o['variables']['v8_enable_maglev'] = 1 if options.v8_enable_maglev else 0
16101610
o['variables']['v8_enable_pointer_compression'] = 1 if options.enable_pointer_compression else 0
1611-
o['variables']['v8_enable_sandbox'] = 1 if options.enable_pointer_compression else 0
1611+
# Using the sandbox requires always allocating array buffer backing stores in the sandbox.
1612+
# We currently have many backing stores tied to pointers from C++ land that are not
1613+
# even necessarily dynamic (e.g. in static storage) for fast communication between JS and C++.
1614+
# Until we manage to get rid of all those, v8_enable_sandbox cannot be used.
1615+
# Note that enabling pointer compression without enabling sandbox is unsupported by V8,
1616+
# so this can be broken at any time.
1617+
o['variables']['v8_enable_sandbox'] = 0
1618+
o['variables']['v8_enable_pointer_compression_shared_cage'] = 1 if options.enable_pointer_compression else 0
1619+
o['variables']['v8_enable_external_code_space'] = 1 if options.enable_pointer_compression else 0
16121620
o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0
16131621
o['variables']['v8_enable_shared_ro_heap'] = 0 if options.enable_pointer_compression or options.disable_shared_ro_heap else 1
16141622
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
@@ -20,9 +20,6 @@ void NodeTestEnvironment::SetUp() {
2020
NodeZeroIsolateTestFixture::platform.reset(
2121
new node::NodePlatform(kV8ThreadPoolSize, tracing_controller));
2222
v8::V8::InitializePlatform(NodeZeroIsolateTestFixture::platform.get());
23-
#ifdef V8_ENABLE_SANDBOX
24-
ASSERT_TRUE(v8::V8::InitializeSandbox());
25-
#endif
2623
cppgc::InitializeProcess(
2724
NodeZeroIsolateTestFixture::platform->GetPageAllocator());
2825

tools/v8_gypfiles/features.gypi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@
253253
# Sets -DV8_ENABLE_SANDBOX.
254254
'v8_enable_sandbox%': 0,
255255

256+
# Enable support for external code range relative to the pointer compression
257+
# cage.
258+
# Sets -DV8_EXTERNAL_CODE_SPACE.
259+
'v8_enable_external_code_space%': 0,
260+
256261
# Experimental feature for collecting per-class zone memory stats.
257262
# Requires use_rtti = true
258263
'v8_enable_precise_zone_stats%': 0,
@@ -371,6 +376,9 @@
371376
['v8_enable_sandbox==1', {
372377
'defines': ['V8_ENABLE_SANDBOX',],
373378
}],
379+
['v8_enable_external_code_space==1', {
380+
'defines': ['V8_EXTERNAL_CODE_SPACE',],
381+
}],
374382
['v8_enable_object_print==1', {
375383
'defines': ['OBJECT_PRINT',],
376384
}],

0 commit comments

Comments
 (0)