diff --git a/configure.py b/configure.py index d9d75443e7c6..c27148781d86 100755 --- a/configure.py +++ b/configure.py @@ -56,6 +56,7 @@ valid_intl_modes = ('none', 'small-icu', 'full-icu', 'system-icu') icu_versions = json.loads((tools_path / 'icu' / 'icu_versions.json').read_text(encoding='utf-8')) maglev_enabled_architectures = ('x64', 'arm', 'arm64', 'ppc64', 's390x', 'riscv64') +sparkplug_plus_enabled_architectures = ('x64', 'arm64', 'loong64') # builtins may be removed later if they have been disabled by options shareable_builtins = {'undici/undici': 'deps/undici/undici.js', @@ -1235,6 +1236,17 @@ default=None, help=f"Disable V8's Maglev compiler. {maglev_enabled_by_default_help}") +sparkplug_plus_enabled_by_default_help = ( + f"(Sparkplug+ is enabled on {','.join(sparkplug_plus_enabled_architectures)} " + "when short builtin calls are enabled, which is the default on x64)") + +parser.add_argument('--v8-disable-sparkplug-plus', + action='store_true', + dest='v8_disable_sparkplug_plus', + default=None, + help="Disable V8's Sparkplug+ (dynamic patching of baseline code). " + + sparkplug_plus_enabled_by_default_help) + parser.add_argument('--v8-enable-short-builtin-calls', action='store_true', dest='v8_enable_short_builtin_calls', @@ -2281,6 +2293,12 @@ def configure_v8(o, configs): o['variables']['v8_enable_hugepage'] = 1 if options.v8_enable_hugepage else 0 if options.v8_enable_short_builtin_calls or o['variables']['target_arch'] == 'x64': o['variables']['v8_enable_short_builtin_calls'] = 1 + # Sparkplug+ patches pc-relative builtin calls in baseline code, so V8 only + # uses it when short builtin calls are enabled. + o['variables']['v8_enable_sparkplug_plus'] = B( + not options.v8_disable_sparkplug_plus and + o['variables']['target_arch'] in sparkplug_plus_enabled_architectures and + o['variables'].get('v8_enable_short_builtin_calls') == 1) if options.v8_enable_snapshot_compression: o['variables']['v8_enable_snapshot_compression'] = 1 if all(opt in sys.argv for opt in ['--v8-enable-object-print', '--v8-disable-object-print']): diff --git a/tools/v8_gypfiles/features.gypi b/tools/v8_gypfiles/features.gypi index 305c81eab34d..87bbacebb1c3 100644 --- a/tools/v8_gypfiles/features.gypi +++ b/tools/v8_gypfiles/features.gypi @@ -287,6 +287,11 @@ # Sets -DV8_ENABLE_SPARKPLUG. 'v8_enable_sparkplug%': 1, + # Enable Sparkplug+ (dynamic patching of Sparkplug baseline code). + # Requires v8_enable_sparkplug. + # Sets -DV8_ENABLE_SPARKPLUG_PLUS. + 'v8_enable_sparkplug_plus%': 0, + # Whether custom embedder snapshots may extend (= allocate new objects in) # ReadOnlySpace. 'v8_enable_extensible_ro_snapshot%': 1, @@ -533,6 +538,9 @@ ['v8_enable_sparkplug==1', { 'defines': ['V8_ENABLE_SPARKPLUG',], }], + ['v8_enable_sparkplug==1 and v8_enable_sparkplug_plus==1', { + 'defines': ['V8_ENABLE_SPARKPLUG_PLUS',], + }], ['v8_enable_maglev==1', { 'defines': ['V8_ENABLE_MAGLEV',], }],