diff --git a/common.gypi b/common.gypi index c9b6b8b6cc1..c8cb1b34979 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.12', + 'v8_embedder_string': '-node.8', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/.gitignore b/deps/v8/.gitignore index d5c64a8e83c..8491447180e 100644 --- a/deps/v8/.gitignore +++ b/deps/v8/.gitignore @@ -40,6 +40,7 @@ .torquelint-cache .vscode /_* +/base /build /buildtools /check-header-includes @@ -86,6 +87,7 @@ !/third_party/v8 !/third_party/wasm-api /tools/builtins-pgo/profiles/*.profile +/tools/builtins-pgo/profiles/profiles_version /tools/clang /tools/gcmole/bootstrap /tools/gcmole/gcmole-tools @@ -95,6 +97,7 @@ /tools/luci-go /tools/oom_dump/oom_dump /tools/oom_dump/oom_dump.o +/tools/protoc_wrapper /tools/turbolizer/build /tools/turbolizer/.rpt2_cache /tools/turbolizer/deploy diff --git a/deps/v8/.gn b/deps/v8/.gn index 3a73ff4e2a1..afdb6fa1201 100644 --- a/deps/v8/.gn +++ b/deps/v8/.gn @@ -25,6 +25,8 @@ no_check_targets = [ ] default_args = { + # Disable js dependencies like the closure compiler. + enable_js_protobuf = false # Disable rust dependencies. enable_rust = false } diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index 6de30c78a85..c2fea2cf324 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -57,6 +57,7 @@ Alexander Botero-Lowry Alexander Karpinsky Alexander Neville Alexandre Vassalotti +Alexey Pavlyutkin Alexis Campailla Allan Sandfeld Jensen Amos Lim @@ -257,6 +258,7 @@ Sander Mathijs van Veen Sandro Santilli Sanjoy Das Sam James +Sébastien Doeraene Seo Sanghyeon Shawn Anastasio Shawn Presser diff --git a/deps/v8/BUILD.bazel b/deps/v8/BUILD.bazel index 05b7472165a..eca514d191c 100644 --- a/deps/v8/BUILD.bazel +++ b/deps/v8/BUILD.bazel @@ -653,6 +653,7 @@ filegroup( "include/v8-promise.h", "include/v8-proxy.h", "include/v8-regexp.h", + "include/v8-sandbox.h", "include/v8-script.h", "include/v8-snapshot.h", "include/v8-statistics.h", @@ -798,6 +799,9 @@ filegroup( "src/base/strings.h", "src/base/sys-info.cc", "src/base/sys-info.h", + "src/base/template-meta-programming/algorithm.h", + "src/base/template-meta-programming/functional.h", + "src/base/template-meta-programming/list.h", "src/base/template-utils.h", "src/base/threaded-list.h", "src/base/timezone-cache.h", @@ -1070,6 +1074,7 @@ filegroup( "src/objects/js-atomics-synchronization.tq", "src/objects/js-collection.tq", "src/objects/js-collection-iterator.tq", + "src/objects/js-disposable-stack.tq", "src/objects/js-function.tq", "src/objects/js-generator.tq", "src/objects/js-iterator-helpers.tq", @@ -1209,15 +1214,6 @@ filegroup( ], ) -# Default setting for v8_enable_pointer_compression when target is x64. -selects.config_setting_group( - name = "is_v8_enable_webassembly_on_non_android_posix_x64", - match_all = [ - ":is_v8_enable_webassembly", - "@v8//bazel/config:is_non_android_posix_x64", - ], -) - filegroup( name = "v8_base_without_compiler_files", srcs = [ @@ -1292,6 +1288,7 @@ filegroup( "src/builtins/builtins-date.cc", "src/builtins/builtins-definitions.h", "src/builtins/builtins-descriptors.h", + "src/builtins/builtins-disposable-stack.cc", "src/builtins/builtins-error.cc", "src/builtins/builtins-function.cc", "src/builtins/builtins-global.cc", @@ -1409,6 +1406,7 @@ filegroup( "src/common/ptr-compr.cc", "src/common/ptr-compr.h", "src/common/ptr-compr-inl.h", + "src/common/simd128.h", "src/compiler-dispatcher/lazy-compile-dispatcher.cc", "src/compiler-dispatcher/lazy-compile-dispatcher.h", "src/compiler-dispatcher/optimizing-compile-dispatcher.cc", @@ -1572,6 +1570,7 @@ filegroup( "src/heap/base/active-system-pages.h", "src/heap/memory-chunk-metadata.cc", "src/heap/memory-chunk-metadata.h", + "src/heap/memory-chunk-metadata-inl.h", "src/heap/code-range.cc", "src/heap/code-range.h", "src/heap/trusted-range.cc", @@ -1621,8 +1620,6 @@ filegroup( "src/heap/free-list.h", "src/heap/free-list-inl.h", "src/heap/gc-callbacks.h", - "src/heap/gc-idle-time-handler.cc", - "src/heap/gc-idle-time-handler.h", "src/heap/gc-tracer.cc", "src/heap/gc-tracer.h", "src/heap/gc-tracer-inl.h", @@ -1650,6 +1647,7 @@ filegroup( "src/heap/index-generator.h", "src/heap/large-page.cc", "src/heap/large-page.h", + "src/heap/large-page-inl.h", "src/heap/large-spaces.cc", "src/heap/large-spaces.h", "src/heap/linear-allocation-area.h", @@ -1692,6 +1690,7 @@ filegroup( "src/heap/mutable-page.h", "src/heap/memory-chunk.cc", "src/heap/memory-chunk.h", + "src/heap/memory-chunk-inl.h", "src/heap/mutable-page-inl.h", "src/heap/memory-chunk-layout.cc", "src/heap/memory-chunk-layout.h", @@ -1706,6 +1705,7 @@ filegroup( "src/heap/new-spaces.h", "src/heap/new-spaces-inl.h", "src/heap/object-lock.h", + "src/heap/object-lock-inl.h", "src/heap/object-stats.cc", "src/heap/object-stats.h", "src/heap/objects-visiting.cc", @@ -1774,8 +1774,8 @@ filegroup( "src/init/heap-symbols.h", "src/init/icu_util.cc", "src/init/icu_util.h", - "src/init/isolate-allocator.cc", - "src/init/isolate-allocator.h", + "src/init/isolate-group.cc", + "src/init/isolate-group.h", "src/init/setup-isolate.h", "src/init/startup-data-util.cc", "src/init/startup-data-util.h", @@ -1792,8 +1792,8 @@ filegroup( "src/interpreter/bytecode-array-writer.h", "src/interpreter/bytecode-decoder.cc", "src/interpreter/bytecode-decoder.h", - "src/interpreter/bytecode-flags.cc", - "src/interpreter/bytecode-flags.h", + "src/interpreter/bytecode-flags-and-tokens.cc", + "src/interpreter/bytecode-flags-and-tokens.h", "src/interpreter/bytecode-generator.cc", "src/interpreter/bytecode-generator.h", "src/interpreter/bytecode-jump-table.h", @@ -1960,6 +1960,9 @@ filegroup( "src/objects/js-collection-inl.h", "src/objects/js-collection-iterator.h", "src/objects/js-collection-iterator-inl.h", + "src/objects/js-disposable-stack.cc", + "src/objects/js-disposable-stack.h", + "src/objects/js-disposable-stack-inl.h", "src/objects/js-function.cc", "src/objects/js-function.h", "src/objects/js-function-inl.h", @@ -2142,6 +2145,8 @@ filegroup( "src/objects/visitors.cc", "src/objects/visitors.h", "src/objects/visitors-inl.h", + "src/objects/waiter-queue-node.cc", + "src/objects/waiter-queue-node.h", "src/parsing/expression-scope.h", "src/parsing/func-name-inferrer.cc", "src/parsing/func-name-inferrer.h", @@ -2300,18 +2305,27 @@ filegroup( "src/sandbox/trusted-pointer-table-inl.h", "src/sandbox/code-pointer.h", "src/sandbox/code-pointer-inl.h", + "src/sandbox/compactible-external-entity-table-inl.h", + "src/sandbox/compactible-external-entity-table.h", "src/sandbox/isolate.h", "src/sandbox/isolate-inl.h", "src/sandbox/indirect-pointer.h", "src/sandbox/indirect-pointer-tag.h", "src/sandbox/indirect-pointer-inl.h", "src/sandbox/code-entrypoint-tag.h", + "src/sandbox/external-buffer.h", + "src/sandbox/external-buffer-tag.h", + "src/sandbox/external-buffer-inl.h", + "src/sandbox/external-buffer-table.cc", + "src/sandbox/external-buffer-table-inl.h", + "src/sandbox/external-buffer-table.h", "src/sandbox/external-entity-table.h", "src/sandbox/external-entity-table-inl.h", "src/sandbox/sandbox.cc", "src/sandbox/sandbox.h", "src/sandbox/sandboxed-pointer.h", "src/sandbox/sandboxed-pointer-inl.h", + "src/sandbox/tagged-payload.h", "src/sandbox/testing.cc", "src/sandbox/testing.h", "src/snapshot/code-serializer.cc", @@ -2364,6 +2378,7 @@ filegroup( "src/strings/char-predicates.h", "src/strings/char-predicates-inl.h", "src/strings/string-builder.cc", + "src/strings/string-builder.h", "src/strings/string-builder-inl.h", "src/strings/string-case.cc", "src/strings/string-case.h", @@ -2393,6 +2408,7 @@ filegroup( "src/torque/runtime-macro-shims.h", "src/tracing/trace-event.cc", "src/tracing/trace-event.h", + "src/tracing/trace-event-no-perfetto.h", "src/tracing/traced-value.cc", "src/tracing/traced-value.h", "src/tracing/tracing-category-observer.cc", @@ -2663,12 +2679,7 @@ filegroup( "src/wasm/baseline/ppc/liftoff-assembler-ppc-inl.h", ], }) + select({ - # Only for x64 builds and for arm64 with x64 host simulator. - ":is_v8_enable_webassembly_on_non_android_posix_x64": [ - "src/trap-handler/handler-inside-posix.cc", - "src/trap-handler/handler-outside-posix.cc", - ], - "@v8//bazel/config:is_macos_arm64": [ + "@v8//bazel/config:is_posix": [ "src/trap-handler/handler-inside-posix.cc", "src/trap-handler/handler-outside-posix.cc", ], @@ -2786,6 +2797,7 @@ filegroup( "src/wasm/baseline/liftoff-compiler.cc", "src/wasm/baseline/liftoff-compiler.h", "src/wasm/baseline/liftoff-register.h", + "src/wasm/baseline/liftoff-varstate.h", "src/wasm/baseline/parallel-move.cc", "src/wasm/baseline/parallel-move.h", "src/wasm/baseline/parallel-move-inl.h", @@ -2852,6 +2864,8 @@ filegroup( "src/wasm/wasm-code-manager.h", "src/wasm/wasm-debug.cc", "src/wasm/wasm-debug.h", + "src/wasm/wasm-deopt-data.cc", + "src/wasm/wasm-deopt-data.h", "src/wasm/wasm-disassembler.cc", "src/wasm/wasm-disassembler.h", "src/wasm/wasm-disassembler-impl.h", @@ -3022,8 +3036,6 @@ filegroup( "src/compiler/const-tracking-let-helpers.h", "src/compiler/control-equivalence.cc", "src/compiler/control-equivalence.h", - "src/compiler/control-flow-optimizer.cc", - "src/compiler/control-flow-optimizer.h", "src/compiler/control-path-state.h", "src/compiler/csa-load-elimination.cc", "src/compiler/csa-load-elimination.h", @@ -3032,8 +3044,6 @@ filegroup( "src/compiler/decompression-optimizer.cc", "src/compiler/decompression-optimizer.h", "src/compiler/diamond.h", - "src/compiler/effect-control-linearizer.cc", - "src/compiler/effect-control-linearizer.h", "src/compiler/escape-analysis.cc", "src/compiler/escape-analysis.h", "src/compiler/escape-analysis-reducer.cc", @@ -3177,8 +3187,6 @@ filegroup( "src/compiler/simplified-operator-reducer.h", "src/compiler/state-values-utils.cc", "src/compiler/state-values-utils.h", - "src/compiler/store-store-elimination.cc", - "src/compiler/store-store-elimination.h", "src/compiler/string-builder-optimizer.cc", "src/compiler/string-builder-optimizer.h", "src/compiler/turbofan.h", @@ -3219,6 +3227,7 @@ filegroup( "src/compiler/turboshaft/graph-visualizer.h", "src/compiler/turboshaft/js-generic-lowering-reducer.h", "src/compiler/turboshaft/index.h", + "src/compiler/turboshaft/instruction-selection-normalization-reducer.h", "src/compiler/turboshaft/instruction-selection-phase.cc", "src/compiler/turboshaft/instruction-selection-phase.h", "src/compiler/turboshaft/late-escape-analysis-reducer.cc", @@ -3279,7 +3288,7 @@ filegroup( "src/compiler/turboshaft/stack-check-lowering-reducer.h", "src/compiler/turboshaft/store-store-elimination-phase.cc", "src/compiler/turboshaft/store-store-elimination-phase.h", - "src/compiler/turboshaft/store-store-elimination-reducer.h", + "src/compiler/turboshaft/store-store-elimination-reducer-inl.h", "src/compiler/turboshaft/structural-optimization-reducer.h", "src/compiler/turboshaft/tracing.h", "src/compiler/turboshaft/type-assertions-phase.cc", @@ -3425,6 +3434,34 @@ filegroup( "src/compiler/wasm-typer.h", ], "//conditions:default": [], + }) + select({ + # Turboshaft's Maglev graph builder needs some Maglev files. We only + # include them explicitely when Maglev is disabled. + ":enable_maglev": [], + "//conditions:default": [ + "src/maglev/maglev-basic-block.h", + "src/maglev/maglev-code-gen-state.h", + "src/maglev/maglev-compilation-info.cc", + "src/maglev/maglev-compilation-info.h", + "src/maglev/maglev-compilation-unit.cc", + "src/maglev/maglev-compilation-unit.h", + "src/maglev/maglev-graph-builder.cc", + "src/maglev/maglev-graph-builder.h", + "src/maglev/maglev-graph.h", + "src/maglev/maglev-graph-labeller.h", + "src/maglev/maglev-graph-printer.cc", + "src/maglev/maglev-graph-printer.h", + "src/maglev/maglev-graph-processor.h", + "src/maglev/maglev-graph-verifier.h", + "src/maglev/maglev-interpreter-frame-state.cc", + "src/maglev/maglev-interpreter-frame-state.h", + "src/maglev/maglev-ir.cc", + "src/maglev/maglev-ir.h", + "src/maglev/maglev-ir-inl.h", + "src/maglev/maglev-register-frame-array.h", + "src/maglev/maglev-phi-representation-selector.cc", + "src/maglev/maglev-phi-representation-selector.h", + ], }), ) @@ -3519,32 +3556,6 @@ filegroup( "src/builtins/builtins-wasm-gen.h", ], "//conditions:default": [], - }) + select({ - # Turboshaft's Maglev graph builder needs some Maglev files. We only - # include them explicitely when Maglev is disabled. - ":enable_maglev": [], - "//conditions:default": [ - "src/maglev/maglev-basic-block.h", - "src/maglev/maglev-code-gen-state.h", - "src/maglev/maglev-compilation-info.cc", - "src/maglev/maglev-compilation-info.h", - "src/maglev/maglev-compilation-unit.cc", - "src/maglev/maglev-compilation-unit.h", - "src/maglev/maglev-graph-builder.cc", - "src/maglev/maglev-graph-builder.h", - "src/maglev/maglev-graph.h", - "src/maglev/maglev-graph-labeller.h", - "src/maglev/maglev-graph-printer.cc", - "src/maglev/maglev-graph-printer.h", - "src/maglev/maglev-graph-processor.h", - "src/maglev/maglev-graph-verifier.h", - "src/maglev/maglev-interpreter-frame-state.cc", - "src/maglev/maglev-interpreter-frame-state.h", - "src/maglev/maglev-ir.cc", - "src/maglev/maglev-ir.h", - "src/maglev/maglev-ir-inl.h", - "src/maglev/maglev-register-frame-array.h", - ], }), ) @@ -4188,7 +4199,6 @@ v8_library( deps = [ ":lib_fp16", ":v8_libbase", - "//external:base_trace_event_common", "//external:absl_btree", "//external:absl_flat_hash_map", "//external:absl_flat_hash_set", @@ -4372,6 +4382,11 @@ alias( v8_build_config( name = "v8_build_config", + arch = select({ + "//third_party/v8/v12_4/google3/config:v8_target_arm64": "arm64", + "//third_party/v8/v12_4/google3/config:v8_target_x64": "x64", + "//conditions:default": "x64", + }), ) # Runs mjsunit with d8. @@ -4389,6 +4404,15 @@ py_test( "--variant=google3_noicu", "--outdir noicu", "--verbose", + ] + select({ + "//third_party/v8/v12_4/google3/config:v8_target_arm64": [ + "--arch=arm64", + ], + "//third_party/v8/v12_4/google3/config:v8_target_x64": [ + "--arch=x64", + ], + "//conditions:default": [], + }) + [ "mjsunit", ], data = [ @@ -4419,6 +4443,15 @@ py_test( "--variant=google3_icu", "--outdir icu", "--verbose", + ] + select({ + "//third_party/v8/v12_4/google3/config:v8_target_arm64": [ + "--arch=arm64", + ], + "//third_party/v8/v12_4/google3/config:v8_target_x64": [ + "--arch=x64", + ], + "//conditions:default": [], + }) + [ "mjsunit", ], data = [ diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn index e2e0c16d970..0acce6db601 100644 --- a/deps/v8/BUILD.gn +++ b/deps/v8/BUILD.gn @@ -333,7 +333,7 @@ declare_args() { # Sets -DV8_COMPRESS_ZONES. v8_enable_zone_compression = "" - # Enable the experimental V8 sandbox. + # Enable the V8 sandbox. # Sets -DV8_ENABLE_SANDBOX. v8_enable_sandbox = "" @@ -404,9 +404,7 @@ declare_args() { # 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. - # iOS (non-simulator) does not have executable pages for 3rd party - # applications yet so disable jit. - v8_jitless = v8_enable_lite_mode || target_is_ios_device + v8_jitless = v8_enable_lite_mode # Enable Sparkplug # Sets -DV8_ENABLE_SPARKPLUG. @@ -428,6 +426,13 @@ declare_args() { # 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 + + # Always move prototype transitions to the start of the transition tree + # (see issue 332914927). + v8_move_prototype_transitions_first = false } # Derived defaults. @@ -691,12 +696,6 @@ 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" || @@ -866,7 +865,6 @@ external_v8_defines = [ "V8_ENABLE_CHECKS", "V8_COMPRESS_POINTERS", "V8_COMPRESS_POINTERS_IN_SHARED_CAGE", - "V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE", "V8_31BIT_SMIS_ON_64BIT_ARCH", "V8_COMPRESS_ZONES", "V8_ENABLE_SANDBOX", @@ -878,6 +876,14 @@ external_v8_defines = [ "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 = [] @@ -889,8 +895,6 @@ 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" ] - } else { - enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE" ] } } if (v8_enable_pointer_compression || v8_enable_31bit_smis_on_64bit_arch) { @@ -926,6 +930,34 @@ if (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 @@ -1022,6 +1054,11 @@ config("features") { defines += [ "CPPGC_ALLOW_ALLOCATIONS_IN_PREFINALIZERS" ] } + if (v8_enable_pointer_compression && + !v8_enable_pointer_compression_shared_cage) { + defines += [ "V8_COMPRESS_POINTERS_IN_MULTIPLE_CAGES" ] + } + if (v8_embedder_string != "") { defines += [ "V8_EMBEDDER_STRING=\"$v8_embedder_string\"" ] } @@ -1253,6 +1290,12 @@ config("features") { if (v8_enable_local_off_stack_check) { defines += [ "V8_ENABLE_LOCAL_OFF_STACK_CHECK" ] } + if (v8_enable_sticky_mark_bits) { + defines += [ "V8_ENABLE_STICKY_MARK_BITS" ] + } + if (v8_move_prototype_transitions_first) { + defines += [ "V8_MOVE_PROTOYPE_TRANSITIONS_FIRST" ] + } } config("toolchain") { @@ -1385,20 +1428,10 @@ config("toolchain") { defines += [ "CAN_USE_RVV_INSTRUCTIONS" ] defines += [ "RVV_VLEN=${riscv_rvv_vlen}" ] } - if (riscv_use_zba || target_is_simulator) { - defines += [ "CAN_USE_ZBA_INSTRUCTIONS" ] - } - if (riscv_use_zbb || target_is_simulator) { - defines += [ "CAN_USE_ZBB_INSTRUCTIONS" ] - } - if (riscv_use_zbs || target_is_simulator) { - defines += [ "CAN_USE_ZBS_INSTRUCTIONS" ] - } } if (v8_current_cpu == "riscv64") { defines += [ "V8_TARGET_ARCH_RISCV64" ] defines += [ "__riscv_xlen=64" ] - defines += [ "CAN_USE_FPU_INSTRUCTIONS" ] if (!is_clang) { cflags += [ "-ffp-contract=off" ] } @@ -1407,7 +1440,6 @@ config("toolchain") { if (v8_current_cpu == "riscv32") { defines += [ "V8_TARGET_ARCH_RISCV32" ] defines += [ "__riscv_xlen=32" ] - defines += [ "CAN_USE_FPU_INSTRUCTIONS" ] } if (v8_current_cpu == "x86") { @@ -1430,33 +1462,6 @@ config("toolchain") { defines += [ "V8_ANDROID_LOG_STDOUT" ] } - # 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") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_ANDROID" ] - } else if (target_os == "fuchsia") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_FUCHSIA" ] - } else if (target_os == "ios") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_IOS" ] - } else if (target_os == "linux") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_LINUX" ] - } else if (target_os == "mac") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_MACOS" ] - } else if (target_os == "win") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_WIN" ] - } else if (target_os == "chromeos") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_CHROMEOS" ] - } - # TODO(infra): Support v8_enable_prof on Windows. # TODO(infra): Add support for compiling with simulators. @@ -2061,6 +2066,7 @@ torque_files = [ "src/objects/js-atomics-synchronization.tq", "src/objects/js-collection-iterator.tq", "src/objects/js-collection.tq", + "src/objects/js-disposable-stack.tq", "src/objects/js-function.tq", "src/objects/js-generator.tq", "src/objects/js-iterator-helpers.tq", @@ -2727,6 +2733,7 @@ action("v8_dump_build_config") { "verify_csa=$v8_enable_verify_csa", "verify_heap=$v8_enable_verify_heap", "verify_predictable=$v8_enable_verify_predictable", + "memory_corruption_api=$v8_enable_memory_corruption_api", ] } @@ -3082,6 +3089,7 @@ v8_header_set("v8_headers") { "include/v8-promise.h", "include/v8-proxy.h", "include/v8-regexp.h", + "include/v8-sandbox.h", "include/v8-script.h", "include/v8-snapshot.h", "include/v8-statistics.h", @@ -3188,7 +3196,6 @@ v8_header_set("v8_internal_headers") { sources = [ ### gcmole(all) ### "$target_gen_dir/builtins-generated/bytecodes-builtins-list.h", - "//base/trace_event/common/trace_event_common.h", "include/cppgc/common.h", "include/v8-inspector-protocol.h", "include/v8-inspector.h", @@ -3285,6 +3292,7 @@ v8_header_set("v8_internal_headers") { "src/common/operation.h", "src/common/ptr-compr-inl.h", "src/common/ptr-compr.h", + "src/common/simd128.h", "src/compiler-dispatcher/lazy-compile-dispatcher.h", "src/compiler-dispatcher/optimizing-compile-dispatcher.h", "src/compiler/access-builder.h", @@ -3327,13 +3335,11 @@ v8_header_set("v8_internal_headers") { "src/compiler/const-tracking-let-helpers.h", "src/compiler/constant-folding-reducer.h", "src/compiler/control-equivalence.h", - "src/compiler/control-flow-optimizer.h", "src/compiler/control-path-state.h", "src/compiler/csa-load-elimination.h", "src/compiler/dead-code-elimination.h", "src/compiler/decompression-optimizer.h", "src/compiler/diamond.h", - "src/compiler/effect-control-linearizer.h", "src/compiler/escape-analysis-reducer.h", "src/compiler/escape-analysis.h", "src/compiler/fast-api-calls.h", @@ -3411,7 +3417,6 @@ v8_header_set("v8_internal_headers") { "src/compiler/simplified-operator-reducer.h", "src/compiler/simplified-operator.h", "src/compiler/state-values-utils.h", - "src/compiler/store-store-elimination.h", "src/compiler/string-builder-optimizer.h", "src/compiler/turbofan.h", "src/compiler/turboshaft/analyzer-iterator.h", @@ -3439,6 +3444,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/graph-visualizer.h", "src/compiler/turboshaft/graph.h", "src/compiler/turboshaft/index.h", + "src/compiler/turboshaft/instruction-selection-normalization-reducer.h", "src/compiler/turboshaft/instruction-selection-phase.h", "src/compiler/turboshaft/js-generic-lowering-reducer.h", "src/compiler/turboshaft/late-escape-analysis-reducer.h", @@ -3477,7 +3483,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/snapshot-table.h", "src/compiler/turboshaft/stack-check-lowering-reducer.h", "src/compiler/turboshaft/store-store-elimination-phase.h", - "src/compiler/turboshaft/store-store-elimination-reducer.h", + "src/compiler/turboshaft/store-store-elimination-reducer-inl.h", "src/compiler/turboshaft/structural-optimization-reducer.h", "src/compiler/turboshaft/tracing.h", "src/compiler/turboshaft/type-assertions-phase.h", @@ -3622,7 +3628,6 @@ v8_header_set("v8_internal_headers") { "src/heap/free-list-inl.h", "src/heap/free-list.h", "src/heap/gc-callbacks.h", - "src/heap/gc-idle-time-handler.h", "src/heap/gc-tracer-inl.h", "src/heap/gc-tracer.h", "src/heap/heap-allocator-inl.h", @@ -3637,6 +3642,7 @@ v8_header_set("v8_internal_headers") { "src/heap/incremental-marking-job.h", "src/heap/incremental-marking.h", "src/heap/index-generator.h", + "src/heap/large-page-inl.h", "src/heap/large-page.h", "src/heap/large-spaces.h", "src/heap/linear-allocation-area.h", @@ -3662,7 +3668,9 @@ v8_header_set("v8_internal_headers") { "src/heap/marking.h", "src/heap/memory-allocator.h", "src/heap/memory-balancer.h", + "src/heap/memory-chunk-inl.h", "src/heap/memory-chunk-layout.h", + "src/heap/memory-chunk-metadata-inl.h", "src/heap/memory-chunk-metadata.h", "src/heap/memory-chunk.h", "src/heap/memory-measurement-inl.h", @@ -3675,6 +3683,7 @@ v8_header_set("v8_internal_headers") { "src/heap/mutable-page.h", "src/heap/new-spaces-inl.h", "src/heap/new-spaces.h", + "src/heap/object-lock-inl.h", "src/heap/object-lock.h", "src/heap/object-stats.h", "src/heap/objects-visiting-inl.h", @@ -3717,7 +3726,7 @@ v8_header_set("v8_internal_headers") { "src/init/bootstrapper.h", "src/init/heap-symbols.h", "src/init/icu_util.h", - "src/init/isolate-allocator.h", + "src/init/isolate-group.h", "src/init/setup-isolate.h", "src/init/startup-data-util.h", "src/init/v8.h", @@ -3727,7 +3736,7 @@ v8_header_set("v8_internal_headers") { "src/interpreter/bytecode-array-random-iterator.h", "src/interpreter/bytecode-array-writer.h", "src/interpreter/bytecode-decoder.h", - "src/interpreter/bytecode-flags.h", + "src/interpreter/bytecode-flags-and-tokens.h", "src/interpreter/bytecode-generator.h", "src/interpreter/bytecode-jump-table.h", "src/interpreter/bytecode-label.h", @@ -3841,6 +3850,8 @@ v8_header_set("v8_internal_headers") { "src/objects/js-collection-iterator-inl.h", "src/objects/js-collection-iterator.h", "src/objects/js-collection.h", + "src/objects/js-disposable-stack-inl.h", + "src/objects/js-disposable-stack.h", "src/objects/js-function-inl.h", "src/objects/js-function.h", "src/objects/js-generator-inl.h", @@ -3983,6 +3994,7 @@ v8_header_set("v8_internal_headers") { "src/objects/value-serializer.h", "src/objects/visitors-inl.h", "src/objects/visitors.h", + "src/objects/waiter-queue-node.h", "src/parsing/expression-scope.h", "src/parsing/func-name-inferrer.h", "src/parsing/import-assertions.h", @@ -4056,6 +4068,13 @@ v8_header_set("v8_internal_headers") { "src/sandbox/code-pointer-table-inl.h", "src/sandbox/code-pointer-table.h", "src/sandbox/code-pointer.h", + "src/sandbox/compactible-external-entity-table-inl.h", + "src/sandbox/compactible-external-entity-table.h", + "src/sandbox/external-buffer-inl.h", + "src/sandbox/external-buffer-table-inl.h", + "src/sandbox/external-buffer-table.h", + "src/sandbox/external-buffer-tag.h", + "src/sandbox/external-buffer.h", "src/sandbox/external-entity-table-inl.h", "src/sandbox/external-entity-table.h", "src/sandbox/external-pointer-inl.h", @@ -4070,6 +4089,7 @@ v8_header_set("v8_internal_headers") { "src/sandbox/sandbox.h", "src/sandbox/sandboxed-pointer-inl.h", "src/sandbox/sandboxed-pointer.h", + "src/sandbox/tagged-payload.h", "src/sandbox/testing.h", "src/sandbox/trusted-pointer-table-inl.h", "src/sandbox/trusted-pointer-table.h", @@ -4101,6 +4121,7 @@ v8_header_set("v8_internal_headers") { "src/strings/char-predicates-inl.h", "src/strings/char-predicates.h", "src/strings/string-builder-inl.h", + "src/strings/string-builder.h", "src/strings/string-case.h", "src/strings/string-hasher-inl.h", "src/strings/string-hasher.h", @@ -4117,6 +4138,7 @@ v8_header_set("v8_internal_headers") { "src/third_party/siphash/halfsiphash.h", "src/third_party/utf8-decoder/utf8-decoder.h", "src/torque/runtime-macro-shims.h", + "src/tracing/trace-event-no-perfetto.h", "src/tracing/trace-event.h", "src/tracing/traced-value.h", "src/tracing/tracing-category-observer.h", @@ -4159,7 +4181,7 @@ v8_header_set("v8_internal_headers") { } if (v8_use_perfetto) { - sources -= [ "//base/trace_event/common/trace_event_common.h" ] + sources -= [ "src/tracing/trace-event-no-perfetto.h" ] sources += [ "src/tracing/code-data-source.h", "src/tracing/code-trace-context.h", @@ -4256,6 +4278,7 @@ v8_header_set("v8_internal_headers") { "src/wasm/baseline/liftoff-assembler.h", "src/wasm/baseline/liftoff-compiler.h", "src/wasm/baseline/liftoff-register.h", + "src/wasm/baseline/liftoff-varstate.h", "src/wasm/baseline/parallel-move-inl.h", "src/wasm/baseline/parallel-move.h", "src/wasm/canonical-types.h", @@ -4296,6 +4319,7 @@ v8_header_set("v8_internal_headers") { "src/wasm/wasm-builtin-list.h", "src/wasm/wasm-code-manager.h", "src/wasm/wasm-debug.h", + "src/wasm/wasm-deopt-data.h", "src/wasm/wasm-disassembler-impl.h", "src/wasm/wasm-disassembler.h", "src/wasm/wasm-engine.h", @@ -4751,6 +4775,11 @@ v8_header_set("v8_internal_headers") { } } + frameworks = [] + if (is_ios) { + frameworks += [ "BrowserEngineKit.framework" ] + } + public_deps = [ ":torque_runtime_support", ":v8_flags", @@ -4805,11 +4834,9 @@ v8_compiler_sources = [ "src/compiler/const-tracking-let-helpers.cc", "src/compiler/constant-folding-reducer.cc", "src/compiler/control-equivalence.cc", - "src/compiler/control-flow-optimizer.cc", "src/compiler/csa-load-elimination.cc", "src/compiler/dead-code-elimination.cc", "src/compiler/decompression-optimizer.cc", - "src/compiler/effect-control-linearizer.cc", "src/compiler/escape-analysis-reducer.cc", "src/compiler/escape-analysis.cc", "src/compiler/fast-api-calls.cc", @@ -4876,7 +4903,6 @@ v8_compiler_sources = [ "src/compiler/simplified-operator-reducer.cc", "src/compiler/simplified-operator.cc", "src/compiler/state-values-utils.cc", - "src/compiler/store-store-elimination.cc", "src/compiler/string-builder-optimizer.cc", "src/compiler/turbofan-enabled.cc", "src/compiler/type-cache.cc", @@ -5131,6 +5157,7 @@ v8_source_set("v8_turboshaft") { "src/maglev/maglev-graph-printer.cc", "src/maglev/maglev-interpreter-frame-state.cc", "src/maglev/maglev-ir.cc", + "src/maglev/maglev-phi-representation-selector.cc", ] } @@ -5214,6 +5241,7 @@ v8_source_set("v8_base_without_compiler") { "src/builtins/builtins-console.cc", "src/builtins/builtins-dataview.cc", "src/builtins/builtins-date.cc", + "src/builtins/builtins-disposable-stack.cc", "src/builtins/builtins-error.cc", "src/builtins/builtins-function.cc", "src/builtins/builtins-global.cc", @@ -5350,7 +5378,6 @@ v8_source_set("v8_base_without_compiler") { "src/heap/factory.cc", "src/heap/finalization-registry-cleanup-task.cc", "src/heap/free-list.cc", - "src/heap/gc-idle-time-handler.cc", "src/heap/gc-tracer.cc", "src/heap/heap-allocator.cc", "src/heap/heap-controller.cc", @@ -5407,7 +5434,7 @@ v8_source_set("v8_base_without_compiler") { "src/ic/stub-cache.cc", "src/init/bootstrapper.cc", "src/init/icu_util.cc", - "src/init/isolate-allocator.cc", + "src/init/isolate-group.cc", "src/init/startup-data-util.cc", "src/init/v8.cc", "src/interpreter/bytecode-array-builder.cc", @@ -5415,7 +5442,7 @@ v8_source_set("v8_base_without_compiler") { "src/interpreter/bytecode-array-random-iterator.cc", "src/interpreter/bytecode-array-writer.cc", "src/interpreter/bytecode-decoder.cc", - "src/interpreter/bytecode-flags.cc", + "src/interpreter/bytecode-flags-and-tokens.cc", "src/interpreter/bytecode-generator.cc", "src/interpreter/bytecode-label.cc", "src/interpreter/bytecode-node.cc", @@ -5467,6 +5494,7 @@ v8_source_set("v8_base_without_compiler") { "src/objects/js-collator.cc", "src/objects/js-date-time-format.cc", "src/objects/js-display-names.cc", + "src/objects/js-disposable-stack.cc", "src/objects/js-duration-format.cc", "src/objects/js-function.cc", "src/objects/js-list-format.cc", @@ -5515,6 +5543,7 @@ v8_source_set("v8_base_without_compiler") { "src/objects/type-hints.cc", "src/objects/value-serializer.cc", "src/objects/visitors.cc", + "src/objects/waiter-queue-node.cc", "src/parsing/func-name-inferrer.cc", "src/parsing/import-assertions.cc", "src/parsing/literal-buffer.cc", @@ -5594,6 +5623,7 @@ v8_source_set("v8_base_without_compiler") { "src/runtime/runtime-weak-refs.cc", "src/runtime/runtime.cc", "src/sandbox/code-pointer-table.cc", + "src/sandbox/external-buffer-table.cc", "src/sandbox/external-pointer-table.cc", "src/sandbox/sandbox.cc", "src/sandbox/testing.cc", @@ -5744,6 +5774,7 @@ v8_source_set("v8_base_without_compiler") { "src/wasm/value-type.cc", "src/wasm/wasm-code-manager.cc", "src/wasm/wasm-debug.cc", + "src/wasm/wasm-deopt-data.cc", "src/wasm/wasm-disassembler.cc", "src/wasm/wasm-engine.cc", "src/wasm/wasm-external-refs.cc", @@ -6243,7 +6274,10 @@ v8_source_set("torque_base") { ":v8_shared_internal_headers", ] - public_deps = [ ":v8_libbase" ] + public_deps = [ + ":v8_config_headers", + ":v8_libbase", + ] # The use of exceptions for Torque in violation of the Chromium style-guide # is justified by the fact that it is only used from the non-essential @@ -6406,6 +6440,9 @@ v8_component("v8_libbase") { "src/base/strings.h", "src/base/sys-info.cc", "src/base/sys-info.h", + "src/base/template-meta-programming/algorithm.h", + "src/base/template-meta-programming/functional.h", + "src/base/template-meta-programming/list.h", "src/base/template-utils.h", "src/base/threaded-list.h", "src/base/timezone-cache.h", @@ -6512,7 +6549,6 @@ v8_component("v8_libbase") { sources += [ "src/base/debug/stack_trace_posix.cc", "src/base/platform/platform-darwin.cc", - "src/base/platform/platform-ios.cc", ] } else if (is_win) { # TODO(infra): Add support for cygwin. @@ -6597,7 +6633,6 @@ if (v8_use_libm_trig_functions) { v8_component("v8_libplatform") { sources = [ - "//base/trace_event/common/trace_event_common.h", "include/libplatform/libplatform-export.h", "include/libplatform/libplatform.h", "include/libplatform/v8-tracing.h", @@ -6624,6 +6659,7 @@ v8_component("v8_libplatform") { "src/libplatform/tracing/tracing-controller.cc", "src/libplatform/worker-thread.cc", "src/libplatform/worker-thread.h", + "src/tracing/trace-event-no-perfetto.h", ] configs = [ ":internal_config_base" ] @@ -6644,12 +6680,12 @@ v8_component("v8_libplatform") { if (v8_use_perfetto) { sources -= [ - "//base/trace_event/common/trace_event_common.h", "src/libplatform/tracing/trace-buffer.cc", "src/libplatform/tracing/trace-buffer.h", "src/libplatform/tracing/trace-object.cc", "src/libplatform/tracing/trace-writer.cc", "src/libplatform/tracing/trace-writer.h", + "src/tracing/trace-event-no-perfetto.h", ] sources += [ "src/libplatform/tracing/trace-event-listener.h" ] } @@ -6746,7 +6782,12 @@ v8_source_set("v8_heap_base") { if (is_clang || !is_win) { if (current_cpu == "x64") { - sources += [ "src/heap/base/asm/x64/push_registers_asm.cc" ] + if (is_win) { + # Prefer a masm version with unwind directives. + sources += [ "src/heap/base/asm/x64/push_registers_masm.asm" ] + } else { + sources += [ "src/heap/base/asm/x64/push_registers_asm.cc" ] + } } else if (current_cpu == "x86") { sources += [ "src/heap/base/asm/ia32/push_registers_asm.cc" ] } else if (current_cpu == "arm") { @@ -6972,7 +7013,7 @@ v8_source_set("cppgc_base") { ] if (cppgc_is_standalone && !v8_use_perfetto) { - sources += [ "//base/trace_event/common/trace_event_common.h" ] + sources += [ "src/tracing/trace-event-no-perfetto.h" ] } else { public_deps += [ ":v8_tracing" ] } @@ -7122,7 +7163,10 @@ if (current_toolchain == v8_snapshot_toolchain) { sources += [ "src/deoptimizer/deoptimizer-cfi-empty.cc" ] } - configs = [ ":internal_config" ] + configs = [ + ":internal_config", + ":disable_icf", + ] deps = [ ":v8_base_without_compiler", @@ -7137,6 +7181,23 @@ if (current_toolchain == v8_snapshot_toolchain) { "//build/win:default_exe_manifest", ] } + + # This config disables a link time optimization "ICF", which may merge + # different functions into one if the function signature and body of them are + # identical. + # + # ICF breaks 1:1 mappings of the external references for V8 snapshot, so we + # disable it while taking a V8 snapshot. + config("disable_icf") { + visibility = [ ":*" ] # Only targets in this file can depend on this. + if (is_win) { + ldflags = [ "/OPT:NOICF" ] # link.exe, but also lld-link.exe. + } else if (is_apple && !use_lld) { + ldflags = [ "-Wl,-no_deduplicate" ] # ld64. + } else if (use_lld) { + ldflags = [ "-Wl,--icf=none" ] + } + } } if (current_toolchain == v8_snapshot_toolchain) { @@ -7354,8 +7415,10 @@ group("v8_fuzzers") { ":v8_simple_multi_return_fuzzer", ":v8_simple_wasm_async_fuzzer", ":v8_simple_wasm_code_fuzzer", + ":v8_simple_wasm_compile_all_fuzzer", ":v8_simple_wasm_compile_fuzzer", ":v8_simple_wasm_compile_simd_fuzzer", + ":v8_simple_wasm_compile_wasmgc_fuzzer", ":v8_simple_wasm_fuzzer", ":v8_simple_wasm_init_expr_fuzzer", ":v8_simple_wasm_streaming_fuzzer", @@ -7624,11 +7687,25 @@ v8_executable("cppgc_hello_world") { } template("v8_fuzzer") { - name = target_name - forward_variables_from(invoker, "*") - v8_executable("v8_simple_" + name) { + fuzzer_name = target_name + + v8_source_set(fuzzer_name) { + sources = invoker.sources + + deps = [ ":fuzzer_support" ] + if (defined(invoker.deps)) { + deps += invoker.deps + } + + configs = [ + ":external_config", + ":internal_config_base", + ] + } + + v8_executable("v8_simple_${fuzzer_name}") { deps = [ - ":" + name, + ":${fuzzer_name}", "//build/win:default_exe_manifest", ] @@ -7638,61 +7715,21 @@ template("v8_fuzzer") { } } -v8_source_set("json_fuzzer") { - sources = [ "test/fuzzer/json.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] -} - v8_fuzzer("json_fuzzer") { -} - -v8_source_set("parser_fuzzer") { - sources = [ "test/fuzzer/parser.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] + sources = [ "test/fuzzer/json.cc" ] } v8_fuzzer("parser_fuzzer") { -} - -v8_source_set("regexp_fuzzer") { - sources = [ "test/fuzzer/regexp.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] + sources = [ "test/fuzzer/parser.cc" ] } v8_fuzzer("regexp_fuzzer") { + sources = [ "test/fuzzer/regexp.cc" ] } if (v8_enable_webassembly) { - v8_source_set("multi_return_fuzzer") { - sources = [ "test/fuzzer/multi-return.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - v8_fuzzer("multi_return_fuzzer") { + sources = [ "test/fuzzer/multi-return.cc" ] } v8_source_set("wasm_test_common") { @@ -7723,67 +7760,11 @@ if (v8_enable_webassembly) { ] } - v8_source_set("wasm_fuzzer") { - sources = [ "test/fuzzer/wasm.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_fuzzer") { - } - - v8_source_set("wasm_async_fuzzer") { - sources = [ "test/fuzzer/wasm-async.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_async_fuzzer") { - } - - v8_source_set("wasm_code_fuzzer") { - sources = [ - "test/common/wasm/test-signatures.h", - "test/fuzzer/wasm-code.cc", - ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_code_fuzzer") { - } - - v8_source_set("lib_wasm_fuzzer_common") { + v8_source_set("wasm_fuzzer_common") { sources = [ "test/fuzzer/wasm-fuzzer-common.cc", "test/fuzzer/wasm-fuzzer-common.h", + "tools/wasm/mjsunit-module-disassembler-impl.h", ] deps = [ @@ -7806,100 +7787,71 @@ if (v8_enable_webassembly) { ] } - v8_source_set("wasm_compile_fuzzer") { - sources = [ - "test/common/wasm/test-signatures.h", - "test/fuzzer/wasm-compile.cc", - ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] + template("v8_wasm_fuzzer") { + forward_variables_from(invoker, "*") + v8_fuzzer(target_name) { + deps = [ + ":wasm_fuzzer_common", + ":wasm_test_common", + ] + } + } - configs = [ - ":external_config", - ":internal_config_base", - ] + v8_wasm_fuzzer("wasm_fuzzer") { + sources = [ "test/fuzzer/wasm.cc" ] } - v8_fuzzer("wasm_compile_fuzzer") { + v8_wasm_fuzzer("wasm_async_fuzzer") { + sources = [ "test/fuzzer/wasm-async.cc" ] } - v8_source_set("wasm_compile_simd_fuzzer") { + v8_wasm_fuzzer("wasm_code_fuzzer") { sources = [ "test/common/wasm/test-signatures.h", - "test/fuzzer/wasm-compile-simd.cc", - ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", + "test/fuzzer/wasm-code.cc", ] + } - configs = [ - ":external_config", - ":internal_config_base", + v8_wasm_fuzzer("wasm_compile_all_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-compile-all.cc", ] } - v8_fuzzer("wasm_compile_simd_fuzzer") { + v8_wasm_fuzzer("wasm_compile_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-compile.cc", + ] } - v8_source_set("wasm_streaming_fuzzer") { - sources = [ "test/fuzzer/wasm-streaming.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", + v8_wasm_fuzzer("wasm_compile_simd_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-compile-simd.cc", ] + } - configs = [ - ":external_config", - ":internal_config_base", + v8_wasm_fuzzer("wasm_compile_wasmgc_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-compile-wasmgc.cc", ] } - v8_fuzzer("wasm_streaming_fuzzer") { + v8_wasm_fuzzer("wasm_streaming_fuzzer") { + sources = [ "test/fuzzer/wasm-streaming.cc" ] } - v8_source_set("wasm_init_expr_fuzzer") { + v8_wasm_fuzzer("wasm_init_expr_fuzzer") { sources = [ "test/fuzzer/wasm-init-expr.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_init_expr_fuzzer") { } } -v8_source_set("inspector_fuzzer") { - sources = [ "test/fuzzer/inspector-fuzzer.cc" ] - - deps = [ - ":fuzzer_support", - "test/inspector:inspector_test", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] -} - v8_fuzzer("inspector_fuzzer") { + sources = [ "test/fuzzer/inspector-fuzzer.cc" ] + deps = [ "test/inspector:inspector_test" ] } # Target to build all generated .cc files. @@ -7916,334 +7868,6 @@ group("v8_generated_cc_files") { # Protobuf targets, used only when building outside of chromium. if (!build_with_chromium && v8_use_perfetto) { - # This config is applied to the autogenerated .pb.{cc,h} files in - # proto_library.gni. This config is propagated up to the source sets - # that depend on generated proto headers. - config("protobuf_gen_config") { - defines = [ - "GOOGLE_PROTOBUF_NO_RTTI", - "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER", - ] - cflags = [ - "-Wno-unknown-warning-option", - "-Wno-deprecated", - "-Wno-undef", - "-Wno-zero-as-null-pointer-constant", - "-Wno-thread-safety-attributes", - ] - include_dirs = [ "third_party/protobuf/src" ] - } - - # Configuration used to build libprotobuf_* and the protoc compiler. - config("protobuf_config") { - # Apply the lighter supressions and macro definitions from above. - configs = [ ":protobuf_gen_config" ] - - if (!is_win) { - defines = [ "HAVE_PTHREAD=1" ] - } - if (is_clang) { - cflags = [ - "-Wno-unused-private-field", - "-Wno-unused-function", - "-Wno-inconsistent-missing-override", - "-Wno-unknown-warning-option", - "-Wno-enum-compare-switch", - "-Wno-user-defined-warnings", - "-Wno-tautological-constant-compare", - ] - } - if (is_win && is_clang) { - cflags += [ "-Wno-microsoft-unqualified-friend" ] - } - } - - source_set("protobuf_lite") { - sources = [ - "third_party/protobuf/src/google/protobuf/any_lite.cc", - "third_party/protobuf/src/google/protobuf/arena.cc", - "third_party/protobuf/src/google/protobuf/arena.h", - "third_party/protobuf/src/google/protobuf/arena_impl.h", - "third_party/protobuf/src/google/protobuf/arenastring.h", - "third_party/protobuf/src/google/protobuf/extension_set.cc", - "third_party/protobuf/src/google/protobuf/extension_set.h", - "third_party/protobuf/src/google/protobuf/generated_enum_util.cc", - "third_party/protobuf/src/google/protobuf/generated_enum_util.h", - "third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.cc", - "third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.h", - "third_party/protobuf/src/google/protobuf/generated_message_util.cc", - "third_party/protobuf/src/google/protobuf/generated_message_util.h", - "third_party/protobuf/src/google/protobuf/has_bits.h", - "third_party/protobuf/src/google/protobuf/implicit_weak_message.cc", - "third_party/protobuf/src/google/protobuf/implicit_weak_message.h", - "third_party/protobuf/src/google/protobuf/inlined_string_field.h", - "third_party/protobuf/src/google/protobuf/io/coded_stream.cc", - "third_party/protobuf/src/google/protobuf/io/coded_stream.h", - "third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h", - "third_party/protobuf/src/google/protobuf/io/io_win32.cc", - "third_party/protobuf/src/google/protobuf/io/io_win32.h", - "third_party/protobuf/src/google/protobuf/io/strtod.cc", - "third_party/protobuf/src/google/protobuf/io/strtod.h", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.cc", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h", - "third_party/protobuf/src/google/protobuf/map.h", - "third_party/protobuf/src/google/protobuf/map_entry_lite.h", - "third_party/protobuf/src/google/protobuf/map_field_lite.h", - "third_party/protobuf/src/google/protobuf/map_type_handler.h", - "third_party/protobuf/src/google/protobuf/message_lite.cc", - "third_party/protobuf/src/google/protobuf/message_lite.h", - "third_party/protobuf/src/google/protobuf/repeated_field.cc", - "third_party/protobuf/src/google/protobuf/repeated_field.h", - "third_party/protobuf/src/google/protobuf/stubs/bytestream.cc", - "third_party/protobuf/src/google/protobuf/stubs/bytestream.h", - "third_party/protobuf/src/google/protobuf/stubs/callback.h", - "third_party/protobuf/src/google/protobuf/stubs/casts.h", - "third_party/protobuf/src/google/protobuf/stubs/common.cc", - "third_party/protobuf/src/google/protobuf/stubs/common.h", - "third_party/protobuf/src/google/protobuf/stubs/fastmem.h", - "third_party/protobuf/src/google/protobuf/stubs/hash.h", - "third_party/protobuf/src/google/protobuf/stubs/int128.cc", - "third_party/protobuf/src/google/protobuf/stubs/int128.h", - "third_party/protobuf/src/google/protobuf/stubs/logging.h", - "third_party/protobuf/src/google/protobuf/stubs/macros.h", - "third_party/protobuf/src/google/protobuf/stubs/map_util.h", - "third_party/protobuf/src/google/protobuf/stubs/mutex.h", - "third_party/protobuf/src/google/protobuf/stubs/once.h", - "third_party/protobuf/src/google/protobuf/stubs/platform_macros.h", - "third_party/protobuf/src/google/protobuf/stubs/port.h", - "third_party/protobuf/src/google/protobuf/stubs/status.cc", - "third_party/protobuf/src/google/protobuf/stubs/status.h", - "third_party/protobuf/src/google/protobuf/stubs/status_macros.h", - "third_party/protobuf/src/google/protobuf/stubs/statusor.cc", - "third_party/protobuf/src/google/protobuf/stubs/statusor.h", - "third_party/protobuf/src/google/protobuf/stubs/stl_util.h", - "third_party/protobuf/src/google/protobuf/stubs/stringpiece.cc", - "third_party/protobuf/src/google/protobuf/stubs/stringpiece.h", - "third_party/protobuf/src/google/protobuf/stubs/stringprintf.cc", - "third_party/protobuf/src/google/protobuf/stubs/stringprintf.h", - "third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc", - "third_party/protobuf/src/google/protobuf/stubs/strutil.cc", - "third_party/protobuf/src/google/protobuf/stubs/strutil.h", - "third_party/protobuf/src/google/protobuf/stubs/template_util.h", - "third_party/protobuf/src/google/protobuf/stubs/time.cc", - "third_party/protobuf/src/google/protobuf/stubs/time.h", - "third_party/protobuf/src/google/protobuf/wire_format_lite.cc", - "third_party/protobuf/src/google/protobuf/wire_format_lite.h", - ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - ":protobuf_config", - ] - if (is_win) { - configs -= [ "//build/config/win:lean_and_mean" ] - } - public_configs = [ ":protobuf_gen_config" ] - } - - # This target should be used only by the protoc compiler and by test targets. - source_set("protobuf_full") { - deps = [ ":protobuf_lite" ] - sources = [ - "third_party/protobuf/src/google/protobuf/any.cc", - "third_party/protobuf/src/google/protobuf/any.h", - "third_party/protobuf/src/google/protobuf/any.pb.cc", - "third_party/protobuf/src/google/protobuf/any.pb.h", - "third_party/protobuf/src/google/protobuf/api.pb.cc", - "third_party/protobuf/src/google/protobuf/api.pb.h", - "third_party/protobuf/src/google/protobuf/compiler/importer.cc", - "third_party/protobuf/src/google/protobuf/compiler/importer.h", - "third_party/protobuf/src/google/protobuf/compiler/parser.cc", - "third_party/protobuf/src/google/protobuf/compiler/parser.h", - "third_party/protobuf/src/google/protobuf/descriptor.cc", - "third_party/protobuf/src/google/protobuf/descriptor.h", - "third_party/protobuf/src/google/protobuf/descriptor.pb.cc", - "third_party/protobuf/src/google/protobuf/descriptor.pb.h", - "third_party/protobuf/src/google/protobuf/descriptor_database.cc", - "third_party/protobuf/src/google/protobuf/descriptor_database.h", - "third_party/protobuf/src/google/protobuf/duration.pb.cc", - "third_party/protobuf/src/google/protobuf/duration.pb.h", - "third_party/protobuf/src/google/protobuf/dynamic_message.cc", - "third_party/protobuf/src/google/protobuf/dynamic_message.h", - "third_party/protobuf/src/google/protobuf/empty.pb.cc", - "third_party/protobuf/src/google/protobuf/empty.pb.h", - "third_party/protobuf/src/google/protobuf/extension_set_heavy.cc", - "third_party/protobuf/src/google/protobuf/field_mask.pb.cc", - "third_party/protobuf/src/google/protobuf/field_mask.pb.h", - "third_party/protobuf/src/google/protobuf/generated_enum_reflection.h", - "third_party/protobuf/src/google/protobuf/generated_message_reflection.cc", - "third_party/protobuf/src/google/protobuf/generated_message_reflection.h", - "third_party/protobuf/src/google/protobuf/io/gzip_stream.cc", - "third_party/protobuf/src/google/protobuf/io/gzip_stream.h", - "third_party/protobuf/src/google/protobuf/io/printer.cc", - "third_party/protobuf/src/google/protobuf/io/printer.h", - "third_party/protobuf/src/google/protobuf/io/tokenizer.cc", - "third_party/protobuf/src/google/protobuf/io/tokenizer.h", - "third_party/protobuf/src/google/protobuf/map_entry.h", - "third_party/protobuf/src/google/protobuf/map_field.cc", - "third_party/protobuf/src/google/protobuf/map_field.h", - "third_party/protobuf/src/google/protobuf/map_field_inl.h", - "third_party/protobuf/src/google/protobuf/message.cc", - "third_party/protobuf/src/google/protobuf/message.h", - "third_party/protobuf/src/google/protobuf/metadata.h", - "third_party/protobuf/src/google/protobuf/reflection.h", - "third_party/protobuf/src/google/protobuf/reflection_internal.h", - "third_party/protobuf/src/google/protobuf/reflection_ops.cc", - "third_party/protobuf/src/google/protobuf/reflection_ops.h", - "third_party/protobuf/src/google/protobuf/service.cc", - "third_party/protobuf/src/google/protobuf/service.h", - "third_party/protobuf/src/google/protobuf/source_context.pb.cc", - "third_party/protobuf/src/google/protobuf/source_context.pb.h", - "third_party/protobuf/src/google/protobuf/struct.pb.cc", - "third_party/protobuf/src/google/protobuf/struct.pb.h", - "third_party/protobuf/src/google/protobuf/stubs/mathlimits.cc", - "third_party/protobuf/src/google/protobuf/stubs/mathlimits.h", - "third_party/protobuf/src/google/protobuf/stubs/mathutil.h", - "third_party/protobuf/src/google/protobuf/stubs/substitute.cc", - "third_party/protobuf/src/google/protobuf/stubs/substitute.h", - "third_party/protobuf/src/google/protobuf/text_format.cc", - "third_party/protobuf/src/google/protobuf/text_format.h", - "third_party/protobuf/src/google/protobuf/timestamp.pb.cc", - "third_party/protobuf/src/google/protobuf/timestamp.pb.h", - "third_party/protobuf/src/google/protobuf/type.pb.cc", - "third_party/protobuf/src/google/protobuf/type.pb.h", - "third_party/protobuf/src/google/protobuf/unknown_field_set.cc", - "third_party/protobuf/src/google/protobuf/unknown_field_set.h", - "third_party/protobuf/src/google/protobuf/util/field_comparator.cc", - "third_party/protobuf/src/google/protobuf/util/field_comparator.h", - "third_party/protobuf/src/google/protobuf/util/field_mask_util.cc", - "third_party/protobuf/src/google/protobuf/util/field_mask_util.h", - "third_party/protobuf/src/google/protobuf/util/internal/constants.h", - "third_party/protobuf/src/google/protobuf/util/internal/datapiece.cc", - "third_party/protobuf/src/google/protobuf/util/internal/datapiece.h", - "third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc", - "third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/error_listener.cc", - "third_party/protobuf/src/google/protobuf/util/internal/error_listener.h", - "third_party/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc", - "third_party/protobuf/src/google/protobuf/util/internal/field_mask_utility.h", - "third_party/protobuf/src/google/protobuf/util/internal/json_escaping.cc", - "third_party/protobuf/src/google/protobuf/util/internal/json_escaping.h", - "third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc", - "third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc", - "third_party/protobuf/src/google/protobuf/util/internal/json_stream_parser.h", - "third_party/protobuf/src/google/protobuf/util/internal/location_tracker.h", - "third_party/protobuf/src/google/protobuf/util/internal/object_location_tracker.h", - "third_party/protobuf/src/google/protobuf/util/internal/object_source.h", - "third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc", - "third_party/protobuf/src/google/protobuf/util/internal/object_writer.h", - "third_party/protobuf/src/google/protobuf/util/internal/proto_writer.cc", - "third_party/protobuf/src/google/protobuf/util/internal/proto_writer.h", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/type_info.cc", - "third_party/protobuf/src/google/protobuf/util/internal/type_info.h", - "third_party/protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc", - "third_party/protobuf/src/google/protobuf/util/internal/type_info_test_helper.h", - "third_party/protobuf/src/google/protobuf/util/internal/utility.cc", - "third_party/protobuf/src/google/protobuf/util/internal/utility.h", - "third_party/protobuf/src/google/protobuf/util/json_util.cc", - "third_party/protobuf/src/google/protobuf/util/json_util.h", - "third_party/protobuf/src/google/protobuf/util/message_differencer.cc", - "third_party/protobuf/src/google/protobuf/util/message_differencer.h", - "third_party/protobuf/src/google/protobuf/util/time_util.cc", - "third_party/protobuf/src/google/protobuf/util/time_util.h", - "third_party/protobuf/src/google/protobuf/util/type_resolver.h", - "third_party/protobuf/src/google/protobuf/util/type_resolver_util.cc", - "third_party/protobuf/src/google/protobuf/util/type_resolver_util.h", - "third_party/protobuf/src/google/protobuf/wire_format.cc", - "third_party/protobuf/src/google/protobuf/wire_format.h", - "third_party/protobuf/src/google/protobuf/wrappers.pb.cc", - "third_party/protobuf/src/google/protobuf/wrappers.pb.h", - ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - ":protobuf_config", - ] - if (is_win) { - configs -= [ "//build/config/win:lean_and_mean" ] - } - public_configs = [ ":protobuf_gen_config" ] - } - - if (current_toolchain == host_toolchain) { - source_set("protoc_lib") { - deps = [ ":protobuf_full" ] - sources = [ - "third_party/protobuf/src/google/protobuf/compiler/code_generator.cc", - "third_party/protobuf/src/google/protobuf/compiler/code_generator.h", - "third_party/protobuf/src/google/protobuf/compiler/command_line_interface.cc", - "third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h", - "third_party/protobuf/src/google/protobuf/compiler/plugin.cc", - "third_party/protobuf/src/google/protobuf/compiler/plugin.h", - "third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc", - "third_party/protobuf/src/google/protobuf/compiler/plugin.pb.h", - "third_party/protobuf/src/google/protobuf/compiler/subprocess.cc", - "third_party/protobuf/src/google/protobuf/compiler/subprocess.h", - "third_party/protobuf/src/google/protobuf/compiler/zip_writer.cc", - "third_party/protobuf/src/google/protobuf/compiler/zip_writer.h", - ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - ":protobuf_config", - ] - if (is_win) { - configs -= [ "//build/config/win:lean_and_mean" ] - } - public_configs = [ ":protobuf_gen_config" ] - } - - executable("protoc") { - deps = [ - ":protoc_lib", - "//build/win:default_exe_manifest", - ] - sources = [ "src/protobuf/protobuf-compiler-main.cc" ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - } # host_toolchain - v8_component("v8_libperfetto") { configs = [ ":v8_tracing_config" ] public_configs = [ "//third_party/perfetto/gn:public_config" ] diff --git a/deps/v8/COMMON_OWNERS b/deps/v8/COMMON_OWNERS index 9e9d51d5835..75076cd1634 100644 --- a/deps/v8/COMMON_OWNERS +++ b/deps/v8/COMMON_OWNERS @@ -1,5 +1,6 @@ adamk@chromium.org ahaas@chromium.org +alexschulze@chromium.org bikineev@chromium.org bmeurer@chromium.org cbruni@chromium.org @@ -16,21 +17,22 @@ ishell@chromium.org jgruber@chromium.org jkummerow@chromium.org leszeks@chromium.org +liviurau@chromium.org machenbach@chromium.org manoskouk@chromium.org -mathias@chromium.org marja@chromium.org +mathias@chromium.org mliedtke@chromium.org mlippautz@chromium.org -mslekova@chromium.org nicohartmann@chromium.org nikolaos@chromium.org +olivf@chromium.org omerkatz@chromium.org pthier@chromium.org +rezvan@chromium.org sroettger@google.com syg@chromium.org szuend@chromium.org -tebbi@chromium.org thibaudm@chromium.org vahl@chromium.org verwaest@chromium.org diff --git a/deps/v8/DEPS b/deps/v8/DEPS index 8f2b6e603db..8da915b8911 100644 --- a/deps/v8/DEPS +++ b/deps/v8/DEPS @@ -57,7 +57,7 @@ vars = { 'checkout_fuchsia_no_hooks': False, # reclient CIPD package version - 'reclient_version': 're_client_version:0.134.1.2c9285b-gomaip', + 'reclient_version': 're_client_version:0.141.1.29a9d3c-gomaip', # Fetch configuration files required for the 'use_remoteexec' gn arg 'download_remoteexec_cfg': False, @@ -73,22 +73,22 @@ vars = { 'build_with_chromium': False, # GN CIPD package version. - 'gn_version': 'git_revision:59c4bb920542ee903ee1df39097ae024e2e8226f', + 'gn_version': 'git_revision:df98b86690c83b81aedc909ded18857296406159', # ninja CIPD package version # https://chrome-infra-packages.appspot.com/p/infra/3pp/tools/ninja 'ninja_version': 'version:2@1.11.1.chromium.6', # siso CIPD package version - 'siso_version': 'git_revision:110b1d8c0528de153cef259f09f3dc5ee627e6cb', + 'siso_version': 'git_revision:4524544994f4eac131378143f498ee4d0b7d1f36', # luci-go CIPD package version. - 'luci_go': 'git_revision:623f8d17a069eaea6d0fca13147888284ec76ff1', + 'luci_go': 'git_revision:69f852c6aea2797c75712d59145efd38d7032196', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Fuchsia sdk # and whatever else without interference from each other. - 'fuchsia_version': 'version:19.20240305.3.1', + 'fuchsia_version': 'version:20.20240430.3.1', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_build-tools_version @@ -125,12 +125,10 @@ vars = { } deps = { - 'base/trace_event/common': - Var('chromium_url') + '/chromium/src/base/trace_event/common.git' + '@' + '29ac73db520575590c3aceb0a6f1f58dda8934f6', 'build': - Var('chromium_url') + '/chromium/src/build.git' + '@' + 'bca39698b291b392f0b4336857caf929c603ada3', + Var('chromium_url') + '/chromium/src/build.git' + '@' + 'dbd3873447f647584690532e2fb935e103c8860c', 'buildtools': - Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + '68fce43789231d29d2028ca85530e4814aac6f50', + Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + 'efa920ce144e4dc1c1841e73179cd7e23b9f0d5e', 'buildtools/linux64': { 'packages': [ { @@ -176,7 +174,7 @@ deps = { 'test/mozilla/data': Var('chromium_url') + '/v8/deps/third_party/mozilla-tests.git' + '@' + 'f6c578a10ea707b1a8ab0b88943fe5115ce2b9be', 'test/test262/data': - Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + '0b1abd5ee70867311bea78e851bd609ad842011a', + Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + '9b4c6577f6fb8de977111dd196c6a941f948ac4e', 'third_party/android_platform': { 'url': Var('chromium_url') + '/chromium/src/third_party/android_platform.git' + '@' + 'eeb2d566f963bb66212fdc0d9bbe1dde550b4969', 'condition': 'checkout_android', @@ -230,19 +228,19 @@ deps = { 'dep_type': 'cipd', }, 'third_party/boringssl': { - 'url': Var('chromium_url') + '/chromium/src/third_party/boringssl.git' + '@' + '9ead20bdbf0ecc33219d25fd3a426876c54d126e', + 'url': Var('chromium_url') + '/chromium/src/third_party/boringssl.git' + '@' + 'fe087b52bb86cb87eaf1b0675a715e92aeec1d95', 'condition': "checkout_centipede_deps", }, 'third_party/boringssl/src': { - 'url': Var('boringssl_url') + '/boringssl.git' + '@' + '414f69504d30d0848b69f6453ea7fb5e88004cb4', + 'url': Var('boringssl_url') + '/boringssl.git' + '@' + '2fb5f9cb8feec2234952f6999af941ac48555710', 'condition': "checkout_centipede_deps", }, 'third_party/catapult': { - 'url': Var('chromium_url') + '/catapult.git' + '@' + '97c002a33e5b777eaa60e3ddc977a185f89446f7', + 'url': Var('chromium_url') + '/catapult.git' + '@' + '1bce0121e31e08811030f6f79c2f9a90801ff380', 'condition': 'checkout_android', }, 'third_party/clang-format/script': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/clang/tools/clang-format.git' + '@' + 'e5337933f2951cacd3aeacd238ce4578163ca0b9', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/clang/tools/clang-format.git' + '@' + '3c0acd2d4e73dd911309d9e970ba09d58bf23a62', 'third_party/colorama/src': { 'url': Var('chromium_url') + '/external/colorama.git' + '@' + '3de9f013df4b470069d03d250224062e8cf15c49', 'condition': 'checkout_android', @@ -252,11 +250,11 @@ deps = { 'condition': 'checkout_android', }, 'third_party/depot_tools': - Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + 'fe6a359a803f55829ede3666215d080f6775f173', + Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + '6708d95ec6d819098093cd57c746636a5bb9a4ea', 'third_party/fp16/src': Var('chromium_url') + '/external/github.com/Maratyszcza/FP16.git' + '@' + '0a92994d729ff76a58f692d3028ca1b64b145d91', 'third_party/fuchsia-gn-sdk': { - 'url': Var('chromium_url') + '/chromium/src/third_party/fuchsia-gn-sdk.git' + '@' + '727f65f8dae76c0d5c39c0f95d9d8f3a90de79f1', + 'url': Var('chromium_url') + '/chromium/src/third_party/fuchsia-gn-sdk.git' + '@' + '30fee7b68b3675e351fa47303c3b6ef322941ccd', 'condition': 'checkout_fuchsia', }, # Exists for rolling the Fuchsia SDK. Check out of the SDK should always @@ -278,15 +276,17 @@ deps = { 'url': Var('chromium_url') + '/external/github.com/google/benchmark.git' + '@' + '344117638c8ff7e239044fd0fa7085839fc03021', }, 'third_party/fuzztest': - Var('chromium_url') + '/chromium/src/third_party/fuzztest.git' + '@' + 'daea7ab861050a6445f59758f09cc3173f5add76', + Var('chromium_url') + '/chromium/src/third_party/fuzztest.git' + '@' + '7bf252c9e40463e2be936bd574d6d24a98c84f0e', 'third_party/fuzztest/src': - Var('chromium_url') + '/external/github.com/google/fuzztest.git' + '@' + 'bddcd9f77ba0a81a99ce50bcadf5149efe545df0', + Var('chromium_url') + '/external/github.com/google/fuzztest.git' + '@' + '34584108adea9bb274f71cee34fc091f89d7b2d5', 'third_party/googletest/src': - Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + 'b479e7a3c161d7087113a05f8cb034b870313a55', + Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + '33af80a883ddc33d9c0fac0a5b4578301efb18de', 'third_party/icu': - Var('chromium_url') + '/chromium/deps/icu.git' + '@' + 'a622de35ac311c5ad390a7af80724634e5dc61ed', - 'third_party/instrumented_libraries': - Var('chromium_url') + '/chromium/src/third_party/instrumented_libraries.git' + '@' + '0893d760101b3ddf9a2408b9d20f15ec2b80b2c1', + Var('chromium_url') + '/chromium/deps/icu.git' + '@' + '98f2494518c2dbb9c488e83e507b070ea5910e95', + 'third_party/instrumented_libs': { + 'url': Var('chromium_url') + '/chromium/third_party/instrumented_libraries.git' + '@' + '0172d67d98df2d30bd2241959d0e9569ada25abe', + 'condition': 'checkout_instrumented_libraries', + }, 'third_party/ittapi': { # Force checkout ittapi libraries to pass v8 header includes check on # bots that has check_v8_header_includes enabled. @@ -298,11 +298,11 @@ deps = { 'third_party/jsoncpp/source': Var('chromium_url') + '/external/github.com/open-source-parsers/jsoncpp.git'+ '@' + '42e892d96e47b1f6e29844cc705e148ec4856448', 'third_party/libc++/src': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxx.git' + '@' + '80307e66e74bae927fb8709a549859e777e3bf0b', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxx.git' + '@' + '852bc6746f45add53fec19f3a29280e69e358d44', 'third_party/libc++abi/src': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + 'fc6253a642c9e336480b17fb17771e2c1efc7fff', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + 'fc3fb0729ef1197d815bc6711f10640cc5cb9f2d', 'third_party/libunwind/src': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/libunwind.git' + '@' + '8bad7bd6ec30f94bce82f7cb5b58ecbd6ce02996', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libunwind.git' + '@' + '419b03c0b8f20d6da9ddcb0d661a94a97cdd7dad', 'third_party/logdog/logdog': Var('chromium_url') + '/infra/luci/luci-py/client/libs/logdog' + '@' + '0b2078a90f7a638d576b3a7c407d136f2fb62399', 'third_party/markupsafe': @@ -319,10 +319,10 @@ deps = { }, 'third_party/perfetto': Var('android_url') + '/platform/external/perfetto.git' + '@' + '6fc824d618d2f06b5d9cd8655ba0419b6b3b366e', - 'third_party/protobuf': - Var('chromium_url') + '/external/github.com/google/protobuf'+ '@' + '6a59a2ad1f61d9696092f79b6d74368b4d7970a3', + 'third_party/protobuf_chrome': + Var('chromium_url') + '/chromium/src/third_party/protobuf.git' + '@' + '4abbe88863a7dd75dd11da0487e9b995133f7592', 'third_party/re2/src': - Var('chromium_url') + '/external/github.com/google/re2.git' + '@' + '108914d28a79243d4300e7e651cd0a0d5883ca0f', + Var('chromium_url') + '/external/github.com/google/re2.git' + '@' + 'a67d6c1d5308b0950a91fed8e03e5c048d22d5cd', 'third_party/requests': { 'url': Var('chromium_url') + '/external/github.com/kennethreitz/requests.git' + '@' + 'c7e0fc087ceeadb8b4c84a0953a422c474093d6d', 'condition': 'checkout_android', @@ -338,9 +338,9 @@ deps = { 'condition': 'not build_with_chromium and host_cpu != "s390" and host_cpu != "ppc"', }, 'third_party/zlib': - Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + 'c5bf1b566e5df14e763507e2ce30cbfebefeeccf', + Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + '4f653ff1af93e9256c59a2c524795cd84c39c698', 'tools/clang': - Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + '1ed379eda880f53d895559815cd3e30b370abff5', + Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + 'aa1c946d23926fb574ad268bbcc638f0779cd444', 'tools/luci-go': { 'packages': [ { @@ -355,8 +355,10 @@ deps = { 'condition': 'host_cpu != "s390" and host_os != "aix"', 'dep_type': 'cipd', }, + 'tools/protoc_wrapper': + Var('chromium_url') + '/chromium/src/tools/protoc_wrapper.git' + '@' + 'dbcbea90c20ae1ece442d8ef64e61c7b10e2b013', 'third_party/abseil-cpp': { - 'url': Var('chromium_url') + '/chromium/src/third_party/abseil-cpp.git' + '@' + 'b3ae305fd5dbc6ad41eed9add26768c29181219f', + 'url': Var('chromium_url') + '/chromium/src/third_party/abseil-cpp.git' + '@' + 'f81f6c011baf9b0132a5594c034fe0060820711d', 'condition': 'not build_with_chromium', } } @@ -456,57 +458,6 @@ hooks = [ '-o', 'tools/clang/dsymutil/bin/dsymutil', ], }, - # Pull clang-format binaries using checked-in hashes. - { - 'name': 'clang_format_win', - 'pattern': '.', - 'condition': 'host_os == "win"', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-clang-format', - '-s', 'buildtools/win/clang-format.exe.sha1', - ], - }, - { - 'name': 'clang_format_mac_x64', - 'pattern': '.', - 'condition': 'host_os == "mac" and host_cpu == "x64"', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-clang-format', - '-s', 'buildtools/mac/clang-format.x64.sha1', - '-o', 'buildtools/mac/clang-format', - ], - }, - { - 'name': 'clang_format_mac_arm64', - 'pattern': '.', - 'condition': 'host_os == "mac" and host_cpu == "arm64"', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-clang-format', - '-s', 'buildtools/mac/clang-format.arm64.sha1', - '-o', 'buildtools/mac/clang-format', - ], - }, - { - 'name': 'clang_format_linux', - 'pattern': '.', - 'condition': 'host_os == "linux"', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-clang-format', - '-s', 'buildtools/linux64/clang-format.sha1', - ], - }, { 'name': 'gcmole', 'pattern': '.', @@ -555,58 +506,6 @@ hooks = [ '-s', 'test/wasm-js/tests.tar.gz.sha1', ], }, - { - 'name': 'sysroot_arm', - 'pattern': '.', - 'condition': '(checkout_linux and checkout_arm)', - 'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py', - '--arch=arm'], - }, - { - 'name': 'sysroot_arm64', - 'pattern': '.', - 'condition': '(checkout_linux and checkout_arm64)', - 'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py', - '--arch=arm64'], - }, - { - 'name': 'sysroot_x86', - 'pattern': '.', - 'condition': '(checkout_linux and (checkout_x86 or checkout_x64))', - 'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py', - '--arch=x86'], - }, - { - 'name': 'sysroot_x64', - 'pattern': '.', - 'condition': 'checkout_linux and checkout_x64', - 'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py', - '--arch=x64'], - }, - { - 'name': 'msan_chained_origins_focal', - 'pattern': '.', - 'condition': 'checkout_instrumented_libraries', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-instrumented-libraries', - '-s', 'third_party/instrumented_libraries/binaries/msan-chained-origins-focal.tgz.sha1', - ], - }, - { - 'name': 'msan_no_origins_focal', - 'pattern': '.', - 'condition': 'checkout_instrumented_libraries', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-instrumented-libraries', - '-s', 'third_party/instrumented_libraries/binaries/msan-no-origins-focal.tgz.sha1', - ], - }, { # Case-insensitivity for the Win SDK. Must run before win_toolchain below. 'name': 'ciopfs_linux', @@ -718,6 +617,7 @@ hooks = [ 'python3', 'tools/builtins-pgo/download_profiles.py', 'download', + '--quiet', ], }, { @@ -773,3 +673,9 @@ hooks = [ ], }, ] + +recursedeps = [ + 'build', + 'buildtools', + 'third_party/instrumented_libs', +] diff --git a/deps/v8/WATCHLISTS b/deps/v8/WATCHLISTS index d853a0de2a2..4558b82518e 100644 --- a/deps/v8/WATCHLISTS +++ b/deps/v8/WATCHLISTS @@ -104,9 +104,6 @@ 'trap-handler': { 'filepath': 'src/trap-handler/', }, - 'tests': { - 'filepath': 'test/', - }, }, 'WATCHLISTS': { @@ -180,8 +177,5 @@ 'mark@chromium.org', 'mseaborn@chromium.org', ], - 'tests': [ - 'almuthanna+watch@chromium.org', - ], }, } diff --git a/deps/v8/WORKSPACE b/deps/v8/WORKSPACE index 96ef24384ed..8692e456b9a 100644 --- a/deps/v8/WORKSPACE +++ b/deps/v8/WORKSPACE @@ -70,17 +70,6 @@ bind( actual = "@com_googlesource_chromium_icu//:icu", ) -new_local_repository( - name = "com_googlesource_chromium_base_trace_event_common", - build_file = "//:bazel/BUILD.trace_event_common", - path = "base/trace_event/common", -) - -bind( - name = "base_trace_event_common", - actual = "@com_googlesource_chromium_base_trace_event_common//:trace_event_common", -) - http_archive( name = "intel_ittapi", add_prefix = "third_party/ittapi", diff --git a/deps/v8/bazel/BUILD.trace_event_common b/deps/v8/bazel/BUILD.trace_event_common deleted file mode 100644 index 685b2840719..00000000000 --- a/deps/v8/bazel/BUILD.trace_event_common +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2021 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cc_library( - name = "trace_event_common", - hdrs = ["trace_event_common.h"], - include_prefix = "base/trace_event/common", - visibility = ["//visibility:public"], -) diff --git a/deps/v8/bazel/config/BUILD.bazel b/deps/v8/bazel/config/BUILD.bazel index 67454fa90ee..c81f2782031 100644 --- a/deps/v8/bazel/config/BUILD.bazel +++ b/deps/v8/bazel/config/BUILD.bazel @@ -201,14 +201,6 @@ selects.config_setting_group( ] ) -selects.config_setting_group( - name = "is_non_android_posix", - match_any = [ - ":is_linux", - ":is_macos", - ], -) - selects.config_setting_group( name = "is_posix_x64", match_all = [ @@ -217,14 +209,6 @@ selects.config_setting_group( ], ) -selects.config_setting_group( - name = "is_non_android_posix_x64", - match_all = [ - ":is_non_android_posix", - ":is_x64", - ], -) - selects.config_setting_group( name = "is_inline_asm_x64", match_all = [ @@ -305,14 +289,6 @@ selects.config_setting_group( ], ) -selects.config_setting_group( - name = "is_macos_arm64", - match_all = [ - ":is_macos", - ":is_arm64", - ], -) - config_setting( name = "is_compiler_default", flag_values = { diff --git a/deps/v8/bazel/defs.bzl b/deps/v8/bazel/defs.bzl index f23f48ef03a..e142a3e7e8d 100644 --- a/deps/v8/bazel/defs.bzl +++ b/deps/v8/bazel/defs.bzl @@ -109,7 +109,8 @@ def _default_args(): "-Werror", "-Wextra", "-Wno-unneeded-internal-declaration", - "-Wno-unknown-warning-option", + "-Wno-unknown-warning-option", # b/330781959 + "-Wno-cast-function-type-mismatch", # b/330781959 "-Wno-bitwise-instead-of-logical", "-Wno-builtin-assume-aligned-alignment", "-Wno-unused-parameter", @@ -560,6 +561,7 @@ def build_config_content(cpu, icu): ("js_shared_memory", "false"), ("lite_mode", "false"), ("local_off_stack_check", "false"), + ("memory_corruption_api", "false"), ("mips_arch_variant", '""'), ("mips_use_msa", "false"), ("msan", "false"), @@ -589,8 +591,8 @@ def build_config_content(cpu, icu): # TODO(victorgomes): Create a rule (instead of a macro), that can # dynamically populate the build config. -def v8_build_config(name): - cpu = _quote("x64") +def v8_build_config(name, arch): + cpu = '"' + arch + '"' native.genrule( name = "noicu/" + name, outs = ["noicu/" + name + ".json"], diff --git a/deps/v8/bazel/v8-non-pointer-compression.bzl b/deps/v8/bazel/v8-non-pointer-compression.bzl index a9f73728301..8c929454840 100644 --- a/deps/v8/bazel/v8-non-pointer-compression.bzl +++ b/deps/v8/bazel/v8-non-pointer-compression.bzl @@ -3,7 +3,7 @@ Exposes the rule v8_binary_non_pointer_compression, which forces a label to be compiled without pointer compression. """ -def _v8_disable_pointer_compression(): +def _v8_disable_pointer_compression(settings, attr): return { "//:v8_enable_pointer_compression": "False", } diff --git a/deps/v8/build_overrides/build.gni b/deps/v8/build_overrides/build.gni index 32896733f83..0a1fc3c46d2 100644 --- a/deps/v8/build_overrides/build.gni +++ b/deps/v8/build_overrides/build.gni @@ -17,11 +17,14 @@ build_with_node = false # chromium build. perfetto_build_with_embedder = true -# When embedding perfetto, its build files need to know in which BUILD.gn file -# the embedder (v8) declared the protobuf targets. In the v8 case they are -# declared in the root v8/BUILD.gn. -perfetto_protobuf_target_prefix = "//" -perfetto_protobuf_gni = "//gni/proto_library.gni" +# TODO(https://crbug.com/337736622): Perfetto and FuzzTest need to know the +# path to protobuf targets. V8 stores them in a different location than Chrome +# until M129. Thereafter, it can move to //third_party/protobuf and these +# variables can be removed. +protobuf_target_prefix = "//third_party/protobuf_chrome/" +perfetto_protobuf_target_prefix = protobuf_target_prefix +perfetto_protobuf_gni = "//third_party/protobuf_chrome/proto_library.gni" +perfetto_protobuf_src_dir = "//third_party/protobuf_chrome/src" # We use Perfetto's Trace Processor to convert traces to the legacy JSON # format. diff --git a/deps/v8/gni/proto_library.gni b/deps/v8/gni/proto_library.gni deleted file mode 100644 index a8690999f97..00000000000 --- a/deps/v8/gni/proto_library.gni +++ /dev/null @@ -1,282 +0,0 @@ -# Copyright 2019 the V8 project 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_overrides/build.gni") - -# This file should not be pulled in chromium builds. -assert(!build_with_chromium) - -if (host_os == "win") { - _host_executable_suffix = ".exe" -} else { - _host_executable_suffix = "" -} - -template("proto_library") { - assert(defined(invoker.sources)) - proto_sources = invoker.sources - - # All the proto imports should be relative to the project root. - proto_in_dir = "//" - if (defined(invoker.proto_in_dir)) { - proto_in_dir = invoker.proto_in_dir - } - assert(defined(invoker.proto_out_dir), - "proto_out_dir must be explicitly defined") - proto_out_dir = invoker.proto_out_dir - - # We don't support generate_python in the standalone build, but still must - # check that the caller sets this to false. This is because when building in - # the chromium tree, chromium's proto_library.gni in chrome (!= this) defaults - # generate_python = true. - assert(defined(invoker.generate_python) && !invoker.generate_python) - - import_dirs = [] - if (defined(invoker.import_dirs)) { - import_dirs = invoker.import_dirs - } - - # If false will not generate the default .pb.{cc,h} files. Used for custom - # codegen plugins. - generate_cc = true - if (defined(invoker.generate_cc)) { - generate_cc = invoker.generate_cc - } - - generate_descriptor = "" - if (defined(invoker.generate_descriptor)) { - generate_descriptor = invoker.generate_descriptor - } - - if (defined(invoker.generator_plugin_label)) { - plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)" - plugin_path = - get_label_info(plugin_host_label, "root_out_dir") + "/" + - get_label_info(plugin_host_label, "name") + _host_executable_suffix - generate_with_plugin = true - } else if (defined(invoker.generator_plugin_script)) { - plugin_path = invoker.generator_plugin_script - generate_with_plugin = true - } else { - generate_with_plugin = false - } - - if (generate_with_plugin) { - if (defined(invoker.generator_plugin_suffix)) { - generator_plugin_suffixes = [ - "${invoker.generator_plugin_suffix}.h", - "${invoker.generator_plugin_suffix}.cc", - ] - } else { - generator_plugin_suffixes = invoker.generator_plugin_suffixes - } - } - - out_dir = "$root_gen_dir/" + proto_out_dir - rel_out_dir = rebase_path(out_dir, root_build_dir) - - # exclude_imports is only used for generating the descriptor. Therefore, the - # check needs to be here to avoid complaints from GN about the unused - # variable. - if (generate_descriptor != "") { - if (defined(invoker.exclude_imports)) { - exclude_imports = invoker.exclude_imports - } else { - exclude_imports = false - } - } - - # Prevent unused errors when generating descriptor only. - if (generate_descriptor != "") { - not_needed([ "rel_out_dir" ]) - } - - protos = rebase_path(proto_sources, proto_in_dir) - protogens = [] - - if (generate_descriptor != "") { - protogens += [ "$out_dir/${generate_descriptor}" ] - } - - foreach(proto, protos) { - proto_dir = get_path_info(proto, "dir") - proto_name = get_path_info(proto, "name") - proto_path = proto_dir + "/" + proto_name - - # Prevent unused errors when generating descriptor only. - if (generate_descriptor != "") { - not_needed([ "proto_path" ]) - } - - if (generate_cc) { - protogens += [ - "$out_dir/$proto_path.pb.h", - "$out_dir/$proto_path.pb.cc", - ] - } - if (generate_with_plugin) { - foreach(suffix, generator_plugin_suffixes) { - protogens += [ "$out_dir/${proto_path}${suffix}" ] - } - } - } - - config_name = "${target_name}_config" - if (generate_descriptor == "") { - action_name = "${target_name}_gen" - source_set_name = target_name - } else { - action_name = target_name - } - - config(config_name) { - include_dirs = [ out_dir ] - } - - # The XXX_gen action that generates the .pb.{cc,h} files. - action(action_name) { - if (generate_descriptor == "") { - visibility = [ ":$source_set_name" ] - } - sources = proto_sources - outputs = get_path_info(protogens, "abspath") - - protoc_label = "//:protoc($host_toolchain)" - protoc_path = get_label_info(protoc_label, "root_out_dir") + "/protoc" + - _host_executable_suffix - protoc_rebased_path = "./" + rebase_path(protoc_path, root_build_dir) - script = "//gni/protoc.py" - args = [ - # Path should be rebased because |root_build_dir| for current toolchain - # may be different from |root_out_dir| of protoc built on host toolchain. - protoc_rebased_path, - "--proto_path", - rebase_path(proto_in_dir, root_build_dir), - ] - - foreach(path, import_dirs) { - args += [ - "--proto_path", - rebase_path(path, root_build_dir), - ] - } - - if (generate_cc) { - cc_generator_options_ = "" - if (defined(invoker.cc_generator_options)) { - cc_generator_options_ = invoker.cc_generator_options - } - args += [ - "--cpp_out", - cc_generator_options_ + rel_out_dir, - ] - } - if (generate_descriptor != "") { - depfile = "$out_dir/$generate_descriptor.d" - if (!exclude_imports) { - args += [ "--include_imports" ] - } - args += [ - "--descriptor_set_out", - rebase_path("$out_dir/$generate_descriptor", root_build_dir), - "--dependency_out", - rebase_path(depfile, root_build_dir), - ] - } - - if (generate_with_plugin) { - plugin_path_rebased = rebase_path(plugin_path, root_build_dir) - plugin_out_args = "" - if (defined(invoker.generator_plugin_options)) { - plugin_out_args += invoker.generator_plugin_options - } - plugin_out_args += ":$rel_out_dir" - - args += [ - "--plugin=protoc-gen-plugin=$plugin_path_rebased", - "--plugin_out=$plugin_out_args", - ] - } - - args += rebase_path(proto_sources, root_build_dir) - - inputs = [ protoc_path ] - deps = [ protoc_label ] - - # TODO(hjd): Avoid adding to deps here this. - # When we generate BUILD files we need find the transitive proto, - # dependencies, so also add link_deps to actual deps so they show up - # in gn desc. - if (defined(invoker.link_deps)) { - deps += invoker.link_deps - } - if (generate_with_plugin) { - inputs += [ plugin_path ] - if (defined(plugin_host_label)) { - # Action depends on native generator plugin but for host toolchain only. - deps += [ plugin_host_label ] - } - } - - if (defined(invoker.deps)) { - deps += invoker.deps - } - } # action(action_name) - - # The source_set that builds the generated .pb.cc files. - if (generate_descriptor == "") { - source_set(source_set_name) { - forward_variables_from(invoker, - [ - "defines", - "include_dirs", - "public_configs", - "testonly", - "visibility", - ]) - - sources = get_target_outputs(":$action_name") - - if (defined(invoker.extra_configs)) { - configs += invoker.extra_configs - } - - if (!defined(invoker.public_configs)) { - public_configs = [] - } - - public_configs += [ - "//:protobuf_gen_config", - ":$config_name", - ] - - # By default, propagate the config for |include_dirs| to dependent - # targets, so that public imports can be resolved to corresponding header - # files. In some cases, the embedder target handles include directory - # propagation itself, e.g. via a common config. - propagate_imports_configs = !defined(invoker.propagate_imports_configs) || - invoker.propagate_imports_configs - if (propagate_imports_configs) { - public_configs += [ ":$config_name" ] - } else { - configs += [ ":$config_name" ] - } - - # Use protobuf_full only for tests. - if (defined(invoker.use_protobuf_full) && - invoker.use_protobuf_full == true) { - deps = [ "//:protobuf_full" ] - } else if (generate_cc) { - deps = [ "//:protobuf_lite" ] - } else { - deps = [] - } - - deps += [ ":$action_name" ] - if (defined(invoker.deps)) { - deps += invoker.deps - } - } # source_set(source_set_name) - } -} # template diff --git a/deps/v8/gni/protoc.py b/deps/v8/gni/protoc.py deleted file mode 100755 index d529d1c65a5..00000000000 --- a/deps/v8/gni/protoc.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2021 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -"""Script to wrap protoc execution. - -This script exists to work-around the bad depfile generation by protoc when -generating descriptors.""" - -from __future__ import print_function -import argparse -import os -import sys -import subprocess -import tempfile -import uuid - -from codecs import open - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('--descriptor_set_out', default=None) - parser.add_argument('--dependency_out', default=None) - parser.add_argument('protoc') - args, remaining = parser.parse_known_args() - - if args.dependency_out and args.descriptor_set_out: - tmp_path = os.path.join(tempfile.gettempdir(), str(uuid.uuid4())) - custom = [ - '--descriptor_set_out', args.descriptor_set_out, '--dependency_out', - tmp_path - ] - try: - cmd = [args.protoc] + custom + remaining - subprocess.check_call(cmd) - with open(tmp_path, 'rb') as tmp_rd: - dependency_data = tmp_rd.read().decode('utf-8') - finally: - if os.path.exists(tmp_path): - os.unlink(tmp_path) - - with open(args.dependency_out, 'w', encoding='utf-8') as f: - f.write(args.descriptor_set_out + ":") - f.write(dependency_data) - else: - subprocess.check_call(sys.argv[1:]) - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/deps/v8/gni/release_branch_toggle.gni b/deps/v8/gni/release_branch_toggle.gni index da60c2433bc..a595b85ef9c 100644 --- a/deps/v8/gni/release_branch_toggle.gni +++ b/deps/v8/gni/release_branch_toggle.gni @@ -6,5 +6,5 @@ declare_args() { # TODO(liviurau): Remove old name after Chromium config update # https://crbug.com/1476977. is_on_release_branch = false - v8_is_on_release_branch = true + v8_is_on_release_branch = false } \ No newline at end of file diff --git a/deps/v8/gni/v8.gni b/deps/v8/gni/v8.gni index 7c4e3ba5c34..134890d7104 100644 --- a/deps/v8/gni/v8.gni +++ b/deps/v8/gni/v8.gni @@ -6,6 +6,7 @@ import("//build/config/chrome_build.gni") import("//build/config/compiler/pgo/pgo.gni") import("//build/config/gclient_args.gni") import("//build/config/ios/config.gni") +import("//build/config/ios/ios_sdk_overrides.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/config/v8_target_cpu.gni") import("//build_overrides/build.gni") @@ -70,6 +71,14 @@ declare_args() { # Sets -DV8_LITE_MODE. v8_enable_lite_mode = false + # iOS executable code pages is in 17.4 SDK. We + # use target_os == "ios" here because it isn't equivalent + # to is_ios (is_ios is based on host_os). + if (target_os == "ios") { + # TODO(dtapuska): Change this to an assert. + v8_enable_lite_mode = ios_deployment_target != "17.4" + } + # Enable the Turbofan compiler. # Sets -dV8_ENABLE_TURBOFAN. v8_enable_turbofan = "" @@ -147,11 +156,6 @@ declare_args() { # TODO: macros for determining endian type are clang specific. v8_use_libm_trig_functions = is_clang - # iOS device does not support executable code pages. Not we - # use target_os == "ios" here because it isn't equivalent - # to is_ios (is_ios is based on host_os). - target_is_ios_device = target_os == "ios" && target_environment == "device" - # Location of icu. v8_icu_path = "//third_party/icu" @@ -176,9 +180,9 @@ if (v8_enable_backtrace == "") { v8_enable_backtrace = is_debug && !v8_optimized_debug } -# If chromium is configured to use the perfetto client library, v8 should also +# Chromium is configured to use the perfetto client library, v8 should also # use perfetto for tracing. -if (build_with_chromium && use_perfetto_client_library) { +if (build_with_chromium) { v8_use_perfetto = true } @@ -196,18 +200,14 @@ if (v8_enable_builtins_optimization == "") { # v8_jitless. # WebAssembly is enabled by default, except in lite mode. if (v8_enable_webassembly == "") { - # iOS (non-simulator) does not have executable pages for 3rd party - # applications yet so disable webassembly. - v8_enable_webassembly = !v8_enable_lite_mode && !target_is_ios_device + v8_enable_webassembly = !v8_enable_lite_mode } assert(!(v8_enable_webassembly && v8_enable_lite_mode), "Webassembly is not available in lite mode.") # Turbofan is enabled by default, except in lite mode. if (v8_enable_turbofan == "") { - # iOS (non-simulator) does not have executable pages for 3rd party - # applications yet so disable turbofan. - v8_enable_turbofan = !v8_enable_lite_mode && !target_is_ios_device + v8_enable_turbofan = !v8_enable_lite_mode } assert(v8_enable_turbofan || !v8_enable_webassembly, "Webassembly is not available when Turbofan is disabled.") diff --git a/deps/v8/include/cppgc/allocation.h b/deps/v8/include/cppgc/allocation.h index 69883fb34d1..cdd3fd48f1f 100644 --- a/deps/v8/include/cppgc/allocation.h +++ b/deps/v8/include/cppgc/allocation.h @@ -47,7 +47,7 @@ namespace internal { // Similar to C++17 std::align_val_t; enum class AlignVal : size_t {}; -class V8_EXPORT MakeGarbageCollectedTraitInternal { +class MakeGarbageCollectedTraitInternal { protected: static inline void MarkObjectAsFullyConstructed(const void* payload) { // See api_constants for an explanation of the constants. @@ -121,16 +121,15 @@ class V8_EXPORT MakeGarbageCollectedTraitInternal { }; private: - static void* CPPGC_DEFAULT_ALIGNED Allocate(cppgc::AllocationHandle&, size_t, - GCInfoIndex); - static void* CPPGC_DOUBLE_WORD_ALIGNED Allocate(cppgc::AllocationHandle&, - size_t, AlignVal, - GCInfoIndex); - static void* CPPGC_DEFAULT_ALIGNED Allocate(cppgc::AllocationHandle&, size_t, - GCInfoIndex, CustomSpaceIndex); - static void* CPPGC_DOUBLE_WORD_ALIGNED Allocate(cppgc::AllocationHandle&, - size_t, AlignVal, GCInfoIndex, - CustomSpaceIndex); + V8_EXPORT static void* CPPGC_DEFAULT_ALIGNED + Allocate(cppgc::AllocationHandle&, size_t, GCInfoIndex); + V8_EXPORT static void* CPPGC_DOUBLE_WORD_ALIGNED + Allocate(cppgc::AllocationHandle&, size_t, AlignVal, GCInfoIndex); + V8_EXPORT static void* CPPGC_DEFAULT_ALIGNED + Allocate(cppgc::AllocationHandle&, size_t, GCInfoIndex, CustomSpaceIndex); + V8_EXPORT static void* CPPGC_DOUBLE_WORD_ALIGNED + Allocate(cppgc::AllocationHandle&, size_t, AlignVal, GCInfoIndex, + CustomSpaceIndex); friend class HeapObjectHeader; }; diff --git a/deps/v8/include/cppgc/internal/member-storage.h b/deps/v8/include/cppgc/internal/member-storage.h index 61b255ba637..2b5bfec4ed5 100644 --- a/deps/v8/include/cppgc/internal/member-storage.h +++ b/deps/v8/include/cppgc/internal/member-storage.h @@ -158,6 +158,12 @@ class V8_TRIVIAL_ABI CompressedPointer final { static V8_INLINE void* Decompress(IntegralType ptr) { CPPGC_DCHECK(CageBaseGlobal::IsSet()); const uintptr_t base = CageBaseGlobal::Get(); + return Decompress(ptr, base); + } + + static V8_INLINE void* Decompress(IntegralType ptr, uintptr_t base) { + CPPGC_DCHECK(CageBaseGlobal::IsSet()); + CPPGC_DCHECK(base == CageBaseGlobal::Get()); // Treat compressed pointer as signed and cast it to uint64_t, which will // sign-extend it. #if defined(CPPGC_2GB_CAGE) diff --git a/deps/v8/include/v8-array-buffer.h b/deps/v8/include/v8-array-buffer.h index ea6f5b5571a..d625b85496b 100644 --- a/deps/v8/include/v8-array-buffer.h +++ b/deps/v8/include/v8-array-buffer.h @@ -87,6 +87,9 @@ class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase { * Assumes that the backing_store was allocated by the ArrayBuffer allocator * of the given isolate. */ + V8_DEPRECATED( + "Reallocate is unsafe, please do not use. Please allocate a new " + "BackingStore and copy instead.") static std::unique_ptr Reallocate( v8::Isolate* isolate, std::unique_ptr backing_store, size_t byte_length); @@ -179,6 +182,9 @@ class V8_EXPORT ArrayBuffer : public Object { * * The default implementation allocates a new block and copies data. */ + V8_DEPRECATED( + "Reallocate is unsafe, please do not use. Please allocate new memory " + "and copy instead.") virtual void* Reallocate(void* data, size_t old_length, size_t new_length); /** @@ -287,7 +293,7 @@ class V8_EXPORT ArrayBuffer : public Object { * preventing JavaScript from ever accessing underlying backing store. * ArrayBuffer should have been externalized and must be detachable. */ - V8_DEPRECATE_SOON( + V8_DEPRECATED( "Use the version which takes a key parameter (passing a null handle is " "ok).") void Detach(); diff --git a/deps/v8/include/v8-callbacks.h b/deps/v8/include/v8-callbacks.h index 4f5e716f814..23ca5506e57 100644 --- a/deps/v8/include/v8-callbacks.h +++ b/deps/v8/include/v8-callbacks.h @@ -152,9 +152,6 @@ using JitCodeEventHandler = void (*)(const JitCodeEvent* event); enum GCType { kGCTypeScavenge = 1 << 0, kGCTypeMinorMarkSweep = 1 << 1, - kGCTypeMinorMarkCompact V8_DEPRECATE_SOON( - "Use kGCTypeMinorMarkSweep instead of kGCTypeMinorMarkCompact.") = - kGCTypeMinorMarkSweep, kGCTypeMarkSweepCompact = 1 << 2, kGCTypeIncrementalMarking = 1 << 3, kGCTypeProcessWeakCallbacks = 1 << 4, diff --git a/deps/v8/include/v8-context.h b/deps/v8/include/v8-context.h index 4849c925806..f432ff67f70 100644 --- a/deps/v8/include/v8-context.h +++ b/deps/v8/include/v8-context.h @@ -107,6 +107,10 @@ class V8_EXPORT Context : public Data { * configured if the default context snapshot contains no pointer embedder * data, or if no custom startup snapshot is configured in the * v8::CreateParams used to create the isolate. + * + * \param api_wrapper_deserializer An optional callback used to deserialize + * API wrapper objects that was initially set with v8::Object::Wrap() and then + * serialized using SerializeAPIWrapperCallback. */ static Local New( Isolate* isolate, ExtensionConfiguration* extensions = nullptr, @@ -116,17 +120,19 @@ class V8_EXPORT Context : public Data { DeserializeInternalFieldsCallback(), MicrotaskQueue* microtask_queue = nullptr, DeserializeContextDataCallback context_data_deserializer = - DeserializeContextDataCallback()); + DeserializeContextDataCallback(), + DeserializeAPIWrapperCallback api_wrapper_deserializer = + DeserializeAPIWrapperCallback()); /** * Create a new context from a (non-default) context snapshot. There * is no way to provide a global object template since we do not create * a new global object from template, but we can reuse a global object. * - * \param isolate See v8::Context::New. + * \param isolate See v8::Context::New(). * * \param context_snapshot_index The index of the context snapshot to - * deserialize from. Use v8::Context::New for the default snapshot. + * deserialize from. Use v8::Context::New() for the default snapshot. * * \param internal_fields_deserializer An optional callback used * to deserialize fields set by @@ -136,19 +142,23 @@ class V8_EXPORT Context : public Data { * pointer fields in the default context snapshot or if no startup * snapshot is configured when the isolate is created. * - * \param extensions See v8::Context::New. + * \param extensions See v8::Context::New(). * - * \param global_object See v8::Context::New. + * \param global_object See v8::Context::New(). * * \param internal_fields_deserializer Similar to - * internal_fields_deserializer in v8::Context::New but applies to + * internal_fields_deserializer in v8::Context::New() but applies to * the context specified by the context_snapshot_index. * - * \param microtask_queue See v8::Context::New. + * \param microtask_queue See v8::Context::New(). * * \param context_data_deserializer Similar to - * context_data_deserializer in v8::Context::New but applies to + * context_data_deserializer in v8::Context::New() but applies to * the context specified by the context_snapshot_index. + * + *\param api_wrapper_deserializer Similar to api_wrapper_deserializer in + * v8::Context::New() but applies to the context specified by the + * context_snapshot_index. */ static MaybeLocal FromSnapshot( Isolate* isolate, size_t context_snapshot_index, @@ -158,7 +168,9 @@ class V8_EXPORT Context : public Data { MaybeLocal global_object = MaybeLocal(), MicrotaskQueue* microtask_queue = nullptr, DeserializeContextDataCallback context_data_deserializer = - DeserializeContextDataCallback()); + DeserializeContextDataCallback(), + DeserializeAPIWrapperCallback api_wrapper_deserializer = + DeserializeAPIWrapperCallback()); /** * Returns an global object that isn't backed by an actual context. @@ -290,6 +302,8 @@ class V8_EXPORT Context : public Data { * SetAlignedPointerInEmbedderData with the same index. Note that index 0 * currently has a special meaning for Chrome's debugger. */ + V8_INLINE void* GetAlignedPointerFromEmbedderData(Isolate* isolate, + int index); V8_INLINE void* GetAlignedPointerFromEmbedderData(int index); /** @@ -444,6 +458,24 @@ Local Context::GetEmbedderData(int index) { #endif } +void* Context::GetAlignedPointerFromEmbedderData(Isolate* isolate, int index) { +#if !defined(V8_ENABLE_CHECKS) + using A = internal::Address; + using I = internal::Internals; + A ctx = internal::ValueHelper::ValueAsAddress(this); + A embedder_data = + I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset); + int value_offset = I::kEmbedderDataArrayHeaderSize + + (I::kEmbedderDataSlotSize * index) + + I::kEmbedderDataSlotExternalPointerOffset; + return reinterpret_cast( + I::ReadExternalPointerField( + isolate, embedder_data, value_offset)); +#else + return SlowGetAlignedPointerFromEmbedderData(index); +#endif +} + void* Context::GetAlignedPointerFromEmbedderData(int index) { #if !defined(V8_ENABLE_CHECKS) using A = internal::Address; diff --git a/deps/v8/include/v8-cppgc.h b/deps/v8/include/v8-cppgc.h index e0d76f45016..ef7f6322f72 100644 --- a/deps/v8/include/v8-cppgc.h +++ b/deps/v8/include/v8-cppgc.h @@ -46,10 +46,14 @@ struct WrapperDescriptor final { /** * Unknown embedder id. The value is reserved for internal usages and must not - * be used with `CppHeap`. + * be used with `CppHeap`. The value is considered as not traceable. */ static constexpr uint16_t kUnknownEmbedderId = UINT16_MAX; + V8_DEPRECATED("WrapperDescriptor is deprecated, see crbug.com/338411141.") + constexpr WrapperDescriptor() = default; + + V8_DEPRECATED("WrapperDescriptor is deprecated, see crbug.com/338411141.") constexpr WrapperDescriptor(InternalFieldIndex wrappable_type_index, InternalFieldIndex wrappable_instance_index, uint16_t embedder_id_for_garbage_collected) @@ -60,12 +64,12 @@ struct WrapperDescriptor final { /** * Index of the wrappable type. */ - InternalFieldIndex wrappable_type_index; + InternalFieldIndex wrappable_type_index = -1; /** * Index of the wrappable instance. */ - InternalFieldIndex wrappable_instance_index; + InternalFieldIndex wrappable_instance_index = -1; /** * Embedder id identifying instances of garbage-collected objects. It is @@ -73,10 +77,17 @@ struct WrapperDescriptor final { * the id. Only references to instances of wrappables types with an id of * `embedder_id_for_garbage_collected` will be considered by CppHeap. */ - uint16_t embedder_id_for_garbage_collected; + uint16_t embedder_id_for_garbage_collected = kUnknownEmbedderId; }; struct V8_EXPORT CppHeapCreateParams { + START_ALLOW_USE_DEPRECATED() + explicit CppHeapCreateParams( + std::vector> custom_spaces) + : custom_spaces(std::move(custom_spaces)) {} + END_ALLOW_USE_DEPRECATED() + + V8_DEPRECATED("WrapperDescriptor is deprecated, see crbug.com/338411141.") CppHeapCreateParams( std::vector> custom_spaces, WrapperDescriptor wrapper_descriptor) @@ -180,6 +191,7 @@ class V8_EXPORT CppHeap { /** * \returns the wrapper descriptor of this CppHeap. */ + V8_DEPRECATED("WrapperDescriptor is deprecated, see crbug.com/338411141.") v8::WrapperDescriptor wrapper_descriptor() const; private: diff --git a/deps/v8/include/v8-date.h b/deps/v8/include/v8-date.h index 8d82ccc9ea6..5c3cbd91c75 100644 --- a/deps/v8/include/v8-date.h +++ b/deps/v8/include/v8-date.h @@ -21,6 +21,10 @@ class V8_EXPORT Date : public Object { static V8_WARN_UNUSED_RESULT MaybeLocal New(Local context, double time); + static V8_WARN_UNUSED_RESULT MaybeLocal Parse( + Local context, + Local date_string); + /** * A specialization of Value::NumberValue that is more efficient * because we know the structure of this object. @@ -32,6 +36,11 @@ class V8_EXPORT Date : public Object { */ v8::Local ToISOString() const; + /** + * Generates UTC string representation. + */ + v8::Local ToUTCString() const; + V8_INLINE static Date* Cast(Value* value) { #ifdef V8_ENABLE_CHECKS CheckCast(value); diff --git a/deps/v8/include/v8-embedder-heap.h b/deps/v8/include/v8-embedder-heap.h index 236e1c1e943..7ba13ad2c1e 100644 --- a/deps/v8/include/v8-embedder-heap.h +++ b/deps/v8/include/v8-embedder-heap.h @@ -29,6 +29,8 @@ class V8_EXPORT EmbedderRootsHandler { virtual ~EmbedderRootsHandler() = default; EmbedderRootsHandler() = default; + + V8_DEPRECATE_SOON("Use the default constructor instead.") explicit EmbedderRootsHandler(RootHandling default_traced_reference_handling) : default_traced_reference_handling_(default_traced_reference_handling) {} @@ -47,6 +49,7 @@ class V8_EXPORT EmbedderRootsHandler { * * The concrete implementations must be thread-safe. */ + V8_DEPRECATE_SOON("Use TracedReferenceHandling::kDroppable instead.") virtual bool IsRoot(const v8::TracedReference& handle) = 0; /** diff --git a/deps/v8/include/v8-exception.h b/deps/v8/include/v8-exception.h index 86f8b3a4baf..fa21896fbbc 100644 --- a/deps/v8/include/v8-exception.h +++ b/deps/v8/include/v8-exception.h @@ -8,6 +8,7 @@ #include #include "v8-local-handle.h" // NOLINT(build/include_directory) +#include "v8-object.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) namespace v8 { @@ -58,6 +59,13 @@ class V8_EXPORT Exception { * of a given exception, or an empty handle if not available. */ static Local GetStackTrace(Local exception); + + /** + * Captures the current stack trace and attaches it to the given object in the + * form of `stack` property. + */ + static Maybe CaptureStackTrace(Local context, + Local object); }; /** diff --git a/deps/v8/include/v8-function-callback.h b/deps/v8/include/v8-function-callback.h index 86a3ea72f40..f4d2f2f1ec1 100644 --- a/deps/v8/include/v8-function-callback.h +++ b/deps/v8/include/v8-function-callback.h @@ -8,6 +8,7 @@ #include #include +#include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-primitive.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) @@ -38,7 +39,7 @@ class ReturnValue { V8_INLINE ReturnValue(const ReturnValue& that) : value_(that.value_) { static_assert(std::is_base_of::value, "type check"); } - // Local setters + // Handle-based setters. template V8_INLINE void Set(const Global& handle); template @@ -51,12 +52,15 @@ class ReturnValue { V8_INLINE void Set(const Local handle); template V8_INLINE void SetNonEmpty(const Local handle); - // Fast primitive setters + // Fast primitive number setters. V8_INLINE void Set(bool value); V8_INLINE void Set(double i); + V8_INLINE void Set(int16_t i); V8_INLINE void Set(int32_t i); + V8_INLINE void Set(int64_t i); + V8_INLINE void Set(uint16_t i); V8_INLINE void Set(uint32_t i); - V8_INLINE void Set(uint16_t); + V8_INLINE void Set(uint64_t i); // Fast JS primitive setters V8_INLINE void SetNull(); V8_INLINE void SetUndefined(); @@ -127,6 +131,12 @@ class FunctionCallbackInfo { * referencing this callback was found (which in V8 internally is often * referred to as holder [sic]). */ + V8_DEPRECATE_SOON( + "V8 will stop providing access to hidden prototype (i.e. " + "JSGlobalObject). Use This() instead. \n" + "DO NOT try to workaround this by accessing JSGlobalObject via " + "v8::Object::GetPrototype() - it'll be deprecated soon too. \n" + "See http://crbug.com/333672197. ") V8_INLINE Local Holder() const; /** For construct calls, this returns the "new.target" value. */ V8_INLINE Local NewTarget() const; @@ -139,6 +149,11 @@ class FunctionCallbackInfo { /** The ReturnValue for the call. */ V8_INLINE ReturnValue GetReturnValue() const; + // This is a temporary replacement for Holder() added just for the purpose + // of testing the deprecated Holder() machinery until it's removed for real. + // DO NOT use it. + V8_INLINE Local HolderSoonToBeDeprecated() const; + private: friend class internal::FunctionCallbackArguments; friend class internal::CustomArguments; @@ -265,7 +280,15 @@ class PropertyCallbackInfo { */ V8_INLINE bool ShouldThrowOnError() const; + V8_DEPRECATE_SOON( + "This is a temporary workaround to ease migration of Chromium bindings " + "code to the new interceptors Api") + explicit PropertyCallbackInfo(const PropertyCallbackInfo& info) + : PropertyCallbackInfo(info.args_) {} + private: + template + friend class PropertyCallbackInfo; friend class MacroAssembler; friend class internal::PropertyCallbackArguments; friend class internal::CustomArguments; @@ -379,26 +402,32 @@ void ReturnValue::Set(double i) { } template -void ReturnValue::Set(int32_t i) { +void ReturnValue::Set(int16_t i) { static_assert(std::is_base_of::value, "type check"); using I = internal::Internals; - if (V8_LIKELY(I::IsValidSmi(i))) { - SetInternal(I::IntToSmi(i)); + static_assert(I::IsValidSmi(std::numeric_limits::min())); + static_assert(I::IsValidSmi(std::numeric_limits::max())); + SetInternal(I::IntegralToSmi(i)); +} + +template +void ReturnValue::Set(int32_t i) { + static_assert(std::is_base_of::value, "type check"); + if (const auto result = internal::Internals::TryIntegralToSmi(i)) { + SetInternal(*result); return; } SetNonEmpty(Integer::New(GetIsolate(), i)); } template -void ReturnValue::Set(uint32_t i) { +void ReturnValue::Set(int64_t i) { static_assert(std::is_base_of::value, "type check"); - // Can't simply use INT32_MAX here for whatever reason. - bool fits_into_int32_t = (i & (1U << 31)) == 0; - if (V8_LIKELY(fits_into_int32_t)) { - Set(static_cast(i)); + if (const auto result = internal::Internals::TryIntegralToSmi(i)) { + SetInternal(*result); return; } - SetNonEmpty(Integer::NewFromUnsigned(GetIsolate(), i)); + SetNonEmpty(Number::New(GetIsolate(), static_cast(i))); } template @@ -407,7 +436,27 @@ void ReturnValue::Set(uint16_t i) { using I = internal::Internals; static_assert(I::IsValidSmi(std::numeric_limits::min())); static_assert(I::IsValidSmi(std::numeric_limits::max())); - SetInternal(I::IntToSmi(i)); + SetInternal(I::IntegralToSmi(i)); +} + +template +void ReturnValue::Set(uint32_t i) { + static_assert(std::is_base_of::value, "type check"); + if (const auto result = internal::Internals::TryIntegralToSmi(i)) { + SetInternal(*result); + return; + } + SetNonEmpty(Integer::NewFromUnsigned(GetIsolate(), i)); +} + +template +void ReturnValue::Set(uint64_t i) { + static_assert(std::is_base_of::value, "type check"); + if (const auto result = internal::Internals::TryIntegralToSmi(i)) { + SetInternal(*result); + return; + } + SetNonEmpty(Number::New(GetIsolate(), static_cast(i))); } template @@ -532,10 +581,15 @@ Local FunctionCallbackInfo::This() const { } template -Local FunctionCallbackInfo::Holder() const { +Local FunctionCallbackInfo::HolderSoonToBeDeprecated() const { return Local::FromSlot(&implicit_args_[kHolderIndex]); } +template +Local FunctionCallbackInfo::Holder() const { + return HolderSoonToBeDeprecated(); +} + template Local FunctionCallbackInfo::NewTarget() const { return Local::FromSlot(&implicit_args_[kNewTargetIndex]); @@ -595,8 +649,8 @@ template bool PropertyCallbackInfo::ShouldThrowOnError() const { using I = internal::Internals; if (args_[kShouldThrowOnErrorIndex] != - I::IntToSmi(I::kInferShouldThrowMode)) { - return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(I::kDontThrow); + I::IntegralToSmi(I::kInferShouldThrowMode)) { + return args_[kShouldThrowOnErrorIndex] != I::IntegralToSmi(I::kDontThrow); } return v8::internal::ShouldThrowOnError( reinterpret_cast(GetIsolate())); diff --git a/deps/v8/include/v8-function.h b/deps/v8/include/v8-function.h index 30a9fcfe174..50f730f3929 100644 --- a/deps/v8/include/v8-function.h +++ b/deps/v8/include/v8-function.h @@ -59,9 +59,6 @@ class V8_EXPORT Function : public Object { void SetName(Local name); Local GetName() const; - V8_DEPRECATED("No direct replacement") - MaybeLocal GetUnboundScript() const; - /** * Name inferred from variable or property assignment of this function. * Used to facilitate debugging and profiling of JavaScript code written diff --git a/deps/v8/include/v8-initialization.h b/deps/v8/include/v8-initialization.h index d3e35d6ec5f..6f12e3db960 100644 --- a/deps/v8/include/v8-initialization.h +++ b/deps/v8/include/v8-initialization.h @@ -97,10 +97,17 @@ class V8_EXPORT V8 { * is created. It always returns true. */ V8_INLINE static bool Initialize() { +#ifdef V8_TARGET_OS_ANDROID + const bool kV8TargetOsIsAndroid = true; +#else + const bool kV8TargetOsIsAndroid = false; +#endif + const int kBuildConfiguration = (internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) | (internal::SmiValuesAre31Bits() ? k31BitSmis : 0) | - (internal::SandboxIsEnabled() ? kSandbox : 0); + (internal::SandboxIsEnabled() ? kSandbox : 0) | + (kV8TargetOsIsAndroid ? kTargetOsIsAndroid : 0); return Initialize(kBuildConfiguration); } @@ -271,6 +278,7 @@ class V8_EXPORT V8 { kPointerCompression = 1 << 0, k31BitSmis = 1 << 1, kSandbox = 1 << 2, + kTargetOsIsAndroid = 1 << 3, }; /** diff --git a/deps/v8/include/v8-internal.h b/deps/v8/include/v8-internal.h index 322b22d98e8..c2a9a411fa8 100644 --- a/deps/v8/include/v8-internal.h +++ b/deps/v8/include/v8-internal.h @@ -11,7 +11,9 @@ #include #include +#include #include +#include #include #include "v8config.h" // NOLINT(build/include_directory) @@ -87,7 +89,10 @@ struct SmiTagging<4> { // Truncate and shift down (requires >> to be sign extending). return static_cast(static_cast(value)) >> shift_bits; } - V8_INLINE static constexpr bool IsValidSmi(intptr_t value) { + + template && + std::is_signed_v>* = nullptr> + V8_INLINE static constexpr bool IsValidSmi(T value) { // Is value in range [kSmiMinValue, kSmiMaxValue]. // Use unsigned operations in order to avoid undefined behaviour in case of // signed integer overflow. @@ -96,6 +101,28 @@ struct SmiTagging<4> { (static_cast(kSmiMaxValue) - static_cast(kSmiMinValue)); } + + template && + std::is_unsigned_v>* = nullptr> + V8_INLINE static constexpr bool IsValidSmi(T value) { + static_assert(kSmiMaxValue <= std::numeric_limits::max()); + return value <= static_cast(kSmiMaxValue); + } + + // Same as the `intptr_t` version but works with int64_t on 32-bit builds + // without slowing down anything else. + V8_INLINE static constexpr bool IsValidSmi(int64_t value) { + return (static_cast(value) - + static_cast(kSmiMinValue)) <= + (static_cast(kSmiMaxValue) - + static_cast(kSmiMinValue)); + } + + V8_INLINE static constexpr bool IsValidSmi(uint64_t value) { + static_assert(kSmiMaxValue <= std::numeric_limits::max()); + return value <= static_cast(kSmiMaxValue); + } }; // Smi constants for systems where tagged pointer is a 64-bit value. @@ -112,10 +139,21 @@ struct SmiTagging<8> { // Shift down and throw away top 32 bits. return static_cast(static_cast(value) >> shift_bits); } - V8_INLINE static constexpr bool IsValidSmi(intptr_t value) { + + template && + std::is_signed_v>* = nullptr> + V8_INLINE static constexpr bool IsValidSmi(T value) { // To be representable as a long smi, the value must be a 32-bit integer. return (value == static_cast(value)); } + + template && + std::is_unsigned_v>* = nullptr> + V8_INLINE static constexpr bool IsValidSmi(T value) { + return (static_cast(value) == + static_cast(static_cast(value))); + } }; #ifdef V8_COMPRESS_POINTERS @@ -253,15 +291,15 @@ static_assert(1ULL << (64 - kBoundedSizeShift) == // size allows omitting bounds checks on table accesses if the indices are // guaranteed (e.g. through shifting) to be below the maximum index. This // value must be a power of two. -constexpr size_t kExternalPointerTableReservationSize = 512 * MB; +constexpr size_t kExternalPointerTableReservationSize = 256 * MB; // The external pointer table indices stored in HeapObjects as external // pointers are shifted to the left by this amount to guarantee that they are // smaller than the maximum table size. -constexpr uint32_t kExternalPointerIndexShift = 6; +constexpr uint32_t kExternalPointerIndexShift = 7; #else -constexpr size_t kExternalPointerTableReservationSize = 1024 * MB; -constexpr uint32_t kExternalPointerIndexShift = 5; +constexpr size_t kExternalPointerTableReservationSize = 512 * MB; +constexpr uint32_t kExternalPointerIndexShift = 6; #endif // V8_TARGET_OS_ANDROID // The maximum number of entries in an external pointer table. @@ -301,6 +339,68 @@ using ExternalPointer_t = Address; constexpr ExternalPointer_t kNullExternalPointer = 0; constexpr ExternalPointerHandle kNullExternalPointerHandle = 0; +// See `ExternalPointerHandle` for the main documentation. The difference to +// `ExternalPointerHandle` is that the handle does not represent an arbitrary +// external pointer but always refers to an object managed by `CppHeap`. The +// handles are using in combination with a dedicated table for `CppHeap` +// references. +using CppHeapPointerHandle = uint32_t; + +// The actual pointer to objects located on the `CppHeap`. When pointer +// compression is enabled these pointers are stored as `CppHeapPointerHandle`. +// In non-compressed configurations the pointers are simply stored as raw +// pointers. +#ifdef V8_COMPRESS_POINTERS +using CppHeapPointer_t = CppHeapPointerHandle; +#else +using CppHeapPointer_t = Address; +#endif + +constexpr CppHeapPointer_t kNullCppHeapPointer = 0; +constexpr CppHeapPointerHandle kNullCppHeapPointerHandle = 0; + +// See `ExternalPointerHandle` for the main documentation. The difference to +// `ExternalPointerHandle` is that the handle always refers to a +// (external pointer, size) tuple. The handles are used in combination with a +// dedicated external buffer table (EBT). +using ExternalBufferHandle = uint32_t; + +// ExternalBuffer point to buffer located outside the sandbox. When the V8 +// sandbox is enabled, these are stored on heap as ExternalBufferHandles, +// otherwise they are simply raw pointers. +#ifdef V8_ENABLE_SANDBOX +using ExternalBuffer_t = ExternalBufferHandle; +#else +using ExternalBuffer_t = Address; +#endif + +#ifdef V8_TARGET_OS_ANDROID +// The size of the virtual memory reservation for the external buffer table. +// As with the external pointer table, a maximum table size in combination with +// shifted indices allows omitting bounds checks. +constexpr size_t kExternalBufferTableReservationSize = 64 * MB; + +// The external buffer handles are stores shifted to the left by this amount +// to guarantee that they are smaller than the maximum table size. +constexpr uint32_t kExternalBufferHandleShift = 10; +#else +constexpr size_t kExternalBufferTableReservationSize = 128 * MB; +constexpr uint32_t kExternalBufferHandleShift = 9; +#endif // V8_TARGET_OS_ANDROID + +// A null handle always references an entry that contains nullptr. +constexpr ExternalBufferHandle kNullExternalBufferHandle = 0; + +// The maximum number of entries in an external buffer table. +constexpr int kExternalBufferTableEntrySize = 16; +constexpr int kExternalBufferTableEntrySizeLog2 = 4; +constexpr size_t kMaxExternalBufferPointers = + kExternalBufferTableReservationSize / kExternalBufferTableEntrySize; +static_assert((1 << (32 - kExternalBufferHandleShift)) == + kMaxExternalBufferPointers, + "kExternalBufferTableReservationSize and " + "kExternalBufferHandleShift don't match"); + // // External Pointers. // @@ -418,22 +518,46 @@ constexpr uint64_t kAllExternalPointerTypeTags[] = { // External pointers using these tags are kept in a per-Isolate external // pointer table and can only be accessed when this Isolate is active. #define PER_ISOLATE_EXTERNAL_POINTER_TAGS(V) \ - V(kForeignForeignAddressTag, TAG(10)) \ - V(kNativeContextMicrotaskQueueTag, TAG(11)) \ - V(kEmbedderDataSlotPayloadTag, TAG(12)) \ + V(kNativeContextMicrotaskQueueTag, TAG(10)) \ + V(kEmbedderDataSlotPayloadTag, TAG(11)) \ /* This tag essentially stands for a `void*` pointer in the V8 API, and */ \ /* it is the Embedder's responsibility to ensure type safety (against */ \ /* substitution) and lifetime validity of these objects. */ \ - V(kExternalObjectValueTag, TAG(13)) \ - V(kFunctionTemplateInfoCallbackTag, TAG(14)) \ - V(kAccessorInfoGetterTag, TAG(15)) \ - V(kAccessorInfoSetterTag, TAG(16)) \ - V(kWasmInternalFunctionCallTargetTag, TAG(17)) \ - V(kWasmTypeInfoNativeTypeTag, TAG(18)) \ - V(kWasmExportedFunctionDataSignatureTag, TAG(19)) \ - V(kWasmContinuationJmpbufTag, TAG(20)) \ - V(kWasmIndirectFunctionTargetTag, TAG(21)) \ - V(kArrayBufferExtensionTag, TAG(22)) + V(kExternalObjectValueTag, TAG(12)) \ + V(kFunctionTemplateInfoCallbackTag, TAG(13)) \ + V(kAccessorInfoGetterTag, TAG(14)) \ + V(kAccessorInfoSetterTag, TAG(15)) \ + V(kWasmInternalFunctionCallTargetTag, TAG(16)) \ + V(kWasmTypeInfoNativeTypeTag, TAG(17)) \ + V(kWasmExportedFunctionDataSignatureTag, TAG(18)) \ + V(kWasmContinuationJmpbufTag, TAG(19)) \ + V(kWasmIndirectFunctionTargetTag, TAG(20)) \ + /* Foreigns */ \ + V(kGenericForeignTag, TAG(30)) \ + /* Managed */ \ + V(kFirstManagedResourceTag, TAG(40)) \ + V(kGenericManagedTag, TAG(40)) \ + V(kWasmWasmStreamingTag, TAG(41)) \ + V(kWasmFuncDataTag, TAG(42)) \ + V(kWasmManagedDataTag, TAG(43)) \ + V(kWasmNativeModuleTag, TAG(44)) \ + V(kWasmStackMemoryTag, TAG(45)) \ + V(kIcuBreakIteratorTag, TAG(46)) \ + V(kIcuUnicodeStringTag, TAG(47)) \ + V(kIcuListFormatterTag, TAG(48)) \ + V(kIcuLocaleTag, TAG(49)) \ + V(kIcuSimpleDateFormatTag, TAG(50)) \ + V(kIcuDateIntervalFormatTag, TAG(51)) \ + V(kIcuRelativeDateTimeFormatterTag, TAG(52)) \ + V(kIcuLocalizedNumberFormatterTag, TAG(53)) \ + V(kIcuPluralRulesTag, TAG(54)) \ + V(kIcuCollatorTag, TAG(55)) \ + V(kDisplayNamesInternalTag, TAG(56)) \ + /* External resources whose lifetime is tied to */ \ + /* their entry in the external pointer table but */ \ + /* which are not referenced via a Managed */ \ + V(kArrayBufferExtensionTag, TAG(57)) \ + V(kLastManagedResourceTag, TAG(57)) \ // All external pointer tags. #define ALL_EXTERNAL_POINTER_TAGS(V) \ @@ -449,12 +573,18 @@ enum ExternalPointerTag : uint64_t { kExternalPointerNullTag = MAKE_TAG(1, 0b00000000), // External pointer tag that will match any external pointer. Use with care! kAnyExternalPointerTag = MAKE_TAG(1, 0b11111111), + // External pointer tag that will match any external pointer in a Foreign. + // Use with care! If desired, this could be made more fine-granular. + kAnyForeignTag = kAnyExternalPointerTag, // The free entry tag has all type bits set so every type check with a // different type fails. It also doesn't have the mark bit set as free // entries are (by definition) not alive. kExternalPointerFreeEntryTag = MAKE_TAG(0, 0b11111111), // Evacuation entries are used during external pointer table compaction. - kExternalPointerEvacuationEntryTag = MAKE_TAG(1, 0b11100111), + kExternalPointerEvacuationEntryTag = MAKE_TAG(1, 0b11111110), + // Tag for zapped/invalidated entries. Those are considered to no longer be + // in use and so have the marking bit cleared. + kExternalPointerZappedEntryTag = MAKE_TAG(0, 0b11111101), ALL_EXTERNAL_POINTER_TAGS(EXTERNAL_POINTER_TAG_ENUM) }; @@ -481,6 +611,15 @@ V8_INLINE static constexpr bool IsMaybeReadOnlyExternalPointerType( tag == kFunctionTemplateInfoCallbackTag; } +// True if the external pointer references an external object whose lifetime is +// tied to the entry in the external pointer table. +// In this case, the entry in the ExternalPointerTable always points to an +// object derived from ExternalPointerTable::ManagedResource. +V8_INLINE static constexpr bool IsManagedExternalPointerType( + ExternalPointerTag tag) { + return tag >= kFirstManagedResourceTag && tag <= kLastManagedResourceTag; +} + // Sanity checks. #define CHECK_SHARED_EXTERNAL_POINTER_TAGS(Tag, ...) \ static_assert(IsSharedExternalPointerType(Tag)); @@ -576,11 +715,11 @@ using CodePointerHandle = IndirectPointerHandle; // The size of the virtual memory reservation for the code pointer table. // As with the other tables, a maximum table size in combination with shifted // indices allows omitting bounds checks. -constexpr size_t kCodePointerTableReservationSize = 16 * MB; +constexpr size_t kCodePointerTableReservationSize = 128 * MB; // Code pointer handles are shifted by a different amount than indirect pointer // handles as the tables have a different maximum size. -constexpr uint32_t kCodePointerHandleShift = 12; +constexpr uint32_t kCodePointerHandleShift = 9; // A null handle always references an entry that contains nullptr. constexpr CodePointerHandle kNullCodePointerHandle = kNullIndirectPointerHandle; @@ -647,6 +786,13 @@ class Internals { static const int kOddballKindOffset = 4 * kApiTaggedSize + kApiDoubleSize; static const int kJSObjectHeaderSize = 3 * kApiTaggedSize; +#ifdef V8_COMPRESS_POINTERS + static const int kJSAPIObjectWithEmbedderSlotsHeaderSize = + kJSObjectHeaderSize + kApiInt32Size; +#else // !V8_COMPRESS_POINTERS + static const int kJSAPIObjectWithEmbedderSlotsHeaderSize = + kJSObjectHeaderSize + kApiTaggedSize; +#endif // !V8_COMPRESS_POINTERS static const int kFixedArrayHeaderSize = 2 * kApiTaggedSize; static const int kEmbedderDataArrayHeaderSize = 2 * kApiTaggedSize; static const int kEmbedderDataSlotSize = kApiSystemPointerSize; @@ -676,6 +822,7 @@ class Internals { // ExternalPointerTable and TrustedPointerTable layout guarantees. static const int kExternalPointerTableBasePointerOffset = 0; static const int kExternalPointerTableSize = 2 * kApiSystemPointerSize; + static const int kExternalBufferTableSize = 2 * kApiSystemPointerSize; static const int kTrustedPointerTableSize = 2 * kApiSystemPointerSize; static const int kTrustedPointerTableBasePointerOffset = 0; @@ -719,16 +866,22 @@ class Internals { kIsolateEmbedderDataOffset + kNumIsolateDataSlots * kApiSystemPointerSize; static const int kIsolateSharedExternalPointerTableAddressOffset = kIsolateExternalPointerTableOffset + kExternalPointerTableSize; + static const int kIsolateCppHeapPointerTableOffset = + kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize; #ifdef V8_ENABLE_SANDBOX static const int kIsolateTrustedCageBaseOffset = - kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize; + kIsolateCppHeapPointerTableOffset + kExternalPointerTableSize; static const int kIsolateTrustedPointerTableOffset = kIsolateTrustedCageBaseOffset + kApiSystemPointerSize; - static const int kIsolateApiCallbackThunkArgumentOffset = + static const int kIsolateExternalBufferTableOffset = kIsolateTrustedPointerTableOffset + kTrustedPointerTableSize; + static const int kIsolateSharedExternalBufferTableAddressOffset = + kIsolateExternalBufferTableOffset + kExternalBufferTableSize; + static const int kIsolateApiCallbackThunkArgumentOffset = + kIsolateSharedExternalBufferTableAddressOffset + kApiSystemPointerSize; #else static const int kIsolateApiCallbackThunkArgumentOffset = - kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize; + kIsolateCppHeapPointerTableOffset + kExternalPointerTableSize; #endif // V8_ENABLE_SANDBOX #else static const int kIsolateApiCallbackThunkArgumentOffset = @@ -736,13 +889,8 @@ class Internals { #endif // V8_COMPRESS_POINTERS static const int kContinuationPreservedEmbedderDataOffset = kIsolateApiCallbackThunkArgumentOffset + kApiSystemPointerSize; - - static const int kWasm64OOBOffsetAlignmentPaddingSize = 0; - static const int kWasm64OOBOffsetOffset = - kContinuationPreservedEmbedderDataOffset + kApiSystemPointerSize + - kWasm64OOBOffsetAlignmentPaddingSize; static const int kIsolateRootsOffset = - kWasm64OOBOffsetOffset + sizeof(int64_t); + kContinuationPreservedEmbedderDataOffset + kApiSystemPointerSize; #if V8_STATIC_ROOTS_BOOL @@ -753,7 +901,7 @@ class Internals { V(TrueValue, 0xc9) \ V(FalseValue, 0xad) \ V(EmptyString, 0xa1) \ - V(TheHoleValue, 0x719) + V(TheHoleValue, 0x741) using Tagged_t = uint32_t; struct StaticReadOnlyRoot { @@ -836,14 +984,36 @@ class Internals { return PlatformSmiTagging::SmiToInt(value); } + V8_INLINE static constexpr Address AddressToSmi(Address value) { + return (value << (kSmiTagSize + PlatformSmiTagging::kSmiShiftSize)) | + kSmiTag; + } + V8_INLINE static constexpr Address IntToSmi(int value) { - return internal::IntToSmi(value); + return AddressToSmi(static_cast
(value)); } - V8_INLINE static constexpr bool IsValidSmi(intptr_t value) { + template >* = nullptr> + V8_INLINE static constexpr Address IntegralToSmi(T value) { + return AddressToSmi(static_cast
(value)); + } + + template >* = nullptr> + V8_INLINE static constexpr bool IsValidSmi(T value) { return PlatformSmiTagging::IsValidSmi(value); } + template >* = nullptr> + static constexpr std::optional
TryIntegralToSmi(T value) { + if (V8_LIKELY(PlatformSmiTagging::IsValidSmi(value))) { + return {AddressToSmi(static_cast
(value))}; + } + return {}; + } + #if V8_STATIC_ROOTS_BOOL V8_INLINE static bool is_identical(Address obj, Tagged_t constant) { return static_cast(obj) == constant; @@ -1116,7 +1286,7 @@ class V8_EXPORT StrongRootAllocatorBase { protected: explicit StrongRootAllocatorBase(Heap* heap) : heap_(heap) {} - explicit StrongRootAllocatorBase(v8::Isolate* isolate); + explicit StrongRootAllocatorBase(Isolate* isolate); // Allocate/deallocate a range of n elements of type internal::Address. Address* allocate_impl(size_t n); @@ -1132,17 +1302,15 @@ class V8_EXPORT StrongRootAllocatorBase { // and internal::StrongRootAllocator> register the allocated range // as strong roots. template -class StrongRootAllocator : public StrongRootAllocatorBase, - private std::allocator { +class StrongRootAllocator : private std::allocator { public: using value_type = T; - explicit StrongRootAllocator(Heap* heap) : StrongRootAllocatorBase(heap) {} - explicit StrongRootAllocator(v8::Isolate* isolate) - : StrongRootAllocatorBase(isolate) {} + explicit StrongRootAllocator(Heap* heap) {} + explicit StrongRootAllocator(Isolate* isolate) {} + explicit StrongRootAllocator(v8::Isolate* isolate) {} template - StrongRootAllocator(const StrongRootAllocator& other) noexcept - : StrongRootAllocatorBase(other) {} + StrongRootAllocator(const StrongRootAllocator& other) noexcept {} using std::allocator::allocate; using std::allocator::deallocate; @@ -1383,10 +1551,6 @@ class HandleHelper final { if (rhs.IsEmpty()) return false; return lhs.ptr() == rhs.ptr(); } - - static V8_EXPORT bool IsOnStack(const void* ptr); - static V8_EXPORT void VerifyOnStack(const void* ptr); - static V8_EXPORT void VerifyOnMainThread(); }; V8_EXPORT void VerifyHandleIsNonEmpty(bool is_empty); diff --git a/deps/v8/include/v8-isolate.h b/deps/v8/include/v8-isolate.h index 585b513fac4..c25c409b26d 100644 --- a/deps/v8/include/v8-isolate.h +++ b/deps/v8/include/v8-isolate.h @@ -276,11 +276,6 @@ class V8_EXPORT Isolate { */ bool allow_atomics_wait = true; - /** - * Termination is postponed when there is no active SafeForTerminationScope. - */ - bool only_terminate_in_safe_scope = false; - /** * The following parameters describe the offsets for addressing type info * for wrapped API objects and are used by the fast C API @@ -389,21 +384,6 @@ class V8_EXPORT Isolate { friend class internal::ThreadLocalTop; }; - /** - * This scope allows terminations inside direct V8 API calls and forbid them - * inside any recursive API calls without explicit SafeForTerminationScope. - */ - class V8_EXPORT V8_NODISCARD SafeForTerminationScope { - public: - V8_DEPRECATE_SOON("All code should be safe for termination") - explicit SafeForTerminationScope(v8::Isolate* v8_isolate) {} - ~SafeForTerminationScope() {} - - // Prevent copying of Scope objects. - SafeForTerminationScope(const SafeForTerminationScope&) = delete; - SafeForTerminationScope& operator=(const SafeForTerminationScope&) = delete; - }; - /** * Types of garbage collections that can be requested via * RequestGarbageCollectionForTesting. @@ -1362,24 +1342,6 @@ class V8_EXPORT Isolate { */ void SetAddCrashKeyCallback(AddCrashKeyCallback); - /** - * Optional notification that the embedder is idle. - * V8 uses the notification to perform garbage collection. - * This call can be used repeatedly if the embedder remains idle. - * Returns true if the embedder should stop calling IdleNotificationDeadline - * until real work has been done. This indicates that V8 has done - * as much cleanup as it will be able to do. - * - * The deadline_in_seconds argument specifies the deadline V8 has to finish - * garbage collection work. deadline_in_seconds is compared with - * MonotonicallyIncreasingTime() and should be based on the same timebase as - * that function. There is no guarantee that the actual work will be done - * within the time limit. - */ - V8_DEPRECATE_SOON( - "Use MemoryPressureNotification() to influence the GC schedule.") - bool IdleNotificationDeadline(double deadline_in_seconds); - /** * Optional notification that the system is running low on memory. * V8 uses these notifications to attempt to free memory. @@ -1656,7 +1618,7 @@ class V8_EXPORT Isolate { * heap. GC is not invoked prior to iterating, therefore there is no * guarantee that visited objects are still alive. */ - V8_DEPRECATE_SOON("Will be removed without replacement. crbug.com/v8/14172") + V8_DEPRECATED("Will be removed without replacement. crbug.com/v8/14172") void VisitExternalResources(ExternalResourceVisitor* visitor); /** diff --git a/deps/v8/include/v8-local-handle.h b/deps/v8/include/v8-local-handle.h index 46f7308431a..03f7d5212e4 100644 --- a/deps/v8/include/v8-local-handle.h +++ b/deps/v8/include/v8-local-handle.h @@ -51,8 +51,6 @@ class Isolate; class Object; template class PersistentValueMapBase; -template -class PersistentValueVector; class Primitive; class Private; template @@ -382,8 +380,6 @@ class V8_TRIVIAL_ABI Local : public LocalBase, friend class InternalEscapableScope; template friend class PersistentValueMapBase; - template - friend class PersistentValueVector; template friend class ReturnValue; template @@ -440,12 +436,12 @@ class V8_TRIVIAL_ABI LocalUnchecked : public Local { // In this case, the check is also enforced in the copy constructor and we // need to suppress it. LocalUnchecked(const LocalUnchecked& other) - : Local(other, Local::do_not_check) {} - LocalUnchecked& operator=(const LocalUnchecked&) = default; + : Local(other, Local::do_not_check) noexcept {} + LocalUnchecked& operator=(const LocalUnchecked&) noexcept = default; #endif // Implicit conversion from Local. - LocalUnchecked(const Local& other) // NOLINT(runtime/explicit) + LocalUnchecked(const Local& other) noexcept // NOLINT(runtime/explicit) : Local(other, Local::do_not_check) {} }; @@ -461,8 +457,10 @@ class StrongRootAllocator> : public StrongRootAllocatorBase { static_assert(sizeof(value_type) == sizeof(Address)); explicit StrongRootAllocator(Heap* heap) : StrongRootAllocatorBase(heap) {} - explicit StrongRootAllocator(v8::Isolate* isolate) + explicit StrongRootAllocator(Isolate* isolate) : StrongRootAllocatorBase(isolate) {} + explicit StrongRootAllocator(v8::Isolate* isolate) + : StrongRootAllocatorBase(reinterpret_cast(isolate)) {} template StrongRootAllocator(const StrongRootAllocator& other) noexcept : StrongRootAllocatorBase(other) {} @@ -561,6 +559,7 @@ class LocalVector { LocalVector& operator=(std::initializer_list> init) { backing_.clear(); + backing_.reserve(init.size()); backing_.insert(backing_.end(), init.begin(), init.end()); return *this; } diff --git a/deps/v8/include/v8-message.h b/deps/v8/include/v8-message.h index 8f49a06dfa8..9f933358792 100644 --- a/deps/v8/include/v8-message.h +++ b/deps/v8/include/v8-message.h @@ -61,27 +61,6 @@ class ScriptOriginOptions { */ class V8_EXPORT ScriptOrigin { public: - V8_DEPRECATE_SOON("Use constructor without the isolate.") - V8_INLINE ScriptOrigin(Isolate* isolate, Local resource_name, - int resource_line_offset = 0, - int resource_column_offset = 0, - bool resource_is_shared_cross_origin = false, - int script_id = -1, - Local source_map_url = Local(), - bool resource_is_opaque = false, bool is_wasm = false, - bool is_module = false, - Local host_defined_options = Local()) - : resource_name_(resource_name), - resource_line_offset_(resource_line_offset), - resource_column_offset_(resource_column_offset), - options_(resource_is_shared_cross_origin, resource_is_opaque, is_wasm, - is_module), - script_id_(script_id), - source_map_url_(source_map_url), - host_defined_options_(host_defined_options) { - VerifyHostDefinedOptions(); - } - V8_INLINE ScriptOrigin(Local resource_name, int resource_line_offset = 0, int resource_column_offset = 0, diff --git a/deps/v8/include/v8-microtask-queue.h b/deps/v8/include/v8-microtask-queue.h index 85d227fa3fd..135dfb06a3b 100644 --- a/deps/v8/include/v8-microtask-queue.h +++ b/deps/v8/include/v8-microtask-queue.h @@ -118,11 +118,6 @@ class V8_EXPORT V8_NODISCARD MicrotasksScope { public: enum Type { kRunMicrotasks, kDoNotRunMicrotasks }; - V8_DEPRECATE_SOON( - "May be incorrect if context was created with non-default microtask " - "queue") - MicrotasksScope(Isolate* isolate, Type type); - MicrotasksScope(Local context, Type type); MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type); ~MicrotasksScope(); diff --git a/deps/v8/include/v8-object.h b/deps/v8/include/v8-object.h index 6cdf53b19c7..c2ea59d3652 100644 --- a/deps/v8/include/v8-object.h +++ b/deps/v8/include/v8-object.h @@ -5,10 +5,12 @@ #ifndef INCLUDE_V8_OBJECT_H_ #define INCLUDE_V8_OBJECT_H_ +#include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-maybe.h" // NOLINT(build/include_directory) #include "v8-persistent-handle.h" // NOLINT(build/include_directory) #include "v8-primitive.h" // NOLINT(build/include_directory) +#include "v8-sandbox.h" // NOLINT(build/include_directory) #include "v8-traced-handle.h" // NOLINT(build/include_directory) #include "v8-value.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) @@ -146,18 +148,20 @@ enum PropertyAttribute { }; /** - * Accessor[Getter|Setter] are used as callback functions when - * setting|getting a particular property. See Object and ObjectTemplate's - * method SetAccessor. + * Accessor[Getter|Setter] are used as callback functions when setting|getting + * a particular data property. See Object::SetNativeDataProperty and + * ObjectTemplate::SetNativeDataProperty methods. */ -using AccessorGetterCallback = +using AccessorGetterCallback V8_DEPRECATE_SOON( + "Use AccessorNameGetterCallback signature instead") = void (*)(Local property, const PropertyCallbackInfo& info); using AccessorNameGetterCallback = void (*)(Local property, const PropertyCallbackInfo& info); -using AccessorSetterCallback = void (*)(Local property, - Local value, - const PropertyCallbackInfo& info); +using AccessorSetterCallback V8_DEPRECATE_SOON( + "Use AccessorNameSetterCallback signature instead") = + void (*)(Local property, Local value, + const PropertyCallbackInfo& info); using AccessorNameSetterCallback = void (*)(Local property, Local value, const PropertyCallbackInfo& info); @@ -339,7 +343,7 @@ class V8_EXPORT Object : public Value { V8_WARN_UNUSED_RESULT Maybe Delete(Local context, uint32_t index); - V8_DEPRECATE_SOON("Use SetNativeDataProperty instead") + V8_DEPRECATED("Use SetNativeDataProperty instead") V8_WARN_UNUSED_RESULT Maybe SetAccessor( Local context, Local name, AccessorNameGetterCallback getter, @@ -429,16 +433,41 @@ class V8_EXPORT Object : public Value { * be skipped by __proto__ and it does not consult the security * handler. */ + // V8_DEPRECATE_SOON( + // "V8 will stop providing access to hidden prototype (i.e. " + // "JSGlobalObject). Use GetPrototypeV2() instead. " + // "See http://crbug.com/333672197.") Local GetPrototype(); + /** + * Get the prototype object (same as getting __proto__ property). This does + * not consult the security handler. + * TODO(333672197): rename back to GetPrototype() once the old version goes + * through the deprecation process and is removed. + */ + Local GetPrototypeV2(); + /** * Set the prototype object. This does not skip objects marked to * be skipped by __proto__ and it does not consult the security * handler. */ + // V8_DEPRECATE_SOON( + // "V8 will stop providing access to hidden prototype (i.e. " + // "JSGlobalObject). Use SetPrototypeV2() instead. " + // "See http://crbug.com/333672197.") V8_WARN_UNUSED_RESULT Maybe SetPrototype(Local context, Local prototype); + /** + * Set the prototype object (same as setting __proto__ property). This does + * does not consult the security handler. + * TODO(333672197): rename back to SetPrototype() once the old version goes + * through the deprecation process and is removed. + */ + V8_WARN_UNUSED_RESULT Maybe SetPrototypeV2(Local context, + Local prototype); + /** * Finds an instance of the given function template in the prototype * chain. @@ -526,7 +555,50 @@ class V8_EXPORT Object : public Value { void* values[]); /** - * HasOwnProperty() is like JavaScript's Object.prototype.hasOwnProperty(). + * Unwraps a JS wrapper object. + * + * \param tag The tag for retrieving the wrappable instance. Must match the + * tag that has been used for a previous `Wrap()` operation. + * \param isolate The Isolate for the `wrapper` object. + * \param wrapper The JS wrapper object that should be unwrapped. + * \returns the C++ wrappable instance, or nullptr if the JS object has never + * been wrapped. + */ + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const v8::Local& wrapper); + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const PersistentBase& wrapper); + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper); + + /** + * Wraps a JS wrapper with a C++ instance. + * + * \param tag The pointer tag that should be used for storing this object. + * Future `Unwrap()` operations must provide a matching tag. + * \param isolate The Isolate for the `wrapper` object. + * \param wrapper The JS wrapper object. + * \param wrappable The C++ object instance that is wrapped by the JS object. + */ + template + static V8_INLINE void Wrap(v8::Isolate* isolate, + const v8::Local& wrapper, + void* wrappable); + template + static V8_INLINE void Wrap(v8::Isolate* isolate, + const PersistentBase& wrapper, + void* wrappable); + template + static V8_INLINE void Wrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper, + void* wrappable); + + /** + * HasOwnProperty() is like JavaScript's + * Object.prototype.hasOwnProperty(). * * See also v8::Object::Has() and v8::Object::HasRealNamedProperty(). */ @@ -610,12 +682,16 @@ class V8_EXPORT Object : public Value { /** * Returns the context in which the object was created. + * Prefer using version with Isolate parameter. */ + MaybeLocal GetCreationContext(v8::Isolate* isolate); MaybeLocal GetCreationContext(); /** - * Shortcut for GetCreationContext().ToLocalChecked(). + * Shortcut for GetCreationContext(...).ToLocalChecked(). + * Prefer using version with Isolate parameter. **/ + Local GetCreationContextChecked(v8::Isolate* isolate); Local GetCreationContextChecked(); /** Same as above, but works for Persistents */ @@ -634,7 +710,12 @@ class V8_EXPORT Object : public Value { * try to expand the embedder data attached to the context. * In case the Local is already available because of other reasons, * it's fine to keep using Context::GetAlignedPointerFromEmbedderData(). + * + * Prefer using version with Isolate parameter if you have an Isolate, + * otherwise use the other one. */ + void* GetAlignedPointerFromEmbedderDataInCreationContext(v8::Isolate* isolate, + int index); void* GetAlignedPointerFromEmbedderDataInCreationContext(int index); /** @@ -650,11 +731,15 @@ class V8_EXPORT Object : public Value { bool IsConstructor() const; /** - * True if this object can carry information relevant to the embedder in its - * embedder fields, false otherwise. This is generally true for objects - * constructed through function templates but also holds for other types where - * V8 automatically adds internal fields at compile time, such as e.g. - * v8::ArrayBuffer. + * Returns true if this object can be generally used to wrap object objects. + * This means that the object either follows the convention of using embedder + * fields to denote type/instance pointers or is using the Wrap()/Unwrap() + * APIs for the same purpose. Returns false otherwise. + * + * Note that there may be other objects that use embedder fields but are not + * used as API wrapper objects. E.g., v8::Promise may in certain configuration + * use embedder fields but promises are not generally supported as API + * wrappers. The method will return false in those cases. */ bool IsApiWrapper() const; @@ -729,6 +814,11 @@ class V8_EXPORT Object : public Value { bool IsCodeLike(Isolate* isolate) const; private: + static void* Unwrap(v8::Isolate* isolate, internal::Address wrapper_obj, + CppHeapPointerTag tag); + static void Wrap(v8::Isolate* isolate, internal::Address wrapper_obj, + CppHeapPointerTag tag, void* wrappable); + Object(); static void CheckCast(Value* obj); Local SlowGetInternalField(int index); @@ -747,7 +837,8 @@ Local Object::GetInternalField(int index) { // know where to find the internal fields and can return the value directly. int instance_type = I::GetInstanceType(obj); if (I::CanHaveInternalField(instance_type)) { - int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index); + int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize + + (I::kEmbedderDataSlotSize * index); A value = I::ReadRawField(obj, offset); #ifdef V8_COMPRESS_POINTERS // We read the full pointer value and then decompress it in order to avoid @@ -773,7 +864,8 @@ void* Object::GetAlignedPointerFromInternalField(v8::Isolate* isolate, // know where to find the internal fields and can return the value directly. auto instance_type = I::GetInstanceType(obj); if (V8_LIKELY(I::CanHaveInternalField(instance_type))) { - int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) + + int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize + + (I::kEmbedderDataSlotSize * index) + I::kEmbedderDataSlotExternalPointerOffset; A value = I::ReadExternalPointerField( @@ -793,7 +885,8 @@ void* Object::GetAlignedPointerFromInternalField(int index) { // know where to find the internal fields and can return the value directly. auto instance_type = I::GetInstanceType(obj); if (V8_LIKELY(I::CanHaveInternalField(instance_type))) { - int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) + + int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize + + (I::kEmbedderDataSlotSize * index) + I::kEmbedderDataSlotExternalPointerOffset; Isolate* isolate = I::GetIsolateForSandbox(obj); A value = @@ -805,6 +898,73 @@ void* Object::GetAlignedPointerFromInternalField(int index) { return SlowGetAlignedPointerFromInternalField(index); } +// static +template +T* Object::Unwrap(v8::Isolate* isolate, const v8::Local& wrapper) { + auto obj = internal::ValueHelper::ValueAsAddress(*wrapper); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize); +#else // defined(V8_ENABLE_CHECKS) + return reinterpret_cast(Unwrap(isolate, obj, tag)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase& wrapper) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize); +#else // defined(V8_ENABLE_CHECKS) + + return reinterpret_cast(Unwrap(isolate, obj, tag)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +T* Object::Unwrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize); +#else // defined(V8_ENABLE_CHECKS) + return reinterpret_cast(Unwrap(isolate, obj, tag)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +void Object::Wrap(v8::Isolate* isolate, const v8::Local& wrapper, + void* wrappable) { + auto obj = internal::ValueHelper::ValueAsAddress(*wrapper); + Wrap(isolate, obj, tag, wrappable); +} + +// static +template +void Object::Wrap(v8::Isolate* isolate, const PersistentBase& wrapper, + void* wrappable) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); + Wrap(isolate, obj, tag, wrappable); +} + +// static +template +void Object::Wrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper, + void* wrappable) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); + Wrap(isolate, obj, tag, wrappable); +} + Private* Private::Cast(Data* data) { #ifdef V8_ENABLE_CHECKS CheckCast(data); diff --git a/deps/v8/include/v8-persistent-handle.h b/deps/v8/include/v8-persistent-handle.h index 9db5af5dddd..3067cb775fc 100644 --- a/deps/v8/include/v8-persistent-handle.h +++ b/deps/v8/include/v8-persistent-handle.h @@ -15,8 +15,6 @@ namespace v8 { class Isolate; template class PersistentValueMapBase; -template -class PersistentValueVector; template class Global; template @@ -204,8 +202,6 @@ class PersistentBase : public api_internal::IndirectHandleBase { friend class ReturnValue; template friend class PersistentValueMapBase; - template - friend class PersistentValueVector; friend class Object; friend class internal::ValueHelper; @@ -236,21 +232,6 @@ class NonCopyablePersistentTraits { } }; -/** - * Helper class traits to allow copying and assignment of Persistent. - * This will clone the contents of storage cell, but not any of the flags, etc. - */ -template -struct CopyablePersistentTraits { - using CopyablePersistent = Persistent>; - static const bool kResetInDestructor = true; - template - static V8_INLINE void Copy(const Persistent& source, - CopyablePersistent* dest) { - // do nothing, just allow copy - } -}; - /** * A PersistentBase which allows copy and assignment. * diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h index 313c0287bcf..56bfd727482 100644 --- a/deps/v8/include/v8-platform.h +++ b/deps/v8/include/v8-platform.h @@ -79,8 +79,10 @@ class TaskRunner { * * Embedders should override PostTaskImpl instead of this. */ - virtual void PostTask(std::unique_ptr task) { - PostTaskImpl(std::move(task), SourceLocation::Current()); + void PostTask( + std::unique_ptr task, + const SourceLocation& location = SourceLocation::Current()) { + PostTaskImpl(std::move(task), location); } /** @@ -100,8 +102,10 @@ class TaskRunner { * * Embedders should override PostNonNestableTaskImpl instead of this. */ - virtual void PostNonNestableTask(std::unique_ptr task) { - PostNonNestableTaskImpl(std::move(task), SourceLocation::Current()); + void PostNonNestableTask( + std::unique_ptr task, + const SourceLocation& location = SourceLocation::Current()) { + PostNonNestableTaskImpl(std::move(task), location); } /** @@ -111,10 +115,10 @@ class TaskRunner { * * Embedders should override PostDelayedTaskImpl instead of this. */ - virtual void PostDelayedTask(std::unique_ptr task, - double delay_in_seconds) { - PostDelayedTaskImpl(std::move(task), delay_in_seconds, - SourceLocation::Current()); + void PostDelayedTask( + std::unique_ptr task, double delay_in_seconds, + const SourceLocation& location = SourceLocation::Current()) { + PostDelayedTaskImpl(std::move(task), delay_in_seconds, location); } /** @@ -135,10 +139,10 @@ class TaskRunner { * * Embedders should override PostNonNestableDelayedTaskImpl instead of this. */ - virtual void PostNonNestableDelayedTask(std::unique_ptr task, - double delay_in_seconds) { - PostNonNestableDelayedTaskImpl(std::move(task), delay_in_seconds, - SourceLocation::Current()); + void PostNonNestableDelayedTask( + std::unique_ptr task, double delay_in_seconds, + const SourceLocation& location = SourceLocation::Current()) { + PostNonNestableDelayedTaskImpl(std::move(task), delay_in_seconds, location); } /** @@ -151,8 +155,10 @@ class TaskRunner { * * Embedders should override PostIdleTaskImpl instead of this. */ - virtual void PostIdleTask(std::unique_ptr task) { - PostIdleTaskImpl(std::move(task), SourceLocation::Current()); + void PostIdleTask( + std::unique_ptr task, + const SourceLocation& location = SourceLocation::Current()) { + PostIdleTaskImpl(std::move(task), location); } /** @@ -389,7 +395,7 @@ class TracingController { /** * Adds a trace event to the platform tracing system. These function calls are - * usually the result of a TRACE_* macro from trace_event_common.h when + * usually the result of a TRACE_* macro from trace-event-no-perfetto.h when * tracing and the category of the particular trace are enabled. It is not * advisable to call these functions on their own; they are really only meant * to be used by the trace macros. The returned handle can be used by diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index 3ec0cd4bb31..00217d499a0 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -899,9 +899,28 @@ class V8_EXPORT EmbedderGraph { /** * Returns a node corresponding to the given V8 value. Ownership is not * transferred. The result pointer is valid while the graph is alive. + * + * For now the variant that takes v8::Data is not marked as abstract for + * compatibility, but embedders who subclass EmbedderGraph are expected to + * implement it. Then in the implementation of the variant that takes + * v8::Value, they can simply forward the call to the one that takes + * v8::Local. */ virtual Node* V8Node(const v8::Local& value) = 0; + /** + * Returns a node corresponding to the given V8 value. Ownership is not + * transferred. The result pointer is valid while the graph is alive. + * + * For API compatibility, this default implementation just checks that the + * data is a v8::Value and forward it to the variant that takes v8::Value, + * which is currently required to be implemented. In the future we'll remove + * the v8::Value variant, and make this variant that takes v8::Data abstract + * instead. If the embedder subclasses v8::EmbedderGraph and also use + * v8::TracedReference, they must override this variant. + */ + virtual Node* V8Node(const v8::Local& value); + /** * Adds the given node to the graph and takes ownership of the node. * Returns a raw pointer to the node that is valid while the graph is alive. @@ -956,7 +975,7 @@ class V8_EXPORT HeapProfiler { /** * Callback function invoked during heap snapshot generation to retrieve - * the detachedness state of an object referenced by a TracedReference. + * the detachedness state of a JS object referenced by a TracedReference. * * The callback takes Local as parameter to allow the embedder to * unpack the TracedReference into a Local and reuse that Local for different diff --git a/deps/v8/include/v8-sandbox.h b/deps/v8/include/v8-sandbox.h new file mode 100644 index 00000000000..f5f91cbb91a --- /dev/null +++ b/deps/v8/include/v8-sandbox.h @@ -0,0 +1,63 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_V8_SANDBOX_H_ +#define INCLUDE_V8_SANDBOX_H_ + +#include + +#include "v8-internal.h" // NOLINT(build/include_directory) +#include "v8config.h" // NOLINT(build/include_directory) + +namespace v8 { + +/** + * A pointer tag used for wrapping and unwrapping `CppHeap` pointers as used + * with JS API wrapper objects that rely on `v8::Object::Wrap()` and + * `v8::Object::Unwrap()`. + */ +enum class CppHeapPointerTag : uint64_t { + kDefaultTag = internal::ExternalPointerTag::kExternalObjectValueTag, +}; + +namespace internal { + +#ifdef V8_COMPRESS_POINTERS +V8_INLINE static Address* GetCppHeapPointerTableBase(v8::Isolate* isolate) { + Address addr = reinterpret_cast
(isolate) + + Internals::kIsolateCppHeapPointerTableOffset + + Internals::kExternalPointerTableBasePointerOffset; + return *reinterpret_cast(addr); +} +#endif // V8_COMPRESS_POINTERS + +template +V8_INLINE static T* ReadCppHeapPointerField(v8::Isolate* isolate, + Address heap_object_ptr, + int offset) { +#ifdef V8_COMPRESS_POINTERS + static_assert(tag != static_cast(kExternalPointerNullTag)); + // See src/sandbox/external-pointer-table-inl.h. Logic duplicated here so + // it can be inlined and doesn't require an additional call. + const CppHeapPointerHandle handle = + Internals::ReadRawField(heap_object_ptr, offset); + if (handle == 0) { + return reinterpret_cast(kNullAddress); + } + const uint32_t index = handle >> kExternalPointerIndexShift; + const Address* table = GetCppHeapPointerTableBase(isolate); + const std::atomic
* ptr = + reinterpret_cast*>(&table[index]); + Address entry = std::atomic_load_explicit(ptr, std::memory_order_relaxed); + return reinterpret_cast(entry & ~static_cast(tag)); +#else // !V8_COMPRESS_POINTERS + return reinterpret_cast( + Internals::ReadRawField
(heap_object_ptr, offset)); +#endif // !V8_COMPRESS_POINTERS +} + +} // namespace internal +} // namespace v8 + +#endif // INCLUDE_V8_SANDBOX_H_ diff --git a/deps/v8/include/v8-script.h b/deps/v8/include/v8-script.h index 75589863d9d..6a7ab5d73db 100644 --- a/deps/v8/include/v8-script.h +++ b/deps/v8/include/v8-script.h @@ -322,6 +322,14 @@ class V8_EXPORT Module : public Data { static void CheckCast(Data* obj); }; +class V8_EXPORT CompileHintsCollector : public Data { + public: + /** + * Returns the positions of lazy functions which were compiled and executed. + */ + std::vector GetCompileHints(Isolate* isolate) const; +}; + /** * A compiled JavaScript script, tied to a Context which was active when the * script was compiled. @@ -359,7 +367,15 @@ class V8_EXPORT Script : public Data { * If the script was compiled, returns the positions of lazy functions which * were eventually compiled and executed. */ + V8_DEPRECATE_SOON("Use GetCompileHintsCollector instead") std::vector GetProducedCompileHints() const; + + /** + * Get a compile hints collector object which we can use later for retrieving + * compile hints (= positions of lazy functions which were compiled and + * executed). + */ + Local GetCompileHintsCollector() const; }; enum class ScriptType { kClassic, kModule }; @@ -787,15 +803,6 @@ class V8_EXPORT ScriptCompiler { * It is possible to specify multiple context extensions (obj in the above * example). */ - V8_DEPRECATED("Use CompileFunction") - static V8_WARN_UNUSED_RESULT MaybeLocal CompileFunctionInContext( - Local context, Source* source, size_t arguments_count, - Local arguments[], size_t context_extension_count, - Local context_extensions[], - CompileOptions options = kNoCompileOptions, - NoCacheReason no_cache_reason = kNoCacheNoReason, - Local* script_or_module_out = nullptr); - static V8_WARN_UNUSED_RESULT MaybeLocal CompileFunction( Local context, Source* source, size_t arguments_count = 0, Local arguments[] = nullptr, size_t context_extension_count = 0, diff --git a/deps/v8/include/v8-snapshot.h b/deps/v8/include/v8-snapshot.h index 9e5a53f134a..8c8390bab18 100644 --- a/deps/v8/include/v8-snapshot.h +++ b/deps/v8/include/v8-snapshot.h @@ -68,6 +68,22 @@ struct SerializeContextDataCallback { void* data; }; +/** + * Similar to `SerializeInternalFieldsCallback`, but is used exclusively to + * serialize API wrappers. The pointers for API wrappers always point into the + * CppHeap. + */ +struct SerializeAPIWrapperCallback { + using CallbackFunction = StartupData (*)(Local holder, + void* cpp_heap_pointer, void* data); + explicit SerializeAPIWrapperCallback(CallbackFunction function = nullptr, + void* data = nullptr) + : callback(function), data(data) {} + + CallbackFunction callback; + void* data; +}; + /** * Callback and supporting data used to implement embedder logic to deserialize * internal fields of v8::Objects. @@ -97,6 +113,17 @@ struct DeserializeContextDataCallback { void* data; }; +struct DeserializeAPIWrapperCallback { + using CallbackFunction = void (*)(Local holder, StartupData payload, + void* data); + explicit DeserializeAPIWrapperCallback(CallbackFunction function = nullptr, + void* data = nullptr) + : callback(function), data(data) {} + + CallbackFunction callback; + void* data; +}; + /** * Helper class to create a snapshot data blob. * @@ -187,13 +214,17 @@ class V8_EXPORT SnapshotCreator { * context embedder data set by * v8::Context::SetAlignedPointerInEmbedderData(). * + * \param api_wrapper_serializer An optional callback used to serialize API + * wrapper references set via `v8::Object::Wrap()`. */ void SetDefaultContext( Local context, SerializeInternalFieldsCallback internal_fields_serializer = SerializeInternalFieldsCallback(), SerializeContextDataCallback context_data_serializer = - SerializeContextDataCallback()); + SerializeContextDataCallback(), + SerializeAPIWrapperCallback api_wrapper_serializer = + SerializeAPIWrapperCallback()); /** * Add additional context to be included in the snapshot blob. @@ -204,12 +235,17 @@ class V8_EXPORT SnapshotCreator { * * \param context_data_serializer Similar to context_data_serializer * in SetDefaultContext() but only applies to the context being added. + * + * \param api_wrapper_serializer Similar to api_wrapper_serializer + * in SetDefaultContext() but only applies to the context being added. */ size_t AddContext(Local context, SerializeInternalFieldsCallback internal_fields_serializer = SerializeInternalFieldsCallback(), SerializeContextDataCallback context_data_serializer = - SerializeContextDataCallback()); + SerializeContextDataCallback(), + SerializeAPIWrapperCallback api_wrapper_serializer = + SerializeAPIWrapperCallback()); /** * Attach arbitrary V8::Data to the context snapshot, which can be retrieved diff --git a/deps/v8/include/v8-template.h b/deps/v8/include/v8-template.h index 6a0c898f450..7c96a233f19 100644 --- a/deps/v8/include/v8-template.h +++ b/deps/v8/include/v8-template.h @@ -80,27 +80,6 @@ class V8_EXPORT Template : public Data { * \param attribute The attributes of the property for which an accessor * is added. */ - V8_DEPRECATE_SOON("Use SetNativeDataProperty without AccessControl instead") - void SetNativeDataProperty( - Local name, AccessorGetterCallback getter, - AccessorSetterCallback setter, Local data, - PropertyAttribute attribute, AccessControl settings, - SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, - SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); - V8_DEPRECATE_SOON("Use SetNativeDataProperty without AccessControl instead") - void SetNativeDataProperty( - Local name, AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter, Local data, - PropertyAttribute attribute, AccessControl settings, - SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, - SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); - V8_DEPRECATE_SOON("Use SetNativeDataProperty with Local instead") - void SetNativeDataProperty( - Local name, AccessorGetterCallback getter, - AccessorSetterCallback setter = nullptr, - Local data = Local(), PropertyAttribute attribute = None, - SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, - SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); void SetNativeDataProperty( Local name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter = nullptr, @@ -142,7 +121,8 @@ enum class Intercepted : uint8_t { kNo = 0, kYes = 1 }; * Interceptor for get requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should + * looked up beyond the interceptor or in case an exception was thrown) it + * should * - (optionally) use info.GetReturnValue().Set()` to set the return value * (by default the result is set to v8::Undefined), * - return `Intercepted::kYes`. @@ -194,7 +174,8 @@ using GenericNamedPropertyGetterCallback = * Interceptor for set requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should return `Intercepted::kYes`. + * looked up beyond the interceptor or in case an exception was thrown) it + * should return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. * @@ -229,9 +210,10 @@ using GenericNamedPropertySetterCallback = * defineProperty(). * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should - * - use `info.GetReturnValue().Set()` to set to an Integer value encoding - * a `v8::PropertyAttribute` bits, + * looked up beyond the interceptor or in case an exception was thrown) it + * should + * - (optionally) use `info.GetReturnValue().Set()` to set to an Integer + * value encoding a `v8::PropertyAttribute` bits, * - return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. @@ -263,9 +245,10 @@ using GenericNamedPropertyQueryCallback = * Interceptor for delete requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should - * - use `info.GetReturnValue().Set()` to set to a Boolean value indicating - * whether the property deletion was successful or not, + * looked up beyond the interceptor or in case an exception was thrown) it + * should + * - (optionally) use `info.GetReturnValue().Set()` to set to a Boolean value + * indicating whether the property deletion was successful or not, * - return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. @@ -311,7 +294,8 @@ using GenericNamedPropertyEnumeratorCallback = NamedPropertyEnumeratorCallback; * Interceptor for defineProperty requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should return `Intercepted::kYes`. + * looked up beyond the interceptor or in case an exception was thrown) it + * should return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. * @@ -344,10 +328,11 @@ using GenericNamedPropertyDefinerCallback = * Interceptor for getOwnPropertyDescriptor requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should - * - use `info.GetReturnValue().Set()` to set the return value which must be - * object that can be converted to a PropertyDescriptor (for example, - * a value returned by `v8::Object::getOwnPropertyDescriptor`), + * looked up beyond the interceptor or in case an exception was thrown) it + * should + * - (optionally) use `info.GetReturnValue().Set()` to set the return value + * which must be object that can be converted to a PropertyDescriptor (for + * example, a value returned by `v8::Object::getOwnPropertyDescriptor`), * - return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. @@ -379,7 +364,7 @@ using GenericNamedPropertyDescriptorCallback = // removed. /** - * See `v8::GenericNamedPropertyGetterCallback`. + * See `v8::NamedPropertyGetterCallback`. */ using IndexedPropertyGetterCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -388,7 +373,7 @@ using IndexedPropertyGetterCallback = void (*)(uint32_t index, const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertySetterCallback`. + * See `v8::NamedPropertySetterCallback`. */ using IndexedPropertySetterCallbackV2 = Intercepted (*)( uint32_t index, Local value, const PropertyCallbackInfo& info); @@ -398,7 +383,7 @@ using IndexedPropertySetterCallback = const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyQueryCallback`. + * See `v8::NamedPropertyQueryCallback`. */ using IndexedPropertyQueryCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -407,7 +392,7 @@ using IndexedPropertyQueryCallback = void (*)(uint32_t index, const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDeleterCallback`. + * See `v8::NamedPropertyDeleterCallback`. */ using IndexedPropertyDeleterCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -425,7 +410,7 @@ using IndexedPropertyEnumeratorCallback = void (*)(const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDefinerCallback`. + * See `v8::NamedPropertyDefinerCallback`. */ using IndexedPropertyDefinerCallbackV2 = Intercepted (*)(uint32_t index, const PropertyDescriptor& desc, @@ -436,7 +421,7 @@ using IndexedPropertyDefinerCallback = const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDescriptorCallback`. + * See `v8::NamedPropertyDescriptorCallback`. */ using IndexedPropertyDescriptorCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -489,8 +474,8 @@ enum class ConstructorBehavior { kThrow, kAllow }; * proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2)); * * v8::Local instance_t = t->InstanceTemplate(); - * instance_t->SetAccessor( - String::NewFromUtf8Literal(isolate, "instance_accessor"), + * instance_t->SetNativeDataProperty( + * String::NewFromUtf8Literal(isolate, "instance_accessor"), * InstanceAccessorCallback); * instance_t->SetHandler( * NamedPropertyHandlerConfiguration(PropertyHandlerCallback)); @@ -762,7 +747,9 @@ struct NamedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATED( + "Provide interceptor callbacks with new signatures instead " + "(NamedPropertyXxxCallback)") NamedPropertyHandlerConfiguration( GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, @@ -801,7 +788,9 @@ struct NamedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATED( + "Provide interceptor callbacks with new signatures instead " + "(NamedPropertyXxxCallback)") explicit NamedPropertyHandlerConfiguration( GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter = nullptr, @@ -839,7 +828,9 @@ struct NamedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATED( + "Provide interceptor callbacks with new signatures instead " + "(NamedPropertyXxxCallback)") NamedPropertyHandlerConfiguration( GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, @@ -901,7 +892,9 @@ struct IndexedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATED( + "Provide interceptor callbacks with new signatures instead " + "(IndexedPropertyXxxCallbackV2)") IndexedPropertyHandlerConfiguration( IndexedPropertyGetterCallback getter, // IndexedPropertySetterCallback setter, // @@ -940,7 +933,9 @@ struct IndexedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATED( + "Provide interceptor callbacks with new signatures instead " + "(IndexedPropertyXxxCallbackV2)") explicit IndexedPropertyHandlerConfiguration( IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter = nullptr, @@ -978,7 +973,9 @@ struct IndexedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATED( + "Provide interceptor callbacks with new signatures instead " + "(IndexedPropertyXxxCallbackV2)") IndexedPropertyHandlerConfiguration( IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter, @@ -1045,13 +1042,7 @@ class V8_EXPORT ObjectTemplate : public Template { * \param attribute The attributes of the property for which an accessor * is added. */ - V8_DEPRECATE_SOON("Use SetAccessor with Local instead") - void SetAccessor( - Local name, AccessorGetterCallback getter, - AccessorSetterCallback setter = nullptr, - Local data = Local(), PropertyAttribute attribute = None, - SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, - SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); + V8_DEPRECATE_SOON("Use SetNativeDataProperty instead") void SetAccessor( Local name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter = nullptr, @@ -1072,34 +1063,6 @@ class V8_EXPORT ObjectTemplate : public Template { */ void SetHandler(const NamedPropertyHandlerConfiguration& configuration); - /** - * Sets an indexed property handler on the object template. - * - * Whenever an indexed property is accessed on objects created from - * this object template, the provided callback is invoked instead of - * accessing the property directly on the JavaScript object. - * - * \param getter The callback to invoke when getting a property. - * \param setter The callback to invoke when setting a property. - * \param query The callback to invoke to check if an object has a property. - * \param deleter The callback to invoke when deleting a property. - * \param enumerator The callback to invoke to enumerate all the indexed - * properties of an object. - * \param data A piece of data that will be passed to the callbacks - * whenever they are invoked. - */ - V8_DEPRECATE_SOON("Use SetHandler instead") - void SetIndexedPropertyHandler( - IndexedPropertyGetterCallback getter, - IndexedPropertySetterCallback setter = nullptr, - IndexedPropertyQueryCallback query = nullptr, - IndexedPropertyDeleterCallback deleter = nullptr, - IndexedPropertyEnumeratorCallback enumerator = nullptr, - Local data = Local()) { - SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query, - deleter, enumerator, data)); - } - /** * Sets an indexed property handler on the object template. * diff --git a/deps/v8/include/v8-traced-handle.h b/deps/v8/include/v8-traced-handle.h index c9fd357b871..04752c4f2ae 100644 --- a/deps/v8/include/v8-traced-handle.h +++ b/deps/v8/include/v8-traced-handle.h @@ -62,11 +62,11 @@ class TracedReferenceBase : public api_internal::IndirectHandleBase { V8_INLINE void Reset(); /** - * Construct a Local from this handle. + * Construct a Local from this handle. */ - V8_INLINE Local Get(Isolate* isolate) const { - if (IsEmpty()) return Local(); - return Local::New(isolate, this->value()); + V8_INLINE Local Get(Isolate* isolate) const { + if (IsEmpty()) return Local(); + return Local::New(isolate, this->value()); } /** @@ -135,17 +135,6 @@ class BasicTracedReference : public TracedReferenceBase { const_cast&>(*this)); } - V8_DEPRECATE_SOON("Use Get to convert to Local instead") - V8_INLINE T* operator->() const { -#ifdef V8_ENABLE_CHECKS - CheckValue(); -#endif // V8_ENABLE_CHECKS - return this->template value(); - } - - V8_DEPRECATE_SOON("Use Get to convert to Local instead") - V8_INLINE T* operator*() const { return this->operator->(); } - private: /** * An empty BasicTracedReference without storage cell. diff --git a/deps/v8/include/v8-unwinder.h b/deps/v8/include/v8-unwinder.h index 8b71bb39b55..5771eb05a81 100644 --- a/deps/v8/include/v8-unwinder.h +++ b/deps/v8/include/v8-unwinder.h @@ -42,7 +42,8 @@ enum StateTag : uint16_t { OTHER, EXTERNAL, ATOMICS_WAIT, - IDLE + IDLE, + LOGGING, }; // The output structure filled up by GetStackSample API function. diff --git a/deps/v8/include/v8-util.h b/deps/v8/include/v8-util.h index db6d1a2fe6b..b7d53f14f75 100644 --- a/deps/v8/include/v8-util.h +++ b/deps/v8/include/v8-util.h @@ -544,122 +544,6 @@ class StdGlobalValueMap : public GlobalValueMap { : GlobalValueMap(isolate) {} }; -class DefaultPersistentValueVectorTraits { - public: - typedef std::vector Impl; - - static void Append(Impl* impl, PersistentContainerValue value) { - impl->push_back(value); - } - static bool IsEmpty(const Impl* impl) { - return impl->empty(); - } - static size_t Size(const Impl* impl) { - return impl->size(); - } - static PersistentContainerValue Get(const Impl* impl, size_t i) { - return (i < impl->size()) ? impl->at(i) : kPersistentContainerNotFound; - } - static void ReserveCapacity(Impl* impl, size_t capacity) { - impl->reserve(capacity); - } - static void Clear(Impl* impl) { - impl->clear(); - } -}; - -/** - * A vector wrapper that safely stores Global values. - * C++11 embedders don't need this class, as they can use Global - * directly in std containers. - * - * This class relies on a backing vector implementation, whose type and methods - * are described by the Traits class. The backing map will handle values of type - * PersistentContainerValue, with all conversion into and out of V8 - * handles being transparently handled by this class. - */ -template -class V8_DEPRECATE_SOON("Use std::vector>.") PersistentValueVector { - public: - explicit PersistentValueVector(Isolate* isolate) : isolate_(isolate) { } - - ~PersistentValueVector() { - Clear(); - } - - /** - * Append a value to the vector. - */ - void Append(Local value) { - Global persistent(isolate_, value); - Traits::Append(&impl_, ClearAndLeak(&persistent)); - } - - /** - * Append a persistent's value to the vector. - */ - void Append(Global persistent) { - Traits::Append(&impl_, ClearAndLeak(&persistent)); - } - - /** - * Are there any values in the vector? - */ - bool IsEmpty() const { - return Traits::IsEmpty(&impl_); - } - - /** - * How many elements are in the vector? - */ - size_t Size() const { - return Traits::Size(&impl_); - } - - /** - * Retrieve the i-th value in the vector. - */ - Local Get(size_t index) const { - return Local::New(isolate_, internal::ValueHelper::SlotAsValue( - Traits::Get(&impl_, index))); - } - - /** - * Remove all elements from the vector. - */ - void Clear() { - size_t length = Traits::Size(&impl_); - for (size_t i = 0; i < length; i++) { - Global p; - p.slot() = reinterpret_cast(Traits::Get(&impl_, i)); - } - Traits::Clear(&impl_); - } - - /** - * Reserve capacity in the vector. - * (Efficiency gains depend on the backing implementation.) - */ - void ReserveCapacity(size_t capacity) { - Traits::ReserveCapacity(&impl_, capacity); - } - - private: - static PersistentContainerValue ClearAndLeak(Global* persistent) { - auto slot = persistent->slot(); - persistent->Clear(); - return reinterpret_cast(slot); - } - - static V* FromVal(PersistentContainerValue v) { - return internal::ValueHelper::SlotAsValue( - reinterpret_cast(v)); - } - - Isolate* isolate_; - typename Traits::Impl impl_; -}; - } // namespace v8 #endif // V8_UTIL_H diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index e769d42101e..dd70363fdde 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -9,9 +9,9 @@ // NOTE these macros are used by some of the tool scripts and the build // system so their names cannot be changed without changing the scripts. #define V8_MAJOR_VERSION 12 -#define V8_MINOR_VERSION 4 -#define V8_BUILD_NUMBER 254 -#define V8_PATCH_LEVEL 17 +#define V8_MINOR_VERSION 7 +#define V8_BUILD_NUMBER 81 +#define V8_PATCH_LEVEL 0 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/include/v8-wasm.h b/deps/v8/include/v8-wasm.h index 71514615466..f8e406c737e 100644 --- a/deps/v8/include/v8-wasm.h +++ b/deps/v8/include/v8-wasm.h @@ -9,6 +9,7 @@ #include #include +#include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-memory-span.h" // NOLINT(build/include_directory) #include "v8-object.h" // NOLINT(build/include_directory) @@ -129,6 +130,8 @@ class V8_EXPORT WasmModuleObject : public Object { */ class V8_EXPORT WasmStreaming final { public: + static constexpr internal::ExternalPointerTag kManagedTag = + internal::kWasmWasmStreamingTag; class WasmStreamingImpl; explicit WasmStreaming(std::unique_ptr impl); diff --git a/deps/v8/include/v8config.h b/deps/v8/include/v8config.h index e649d8cce7d..7565ebf68ea 100644 --- a/deps/v8/include/v8config.h +++ b/deps/v8/include/v8config.h @@ -477,14 +477,23 @@ path. Add it with -I to the command line # define V8_INLINE inline #endif +#if V8_HAS_BUILTIN_ASSUME #ifdef DEBUG -// In debug mode, check assumptions instead of actually adding annotations. -# define V8_ASSUME DCHECK -#elif V8_HAS_BUILTIN_ASSUME +// In debug mode, check assumptions in addition to adding annotations. +// This helps GCC (and maybe other compilers) figure out that certain +// situations are unreachable. +# define V8_ASSUME(condition) \ + do { \ + DCHECK(condition); \ + __builtin_assume(condition); \ + } while (false) +#else // DEBUG # define V8_ASSUME __builtin_assume +#endif // DEBUG #elif V8_HAS_BUILTIN_UNREACHABLE # define V8_ASSUME(condition) \ do { \ + DCHECK(condition); \ if (!(condition)) __builtin_unreachable(); \ } while (false) #else diff --git a/deps/v8/infra/mb/mb_config.pyl b/deps/v8/infra/mb/mb_config.pyl index a498d240e3f..e500dc24574 100644 --- a/deps/v8/infra/mb/mb_config.pyl +++ b/deps/v8/infra/mb/mb_config.pyl @@ -66,7 +66,6 @@ 'V8 Linux - verify csa - builder': 'release_x86_verify_csa', # Linux64. 'V8 Linux64 - builder': 'release_x64_gcmole', - 'V8 Linux64 - builder (goma cache silo)': 'release_x64', 'V8 Linux64 - builder (reclient)': 'release_x64_reclient', 'V8 Linux64 - builder (reclient compare)': 'release_x64_reclient', 'V8 Linux64 - official - builder': 'official_x64_on_release_branch', @@ -82,8 +81,8 @@ 'V8 Linux64 - verify csa - builder': 'release_x64_verify_csa', 'V8 Linux64 - no wasm - builder': 'release_x64_webassembly_disabled', # Windows. + 'V8 Win - arm64 - debug builder': 'debug_arm64', 'V8 Win32 - builder': 'release_x86_minimal_symbols', - 'V8 Win32 - builder (goma cache silo)': 'release_x86', 'V8 Win32 - builder (reclient)': 'release_x86_minimal_symbols_reclient', 'V8 Win32 - builder (reclient compare)': 'release_x86_minimal_symbols_reclient', 'V8 Win32 - debug builder': 'debug_x86_minimal_symbols', @@ -128,6 +127,7 @@ 'V8 Linux64 - disable runtime call stats - builder': 'release_x64_disable_runtime_call_stats', 'V8 Linux64 - debug - single generation - builder': 'debug_x64_single_generation', 'V8 Linux64 - no pointer compression - builder': 'release_x64_no_pointer_compression', + 'V8 Linux64 - sticky mark bits - debug builder': 'debug_x64_sticky_mark_bits', 'V8 Linux64 css - debug builder': 'debug_x64_conservative_stack_scanning', 'V8 Linux64 gcc - builder': 'release_x64_gcc', 'V8 Linux64 gcc - debug builder': 'debug_x64_gcc', @@ -306,6 +306,7 @@ 'v8_linux_riscv32_compile_rel': 'release_simulate_riscv32', 'v8_linux64_riscv64_compile_rel': 'release_simulate_riscv64', 'v8_linux64_riscv64_pointer_compression_compile_rel': 'release_simulate_riscv64_pointer_compression', + 'v8_linux64_sticky_mark_bits_compile_dbg': 'debug_x64_sticky_mark_bits', 'v8_linux64_tsan_compile_rel': 'release_x64_tsan_minimal_symbols', 'v8_linux64_tsan_compile_dbg': 'debug_x64_tsan_minimal_symbols', 'v8_linux64_tsan_no_cm_compile_rel': 'release_x64_tsan_no_cm', @@ -316,6 +317,7 @@ 'v8_linux64_verify_deterministic_rel': 'release_x64_verify_deterministic', 'v8_odroid_arm_compile_rel': 'release_arm', 'v8_linux_torque_compare': 'torque_compare', + 'v8_win_arm64_compile_dbg': 'debug_arm64', # TODO(machenbach): Remove after switching to x64 on infra side. 'v8_win_compile_dbg': 'debug_x86_trybot', 'v8_win_compile_rel': 'release_x86_trybot', @@ -693,6 +695,8 @@ 'debug_bot', 'x64', 'no_sandbox'], 'debug_x64_single_generation': [ 'debug_bot', 'x64', 'v8_enable_single_generation'], + 'debug_x64_sticky_mark_bits': [ + 'debug_bot', 'x64', 'v8_enable_sticky_mark_bits'], 'debug_x64_trybot': [ 'debug_trybot', 'x64'], 'debug_x64_dict_tracking_trybot': [ @@ -724,8 +728,6 @@ 'debug', 'x86', 'reclient', 'v8_enable_slow_dchecks', 'v8_full_debug'], # Release configs for x86. - 'release_x86': [ - 'release_bot', 'x86'], 'release_x86_asan_symbolized_verify_heap': [ 'release_bot', 'x86', 'asan', 'lsan', 'symbolized', 'v8_verify_heap'], @@ -889,7 +891,7 @@ }, 'ios_simulator': { - 'gn_args': 'target_cpu="x64" target_os="ios"', + 'gn_args': 'target_cpu="x64" target_os="ios" use_blink=true', }, 'lld': { @@ -1101,6 +1103,9 @@ 'gn_args': 'v8_enable_single_generation=true ' 'v8_disable_write_barriers=true', }, + 'v8_enable_sticky_mark_bits': { + 'gn_args': 'v8_enable_sticky_mark_bits=true', + }, 'v8_enable_test_features': { 'gn_args': 'v8_enable_test_features=true', }, diff --git a/deps/v8/infra/testing/builders.pyl b/deps/v8/infra/testing/builders.pyl index 7655763cab4..63ae917bf20 100644 --- a/deps/v8/infra/testing/builders.pyl +++ b/deps/v8/infra/testing/builders.pyl @@ -649,6 +649,15 @@ {'name': 'v8testing', 'variant': 'default'}, ], }, + 'v8_linux64_sandbox_testing_rel': { + 'swarming_dimensions' : { + 'cpu': 'x86-64', + 'os': 'Ubuntu-22.04', + }, + 'tests': [ + {'name': 'mjsunit', 'variant': 'default'}, + ], + }, 'v8_linux64_single_generation_dbg': { 'swarming_dimensions' : { 'os': 'Ubuntu-22.04', @@ -657,6 +666,15 @@ {'name': 'v8testing', 'shards': 3}, ], }, + 'v8_linux64_sticky_mark_bits_dbg': { + 'swarming_dimensions' : { + 'os': 'Ubuntu-22.04', + 'cpu': 'x86-64', + }, + 'tests': [ + {'name': 'v8testing', 'shards': 3}, + ], + }, 'v8_linux64_rel': { 'swarming_dimensions' : { 'cpu': 'x86-64-avx2', @@ -733,6 +751,7 @@ {'name': 'v8testing', 'variant': 'extra', 'shards': 6}, {'name': 'v8testing', 'variant': 'slow_path', 'shards': 2}, {'name': 'v8testing', 'variant': 'stress_concurrent_allocation', 'shards': 2}, + {'name': 'v8testing', 'variant': 'minor_ms', 'shards': 2}, ], }, 'v8_linux64_tsan_dbg': { @@ -1698,6 +1717,15 @@ {'name': 'v8testing', 'shards': 2}, ], }, + 'V8 Linux64 - sandbox testing': { + 'swarming_dimensions' : { + 'cpu': 'x86-64', + 'os': 'Ubuntu-22.04', + }, + 'tests': [ + {'name': 'mjsunit', 'variant': 'default'}, + ], + }, 'V8 Linux64 - shared': { 'swarming_dimensions' : { 'os': 'Ubuntu-22.04', @@ -1708,6 +1736,15 @@ {'name': 'v8testing'}, ], }, + 'V8 Linux64 - sticky mark bits - debug': { + 'swarming_dimensions' : { + 'os': 'Ubuntu-22.04', + 'cpu': 'x86-64', + }, + 'tests': [ + {'name': 'v8testing', 'shards': 3}, + ], + }, 'V8 Linux64 - verify csa': { 'swarming_dimensions' : { 'os': 'Ubuntu-22.04', @@ -1770,6 +1807,7 @@ {'name': 'v8testing', 'variant': 'extra', 'shards': 5}, {'name': 'v8testing', 'variant': 'slow_path', 'shards': 2}, {'name': 'v8testing', 'variant': 'stress_concurrent_allocation', 'shards': 2}, + {'name': 'v8testing', 'variant': 'minor_ms', 'shards': 2}, ], }, 'V8 Linux64 TSAN - debug': { diff --git a/deps/v8/samples/process.cc b/deps/v8/samples/process.cc index d773e9b9d18..80dc6040a87 100644 --- a/deps/v8/samples/process.cc +++ b/deps/v8/samples/process.cc @@ -150,9 +150,10 @@ class JsHttpRequestProcessor : public HttpRequestProcessor { const PropertyCallbackInfo& info); // Callbacks that access maps - static void MapGet(Local name, const PropertyCallbackInfo& info); - static void MapSet(Local name, Local value, - const PropertyCallbackInfo& info); + static v8::Intercepted MapGet(Local name, + const PropertyCallbackInfo& info); + static v8::Intercepted MapSet(Local name, Local value, + const PropertyCallbackInfo& info); // Utility methods for wrapping C++ objects as JavaScript objects, // and going back again. @@ -399,10 +400,9 @@ string ObjectToString(v8::Isolate* isolate, Local value) { return string(*utf8_value); } - -void JsHttpRequestProcessor::MapGet(Local name, - const PropertyCallbackInfo& info) { - if (name->IsSymbol()) return; +v8::Intercepted JsHttpRequestProcessor::MapGet( + Local name, const PropertyCallbackInfo& info) { + if (name->IsSymbol()) return v8::Intercepted::kNo; // Fetch the map wrapped by this object. map* obj = UnwrapMap(info.Holder()); @@ -414,7 +414,7 @@ void JsHttpRequestProcessor::MapGet(Local name, map::iterator iter = obj->find(key); // If the key is not present return an empty handle as signal - if (iter == obj->end()) return; + if (iter == obj->end()) return v8::Intercepted::kNo; // Otherwise fetch the value and wrap it in a JavaScript string const string& value = (*iter).second; @@ -422,12 +422,13 @@ void JsHttpRequestProcessor::MapGet(Local name, String::NewFromUtf8(info.GetIsolate(), value.c_str(), NewStringType::kNormal, static_cast(value.length())).ToLocalChecked()); + return v8::Intercepted::kYes; } - -void JsHttpRequestProcessor::MapSet(Local name, Local value_obj, - const PropertyCallbackInfo& info) { - if (name->IsSymbol()) return; +v8::Intercepted JsHttpRequestProcessor::MapSet( + Local name, Local value_obj, + const PropertyCallbackInfo& info) { + if (name->IsSymbol()) return v8::Intercepted::kNo; // Fetch the map wrapped by this object. map* obj = UnwrapMap(info.Holder()); @@ -441,9 +442,9 @@ void JsHttpRequestProcessor::MapSet(Local name, Local value_obj, // Return the value; any non-empty handle will work. info.GetReturnValue().Set(value_obj); + return v8::Intercepted::kYes; } - Local JsHttpRequestProcessor::MakeMapTemplate( Isolate* isolate) { EscapableHandleScope handle_scope(isolate); @@ -560,18 +561,20 @@ Local JsHttpRequestProcessor::MakeRequestTemplate( result->SetInternalFieldCount(1); // Add accessors for each of the fields of the request. - result->SetAccessor( + result->SetNativeDataProperty( String::NewFromUtf8Literal(isolate, "path", NewStringType::kInternalized), GetPath); - result->SetAccessor(String::NewFromUtf8Literal(isolate, "referrer", - NewStringType::kInternalized), - GetReferrer); - result->SetAccessor( + result->SetNativeDataProperty( + String::NewFromUtf8Literal(isolate, "referrer", + NewStringType::kInternalized), + GetReferrer); + result->SetNativeDataProperty( String::NewFromUtf8Literal(isolate, "host", NewStringType::kInternalized), GetHost); - result->SetAccessor(String::NewFromUtf8Literal(isolate, "userAgent", - NewStringType::kInternalized), - GetUserAgent); + result->SetNativeDataProperty( + String::NewFromUtf8Literal(isolate, "userAgent", + NewStringType::kInternalized), + GetUserAgent); // Again, return the result through the current handle scope. return handle_scope.Escape(result); diff --git a/deps/v8/src/DEPS b/deps/v8/src/DEPS index d9c58d01236..b06fa768754 100644 --- a/deps/v8/src/DEPS +++ b/deps/v8/src/DEPS @@ -1,5 +1,4 @@ include_rules = [ - "+base/trace_event/common/trace_event_common.h", "+src", "-src/asmjs", "+src/asmjs/asm-js.h", @@ -41,6 +40,7 @@ include_rules = [ "+src/heap/mutable-page.h", "+src/heap/mutable-page-inl.h", "+src/heap/memory-chunk.h", + "+src/heap/page-inl.h", "+src/heap/paged-spaces-inl.h", "+src/heap/parked-scope-inl.h", "+src/heap/parked-scope.h", @@ -55,7 +55,7 @@ include_rules = [ "+src/interpreter/bytecode-array-iterator.h", "+src/interpreter/bytecode-array-random-iterator.h", "+src/interpreter/bytecode-decoder.h", - "+src/interpreter/bytecode-flags.h", + "+src/interpreter/bytecode-flags-and-tokens.h", "+src/interpreter/bytecode-register.h", "+src/interpreter/bytecodes.h", "+src/interpreter/interpreter.h", @@ -69,6 +69,7 @@ include_rules = [ "+src/regexp/regexp-flags.h", "+src/regexp/regexp-stack.h", "+src/regexp/regexp-utils.h", + "+src/tracing/trace-event-no-perfetto.h", "-src/trap-handler", "+src/trap-handler/handler-inside-posix.h", "+src/trap-handler/handler-inside-win.h", diff --git a/deps/v8/src/api/OWNERS b/deps/v8/src/api/OWNERS index eb4a9242713..aa5d9dd1fbd 100644 --- a/deps/v8/src/api/OWNERS +++ b/deps/v8/src/api/OWNERS @@ -4,7 +4,6 @@ ishell@chromium.org jkummerow@chromium.org leszeks@chromium.org mlippautz@chromium.org -mslekova@chromium.org verwaest@chromium.org # For v8-debug.h implementations. diff --git a/deps/v8/src/api/api-arguments-inl.h b/deps/v8/src/api/api-arguments-inl.h index de2648c8d60..e32953bd270 100644 --- a/deps/v8/src/api/api-arguments-inl.h +++ b/deps/v8/src/api/api-arguments-inl.h @@ -143,6 +143,9 @@ Handle PropertyCallbackArguments::CallNamedQuery( RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedQueryCallback); Handle receiver_check_unsupported; if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); NamedPropertyQueryCallback f = ToCData(interceptor->query()); PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Integer, interceptor); @@ -165,6 +168,9 @@ Handle PropertyCallbackArguments::CallNamedGetter( Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedGetterCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); NamedPropertyGetterCallback f = ToCData(interceptor->getter()); PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); @@ -187,6 +193,9 @@ Handle PropertyCallbackArguments::CallNamedDescriptor( Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedDescriptorCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); NamedPropertyDescriptorCallback f = ToCData(interceptor->descriptor()); PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); @@ -212,6 +221,9 @@ Handle PropertyCallbackArguments::CallNamedSetter( Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedSetterCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); NamedPropertySetterCallback f = ToCData(interceptor->setter()); Handle has_side_effects; @@ -240,6 +252,9 @@ Handle PropertyCallbackArguments::CallNamedDefiner( Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedDefinerCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); NamedPropertyDefinerCallback f = ToCData(interceptor->definer()); Handle has_side_effects; @@ -266,6 +281,9 @@ Handle PropertyCallbackArguments::CallNamedDeleter( Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedDeleterCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); NamedPropertyDeleterCallback f = ToCData(interceptor->deleter()); Handle has_side_effects; @@ -302,6 +320,9 @@ Handle PropertyCallbackArguments::CallIndexedQuery( Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kIndexedQueryCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); IndexedPropertyQueryCallbackV2 f = ToCData(interceptor->query()); PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Integer, interceptor); @@ -321,11 +342,14 @@ Handle PropertyCallbackArguments::CallIndexedQuery( Handle PropertyCallbackArguments::CallIndexedGetter( Handle interceptor, uint32_t index) { DCHECK(!interceptor->is_named()); - RCS_SCOPE(isolate(), RuntimeCallCounterId::kNamedGetterCallback); + Isolate* isolate = this->isolate(); + RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedGetterCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); IndexedPropertyGetterCallbackV2 f = ToCData(interceptor->getter()); - Isolate* isolate = this->isolate(); PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); auto intercepted = f(index, callback_info); if (intercepted == v8::Intercepted::kNo) return {}; @@ -334,7 +358,6 @@ Handle PropertyCallbackArguments::CallIndexedGetter( } else { IndexedPropertyGetterCallback f = ToCData(interceptor->getter()); - Isolate* isolate = this->isolate(); PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); f(index, callback_info); return GetReturnValue(isolate); @@ -347,6 +370,9 @@ Handle PropertyCallbackArguments::CallIndexedDescriptor( Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kIndexedDescriptorCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); IndexedPropertyDescriptorCallbackV2 f = ToCData(interceptor->descriptor()); PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); @@ -370,6 +396,9 @@ Handle PropertyCallbackArguments::CallIndexedSetter( Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kIndexedSetterCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); IndexedPropertySetterCallbackV2 f = ToCData(interceptor->setter()); Handle has_side_effects; @@ -397,6 +426,9 @@ Handle PropertyCallbackArguments::CallIndexedDefiner( Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kIndexedDefinerCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); IndexedPropertyDefinerCallbackV2 f = ToCData(interceptor->definer()); Handle has_side_effects; @@ -423,6 +455,9 @@ Handle PropertyCallbackArguments::CallIndexedDeleter( Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kIndexedDeleterCallback); if (interceptor->has_new_callbacks_signature()) { + // New Api relies on the return value to be set to undefined. + // TODO(ishell): do this in the constructor once the old Api is deprecated. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); IndexedPropertyDeleterCallbackV2 f = ToCData(interceptor->deleter()); PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Boolean, interceptor); diff --git a/deps/v8/src/api/api-inl.h b/deps/v8/src/api/api-inl.h index b8e60c48e65..7fe521d35bc 100644 --- a/deps/v8/src/api/api-inl.h +++ b/deps/v8/src/api/api-inl.h @@ -22,14 +22,16 @@ inline T ToCData(v8::internal::Tagged obj) { static_assert(sizeof(T) == sizeof(v8::internal::Address)); if (obj == v8::internal::Smi::zero()) return nullptr; return reinterpret_cast( - v8::internal::Foreign::cast(obj)->foreign_address()); + v8::internal::Foreign::cast(obj) + ->foreign_address()); } template <> inline v8::internal::Address ToCData( v8::internal::Tagged obj) { if (obj == v8::internal::Smi::zero()) return v8::internal::kNullAddress; - return v8::internal::Foreign::cast(obj)->foreign_address(); + return v8::internal::Foreign::cast(obj) + ->foreign_address(); } template @@ -37,7 +39,7 @@ inline v8::internal::Handle FromCData( v8::internal::Isolate* isolate, T obj) { static_assert(sizeof(T) == sizeof(v8::internal::Address)); if (obj == nullptr) return handle(v8::internal::Smi::zero(), isolate); - return isolate->factory()->NewForeign( + return isolate->factory()->NewForeign( reinterpret_cast(obj)); } @@ -47,7 +49,7 @@ inline v8::internal::Handle FromCData( if (obj == v8::internal::kNullAddress) { return handle(v8::internal::Smi::zero(), isolate); } - return isolate->factory()->NewForeign(obj); + return isolate->factory()->NewForeign(obj); } template diff --git a/deps/v8/src/api/api-natives.cc b/deps/v8/src/api/api-natives.cc index e3ff723b53e..23ca54bd94d 100644 --- a/deps/v8/src/api/api-natives.cc +++ b/deps/v8/src/api/api-natives.cc @@ -5,6 +5,7 @@ #include "src/api/api-natives.h" #include "src/api/api-inl.h" +#include "src/common/globals.h" #include "src/common/message-template.h" #include "src/execution/isolate-inl.h" #include "src/execution/protectors-inl.h" @@ -139,7 +140,7 @@ void DisableAccessChecks(Isolate* isolate, Handle object) { // Copy map so it won't interfere constructor's initial map. Handle new_map = Map::Copy(isolate, old_map, "DisableAccessChecks"); new_map->set_is_access_check_needed(false); - JSObject::MigrateToMap(isolate, Handle::cast(object), new_map); + JSObject::MigrateToMap(isolate, object, new_map); } void EnableAccessChecks(Isolate* isolate, Handle object) { @@ -339,10 +340,16 @@ MaybeHandle InstantiateObject(Isolate* isolate, if (new_target.is_null()) new_target = constructor; } + const auto new_js_object_type = + constructor->has_initial_map() && + IsJSApiWrapperObject(constructor->initial_map()) + ? NewJSObjectType::kAPIWrapper + : NewJSObjectType::kNoAPIWrapper; Handle object; ASSIGN_RETURN_ON_EXCEPTION( isolate, object, - JSObject::New(constructor, new_target, Handle::null()), + JSObject::New(constructor, new_target, Handle::null(), + new_js_object_type), JSObject); if (is_prototype) JSObject::OptimizeAsPrototype(object); @@ -530,14 +537,16 @@ MaybeHandle ApiNatives::InstantiateRemoteObject( FunctionTemplateInfo::cast(data->constructor()), isolate); Handle object_map = isolate->factory()->NewContextlessMap( JS_SPECIAL_API_OBJECT_TYPE, - JSObject::kHeaderSize + + JSSpecialObject::kHeaderSize + data->embedder_field_count() * kEmbedderDataSlotSize, TERMINAL_FAST_ELEMENTS_KIND); object_map->SetConstructor(*constructor); object_map->set_is_access_check_needed(true); object_map->set_may_have_interesting_properties(true); - Handle object = isolate->factory()->NewJSObjectFromMap(object_map); + Handle object = isolate->factory()->NewJSObjectFromMap( + object_map, AllocationType::kYoung, DirectHandle::null(), + NewJSObjectType::kAPIWrapper); JSObject::ForceSetPrototype(isolate, object, isolate->factory()->null_value()); diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index a7070c494c2..fed54a46578 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -568,21 +568,25 @@ Isolate* SnapshotCreator::GetIsolate() { void SnapshotCreator::SetDefaultContext( Local context, SerializeInternalFieldsCallback internal_fields_serializer, - SerializeContextDataCallback context_data_serializer) { + SerializeContextDataCallback context_data_serializer, + SerializeAPIWrapperCallback api_wrapper_serializer) { impl_->SetDefaultContext( Utils::OpenHandle(*context), i::SerializeEmbedderFieldsCallback(internal_fields_serializer, - context_data_serializer)); + context_data_serializer, + api_wrapper_serializer)); } size_t SnapshotCreator::AddContext( Local context, SerializeInternalFieldsCallback internal_fields_serializer, - SerializeContextDataCallback context_data_serializer) { + SerializeContextDataCallback context_data_serializer, + SerializeAPIWrapperCallback api_wrapper_serializer) { return impl_->AddContext( Utils::OpenHandle(*context), i::SerializeEmbedderFieldsCallback(internal_fields_serializer, - context_data_serializer)); + context_data_serializer, + api_wrapper_serializer)); } size_t SnapshotCreator::AddData(i::Address object) { @@ -615,7 +619,6 @@ void V8::SetFlagsFromString(const char* str) { void V8::SetFlagsFromString(const char* str, size_t length) { i::FlagList::SetFlagsFromString(str, length); - i::FlagList::EnforceFlagImplications(); } void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { @@ -726,7 +729,7 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, namespace api_internal { void StackAllocated::VerifyOnStack() const { if (internal::StackAllocatedCheck::Get()) { - internal::HandleHelper::VerifyOnStack(this); + DCHECK(::heap::base::Stack::IsOnStack(this)); } } } // namespace api_internal @@ -760,22 +763,6 @@ void DisposeTracedReference(internal::Address* location) { TracedHandles::Destroy(location); } -// static -bool HandleHelper::IsOnStack(const void* ptr) { - return v8::base::Stack::GetCurrentStackPosition() <= ptr && - ptr <= v8::base::Stack::GetStackStartUnchecked(); -} - -// static -void HandleHelper::VerifyOnStack(const void* ptr) { DCHECK(IsOnStack(ptr)); } - -// static -void HandleHelper::VerifyOnMainThread() { - // The following verifies that we are on the main thread, as - // LocalHeap::Current is not set in that case. - DCHECK_NULL(LocalHeap::Current()); -} - #if V8_STATIC_ROOTS_BOOL // Check static root constants exposed in v8-internal.h. @@ -1135,8 +1122,8 @@ void Context::SetAlignedPointerInEmbedderData(int index, void* value) { i::Isolate* i_isolate = Utils::OpenDirectHandle(this)->GetIsolate(); i::Handle data = EmbedderDataFor(this, index, true, location); - bool ok = - i::EmbedderDataSlot(*data, index).store_aligned_pointer(i_isolate, value); + bool ok = i::EmbedderDataSlot(*data, index) + .store_aligned_pointer(i_isolate, *data, value); Utils::ApiCheck(ok, location, "Pointer is not aligned"); DCHECK_EQ(value, GetAlignedPointerFromEmbedderData(index)); } @@ -1600,41 +1587,6 @@ void TemplateSetAccessor(Template* template_obj, v8::Local name, } } // namespace -void Template::SetNativeDataProperty(v8::Local name, - AccessorGetterCallback getter, - AccessorSetterCallback setter, - v8::Local data, - PropertyAttribute attribute, - v8::AccessControl settings, - SideEffectType getter_side_effect_type, - SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, setter, data, attribute, true, false, - getter_side_effect_type, setter_side_effect_type); -} - -void Template::SetNativeDataProperty(v8::Local name, - AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter, - v8::Local data, - PropertyAttribute attribute, - v8::AccessControl settings, - SideEffectType getter_side_effect_type, - SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, setter, data, attribute, true, false, - getter_side_effect_type, setter_side_effect_type); -} - -void Template::SetNativeDataProperty(v8::Local name, - AccessorGetterCallback getter, - AccessorSetterCallback setter, - v8::Local data, - PropertyAttribute attribute, - SideEffectType getter_side_effect_type, - SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, setter, data, attribute, true, false, - getter_side_effect_type, setter_side_effect_type); -} - void Template::SetNativeDataProperty(v8::Local name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter, @@ -1669,18 +1621,6 @@ void Template::SetIntrinsicDataProperty(Local name, Intrinsic intrinsic, static_cast(attribute)); } -void ObjectTemplate::SetAccessor(v8::Local name, - AccessorGetterCallback getter, - AccessorSetterCallback setter, - v8::Local data, - PropertyAttribute attribute, - SideEffectType getter_side_effect_type, - SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, setter, data, attribute, - i::v8_flags.disable_old_api_accessors, false, - getter_side_effect_type, setter_side_effect_type); -} - void ObjectTemplate::SetAccessor(v8::Local name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter, @@ -2230,6 +2170,36 @@ std::vector Script::GetProducedCompileHints() const { return result; } +Local Script::GetCompileHintsCollector() const { + i::DisallowGarbageCollection no_gc; + auto func = Utils::OpenDirectHandle(this); + i::Isolate* i_isolate = func->GetIsolate(); + i::Tagged sfi = func->shared(); + CHECK(IsScript(sfi->script())); + i::Handle script(i::Script::cast(sfi->script()), i_isolate); + return ToApiHandle(script); +} + +std::vector CompileHintsCollector::GetCompileHints( + Isolate* v8_isolate) const { + i::DisallowGarbageCollection no_gc; + auto script = Utils::OpenDirectHandle(this); + i::Isolate* i_isolate = reinterpret_cast(v8_isolate); + i::Tagged maybe_array_list = + script->compiled_lazy_function_positions(); + std::vector result; + if (!IsUndefined(maybe_array_list, i_isolate)) { + i::Tagged array_list = i::ArrayList::cast(maybe_array_list); + result.reserve(array_list->length()); + for (int i = 0; i < array_list->length(); ++i) { + i::Tagged item = array_list->get(i); + CHECK(IsSmi(item)); + result.push_back(i::Smi::ToInt(item)); + } + } + return result; +} + // static Local PrimitiveArray::New(Isolate* v8_isolate, int length) { i::Isolate* i_isolate = reinterpret_cast(v8_isolate); @@ -2663,119 +2633,68 @@ MaybeLocal ScriptCompiler::CompileModule( // static V8_WARN_UNUSED_RESULT MaybeLocal ScriptCompiler::CompileFunction( - Local context, Source* source, size_t arguments_count, - Local arguments[], size_t context_extension_count, - Local context_extensions[], CompileOptions options, - NoCacheReason no_cache_reason) { - return CompileFunctionInternal(context, source, arguments_count, arguments, - context_extension_count, context_extensions, - options, no_cache_reason, nullptr); -} - -#ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME -// static -MaybeLocal ScriptCompiler::CompileFunctionInContext( - Local context, Source* source, size_t arguments_count, - Local arguments[], size_t context_extension_count, - Local context_extensions[], CompileOptions options, - NoCacheReason no_cache_reason, - Local* script_or_module_out) { - return CompileFunctionInternal( - context, source, arguments_count, arguments, context_extension_count, - context_extensions, options, no_cache_reason, script_or_module_out); -} -#endif // V8_SCRIPTORMODULE_LEGACY_LIFETIME - -MaybeLocal ScriptCompiler::CompileFunctionInternal( Local v8_context, Source* source, size_t arguments_count, Local arguments[], size_t context_extension_count, Local context_extensions[], CompileOptions options, - NoCacheReason no_cache_reason, - Local* script_or_module_out) { - Local result; - - { - PREPARE_FOR_EXECUTION(v8_context, ScriptCompiler, CompileFunction); - TRACE_EVENT_CALL_STATS_SCOPED(i_isolate, "v8", "V8.ScriptCompiler"); + NoCacheReason no_cache_reason) { + PREPARE_FOR_EXECUTION(v8_context, ScriptCompiler, CompileFunction); + TRACE_EVENT_CALL_STATS_SCOPED(i_isolate, "v8", "V8.ScriptCompiler"); - DCHECK(options == CompileOptions::kConsumeCodeCache || - options == CompileOptions::kEagerCompile || - options == CompileOptions::kNoCompileOptions); + DCHECK(options == CompileOptions::kConsumeCodeCache || + options == CompileOptions::kEagerCompile || + options == CompileOptions::kNoCompileOptions); - i::Handle context = Utils::OpenHandle(*v8_context); + i::Handle context = Utils::OpenHandle(*v8_context); - DCHECK(IsNativeContext(*context)); + DCHECK(IsNativeContext(*context)); - i::Handle arguments_list = - i_isolate->factory()->NewFixedArray(static_cast(arguments_count)); - for (int i = 0; i < static_cast(arguments_count); i++) { - auto argument = Utils::OpenHandle(*arguments[i]); - if (!i::String::IsIdentifier(i_isolate, argument)) - return Local(); - arguments_list->set(i, *argument); - } + i::Handle arguments_list = + i_isolate->factory()->NewFixedArray(static_cast(arguments_count)); + for (int i = 0; i < static_cast(arguments_count); i++) { + auto argument = Utils::OpenHandle(*arguments[i]); + if (!i::String::IsIdentifier(i_isolate, argument)) return Local(); + arguments_list->set(i, *argument); + } - for (size_t i = 0; i < context_extension_count; ++i) { - i::Handle extension = - Utils::OpenHandle(*context_extensions[i]); - if (!IsJSObject(*extension)) return Local(); - context = i_isolate->factory()->NewWithContext( - context, - i::ScopeInfo::CreateForWithScope( - i_isolate, - IsNativeContext(*context) - ? i::Handle::null() - : i::Handle(context->scope_info(), i_isolate)), - extension); - } + for (size_t i = 0; i < context_extension_count; ++i) { + i::Handle extension = + Utils::OpenHandle(*context_extensions[i]); + if (!IsJSObject(*extension)) return Local(); + context = i_isolate->factory()->NewWithContext( + context, + i::ScopeInfo::CreateForWithScope( + i_isolate, + IsNativeContext(*context) + ? i::Handle::null() + : i::Handle(context->scope_info(), i_isolate)), + extension); + } - i::ScriptDetails script_details = GetScriptDetails( - i_isolate, source->resource_name, source->resource_line_offset, - source->resource_column_offset, source->source_map_url, - source->host_defined_options, source->resource_options); - script_details.wrapped_arguments = arguments_list; + i::ScriptDetails script_details = GetScriptDetails( + i_isolate, source->resource_name, source->resource_line_offset, + source->resource_column_offset, source->source_map_url, + source->host_defined_options, source->resource_options); + script_details.wrapped_arguments = arguments_list; - std::unique_ptr cached_data; - if (options == kConsumeCodeCache) { - DCHECK(source->cached_data); - // ScriptData takes care of pointer-aligning the data. - cached_data.reset(new i::AlignedCachedData(source->cached_data->data, - source->cached_data->length)); - } + std::unique_ptr cached_data; + if (options == kConsumeCodeCache) { + DCHECK(source->cached_data); + // ScriptData takes care of pointer-aligning the data. + cached_data.reset(new i::AlignedCachedData(source->cached_data->data, + source->cached_data->length)); + } - i::Handle scoped_result; - has_exception = - !i::Compiler::GetWrappedFunction( - Utils::OpenHandle(*source->source_string), context, script_details, - cached_data.get(), options, no_cache_reason) - .ToHandle(&scoped_result); - if (options == kConsumeCodeCache) { - source->cached_data->rejected = cached_data->rejected(); - } - RETURN_ON_FAILED_EXECUTION(Function); - result = handle_scope.Escape(Utils::CallableToLocal(scoped_result)); - } - // TODO(cbruni): remove script_or_module_out paramater - if (script_or_module_out != nullptr) { - auto function = - i::DirectHandle::cast(Utils::OpenDirectHandle(*result)); - i::Isolate* i_isolate = function->GetIsolate(); - i::Handle shared(function->shared(), i_isolate); - i::Handle script(i::Script::cast(shared->script()), i_isolate); - // TODO(cbruni, v8:12302): Avoid creating tempory ScriptOrModule objects. - auto script_or_module = i::Handle::cast( - i_isolate->factory()->NewStruct(i::SCRIPT_OR_MODULE_TYPE)); - script_or_module->set_resource_name(script->name()); - script_or_module->set_host_defined_options(script->host_defined_options()); -#ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME - i::Handle list = - i::handle(script->script_or_modules(), i_isolate); - list = i::ArrayList::Add(i_isolate, list, script_or_module); - script->set_script_or_modules(*list); -#endif // V8_SCRIPTORMODULE_LEGACY_LIFETIME - *script_or_module_out = v8::Utils::ToLocal(script_or_module); + i::Handle result; + has_exception = + !i::Compiler::GetWrappedFunction( + Utils::OpenHandle(*source->source_string), context, script_details, + cached_data.get(), options, no_cache_reason) + .ToHandle(&result); + if (options == kConsumeCodeCache) { + source->cached_data->rejected = cached_data->rejected(); } - return result; + RETURN_ON_FAILED_EXECUTION(Function); + return handle_scope.Escape(Utils::CallableToLocal(result)); } void ScriptCompiler::ScriptStreamingTask::Run() { data_->task->Run(); } @@ -3916,7 +3835,8 @@ MaybeLocal Value::ToDetailString(Local context) const { } if (i::IsString(*obj)) return ToApiHandle(obj); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); - return Utils::ToLocal(i::Object::NoSideEffectsToString(i_isolate, obj)); + return Utils::ToLocal(i::Object::NoSideEffectsToString(i_isolate, obj), + i_isolate); } MaybeLocal Value::ToObject(Local context) const { @@ -4512,23 +4432,23 @@ Maybe v8::Object::CreateDataProperty(v8::Local context, auto value_obj = Utils::OpenHandle(*value); i::PropertyKey lookup_key(i_isolate, key_obj); - i::LookupIterator it(i_isolate, self, lookup_key, i::LookupIterator::OWN); - if (i::IsJSProxy(*self)) { - ENTER_V8(i_isolate, context, Object, CreateDataProperty, i::HandleScope); - Maybe result = - i::JSReceiver::CreateDataProperty(&it, value_obj, Just(i::kDontThrow)); - has_exception = result.IsNothing(); - RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); - return result; - } else { + if (i::IsJSObject(*self)) { ENTER_V8_NO_SCRIPT(i_isolate, context, Object, CreateDataProperty, i::HandleScope); - Maybe result = - i::JSObject::CreateDataProperty(&it, value_obj, Just(i::kDontThrow)); + Maybe result = i::JSObject::CreateDataProperty( + i_isolate, i::Handle::cast(self), lookup_key, value_obj, + Just(i::kDontThrow)); has_exception = result.IsNothing(); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); return result; } + // JSProxy or WasmObject or other non-JSObject. + ENTER_V8(i_isolate, context, Object, CreateDataProperty, i::HandleScope); + Maybe result = i::JSReceiver::CreateDataProperty( + i_isolate, self, lookup_key, value_obj, Just(i::kDontThrow)); + has_exception = result.IsNothing(); + RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); + return result; } Maybe v8::Object::CreateDataProperty(v8::Local context, @@ -4538,23 +4458,24 @@ Maybe v8::Object::CreateDataProperty(v8::Local context, auto self = Utils::OpenHandle(this); auto value_obj = Utils::OpenHandle(*value); - i::LookupIterator it(i_isolate, self, index, self, i::LookupIterator::OWN); - if (i::IsJSProxy(*self)) { - ENTER_V8(i_isolate, context, Object, CreateDataProperty, i::HandleScope); - Maybe result = - i::JSReceiver::CreateDataProperty(&it, value_obj, Just(i::kDontThrow)); - has_exception = result.IsNothing(); - RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); - return result; - } else { + i::PropertyKey lookup_key(i_isolate, index); + if (i::IsJSObject(*self)) { ENTER_V8_NO_SCRIPT(i_isolate, context, Object, CreateDataProperty, i::HandleScope); - Maybe result = - i::JSObject::CreateDataProperty(&it, value_obj, Just(i::kDontThrow)); + Maybe result = i::JSObject::CreateDataProperty( + i_isolate, i::Handle::cast(self), lookup_key, value_obj, + Just(i::kDontThrow)); has_exception = result.IsNothing(); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); return result; } + // JSProxy or WasmObject or other non-JSObject. + ENTER_V8(i_isolate, context, Object, CreateDataProperty, i::HandleScope); + Maybe result = i::JSReceiver::CreateDataProperty( + i_isolate, self, lookup_key, value_obj, Just(i::kDontThrow)); + has_exception = result.IsNothing(); + RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); + return result; } struct v8::PropertyDescriptor::PrivateData { @@ -4665,15 +4586,7 @@ Maybe v8::Object::DefineOwnProperty(v8::Local context, desc.set_configurable(!(attributes & v8::DontDelete)); desc.set_value(value_obj); - if (i::IsJSProxy(*self)) { - ENTER_V8(i_isolate, context, Object, DefineOwnProperty, i::HandleScope); - Maybe success = i::JSReceiver::DefineOwnProperty( - i_isolate, self, key_obj, &desc, Just(i::kDontThrow)); - // Even though we said kDontThrow, there might be accessors that do throw. - has_exception = success.IsNothing(); - RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); - return success; - } else { + if (i::IsJSObject(*self)) { // If it's not a JSProxy, i::JSReceiver::DefineOwnProperty should never run // a script. ENTER_V8_NO_SCRIPT(i_isolate, context, Object, DefineOwnProperty, @@ -4684,6 +4597,14 @@ Maybe v8::Object::DefineOwnProperty(v8::Local context, RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); return success; } + // JSProxy or WasmObject or other non-JSObject. + ENTER_V8(i_isolate, context, Object, DefineOwnProperty, i::HandleScope); + Maybe success = i::JSReceiver::DefineOwnProperty( + i_isolate, self, key_obj, &desc, Just(i::kDontThrow)); + // Even though we said kDontThrow, there might be accessors that do throw. + has_exception = success.IsNothing(); + RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); + return success; } Maybe v8::Object::DefineProperty(v8::Local context, @@ -4709,6 +4630,15 @@ Maybe v8::Object::SetPrivate(Local context, Local key, auto self = Utils::OpenHandle(this); auto key_obj = Utils::OpenHandle(reinterpret_cast(*key)); auto value_obj = Utils::OpenHandle(*value); + if (i::IsJSObject(*self)) { + auto js_object = i::Handle::cast(self); + i::LookupIterator it(i_isolate, js_object, key_obj, js_object); + has_exception = i::JSObject::DefineOwnPropertyIgnoreAttributes( + &it, value_obj, i::DONT_ENUM) + .is_null(); + RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); + return Just(true); + } if (i::IsJSProxy(*self)) { i::PropertyDescriptor desc; desc.set_writable(true); @@ -4719,13 +4649,8 @@ Maybe v8::Object::SetPrivate(Local context, Local key, i_isolate, i::Handle::cast(self), i::Handle::cast(key_obj), &desc, Just(i::kDontThrow)); } - auto js_object = i::Handle::cast(self); - i::LookupIterator it(i_isolate, js_object, key_obj, js_object); - has_exception = i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value_obj, - i::DONT_ENUM) - .is_null(); - RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); - return Just(true); + // Wasm object, or other kind of special object not supported here. + return Just(false); } MaybeLocal v8::Object::Get(Local context, @@ -4799,11 +4724,39 @@ Local v8::Object::GetPrototype() { return Utils::ToLocal(i::PrototypeIterator::GetCurrent(iter)); } -Maybe v8::Object::SetPrototype(Local context, - Local value) { - auto i_isolate = reinterpret_cast(context->GetIsolate()); +Local v8::Object::GetPrototypeV2() { auto self = Utils::OpenHandle(this); + auto i_isolate = self->GetIsolate(); + i::PrototypeIterator iter(i_isolate, self); + if (i::IsJSGlobalProxy(*self)) { + // Skip hidden prototype (i.e. JSGlobalObject). + iter.Advance(); + } + DCHECK(!i::IsJSGlobalObject(*i::PrototypeIterator::GetCurrent(iter))); + return Utils::ToLocal(i::PrototypeIterator::GetCurrent(iter)); +} + +namespace { + +Maybe SetPrototypeImpl(v8::Object* this_, Local context, + Local value, bool from_javascript) { + auto i_isolate = reinterpret_cast(context->GetIsolate()); + auto self = Utils::OpenHandle(this_); auto value_obj = Utils::OpenHandle(*value); + // TODO(333672197): turn this to DCHECK once it's no longer possible + // to get JSGlobalObject via API. + CHECK_IMPLIES(from_javascript, !i::IsJSGlobalObject(*value_obj)); + if (i::IsJSObject(*self)) { + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + // TODO(333672197): turn this to DCHECK once it's no longer possible + // to get JSGlobalObject via API. + CHECK_IMPLIES(from_javascript, !i::IsJSGlobalObject(*self)); + auto result = + i::JSObject::SetPrototype(i_isolate, i::Handle::cast(self), + value_obj, from_javascript, i::kDontThrow); + if (!result.FromJust()) return Nothing(); + return Just(true); + } if (i::IsJSProxy(*self)) { ENTER_V8(i_isolate, context, Object, SetPrototype, i::HandleScope); // We do not allow exceptions thrown while setting the prototype @@ -4811,17 +4764,27 @@ Maybe v8::Object::SetPrototype(Local context, TryCatch try_catch(reinterpret_cast(i_isolate)); auto result = i::JSProxy::SetPrototype(i_isolate, i::Handle::cast(self), - value_obj, false, i::kThrowOnError); + value_obj, from_javascript, i::kThrowOnError); has_exception = result.IsNothing(); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); - } else { - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); - auto result = - i::JSObject::SetPrototype(i_isolate, i::Handle::cast(self), - value_obj, false, i::kDontThrow); - if (!result.FromJust()) return Nothing(); + return Just(true); } - return Just(true); + // Wasm object or other kind of special object not supported here. + return Nothing(); +} + +} // namespace + +Maybe v8::Object::SetPrototype(Local context, + Local value) { + static constexpr bool from_javascript = false; + return SetPrototypeImpl(this, context, value, from_javascript); +} + +Maybe v8::Object::SetPrototypeV2(Local context, + Local value) { + static constexpr bool from_javascript = true; + return SetPrototypeImpl(this, context, value, from_javascript); } Local v8::Object::FindInstanceInPrototypeChain( @@ -4937,6 +4900,7 @@ Maybe v8::Object::Delete(Local context, Local key) { } else { // If it's not a JSProxy, i::Runtime::DeleteObjectProperty should never run // a script. + DCHECK(i::IsJSObject(*self) || i::IsWasmObject(*self)); ENTER_V8_NO_SCRIPT(i_isolate, context, Object, Delete, i::HandleScope); Maybe result = i::Runtime::DeleteObjectProperty( i_isolate, self, key_obj, i::LanguageMode::kSloppy); @@ -5270,39 +5234,77 @@ Local v8::Object::Clone() { return Utils::ToLocal(result); } -MaybeLocal v8::Object::GetCreationContext() { - auto self = Utils::OpenDirectHandle(this); - auto i_isolate = self->GetIsolate(); +namespace { +V8_INLINE MaybeLocal GetCreationContextImpl( + i::DirectHandle object, i::Isolate* i_isolate) { i::Handle context; - if (self->GetCreationContext(i_isolate).ToHandle(&context)) { + if (object->GetCreationContext(i_isolate).ToHandle(&context)) { return Utils::ToLocal(context); } return MaybeLocal(); } +} // namespace -void* v8::Object::GetAlignedPointerFromEmbedderDataInCreationContext( +MaybeLocal v8::Object::GetCreationContext(v8::Isolate* isolate) { + auto self = Utils::OpenDirectHandle(this); + auto i_isolate = reinterpret_cast(isolate); + return GetCreationContextImpl(self, i_isolate); +} + +MaybeLocal v8::Object::GetCreationContext() { + auto self = Utils::OpenDirectHandle(this); + return GetCreationContextImpl(self, self->GetIsolate()); +} + +namespace { +V8_INLINE Local GetCreationContextCheckedImpl( + i::DirectHandle object, i::Isolate* i_isolate) { + i::Handle context; + Utils::ApiCheck(object->GetCreationContext(i_isolate).ToHandle(&context), + "v8::Object::GetCreationContextChecked", + "No creation context available"); + return Utils::ToLocal(context); +} +} // namespace + +Local v8::Object::GetCreationContextChecked(v8::Isolate* isolate) { + auto self = Utils::OpenDirectHandle(this); + auto i_isolate = reinterpret_cast(isolate); + return GetCreationContextCheckedImpl(self, i_isolate); +} + +Local v8::Object::GetCreationContextChecked() { + auto self = Utils::OpenDirectHandle(this); + return GetCreationContextCheckedImpl(self, self->GetIsolate()); +} + +namespace { +V8_INLINE void* GetAlignedPointerFromEmbedderDataInCreationContextImpl( + i::DirectHandle object, i::Isolate* i_isolate_for_sandbox, int index) { const char* location = "v8::Object::GetAlignedPointerFromEmbedderDataInCreationContext()"; - auto maybe_context = Utils::OpenDirectHandle(this)->GetCreationContext(); + auto maybe_context = object->GetCreationContext(); if (!maybe_context.has_value()) return nullptr; // The code below mostly mimics Context::GetAlignedPointerFromEmbedderData() // but it doesn't try to expand the EmbedderDataArray instance. i::DisallowGarbageCollection no_gc; i::Tagged native_context = maybe_context.value(); - i::Isolate* i_isolate = native_context->GetIsolate(); - DCHECK_NO_SCRIPT_NO_EXCEPTION(i_isolate); + // This macro requires a real Isolate while |i_isolate_for_sandbox| might be + // nullptr if the V8 sandbox is not enabled. + DCHECK_NO_SCRIPT_NO_EXCEPTION(native_context->GetIsolate()); + // TODO(ishell): remove cast once embedder_data slot has a proper type. i::Tagged data = i::EmbedderDataArray::cast(native_context->embedder_data()); if (V8_LIKELY(static_cast(index) < static_cast(data->length()))) { void* result; - Utils::ApiCheck( - i::EmbedderDataSlot(data, index).ToAlignedPointer(i_isolate, &result), - location, "Pointer is not aligned"); + Utils::ApiCheck(i::EmbedderDataSlot(data, index) + .ToAlignedPointer(i_isolate_for_sandbox, &result), + location, "Pointer is not aligned"); return result; } // Bad index, report an API error. @@ -5311,13 +5313,23 @@ void* v8::Object::GetAlignedPointerFromEmbedderDataInCreationContext( "Index too large"); return nullptr; } +} // namespace + +void* v8::Object::GetAlignedPointerFromEmbedderDataInCreationContext( + v8::Isolate* isolate, int index) { + auto self = Utils::OpenDirectHandle(this); + auto i_isolate = reinterpret_cast(isolate); + return GetAlignedPointerFromEmbedderDataInCreationContextImpl(self, i_isolate, + index); +} -Local v8::Object::GetCreationContextChecked() { - Local context; - Utils::ApiCheck(GetCreationContext().ToLocal(&context), - "v8::Object::GetCreationContextChecked", - "No creation context available"); - return context; +void* v8::Object::GetAlignedPointerFromEmbedderDataInCreationContext( + int index) { + auto self = Utils::OpenDirectHandle(this); + auto i_isolate_for_sandbox = + reinterpret_cast(GetIsolateForSandbox(*self)); + return GetAlignedPointerFromEmbedderDataInCreationContextImpl( + self, i_isolate_for_sandbox, index); } int v8::Object::GetIdentityHash() { @@ -5338,13 +5350,15 @@ bool v8::Object::IsConstructor() const { } bool v8::Object::IsApiWrapper() const { - auto self = i::DirectHandle::cast(Utils::OpenDirectHandle(this)); - // Objects with embedder fields can wrap API objects. - return self->MayHaveEmbedderFields(); + auto self = Utils::OpenDirectHandle(this); + // This checks whether an object of a given instance type can serve as API + // object. It does not check whether the JS object is wrapped via embedder + // fields or Wrap()/Unwrap() API. + return IsJSApiWrapperObject(*self); } bool v8::Object::IsUndetectable() const { - auto self = i::DirectHandle::cast(Utils::OpenDirectHandle(this)); + auto self = Utils::OpenDirectHandle(this); return i::IsUndetectable(*self); } @@ -5591,14 +5605,6 @@ int Function::GetScriptStartPosition() const { return kLineOffsetNotFound; } -MaybeLocal Function::GetUnboundScript() const { - auto self = *Utils::OpenDirectHandle(this); - if (!IsJSFunction(self)) return MaybeLocal(); - auto sfi = i::JSFunction::cast(self)->shared(); - i::Isolate* isolate = self->GetIsolate(); - return ToApiHandle(i::direct_handle(sfi, isolate), isolate); -} - int Function::ScriptId() const { auto self = *Utils::OpenDirectHandle(this); if (!IsJSFunction(self)) return v8::UnboundScript::kNoScriptId; @@ -6325,7 +6331,7 @@ void v8::Object::SetAlignedPointerInInternalField(int index, void* value) { i::DisallowGarbageCollection no_gc; Utils::ApiCheck(i::EmbedderDataSlot(i::JSObject::cast(*obj), index) - .store_aligned_pointer(obj->GetIsolate(), value), + .store_aligned_pointer(obj->GetIsolate(), *obj, value), location, "Unaligned pointer"); DCHECK_EQ(value, GetAlignedPointerFromInternalField(index)); internal::WriteBarrier::CombinedBarrierFromInternalFields( @@ -6335,7 +6341,7 @@ void v8::Object::SetAlignedPointerInInternalField(int index, void* value) { void v8::Object::SetAlignedPointerInInternalFields(int argc, int indices[], void* values[]) { auto obj = Utils::OpenDirectHandle(this); - + if (!IsJSObject(*obj)) return; i::DisallowGarbageCollection no_gc; const char* location = "v8::Object::SetAlignedPointerInInternalFields()"; auto js_obj = i::JSObject::cast(*obj); @@ -6348,7 +6354,7 @@ void v8::Object::SetAlignedPointerInInternalFields(int argc, int indices[], } void* value = values[i]; Utils::ApiCheck(i::EmbedderDataSlot(js_obj, index) - .store_aligned_pointer(obj->GetIsolate(), value), + .store_aligned_pointer(obj->GetIsolate(), *obj, value), location, "Unaligned pointer"); DCHECK_EQ(value, GetAlignedPointerFromInternalField(index)); } @@ -6356,6 +6362,22 @@ void v8::Object::SetAlignedPointerInInternalFields(int argc, int indices[], values); } +// static +void* v8::Object::Unwrap(v8::Isolate* isolate, i::Address wrapper_obj, + CppHeapPointerTag tag) { + return i::JSApiWrapper(i::JSObject::cast(i::Tagged(wrapper_obj))) + .GetCppHeapWrappable(reinterpret_cast(isolate), + static_cast(tag)); +} + +// static +void v8::Object::Wrap(v8::Isolate* isolate, i::Address wrapper_obj, + CppHeapPointerTag tag, void* wrappable) { + return i::JSApiWrapper(i::JSObject::cast(i::Tagged(wrapper_obj))) + .SetCppHeapWrappable(reinterpret_cast(isolate), wrappable, + static_cast(tag)); +} + // --- E n v i r o n m e n t --- void v8::V8::InitializePlatform(Platform* platform) { @@ -6392,6 +6414,21 @@ bool v8::V8::Initialize(const int build_config) { V8_ENABLE_SANDBOX_BOOL ? "ENABLED" : "DISABLED"); } + const bool kEmbedderTargetOsIsAndroid = + (build_config & kTargetOsIsAndroid) != 0; +#ifdef V8_TARGET_OS_ANDROID + const bool kV8TargetOsIsAndroid = true; +#else + const bool kV8TargetOsIsAndroid = false; +#endif + if (kEmbedderTargetOsIsAndroid != kV8TargetOsIsAndroid) { + FATAL( + "Embedder-vs-V8 build configuration mismatch. On embedder side " + "target OS is %s while on V8 side it's %s.", + kEmbedderTargetOsIsAndroid ? "Android" : "not Android", + kV8TargetOsIsAndroid ? "Android" : "not Android"); + } + i::V8::Initialize(); return true; } @@ -6721,11 +6758,13 @@ Local v8::Context::New( v8::MaybeLocal global_object, v8::DeserializeInternalFieldsCallback internal_fields_deserializer, v8::MicrotaskQueue* microtask_queue, - v8::DeserializeContextDataCallback context_callback_deserializer) { + v8::DeserializeContextDataCallback context_callback_deserializer, + v8::DeserializeAPIWrapperCallback api_wrapper_deserializer) { return NewContext( external_isolate, extensions, global_template, global_object, 0, i::DeserializeEmbedderFieldsCallback(internal_fields_deserializer, - context_callback_deserializer), + context_callback_deserializer, + api_wrapper_deserializer), microtask_queue); } @@ -6734,7 +6773,8 @@ MaybeLocal v8::Context::FromSnapshot( v8::DeserializeInternalFieldsCallback internal_fields_deserializer, v8::ExtensionConfiguration* extensions, MaybeLocal global_object, v8::MicrotaskQueue* microtask_queue, - v8::DeserializeContextDataCallback context_callback_deserializer) { + v8::DeserializeContextDataCallback context_callback_deserializer, + v8::DeserializeAPIWrapperCallback api_wrapper_deserializer) { size_t index_including_default_context = context_snapshot_index + 1; if (!i::Snapshot::HasContextSnapshot( reinterpret_cast(external_isolate), @@ -6745,7 +6785,8 @@ MaybeLocal v8::Context::FromSnapshot( external_isolate, extensions, MaybeLocal(), global_object, index_including_default_context, i::DeserializeEmbedderFieldsCallback(internal_fields_deserializer, - context_callback_deserializer), + context_callback_deserializer, + api_wrapper_deserializer), microtask_queue); } @@ -6810,7 +6851,7 @@ bool RequiresEmbedderSupportToFreeze(i::InstanceType obj_type) { return (i::InstanceTypeChecker::IsJSApiObject(obj_type) || i::InstanceTypeChecker::IsJSExternalObject(obj_type) || - i::InstanceTypeChecker::IsJSObjectWithEmbedderSlots(obj_type)); + i::InstanceTypeChecker::IsJSAPIObjectWithEmbedderSlots(obj_type)); } bool IsJSReceiverSafeToFreeze(i::InstanceType obj_type) { @@ -6991,8 +7032,8 @@ class ObjectVisitorDeepFreezer : i::ObjectVisitor { // If not they could be replaced to bypass freezing. i::Tagged scope_info = i::Context::cast(obj)->scope_info(); for (auto it : i::ScopeInfo::IterateLocalNames(scope_info, no_gc)) { - if (scope_info->ContextLocalMode(it->index()) != - i::VariableMode::kConst) { + if (!IsImmutableLexicalVariableMode( + scope_info->ContextLocalMode(it->index()))) { DCHECK(!error_.has_value()); error_ = ErrorInfo{i::MessageTemplate::kCannotDeepFreezeValue, i::handle(it->name(), isolate_)}; @@ -7901,6 +7942,22 @@ MaybeLocal v8::Date::New(Local context, double time) { RETURN_ESCAPED(result); } +MaybeLocal v8::Date::Parse(Local context, + Local value) { + PREPARE_FOR_EXECUTION(context, Date, Parse); + auto string = Utils::OpenHandle(*value); + double time = ParseDateTimeString(i_isolate, string); + + Local result; + has_exception = + !ToLocal(i::JSDate::New(i_isolate->date_function(), + i_isolate->date_function(), time), + &result); + + RETURN_ON_FAILED_EXECUTION(Value) + RETURN_ESCAPED(result); +} + double v8::Date::ValueOf() const { auto obj = Utils::OpenDirectHandle(this); auto jsdate = i::DirectHandle::cast(obj); @@ -7922,6 +7979,20 @@ v8::Local v8::Date::ToISOString() const { return Utils::ToLocal(str); } +v8::Local v8::Date::ToUTCString() const { + auto obj = Utils::OpenDirectHandle(this); + auto jsdate = i::DirectHandle::cast(obj); + i::Isolate* i_isolate = jsdate->GetIsolate(); + API_RCS_SCOPE(i_isolate, Date, NumberValue); + i::DateBuffer buffer = i::ToDateString(i::Object::Number(jsdate->value()), + i_isolate->date_cache(), + i::ToDateStringMode::kUTCDateAndTime); + i::Handle str = i_isolate->factory() + ->NewStringFromUtf8(base::VectorOf(buffer)) + .ToHandleChecked(); + return Utils::ToLocal(str); +} + // Assert that the static TimeZoneDetection cast in // DateTimeConfigurationChangeNotification is valid. #define TIME_ZONE_DETECTION_ASSERT_EQ(value) \ @@ -8754,8 +8825,7 @@ MaybeLocal WasmModuleObject::FromCompiledModule( i::wasm::GetWasmEngine()->ImportNativeModule( i_isolate, compiled_module.native_module_, base::VectorOf(compiled_module.source_url())); - return Local::Cast( - Utils::ToLocal(i::Handle::cast(module_object))); + return Utils::ToLocal(module_object); #else UNREACHABLE(); #endif // V8_ENABLE_WEBASSEMBLY @@ -8770,7 +8840,7 @@ MaybeLocal WasmModuleObject::Compile( if (!i::wasm::IsWasmCodegenAllowed(i_isolate, i_isolate->native_context())) { return MaybeLocal(); } - i::MaybeHandle maybe_compiled; + i::MaybeHandle maybe_compiled; { i::wasm::ErrorThrower thrower(i_isolate, "WasmModuleObject::Compile()"); auto enabled_features = i::wasm::WasmFeatures::FromIsolate(i_isolate); @@ -8783,8 +8853,7 @@ MaybeLocal WasmModuleObject::Compile( if (maybe_compiled.is_null()) { return MaybeLocal(); } - return Local::Cast( - Utils::ToLocal(maybe_compiled.ToHandleChecked())); + return Utils::ToLocal(maybe_compiled.ToHandleChecked()); #else Utils::ApiCheck(false, "WasmModuleObject::Compile", "WebAssembly support is not enabled"); @@ -8953,9 +9022,6 @@ std::unique_ptr v8::ArrayBuffer::NewBackingStore( // static std::unique_ptr v8::ArrayBuffer::NewResizableBackingStore( size_t byte_length, size_t max_byte_length) { - Utils::ApiCheck(i::v8_flags.harmony_rab_gsab, - "v8::ArrayBuffer::NewResizableBackingStore", - "Constructing resizable ArrayBuffers is not supported"); Utils::ApiCheck(byte_length <= max_byte_length, "v8::ArrayBuffer::NewResizableBackingStore", "Cannot construct resizable ArrayBuffer, byte_length must be " @@ -9752,6 +9818,14 @@ void Isolate::Dispose() { void Isolate::DumpAndResetStats() { i::Isolate* i_isolate = reinterpret_cast(this); +#ifdef DEBUG + // This method might be called on a thread that's not bound to any Isolate + // and thus pointer compression schemes might have cage base value unset. + // Read-only roots accessors contain type DCHECKs which require access to + // V8 heap in order to check the object type. So, allow heap access here + // to let the checks work. + i::PtrComprCageAccessScope ptr_compr_cage_access_scope(i_isolate); +#endif // DEBUG i_isolate->DumpAndResetStats(); } @@ -10235,14 +10309,6 @@ void Isolate::SetAddCrashKeyCallback(AddCrashKeyCallback callback) { i_isolate->SetAddCrashKeyCallback(callback); } -bool Isolate::IdleNotificationDeadline(double deadline_in_seconds) { - // Returning true tells the caller that it need not - // continue to call IdleNotification. - i::Isolate* i_isolate = reinterpret_cast(this); - if (!i::v8_flags.use_idle_notification) return true; - return i_isolate->heap()->IdleNotification(deadline_in_seconds); -} - void Isolate::LowMemoryNotification() { i::Isolate* i_isolate = reinterpret_cast(this); { @@ -10276,6 +10342,7 @@ int Isolate::ContextDisposedNotification(bool dependant_context) { } } #endif // V8_ENABLE_WEBASSEMBLY + i_isolate->AbortConcurrentOptimization(i::BlockingBehavior::kDontBlock); // TODO(ahaas): move other non-heap activity out of the heap call. return i_isolate->heap()->NotifyContextDisposed(dependant_context); } @@ -10412,7 +10479,7 @@ CALLBACK_SETTER(FatalErrorHandler, FatalErrorCallback, exception_behavior) CALLBACK_SETTER(OOMErrorHandler, OOMErrorCallback, oom_behavior) CALLBACK_SETTER(ModifyCodeGenerationFromStringsCallback, ModifyCodeGenerationFromStringsCallback2, - modify_code_gen_callback2) + modify_code_gen_callback) CALLBACK_SETTER(AllowWasmCodeGenerationCallback, AllowWasmCodeGenerationCallback, allow_wasm_code_gen_callback) @@ -10496,7 +10563,8 @@ bool Isolate::AddMessageListenerWithErrorLevel(MessageCallback that, i::Handle list = i_isolate->factory()->message_listeners(); i::Handle listener = i_isolate->factory()->NewFixedArray(3); i::Handle foreign = - i_isolate->factory()->NewForeign(FUNCTION_ADDR(that)); + i_isolate->factory()->NewForeign( + FUNCTION_ADDR(that)); listener->set(0, *foreign); listener->set(1, data.IsEmpty() ? i::ReadOnlyRoots(i_isolate).undefined_value() @@ -10519,7 +10587,8 @@ void Isolate::RemoveMessageListeners(MessageCallback that) { } i::Tagged listener = i::FixedArray::cast(listeners->get(i)); i::Tagged callback_obj = i::Foreign::cast(listener->get(0)); - if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) { + if (callback_obj->foreign_address() == + FUNCTION_ADDR(that)) { listeners->set(i, i::ReadOnlyRoots(i_isolate).undefined_value()); } } @@ -10606,10 +10675,6 @@ std::unique_ptr MicrotaskQueue::New(Isolate* v8_isolate, return ret; } -MicrotasksScope::MicrotasksScope(Isolate* v8_isolate, - MicrotasksScope::Type type) - : MicrotasksScope(v8_isolate, nullptr, type) {} - MicrotasksScope::MicrotasksScope(Local v8_context, MicrotasksScope::Type type) : MicrotasksScope(v8_context->GetIsolate(), v8_context->GetMicrotaskQueue(), @@ -10750,6 +10815,27 @@ Local Exception::GetStackTrace(Local exception) { return Utils::StackTraceToLocal(i_isolate->GetDetailedStackTrace(js_obj)); } +Maybe Exception::CaptureStackTrace(Local context, + Local object) { + auto i_isolate = reinterpret_cast(context->GetIsolate()); + ENTER_V8_NO_SCRIPT(i_isolate, context, Exception, CaptureStackTrace, + i::HandleScope); + auto obj = Utils::OpenHandle(*object); + if (!IsJSObject(*obj)) return Just(false); + + auto js_obj = i::Handle::cast(obj); + + i::FrameSkipMode mode = i::FrameSkipMode::SKIP_FIRST; + + auto result = i::ErrorUtils::CaptureStackTrace(i_isolate, js_obj, mode, + i::Handle()); + + i::Handle handle; + has_exception = !result.ToHandle(&handle); + RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); + return Just(true); +} + v8::MaybeLocal v8::Object::PreviewEntries(bool* is_key_value) { auto object = Utils::OpenHandle(this); i::Isolate* i_isolate = object->GetIsolate(); @@ -11358,6 +11444,12 @@ void HeapProfiler::DeleteAllHeapSnapshots() { reinterpret_cast(this)->DeleteAllSnapshots(); } +v8::EmbedderGraph::Node* v8::EmbedderGraph::V8Node( + const v8::Local& data) { + CHECK(data->IsValue()); + return V8Node(data.As()); +} + void HeapProfiler::AddBuildEmbedderGraphCallback( BuildEmbedderGraphCallback callback, void* data) { reinterpret_cast(this)->AddBuildEmbedderGraphCallback( @@ -11789,7 +11881,7 @@ bool ValidateFunctionCallbackInfo(const FunctionCallbackInfo& info) { CHECK_EQ(i_isolate, Isolate::Current()); CHECK(!i_isolate->GetIncumbentContext().is_null()); CHECK(info.This()->IsValue()); - CHECK(info.Holder()->IsObject()); + CHECK(info.HolderSoonToBeDeprecated()->IsObject()); CHECK(!info.Data().IsEmpty()); CHECK(info.GetReturnValue().Get()->IsValue()); return true; diff --git a/deps/v8/src/api/api.h b/deps/v8/src/api/api.h index 40b419db777..ad7f590dc63 100644 --- a/deps/v8/src/api/api.h +++ b/deps/v8/src/api/api.h @@ -127,7 +127,8 @@ class RegisteredExtension { V(ToLocalPrimitive, Object, Primitive) \ V(FixedArrayToLocal, FixedArray, FixedArray) \ V(PrimitiveArrayToLocal, FixedArray, PrimitiveArray) \ - V(ToLocal, ScriptOrModule, ScriptOrModule) + V(ToLocal, ScriptOrModule, ScriptOrModule) \ + IF_WASM(V, ToLocal, WasmModuleObject, WasmModuleObject) #define OPEN_HANDLE_LIST(V) \ V(Template, TemplateInfo) \ @@ -164,6 +165,7 @@ class RegisteredExtension { V(UnboundScript, SharedFunctionInfo) \ V(Module, Module) \ V(Function, JSReceiver) \ + V(CompileHintsCollector, Script) \ V(Message, JSMessageObject) \ V(Context, NativeContext) \ V(External, Object) \ diff --git a/deps/v8/src/asmjs/asm-parser.cc b/deps/v8/src/asmjs/asm-parser.cc index c5ff60d671f..e3bfd13b1f9 100644 --- a/deps/v8/src/asmjs/asm-parser.cc +++ b/deps/v8/src/asmjs/asm-parser.cc @@ -78,7 +78,7 @@ AsmJsParser::AsmJsParser(Zone* zone, uintptr_t stack_limit, stack_limit_(stack_limit), block_stack_(zone), global_imports_(zone) { - module_builder_->SetMinMemorySize(0); + module_builder_->AddMemory(0); InitializeStdlibTypes(); } diff --git a/deps/v8/src/ast/ast-value-factory.h b/deps/v8/src/ast/ast-value-factory.h index b7bdc33b160..3edc5a796bc 100644 --- a/deps/v8/src/ast/ast-value-factory.h +++ b/deps/v8/src/ast/ast-value-factory.h @@ -36,6 +36,7 @@ #include "src/handles/handles.h" #include "src/numbers/conversions.h" #include "src/objects/name.h" +#include "src/zone/zone.h" // Ast(Raw|Cons)String and AstValueFactory are for storing strings and // values independent of the V8 heap and internalizing them later. During diff --git a/deps/v8/src/ast/prettyprinter.cc b/deps/v8/src/ast/prettyprinter.cc index 2876beb19e6..1b0da392660 100644 --- a/deps/v8/src/ast/prettyprinter.cc +++ b/deps/v8/src/ast/prettyprinter.cc @@ -20,7 +20,7 @@ namespace internal { CallPrinter::CallPrinter(Isolate* isolate, bool is_user_js, SpreadErrorInArgsHint error_in_spread_args) - : builder_(new IncrementalStringBuilder(isolate)) { + : builder_(isolate) { isolate_ = isolate; position_ = 0; num_prints_ = 0; @@ -55,7 +55,7 @@ Handle CallPrinter::Print(FunctionLiteral* program, int position) { num_prints_ = 0; position_ = position; Find(program); - return builder_->Finish().ToHandleChecked(); + return indirect_handle(builder_.Finish().ToHandleChecked(), isolate_); } @@ -75,19 +75,19 @@ void CallPrinter::Find(AstNode* node, bool print) { void CallPrinter::Print(char c) { if (!found_ || done_) return; num_prints_++; - builder_->AppendCharacter(c); + builder_.AppendCharacter(c); } void CallPrinter::Print(const char* str) { if (!found_ || done_) return; num_prints_++; - builder_->AppendCString(str); + builder_.AppendCString(str); } void CallPrinter::Print(Handle str) { if (!found_ || done_) return; num_prints_++; - builder_->AppendString(str); + builder_.AppendString(str); } void CallPrinter::VisitBlock(Block* node) { diff --git a/deps/v8/src/ast/prettyprinter.h b/deps/v8/src/ast/prettyprinter.h index efb8b7a9904..3baaed1bc85 100644 --- a/deps/v8/src/ast/prettyprinter.h +++ b/deps/v8/src/ast/prettyprinter.h @@ -5,18 +5,15 @@ #ifndef V8_AST_PRETTYPRINTER_H_ #define V8_AST_PRETTYPRINTER_H_ -#include - #include "src/ast/ast.h" #include "src/base/compiler-specific.h" #include "src/execution/isolate.h" #include "src/objects/function-kind.h" +#include "src/strings/string-builder.h" namespace v8 { namespace internal { -class IncrementalStringBuilder; // to avoid including string-builder-inl.h - class CallPrinter final : public AstVisitor { public: enum class SpreadErrorInArgsHint { kErrorInArgs, kNoErrorInArgs }; @@ -60,8 +57,7 @@ class CallPrinter final : public AstVisitor { Isolate* isolate_; int num_prints_; - // Allocate the builder on the heap simply because it's forward declared. - std::unique_ptr builder_; + IncrementalStringBuilder builder_; int position_; // position of ast node to print bool found_; bool done_; diff --git a/deps/v8/src/ast/scopes.cc b/deps/v8/src/ast/scopes.cc index 39e3a8d5d59..660fdd2e9ad 100644 --- a/deps/v8/src/ast/scopes.cc +++ b/deps/v8/src/ast/scopes.cc @@ -372,6 +372,8 @@ void Scope::SetDefaults() { needs_home_object_ = false; is_block_scope_for_object_literal_ = false; + has_using_declaration_ = false; + num_stack_slots_ = 0; num_heap_slots_ = ContextHeaderLength(); @@ -2930,7 +2932,7 @@ Variable* ClassScope::LookupPrivateNameInScopeInfo(const AstRawString* name) { return nullptr; } - DCHECK(IsConstVariableMode(lookup_result.mode)); + DCHECK(IsImmutableLexicalOrPrivateVariableMode(lookup_result.mode)); DCHECK_EQ(lookup_result.init_flag, InitializationFlag::kNeedsInitialization); DCHECK_EQ(lookup_result.maybe_assigned_flag, MaybeAssignedFlag::kNotAssigned); @@ -3076,9 +3078,10 @@ Variable* ClassScope::DeclareClassVariable(AstValueFactory* ast_value_factory, const AstRawString* name, int class_token_pos) { DCHECK_NULL(class_variable_); + DCHECK_NOT_NULL(name); bool was_added; class_variable_ = - Declare(zone(), name == nullptr ? ast_value_factory->dot_string() : name, + Declare(zone(), name->IsEmpty() ? ast_value_factory->dot_string() : name, VariableMode::kConst, NORMAL_VARIABLE, InitializationFlag::kNeedsInitialization, MaybeAssignedFlag::kMaybeAssigned, &was_added); diff --git a/deps/v8/src/ast/scopes.h b/deps/v8/src/ast/scopes.h index cea379caec8..dc3fa65dc47 100644 --- a/deps/v8/src/ast/scopes.h +++ b/deps/v8/src/ast/scopes.h @@ -380,6 +380,8 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { return private_name_lookup_skips_outer_class_; } + bool has_using_declaration() const { return has_using_declaration_; } + #if V8_ENABLE_WEBASSEMBLY bool IsAsmModule() const; // Returns true if this scope or any inner scopes that might be eagerly @@ -651,6 +653,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { Variable* result = variables_.Declare( zone, this, name, mode, kind, initialization_flag, maybe_assigned_flag, IsStaticFlag::kNotStatic, was_added); + if (mode == VariableMode::kUsing) has_using_declaration_ = true; if (*was_added) locals_.Add(result); return result; } @@ -846,6 +849,9 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { bool needs_home_object_ : 1; bool is_block_scope_for_object_literal_ : 1; + + // If declarations include any `using` declarations. + bool has_using_declaration_ : 1; }; class V8_EXPORT_PRIVATE DeclarationScope : public Scope { diff --git a/deps/v8/src/ast/variables.cc b/deps/v8/src/ast/variables.cc index 6f5d94257b9..02de3f2619b 100644 --- a/deps/v8/src/ast/variables.cc +++ b/deps/v8/src/ast/variables.cc @@ -29,6 +29,7 @@ bool Variable::IsGlobalObjectProperty() const { scope_ != nullptr && scope_->is_script_scope(); } +// TODO(rezvan): Add check and related tests for VariableMode::kUsing. bool Variable::IsReplGlobal() const { return scope()->is_repl_mode_scope() && (mode() == VariableMode::kLet || mode() == VariableMode::kConst); @@ -37,6 +38,7 @@ bool Variable::IsReplGlobal() const { void Variable::RewriteLocationForRepl() { DCHECK(scope_->is_repl_mode_scope()); + // TODO(rezvan): Add check and related tests for VariableMode::kUsing. if (mode() == VariableMode::kLet || mode() == VariableMode::kConst) { DCHECK_EQ(location(), VariableLocation::CONTEXT); bit_field_ = diff --git a/deps/v8/src/ast/variables.h b/deps/v8/src/ast/variables.h index 30d41ea800d..d33ba538a07 100644 --- a/deps/v8/src/ast/variables.h +++ b/deps/v8/src/ast/variables.h @@ -46,7 +46,7 @@ class Variable final : public ZoneObject { DCHECK(!(mode == VariableMode::kVar && initialization_flag == kNeedsInitialization)); DCHECK_IMPLIES(is_static_flag == IsStaticFlag::kStatic, - IsConstVariableMode(mode)); + IsImmutableLexicalOrPrivateVariableMode(mode)); } explicit Variable(Variable* other); @@ -92,7 +92,9 @@ class Variable final : public ZoneObject { bit_field_ = MaybeAssignedFlagField::update(bit_field_, kNotAssigned); } void SetMaybeAssigned() { - if (mode() == VariableMode::kConst) return; + if (IsImmutableLexicalVariableMode(mode())) { + return; + } // Private names are only initialized once by us. if (name_->IsPrivateName()) { return; @@ -105,8 +107,9 @@ class Variable final : public ZoneObject { if (!maybe_assigned()) { local_if_not_shadowed()->SetMaybeAssigned(); } - DCHECK_IMPLIES(local_if_not_shadowed()->mode() != VariableMode::kConst, - local_if_not_shadowed()->maybe_assigned()); + DCHECK_IMPLIES( + (!IsImmutableLexicalVariableMode(local_if_not_shadowed()->mode())), + local_if_not_shadowed()->maybe_assigned()); } set_maybe_assigned(); } diff --git a/deps/v8/src/base/OWNERS b/deps/v8/src/base/OWNERS index 8fcbc9e047a..7f690fd4731 100644 --- a/deps/v8/src/base/OWNERS +++ b/deps/v8/src/base/OWNERS @@ -1,3 +1,4 @@ +bikineev@chromium.org clemensb@chromium.org ishell@chromium.org mlippautz@chromium.org diff --git a/deps/v8/src/base/bits.h b/deps/v8/src/base/bits.h index 78f2c8b88ac..d9ae9d681e1 100644 --- a/deps/v8/src/base/bits.h +++ b/deps/v8/src/base/bits.h @@ -485,6 +485,11 @@ V8_BASE_EXPORT int64_t SignedSaturatedAdd64(int64_t lhs, int64_t rhs); // checks and returns the result. V8_BASE_EXPORT int64_t SignedSaturatedSub64(int64_t lhs, int64_t rhs); +template +V8_BASE_EXPORT constexpr int BitWidth(T x) { + return std::numeric_limits::digits - CountLeadingZeros(x); +} + } // namespace bits } // namespace base } // namespace v8 diff --git a/deps/v8/src/base/bounded-page-allocator.cc b/deps/v8/src/base/bounded-page-allocator.cc index d3a377b49b5..f30385b793a 100644 --- a/deps/v8/src/base/bounded-page-allocator.cc +++ b/deps/v8/src/base/bounded-page-allocator.cc @@ -61,16 +61,24 @@ void* BoundedPageAllocator::AllocatePages(void* hint, size_t size, void* ptr = reinterpret_cast(address); // It's assumed that free regions are in kNoAccess/kNoAccessWillJitLater // state. - if (access != PageAllocator::kNoAccess && - access != PageAllocator::kNoAccessWillJitLater) { - if (!page_allocator_->SetPermissions(ptr, size, access)) { - // This most likely means that we ran out of memory. - CHECK_EQ(region_allocator_.FreeRegion(address), size); - return nullptr; + if (access == PageAllocator::kNoAccess || + access == PageAllocator::kNoAccessWillJitLater) { + return ptr; + } + + if (page_initialization_mode_ == PageInitializationMode::kRecommitOnly) { + if (page_allocator_->RecommitPages(ptr, size, access)) { + return ptr; + } + } else { + if (page_allocator_->SetPermissions(ptr, size, access)) { + return ptr; } } - return ptr; + // This most likely means that we ran out of memory. + CHECK_EQ(region_allocator_.FreeRegion(address), size); + return nullptr; } bool BoundedPageAllocator::AllocatePagesAt(Address address, size_t size, @@ -132,9 +140,9 @@ bool BoundedPageAllocator::FreePages(void* raw_address, size_t size) { // pages here, which will cause any wired pages to be removed by the OS. return page_allocator_->DecommitPages(raw_address, size); } - DCHECK_EQ(page_initialization_mode_, - PageInitializationMode::kAllocatedPagesCanBeUninitialized); if (page_freeing_mode_ == PageFreeingMode::kMakeInaccessible) { + DCHECK_EQ(page_initialization_mode_, + PageInitializationMode::kAllocatedPagesCanBeUninitialized); return page_allocator_->SetPermissions(raw_address, size, PageAllocator::kNoAccess); } @@ -178,9 +186,9 @@ bool BoundedPageAllocator::ReleasePages(void* raw_address, size_t size, // See comment in FreePages(). return (page_allocator_->DecommitPages(free_address, free_size)); } - DCHECK_EQ(page_initialization_mode_, - PageInitializationMode::kAllocatedPagesCanBeUninitialized); if (page_freeing_mode_ == PageFreeingMode::kMakeInaccessible) { + DCHECK_EQ(page_initialization_mode_, + PageInitializationMode::kAllocatedPagesCanBeUninitialized); return page_allocator_->SetPermissions(free_address, free_size, PageAllocator::kNoAccess); } diff --git a/deps/v8/src/base/bounded-page-allocator.h b/deps/v8/src/base/bounded-page-allocator.h index 938f72927f3..83870006a7d 100644 --- a/deps/v8/src/base/bounded-page-allocator.h +++ b/deps/v8/src/base/bounded-page-allocator.h @@ -21,6 +21,9 @@ enum class PageInitializationMode { // data. This is slightly faster as comitted pages are not decommitted // during FreePages and ReleasePages, but only made inaccessible. kAllocatedPagesCanBeUninitialized, + // Assume pages are in discarded state and already have the right page + // permissions. Using this mode requires PageFreeingMode::kDiscard. + kRecommitOnly, }; // Defines how BoundedPageAllocator frees pages when FreePages or ReleasePages diff --git a/deps/v8/src/base/build_config.h b/deps/v8/src/base/build_config.h index 9ed4c8f1026..5708ce20c8a 100644 --- a/deps/v8/src/base/build_config.h +++ b/deps/v8/src/base/build_config.h @@ -28,13 +28,21 @@ #endif // pthread_jit_write_protect is only available on arm64 Mac. -#if defined(V8_HOST_ARCH_ARM64) && \ - (defined(V8_OS_MACOS) || (defined(V8_OS_IOS) && TARGET_OS_SIMULATOR)) +#if defined(V8_HOST_ARCH_ARM64) && defined(V8_OS_MACOS) #define V8_HAS_PTHREAD_JIT_WRITE_PROTECT 1 #else #define V8_HAS_PTHREAD_JIT_WRITE_PROTECT 0 #endif +// BrowserEngineCore JIT write protect is only available on iOS 17.4 and later. +#if defined(V8_HOST_ARCH_ARM64) && defined(V8_OS_IOS) && \ + defined(__IPHONE_17_4) && \ + __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_17_4 +#define V8_HAS_BECORE_JIT_WRITE_PROTECT 1 +#else +#define V8_HAS_BECORE_JIT_WRITE_PROTECT 0 +#endif + #if defined(V8_OS_LINUX) && defined(V8_HOST_ARCH_X64) #define V8_HAS_PKU_JIT_WRITE_PROTECT 1 #else @@ -68,6 +76,8 @@ constexpr int kPageSizeBits = kHugePageBits; constexpr int kPageSizeBits = 18; #endif +constexpr int kRegularPageSize = 1 << kPageSizeBits; + // The minimal supported page size by the operation system. Any region aligned // to that size needs to be individually protectable via // {base::OS::SetPermission} and friends. diff --git a/deps/v8/src/base/cpu.cc b/deps/v8/src/base/cpu.cc index 1b1c5c0776b..df630a87a4f 100644 --- a/deps/v8/src/base/cpu.cc +++ b/deps/v8/src/base/cpu.cc @@ -87,6 +87,30 @@ static V8_INLINE void __cpuid(int cpu_info[4], int info_type) { #endif // defined(__i386__) && defined(__pic__) } +static V8_INLINE void __cpuidex(int cpu_info[4], int info_type, + int sub_info_type) { +// Gather additional information about the processor. +// Set the value of the ECX register to sub_info_type before it generates the +// cpuid instruction, align with __cpuidex() of MSVC: +// https://msdn.microsoft.com/en-us/library/hskdteyh.aspx +#if defined(__i386__) && defined(__pic__) + // Make sure to preserve ebx, which contains the pointer + // to the GOT in case we're generating PIC. + __asm__ volatile( + "mov %%ebx, %%edi\n\t" + "cpuid\n\t" + "xchg %%edi, %%ebx\n\t" + : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), + "=d"(cpu_info[3]) + : "a"(info_type), "c"(sub_info_type)); +#else + __asm__ volatile("cpuid \n\t" + : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), + "=d"(cpu_info[3]) + : "a"(info_type), "c"(sub_info_type)); +#endif // defined(__i386__) && defined(__pic__) +} + #endif // !V8_LIBC_MSVCRT #elif V8_HOST_ARCH_ARM || V8_HOST_ARCH_ARM64 || V8_HOST_ARCH_MIPS64 || \ @@ -359,11 +383,13 @@ bool CPU::StarboardDetectCPU() { has_sahf_ = features.x86.has_sahf; has_avx_ = features.x86.has_avx; has_avx2_ = features.x86.has_avx2; + // TODO: Support AVX-VNNI on Starboard has_fma3_ = features.x86.has_fma3; has_bmi1_ = features.x86.has_bmi1; has_bmi2_ = features.x86.has_bmi2; has_lzcnt_ = features.x86.has_lzcnt; has_popcnt_ = features.x86.has_popcnt; + has_f16c_ = features.x86.has_f16c; break; default: return false; @@ -403,7 +429,9 @@ CPU::CPU() has_osxsave_(false), has_avx_(false), has_avx2_(false), + has_avx_vnni_(false), has_fma3_(false), + has_f16c_(false), has_bmi1_(false), has_bmi2_(false), has_lzcnt_(false), @@ -418,6 +446,8 @@ CPU::CPU() has_dot_prod_(false), has_lse_(false), has_mte_(false), + has_pmull1q_(false), + has_fp16_(false), is_fp64_mode_(false), has_non_stop_time_stamp_counter_(false), is_running_in_vm_(false), @@ -452,9 +482,14 @@ CPU::CPU() if (num_ids > 0) { __cpuid(cpu_info, 1); - int cpu_info7[4] = {0}; + int cpu_info70[4] = {0}; + int cpu_info71[4] = {0}; if (num_ids >= 7) { - __cpuid(cpu_info7, 7); + __cpuid(cpu_info70, 7); + // Check the maximum input value for supported leaf 7 sub-leaves + if (cpu_info70[0] >= 1) { + __cpuidex(cpu_info71, 7, 1); + } } stepping_ = cpu_info[0] & 0xF; @@ -475,11 +510,13 @@ CPU::CPU() has_popcnt_ = (cpu_info[2] & 0x00800000) != 0; has_osxsave_ = (cpu_info[2] & 0x08000000) != 0; has_avx_ = (cpu_info[2] & 0x10000000) != 0; - has_avx2_ = (cpu_info7[1] & 0x00000020) != 0; + has_avx2_ = (cpu_info70[1] & 0x00000020) != 0; + has_avx_vnni_ = (cpu_info71[0] & 0x00000010) != 0; has_fma3_ = (cpu_info[2] & 0x00001000) != 0; + has_f16c_ = (cpu_info[2] & 0x20000000) != 0; // CET shadow stack feature flag. See // https://en.wikipedia.org/wiki/CPUID#EAX=7,_ECX=0:_Extended_Features - has_cetss_ = (cpu_info7[2] & 0x00000080) != 0; + has_cetss_ = (cpu_info70[2] & 0x00000080) != 0; // "Hypervisor Present Bit: Bit 31 of ECX of CPUID leaf 0x1." // See https://lwn.net/Articles/301888/ // This is checking for any hypervisor. Hypervisors may choose not to @@ -773,11 +810,21 @@ CPU::CPU() #if !defined(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE) constexpr int PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE = 43; #endif +#if !defined(PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE) + constexpr int PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE = 34; +#endif +#if !defined(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) + constexpr int PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE = 30; +#endif has_jscvt_ = IsProcessorFeaturePresent(PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE); has_dot_prod_ = IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE); + has_lse_ = + IsProcessorFeaturePresent(PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE); + has_pmull1q_ = + IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE); #elif V8_OS_LINUX // Try to extract the list of CPU features from ELF hwcaps. @@ -788,6 +835,8 @@ CPU::CPU() has_jscvt_ = (hwcaps & HWCAP_JSCVT) != 0; has_dot_prod_ = (hwcaps & HWCAP_ASIMDDP) != 0; has_lse_ = (hwcaps & HWCAP_ATOMICS) != 0; + has_pmull1q_ = (hwcaps & HWCAP_PMULL) != 0; + has_fp16_ = (hwcaps & HWCAP_FPHP) != 0; } else { // Try to fallback to "Features" CPUInfo field CPUInfo cpu_info; @@ -795,6 +844,8 @@ CPU::CPU() has_jscvt_ = HasListItem(features, "jscvt"); has_dot_prod_ = HasListItem(features, "asimddp"); has_lse_ = HasListItem(features, "atomics"); + has_pmull1q_ = HasListItem(features, "pmull"); + has_fp16_ = HasListItem(features, "half"); delete[] features; } #elif V8_OS_DARWIN @@ -823,11 +874,29 @@ CPU::CPU() } else { has_lse_ = feat_lse; } + int64_t feat_pmull = 0; + size_t feat_pmull_size = sizeof(feat_pmull); + if (sysctlbyname("hw.optional.arm.FEAT_PMULL", &feat_pmull, &feat_pmull_size, + nullptr, 0) == -1) { + has_pmull1q_ = false; + } else { + has_pmull1q_ = feat_pmull; + } + int64_t fp16 = 0; + size_t fp16_size = sizeof(fp16); + if (sysctlbyname("hw.optional.arm.FEAT_FP16", &fp16, &fp16_size, nullptr, + 0) == -1) { + has_fp16_ = false; + } else { + has_fp16_ = fp16; + } #else - // ARM64 Macs always have JSCVT, ASIMDDP and LSE. + // ARM64 Macs always have JSCVT, ASIMDDP, FP16 and LSE. has_jscvt_ = true; has_dot_prod_ = true; has_lse_ = true; + has_pmull1q_ = true; + has_fp16_ = true; #endif // V8_OS_IOS #endif // V8_OS_WIN @@ -914,6 +983,20 @@ CPU::CPU() #elif V8_HOST_ARCH_RISCV64 #if V8_OS_LINUX CPUInfo cpu_info; +#if (V8_GLIBC_PREREQ(2, 39)) +#include +#include + riscv_hwprobe pairs[] = {{RISCV_HWPROBE_KEY_IMA_EXT_0, 0}}; + if (!syscall(__NR_riscv_hwprobe, &pairs, + sizeof(pairs) / sizeof(riscv_hwprobe), 0, nullptr, 0)) { + if (pairs[0].value & RISCV_HWPROBE_IMA_V) { + has_rvv_ = true; + } + if (pairs[0].value & RISCV_HWPROBE_IMA_FD) { + has_fpu_ = true; + } + } +#else char* features = cpu_info.ExtractField("isa"); if (HasListItem(features, "rv64imafdc")) { @@ -923,6 +1006,8 @@ CPU::CPU() has_fpu_ = true; has_rvv_ = true; } +#endif + char* mmu = cpu_info.ExtractField("mmu"); if (HasListItem(mmu, "sv48")) { riscv_mmu_ = RV_MMU_MODE::kRiscvSV48; diff --git a/deps/v8/src/base/cpu.h b/deps/v8/src/base/cpu.h index fc9a77e2bf6..9f94782efde 100644 --- a/deps/v8/src/base/cpu.h +++ b/deps/v8/src/base/cpu.h @@ -95,7 +95,9 @@ class V8_BASE_EXPORT CPU final { bool has_osxsave() const { return has_osxsave_; } bool has_avx() const { return has_avx_; } bool has_avx2() const { return has_avx2_; } + bool has_avx_vnni() const { return has_avx_vnni_; } bool has_fma3() const { return has_fma3_; } + bool has_f16c() const { return has_f16c_; } bool has_bmi1() const { return has_bmi1_; } bool has_bmi2() const { return has_bmi2_; } bool has_lzcnt() const { return has_lzcnt_; } @@ -127,6 +129,8 @@ class V8_BASE_EXPORT CPU final { bool has_dot_prod() const { return has_dot_prod_; } bool has_lse() const { return has_lse_; } bool has_mte() const { return has_mte_; } + bool has_pmull1q() const { return has_pmull1q_; } + bool has_fp16() const { return has_fp16_; } // mips features bool is_fp64_mode() const { return is_fp64_mode_; } @@ -175,7 +179,9 @@ class V8_BASE_EXPORT CPU final { bool has_osxsave_; bool has_avx_; bool has_avx2_; + bool has_avx_vnni_; bool has_fma3_; + bool has_f16c_; bool has_bmi1_; bool has_bmi2_; bool has_lzcnt_; @@ -190,6 +196,8 @@ class V8_BASE_EXPORT CPU final { bool has_dot_prod_; bool has_lse_; bool has_mte_; + bool has_pmull1q_; + bool has_fp16_; bool is_fp64_mode_; bool has_non_stop_time_stamp_counter_; bool is_running_in_vm_; diff --git a/deps/v8/src/base/macros.h b/deps/v8/src/base/macros.h index 210885af3c3..14203861b82 100644 --- a/deps/v8/src/base/macros.h +++ b/deps/v8/src/base/macros.h @@ -25,20 +25,22 @@ #define OFFSET_OF(type, field) offsetof(type, field) +// A comma, to be used in macro arguments where it would otherwise be +// interpreted as separator of arguments. +#define LITERAL_COMMA , + // The arraysize(arr) macro returns the # of elements in an array arr. // The expression is a compile-time constant, and therefore can be // used in defining new arrays, for example. If you use arraysize on // a pointer by mistake, you will get a compile-time error. #define arraysize(array) (sizeof(ArraySizeHelper(array))) - // This template function declaration is used in defining arraysize. // Note that the function doesn't need an implementation, as we only // use its type. template char (&ArraySizeHelper(T (&array)[N]))[N]; - #if !V8_CC_MSVC // That gcc wants both of these prototypes seems mysterious. VC, for // its part, can't decide which to use (another mystery). Matching of diff --git a/deps/v8/src/base/memory.h b/deps/v8/src/base/memory.h index a635a4a0a69..bfcfa454ef4 100644 --- a/deps/v8/src/base/memory.h +++ b/deps/v8/src/base/memory.h @@ -14,8 +14,6 @@ using Address = uintptr_t; // Memory provides an interface to 'raw' memory. It encapsulates the casts // that typically are needed when incompatible pointer types are used. -// Note that this class currently relies on undefined behaviour. There is a -// proposal (http://wg21.link/p0593r2) to make it defined behaviour though. template inline T& Memory(Address addr) { DCHECK(IsAligned(addr, alignof(T))); diff --git a/deps/v8/src/base/page-allocator.cc b/deps/v8/src/base/page-allocator.cc index 7303c5ed589..97ce70360bf 100644 --- a/deps/v8/src/base/page-allocator.cc +++ b/deps/v8/src/base/page-allocator.cc @@ -44,7 +44,7 @@ void* PageAllocator::GetRandomMmapAddr() { void* PageAllocator::AllocatePages(void* hint, size_t size, size_t alignment, PageAllocator::Permission access) { -#if !V8_HAS_PTHREAD_JIT_WRITE_PROTECT +#if !V8_HAS_PTHREAD_JIT_WRITE_PROTECT && !V8_HAS_BECORE_JIT_WRITE_PROTECT // kNoAccessWillJitLater is only used on Apple Silicon. Map it to regular // kNoAccess on other platforms, so code doesn't have to handle both enum // values. diff --git a/deps/v8/src/base/platform/platform-darwin.cc b/deps/v8/src/base/platform/platform-darwin.cc index c563693d461..04447e65fd0 100644 --- a/deps/v8/src/base/platform/platform-darwin.cc +++ b/deps/v8/src/base/platform/platform-darwin.cc @@ -96,7 +96,7 @@ std::vector OS::GetSharedLibraryAddresses() { #endif if (code_ptr == nullptr) continue; const intptr_t slide = _dyld_get_image_vmaddr_slide(i); - const uintptr_t start = reinterpret_cast(code_ptr) + slide; + const uintptr_t start = reinterpret_cast(code_ptr); result.push_back(SharedLibraryAddress(_dyld_get_image_name(i), start, start + size, slide)); } diff --git a/deps/v8/src/base/platform/platform-ios.cc b/deps/v8/src/base/platform/platform-ios.cc deleted file mode 100644 index f0fc18648dd..00000000000 --- a/deps/v8/src/base/platform/platform-ios.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/base/base-export.h" -#include "src/base/build_config.h" - -// pthread_jit_write_protect_np is marked as not available in the iOS -// SDK but it is there for the iOS simulator. So we provide a thunk -// and a forward declaration in a compilation target that doesn't -// include pthread.h to avoid the compiler error. -extern "C" void pthread_jit_write_protect_np(int enable); - -namespace v8::base { - -#if V8_HAS_PTHREAD_JIT_WRITE_PROTECT && defined(V8_OS_IOS) -V8_BASE_EXPORT void SetJitWriteProtected(int enable) { - pthread_jit_write_protect_np(enable); -} -#endif - -} // namespace v8::base diff --git a/deps/v8/src/base/platform/platform-posix.cc b/deps/v8/src/base/platform/platform-posix.cc index 529a073040a..15910387d98 100644 --- a/deps/v8/src/base/platform/platform-posix.cc +++ b/deps/v8/src/base/platform/platform-posix.cc @@ -131,7 +131,8 @@ int GetFlagsForMemoryPermission(OS::MemoryPermission access, PageType page_type) { int flags = MAP_ANONYMOUS; flags |= (page_type == PageType::kShared) ? MAP_SHARED : MAP_PRIVATE; - if (access == OS::MemoryPermission::kNoAccess) { + if (access == OS::MemoryPermission::kNoAccess || + access == OS::MemoryPermission::kNoAccessWillJitLater) { #if !V8_OS_AIX && !V8_OS_FREEBSD && !V8_OS_QNX flags |= MAP_NORESERVE; #endif // !V8_OS_AIX && !V8_OS_FREEBSD && !V8_OS_QNX @@ -144,7 +145,8 @@ int GetFlagsForMemoryPermission(OS::MemoryPermission access, // hardened runtime/memory protection is enabled, which is optional (via code // signing) on Intel-based Macs but mandatory on Apple silicon ones. See also // https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon. - if (access == OS::MemoryPermission::kNoAccessWillJitLater) { + if (access == OS::MemoryPermission::kNoAccessWillJitLater || + access == OS::MemoryPermission::kReadWriteExecute) { flags |= MAP_JIT; } #endif // V8_OS_DARWIN @@ -539,10 +541,8 @@ bool OS::RecommitPages(void* address, size_t size, MemoryPermission access) { #if defined(V8_OS_DARWIN) while (madvise(address, size, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { } - return true; -#else - return SetPermissions(address, size, access); #endif // defined(V8_OS_DARWIN) + return true; } // static diff --git a/deps/v8/src/base/platform/platform.h b/deps/v8/src/base/platform/platform.h index 99be31da701..0091d0d71d6 100644 --- a/deps/v8/src/base/platform/platform.h +++ b/deps/v8/src/base/platform/platform.h @@ -64,13 +64,11 @@ extern "C" unsigned long __readfsdword(unsigned long); // NOLINT(runtime/int) #endif // V8_CC_MSVC && V8_HOST_ARCH_IA32 #endif // V8_NO_FAST_TLS -namespace v8 { - -namespace internal { -class HandleHelper; +namespace heap::base { +class Stack; } -namespace base { +namespace v8::base { // ---------------------------------------------------------------------------- // Fast TLS support @@ -684,14 +682,13 @@ class V8_BASE_EXPORT Stack { static StackSlot GetStackStartUnchecked(); static Stack::StackSlot ObtainCurrentThreadStackStart(); - friend v8::internal::HandleHelper; + friend class heap::base::Stack; }; #if V8_HAS_PTHREAD_JIT_WRITE_PROTECT V8_BASE_EXPORT void SetJitWriteProtected(int enable); #endif -} // namespace base -} // namespace v8 +} // namespace v8::base #endif // V8_BASE_PLATFORM_PLATFORM_H_ diff --git a/deps/v8/src/base/sanitizer/lsan-page-allocator.cc b/deps/v8/src/base/sanitizer/lsan-page-allocator.cc index c50bb4611b9..b4a6b7a5e59 100644 --- a/deps/v8/src/base/sanitizer/lsan-page-allocator.cc +++ b/deps/v8/src/base/sanitizer/lsan-page-allocator.cc @@ -27,7 +27,16 @@ void* LsanPageAllocator::AllocatePages(void* hint, size_t size, void* result = page_allocator_->AllocatePages(hint, size, alignment, access); #if defined(LEAK_SANITIZER) if (result != nullptr) { - __lsan_register_root_region(result, size); + if (access != PageAllocator::Permission::kNoAccessWillJitLater) { + __lsan_register_root_region(result, size); + } else { + // We allocate the JIT cage as RWX from the beginning und use Discard to + // mark the memory as unused. This makes tests with LSAN enabled 2-3x + // slower since it will always try to scan the area for pointers. So skip + // registering the JIT regions with LSAN. + base::MutexGuard lock(¬_registered_regions_mutex_); + not_registered_regions_.insert(result); + } } #endif return result; @@ -52,7 +61,12 @@ bool LsanPageAllocator::CanAllocateSharedPages() { bool LsanPageAllocator::FreePages(void* address, size_t size) { CHECK(page_allocator_->FreePages(address, size)); #if defined(LEAK_SANITIZER) - __lsan_unregister_root_region(address, size); + base::MutexGuard lock(¬_registered_regions_mutex_); + if (not_registered_regions_.count(address) == 0) { + __lsan_unregister_root_region(address, size); + } else { + not_registered_regions_.erase(address); + } #endif return true; } @@ -61,8 +75,11 @@ bool LsanPageAllocator::ReleasePages(void* address, size_t size, size_t new_size) { CHECK(page_allocator_->ReleasePages(address, size, new_size)); #if defined(LEAK_SANITIZER) - __lsan_unregister_root_region(address, size); - __lsan_register_root_region(address, new_size); + base::MutexGuard lock(¬_registered_regions_mutex_); + if (not_registered_regions_.count(address) == 0) { + __lsan_unregister_root_region(address, size); + __lsan_register_root_region(address, new_size); + } #endif return true; } diff --git a/deps/v8/src/base/sanitizer/lsan-page-allocator.h b/deps/v8/src/base/sanitizer/lsan-page-allocator.h index 3f6306bcf15..33fea672bbf 100644 --- a/deps/v8/src/base/sanitizer/lsan-page-allocator.h +++ b/deps/v8/src/base/sanitizer/lsan-page-allocator.h @@ -5,9 +5,14 @@ #ifndef V8_BASE_SANITIZER_LSAN_PAGE_ALLOCATOR_H_ #define V8_BASE_SANITIZER_LSAN_PAGE_ALLOCATOR_H_ +#include + #include "include/v8-platform.h" #include "src/base/base-export.h" #include "src/base/compiler-specific.h" +#if defined(LEAK_SANITIZER) +#include "src/base/platform/mutex.h" +#endif namespace v8 { namespace base { @@ -66,6 +71,10 @@ class V8_BASE_EXPORT LsanPageAllocator : public v8::PageAllocator { v8::PageAllocator* const page_allocator_; const size_t allocate_page_size_; const size_t commit_page_size_; +#if defined(LEAK_SANITIZER) + base::Mutex not_registered_regions_mutex_; + std::set not_registered_regions_; +#endif }; } // namespace base diff --git a/deps/v8/src/base/small-vector.h b/deps/v8/src/base/small-vector.h index edaab3a7a6b..cb152047657 100644 --- a/deps/v8/src/base/small-vector.h +++ b/deps/v8/src/base/small-vector.h @@ -191,6 +191,10 @@ class SmallVector { return pos; } + T* insert(T* pos, std::initializer_list values) { + return insert(pos, values.begin(), values.end()); + } + void resize_no_init(size_t new_size) { // Resizing without initialization is safe if T is trivially copyable. ASSERT_TRIVIALLY_COPYABLE(T); diff --git a/deps/v8/src/base/template-meta-programming/algorithm.h b/deps/v8/src/base/template-meta-programming/algorithm.h new file mode 100644 index 00000000000..bf3b9703d34 --- /dev/null +++ b/deps/v8/src/base/template-meta-programming/algorithm.h @@ -0,0 +1,75 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_BASE_TEMPLATE_META_PROGRAMMING_ALGORITHM_H_ +#define V8_BASE_TEMPLATE_META_PROGRAMMING_ALGORITHM_H_ + +#include + +#include "src/base/template-meta-programming/list.h" + +namespace v8::base::tmp { + +namespace detail { + +template