forked from v8/v8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.gn
8209 lines (7524 loc) · 278 KB
/
BUILD.gn
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/config.gni")
import("//build/config/arm.gni")
import("//build/config/coverage/coverage.gni")
import("//build/config/dcheck_always_on.gni")
import("//build/config/host_byteorder.gni")
import("//build/config/mips.gni")
import("//build/config/riscv.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build_overrides/build.gni")
import("gni/snapshot_toolchain.gni")
import("gni/v8.gni")
# Specifies if the target build is a simulator build. Comparing target cpu
# with v8 target cpu to not affect simulator builds for making cross-compile
# snapshots.
target_is_simulator = (target_cpu != v8_target_cpu && !v8_multi_arch_build) ||
(current_cpu != v8_current_cpu && v8_multi_arch_build)
# For faster Windows builds. See https://crbug.com/v8/8475.
emit_builtins_as_inline_asm = is_win && is_clang
declare_args() {
# Print to stdout on Android.
v8_android_log_stdout = false
# Dynamically set an additional dependency from v8/custom_deps.
v8_custom_deps = ""
# Turns on all V8 debug features. Enables running V8 in a pseudo debug mode
# within a release Chrome.
v8_enable_debugging_features = is_debug
# Sets -DV8_ENABLE_FUTURE.
v8_enable_future = false
# Sets -DENABLE_SYSTEM_INSTRUMENTATION. Enables OS-dependent event tracing
v8_enable_system_instrumentation = (is_win || is_mac) && !v8_use_perfetto
# Sets -DV8_ENABLE_ETW_STACK_WALKING. Enables ETW Stack Walking
v8_enable_etw_stack_walking = is_win
# Sets the GUID for the ETW provider
v8_etw_guid = ""
# Sets -DVERIFY_HEAP.
v8_enable_verify_heap = ""
# Sets -DVERIFY_PREDICTABLE
v8_enable_verify_predictable = false
# Enable compiler warnings when using V8_DEPRECATED apis.
v8_deprecation_warnings = true
# Enable compiler warnings when using V8_DEPRECATE_SOON apis.
v8_imminent_deprecation_warnings = true
# Embeds the given script into the snapshot.
v8_embed_script = ""
# Allows the embedder to add a custom suffix to the version string.
v8_embedder_string = ""
# Sets -dENABLE_DISASSEMBLER.
v8_enable_disassembler = ""
# Sets the number of internal fields on promise objects.
v8_promise_internal_field_count = 0
# Sets -dENABLE_GDB_JIT_INTERFACE.
v8_enable_gdbjit = ""
# Sets -dENABLE_VTUNE_JIT_INTERFACE.
v8_enable_vtunejit = false
# Sets -dENABLE_VTUNE_TRACEMARK.
v8_enable_vtunetracemark = false
# Sets -dENABLE_HUGEPAGE
v8_enable_hugepage = false
# Sets -dV8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION.
#
# This flag speeds up the performance of fork/execve on Linux systems for
# embedders which use it (like Node.js). It works by marking the pages that
# V8 allocates as MADV_DONTFORK. Without MADV_DONTFORK, the Linux kernel
# spends a long time manipulating page mappings on fork and exec which the
# child process doesn't generally need to access.
#
# See v8:7381 for more details.
v8_enable_private_mapping_fork_optimization = false
# Sets -dENABLE_HANDLE_ZAPPING.
v8_enable_handle_zapping = is_asan || is_debug
# Enable slow dchecks.
v8_enable_slow_dchecks = false
# Enable fast mksnapshot runs.
v8_enable_fast_mksnapshot = false
# Optimize code for Torque executable, even during a debug build.
v8_enable_fast_torque = ""
# Enable the registration of unwinding info for Windows x64 and ARM64.
v8_win64_unwinding_info = true
# Enable code comments for builtins in the snapshot (impacts performance).
# This also enables v8_code_comments.
v8_enable_snapshot_code_comments = false
# Allow runtime-enabled code comments (with --code-comments). Enabled by
# default in debug builds.
# Sets -dV8_CODE_COMMENTS
v8_code_comments = ""
# Allow runtime-enabled debug code (with --debug-code). Enabled by default in
# debug builds.
# Sets -dV8_ENABLE_DEBUG_CODE
v8_enable_debug_code = ""
# Enable native counters from the snapshot (impacts performance, sets
# -dV8_SNAPSHOT_NATIVE_CODE_COUNTERS).
# This option will generate extra code in the snapshot to increment counters,
# as per the --native-code-counters flag.
v8_enable_snapshot_native_code_counters = ""
# Use pre-generated static root pointer values from static-roots.h.
v8_enable_static_roots = ""
# Mode used by gen-static-roots.py to have a heap layout which is identical
# to when v8_enable_static_roots is enabled.
v8_enable_static_roots_generation = false
# Enable code-generation-time checking of types in the CodeStubAssembler.
v8_enable_verify_csa = false
# Enable pointer compression (sets -dV8_COMPRESS_POINTERS).
v8_enable_pointer_compression = ""
v8_enable_pointer_compression_shared_cage = ""
v8_enable_31bit_smis_on_64bit_arch = false
# Sets -dOBJECT_PRINT.
v8_enable_object_print = ""
# Sets -dV8_TRACE_MAPS.
v8_enable_trace_maps = ""
# Sets -dV8_ENABLE_CHECKS.
v8_enable_v8_checks = ""
# Sets -dV8_TRACE_UNOPTIMIZED.
v8_enable_trace_unoptimized = ""
v8_enable_trace_ignition = false
v8_enable_trace_baseline_exec = false
# Sets -dV8_TRACE_FEEDBACK_UPDATES.
v8_enable_trace_feedback_updates = false
# Sets -dV8_ATOMIC_OBJECT_FIELD_WRITES and turns all field write operations
# into relaxed atomic operations.
v8_enable_atomic_object_field_writes = ""
# Controls the default value of v8_enable_concurrent_marking_state. See the
# default setting code below.
v8_enable_concurrent_marking = true
# Sets -dV8_IGNITION_DISPATCH_COUNTING.
# Enables counting frequencies of bytecode dispatches. After building in this
# configuration, subsequent runs of d8 can output frequencies for each pair
# of (current, next) bytecode instructions executed if you specify
# --trace-ignition-dispatches-output-file, or can generate a JS object with
# those frequencies if you run with --expose-ignition-statistics and call the
# extension function getIgnitionDispatchCounters().
v8_enable_ignition_dispatch_counting = false
# Runs mksnapshot with --turbo-profiling. After building in this
# configuration, any subsequent run of d8 will output information about usage
# of basic blocks in builtins.
v8_enable_builtins_profiling = false
# Runs mksnapshot with --turbo-profiling-verbose. After building in this
# configuration, any subsequent run of d8 will output information about usage
# of basic blocks in builtins, including the schedule and disassembly of all
# used builtins.
v8_enable_builtins_profiling_verbose = false
# This build flag is used to input a builtin pgo file containing raw
# execution counts (as opposed to branch hints), which are embedded into
# the `--trace-turbo` .json file from `mksnapshot`.
v8_log_builtins_block_count_input = ""
# This build flag is used to control whether reorder builtins acoording to
# the call graph with C3 algorithm based builtin PGO profiling.
v8_enable_builtins_reordering = true
# Provides the given V8 log file as an input to mksnapshot, where it can be
# used for profile-guided optimization of builtins.
#
# To do profile-guided optimizations of builtins:
# 1. Build with v8_enable_builtins_profiling = true
# 2. Run your chosen workload with the --turbo-profiling-output flag.
# For Chrome, the invocation might look like this:
# chrome --no-sandbox --disable-extensions
# --js-flags="--turbo-profiling-output=v8.builtins.pgo"
# "http://localhost/test-suite"
# 3. Run tools/builtins-pgo/get_hints.py to produce the branch hints,
# selecting min_count and threshold_ratio as you wish.
# 4. Optionally repeat steps 2-3 for additional workloads, and use
# tools/builtins-pgo/combine_hints.py to combine the hints produced in
# step 3 into a single file.
# 5. Build again with v8_builtins_profiling_log_file set to the file created
# in step 3 or 4.
v8_builtins_profiling_log_file = "default"
# Enables various testing features.
v8_enable_test_features = ""
# Enable short builtins call instruction sequences by un-embedding builtins.
# Sets -dV8_SHORT_BUILTIN_CALLS
v8_enable_short_builtin_calls = ""
# Enable support for external code range relative to the pointer compression
# cage.
# Sets -dV8_EXTERNAL_CODE_SPACE
v8_enable_external_code_space = ""
# With post mortem support enabled, metadata is embedded into libv8 that
# describes various parameters of the VM for use by debuggers. See
# tools/gen-postmortem-metadata.py for details.
v8_postmortem_support = false
# Use Siphash as added protection against hash flooding attacks.
v8_use_siphash = false
# Switches off inlining in V8.
v8_no_inline = false
# Override OS page size when generating snapshot
v8_os_page_size = "0"
# Similar to vfp but on MIPS.
v8_can_use_fpu_instructions = true
# Similar to the ARM hard float ABI but on MIPS.
v8_use_mips_abi_hardfloat = true
# Controls the threshold for on-heap/off-heap Typed Arrays.
v8_typed_array_max_size_in_heap = 64
v8_enable_gdbjit = ((v8_current_cpu == "x86" || v8_current_cpu == "x64") &&
(is_linux || is_chromeos || is_mac)) ||
(v8_current_cpu == "ppc64" && (is_linux || is_chromeos))
# Check that each header can be included in isolation (requires also
# setting the "check_v8_header_includes" gclient variable to run a
# specific hook).
v8_check_header_includes = false
# Enable sharing read-only space across isolates.
# Sets -DV8_SHARED_RO_HEAP.
v8_enable_shared_ro_heap = ""
# Enable lazy source positions by default.
v8_enable_lazy_source_positions = true
# Enable third party HEAP library
v8_enable_third_party_heap = false
# Libaries used by third party heap
v8_third_party_heap_libs = []
# Source code used by third party heap
v8_third_party_heap_files = []
# Disable write barriers when GCs are non-incremental and
# heap has single generation.
v8_disable_write_barriers = false
# Ensure that write barriers are always used.
# Useful for debugging purposes.
v8_enable_unconditional_write_barriers = false
# Redirect allocation in young generation so that there will be
# only one single generation.
v8_enable_single_generation = ""
# Use token threaded dispatch for the regular expression interpreter.
# Use switch-based dispatch if this is false
v8_enable_regexp_interpreter_threaded_dispatch = true
# Enforce equality of builtins hashes from compatible architectures.
v8_verify_builtins_compatibility = false
# Check mksnapshot determinism by running it multiple times.
v8_verify_deterministic_mksnapshot = false
# Enable additional targets necessary for verification of torque
# file generation
v8_verify_torque_generation_invariance = false
# Generate comments describing the Torque intermediate representation.
v8_annotate_torque_ir = false
# Enable snapshot compression (enabled by default for desktop) devices.
v8_enable_snapshot_compression =
target_os == "android" || target_os == "chromeos" ||
target_os == "fuchsia"
# Enable control-flow integrity features, such as pointer authentication for
# ARM64. Enable it by default for simulator builds and when native code
# supports it as well.
v8_control_flow_integrity =
v8_current_cpu == "arm64" &&
(target_is_simulator || arm_control_flow_integrity != "none")
# Enable heap reservation of size 4GB. Only possible for 64bit archs.
cppgc_enable_caged_heap =
v8_current_cpu == "x64" || v8_current_cpu == "arm64" ||
v8_current_cpu == "loong64" || v8_current_cpu == "riscv64"
# Enables additional heap verification phases and checks.
cppgc_enable_verify_heap = ""
# Enable allocations during prefinalizer invocations.
cppgc_allow_allocations_in_prefinalizers = false
# Enable V8 zone compression experimental feature.
# Sets -DV8_COMPRESS_ZONES.
v8_enable_zone_compression = ""
# Enable the V8 sandbox.
# Sets -DV8_ENABLE_SANDBOX.
v8_enable_sandbox = ""
# Enable the memory corruption API. Useful for testing the sandbox.
# The memory corruption API is only exposed to JavaScript if sandbox testing
# mode is enabled at runtime, for example via --sandbox-fuzzing.
# WARNING This will enable builtins that (by design) cause memory corruption.
# Sets -DV8_ENABLE_MEMORY_CORRUPTION_API
v8_enable_memory_corruption_api = false
# Experimental feature for collecting per-class zone memory stats.
# Requires use_rtti = true
v8_enable_precise_zone_stats = false
# Experimental feature that uses SwissNameDictionary instead of NameDictionary
# as the backing store for all dictionary mode objects.
v8_enable_swiss_name_dictionary = false
# If enabled then macro definitions that are used in externally visible
# header files are placed in a separate header file v8-gn.h.
v8_generate_external_defines_header = false
# Experimental feature for tracking constness of properties in non-global
# dictionaries. Enabling this also always keeps prototypes in dict mode,
# meaning that they are not switched to fast mode.
# Sets -DV8_DICT_PROPERTY_CONST_TRACKING
v8_dict_property_const_tracking = false
# Enable map packing & unpacking (sets -dV8_MAP_PACKING).
v8_enable_map_packing = false
# Allow for JS promise hooks (instead of just C++).
v8_enable_javascript_promise_hooks = false
# Allow embedder data to be saved on continuations. Used to support
# TaskAttribution and `scheduler.yield()`.
# The flag enables disabling the feature, to test this data's overhead.
v8_enable_continuation_preserved_embedder_data = true
# Enable allocation folding globally (sets -dV8_ALLOCATION_FOLDING).
# When it's disabled, the --turbo-allocation-folding runtime flag will be ignored.
v8_enable_allocation_folding = true
# Enable runtime verification of heap snapshots produced for devtools.
v8_enable_heap_snapshot_verify = ""
# Enable global allocation site tracking.
v8_allocation_site_tracking = true
# TODO(cbruni, v8:12302): Remove once API is migrated
# Enable legacy mode for ScriptOrModule's lifetime. By default it's a
# temporary object, if enabled it will be kept alive by the parent Script.
# This is only used by nodejs.
v8_scriptormodule_legacy_lifetime = false
# Enables pointer compression for 8GB heaps.
# Sets -DV8_COMPRESS_POINTERS_8GB.
v8_enable_pointer_compression_8gb = ""
# Compile V8 using zlib as dependency.
# Sets -DV8_USE_ZLIB
v8_use_zlib = true
# Make ValueDeserializer crash if the data to deserialize is invalid.
v8_value_deserializer_hard_fail = false
# Enable jitless mode, including compile-time optimizations. Note that even
# when this is set to 'false', one can run V8 in jitless mode at runtime by
# passing the `--jitless` flag; but then you miss out on compile-time
# optimizations.
v8_jitless = v8_enable_lite_mode
# Enable Sparkplug
# Sets -DV8_ENABLE_SPARKPLUG.
v8_enable_sparkplug = ""
# Enable Maglev's graph printer.
# Sets -DV8_ENABLE_MAGLEV_GRAPH_PRINTER.
v8_enable_maglev_graph_printer = !build_with_chromium
# Enable slow tracing, e.g., tracing on every instruction or Turbofan node.
# Sets -DV8_ENABLE_SLOW_TRACING.
v8_enable_slow_tracing = is_debug
# Enable jump table switch for built-in.
v8_enable_builtin_jump_table_switch = v8_current_cpu == "x64"
v8_shortcut_strings_in_minor_ms = false
# Whether custom embedder snapshots may extend (= allocate new objects in)
# ReadOnlySpace.
v8_enable_extensible_ro_snapshot = true
# Use sticky mark-bits for separating object generations.
v8_enable_sticky_mark_bits = false
}
# Derived defaults.
if (cppgc_enable_verify_heap == "") {
cppgc_enable_verify_heap = v8_enable_debugging_features || dcheck_always_on
}
if (v8_enable_verify_heap == "") {
v8_enable_verify_heap = v8_enable_debugging_features
}
if (v8_enable_object_print == "") {
v8_enable_object_print = v8_enable_debugging_features
}
if (v8_enable_disassembler == "") {
v8_enable_disassembler = v8_enable_debugging_features
}
if (v8_enable_trace_maps == "") {
v8_enable_trace_maps = v8_enable_debugging_features
}
if (v8_enable_test_features == "") {
v8_enable_test_features = v8_enable_debugging_features || dcheck_always_on
}
if (v8_enable_v8_checks == "") {
v8_enable_v8_checks = v8_enable_debugging_features
}
if (v8_enable_heap_snapshot_verify == "") {
v8_enable_heap_snapshot_verify =
v8_enable_debugging_features || dcheck_always_on
}
if (v8_enable_snapshot_code_comments) {
assert(v8_code_comments == true || v8_code_comments == "",
"v8_enable_snapshot_code_comments conflicts with v8_code_comments.")
v8_code_comments = true
} else if (v8_code_comments == "") {
v8_code_comments = v8_enable_debugging_features
}
if (v8_enable_debug_code == "") {
v8_enable_debug_code = v8_enable_debugging_features
}
if (v8_enable_snapshot_native_code_counters == "") {
v8_enable_snapshot_native_code_counters = v8_enable_debugging_features
}
if (v8_enable_pointer_compression == "") {
v8_enable_pointer_compression =
v8_current_cpu == "arm64" || v8_current_cpu == "x64"
}
# Toggle pointer compression for correctness fuzzing when building the
# clang_x64_pointer_compression toolchain. We'll correctness-compare the
# default build with the clang_x64_pointer_compression build.
if (v8_multi_arch_build &&
rebase_path(get_label_info(":d8", "root_out_dir"), root_build_dir) ==
"clang_x64_pointer_compression") {
v8_enable_pointer_compression = !v8_enable_pointer_compression
}
# Ensure the sandbox is on/off in the same way as pointer compression for
# correctness fuzzing builds.
if (v8_multi_arch_build) {
v8_enable_sandbox = v8_enable_pointer_compression
}
if (v8_enable_pointer_compression_shared_cage == "") {
v8_enable_pointer_compression_shared_cage = v8_enable_pointer_compression
}
if (v8_enable_pointer_compression_8gb == "") {
v8_enable_pointer_compression_8gb = false
}
if (v8_enable_fast_torque == "") {
v8_enable_fast_torque = v8_enable_fast_mksnapshot
}
if (v8_enable_zone_compression == "") {
v8_enable_zone_compression = false
}
if (v8_enable_short_builtin_calls == "") {
v8_enable_short_builtin_calls =
v8_current_cpu == "x64" || v8_current_cpu == "arm64"
}
if (v8_enable_external_code_space == "") {
v8_enable_external_code_space =
v8_enable_pointer_compression &&
v8_enable_pointer_compression_shared_cage &&
(v8_current_cpu == "x64" || v8_current_cpu == "arm64")
}
if (v8_enable_sparkplug == "") {
v8_enable_sparkplug = !v8_jitless
}
if (v8_enable_maglev == "") {
v8_enable_maglev = v8_enable_turbofan &&
(v8_current_cpu == "arm" || v8_current_cpu == "x64" ||
v8_current_cpu == "arm64")
}
assert(v8_enable_turbofan || !v8_enable_maglev,
"Maglev is not available when Turbofan is disabled.")
assert(!v8_jitless || (!v8_enable_sparkplug && !v8_enable_maglev &&
!v8_enable_turbofan && !v8_enable_webassembly),
"Sparkplug, Maglev, Turbofan and Wasm are not available in jitless mode")
if (v8_enable_single_generation == "") {
v8_enable_single_generation = v8_disable_write_barriers
}
if (v8_enable_atomic_object_field_writes == "") {
v8_enable_atomic_object_field_writes = v8_enable_concurrent_marking
}
if (v8_enable_third_party_heap) {
v8_disable_write_barriers = true
v8_enable_single_generation = true
v8_enable_shared_ro_heap = false
v8_enable_pointer_compression = false
v8_enable_pointer_compression_shared_cage = false
v8_enable_allocation_folding = false
}
if (v8_enable_single_generation) {
v8_allocation_site_tracking = false
}
assert(!v8_enable_concurrent_marking || v8_enable_atomic_object_field_writes,
"Concurrent marking requires atomic object field writes.")
if (v8_enable_trace_unoptimized == "") {
v8_enable_trace_unoptimized =
v8_enable_trace_ignition || v8_enable_trace_baseline_exec
}
assert(!v8_enable_trace_ignition || v8_enable_trace_unoptimized,
"Ignition tracing requires unoptimized tracing to be enabled.")
assert(!v8_enable_trace_baseline_exec || v8_enable_trace_unoptimized,
"Baseline tracing requires unoptimized tracing to be enabled.")
assert(
v8_enable_debugging_features == true || dcheck_always_on ||
!v8_enable_slow_dchecks,
"v8_enable_slow_dchecks requires v8_enable_debugging_features or dcheck_always_on.")
if (v8_enable_short_builtin_calls &&
(!v8_enable_pointer_compression && v8_current_cpu != "x64")) {
# Disable short calls when pointer compression is not enabled, except x64,
# where short builtin calls can still be enabled if the code range is
# guaranteed to be close enough to embedded builtins.
v8_enable_short_builtin_calls = false
}
if (v8_enable_shared_ro_heap == "") {
v8_enable_shared_ro_heap = !v8_enable_pointer_compression ||
v8_enable_pointer_compression_shared_cage
}
if (v8_enable_sandbox == "") {
# TODO(saelo, v8:11880) remove dependency on v8_enable_external_code_space
# once that is enabled everywhere by default.
# TODO(chromium:1325784) the sandbox is not currently supported in Chromium
# on Fuchsia.
v8_enable_sandbox = v8_enable_pointer_compression_shared_cage &&
v8_enable_external_code_space && target_os != "fuchsia"
}
if (v8_enable_static_roots == "") {
# Static roots are only valid for builds with pointer compression and a
# shared read-only heap.
# TODO(olivf, v8:13466) Some configurations could be supported if we
# introduce different static root files for different build configurations:
# Non-wasm and non-i18n builds have fewer read only roots. Configurations
# without external code space allocate read only roots at a further
# location relative to the cage base.
v8_enable_static_roots =
v8_enable_pointer_compression && v8_enable_shared_ro_heap &&
v8_enable_pointer_compression_shared_cage &&
v8_enable_external_code_space && v8_enable_webassembly &&
v8_enable_i18n_support
}
assert(!v8_enable_static_roots ||
(v8_enable_pointer_compression && v8_enable_shared_ro_heap &&
v8_enable_pointer_compression_shared_cage &&
v8_enable_external_code_space && v8_enable_webassembly &&
v8_enable_i18n_support),
"Trying to enable static roots in a configuration that is not supported")
assert(
!(v8_enable_static_roots && v8_enable_static_roots_generation),
"Static root values must be generated in a build that does not rely on static roots itself")
if (v8_builtins_profiling_log_file == "default") {
v8_builtins_profiling_log_file = ""
# The existing profile can be used only when
# * `v8_enable_builtins_optimization` - this switch enables builtins PGO,
# * `!v8_enable_builtins_profiling` - don't use the profiles when generating
# a new one,
# * `!is_debug && !dcheck_always_on` - these modes add more checks to
# the builtins control flow which makes the builtins code different,
# * `v8_enable_pointer_compression` - it changes the objects layouts,
# * `v8_enable_sandbox && v8_enable_external_code_space` because they affect
# the way how external pointer values are accessed,
# * `v8_enable_webassembly` because it changes the set of opcodes which
# affects graphs hashes.
if (v8_enable_builtins_optimization && !v8_enable_builtins_profiling &&
!is_debug && !dcheck_always_on && v8_enable_webassembly) {
# This is about function arguments evaluation order on the machine building
# mksnapshot, which makes node IDs not predictable for subgraphs like
# Op1(Op2(), Op3()) and as a result different graph hashes.
# Clang uses left-to-right order everywhere except Windows, otherwise the
# order is right-to-left.
# TODO(crbug.com/v8/13647): Remove once this issue is fixed in CSA.
if (!is_clang || host_os == "win") {
pgo_profile_suffix = "-rl"
} else {
pgo_profile_suffix = ""
}
if ((v8_current_cpu == "x64" || v8_current_cpu == "arm64") &&
v8_enable_pointer_compression && v8_enable_external_code_space &&
v8_enable_sandbox) {
# Note, currently x64 profile can be applied to arm64 but not the other
# way round.
v8_builtins_profiling_log_file =
"tools/builtins-pgo/profiles/x64" + pgo_profile_suffix + ".profile"
} else if (v8_current_cpu == "x86" || v8_current_cpu == "arm") {
# Note, x86 profile can be applied to arm but not the other way round.
v8_builtins_profiling_log_file =
"tools/builtins-pgo/profiles/x86" + pgo_profile_suffix + ".profile"
}
}
}
if (v8_enable_webassembly && !target_is_simulator && v8_current_cpu == "x64") {
v8_enable_wasm_simd256_revec = true
}
assert(!v8_disable_write_barriers || v8_enable_single_generation,
"Disabling write barriers works only with single generation")
assert(v8_current_cpu == "arm64" || !v8_control_flow_integrity,
"Control-flow integrity is only supported on arm64")
if (v8_enable_shared_ro_heap && v8_enable_pointer_compression &&
!v8_enable_pointer_compression_shared_cage) {
assert(
is_linux || is_chromeos || is_android,
"Sharing read-only heap with pointer compression is only supported on Linux or Android")
}
assert(!v8_enable_map_packing || !v8_enable_pointer_compression,
"Map packing does not support pointer compression")
assert(!v8_enable_map_packing || v8_current_cpu == "x64",
"Map packing is only supported on x64")
assert(!v8_enable_external_code_space || v8_enable_pointer_compression,
"External code space feature requires pointer compression")
assert(!v8_enable_pointer_compression_8gb || v8_enable_pointer_compression,
"Pointer compression for 8GB cages requires pointer compression")
assert(!v8_enable_sandbox || v8_enable_pointer_compression_shared_cage,
"The sandbox requires the shared pointer compression cage")
assert(!v8_enable_sandbox || v8_enable_external_code_space,
"The sandbox requires the external code space")
assert(!v8_enable_sandbox || !v8_enable_third_party_heap,
"The sandbox is incompatible with the third-party heap")
assert(!v8_enable_memory_corruption_api || v8_enable_sandbox,
"The Memory Corruption API requires the sandbox")
assert(
!v8_enable_pointer_compression_shared_cage || v8_enable_pointer_compression,
"Can't share a pointer compression cage if pointers aren't compressed")
assert(
!v8_enable_pointer_compression ||
v8_enable_pointer_compression_shared_cage ||
!v8_enable_external_code_space,
"Multi-cage pointer compression mode is not compatible with external code space")
assert(
!v8_enable_pointer_compression_shared_cage || v8_current_cpu == "x64" ||
v8_current_cpu == "arm64" || v8_current_cpu == "riscv64" ||
v8_current_cpu == "ppc64" || v8_current_cpu == "s390x" ||
v8_current_cpu == "loong64",
"Sharing a pointer compression cage is only supported on x64, arm64, ppc64, s390x, riscv64 and loong64")
assert(!v8_enable_unconditional_write_barriers || !v8_disable_write_barriers,
"Write barriers can't be both enabled and disabled")
assert(!cppgc_enable_caged_heap || v8_current_cpu == "x64" ||
v8_current_cpu == "arm64" || v8_current_cpu == "loong64" ||
v8_current_cpu == "riscv64",
"CppGC caged heap requires 64bit platforms")
assert(!cppgc_enable_young_generation || cppgc_enable_caged_heap,
"Young generation in CppGC requires caged heap")
assert(!cppgc_enable_pointer_compression || cppgc_enable_caged_heap,
"Pointer compression in CppGC requires caged heap")
if (v8_enable_single_generation == true) {
assert(
v8_enable_unconditional_write_barriers || v8_disable_write_barriers,
"Requires unconditional write barriers or none (which disables incremental marking)")
}
assert(!v8_enable_snapshot_compression || v8_use_zlib,
"Snapshot compression requires zlib")
if (v8_expose_public_symbols == "") {
v8_expose_public_symbols = v8_expose_symbols
}
v8_random_seed = "314159265"
v8_toolset_for_shell = "host"
###############################################################################
# Configurations
#
config("internal_config_base") {
# Only targets in this file and its subdirs can depend on this.
visibility = [ "./*" ]
configs = [ ":v8_tracing_config" ]
include_dirs = [
".",
"include",
"$target_gen_dir",
]
}
config("internal_config") {
defines = []
# Only targets in this file and its subdirs can depend on this.
visibility = [ "./*" ]
configs = [
"//build/config/compiler:wexit_time_destructors",
":internal_config_base",
":v8_header_features",
":cppgc_header_features",
]
if (is_component_build) {
defines += [ "BUILDING_V8_SHARED_PRIVATE" ]
} else if (v8_expose_public_symbols) {
defines += [ "BUILDING_V8_SHARED" ]
}
if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") {
if (!is_clang) {
libs = [ "atomic" ]
}
}
}
# Should be applied to all targets that write trace events.
config("v8_tracing_config") {
if (v8_use_perfetto) {
include_dirs = [
"//third_party/perfetto/include",
"$root_gen_dir/third_party/perfetto",
"$root_gen_dir/third_party/perfetto/build_config",
]
}
}
# This config should be applied to code using the libplatform.
config("libplatform_config") {
include_dirs = [ "include" ]
if (is_component_build) {
defines = [ "USING_V8_PLATFORM_SHARED" ]
}
}
# This config should be applied to code using the libbase.
config("libbase_config") {
if (is_component_build) {
defines = [ "USING_V8_BASE_SHARED" ]
}
libs = []
if (is_android && current_toolchain != host_toolchain) {
libs += [ "log" ]
}
}
# Standalone cppgc cannot be built within chrome or with perfetto.
assert(!cppgc_is_standalone || !build_with_chromium)
assert(!cppgc_is_standalone || !v8_use_perfetto)
# This config should be applied to code using the cppgc_base.
config("cppgc_base_config") {
defines = []
if (cppgc_is_standalone) {
defines += [ "CPPGC_IS_STANDALONE" ]
}
}
# This config is only applied to v8_headers and is the basis for external_config
# but without setting the USING_V8_SHARED define, which means v8_headers can be
# used inside v8 itself.
config("headers_config") {
defines = []
configs = [
":v8_header_features",
":cppgc_header_features",
]
include_dirs = [ "include" ]
}
# This config should only be applied to code using V8 and not any V8 code
# itself.
config("external_config") {
configs = [ ":headers_config" ]
defines = []
if (is_component_build) {
defines += [
"USING_V8_SHARED",
"USING_V8_SHARED_PRIVATE",
]
}
if (current_cpu == "riscv64" || current_cpu == "riscv32") {
if (!is_clang) {
libs = [ "atomic" ]
}
}
}
# This config should only be applied to code that needs to be explicitly
# aware of whether we are using startup data or not.
config("external_startup_data") {
if (v8_use_external_startup_data) {
defines = [ "V8_USE_EXTERNAL_STARTUP_DATA" ]
}
}
# List of defines that can appear in externally visible header files and that
# are controlled by args.gn.
# Make sure the |v8_generate_features_json| action is also updated when adding
# or removing defines below.
external_v8_defines = [
"V8_ENABLE_CHECKS",
"V8_COMPRESS_POINTERS",
"V8_COMPRESS_POINTERS_IN_SHARED_CAGE",
"V8_31BIT_SMIS_ON_64BIT_ARCH",
"V8_COMPRESS_ZONES",
"V8_ENABLE_SANDBOX",
"V8_DEPRECATION_WARNINGS",
"V8_IMMINENT_DEPRECATION_WARNINGS",
"V8_USE_PERFETTO",
"V8_MAP_PACKING",
"V8_IS_TSAN",
"V8_ENABLE_CONSERVATIVE_STACK_SCANNING",
"V8_ENABLE_DIRECT_LOCAL",
"V8_MINORMS_STRING_SHORTCUTTING",
"V8_HAVE_TARGET_OS",
"V8_TARGET_OS_ANDROID",
"V8_TARGET_OS_FUCHSIA",
"V8_TARGET_OS_IOS",
"V8_TARGET_OS_LINUX",
"V8_TARGET_OS_MACOS",
"V8_TARGET_OS_WIN",
"V8_TARGET_OS_CHROMEOS",
]
enabled_external_v8_defines = []
if (v8_enable_v8_checks) {
enabled_external_v8_defines += [ "V8_ENABLE_CHECKS" ]
}
if (v8_enable_pointer_compression) {
enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS" ]
if (v8_enable_pointer_compression_shared_cage) {
enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS_IN_SHARED_CAGE" ]
}
}
if (v8_enable_pointer_compression || v8_enable_31bit_smis_on_64bit_arch) {
enabled_external_v8_defines += [ "V8_31BIT_SMIS_ON_64BIT_ARCH" ]
}
if (v8_enable_zone_compression) {
enabled_external_v8_defines += [ "V8_COMPRESS_ZONES" ]
}
if (v8_enable_sandbox) {
enabled_external_v8_defines += [ "V8_ENABLE_SANDBOX" ]
}
if (v8_deprecation_warnings) {
enabled_external_v8_defines += [ "V8_DEPRECATION_WARNINGS" ]
}
if (v8_imminent_deprecation_warnings) {
enabled_external_v8_defines += [ "V8_IMMINENT_DEPRECATION_WARNINGS" ]
}
if (v8_use_perfetto) {
enabled_external_v8_defines += [ "V8_USE_PERFETTO" ]
}
if (v8_enable_map_packing) {
enabled_external_v8_defines += [ "V8_MAP_PACKING" ]
}
if (is_tsan) {
enabled_external_v8_defines += [ "V8_IS_TSAN" ]
}
if (v8_enable_conservative_stack_scanning) {
enabled_external_v8_defines += [ "V8_ENABLE_CONSERVATIVE_STACK_SCANNING" ]
}
if (v8_enable_direct_local) {
enabled_external_v8_defines += [ "V8_ENABLE_DIRECT_LOCAL" ]
}
if (v8_shortcut_strings_in_minor_ms) {
enabled_external_v8_defines += [ "V8_MINORMS_STRING_SHORTCUTTING" ]
}
# V8_TARGET_OS_ defines. The target OS may differ from host OS e.g. in
# mksnapshot. We additionally set V8_HAVE_TARGET_OS to determine that a
# target OS has in fact been set; otherwise we internally assume that target
# OS == host OS (see v8config.h).
if (target_os == "android") {
enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ]
enabled_external_v8_defines += [ "V8_TARGET_OS_ANDROID" ]
} else if (target_os == "fuchsia") {
enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ]
enabled_external_v8_defines += [ "V8_TARGET_OS_FUCHSIA" ]
} else if (target_os == "ios") {
enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ]
enabled_external_v8_defines += [ "V8_TARGET_OS_IOS" ]
} else if (target_os == "linux") {
enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ]
enabled_external_v8_defines += [ "V8_TARGET_OS_LINUX" ]
} else if (target_os == "mac") {
enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ]
enabled_external_v8_defines += [ "V8_TARGET_OS_MACOS" ]
} else if (target_os == "win") {
enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ]
enabled_external_v8_defines += [ "V8_TARGET_OS_WIN" ]
} else if (target_os == "chromeos") {
enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ]
enabled_external_v8_defines += [ "V8_TARGET_OS_CHROMEOS" ]
}
disabled_external_v8_defines = external_v8_defines - enabled_external_v8_defines
# Put defines that are used in public headers here; public headers are
# defined in "v8_headers" and are included by embedders of V8.
config("v8_header_features") {
visibility = [ ":*" ]
if (v8_generate_external_defines_header) {
defines = [ "V8_GN_HEADER" ]
} else {
defines = enabled_external_v8_defines
}
}
# List of defines that can appear in externally visible cppgc header files and
# that are controlled by args.gn.
external_cppgc_defines = [
"CPPGC_SUPPORTS_OBJECT_NAMES",
"CPPGC_CAGED_HEAP",
"CPPGC_SLIM_WRITE_BARRIER",
"CPPGC_YOUNG_GENERATION",
"CPPGC_POINTER_COMPRESSION",
"CPPGC_ENABLE_LARGER_CAGE",
]
enabled_external_cppgc_defines = []
if (cppgc_enable_object_names) {
enabled_external_cppgc_defines += [ "CPPGC_SUPPORTS_OBJECT_NAMES" ]
}
if (cppgc_enable_caged_heap) {
enabled_external_cppgc_defines += [ "CPPGC_CAGED_HEAP" ]
# Always enable young generation compile time flag if caged heap is enabled.
cppgc_enable_young_generation = true
# Pointer compression regresses binary size on Fuchsia by about 300K.
# However, the change improves Oilpan memory by 15-20% (2-4% of PMF),