diff --git a/common.gypi b/common.gypi index c9b6b8b6cc1527..c8cb1b3497974d 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/AUTHORS b/deps/v8/AUTHORS index 6de30c78a85421..efa9bf564b7ada 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -257,6 +257,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 05b7472165ae85..453726808be0e2 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,8 @@ 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/list.h", "src/base/template-utils.h", "src/base/threaded-list.h", "src/base/timezone-cache.h", @@ -1070,6 +1073,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", @@ -1572,6 +1576,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", @@ -1650,6 +1655,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 +1698,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 +1713,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 +1782,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", @@ -1960,6 +1968,8 @@ 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.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 +2152,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,6 +2312,8 @@ 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", @@ -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", @@ -3544,6 +3553,8 @@ filegroup( "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", ], }), ) diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn index e2e0c16d97080d..79b95fb517e059 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. @@ -866,7 +864,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 +875,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 +894,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 +929,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 +1053,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\"" ] } @@ -1430,33 +1466,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 +2070,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", @@ -3082,6 +3092,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", @@ -3327,13 +3338,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 +3420,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 +3447,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 +3486,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", @@ -3637,6 +3646,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 +3672,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 +3687,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 +3730,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", @@ -3841,6 +3854,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 +3998,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 +4072,8 @@ 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-entity-table-inl.h", "src/sandbox/external-entity-table.h", "src/sandbox/external-pointer-inl.h", @@ -4751,6 +4769,11 @@ v8_header_set("v8_internal_headers") { } } + frameworks = [] + if (is_ios) { + frameworks += [ "BrowserEngineKit.framework" ] + } + public_deps = [ ":torque_runtime_support", ":v8_flags", @@ -4805,11 +4828,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 +4897,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 +5151,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", ] } @@ -5407,7 +5428,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", @@ -5515,6 +5536,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", @@ -6243,7 +6265,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 +6431,8 @@ 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/list.h", "src/base/template-utils.h", "src/base/threaded-list.h", "src/base/timezone-cache.h", @@ -6512,7 +6539,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. @@ -7354,8 +7380,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 +7652,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 +7680,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,64 +7725,7 @@ 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", @@ -7806,100 +7751,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. diff --git a/deps/v8/COMMON_OWNERS b/deps/v8/COMMON_OWNERS index 9e9d51d5835a1d..2f31c18adfbd82 100644 --- a/deps/v8/COMMON_OWNERS +++ b/deps/v8/COMMON_OWNERS @@ -18,13 +18,14 @@ jkummerow@chromium.org leszeks@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 sroettger@google.com diff --git a/deps/v8/DEPS b/deps/v8/DEPS index 8f2b6e603dbde4..845dda7199e82c 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.138.0.e854224-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:d823fd85da3fb83146f734377da454473b93a2b2', # 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:437716714a744e272fabdf1377b8878ccac26b43', # luci-go CIPD package version. - 'luci_go': 'git_revision:623f8d17a069eaea6d0fca13147888284ec76ff1', + 'luci_go': 'git_revision:239be4fd8499df782db6bddb0f55832bf4f01307', # 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.20240404.3.1', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_build-tools_version @@ -128,9 +128,9 @@ 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' + '@' + '5fb1330b84e1ee6d5bda9bd11602087defc32cd9', 'buildtools': - Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + '68fce43789231d29d2028ca85530e4814aac6f50', + Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + '5384d31f9ec3eead487ae8bcac930cd82b30fee8', 'buildtools/linux64': { 'packages': [ { @@ -176,7 +176,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' + '@' + '6c60904d42b4872a3aa1224fc7ad2c4c733e9685', 'third_party/android_platform': { 'url': Var('chromium_url') + '/chromium/src/third_party/android_platform.git' + '@' + 'eeb2d566f963bb66212fdc0d9bbe1dde550b4969', 'condition': 'checkout_android', @@ -230,19 +230,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' + '@' + '0c02157621782572403132d1033230f050099118', 'condition': "checkout_centipede_deps", }, 'third_party/boringssl/src': { - 'url': Var('boringssl_url') + '/boringssl.git' + '@' + '414f69504d30d0848b69f6453ea7fb5e88004cb4', + 'url': Var('boringssl_url') + '/boringssl.git' + '@' + '06fb6e1b129d426b0f543e0e77890295175f012a', 'condition': "checkout_centipede_deps", }, 'third_party/catapult': { - 'url': Var('chromium_url') + '/catapult.git' + '@' + '97c002a33e5b777eaa60e3ddc977a185f89446f7', + 'url': Var('chromium_url') + '/catapult.git' + '@' + '24c482ad9c93a7e6504c70ed8a7f1716543c8371', '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 +252,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' + '@' + '7894b0d6811036f55f472784d8dd86640450ac41', 'third_party/fp16/src': - Var('chromium_url') + '/external/github.com/Maratyszcza/FP16.git' + '@' + '0a92994d729ff76a58f692d3028ca1b64b145d91', + Var('chromium_url') + '/external/github.com/Maratyszcza/FP16.git' + '@' + '581ac1c79dd9d9f6f4e8b2934e7a55c7becf0799', '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 +278,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' + '@' + 'ae21d2447b4b312ab22f7462c7f141caff4fa77a', 'third_party/fuzztest/src': - Var('chromium_url') + '/external/github.com/google/fuzztest.git' + '@' + 'bddcd9f77ba0a81a99ce50bcadf5149efe545df0', + Var('chromium_url') + '/external/github.com/google/fuzztest.git' + '@' + '65354bf09a2479945b4683c42948695d4f2f7c07', 'third_party/googletest/src': - Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + 'b479e7a3c161d7087113a05f8cb034b870313a55', + Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + 'b1a777f31913f8a047f43b2a5f823e736e7f5082', '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', + 'third_party/instrumented_libs': { + 'url': Var('chromium_url') + '/chromium/third_party/instrumented_libraries.git' + '@' + '0afcd954d906cd988fa5e55807c19f1443080657', + '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 +300,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' + '@' + 'e3b94d0e5b86883fd77696bf10dc33ba250ba99b', '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' + '@' + '932d253fedb390a08b17ec3a92469a4553934a6a', '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': @@ -322,7 +324,7 @@ deps = { 'third_party/protobuf': Var('chromium_url') + '/external/github.com/google/protobuf'+ '@' + '6a59a2ad1f61d9696092f79b6d74368b4d7970a3', 'third_party/re2/src': - Var('chromium_url') + '/external/github.com/google/re2.git' + '@' + '108914d28a79243d4300e7e651cd0a0d5883ca0f', + Var('chromium_url') + '/external/github.com/google/re2.git' + '@' + 'b84e3ff189980a33d4a0c6fa1201aa0b3b8bab4a', 'third_party/requests': { 'url': Var('chromium_url') + '/external/github.com/kennethreitz/requests.git' + '@' + 'c7e0fc087ceeadb8b4c84a0953a422c474093d6d', 'condition': 'checkout_android', @@ -338,9 +340,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'+ '@' + '7d77fb7fd66d8a5640618ad32c71fdeb7d3e02df', 'tools/clang': - Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + '1ed379eda880f53d895559815cd3e30b370abff5', + Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + 'b54e4fd0f84962fca8d8737f500ec31ebd2a1f3b', 'tools/luci-go': { 'packages': [ { @@ -356,7 +358,7 @@ deps = { 'dep_type': 'cipd', }, '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' + '@' + 'a64dd87cec79c80c88190265cfea0cbd4027677f', 'condition': 'not build_with_chromium', } } @@ -583,30 +585,6 @@ hooks = [ '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', @@ -773,3 +751,7 @@ hooks = [ ], }, ] + +recursedeps = [ + 'third_party/instrumented_libs', +] diff --git a/deps/v8/bazel/defs.bzl b/deps/v8/bazel/defs.bzl index f23f48ef03ae6a..2c49fe59ba3424 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", diff --git a/deps/v8/gni/v8.gni b/deps/v8/gni/v8.gni index 7c4e3ba5c34af2..1e7a5a6473eabb 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" @@ -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/internal/member-storage.h b/deps/v8/include/cppgc/internal/member-storage.h index 61b255ba637a92..2b5bfec4ed5cc1 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 ea6f5b5571a476..5d855441f8ed7b 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_DEPRECATE_SOON( + "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-context.h b/deps/v8/include/v8-context.h index 4849c925806f95..f65aa9abbe1c53 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. diff --git a/deps/v8/include/v8-function-callback.h b/deps/v8/include/v8-function-callback.h index 86a3ea72f4033c..cd5b07939fab4c 100644 --- a/deps/v8/include/v8-function-callback.h +++ b/deps/v8/include/v8-function-callback.h @@ -127,6 +127,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 +145,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 +276,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; @@ -532,10 +551,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]); diff --git a/deps/v8/include/v8-function.h b/deps/v8/include/v8-function.h index 30a9fcfe174acb..50f730f3929fe5 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 d3e35d6ec5f860..6f12e3db960b2a 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 322b22d98e8be4..14120ceeecc773 100644 --- a/deps/v8/include/v8-internal.h +++ b/deps/v8/include/v8-internal.h @@ -253,15 +253,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 +301,26 @@ 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; + // // External Pointers. // @@ -418,22 +438,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(kLastManagedResourceTag, TAG(56)) \ + V(kArrayBufferExtensionTag, TAG(57)) // All external pointer tags. #define ALL_EXTERNAL_POINTER_TAGS(V) \ @@ -449,12 +493,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 +531,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 +635,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 +706,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; @@ -719,16 +785,18 @@ 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 = kIsolateTrustedPointerTableOffset + kTrustedPointerTableSize; #else static const int kIsolateApiCallbackThunkArgumentOffset = - kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize; + kIsolateCppHeapPointerTableOffset + kExternalPointerTableSize; #endif // V8_ENABLE_SANDBOX #else static const int kIsolateApiCallbackThunkArgumentOffset = @@ -753,7 +821,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 { @@ -1383,10 +1451,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 585b513fac446a..9e49d77182dfbc 100644 --- a/deps/v8/include/v8-isolate.h +++ b/deps/v8/include/v8-isolate.h @@ -1656,7 +1656,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-object.h b/deps/v8/include/v8-object.h index 6cdf53b19c7d05..0d09ee7c088767 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); @@ -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(). */ @@ -729,6 +801,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 +824,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 +851,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 +872,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 +885,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 9db5af5dddd557..e08747a55f9fef 100644 --- a/deps/v8/include/v8-persistent-handle.h +++ b/deps/v8/include/v8-persistent-handle.h @@ -236,21 +236,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-sandbox.h b/deps/v8/include/v8-sandbox.h new file mode 100644 index 00000000000000..f5f91cbb91a696 --- /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 75589863d9d1c7..d4b626f013c7ce 100644 --- a/deps/v8/include/v8-script.h +++ b/deps/v8/include/v8-script.h @@ -787,15 +787,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 9e5a53f134a82c..8c8390bab18f36 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 6a0c898f4507d2..f1435541f1eb2d 100644 --- a/deps/v8/include/v8-template.h +++ b/deps/v8/include/v8-template.h @@ -80,21 +80,21 @@ 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") + V8_DEPRECATED("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") + V8_DEPRECATED("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") + V8_DEPRECATED("Use SetNativeDataProperty with Local instead") void SetNativeDataProperty( Local name, AccessorGetterCallback getter, AccessorSetterCallback setter = nullptr, @@ -142,7 +142,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 +195,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 +231,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 +266,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 +315,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 +349,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 +385,7 @@ using GenericNamedPropertyDescriptorCallback = // removed. /** - * See `v8::GenericNamedPropertyGetterCallback`. + * See `v8::NamedPropertyGetterCallback`. */ using IndexedPropertyGetterCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -388,7 +394,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 +404,7 @@ using IndexedPropertySetterCallback = const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyQueryCallback`. + * See `v8::NamedPropertyQueryCallback`. */ using IndexedPropertyQueryCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -407,7 +413,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 +431,7 @@ using IndexedPropertyEnumeratorCallback = void (*)(const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDefinerCallback`. + * See `v8::NamedPropertyDefinerCallback`. */ using IndexedPropertyDefinerCallbackV2 = Intercepted (*)(uint32_t index, const PropertyDescriptor& desc, @@ -436,7 +442,7 @@ using IndexedPropertyDefinerCallback = const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDescriptorCallback`. + * See `v8::NamedPropertyDescriptorCallback`. */ using IndexedPropertyDescriptorCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -762,7 +768,9 @@ struct NamedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(NamedPropertyXxxCallback)") NamedPropertyHandlerConfiguration( GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, @@ -801,7 +809,9 @@ struct NamedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(NamedPropertyXxxCallback)") explicit NamedPropertyHandlerConfiguration( GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter = nullptr, @@ -839,7 +849,9 @@ struct NamedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(NamedPropertyXxxCallback)") NamedPropertyHandlerConfiguration( GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, @@ -901,7 +913,9 @@ struct IndexedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(IndexedPropertyXxxCallbackV2)") IndexedPropertyHandlerConfiguration( IndexedPropertyGetterCallback getter, // IndexedPropertySetterCallback setter, // @@ -940,7 +954,9 @@ struct IndexedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(IndexedPropertyXxxCallbackV2)") explicit IndexedPropertyHandlerConfiguration( IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter = nullptr, @@ -978,7 +994,9 @@ struct IndexedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(IndexedPropertyXxxCallbackV2)") IndexedPropertyHandlerConfiguration( IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter, @@ -1045,7 +1063,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") + V8_DEPRECATED("Use SetAccessor with Local instead") void SetAccessor( Local name, AccessorGetterCallback getter, AccessorSetterCallback setter = nullptr, diff --git a/deps/v8/include/v8-unwinder.h b/deps/v8/include/v8-unwinder.h index 8b71bb39b55f42..5771eb05a81ecf 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-version.h b/deps/v8/include/v8-version.h index 460ec45badd30c..eb437923be213e 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 18 +#define V8_MINOR_VERSION 5 +#define V8_BUILD_NUMBER 227 +#define V8_PATCH_LEVEL 11 // 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 71514615466eb3..f8e406c737e1cf 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 e649d8cce7d03d..7565ebf68eac7d 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 a498d240e3fd83..54a177c87e17fc 100644 --- a/deps/v8/infra/mb/mb_config.pyl +++ b/deps/v8/infra/mb/mb_config.pyl @@ -82,6 +82,7 @@ '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', @@ -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', diff --git a/deps/v8/samples/process.cc b/deps/v8/samples/process.cc index d773e9b9d1870c..9b9b39482aafdd 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); diff --git a/deps/v8/src/DEPS b/deps/v8/src/DEPS index d9c58d01236454..1affba690f127b 100644 --- a/deps/v8/src/DEPS +++ b/deps/v8/src/DEPS @@ -41,6 +41,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", diff --git a/deps/v8/src/api/api-arguments-inl.h b/deps/v8/src/api/api-arguments-inl.h index de2648c8d60528..e32953bd270d91 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 b8e60c48e651d8..7fe521d35bc1f0 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 e3ff723b53e38d..23ca54bd94d971 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 a7070c494c211b..e2be8c72ebc12e 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) { @@ -726,7 +730,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 +764,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. @@ -2663,119 +2651,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(); } @@ -4512,23 +4449,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 +4475,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 +4603,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 +4614,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 +4647,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 +4666,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 +4741,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 +4781,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 +4917,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); @@ -5338,13 +5319,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 +5574,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; @@ -6335,7 +6310,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); @@ -6356,6 +6331,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 +6383,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 +6727,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 +6742,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 +6754,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 +6820,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 +7001,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_)}; @@ -8754,8 +8764,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 +8779,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 +8792,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"); @@ -10276,6 +10284,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); } @@ -10496,7 +10505,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 +10529,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()); } } @@ -11789,7 +11800,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 40b419db777f96..fcc588e50158fe 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) \ diff --git a/deps/v8/src/asmjs/asm-parser.cc b/deps/v8/src/asmjs/asm-parser.cc index c5ff60d671f19d..e3bfd13b1f91a6 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 b7bdc33b1604df..3edc5a796bce16 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/scopes.cc b/deps/v8/src/ast/scopes.cc index 39e3a8d5d59acb..660fdd2e9ad30b 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 cea379caec837d..dc3fa65dc47724 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 6f5d94257b912d..02de3f2619b40e 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 30d41ea800d00d..d33ba538a0711d 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/bits.h b/deps/v8/src/base/bits.h index 78f2c8b88acc28..d9ae9d681e1f52 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 d3a377b49b53a0..f30385b793ab58 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 938f72927f3f28..83870006a7d23f 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 9ed4c8f10263f0..5708ce20c8aab2 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 1b1c5c0776ba0c..bd4cbe4a2fa108 100644 --- a/deps/v8/src/base/cpu.cc +++ b/deps/v8/src/base/cpu.cc @@ -418,6 +418,7 @@ CPU::CPU() has_dot_prod_(false), has_lse_(false), has_mte_(false), + has_pmull1q_(false), is_fp64_mode_(false), has_non_stop_time_stamp_counter_(false), is_running_in_vm_(false), @@ -773,11 +774,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 +799,7 @@ 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; } else { // Try to fallback to "Features" CPUInfo field CPUInfo cpu_info; @@ -795,6 +807,7 @@ CPU::CPU() has_jscvt_ = HasListItem(features, "jscvt"); has_dot_prod_ = HasListItem(features, "asimddp"); has_lse_ = HasListItem(features, "atomics"); + has_pmull1q_ = HasListItem(features, "pmull"); delete[] features; } #elif V8_OS_DARWIN @@ -823,11 +836,20 @@ 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; + } #else // ARM64 Macs always have JSCVT, ASIMDDP and LSE. has_jscvt_ = true; has_dot_prod_ = true; has_lse_ = true; + has_pmull1q_ = true; #endif // V8_OS_IOS #endif // V8_OS_WIN @@ -914,6 +936,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 +959,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 fc9a77e2bf6a78..6a5023a220a79f 100644 --- a/deps/v8/src/base/cpu.h +++ b/deps/v8/src/base/cpu.h @@ -127,6 +127,7 @@ 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_; } // mips features bool is_fp64_mode() const { return is_fp64_mode_; } @@ -190,6 +191,7 @@ class V8_BASE_EXPORT CPU final { bool has_dot_prod_; bool has_lse_; bool has_mte_; + bool has_pmull1q_; 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 210885af3c3c0a..14203861b82187 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/page-allocator.cc b/deps/v8/src/base/page-allocator.cc index 7303c5ed589b6d..97ce70360bf9cf 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 c563693d461cad..04447e65fd0927 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 f0fc18648dde3a..00000000000000 --- 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 529a073040af1f..15910387d98178 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 99be31da70195d..0091d0d71d6a74 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 c50bb4611b9b3f..b4a6b7a5e5964d 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 3f6306bcf15c08..33fea672bbfc41 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 edaab3a7a6b42f..cb152047657a8e 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 00000000000000..bf3b9703d34bdc --- /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