diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index e095f812659d7a..b39fbd633128d7 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -103,11 +103,13 @@ Dominic Chen Dominic Farolini Douglas Crosher Dusan Milosavljevic +Eden Wang Eric Rannaud Erich Ocean Evan Lucas Fedor Indutny Felix Geisendörfer +Feng Yu Filipe David Manana Franziska Hinkelmann Gao Sheng diff --git a/deps/v8/BUILD.bazel b/deps/v8/BUILD.bazel index 279e3e55a0dca8..bd03deb8069620 100644 --- a/deps/v8/BUILD.bazel +++ b/deps/v8/BUILD.bazel @@ -579,7 +579,6 @@ filegroup( "src/base/address-region.h", "src/base/atomic-utils.h", "src/base/atomicops.h", - "src/base/atomicops_internals_atomicword_compat.h", "src/base/base-export.h", "src/base/bit-field.h", "src/base/bits-iterator.h", @@ -689,6 +688,7 @@ filegroup( "@v8//bazel/config:is_linux": [ "src/base/debug/stack_trace_posix.cc", "src/base/platform/platform-linux.cc", + "src/base/platform/platform-linux.h", ], "@v8//bazel/config:is_android": [ "src/base/debug/stack_trace_android.cc", @@ -912,7 +912,7 @@ filegroup( "src/objects/js-proxy.tq", "src/objects/js-regexp-string-iterator.tq", "src/objects/js-regexp.tq", - "src/objects/js-shadow-realms.tq", + "src/objects/js-shadow-realm.tq", "src/objects/js-struct.tq", "src/objects/js-temporal-objects.tq", "src/objects/js-weak-refs.tq", @@ -1034,6 +1034,15 @@ filegroup( ], ) +# Default setting for v8_enable_pointer_compression when target is x64. +selects.config_setting_group( + name = "is_v8_enable_webassembly_on_non_android_posix_x64", + match_all = [ + ":is_v8_enable_webassembly", + "@v8//bazel/config:is_non_android_posix_x64", + ], +) + filegroup( name = "v8_base_without_compiler_files", srcs = [ @@ -1110,7 +1119,7 @@ filegroup( "src/builtins/builtins-promise.h", "src/builtins/builtins-reflect.cc", "src/builtins/builtins-regexp.cc", - "src/builtins/builtins-shadow-realms.cc", + "src/builtins/builtins-shadow-realm.cc", "src/builtins/builtins-sharedarraybuffer.cc", "src/builtins/builtins-string.cc", "src/builtins/builtins-struct.cc", @@ -1121,6 +1130,7 @@ filegroup( "src/builtins/builtins-utils-inl.h", "src/builtins/builtins-utils.h", "src/builtins/builtins-weak-refs.cc", + "src/builtins/builtins-web-snapshots.cc", "src/builtins/builtins.cc", "src/builtins/builtins.h", "src/builtins/constants-table-builder.cc", @@ -1205,6 +1215,9 @@ filegroup( "src/common/assert-scope.h", "src/common/allow-deprecated.h", "src/common/checks.h", + "src/common/code-memory-access-inl.h", + "src/common/code-memory-access.cc", + "src/common/code-memory-access.h", "src/common/high-allocation-throughput-scope.h", "src/common/message-template.h", "src/common/operation.h", @@ -1595,8 +1608,8 @@ filegroup( "src/logging/local-logger.cc", "src/logging/local-logger.h", "src/logging/log-inl.h", - "src/logging/log-utils.cc", - "src/logging/log-utils.h", + "src/logging/log-file.cc", + "src/logging/log-file.h", "src/logging/log.cc", "src/logging/log.h", "src/logging/metrics.cc", @@ -1714,8 +1727,8 @@ filegroup( "src/objects/js-regexp-string-iterator.h", "src/objects/js-regexp.cc", "src/objects/js-regexp.h", - "src/objects/js-shadow-realms.h", - "src/objects/js-shadow-realms-inl.h", + "src/objects/js-shadow-realm.h", + "src/objects/js-shadow-realm-inl.h", "src/objects/js-struct.h", "src/objects/js-struct-inl.h", "src/objects/js-temporal-objects.h", @@ -1771,9 +1784,6 @@ filegroup( "src/objects/ordered-hash-table-inl.h", "src/objects/ordered-hash-table.cc", "src/objects/ordered-hash-table.h", - "src/objects/osr-optimized-code-cache-inl.h", - "src/objects/osr-optimized-code-cache.cc", - "src/objects/osr-optimized-code-cache.h", "src/objects/primitive-heap-object-inl.h", "src/objects/primitive-heap-object.h", "src/objects/promise-inl.h", @@ -1994,6 +2004,7 @@ filegroup( "src/runtime/runtime-shadow-realm.cc", "src/runtime/runtime-strings.cc", "src/runtime/runtime-symbol.cc", + "src/runtime/runtime-temporal.cc", "src/runtime/runtime-test.cc", "src/runtime/runtime-trace.cc", "src/runtime/runtime-typedarray.cc", @@ -2097,12 +2108,6 @@ filegroup( "src/tracing/traced-value.h", "src/tracing/tracing-category-observer.cc", "src/tracing/tracing-category-observer.h", - "src/trap-handler/handler-inside-posix.h", - "src/trap-handler/handler-inside.cc", - "src/trap-handler/handler-outside.cc", - "src/trap-handler/handler-shared.cc", - "src/trap-handler/trap-handler-internal.h", - "src/trap-handler/trap-handler.h", "src/utils/address-map.cc", "src/utils/address-map.h", "src/utils/allocation.cc", @@ -2386,7 +2391,11 @@ filegroup( ], }) + select({ # Only for x64 builds and for arm64 with x64 host simulator. - "@v8//bazel/config:is_non_android_posix_x64": [ + ":is_v8_enable_webassembly_on_non_android_posix_x64": [ + "src/trap-handler/handler-inside-posix.cc", + "src/trap-handler/handler-outside-posix.cc", + ], + "@v8//bazel/config:is_macos_arm64": [ "src/trap-handler/handler-inside-posix.cc", "src/trap-handler/handler-outside-posix.cc", ], @@ -2423,6 +2432,7 @@ filegroup( "src/compiler/int64-lowering.h", "src/compiler/wasm-compiler.h", "src/compiler/wasm-escape-analysis.h", + "src/compiler/wasm-graph-assembler.h", "src/compiler/wasm-inlining.h", "src/compiler/wasm-loop-peeling.h", "src/debug/debug-wasm-objects.cc", @@ -2430,6 +2440,14 @@ filegroup( "src/debug/debug-wasm-objects-inl.h", "src/runtime/runtime-test-wasm.cc", "src/runtime/runtime-wasm.cc", + "src/trap-handler/handler-inside-posix.h", + "src/trap-handler/handler-inside.cc", + "src/trap-handler/handler-outside.cc", + "src/trap-handler/handler-shared.cc", + "src/trap-handler/trap-handler-internal.h", + "src/trap-handler/trap-handler.h", + "src/wasm/assembler-buffer-cache.cc", + "src/wasm/assembler-buffer-cache.h", "src/wasm/baseline/liftoff-assembler.cc", "src/wasm/baseline/liftoff-assembler-defs.h", "src/wasm/baseline/liftoff-assembler.h", @@ -2793,6 +2811,16 @@ filegroup( "src/compiler/state-values-utils.h", "src/compiler/store-store-elimination.cc", "src/compiler/store-store-elimination.h", + "src/compiler/turboshaft/assembler.h", + "src/compiler/turboshaft/deopt-data.h", + "src/compiler/turboshaft/graph-builder.cc", + "src/compiler/turboshaft/graph-builder.h", + "src/compiler/turboshaft/graph.cc", + "src/compiler/turboshaft/graph.h", + "src/compiler/turboshaft/operations.cc", + "src/compiler/turboshaft/operations.h", + "src/compiler/turboshaft/recreate-schedule.cc", + "src/compiler/turboshaft/recreate-schedule.h", "src/compiler/type-cache.cc", "src/compiler/type-cache.h", "src/compiler/type-narrowing-reducer.cc", @@ -2816,6 +2844,7 @@ filegroup( "src/compiler/wasm-compiler.cc", "src/compiler/wasm-loop-peeling.cc", "src/compiler/wasm-escape-analysis.cc", + "src/compiler/wasm-graph-assembler.cc", "src/compiler/wasm-inlining.cc", ], "//conditions:default": [], @@ -2863,7 +2892,7 @@ filegroup( "src/builtins/builtins-proxy-gen.h", "src/builtins/builtins-regexp-gen.cc", "src/builtins/builtins-regexp-gen.h", - "src/builtins/builtins-shadowrealm-gen.cc", + "src/builtins/builtins-shadow-realm-gen.cc", "src/builtins/builtins-sharedarraybuffer-gen.cc", "src/builtins/builtins-string-gen.cc", "src/builtins/builtins-string-gen.h", @@ -3136,6 +3165,8 @@ filegroup( "src/inspector/v8-string-conversions.h", "src/inspector/v8-value-utils.cc", "src/inspector/v8-value-utils.h", + "src/inspector/v8-webdriver-serializer.cc", + "src/inspector/v8-webdriver-serializer.h", "src/inspector/value-mirror.cc", "src/inspector/value-mirror.h", ":crdtp_platform_files", @@ -3596,7 +3627,7 @@ v8_binary_non_pointer_compression( alias( name = "v8ci", - actual = "icu/v8", + actual = "noicu/v8", ) # ================================================= diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn index 988c907d964a25..9ddff70ab939c8 100644 --- a/deps/v8/BUILD.gn +++ b/deps/v8/BUILD.gn @@ -180,10 +180,13 @@ declare_args() { # chrome --no-sandbox --disable-extensions # --js-flags="--turbo-profiling-log-builtins --logfile=path/to/v8.log" # "http://localhost/test-suite" - # 3. Optionally repeat step 2 for additional workloads, and concatenate all of - # the resulting log files into a single file. - # 4. Build again with v8_builtins_profiling_log_file set to the file created - # in steps 2-3. + # 3. Run tools/get_hints.py to produce the branch hints, selecting min_count + # and threshold_ratio as you wish. + # 4. Optionally repeat steps 2-3 for additional workloads, and use + # tools/combine_hints.py to combine the hints produced in step 3 into a + # single file. + # 5. Build again with v8_builtins_profiling_log_file set to the file created + # in step 3 or 4. v8_builtins_profiling_log_file = "" # Enables various testing features. @@ -418,7 +421,7 @@ if (v8_enable_zone_compression == "") { } if (v8_enable_short_builtin_calls == "") { v8_enable_short_builtin_calls = - v8_current_cpu == "x64" || (!is_android && v8_current_cpu == "arm64") + v8_current_cpu == "x64" || v8_current_cpu == "arm64" } if (v8_enable_external_code_space == "") { v8_enable_external_code_space = @@ -498,6 +501,18 @@ if (v8_enable_sandbox == "") { v8_enable_external_code_space } +# Enable sandboxed pointers on desktop when the sandbox is enabled. +if (v8_enable_sandbox) { + # When sanitizers are enabled, PartitionAlloc forwards allocations to malloc + # instead of allocating from its Pools and so isn't compatible with the + # sandbox. As such, disable the sandbox there. See https://crbug.com/1323174 + if (!is_asan && !is_hwasan && !is_lsan && !is_tsan && !is_msan) { + v8_enable_sandboxed_pointers = + target_os != "fuchsia" && target_os != "android" && + target_os != "chromeos" + } +} + # Enable all available sandbox features if sandbox future is enabled. if (v8_enable_sandbox_future) { v8_enable_sandboxed_pointers = true @@ -564,9 +579,6 @@ if (v8_enable_single_generation == true) { "Requires unconditional write barriers or none (which disables incremental marking)") } -assert(!v8_enable_conservative_stack_scanning || v8_enable_single_generation, - "Conservative stack scanning requires single generation") - if (v8_fuchsia_use_vmex_resource) { assert(target_os == "fuchsia", "VMEX resource only available on Fuchsia") } @@ -787,6 +799,9 @@ if (cppgc_enable_object_names) { } if (cppgc_enable_caged_heap) { enabled_external_cppgc_defines += [ "CPPGC_CAGED_HEAP" ] + + # Always enable young generation compile time flag if caged heap is enabled. + cppgc_enable_young_generation = true } if (cppgc_enable_young_generation) { enabled_external_cppgc_defines += [ "CPPGC_YOUNG_GENERATION" ] @@ -1470,7 +1485,7 @@ config("toolchain") { # For code that is hot during mksnapshot. In fast-mksnapshot builds, we # optimize some files even in debug builds to speed up mksnapshot times. -config("always_optimize") { +config("always_turbofanimize") { configs = [ ":internal_config" ] # TODO(crbug.com/621335) Rework this so that we don't have the confusion @@ -1786,7 +1801,7 @@ torque_files = [ "src/objects/js-proxy.tq", "src/objects/js-regexp-string-iterator.tq", "src/objects/js-regexp.tq", - "src/objects/js-shadow-realms.tq", + "src/objects/js-shadow-realm.tq", "src/objects/js-struct.tq", "src/objects/js-temporal-objects.tq", "src/objects/js-weak-refs.tq", @@ -2365,7 +2380,7 @@ v8_source_set("v8_initializers") { "src/builtins/builtins-proxy-gen.h", "src/builtins/builtins-regexp-gen.cc", "src/builtins/builtins-regexp-gen.h", - "src/builtins/builtins-shadowrealm-gen.cc", + "src/builtins/builtins-shadow-realm-gen.cc", "src/builtins/builtins-sharedarraybuffer-gen.cc", "src/builtins/builtins-string-gen.cc", "src/builtins/builtins-string-gen.h", @@ -2750,6 +2765,8 @@ v8_header_set("v8_internal_headers") { "src/common/allow-deprecated.h", "src/common/assert-scope.h", "src/common/checks.h", + "src/common/code-memory-access-inl.h", + "src/common/code-memory-access.h", "src/common/high-allocation-throughput-scope.h", "src/common/message-template.h", "src/common/operation.h", @@ -2874,6 +2891,12 @@ v8_header_set("v8_internal_headers") { "src/compiler/simplified-operator.h", "src/compiler/state-values-utils.h", "src/compiler/store-store-elimination.h", + "src/compiler/turboshaft/assembler.h", + "src/compiler/turboshaft/deopt-data.h", + "src/compiler/turboshaft/graph-builder.h", + "src/compiler/turboshaft/graph.h", + "src/compiler/turboshaft/operations.h", + "src/compiler/turboshaft/recreate-schedule.h", "src/compiler/type-cache.h", "src/compiler/type-narrowing-reducer.h", "src/compiler/typed-optimization.h", @@ -3108,8 +3131,8 @@ v8_header_set("v8_internal_headers") { "src/logging/counters-scopes.h", "src/logging/counters.h", "src/logging/local-logger.h", + "src/logging/log-file.h", "src/logging/log-inl.h", - "src/logging/log-utils.h", "src/logging/log.h", "src/logging/metrics.h", "src/logging/runtime-call-stats-scope.h", @@ -3207,8 +3230,8 @@ v8_header_set("v8_internal_headers") { "src/objects/js-regexp.h", "src/objects/js-segments-inl.h", "src/objects/js-segments.h", - "src/objects/js-shadow-realms-inl.h", - "src/objects/js-shadow-realms.h", + "src/objects/js-shadow-realm-inl.h", + "src/objects/js-shadow-realm.h", "src/objects/js-struct-inl.h", "src/objects/js-struct.h", "src/objects/js-temporal-objects-inl.h", @@ -3251,8 +3274,6 @@ v8_header_set("v8_internal_headers") { "src/objects/option-utils.h", "src/objects/ordered-hash-table-inl.h", "src/objects/ordered-hash-table.h", - "src/objects/osr-optimized-code-cache-inl.h", - "src/objects/osr-optimized-code-cache.h", "src/objects/primitive-heap-object-inl.h", "src/objects/primitive-heap-object.h", "src/objects/promise-inl.h", @@ -3442,12 +3463,14 @@ v8_header_set("v8_internal_headers") { "src/utils/bit-vector.h", "src/utils/boxed-float.h", "src/utils/detachable-vector.h", + "src/utils/hex-format.h", "src/utils/identity-map.h", "src/utils/locked-queue-inl.h", "src/utils/locked-queue.h", "src/utils/memcopy.h", "src/utils/ostreams.h", "src/utils/scoped-list.h", + "src/utils/sha-256.h", "src/utils/utils-inl.h", "src/utils/utils.h", "src/utils/version.h", @@ -3507,12 +3530,14 @@ v8_header_set("v8_internal_headers") { "src/compiler/int64-lowering.h", "src/compiler/wasm-compiler.h", "src/compiler/wasm-escape-analysis.h", + "src/compiler/wasm-graph-assembler.h", "src/compiler/wasm-inlining.h", "src/compiler/wasm-loop-peeling.h", "src/debug/debug-wasm-objects-inl.h", "src/debug/debug-wasm-objects.h", "src/trap-handler/trap-handler-internal.h", "src/trap-handler/trap-handler.h", + "src/wasm/assembler-buffer-cache.h", "src/wasm/baseline/liftoff-assembler-defs.h", "src/wasm/baseline/liftoff-assembler.h", "src/wasm/baseline/liftoff-compiler.h", @@ -3991,6 +4016,8 @@ v8_compiler_sources = [ "src/compiler/value-numbering-reducer.cc", "src/compiler/verifier.cc", "src/compiler/zone-stats.cc", + "src/utils/hex-format.cc", + "src/utils/sha-256.cc", ] if (v8_enable_webassembly) { @@ -3998,6 +4025,7 @@ if (v8_enable_webassembly) { "src/compiler/int64-lowering.cc", "src/compiler/wasm-compiler.cc", "src/compiler/wasm-escape-analysis.cc", + "src/compiler/wasm-graph-assembler.cc", "src/compiler/wasm-inlining.cc", "src/compiler/wasm-loop-peeling.cc", ] @@ -4026,7 +4054,7 @@ v8_source_set("v8_compiler_opt") { if (is_debug && !v8_optimized_debug && v8_enable_fast_mksnapshot) { # The :no_optimize config is added to v8_add_configs in v8.gni. remove_configs = [ "//build/config/compiler:no_optimize" ] - configs = [ ":always_optimize" ] + configs = [ ":always_turbofanimize" ] } else { # Without this else branch, gn fails to generate build files for non-debug # builds (because we try to remove a config that is not present). @@ -4058,6 +4086,34 @@ v8_source_set("v8_compiler") { configs = [ ":internal_config" ] } +# The src/compiler files with default optimization behavior. +v8_source_set("v8_turboshaft") { + visibility = [ ":*" ] # Only targets in this file can depend on this. + + sources = [ + "src/compiler/turboshaft/graph-builder.cc", + "src/compiler/turboshaft/graph.cc", + "src/compiler/turboshaft/operations.cc", + "src/compiler/turboshaft/recreate-schedule.cc", + ] + + public_deps = [ + ":generate_bytecode_builtins_list", + ":run_torque", + ":v8_internal_headers", + ":v8_maybe_icu", + ":v8_tracing", + ] + + deps = [ + ":v8_base_without_compiler", + ":v8_libbase", + ":v8_shared_internal_headers", + ] + + configs = [ ":internal_config" ] +} + group("v8_compiler_for_mksnapshot") { if (is_debug && !v8_optimized_debug && v8_enable_fast_mksnapshot) { deps = [ ":v8_compiler_opt" ] @@ -4122,7 +4178,7 @@ v8_source_set("v8_base_without_compiler") { "src/builtins/builtins-object.cc", "src/builtins/builtins-reflect.cc", "src/builtins/builtins-regexp.cc", - "src/builtins/builtins-shadow-realms.cc", + "src/builtins/builtins-shadow-realm.cc", "src/builtins/builtins-sharedarraybuffer.cc", "src/builtins/builtins-string.cc", "src/builtins/builtins-struct.cc", @@ -4131,6 +4187,7 @@ v8_source_set("v8_base_without_compiler") { "src/builtins/builtins-trace.cc", "src/builtins/builtins-typed-array.cc", "src/builtins/builtins-weak-refs.cc", + "src/builtins/builtins-web-snapshots.cc", "src/builtins/builtins.cc", "src/builtins/constants-table-builder.cc", "src/codegen/aligned-slot-allocator.cc", @@ -4163,6 +4220,7 @@ v8_source_set("v8_base_without_compiler") { "src/codegen/turbo-assembler.cc", "src/codegen/unoptimized-compilation-info.cc", "src/common/assert-scope.cc", + "src/common/code-memory-access.cc", "src/compiler-dispatcher/lazy-compile-dispatcher.cc", "src/compiler-dispatcher/optimizing-compile-dispatcher.cc", "src/date/date.cc", @@ -4316,7 +4374,7 @@ v8_source_set("v8_base_without_compiler") { "src/libsampler/sampler.cc", "src/logging/counters.cc", "src/logging/local-logger.cc", - "src/logging/log-utils.cc", + "src/logging/log-file.cc", "src/logging/log.cc", "src/logging/metrics.cc", "src/logging/runtime-call-stats.cc", @@ -4366,7 +4424,6 @@ v8_source_set("v8_base_without_compiler") { "src/objects/objects.cc", "src/objects/option-utils.cc", "src/objects/ordered-hash-table.cc", - "src/objects/osr-optimized-code-cache.cc", "src/objects/property-descriptor.cc", "src/objects/property.cc", "src/objects/scope-info.cc", @@ -4458,6 +4515,7 @@ v8_source_set("v8_base_without_compiler") { "src/runtime/runtime-shadow-realm.cc", "src/runtime/runtime-strings.cc", "src/runtime/runtime-symbol.cc", + "src/runtime/runtime-temporal.cc", "src/runtime/runtime-test.cc", "src/runtime/runtime-trace.cc", "src/runtime/runtime-typedarray.cc", @@ -4544,6 +4602,7 @@ v8_source_set("v8_base_without_compiler") { "src/trap-handler/handler-inside.cc", "src/trap-handler/handler-outside.cc", "src/trap-handler/handler-shared.cc", + "src/wasm/assembler-buffer-cache.cc", "src/wasm/baseline/liftoff-assembler.cc", "src/wasm/baseline/liftoff-compiler.cc", "src/wasm/canonical-types.cc", @@ -4966,6 +5025,7 @@ group("v8_base") { public_deps = [ ":v8_base_without_compiler", ":v8_compiler", + ":v8_turboshaft", ] } @@ -5057,7 +5117,7 @@ v8_source_set("torque_base") { if (is_debug && !v8_optimized_debug && v8_enable_fast_torque) { # The :no_optimize config is added to v8_add_configs in v8.gni. remove_configs += [ "//build/config/compiler:no_optimize" ] - configs += [ ":always_optimize" ] + configs += [ ":always_turbofanimize" ] } } @@ -5101,7 +5161,6 @@ v8_component("v8_libbase") { "src/base/address-region.h", "src/base/atomic-utils.h", "src/base/atomicops.h", - "src/base/atomicops_internals_atomicword_compat.h", "src/base/base-export.h", "src/base/bit-field.h", "src/base/bits-iterator.h", @@ -5243,6 +5302,7 @@ v8_component("v8_libbase") { sources += [ "src/base/debug/stack_trace_posix.cc", "src/base/platform/platform-linux.cc", + "src/base/platform/platform-linux.h", ] libs = [ @@ -5874,6 +5934,7 @@ if (current_toolchain == v8_snapshot_toolchain) { ":v8_maybe_icu", ":v8_shared_internal_headers", ":v8_tracing", + ":v8_turboshaft", "//build/win:default_exe_manifest", ] } diff --git a/deps/v8/DEPS b/deps/v8/DEPS index 54ac85a4bdbb8a..29936d4d23eb46 100644 --- a/deps/v8/DEPS +++ b/deps/v8/DEPS @@ -36,14 +36,22 @@ vars = { 'check_v8_header_includes': False, 'checkout_reclient': False, + # By default, download the fuchsia sdk from the public sdk directory. + 'fuchsia_sdk_cipd_prefix': 'fuchsia/sdk/gn/', + # reclient CIPD package version 'reclient_version': 're_client_version:0.40.0.40ff5a5', # GN CIPD package version. - 'gn_version': 'git_revision:ae110f8b525009255ba1f9ae96982176d3bfad3d', + 'gn_version': 'git_revision:bf4e17dc67b2a2007475415e3f9e1d1cf32f6e35', # luci-go CIPD package version. - 'luci_go': 'git_revision:6da0608e4fa8a3c6d1fa4f855485c0038b05bf72', + 'luci_go': 'git_revision:2aa3d7e5e8662c5193059a490f07b7d91331933e', + + # 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:8.20220510.2.1', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_build-tools_version @@ -56,7 +64,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_extras_version # and whatever else without interference from each other. - 'android_sdk_extras_version': 'ppQ4TnqDvBHQ3lXx5KPq97egzF5X2FFyOrVHkGmiTMQC', + 'android_sdk_extras_version': 'bY55nDqO6FAm6FkGIj09sh2KW9oqAkCGKjYok5nUvBMC', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_patcher_version # and whatever else without interference from each other. @@ -83,20 +91,20 @@ deps = { 'base/trace_event/common': Var('chromium_url') + '/chromium/src/base/trace_event/common.git' + '@' + 'd115b033c4e53666b535cbd1985ffe60badad082', 'build': - Var('chromium_url') + '/chromium/src/build.git' + '@' + 'b37c340767cf9e7777d4ca5a588c34c5744df9b2', + Var('chromium_url') + '/chromium/src/build.git' + '@' + '1c34f36484f43be915b48b090527d87356c72ce8', 'buildtools': - Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + 'c2e4795660817c2776dbabd778b92ed58c074032', + Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + '7208eddba161d85108097c3c5975264c04e3cad8', 'buildtools/clang_format/script': Var('chromium_url') + '/external/github.com/llvm/llvm-project/clang/tools/clang-format.git' + '@' + 'e435ad79c17b1888b34df88d6a30a094936e3836', 'buildtools/linux64': { 'packages': [ { - 'package': 'gn/gn/linux-amd64', + 'package': 'gn/gn/linux-${{arch}}', 'version': Var('gn_version'), } ], 'dep_type': 'cipd', - 'condition': 'host_os == "linux"', + 'condition': 'host_os == "linux" and host_cpu != "s390" and host_cpu != "ppc"', }, 'buildtools/mac': { 'packages': [ @@ -111,9 +119,9 @@ deps = { 'buildtools/third_party/libc++/trunk': Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxx.git' + '@' + '79a2e924d96e2fc1e4b937c42efd08898fa472d7', 'buildtools/third_party/libc++abi/trunk': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + 'e025ba5dc85202540099d7cd8e72eae2d4ee9e33', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + 'ecff200716d0e23f46d01dfcebac61ac7e00b15b', 'buildtools/third_party/libunwind/trunk': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/libunwind.git' + '@' + 'c39fea88739be63a2d5590a938ce19d762b915fc', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libunwind.git' + '@' + '3d54d41c27afba1e3a83303c1bc005d303d40eb6', 'buildtools/win': { 'packages': [ { @@ -139,7 +147,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' + '@' + 'd7c0a2076c2b0c1531aef7069d4abe70eec44ee3', + Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + '8f5c7aed093e753649500a538ce62f8b8c035aa4', 'third_party/aemu-linux-x64': { 'packages': [ { @@ -165,7 +173,7 @@ deps = { 'condition': 'checkout_android', }, 'third_party/android_platform': { - 'url': Var('chromium_url') + '/chromium/src/third_party/android_platform.git' + '@' + '2760db43ffc8b074cb7960c90b5254f74a5c299a', + 'url': Var('chromium_url') + '/chromium/src/third_party/android_platform.git' + '@' + '5ecb4635f03307cc461051c2d90b1e2397483f49', 'condition': 'checkout_android', }, 'third_party/android_sdk/public': { @@ -207,7 +215,7 @@ deps = { 'dep_type': 'cipd', }, 'third_party/catapult': { - 'url': Var('chromium_url') + '/catapult.git' + '@' + '3a1ae18f882d024686144edbec3050aae055f146', + 'url': Var('chromium_url') + '/catapult.git' + '@' + 'd1ddc12119ab1365426dac869c09711ee3a463ed', 'condition': 'checkout_android', }, 'third_party/colorama/src': { @@ -215,18 +223,24 @@ deps = { 'condition': 'checkout_android', }, 'third_party/depot_tools': - Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + '3b97fa826eee4bd1978c4c049038b1e4f201e8f2', - 'third_party/fuchsia-sdk': { - 'url': Var('chromium_url') + '/chromium/src/third_party/fuchsia-sdk.git' + '@' + '7c9c220d13ab367d49420144a257886ebfbce278', + Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + '31bfd519956b011b822769f227fd7dcf679f2f43', + 'third_party/fuchsia-sdk/sdk': { + 'packages': [ + { + 'package': Var('fuchsia_sdk_cipd_prefix') + '${{platform}}', + 'version': Var('fuchsia_version'), + }, + ], 'condition': 'checkout_fuchsia', + 'dep_type': 'cipd', }, 'third_party/google_benchmark/src': { - 'url': Var('chromium_url') + '/external/github.com/google/benchmark.git' + '@' + 'dc901ff9090e2b931433790cc44afc3af3b09ab2', + 'url': Var('chromium_url') + '/external/github.com/google/benchmark.git' + '@' + 'bc4639c15443d7bc134de57a39833cf97018f4c1', }, 'third_party/googletest/src': Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + 'af29db7ec28d6df1c7f0f745186884091e602e07', 'third_party/icu': - Var('chromium_url') + '/chromium/deps/icu.git' + '@' + '1fd0dbea04448c3f73fe5cb7599f9472f0f107f1', + Var('chromium_url') + '/chromium/deps/icu.git' + '@' + '585942f33d939a11f4600bd5042649b7ca189008', 'third_party/instrumented_libraries': Var('chromium_url') + '/chromium/src/third_party/instrumented_libraries.git' + '@' + 'e09c4b66b6e87116eb190651421f1a6e2f3b9c52', 'third_party/ittapi': { @@ -272,9 +286,9 @@ deps = { 'condition': 'checkout_android', }, 'third_party/zlib': - Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + 'a6d209ab932df0f1c9d5b7dc67cfa74e8a3272c0', + Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + '9979c19f11314156490b53da91df08c934a3c0d4', 'tools/clang': - Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + 'b5e2f7c16bbf3aefc9354e8fbad3de0a543f2193', + Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + '9da95105864734ee87f47e0de638a09eb088338b', 'tools/luci-go': { 'packages': [ { @@ -580,15 +594,6 @@ hooks = [ 'action': ['python3', 'build/util/lastchange.py', '-o', 'build/util/LASTCHANGE'], }, - { - 'name': 'Download Fuchsia SDK', - 'pattern': '.', - 'condition': 'checkout_fuchsia', - 'action': [ - 'python3', - 'build/fuchsia/update_sdk.py', - ], - }, { 'name': 'Download Fuchsia system images', 'pattern': '.', diff --git a/deps/v8/bazel/config/BUILD.bazel b/deps/v8/bazel/config/BUILD.bazel index ffa9ef040722b4..448260de88465d 100644 --- a/deps/v8/bazel/config/BUILD.bazel +++ b/deps/v8/bazel/config/BUILD.bazel @@ -290,6 +290,14 @@ selects.config_setting_group( ], ) +selects.config_setting_group( + name = "is_macos_arm64", + match_all = [ + ":is_macos", + ":is_arm64", + ], +) + config_setting( name = "is_compiler_default", flag_values = { diff --git a/deps/v8/gni/release_branch_toggle.gni b/deps/v8/gni/release_branch_toggle.gni index 43e3b6ae567631..c502c8c62e5836 100644 --- a/deps/v8/gni/release_branch_toggle.gni +++ b/deps/v8/gni/release_branch_toggle.gni @@ -4,4 +4,4 @@ declare_args() { is_on_release_branch = true -} +} \ No newline at end of file diff --git a/deps/v8/include/cppgc/heap-statistics.h b/deps/v8/include/cppgc/heap-statistics.h index 8e626596e5b07b..de3b435c735c8e 100644 --- a/deps/v8/include/cppgc/heap-statistics.h +++ b/deps/v8/include/cppgc/heap-statistics.h @@ -56,7 +56,7 @@ struct HeapStatistics final { /** Amount of memory actually used on the page. */ size_t used_size_bytes = 0; /** Statistics for object allocated on the page. Filled only when - * NameProvider::HideInternalNames() is false. */ + * NameProvider::SupportsCppClassNamesAsObjectNames() is true. */ std::vector object_statistics; }; diff --git a/deps/v8/include/cppgc/heap.h b/deps/v8/include/cppgc/heap.h index aa3c6f468a21de..2ebda47bf60ab4 100644 --- a/deps/v8/include/cppgc/heap.h +++ b/deps/v8/include/cppgc/heap.h @@ -59,7 +59,7 @@ class V8_EXPORT Heap { }; /** - * Specifies supported marking types + * Specifies supported marking types. */ enum class MarkingType : uint8_t { /** @@ -79,7 +79,7 @@ class V8_EXPORT Heap { }; /** - * Specifies supported sweeping types + * Specifies supported sweeping types. */ enum class SweepingType : uint8_t { /** diff --git a/deps/v8/include/cppgc/internal/caged-heap-local-data.h b/deps/v8/include/cppgc/internal/caged-heap-local-data.h index a27649c17fce5b..081c88e30e0bbb 100644 --- a/deps/v8/include/cppgc/internal/caged-heap-local-data.h +++ b/deps/v8/include/cppgc/internal/caged-heap-local-data.h @@ -14,6 +14,10 @@ #include "cppgc/platform.h" #include "v8config.h" // NOLINT(build/include_directory) +#if __cpp_lib_bitopts +#include +#endif // __cpp_lib_bitopts + namespace cppgc { namespace internal { @@ -22,24 +26,31 @@ class HeapBase; #if defined(CPPGC_YOUNG_GENERATION) // AgeTable is the bytemap needed for the fast generation check in the write -// barrier. AgeTable contains entries that correspond to 512 bytes memory +// barrier. AgeTable contains entries that correspond to 4096 bytes memory // regions (cards). Each entry in the table represents generation of the objects // that reside on the corresponding card (young, old or mixed). -class AgeTable final { +class V8_EXPORT AgeTable final { static constexpr size_t kRequiredSize = 1 * api_constants::kMB; static constexpr size_t kAllocationGranularity = api_constants::kAllocationGranularity; public: + // Represents age of the objects living on a single card. enum class Age : uint8_t { kOld, kYoung, kMixed }; + // When setting age for a range, consider or ignore ages of the adjacent + // cards. + enum class AdjacentCardsPolicy : uint8_t { kConsider, kIgnore }; static constexpr size_t kCardSizeInBytes = - (api_constants::kCagedHeapReservationSize / kAllocationGranularity) / - kRequiredSize; + api_constants::kCagedHeapReservationSize / kRequiredSize; void SetAge(uintptr_t cage_offset, Age age) { table_[card(cage_offset)] = age; } + + void SetAgeForRange(uintptr_t cage_offset_begin, uintptr_t cage_offset_end, + Age age, AdjacentCardsPolicy adjacent_cards_policy); + V8_INLINE Age GetAge(uintptr_t cage_offset) const { return table_[card(cage_offset)]; } @@ -49,7 +60,15 @@ class AgeTable final { private: V8_INLINE size_t card(uintptr_t offset) const { constexpr size_t kGranularityBits = +#if __cpp_lib_bitopts + std::countr_zero(static_cast(kCardSizeInBytes)); +#elif V8_HAS_BUILTIN_CTZ __builtin_ctz(static_cast(kCardSizeInBytes)); +#else //! V8_HAS_BUILTIN_CTZ + // Hardcode and check with assert. + 12; +#endif // !V8_HAS_BUILTIN_CTZ + static_assert((1 << kGranularityBits) == kCardSizeInBytes); const size_t entry = offset >> kGranularityBits; CPPGC_DCHECK(table_.size() > entry); return entry; @@ -67,6 +86,7 @@ struct CagedHeapLocalData final { CagedHeapLocalData(HeapBase&, PageAllocator&); bool is_incremental_marking_in_progress = false; + bool is_young_generation_enabled = false; HeapBase& heap_base; #if defined(CPPGC_YOUNG_GENERATION) AgeTable age_table; diff --git a/deps/v8/include/cppgc/internal/name-trait.h b/deps/v8/include/cppgc/internal/name-trait.h index 32a334785926d7..ece49cbe75e721 100644 --- a/deps/v8/include/cppgc/internal/name-trait.h +++ b/deps/v8/include/cppgc/internal/name-trait.h @@ -6,6 +6,7 @@ #define INCLUDE_CPPGC_INTERNAL_NAME_TRAIT_H_ #include +#include #include #include "cppgc/name-provider.h" @@ -58,6 +59,11 @@ struct HeapObjectName { bool name_was_hidden; }; +enum class HeapObjectNameForUnnamedObject : uint8_t { + kUseClassNameIfSupported, + kUseHiddenName, +}; + class V8_EXPORT NameTraitBase { protected: static HeapObjectName GetNameFromTypeSignature(const char*); @@ -78,16 +84,24 @@ class NameTrait final : public NameTraitBase { #endif // !CPPGC_SUPPORTS_OBJECT_NAMES } - static HeapObjectName GetName(const void* obj) { - return GetNameFor(static_cast(obj)); + static HeapObjectName GetName( + const void* obj, HeapObjectNameForUnnamedObject name_retrieval_mode) { + return GetNameFor(static_cast(obj), name_retrieval_mode); } private: - static HeapObjectName GetNameFor(const NameProvider* name_provider) { + static HeapObjectName GetNameFor(const NameProvider* name_provider, + HeapObjectNameForUnnamedObject) { + // Objects inheriting from `NameProvider` are not considered unnamed as + // users already provided a name for them. return {name_provider->GetHumanReadableName(), false}; } - static HeapObjectName GetNameFor(...) { + static HeapObjectName GetNameFor( + const void*, HeapObjectNameForUnnamedObject name_retrieval_mode) { + if (name_retrieval_mode == HeapObjectNameForUnnamedObject::kUseHiddenName) + return {NameProvider::kHiddenName, true}; + #if CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME return {GetTypename(), false}; #elif CPPGC_SUPPORTS_OBJECT_NAMES @@ -112,7 +126,8 @@ class NameTrait final : public NameTraitBase { } }; -using NameCallback = HeapObjectName (*)(const void*); +using NameCallback = HeapObjectName (*)(const void*, + HeapObjectNameForUnnamedObject); } // namespace internal } // namespace cppgc diff --git a/deps/v8/include/cppgc/internal/write-barrier.h b/deps/v8/include/cppgc/internal/write-barrier.h index bfabc31e13a969..555d3269382a03 100644 --- a/deps/v8/include/cppgc/internal/write-barrier.h +++ b/deps/v8/include/cppgc/internal/write-barrier.h @@ -95,12 +95,10 @@ class V8_EXPORT WriteBarrier final { static void CheckParams(Type expected_type, const Params& params) {} #endif // !V8_ENABLE_CHECKS - // The IncrementalOrConcurrentUpdater class allows cppgc internal to update - // |incremental_or_concurrent_marking_flag_|. - class IncrementalOrConcurrentMarkingFlagUpdater; - static bool IsAnyIncrementalOrConcurrentMarking() { - return incremental_or_concurrent_marking_flag_.MightBeEntered(); - } + // The FlagUpdater class allows cppgc internal to update + // |write_barrier_enabled_|. + class FlagUpdater; + static bool IsEnabled() { return write_barrier_enabled_.MightBeEntered(); } private: WriteBarrier() = delete; @@ -130,12 +128,13 @@ class V8_EXPORT WriteBarrier final { const CagedHeapLocalData& local_data, const void* object); #endif // CPPGC_YOUNG_GENERATION - static AtomicEntryFlag incremental_or_concurrent_marking_flag_; + static AtomicEntryFlag write_barrier_enabled_; }; template V8_INLINE WriteBarrier::Type SetAndReturnType(WriteBarrier::Params& params) { - if (type == WriteBarrier::Type::kNone) return WriteBarrier::Type::kNone; + if constexpr (type == WriteBarrier::Type::kNone) + return WriteBarrier::Type::kNone; #if V8_ENABLE_CHECKS params.type = type; #endif // !V8_ENABLE_CHECKS @@ -180,18 +179,24 @@ class V8_EXPORT WriteBarrierTypeForCagedHeapPolicy final { static V8_INLINE bool TryGetCagedHeap(const void* slot, const void* value, WriteBarrier::Params& params) { - // TODO(chromium:1056170): Check if the null check can be folded in with - // the rest of the write barrier. - if (!value) return false; - params.start = reinterpret_cast(value) & - ~(api_constants::kCagedHeapReservationAlignment - 1); - const uintptr_t slot_offset = - reinterpret_cast(slot) - params.start; - if (slot_offset > api_constants::kCagedHeapReservationSize) { - // Check if slot is on stack or value is sentinel or nullptr. This relies - // on the fact that kSentinelPointer is encoded as 0x1. - return false; - } + // The compiler must fold these checks into a single one. + if (!value || value == kSentinelPointer) return false; + + // Now we are certain that |value| points within the cage. + const uintptr_t real_cage_base = + reinterpret_cast(value) & + ~(api_constants::kCagedHeapReservationAlignment - 1); + + const uintptr_t cage_base_from_slot = + reinterpret_cast(slot) & + ~(api_constants::kCagedHeapReservationAlignment - 1); + + // If |cage_base_from_slot| is different from |real_cage_base|, the slot + // must be on stack, bail out. + if (V8_UNLIKELY(real_cage_base != cage_base_from_slot)) return false; + + // Otherwise, set params.start and return. + params.start = real_cage_base; return true; } @@ -209,17 +214,17 @@ struct WriteBarrierTypeForCagedHeapPolicy::ValueModeDispatch< static V8_INLINE WriteBarrier::Type Get(const void* slot, const void* value, WriteBarrier::Params& params, HeapHandleCallback) { -#if !defined(CPPGC_YOUNG_GENERATION) - if (V8_LIKELY(!WriteBarrier::IsAnyIncrementalOrConcurrentMarking())) { + if (V8_LIKELY(!WriteBarrier::IsEnabled())) return SetAndReturnType(params); - } -#endif // !CPPGC_YOUNG_GENERATION - bool within_cage = TryGetCagedHeap(slot, value, params); - if (!within_cage) { - return WriteBarrier::Type::kNone; - } - if (V8_LIKELY(!params.caged_heap().is_incremental_marking_in_progress)) { + + const bool within_cage = TryGetCagedHeap(slot, value, params); + if (!within_cage) return WriteBarrier::Type::kNone; + + const auto& caged_heap = params.caged_heap(); + if (V8_LIKELY(!caged_heap.is_incremental_marking_in_progress)) { #if defined(CPPGC_YOUNG_GENERATION) + if (!caged_heap.is_young_generation_enabled) + return WriteBarrier::Type::kNone; params.heap = reinterpret_cast(params.start); params.slot_offset = reinterpret_cast(slot) - params.start; params.value_offset = reinterpret_cast(value) - params.start; @@ -228,6 +233,8 @@ struct WriteBarrierTypeForCagedHeapPolicy::ValueModeDispatch< return SetAndReturnType(params); #endif // !CPPGC_YOUNG_GENERATION } + + // Use marking barrier. params.heap = reinterpret_cast(params.start); return SetAndReturnType(params); } @@ -240,10 +247,15 @@ struct WriteBarrierTypeForCagedHeapPolicy::ValueModeDispatch< static V8_INLINE WriteBarrier::Type Get(const void* slot, const void*, WriteBarrier::Params& params, HeapHandleCallback callback) { + if (V8_LIKELY(!WriteBarrier::IsEnabled())) + return SetAndReturnType(params); + #if defined(CPPGC_YOUNG_GENERATION) HeapHandle& handle = callback(); if (V8_LIKELY(!IsMarking(handle, params))) { // params.start is populated by IsMarking(). + if (!params.caged_heap().is_young_generation_enabled) + return WriteBarrier::Type::kNone; params.heap = &handle; params.slot_offset = reinterpret_cast(slot) - params.start; // params.value_offset stays 0. @@ -253,15 +265,12 @@ struct WriteBarrierTypeForCagedHeapPolicy::ValueModeDispatch< } return SetAndReturnType(params); } -#else // !CPPGC_YOUNG_GENERATION - if (V8_LIKELY(!WriteBarrier::IsAnyIncrementalOrConcurrentMarking())) { - return SetAndReturnType(params); - } +#else // !defined(CPPGC_YOUNG_GENERATION) HeapHandle& handle = callback(); if (V8_UNLIKELY(!subtle::HeapState::IsMarking(handle))) { return SetAndReturnType(params); } -#endif // !CPPGC_YOUNG_GENERATION +#endif // !defined(CPPGC_YOUNG_GENERATION) params.heap = &handle; return SetAndReturnType(params); } @@ -310,7 +319,7 @@ struct WriteBarrierTypeForNonCagedHeapPolicy::ValueModeDispatch< if (object <= static_cast(kSentinelPointer)) { return SetAndReturnType(params); } - if (V8_LIKELY(!WriteBarrier::IsAnyIncrementalOrConcurrentMarking())) { + if (V8_LIKELY(!WriteBarrier::IsEnabled())) { return SetAndReturnType(params); } if (IsMarking(object, ¶ms.heap)) { @@ -327,7 +336,7 @@ struct WriteBarrierTypeForNonCagedHeapPolicy::ValueModeDispatch< static V8_INLINE WriteBarrier::Type Get(const void*, const void*, WriteBarrier::Params& params, HeapHandleCallback callback) { - if (V8_UNLIKELY(WriteBarrier::IsAnyIncrementalOrConcurrentMarking())) { + if (V8_UNLIKELY(WriteBarrier::IsEnabled())) { HeapHandle& handle = callback(); if (IsMarking(handle)) { params.heap = &handle; diff --git a/deps/v8/include/cppgc/name-provider.h b/deps/v8/include/cppgc/name-provider.h index 224dd4b5d678ec..216f6098d99dd1 100644 --- a/deps/v8/include/cppgc/name-provider.h +++ b/deps/v8/include/cppgc/name-provider.h @@ -37,15 +37,15 @@ class V8_EXPORT NameProvider { static constexpr const char kNoNameDeducible[] = ""; /** - * Indicating whether internal names are hidden or not. + * Indicating whether the build supports extracting C++ names as object names. * * @returns true if C++ names should be hidden and represented by kHiddenName. */ - static constexpr bool HideInternalNames() { + static constexpr bool SupportsCppClassNamesAsObjectNames() { #if CPPGC_SUPPORTS_OBJECT_NAMES - return false; -#else // !CPPGC_SUPPORTS_OBJECT_NAMES return true; +#else // !CPPGC_SUPPORTS_OBJECT_NAMES + return false; #endif // !CPPGC_SUPPORTS_OBJECT_NAMES } diff --git a/deps/v8/include/js_protocol.pdl b/deps/v8/include/js_protocol.pdl index 53a5f4c11dcc02..0421ecdef4cfd0 100644 --- a/deps/v8/include/js_protocol.pdl +++ b/deps/v8/include/js_protocol.pdl @@ -113,6 +113,11 @@ domain Debugger Runtime.RemoteObject this # The value being returned, if the function is at return point. optional Runtime.RemoteObject returnValue + # Valid only while the VM is paused and indicates whether this frame + # can be restarted or not. Note that a `true` value here does not + # guarantee that Debugger#restartFrame with this CallFrameId will be + # successful, but it is very likely. + experimental optional boolean canBeRestarted # Scope description. type Scope extends object @@ -554,7 +559,7 @@ domain Debugger integer endColumn # Specifies script creation context. Runtime.ExecutionContextId executionContextId - # Content hash of the script. + # Content hash of the script, SHA-256. string hash # Embedder-specific auxiliary data. optional object executionContextAuxData @@ -593,7 +598,7 @@ domain Debugger integer endColumn # Specifies script creation context. Runtime.ExecutionContextId executionContextId - # Content hash of the script. + # Content hash of the script, SHA-256. string hash # Embedder-specific auxiliary data. optional object executionContextAuxData @@ -708,18 +713,24 @@ experimental domain HeapProfiler # If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken # when the tracking is stopped. optional boolean reportProgress - optional boolean treatGlobalObjectsAsRoots + # Deprecated in favor of `exposeInternals`. + deprecated optional boolean treatGlobalObjectsAsRoots # If true, numerical values are included in the snapshot optional boolean captureNumericValue + # If true, exposes internals of the snapshot. + experimental optional boolean exposeInternals command takeHeapSnapshot parameters # If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken. optional boolean reportProgress - # If true, a raw snapshot without artificial roots will be generated - optional boolean treatGlobalObjectsAsRoots + # If true, a raw snapshot without artificial roots will be generated. + # Deprecated in favor of `exposeInternals`. + deprecated optional boolean treatGlobalObjectsAsRoots # If true, numerical values are included in the snapshot optional boolean captureNumericValue + # If true, exposes internals of the snapshot. + experimental optional boolean exposeInternals event addHeapSnapshotChunk parameters @@ -1342,7 +1353,9 @@ domain Runtime optional string objectGroup # Whether to throw an exception if side effect cannot be ruled out during evaluation. experimental optional boolean throwOnSideEffect - # Whether the result should be serialized according to https://w3c.github.io/webdriver-bidi. + # Whether the result should contain `webDriverValue`, serialized according to + # https://w3c.github.io/webdriver-bidi. This is mutually exclusive with `returnByValue`, but + # resulting `objectId` is still provided. experimental optional boolean generateWebDriverValue returns # Call result. diff --git a/deps/v8/include/v8-callbacks.h b/deps/v8/include/v8-callbacks.h index 70b9c2ae9308a5..b8c8a1505b9a15 100644 --- a/deps/v8/include/v8-callbacks.h +++ b/deps/v8/include/v8-callbacks.h @@ -216,6 +216,10 @@ using AddHistogramSampleCallback = void (*)(void* histogram, int sample); using FatalErrorCallback = void (*)(const char* location, const char* message); +using LegacyOOMErrorCallback = void (*)(const char* location, bool is_heap_oom); + +// TODO(chromium:1323177): Add a parameter for details, once this is deprecated +// for at least one branch. using OOMErrorCallback = void (*)(const char* location, bool is_heap_oom); using MessageCallback = void (*)(Local message, Local data); @@ -233,6 +237,8 @@ enum class CrashKeyId { kMapSpaceFirstPageAddress, kCodeSpaceFirstPageAddress, kDumpType, + kSnapshotChecksumCalculated, + kSnapshotChecksumExpected, }; using AddCrashKeyCallback = void (*)(CrashKeyId id, const std::string& value); diff --git a/deps/v8/include/v8-embedder-heap.h b/deps/v8/include/v8-embedder-heap.h index 09dbae1fd8778b..01b74dbebc2479 100644 --- a/deps/v8/include/v8-embedder-heap.h +++ b/deps/v8/include/v8-embedder-heap.h @@ -205,10 +205,10 @@ class V8_EXPORT EmbedderHeapTracer { * Returns the v8::Isolate this tracer is attached too and |nullptr| if it * is not attached to any v8::Isolate. */ - v8::Isolate* isolate() const { return isolate_; } + v8::Isolate* isolate() const { return v8_isolate_; } protected: - v8::Isolate* isolate_ = nullptr; + v8::Isolate* v8_isolate_ = nullptr; friend class internal::LocalEmbedderHeapTracer; }; diff --git a/deps/v8/include/v8-exception.h b/deps/v8/include/v8-exception.h index 64126c420a6928..bc058e3fc7b874 100644 --- a/deps/v8/include/v8-exception.h +++ b/deps/v8/include/v8-exception.h @@ -197,7 +197,7 @@ class V8_EXPORT TryCatch { void ResetInternal(); - internal::Isolate* isolate_; + internal::Isolate* i_isolate_; TryCatch* next_; void* exception_; void* message_obj_; diff --git a/deps/v8/include/v8-fast-api-calls.h b/deps/v8/include/v8-fast-api-calls.h index 3403de93eca852..6ef950c10f22b0 100644 --- a/deps/v8/include/v8-fast-api-calls.h +++ b/deps/v8/include/v8-fast-api-calls.h @@ -881,31 +881,6 @@ static constexpr CTypeInfo kTypeInfoFloat64 = * to the requested destination type, is considered unsupported. The operation * returns true on success. `type_info` will be used for conversions. */ -template -V8_DEPRECATED( - "Use TryToCopyAndConvertArrayToCppBuffer()") -bool V8_EXPORT V8_WARN_UNUSED_RESULT - TryCopyAndConvertArrayToCppBuffer(Local src, T* dst, - uint32_t max_length); - -template <> -V8_DEPRECATED( - "Use TryToCopyAndConvertArrayToCppBuffer()") -inline bool V8_WARN_UNUSED_RESULT - TryCopyAndConvertArrayToCppBuffer<&kTypeInfoInt32, int32_t>( - Local src, int32_t* dst, uint32_t max_length) { - return false; -} - -template <> -V8_DEPRECATED( - "Use TryToCopyAndConvertArrayToCppBuffer()") -inline bool V8_WARN_UNUSED_RESULT - TryCopyAndConvertArrayToCppBuffer<&kTypeInfoFloat64, double>( - Local src, double* dst, uint32_t max_length) { - return false; -} - template bool V8_EXPORT V8_WARN_UNUSED_RESULT TryToCopyAndConvertArrayToCppBuffer( Local src, T* dst, uint32_t max_length); diff --git a/deps/v8/include/v8-initialization.h b/deps/v8/include/v8-initialization.h index 3d59c73f7c9caf..48c7fb6b481bc8 100644 --- a/deps/v8/include/v8-initialization.h +++ b/deps/v8/include/v8-initialization.h @@ -184,8 +184,6 @@ class V8_EXPORT V8 { * V8 was disposed. */ static void DisposePlatform(); - V8_DEPRECATED("Use DisposePlatform()") - static void ShutdownPlatform() { DisposePlatform(); } #ifdef V8_SANDBOX // @@ -206,7 +204,7 @@ class V8_EXPORT V8 { * as part of V8::Initialize, at which point this function should be removed. */ static bool InitializeSandbox(); - V8_DEPRECATE_SOON("Use InitializeSandbox()") + V8_DEPRECATED("Use InitializeSandbox()") static bool InitializeVirtualMemoryCage() { return InitializeSandbox(); } /** @@ -224,7 +222,7 @@ class V8_EXPORT V8 { * This function must only be called after initializing the sandbox. */ static VirtualAddressSpace* GetSandboxAddressSpace(); - V8_DEPRECATE_SOON("Use GetSandboxAddressSpace()") + V8_DEPRECATED("Use GetSandboxAddressSpace()") static PageAllocator* GetVirtualMemoryCagePageAllocator(); /** @@ -234,7 +232,7 @@ class V8_EXPORT V8 { * this returns zero. */ static size_t GetSandboxSizeInBytes(); - V8_DEPRECATE_SOON("Use GetSandboxSizeInBytes()") + V8_DEPRECATED("Use GetSandboxSizeInBytes()") static size_t GetVirtualMemoryCageSizeInBytes() { return GetSandboxSizeInBytes(); } @@ -248,7 +246,7 @@ class V8_EXPORT V8 { * insecure sandbox is being used, in which case it will return false. */ static bool IsSandboxConfiguredSecurely(); - V8_DEPRECATE_SOON("Use IsSandboxConfiguredSecurely()") + V8_DEPRECATED("Use IsSandboxConfiguredSecurely()") static bool IsUsingSecureVirtualMemoryCage() { return IsSandboxConfiguredSecurely(); } @@ -273,7 +271,7 @@ class V8_EXPORT V8 { * exceptions in V8-generated code. */ static void SetUnhandledExceptionCallback( - UnhandledExceptionCallback unhandled_exception_callback); + UnhandledExceptionCallback callback); #endif /** @@ -281,8 +279,7 @@ class V8_EXPORT V8 { * v8 has encountered a fatal failure to allocate memory and is about to * terminate. */ - - static void SetFatalMemoryErrorCallback(OOMErrorCallback oom_error_callback); + static void SetFatalMemoryErrorCallback(LegacyOOMErrorCallback callback); /** * Get statistics about the shared memory usage. diff --git a/deps/v8/include/v8-inspector.h b/deps/v8/include/v8-inspector.h index ce5430bd039870..1fb1c2c61a574c 100644 --- a/deps/v8/include/v8-inspector.h +++ b/deps/v8/include/v8-inspector.h @@ -207,10 +207,10 @@ class V8_EXPORT V8InspectorSession { class V8_EXPORT WebDriverValue { public: - explicit WebDriverValue(StringView type, v8::MaybeLocal value = {}) - : type(type), value(value) {} - - StringView type; + explicit WebDriverValue(std::unique_ptr type, + v8::MaybeLocal value = {}) + : type(std::move(type)), value(value) {} + std::unique_ptr type; v8::MaybeLocal value; }; @@ -361,9 +361,18 @@ class V8_EXPORT V8Inspector { virtual void sendNotification(std::unique_ptr message) = 0; virtual void flushProtocolNotifications() = 0; }; + V8_DEPRECATED("Use version with client_is_trusted argument") virtual std::unique_ptr connect(int contextGroupId, - Channel*, - StringView state) = 0; + Channel* channel, + StringView state) { + return connect(contextGroupId, channel, state, kFullyTrusted); + } + enum ClientTrustLevel { kUntrusted, kFullyTrusted }; + virtual std::unique_ptr connect( + int contextGroupId, Channel*, StringView state, + ClientTrustLevel client_trust_level) { + return nullptr; + } // API methods. virtual std::unique_ptr createStackTrace( diff --git a/deps/v8/include/v8-internal.h b/deps/v8/include/v8-internal.h index e6e9cc5f9f5bbc..71784915de8f37 100644 --- a/deps/v8/include/v8-internal.h +++ b/deps/v8/include/v8-internal.h @@ -187,8 +187,15 @@ using ExternalPointer_t = Address; #ifdef V8_SANDBOX_IS_AVAILABLE -// Size of the sandbox, excluding the guard regions surrounding it. +#ifdef V8_OS_ANDROID +// On Android, most 64-bit devices seem to be configured with only 39 bits of +// virtual address space for userspace. As such, limit the sandbox to 128GB (a +// quarter of the total available address space). +constexpr size_t kSandboxSizeLog2 = 37; // 128 GB +#else +// Everywhere else use a 1TB sandbox. constexpr size_t kSandboxSizeLog2 = 40; // 1 TB +#endif // V8_OS_ANDROID constexpr size_t kSandboxSize = 1ULL << kSandboxSizeLog2; // Required alignment of the sandbox. For simplicity, we require the @@ -365,8 +372,8 @@ class Internals { static const uint32_t kNumIsolateDataSlots = 4; static const int kStackGuardSize = 7 * kApiSystemPointerSize; - static const int kBuiltinTier0EntryTableSize = 10 * kApiSystemPointerSize; - static const int kBuiltinTier0TableSize = 10 * kApiSystemPointerSize; + static const int kBuiltinTier0EntryTableSize = 9 * kApiSystemPointerSize; + static const int kBuiltinTier0TableSize = 9 * kApiSystemPointerSize; // IsolateData layout guarantees. static const int kIsolateCageBaseOffset = 0; @@ -406,7 +413,6 @@ class Internals { static const int kNodeFlagsOffset = 1 * kApiSystemPointerSize + 3; static const int kNodeStateMask = 0x7; static const int kNodeStateIsWeakValue = 2; - static const int kNodeStateIsPendingValue = 3; static const int kFirstNonstringType = 0x80; static const int kOddballType = 0x83; diff --git a/deps/v8/include/v8-isolate.h b/deps/v8/include/v8-isolate.h index 2849d7cae1e9e8..4c35d324319c1d 100644 --- a/deps/v8/include/v8-isolate.h +++ b/deps/v8/include/v8-isolate.h @@ -286,6 +286,7 @@ class V8_EXPORT Isolate { * Callbacks to invoke in case of fatal or OOM errors. */ FatalErrorCallback fatal_error_callback = nullptr; + LegacyOOMErrorCallback legacy_oom_error_callback = nullptr; OOMErrorCallback oom_error_callback = nullptr; /** @@ -301,16 +302,18 @@ class V8_EXPORT Isolate { */ class V8_EXPORT V8_NODISCARD Scope { public: - explicit Scope(Isolate* isolate) : isolate_(isolate) { isolate->Enter(); } + explicit Scope(Isolate* isolate) : v8_isolate_(isolate) { + v8_isolate_->Enter(); + } - ~Scope() { isolate_->Exit(); } + ~Scope() { v8_isolate_->Exit(); } // Prevent copying of Scope objects. Scope(const Scope&) = delete; Scope& operator=(const Scope&) = delete; private: - Isolate* const isolate_; + Isolate* const v8_isolate_; }; /** @@ -331,7 +334,7 @@ class V8_EXPORT Isolate { private: OnFailure on_failure_; - Isolate* isolate_; + v8::Isolate* v8_isolate_; bool was_execution_allowed_assert_; bool was_execution_allowed_throws_; @@ -353,7 +356,7 @@ class V8_EXPORT Isolate { const AllowJavascriptExecutionScope&) = delete; private: - Isolate* isolate_; + Isolate* v8_isolate_; bool was_execution_allowed_assert_; bool was_execution_allowed_throws_; bool was_execution_allowed_dump_; @@ -376,7 +379,7 @@ class V8_EXPORT Isolate { const SuppressMicrotaskExecutionScope&) = delete; private: - internal::Isolate* const isolate_; + internal::Isolate* const i_isolate_; internal::MicrotaskQueue* const microtask_queue_; internal::Address previous_stack_height_; @@ -389,7 +392,7 @@ class V8_EXPORT Isolate { */ class V8_EXPORT V8_NODISCARD SafeForTerminationScope { public: - explicit SafeForTerminationScope(v8::Isolate* isolate); + explicit SafeForTerminationScope(v8::Isolate* v8_isolate); ~SafeForTerminationScope(); // Prevent copying of Scope objects. @@ -397,7 +400,7 @@ class V8_EXPORT Isolate { SafeForTerminationScope& operator=(const SafeForTerminationScope&) = delete; private: - internal::Isolate* isolate_; + internal::Isolate* i_isolate_; bool prev_value_; }; @@ -636,9 +639,6 @@ class V8_EXPORT Isolate { * This specifies the callback called by the upcoming dynamic * import() language feature to load modules. */ - V8_DEPRECATED("Use HostImportModuleDynamicallyCallback") - void SetHostImportModuleDynamicallyCallback( - HostImportModuleDynamicallyWithImportAssertionsCallback callback); void SetHostImportModuleDynamicallyCallback( HostImportModuleDynamicallyCallback callback); @@ -843,6 +843,9 @@ class V8_EXPORT Isolate { * Returns the number of phantom handles without callbacks that were reset * by the garbage collector since the last call to this function. */ + V8_DEPRECATE_SOON( + "Information cannot be relied on anymore as internal representation may " + "change.") size_t NumberOfPhantomHandleResetsSinceLastCall(); /** @@ -1473,7 +1476,7 @@ class V8_EXPORT Isolate { void SetFatalErrorHandler(FatalErrorCallback that); /** Set the callback to invoke in case of OOM errors. */ - void SetOOMErrorHandler(OOMErrorCallback that); + void SetOOMErrorHandler(LegacyOOMErrorCallback that); /** * Add a callback to invoke in case the heap size is close to the heap limit. @@ -1602,6 +1605,9 @@ class V8_EXPORT Isolate { * Iterates through all the persistent handles in the current isolate's heap * that have class_ids. */ + V8_DEPRECATE_SOON( + "Information cannot be relied on anymore as internal representation may " + "change.") void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor); /** @@ -1609,6 +1615,9 @@ class V8_EXPORT Isolate { * that have class_ids and are weak to be marked as inactive if there is no * pending activity for the handle. */ + V8_DEPRECATE_SOON( + "Information cannot be relied on anymore as internal representation may " + "change.") void VisitWeakHandles(PersistentHandleVisitor* visitor); /** diff --git a/deps/v8/include/v8-local-handle.h b/deps/v8/include/v8-local-handle.h index 5ae974081f8e32..cbf87f949d09fa 100644 --- a/deps/v8/include/v8-local-handle.h +++ b/deps/v8/include/v8-local-handle.h @@ -86,7 +86,7 @@ class V8_EXPORT V8_NODISCARD HandleScope { static int NumberOfHandles(Isolate* isolate); V8_INLINE Isolate* GetIsolate() const { - return reinterpret_cast(isolate_); + return reinterpret_cast(i_isolate_); } HandleScope(const HandleScope&) = delete; @@ -97,7 +97,7 @@ class V8_EXPORT V8_NODISCARD HandleScope { void Initialize(Isolate* isolate); - static internal::Address* CreateHandle(internal::Isolate* isolate, + static internal::Address* CreateHandle(internal::Isolate* i_isolate, internal::Address value); private: @@ -108,7 +108,7 @@ class V8_EXPORT V8_NODISCARD HandleScope { void operator delete(void*, size_t); void operator delete[](void*, size_t); - internal::Isolate* isolate_; + internal::Isolate* i_isolate_; internal::Address* prev_next_; internal::Address* prev_limit_; @@ -354,7 +354,7 @@ class MaybeLocal { /** * Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty, - * |false| is returned and |out| is left untouched. + * |false| is returned and |out| is assigned with nullptr. */ template V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local* out) const { @@ -445,7 +445,7 @@ class V8_EXPORT V8_NODISCARD SealHandleScope { void operator delete(void*, size_t); void operator delete[](void*, size_t); - internal::Isolate* const isolate_; + internal::Isolate* const i_isolate_; internal::Address* prev_limit_; int prev_sealed_level_; }; diff --git a/deps/v8/include/v8-locker.h b/deps/v8/include/v8-locker.h index 7ca5bf6e421e41..17ea88cb814a98 100644 --- a/deps/v8/include/v8-locker.h +++ b/deps/v8/include/v8-locker.h @@ -127,10 +127,8 @@ class V8_EXPORT Locker { * The current implementation is quite confusing and leads to unexpected * results if anybody uses v8::Locker in the current process. */ - V8_DEPRECATE_SOON("This method will be removed.") + V8_DEPRECATED("This method will be removed.") static bool WasEverUsed(); - V8_DEPRECATED("Use WasEverUsed instead") - static bool IsActive(); // Disallow copying and assigning. Locker(const Locker&) = delete; diff --git a/deps/v8/include/v8-maybe.h b/deps/v8/include/v8-maybe.h index 0532a510059d02..8d3aeabe02af45 100644 --- a/deps/v8/include/v8-maybe.h +++ b/deps/v8/include/v8-maybe.h @@ -5,6 +5,9 @@ #ifndef INCLUDE_V8_MAYBE_H_ #define INCLUDE_V8_MAYBE_H_ +#include +#include + #include "v8-internal.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) @@ -57,11 +60,20 @@ class Maybe { * Converts this Maybe<> to a value of type T. If this Maybe<> is * nothing (empty), V8 will crash the process. */ - V8_INLINE T FromJust() const { + V8_INLINE T FromJust() const& { if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); return value_; } + /** + * Converts this Maybe<> to a value of type T. If this Maybe<> is + * nothing (empty), V8 will crash the process. + */ + V8_INLINE T FromJust() && { + if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); + return std::move(value_); + } + /** * Converts this Maybe<> to a value of type T, using a default value if this * Maybe<> is nothing (empty). @@ -82,6 +94,7 @@ class Maybe { private: Maybe() : has_value_(false) {} explicit Maybe(const T& t) : has_value_(true), value_(t) {} + explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {} bool has_value_; T value_; @@ -90,6 +103,8 @@ class Maybe { friend Maybe Nothing(); template friend Maybe Just(const U& u); + template >*> + friend Maybe Just(U&& u); }; template @@ -102,6 +117,14 @@ inline Maybe Just(const T& t) { return Maybe(t); } +// Don't use forwarding references here but instead use two overloads. +// Forwarding references only work when type deduction takes place, which is not +// the case for callsites such as Just(t). +template >* = nullptr> +inline Maybe Just(T&& t) { + return Maybe(std::move(t)); +} + // A template specialization of Maybe for the case of T = void. template <> class Maybe { diff --git a/deps/v8/include/v8-message.h b/deps/v8/include/v8-message.h index a13276412a8152..15325e423428e2 100644 --- a/deps/v8/include/v8-message.h +++ b/deps/v8/include/v8-message.h @@ -70,7 +70,7 @@ class V8_EXPORT ScriptOrigin { bool resource_is_opaque = false, bool is_wasm = false, bool is_module = false, Local host_defined_options = Local()) - : isolate_(isolate), + : v8_isolate_(isolate), resource_name_(resource_name), resource_line_offset_(resource_line_offset), resource_column_offset_(resource_column_offset), @@ -87,14 +87,14 @@ class V8_EXPORT ScriptOrigin { V8_INLINE int ColumnOffset() const; V8_INLINE int ScriptId() const; V8_INLINE Local SourceMapUrl() const; - V8_DEPRECATE_SOON("Use GetHostDefinedOptions") + V8_DEPRECATED("Use GetHostDefinedOptions") Local HostDefinedOptions() const; V8_INLINE Local GetHostDefinedOptions() const; V8_INLINE ScriptOriginOptions Options() const { return options_; } private: void VerifyHostDefinedOptions() const; - Isolate* isolate_; + Isolate* v8_isolate_; Local resource_name_; int resource_line_offset_; int resource_column_offset_; diff --git a/deps/v8/include/v8-microtask-queue.h b/deps/v8/include/v8-microtask-queue.h index af9caa54a8ff51..f1624b903b13c1 100644 --- a/deps/v8/include/v8-microtask-queue.h +++ b/deps/v8/include/v8-microtask-queue.h @@ -142,7 +142,7 @@ class V8_EXPORT V8_NODISCARD MicrotasksScope { MicrotasksScope& operator=(const MicrotasksScope&) = delete; private: - internal::Isolate* const isolate_; + internal::Isolate* const i_isolate_; internal::MicrotaskQueue* const microtask_queue_; bool run_; }; diff --git a/deps/v8/include/v8-object.h b/deps/v8/include/v8-object.h index bad299fc42948d..cc3ddcda2f3803 100644 --- a/deps/v8/include/v8-object.h +++ b/deps/v8/include/v8-object.h @@ -594,8 +594,6 @@ class V8_EXPORT Object : public Value { /** * Returns the context in which the object was created. */ - V8_DEPRECATED("Use MaybeLocal GetCreationContext()") - Local CreationContext(); MaybeLocal GetCreationContext(); /** @@ -604,10 +602,6 @@ class V8_EXPORT Object : public Value { Local GetCreationContextChecked(); /** Same as above, but works for Persistents */ - V8_DEPRECATED( - "Use MaybeLocal GetCreationContext(const " - "PersistentBase& object)") - static Local CreationContext(const PersistentBase& object); V8_INLINE static MaybeLocal GetCreationContext( const PersistentBase& object) { return object.val_->GetCreationContext(); diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h index 91b3fd9cc3f9a3..efe5402969bde2 100644 --- a/deps/v8/include/v8-platform.h +++ b/deps/v8/include/v8-platform.h @@ -429,6 +429,17 @@ class PageAllocator { virtual bool SetPermissions(void* address, size_t length, Permission permissions) = 0; + /** + * Recommits discarded pages in the given range with given permissions. + * Discarded pages must be recommitted with their original permissions + * before they are used again. + */ + virtual bool RecommitPages(void* address, size_t length, + Permission permissions) { + // TODO(v8:12797): make it pure once it's implemented on Chromium side. + return false; + } + /** * Frees memory in the given [address, address + size) range. address and size * should be operating system page-aligned. The next write to this @@ -698,6 +709,10 @@ class VirtualAddressSpace { /** * Sets permissions of all allocated pages in the given range. * + * This operation can fail due to OOM, in which case false is returned. If + * the operation fails for a reason other than OOM, this function will + * terminate the process as this implies a bug in the client. + * * \param address The start address of the range. Must be aligned to * page_size(). * @@ -706,7 +721,7 @@ class VirtualAddressSpace { * * \param permissions The new permissions for the range. * - * \returns true on success, false otherwise. + * \returns true on success, false on OOM. */ virtual V8_WARN_UNUSED_RESULT bool SetPagePermissions( Address address, size_t size, PagePermissions permissions) = 0; @@ -820,6 +835,24 @@ class VirtualAddressSpace { // takes a command enum as parameter. // + /** + * Recommits discarded pages in the given range with given permissions. + * Discarded pages must be recommitted with their original permissions + * before they are used again. + * + * \param address The start address of the range. Must be aligned to + * page_size(). + * + * \param size The size in bytes of the range. Must be a multiple + * of page_size(). + * + * \param permissions The permissions for the range that the pages must have. + * + * \returns true on success, false otherwise. + */ + virtual V8_WARN_UNUSED_RESULT bool RecommitPages( + Address address, size_t size, PagePermissions permissions) = 0; + /** * Frees memory in the given [address, address + size) range. address and * size should be aligned to the page_size(). The next write to this memory diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index 268104073231c6..77e42606d8e3db 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -542,7 +542,9 @@ class V8_EXPORT HeapGraphNode { kConsString = 10, // Concatenated string. A pair of pointers to strings. kSlicedString = 11, // Sliced string. A fragment of another string. kSymbol = 12, // A Symbol (ES6). - kBigInt = 13 // BigInt. + kBigInt = 13, // BigInt. + kObjectShape = 14, // Internal data used for tracking the shapes (or + // "hidden classes") of JS objects. }; /** Returns node type (see HeapGraphNode::Type). */ @@ -975,14 +977,71 @@ class V8_EXPORT HeapProfiler { virtual ~ObjectNameResolver() = default; }; + enum class HeapSnapshotMode { + /** + * Heap snapshot for regular developers. + */ + kRegular, + /** + * Heap snapshot is exposing internals that may be useful for experts. + */ + kExposeInternals, + }; + + enum class NumericsMode { + /** + * Numeric values are hidden as they are values of the corresponding + * objects. + */ + kHideNumericValues, + /** + * Numeric values are exposed in artificial fields. + */ + kExposeNumericValues + }; + + struct HeapSnapshotOptions final { + // Manually define default constructor here to be able to use it in + // `TakeSnapshot()` below. + // NOLINTNEXTLINE + HeapSnapshotOptions() {} + + /** + * The control used to report intermediate progress to. + */ + ActivityControl* control = nullptr; + /** + * The resolver used by the snapshot generator to get names for V8 objects. + */ + ObjectNameResolver* global_object_name_resolver = nullptr; + /** + * Mode for taking the snapshot, see `HeapSnapshotMode`. + */ + HeapSnapshotMode snapshot_mode = HeapSnapshotMode::kRegular; + /** + * Mode for dealing with numeric values, see `NumericsMode`. + */ + NumericsMode numerics_mode = NumericsMode::kHideNumericValues; + }; + /** - * Takes a heap snapshot and returns it. + * Takes a heap snapshot. + * + * \returns the snapshot. + */ + const HeapSnapshot* TakeHeapSnapshot( + const HeapSnapshotOptions& options = HeapSnapshotOptions()); + + /** + * Takes a heap snapshot. See `HeapSnapshotOptions` for details on the + * parameters. + * + * \returns the snapshot. */ const HeapSnapshot* TakeHeapSnapshot( - ActivityControl* control = nullptr, + ActivityControl* control, ObjectNameResolver* global_object_name_resolver = nullptr, - bool treat_global_objects_as_roots = true, - bool capture_numeric_value = false); + bool hide_internals = true, bool capture_numeric_value = false); /** * Starts tracking of heap objects population statistics. After calling diff --git a/deps/v8/include/v8-script.h b/deps/v8/include/v8-script.h index 5644a3bb70c6b1..3a5efe7458fe4d 100644 --- a/deps/v8/include/v8-script.h +++ b/deps/v8/include/v8-script.h @@ -78,7 +78,13 @@ class V8_EXPORT UnboundScript { * Returns zero based line number of the code_pos location in the script. * -1 will be returned if no information available. */ - int GetLineNumber(int code_pos); + int GetLineNumber(int code_pos = 0); + + /** + * Returns zero based column number of the code_pos location in the script. + * -1 will be returned if no information available. + */ + int GetColumnNumber(int code_pos = 0); static const int kNoScriptId = 0; }; diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 37abe105b74e3c..b7bd6d531a4d81 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 10 -#define V8_MINOR_VERSION 2 -#define V8_BUILD_NUMBER 154 -#define V8_PATCH_LEVEL 4 +#define V8_MINOR_VERSION 3 +#define V8_BUILD_NUMBER 174 +#define V8_PATCH_LEVEL 8 // 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 59b2a69b1244ca..fc074d17e0a20e 100644 --- a/deps/v8/include/v8-wasm.h +++ b/deps/v8/include/v8-wasm.h @@ -235,7 +235,7 @@ class V8_EXPORT WasmModuleObjectBuilderStreaming final { const WasmModuleObjectBuilderStreaming&) = delete; WasmModuleObjectBuilderStreaming& operator=( WasmModuleObjectBuilderStreaming&&) = default; - Isolate* isolate_ = nullptr; + Isolate* v8_isolate_ = nullptr; #if V8_CC_MSVC /** diff --git a/deps/v8/include/v8-weak-callback-info.h b/deps/v8/include/v8-weak-callback-info.h index 6d0fb3ac1d40f8..df4dcb8eb9644c 100644 --- a/deps/v8/include/v8-weak-callback-info.h +++ b/deps/v8/include/v8-weak-callback-info.h @@ -63,13 +63,6 @@ enum class WeakCallbackType { * Passes the first two internal fields of the object back to the callback. */ kInternalFields, - /** - * Passes a user-defined void* parameter back to the callback. Will do so - * before the object is actually reclaimed, allowing it to be resurrected. In - * this case it is not possible to set a second-pass callback. - */ - kFinalizer V8_ENUM_DEPRECATED("Resurrecting finalizers are deprecated " - "and will not be supported going forward.") }; template diff --git a/deps/v8/infra/mb/mb_config.pyl b/deps/v8/infra/mb/mb_config.pyl index 769582188a11d5..2082517c4c9340 100644 --- a/deps/v8/infra/mb/mb_config.pyl +++ b/deps/v8/infra/mb/mb_config.pyl @@ -67,7 +67,6 @@ 'V8 Linux64 - builder (reclient)': 'release_x64_reclient', 'V8 Linux64 - builder (reclient compare)': 'release_x64_reclient', 'V8 Linux64 - debug builder': 'debug_x64', - 'V8 Linux64 - dict tracking - debug - builder': 'debug_x64_dict_tracking_trybot', 'V8 Linux64 - external code space - debug - builder': 'debug_x64_external_code_space', 'V8 Linux64 - custom snapshot - debug builder': 'debug_x64_custom', 'V8 Linux64 - heap sandbox - debug - builder': 'debug_x64_heap_sandbox', @@ -173,6 +172,7 @@ 'V8 Android Arm64 - builder - perf': 'official_android_arm64', 'V8 Linux - builder - perf': 'official_x86', 'V8 Linux64 - builder - perf': 'official_x64', + 'V8 Mac Arm64 - builder - perf': 'official_mac_arm64', }, 'client.v8.ports': { # Arm. @@ -475,6 +475,8 @@ 'official_android_arm64': [ 'release_bot', 'arm64', 'android', 'minimal_symbols', 'android_strip_outputs', 'official', 'disable_pgo'], + 'official_mac_arm64': [ + 'release_bot', 'arm64', 'official', 'disable_pgo'], # Release configs for x64. 'release_x64': [ diff --git a/deps/v8/infra/testing/builders.pyl b/deps/v8/infra/testing/builders.pyl index 11db9b11f714a3..eba1b8ca05aaa9 100644 --- a/deps/v8/infra/testing/builders.pyl +++ b/deps/v8/infra/testing/builders.pyl @@ -156,10 +156,10 @@ {'name': 'mozilla', 'variant': 'extra'}, {'name': 'optimize_for_size'}, {'name': 'test262', 'shards': 4}, - {'name': 'test262', 'variant': 'extra', 'shards': 3}, - {'name': 'v8testing', 'shards': 2}, - {'name': 'v8testing', 'suffix': 'isolates', 'test_args': ['--isolates'], 'shards': 2}, - {'name': 'v8testing', 'variant': 'extra', 'shards': 2}, + {'name': 'test262', 'variant': 'extra', 'shards': 6}, + {'name': 'v8testing', 'shards': 4}, + {'name': 'v8testing', 'suffix': 'isolates', 'test_args': ['--isolates'], 'shards': 4}, + {'name': 'v8testing', 'variant': 'extra', 'shards': 4}, ], }, 'v8_linux_optional_rel_ng_triggered': { @@ -314,9 +314,9 @@ 'os': 'Ubuntu-18.04', }, 'tests': [ - {'name': 'test262', 'shards': 7}, - {'name': 'v8testing', 'shards': 3}, - {'name': 'v8testing', 'variant': 'extra', 'shards': 3}, + {'name': 'test262', 'shards': 12}, + {'name': 'v8testing', 'shards': 5}, + {'name': 'v8testing', 'variant': 'extra', 'shards': 5}, {'name': 'v8testing', 'variant': 'slow_path'}, ], }, @@ -408,6 +408,8 @@ {'name': 'webkit', 'variant': 'stress_sampling'}, # Stress snapshot. {'name': 'mjsunit', 'variant': 'stress_snapshot'}, + # Maglev. + {'name': 'mjsunit', 'variant': 'maglev'}, # Experimental regexp engine. {'name': 'mjsunit', 'variant': 'experimental_regexp'}, # Wasm write protect code space. @@ -1231,15 +1233,6 @@ }, ], }, - 'V8 Linux64 - dict tracking - debug': { - 'swarming_dimensions': { - 'cpu': 'x86-64-avx2', - 'os': 'Ubuntu-18.04', - }, - 'tests': [ - {'name': 'v8testing', 'shards': 3}, - ], - }, 'V8 Linux64 - disable runtime call stats': { 'swarming_dimensions' : { 'os': 'Ubuntu-18.04', @@ -1260,6 +1253,8 @@ {'name': 'webkit', 'variant': 'stress_sampling'}, # Stress snapshot. {'name': 'mjsunit', 'variant': 'stress_snapshot'}, + # Maglev. + {'name': 'mjsunit', 'variant': 'maglev'}, # Experimental regexp engine. {'name': 'mjsunit', 'variant': 'experimental_regexp'}, # Wasm write protect code space. @@ -1322,6 +1317,8 @@ {'name': 'webkit', 'variant': 'stress_sampling'}, # Stress snapshot. {'name': 'mjsunit', 'variant': 'stress_snapshot'}, + # Maglev. + {'name': 'mjsunit', 'variant': 'maglev'}, # Experimental regexp engine. {'name': 'mjsunit', 'variant': 'experimental_regexp'}, # Wasm write protect code space. diff --git a/deps/v8/src/api/api-inl.h b/deps/v8/src/api/api-inl.h index 975976ae096ae2..9a507fc1355543 100644 --- a/deps/v8/src/api/api-inl.h +++ b/deps/v8/src/api/api-inl.h @@ -233,14 +233,6 @@ class V8_NODISCARD InternalEscapableScope : public EscapableHandleScope { : EscapableHandleScope(reinterpret_cast(isolate)) {} }; -inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { - if (isolate->has_scheduled_exception()) { - return isolate->scheduled_exception() == - i::ReadOnlyRoots(isolate).termination_exception(); - } - return false; -} - template void CopySmiElementsToTypedBuffer(T* dst, uint32_t length, i::FixedArray elements) { diff --git a/deps/v8/src/api/api-macros-undef.h b/deps/v8/src/api/api-macros-undef.h index d3eea83a5f0c21..ab1116d9cee7b7 100644 --- a/deps/v8/src/api/api-macros-undef.h +++ b/deps/v8/src/api/api-macros-undef.h @@ -5,8 +5,8 @@ // PRESUBMIT_INTENTIONALLY_MISSING_INCLUDE_GUARD #undef LOG_API -#undef ENTER_V8_DO_NOT_USE -#undef ENTER_V8_HELPER_DO_NOT_USE +#undef ENTER_V8_BASIC +#undef ENTER_V8_HELPER_INTERNAL #undef PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE #undef PREPARE_FOR_EXECUTION_WITH_CONTEXT #undef PREPARE_FOR_EXECUTION diff --git a/deps/v8/src/api/api-macros.h b/deps/v8/src/api/api-macros.h index 9fbe9a973903ae..149dd0555a69be 100644 --- a/deps/v8/src/api/api-macros.h +++ b/deps/v8/src/api/api-macros.h @@ -35,98 +35,117 @@ * TODO(verwaest): Remove calls form API methods to DO_NOT_USE macros. */ -#define API_RCS_SCOPE(isolate, class_name, function_name) \ - RCS_SCOPE(isolate, \ +#define API_RCS_SCOPE(i_isolate, class_name, function_name) \ + RCS_SCOPE(i_isolate, \ i::RuntimeCallCounterId::kAPI_##class_name##_##function_name); -#define ENTER_V8_DO_NOT_USE(isolate) i::VMState __state__((isolate)) - -#define ENTER_V8_HELPER_DO_NOT_USE(isolate, context, class_name, \ - function_name, bailout_value, \ - HandleScopeClass, do_callback) \ - if (IsExecutionTerminatingCheck(isolate)) { \ - return bailout_value; \ - } \ - HandleScopeClass handle_scope(isolate); \ - CallDepthScope call_depth_scope(isolate, context); \ - API_RCS_SCOPE(isolate, class_name, function_name); \ - i::VMState __state__((isolate)); \ +#define ENTER_V8_BASIC(i_isolate) \ + /* Embedders should never enter V8 after terminating it */ \ + DCHECK(!i_isolate->is_execution_terminating()); \ + i::VMState __state__((i_isolate)) + +#define ENTER_V8_HELPER_INTERNAL(i_isolate, context, class_name, \ + function_name, bailout_value, \ + HandleScopeClass, do_callback) \ + if (i_isolate->is_execution_terminating()) { \ + return bailout_value; \ + } \ + HandleScopeClass handle_scope(i_isolate); \ + CallDepthScope call_depth_scope(i_isolate, context); \ + API_RCS_SCOPE(i_isolate, class_name, function_name); \ + i::VMState __state__((i_isolate)); \ bool has_pending_exception = false -#define PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE(isolate, T) \ - if (IsExecutionTerminatingCheck(isolate)) { \ - return MaybeLocal(); \ - } \ - InternalEscapableScope handle_scope(isolate); \ - CallDepthScope call_depth_scope(isolate, v8::Local()); \ - i::VMState __state__((isolate)); \ +#define PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE(i_isolate, T) \ + if (i_isolate->is_execution_terminating()) { \ + return MaybeLocal(); \ + } \ + InternalEscapableScope handle_scope(i_isolate); \ + CallDepthScope call_depth_scope(i_isolate, v8::Local()); \ + i::VMState __state__((i_isolate)); \ bool has_pending_exception = false #define PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ bailout_value, HandleScopeClass, \ do_callback) \ - auto isolate = context.IsEmpty() \ - ? i::Isolate::Current() \ - : reinterpret_cast(context->GetIsolate()); \ - ENTER_V8_HELPER_DO_NOT_USE(isolate, context, class_name, function_name, \ - bailout_value, HandleScopeClass, do_callback); + auto i_isolate = context.IsEmpty() \ + ? i::Isolate::Current() \ + : reinterpret_cast(context->GetIsolate()); \ + ENTER_V8_HELPER_INTERNAL(i_isolate, context, class_name, function_name, \ + bailout_value, HandleScopeClass, do_callback); #define PREPARE_FOR_EXECUTION(context, class_name, function_name, T) \ PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ MaybeLocal(), InternalEscapableScope, \ false) -#define ENTER_V8(isolate, context, class_name, function_name, bailout_value, \ - HandleScopeClass) \ - ENTER_V8_HELPER_DO_NOT_USE(isolate, context, class_name, function_name, \ - bailout_value, HandleScopeClass, true) +#define ENTER_V8(i_isolate, context, class_name, function_name, bailout_value, \ + HandleScopeClass) \ + ENTER_V8_HELPER_INTERNAL(i_isolate, context, class_name, function_name, \ + bailout_value, HandleScopeClass, true) #ifdef DEBUG -#define ENTER_V8_NO_SCRIPT(isolate, context, class_name, function_name, \ +#define ENTER_V8_NO_SCRIPT(i_isolate, context, class_name, function_name, \ bailout_value, HandleScopeClass) \ - ENTER_V8_HELPER_DO_NOT_USE(isolate, context, class_name, function_name, \ - bailout_value, HandleScopeClass, false); \ - i::DisallowJavascriptExecutionDebugOnly __no_script__((isolate)) + ENTER_V8_HELPER_INTERNAL(i_isolate, context, class_name, function_name, \ + bailout_value, HandleScopeClass, false); \ + i::DisallowJavascriptExecutionDebugOnly __no_script__((i_isolate)) + +#define DCHECK_NO_SCRIPT_NO_EXCEPTION_MAYBE_TEARDOWN(i_isolate) \ + i::DisallowJavascriptExecutionDebugOnly __no_script__((i_isolate)); \ + i::DisallowExceptions __no_exceptions__((i_isolate)) // Lightweight version for APIs that don't require an active context. -#define ASSERT_NO_SCRIPT_NO_EXCEPTION(isolate) \ - i::DisallowJavascriptExecutionDebugOnly __no_script__((isolate)); \ - i::DisallowExceptions __no_exceptions__((isolate)) - -#define ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate) \ - i::VMState __state__((isolate)); \ - ASSERT_NO_SCRIPT_NO_EXCEPTION(isolate) - -#define ENTER_V8_FOR_NEW_CONTEXT(isolate) \ - i::VMState __state__((isolate)); \ - i::DisallowExceptions __no_exceptions__((isolate)) -#else -#define ENTER_V8_NO_SCRIPT(isolate, context, class_name, function_name, \ +#define DCHECK_NO_SCRIPT_NO_EXCEPTION(i_isolate) \ + /* Embedders should never enter V8 after terminating it */ \ + DCHECK(!i_isolate->is_execution_terminating()); \ + DCHECK_NO_SCRIPT_NO_EXCEPTION_MAYBE_TEARDOWN(i_isolate) + +#define ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate) \ + i::VMState __state__((i_isolate)); \ + DCHECK_NO_SCRIPT_NO_EXCEPTION(i_isolate) + +// Used instead of ENTER_V8_NO_SCRIPT_NO_EXCEPTION where the V8 Api is entered +// during termination sequences. +#define ENTER_V8_MAYBE_TEARDOWN(i_isolate) \ + i::VMState __state__((i_isolate)); \ + DCHECK_NO_SCRIPT_NO_EXCEPTION_MAYBE_TEARDOWN(i_isolate) + +#define ENTER_V8_FOR_NEW_CONTEXT(i_isolate) \ + DCHECK(!(i_isolate)->is_execution_terminating()); \ + i::VMState __state__((i_isolate)); \ + i::DisallowExceptions __no_exceptions__((i_isolate)) +#else // DEBUG +#define ENTER_V8_NO_SCRIPT(i_isolate, context, class_name, function_name, \ bailout_value, HandleScopeClass) \ - ENTER_V8_HELPER_DO_NOT_USE(isolate, context, class_name, function_name, \ - bailout_value, HandleScopeClass, false) + ENTER_V8_HELPER_INTERNAL(i_isolate, context, class_name, function_name, \ + bailout_value, HandleScopeClass, false) + +#define DCHECK_NO_SCRIPT_NO_EXCEPTION(i_isolate) +#define DCHECK_NO_SCRIPT_NO_EXCEPTION_MAYBE_TEARDOWN(i_isolate) -#define ASSERT_NO_SCRIPT_NO_EXCEPTION(isolate) +#define ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate) \ + i::VMState __state__((i_isolate)); -#define ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate) \ - i::VMState __state__((isolate)); +#define ENTER_V8_MAYBE_TEARDOWN(i_isolate) \ + i::VMState __state__((i_isolate)); -#define ENTER_V8_FOR_NEW_CONTEXT(isolate) \ - i::VMState __state__((isolate)); +#define ENTER_V8_FOR_NEW_CONTEXT(i_isolate) \ + i::VMState __state__((i_isolate)); #endif // DEBUG -#define EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE(isolate, value) \ - do { \ - if (has_pending_exception) { \ - call_depth_scope.Escape(); \ - return value; \ - } \ +#define EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE(i_isolate, value) \ + do { \ + if (has_pending_exception) { \ + call_depth_scope.Escape(); \ + return value; \ + } \ } while (false) #define RETURN_ON_FAILED_EXECUTION(T) \ - EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE(isolate, MaybeLocal()) + EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE(i_isolate, MaybeLocal()) #define RETURN_ON_FAILED_EXECUTION_PRIMITIVE(T) \ - EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE(isolate, Nothing()) + EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE(i_isolate, Nothing()) #define RETURN_ESCAPED(value) return handle_scope.Escape(value); diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index a0ab21d71a378a..8423f288efa3f0 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -140,9 +140,13 @@ #if V8_OS_LINUX || V8_OS_DARWIN || V8_OS_FREEBSD #include + +#if V8_ENABLE_WEBASSEMBLY #include "include/v8-wasm-trap-handler-posix.h" #include "src/trap-handler/handler-inside-posix.h" -#endif +#endif // V8_ENABLE_WEBASSEMBLY + +#endif // V8_OS_LINUX || V8_OS_DARWIN || V8_OS_FREEBSD #if V8_OS_WIN #include @@ -168,21 +172,23 @@ namespace v8 { -static OOMErrorCallback g_oom_error_callback = nullptr; +// TODO(chromium:1323177): Add a separate global for OOMErrorCallback once the +// types diverge. +static LegacyOOMErrorCallback g_oom_error_callback = nullptr; -static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate, +static ScriptOrigin GetScriptOriginForScript(i::Isolate* i_isolate, i::Handle script) { - i::Handle scriptName(script->GetNameOrSourceURL(), isolate); - i::Handle source_map_url(script->source_mapping_url(), isolate); + i::Handle scriptName(script->GetNameOrSourceURL(), i_isolate); + i::Handle source_map_url(script->source_mapping_url(), i_isolate); i::Handle host_defined_options(script->host_defined_options(), - isolate); + i_isolate); ScriptOriginOptions options(script->origin_options()); bool is_wasm = false; #if V8_ENABLE_WEBASSEMBLY is_wasm = script->type() == i::Script::TYPE_WASM; #endif // V8_ENABLE_WEBASSEMBLY v8::ScriptOrigin origin( - reinterpret_cast(isolate), Utils::ToLocal(scriptName), + reinterpret_cast(i_isolate), Utils::ToLocal(scriptName), script->line_offset(), script->column_offset(), options.IsSharedCrossOrigin(), script->id(), Utils::ToLocal(source_map_url), options.IsOpaque(), is_wasm, @@ -203,23 +209,23 @@ Local ScriptOrigin::HostDefinedOptions() const { // --- E x c e p t i o n B e h a v i o r --- -void i::FatalProcessOutOfMemory(i::Isolate* isolate, const char* location) { - i::V8::FatalProcessOutOfMemory(isolate, location, false); +void i::FatalProcessOutOfMemory(i::Isolate* i_isolate, const char* location) { + i::V8::FatalProcessOutOfMemory(i_isolate, location, false); } // When V8 cannot allocate memory FatalProcessOutOfMemory is called. The default // OOM error handler is called and execution is stopped. -void i::V8::FatalProcessOutOfMemory(i::Isolate* isolate, const char* location, +void i::V8::FatalProcessOutOfMemory(i::Isolate* i_isolate, const char* location, bool is_heap_oom) { char last_few_messages[Heap::kTraceRingBufferSize + 1]; char js_stacktrace[Heap::kStacktraceBufferSize + 1]; i::HeapStats heap_stats; - if (isolate == nullptr) { - isolate = Isolate::TryGetCurrent(); + if (i_isolate == nullptr) { + i_isolate = Isolate::TryGetCurrent(); } - if (isolate == nullptr) { + if (i_isolate == nullptr) { // If the Isolate is not available for the current thread we cannot retrieve // memory information from the Isolate. Write easy-to-recognize values on // the stack. @@ -290,10 +296,10 @@ void i::V8::FatalProcessOutOfMemory(i::Isolate* isolate, const char* location, heap_stats.js_stacktrace = js_stacktrace; intptr_t end_marker; heap_stats.end_marker = &end_marker; - if (isolate->heap()->HasBeenSetUp()) { + if (i_isolate->heap()->HasBeenSetUp()) { // BUG(1718): Don't use the take_snapshot since we don't support // HeapObjectIterator here without doing a special GC. - isolate->heap()->RecordStats(&heap_stats, false); + i_isolate->heap()->RecordStats(&heap_stats, false); if (!FLAG_correctness_fuzzer_suppressions) { char* first_newline = strchr(last_few_messages, '\n'); if (first_newline == nullptr || first_newline[1] == '\0') @@ -302,17 +308,17 @@ void i::V8::FatalProcessOutOfMemory(i::Isolate* isolate, const char* location, base::OS::PrintError("\n<--- JS stacktrace --->\n%s\n", js_stacktrace); } } - Utils::ReportOOMFailure(isolate, location, is_heap_oom); + Utils::ReportOOMFailure(i_isolate, location, is_heap_oom); if (g_oom_error_callback) g_oom_error_callback(location, is_heap_oom); // If the fatal error handler returns, we stop execution. FATAL("API fatal error handler returned after process out of memory"); } void Utils::ReportApiFailure(const char* location, const char* message) { - i::Isolate* isolate = i::Isolate::TryGetCurrent(); + i::Isolate* i_isolate = i::Isolate::TryGetCurrent(); FatalErrorCallback callback = nullptr; - if (isolate != nullptr) { - callback = isolate->exception_behavior(); + if (i_isolate != nullptr) { + callback = i_isolate->exception_behavior(); } if (callback == nullptr) { base::OS::PrintError("\n#\n# Fatal error in %s\n# %s\n#\n\n", location, @@ -321,16 +327,16 @@ void Utils::ReportApiFailure(const char* location, const char* message) { } else { callback(location, message); } - isolate->SignalFatalError(); + i_isolate->SignalFatalError(); } -void Utils::ReportOOMFailure(i::Isolate* isolate, const char* location, +void Utils::ReportOOMFailure(i::Isolate* i_isolate, const char* location, bool is_heap_oom) { - OOMErrorCallback oom_callback = isolate->oom_behavior(); + LegacyOOMErrorCallback oom_callback = i_isolate->oom_behavior(); if (oom_callback == nullptr) { // TODO(wfh): Remove this fallback once Blink is setting OOM handler. See // crbug.com/614440. - FatalErrorCallback fatal_callback = isolate->exception_behavior(); + FatalErrorCallback fatal_callback = i_isolate->exception_behavior(); if (fatal_callback == nullptr) { base::OS::PrintError("\n#\n# Fatal %s OOM in %s\n#\n\n", is_heap_oom ? "javascript" : "process", location); @@ -348,7 +354,7 @@ void Utils::ReportOOMFailure(i::Isolate* isolate, const char* location, } else { oom_callback(location, is_heap_oom); } - isolate->SignalFatalError(); + i_isolate->SignalFatalError(); } void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { @@ -432,10 +438,10 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { #endif // V8_SANDBOXED_POINTERS struct SnapshotCreatorData { - explicit SnapshotCreatorData(Isolate* isolate) - : isolate_(isolate), + explicit SnapshotCreatorData(Isolate* v8_isolate) + : isolate_(v8_isolate), default_context_(), - contexts_(isolate), + contexts_(v8_isolate), created_(false) {} static SnapshotCreatorData* cast(void* data) { @@ -453,27 +459,27 @@ struct SnapshotCreatorData { } // namespace -SnapshotCreator::SnapshotCreator(Isolate* isolate, +SnapshotCreator::SnapshotCreator(Isolate* v8_isolate, const intptr_t* external_references, StartupData* existing_snapshot) { - SnapshotCreatorData* data = new SnapshotCreatorData(isolate); - i::Isolate* internal_isolate = reinterpret_cast(isolate); - internal_isolate->set_array_buffer_allocator(&data->allocator_); - internal_isolate->set_api_external_references(external_references); - internal_isolate->enable_serializer(); - isolate->Enter(); + SnapshotCreatorData* data = new SnapshotCreatorData(v8_isolate); + i::Isolate* i_isolate = reinterpret_cast(v8_isolate); + i_isolate->set_array_buffer_allocator(&data->allocator_); + i_isolate->set_api_external_references(external_references); + i_isolate->enable_serializer(); + v8_isolate->Enter(); const StartupData* blob = existing_snapshot ? existing_snapshot : i::Snapshot::DefaultSnapshotBlob(); if (blob && blob->raw_size > 0) { - internal_isolate->set_snapshot_blob(blob); - i::Snapshot::Initialize(internal_isolate); + i_isolate->set_snapshot_blob(blob); + i::Snapshot::Initialize(i_isolate); } else { - internal_isolate->InitWithoutSnapshot(); + i_isolate->InitWithoutSnapshot(); } data_ = data; // Disable batch compilation during snapshot creation. - internal_isolate->baseline_batch_compiler()->set_enabled(false); + i_isolate->baseline_batch_compiler()->set_enabled(false); } SnapshotCreator::SnapshotCreator(const intptr_t* external_references, @@ -484,9 +490,9 @@ SnapshotCreator::SnapshotCreator(const intptr_t* external_references, SnapshotCreator::~SnapshotCreator() { SnapshotCreatorData* data = SnapshotCreatorData::cast(data_); DCHECK(data->created_); - Isolate* isolate = data->isolate_; - isolate->Exit(); - isolate->Dispose(); + Isolate* v8_isolate = data->isolate_; + v8_isolate->Exit(); + v8_isolate->Dispose(); delete data; } @@ -500,9 +506,9 @@ void SnapshotCreator::SetDefaultContext( SnapshotCreatorData* data = SnapshotCreatorData::cast(data_); DCHECK(!data->created_); DCHECK(data->default_context_.IsEmpty()); - Isolate* isolate = data->isolate_; - CHECK_EQ(isolate, context->GetIsolate()); - data->default_context_.Reset(isolate, context); + Isolate* v8_isolate = data->isolate_; + CHECK_EQ(v8_isolate, context->GetIsolate()); + data->default_context_.Reset(v8_isolate, context); data->default_embedder_fields_serializer_ = callback; } @@ -511,8 +517,8 @@ size_t SnapshotCreator::AddContext(Local context, DCHECK(!context.IsEmpty()); SnapshotCreatorData* data = SnapshotCreatorData::cast(data_); DCHECK(!data->created_); - Isolate* isolate = data->isolate_; - CHECK_EQ(isolate, context->GetIsolate()); + Isolate* v8_isolate = data->isolate_; + CHECK_EQ(v8_isolate, context->GetIsolate()); size_t index = data->contexts_.Size(); data->contexts_.Append(context); data->embedder_fields_serializers_.push_back(callback); @@ -523,19 +529,19 @@ size_t SnapshotCreator::AddData(i::Address object) { DCHECK_NE(object, i::kNullAddress); SnapshotCreatorData* data = SnapshotCreatorData::cast(data_); DCHECK(!data->created_); - i::Isolate* isolate = reinterpret_cast(data->isolate_); - i::HandleScope scope(isolate); - i::Handle obj(i::Object(object), isolate); + i::Isolate* i_isolate = reinterpret_cast(data->isolate_); + i::HandleScope scope(i_isolate); + i::Handle obj(i::Object(object), i_isolate); i::Handle list; - if (!isolate->heap()->serialized_objects().IsArrayList()) { - list = i::ArrayList::New(isolate, 1); + if (!i_isolate->heap()->serialized_objects().IsArrayList()) { + list = i::ArrayList::New(i_isolate, 1); } else { list = i::Handle( - i::ArrayList::cast(isolate->heap()->serialized_objects()), isolate); + i::ArrayList::cast(i_isolate->heap()->serialized_objects()), i_isolate); } size_t index = static_cast(list->Length()); - list = i::ArrayList::Add(isolate, list, obj); - isolate->heap()->SetSerializedObjects(*list); + list = i::ArrayList::Add(i_isolate, list, obj); + i_isolate->heap()->SetSerializedObjects(*list); return index; } @@ -543,18 +549,18 @@ size_t SnapshotCreator::AddData(Local context, i::Address object) { DCHECK_NE(object, i::kNullAddress); DCHECK(!SnapshotCreatorData::cast(data_)->created_); i::Handle ctx = Utils::OpenHandle(*context); - i::Isolate* isolate = ctx->GetIsolate(); - i::HandleScope scope(isolate); - i::Handle obj(i::Object(object), isolate); + i::Isolate* i_isolate = ctx->GetIsolate(); + i::HandleScope scope(i_isolate); + i::Handle obj(i::Object(object), i_isolate); i::Handle list; if (!ctx->serialized_objects().IsArrayList()) { - list = i::ArrayList::New(isolate, 1); + list = i::ArrayList::New(i_isolate, 1); } else { list = i::Handle( - i::ArrayList::cast(ctx->serialized_objects()), isolate); + i::ArrayList::cast(ctx->serialized_objects()), i_isolate); } size_t index = static_cast(list->Length()); - list = i::ArrayList::Add(isolate, list, obj); + list = i::ArrayList::Add(i_isolate, list, obj); ctx->set_serialized_objects(*list); return index; } @@ -562,26 +568,27 @@ size_t SnapshotCreator::AddData(Local context, i::Address object) { namespace { void ConvertSerializedObjectsToFixedArray(Local context) { i::Handle ctx = Utils::OpenHandle(*context); - i::Isolate* isolate = ctx->GetIsolate(); + i::Isolate* i_isolate = ctx->GetIsolate(); if (!ctx->serialized_objects().IsArrayList()) { - ctx->set_serialized_objects(i::ReadOnlyRoots(isolate).empty_fixed_array()); + ctx->set_serialized_objects( + i::ReadOnlyRoots(i_isolate).empty_fixed_array()); } else { i::Handle list(i::ArrayList::cast(ctx->serialized_objects()), - isolate); - i::Handle elements = i::ArrayList::Elements(isolate, list); + i_isolate); + i::Handle elements = i::ArrayList::Elements(i_isolate, list); ctx->set_serialized_objects(*elements); } } -void ConvertSerializedObjectsToFixedArray(i::Isolate* isolate) { - if (!isolate->heap()->serialized_objects().IsArrayList()) { - isolate->heap()->SetSerializedObjects( - i::ReadOnlyRoots(isolate).empty_fixed_array()); +void ConvertSerializedObjectsToFixedArray(i::Isolate* i_isolate) { + if (!i_isolate->heap()->serialized_objects().IsArrayList()) { + i_isolate->heap()->SetSerializedObjects( + i::ReadOnlyRoots(i_isolate).empty_fixed_array()); } else { i::Handle list( - i::ArrayList::cast(isolate->heap()->serialized_objects()), isolate); - i::Handle elements = i::ArrayList::Elements(isolate, list); - isolate->heap()->SetSerializedObjects(*elements); + i::ArrayList::cast(i_isolate->heap()->serialized_objects()), i_isolate); + i::Handle elements = i::ArrayList::Elements(i_isolate, list); + i_isolate->heap()->SetSerializedObjects(*elements); } } } // anonymous namespace @@ -589,7 +596,7 @@ void ConvertSerializedObjectsToFixedArray(i::Isolate* isolate) { StartupData SnapshotCreator::CreateBlob( SnapshotCreator::FunctionCodeHandling function_code_handling) { SnapshotCreatorData* data = SnapshotCreatorData::cast(data_); - i::Isolate* isolate = reinterpret_cast(data->isolate_); + i::Isolate* i_isolate = reinterpret_cast(data->isolate_); DCHECK(!data->created_); DCHECK(!data->default_context_.IsEmpty()); @@ -599,9 +606,9 @@ StartupData SnapshotCreator::CreateBlob( // Create and store lists of embedder-provided data needed during // serialization. { - i::HandleScope scope(isolate); + i::HandleScope scope(i_isolate); // Convert list of context-independent data to FixedArray. - ConvertSerializedObjectsToFixedArray(isolate); + ConvertSerializedObjectsToFixedArray(i_isolate); // Convert lists of context-dependent data to FixedArray. ConvertSerializedObjectsToFixedArray( @@ -613,33 +620,33 @@ StartupData SnapshotCreator::CreateBlob( // We need to store the global proxy size upfront in case we need the // bootstrapper to create a global proxy before we deserialize the context. i::Handle global_proxy_sizes = - isolate->factory()->NewFixedArray(num_additional_contexts, - i::AllocationType::kOld); + i_isolate->factory()->NewFixedArray(num_additional_contexts, + i::AllocationType::kOld); for (int i = 0; i < num_additional_contexts; i++) { i::Handle context = v8::Utils::OpenHandle(*data->contexts_.Get(i)); global_proxy_sizes->set(i, i::Smi::FromInt(context->global_proxy().Size())); } - isolate->heap()->SetSerializedGlobalProxySizes(*global_proxy_sizes); + i_isolate->heap()->SetSerializedGlobalProxySizes(*global_proxy_sizes); } // We might rehash strings and re-sort descriptors. Clear the lookup cache. - isolate->descriptor_lookup_cache()->Clear(); + i_isolate->descriptor_lookup_cache()->Clear(); // If we don't do this then we end up with a stray root pointing at the // context even after we have disposed of the context. - isolate->heap()->CollectAllAvailableGarbage( + i_isolate->heap()->CollectAllAvailableGarbage( i::GarbageCollectionReason::kSnapshotCreator); { - i::HandleScope scope(isolate); - isolate->heap()->CompactWeakArrayLists(); + i::HandleScope scope(i_isolate); + i_isolate->heap()->CompactWeakArrayLists(); } i::Snapshot::ClearReconstructableDataForSerialization( - isolate, function_code_handling == FunctionCodeHandling::kClear); + i_isolate, function_code_handling == FunctionCodeHandling::kClear); - i::GlobalSafepointScope global_safepoint(isolate); + i::GlobalSafepointScope global_safepoint(i_isolate); i::DisallowGarbageCollection no_gc_from_here_on; // Create a vector with all contexts and clear associated Persistent fields. @@ -649,7 +656,7 @@ StartupData SnapshotCreator::CreateBlob( std::vector contexts; contexts.reserve(num_contexts); { - i::HandleScope scope(isolate); + i::HandleScope scope(i_isolate); contexts.push_back( *v8::Utils::OpenHandle(*data->default_context_.Get(data->isolate_))); data->default_context_.Reset(); @@ -662,7 +669,7 @@ StartupData SnapshotCreator::CreateBlob( } // Check that values referenced by global/eternal handles are accounted for. - i::SerializedHandleChecker handle_checker(isolate, &contexts); + i::SerializedHandleChecker handle_checker(i_isolate, &contexts); CHECK(handle_checker.CheckGlobalAndEternalHandles()); // Create a vector with all embedder fields serializers. @@ -676,7 +683,7 @@ StartupData SnapshotCreator::CreateBlob( } data->created_ = true; - return i::Snapshot::Create(isolate, &contexts, embedder_fields_serializers, + return i::Snapshot::Create(i_isolate, &contexts, embedder_fields_serializers, global_safepoint, no_gc_from_here_on); } @@ -807,19 +814,19 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, namespace internal { -i::Address* GlobalizeTracedReference(i::Isolate* isolate, i::Address* obj, +i::Address* GlobalizeTracedReference(i::Isolate* i_isolate, i::Address* obj, internal::Address* slot, GlobalHandleStoreMode store_mode) { - API_RCS_SCOPE(isolate, TracedGlobal, New); + API_RCS_SCOPE(i_isolate, TracedGlobal, New); #ifdef DEBUG Utils::ApiCheck((slot != nullptr), "v8::GlobalizeTracedReference", "the address slot must be not null"); #endif i::Handle result = - isolate->global_handles()->CreateTraced(*obj, slot, store_mode); + i_isolate->global_handles()->CreateTraced(*obj, slot, store_mode); #ifdef VERIFY_HEAP if (i::FLAG_verify_heap) { - i::Object(*obj).ObjectVerify(isolate); + i::Object(*obj).ObjectVerify(i_isolate); } #endif // VERIFY_HEAP return result.location(); @@ -842,12 +849,12 @@ void DisposeTracedReference(internal::Address* location) { namespace api_internal { -i::Address* GlobalizeReference(i::Isolate* isolate, i::Address* obj) { - API_RCS_SCOPE(isolate, Persistent, New); - i::Handle result = isolate->global_handles()->Create(*obj); +i::Address* GlobalizeReference(i::Isolate* i_isolate, i::Address* obj) { + API_RCS_SCOPE(i_isolate, Persistent, New); + i::Handle result = i_isolate->global_handles()->Create(*obj); #ifdef VERIFY_HEAP if (i::FLAG_verify_heap) { - i::Object(*obj).ObjectVerify(isolate); + i::Object(*obj).ObjectVerify(i_isolate); } #endif // VERIFY_HEAP return result.location(); @@ -885,12 +892,12 @@ void DisposeGlobal(i::Address* location) { } Value* Eternalize(Isolate* v8_isolate, Value* value) { - i::Isolate* isolate = reinterpret_cast(v8_isolate); + i::Isolate* i_isolate = reinterpret_cast(v8_isolate); i::Object object = *Utils::OpenHandle(value); int index = -1; - isolate->eternal_handles()->Create(isolate, object, &index); + i_isolate->eternal_handles()->Create(i_isolate, object, &index); return reinterpret_cast( - isolate->eternal_handles()->Get(index).location()); + i_isolate->eternal_handles()->Get(index).location()); } void FromJustIsNothing() { @@ -911,30 +918,29 @@ void InternalFieldOutOfBounds(int index) { // --- H a n d l e s --- -HandleScope::HandleScope(Isolate* isolate) { Initialize(isolate); } +HandleScope::HandleScope(Isolate* v8_isolate) { Initialize(v8_isolate); } -void HandleScope::Initialize(Isolate* isolate) { - i::Isolate* internal_isolate = reinterpret_cast(isolate); +void HandleScope::Initialize(Isolate* v8_isolate) { + i::Isolate* i_isolate = reinterpret_cast(v8_isolate); // We do not want to check the correct usage of the Locker class all over the // place, so we do it only here: Without a HandleScope, an embedder can do // almost nothing, so it is enough to check in this central place. // We make an exception if the serializer is enabled, which means that the // Isolate is exclusively used to create a snapshot. - Utils::ApiCheck( - !internal_isolate->was_locker_ever_used() || - internal_isolate->thread_manager()->IsLockedByCurrentThread() || - internal_isolate->serializer_enabled(), - "HandleScope::HandleScope", - "Entering the V8 API without proper locking in place"); - i::HandleScopeData* current = internal_isolate->handle_scope_data(); - isolate_ = internal_isolate; + Utils::ApiCheck(!i_isolate->was_locker_ever_used() || + i_isolate->thread_manager()->IsLockedByCurrentThread() || + i_isolate->serializer_enabled(), + "HandleScope::HandleScope", + "Entering the V8 API without proper locking in place"); + i::HandleScopeData* current = i_isolate->handle_scope_data(); + i_isolate_ = i_isolate; prev_next_ = current->next; prev_limit_ = current->limit; current->level++; } HandleScope::~HandleScope() { - i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_); + i::HandleScope::CloseScope(i_isolate_, prev_next_, prev_limit_); } void* HandleScope::operator new(size_t) { base::OS::Abort(); } @@ -942,19 +948,19 @@ void* HandleScope::operator new[](size_t) { base::OS::Abort(); } void HandleScope::operator delete(void*, size_t) { base::OS::Abort(); } void HandleScope::operator delete[](void*, size_t) { base::OS::Abort(); } -int HandleScope::NumberOfHandles(Isolate* isolate) { +int HandleScope::NumberOfHandles(Isolate* v8_isolate) { return i::HandleScope::NumberOfHandles( - reinterpret_cast(isolate)); + reinterpret_cast(v8_isolate)); } -i::Address* HandleScope::CreateHandle(i::Isolate* isolate, i::Address value) { - return i::HandleScope::CreateHandle(isolate, value); +i::Address* HandleScope::CreateHandle(i::Isolate* i_isolate, i::Address value) { + return i::HandleScope::CreateHandle(i_isolate, value); } EscapableHandleScope::EscapableHandleScope(Isolate* v8_isolate) { - i::Isolate* isolate = reinterpret_cast(v8_isolate); - escape_slot_ = - CreateHandle(isolate, i::ReadOnlyRoots(isolate).the_hole_value().ptr()); + i::Isolate* i_isolate = reinterpret_cast(v8_isolate); + escape_slot_ = CreateHandle( + i_isolate, i::ReadOnlyRoots(i_isolate).the_hole_value().ptr()); Initialize(v8_isolate); } @@ -977,9 +983,9 @@ void EscapableHandleScope::operator delete[](void*, size_t) { base::OS::Abort(); } -SealHandleScope::SealHandleScope(Isolate* isolate) - : isolate_(reinterpret_cast(isolate)) { - i::HandleScopeData* current = isolate_->handle_scope_data(); +SealHandleScope::SealHandleScope(Isolate* v8_isolate) + : i_isolate_(reinterpret_cast(v8_isolate)) { + i::HandleScopeData* current = i_isolate_->handle_scope_data(); prev_limit_ = current->limit; current->limit = current->next; prev_sealed_level_ = current->sealed_level; @@ -987,7 +993,7 @@ SealHandleScope::SealHandleScope(Isolate* isolate) } SealHandleScope::~SealHandleScope() { - i::HandleScopeData* current = isolate_->handle_scope_data(); + i::HandleScopeData* current = i_isolate_->handle_scope_data(); DCHECK_EQ(current->next, current->limit); current->limit = prev_limit_; DCHECK_EQ(current->level, current->sealed_level); @@ -1031,26 +1037,30 @@ bool Data::IsFunctionTemplate() const { bool Data::IsContext() const { return Utils::OpenHandle(this)->IsContext(); } void Context::Enter() { - i::Handle env = Utils::OpenHandle(this); - i::Isolate* isolate = env->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); - impl->EnterContext(*env); - impl->SaveContext(isolate->context()); - isolate->set_context(*env); + i::DisallowGarbageCollection no_gc; + i::Context env = *Utils::OpenHandle(this); + i::Isolate* i_isolate = env.GetIsolate(); + // TODO(cbruni): Use ENTER_V8_NO_SCRIPT_NO_EXCEPTION which also checks + // Isolate::is_execution_terminating + // ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + ENTER_V8_MAYBE_TEARDOWN(i_isolate); + i::HandleScopeImplementer* impl = i_isolate->handle_scope_implementer(); + impl->EnterContext(env); + impl->SaveContext(i_isolate->context()); + i_isolate->set_context(env); } void Context::Exit() { i::Handle env = Utils::OpenHandle(this); - i::Isolate* isolate = env->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); + i::Isolate* i_isolate = env->GetIsolate(); + ENTER_V8_MAYBE_TEARDOWN(i_isolate); + i::HandleScopeImplementer* impl = i_isolate->handle_scope_implementer(); if (!Utils::ApiCheck(impl->LastEnteredContextWas(*env), "v8::Context::Exit()", "Cannot exit non-entered context")) { return; } impl->LeaveContext(); - isolate->set_context(impl->RestoreContext()); + i_isolate->set_context(impl->RestoreContext()); } Context::BackupIncumbentScope::BackupIncumbentScope( @@ -1059,22 +1069,22 @@ Context::BackupIncumbentScope::BackupIncumbentScope( DCHECK(!backup_incumbent_context_.IsEmpty()); i::Handle env = Utils::OpenHandle(*backup_incumbent_context_); - i::Isolate* isolate = env->GetIsolate(); + i::Isolate* i_isolate = env->GetIsolate(); js_stack_comparable_address_ = - i::SimulatorStack::RegisterJSStackComparableAddress(isolate); + i::SimulatorStack::RegisterJSStackComparableAddress(i_isolate); - prev_ = isolate->top_backup_incumbent_scope(); - isolate->set_top_backup_incumbent_scope(this); + prev_ = i_isolate->top_backup_incumbent_scope(); + i_isolate->set_top_backup_incumbent_scope(this); } Context::BackupIncumbentScope::~BackupIncumbentScope() { i::Handle env = Utils::OpenHandle(*backup_incumbent_context_); - i::Isolate* isolate = env->GetIsolate(); + i::Isolate* i_isolate = env->GetIsolate(); - i::SimulatorStack::UnregisterJSStackComparableAddress(isolate); + i::SimulatorStack::UnregisterJSStackComparableAddress(i_isolate); - isolate->set_top_backup_incumbent_scope(prev_); + i_isolate->set_top_backup_incumbent_scope(prev_); } STATIC_ASSERT(i::Internals::kEmbedderDataSlotSize == i::kEmbedderDataSlotSize); @@ -1083,28 +1093,28 @@ static i::Handle EmbedderDataFor(Context* context, int index, bool can_grow, const char* location) { i::Handle env = Utils::OpenHandle(context); - i::Isolate* isolate = env->GetIsolate(); - ASSERT_NO_SCRIPT_NO_EXCEPTION(isolate); + i::Isolate* i_isolate = env->GetIsolate(); + DCHECK_NO_SCRIPT_NO_EXCEPTION_MAYBE_TEARDOWN(i_isolate); bool ok = Utils::ApiCheck(env->IsNativeContext(), location, "Not a native context") && Utils::ApiCheck(index >= 0, location, "Negative index"); if (!ok) return i::Handle(); // TODO(ishell): remove cast once embedder_data slot has a proper type. i::Handle data( - i::EmbedderDataArray::cast(env->embedder_data()), isolate); + i::EmbedderDataArray::cast(env->embedder_data()), i_isolate); if (index < data->length()) return data; if (!Utils::ApiCheck(can_grow && index < i::EmbedderDataArray::kMaxLength, location, "Index too large")) { return i::Handle(); } - data = i::EmbedderDataArray::EnsureCapacity(isolate, data, index); + data = i::EmbedderDataArray::EnsureCapacity(i_isolate, data, index); env->set_embedder_data(*data); return data; } uint32_t Context::GetNumberOfEmbedderDataFields() { i::Handle context = Utils::OpenHandle(this); - ASSERT_NO_SCRIPT_NO_EXCEPTION(context->GetIsolate()); + DCHECK_NO_SCRIPT_NO_EXCEPTION(context->GetIsolate()); Utils::ApiCheck(context->IsNativeContext(), "Context::GetNumberOfEmbedderDataFields", "Not a native context"); @@ -1118,9 +1128,9 @@ v8::Local Context::SlowGetEmbedderData(int index) { i::Handle data = EmbedderDataFor(this, index, false, location); if (data.is_null()) return Local(); - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); i::Handle result(i::EmbedderDataSlot(*data, index).load_tagged(), - isolate); + i_isolate); return Utils::ToLocal(result); } @@ -1137,25 +1147,25 @@ void Context::SetEmbedderData(int index, v8::Local value) { void* Context::SlowGetAlignedPointerFromEmbedderData(int index) { const char* location = "v8::Context::GetAlignedPointerFromEmbedderData()"; - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); - i::HandleScope handle_scope(isolate); + i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); + i::HandleScope handle_scope(i_isolate); i::Handle data = EmbedderDataFor(this, index, false, location); if (data.is_null()) return nullptr; void* result; Utils::ApiCheck( - i::EmbedderDataSlot(*data, index).ToAlignedPointer(isolate, &result), + i::EmbedderDataSlot(*data, index).ToAlignedPointer(i_isolate, &result), location, "Pointer is not aligned"); return result; } void Context::SetAlignedPointerInEmbedderData(int index, void* value) { const char* location = "v8::Context::SetAlignedPointerInEmbedderData()"; - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); i::Handle data = EmbedderDataFor(this, index, true, location); bool ok = - i::EmbedderDataSlot(*data, index).store_aligned_pointer(isolate, value); + i::EmbedderDataSlot(*data, index).store_aligned_pointer(i_isolate, value); Utils::ApiCheck(ok, location, "Pointer is not aligned"); DCHECK_EQ(value, GetAlignedPointerFromEmbedderData(index)); } @@ -1174,9 +1184,9 @@ static void InitializeTemplate(i::TemplateInfo that, int type, void Template::Set(v8::Local name, v8::Local value, v8::PropertyAttribute attribute) { auto templ = Utils::OpenHandle(this); - i::Isolate* isolate = templ->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScope scope(isolate); + i::Isolate* i_isolate = templ->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::HandleScope scope(i_isolate); auto value_obj = Utils::OpenHandle(*value); Utils::ApiCheck(!value_obj->IsJSReceiver() || value_obj->IsTemplateInfo(), @@ -1190,7 +1200,7 @@ void Template::Set(v8::Local name, v8::Local value, templ->set_serial_number(i::TemplateInfo::kDoNotCache); } - i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), + i::ApiNatives::AddDataProperty(i_isolate, templ, Utils::OpenHandle(*name), value_obj, static_cast(attribute)); } @@ -1209,13 +1219,13 @@ void Template::SetAccessorProperty(v8::Local name, // TODO(verwaest): Remove |access_control|. DCHECK_EQ(v8::DEFAULT, access_control); auto templ = Utils::OpenHandle(this); - auto isolate = templ->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + auto i_isolate = templ->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); DCHECK(!name.IsEmpty()); DCHECK(!getter.IsEmpty() || !setter.IsEmpty()); - i::HandleScope scope(isolate); + i::HandleScope scope(i_isolate); i::ApiNatives::AddAccessorProperty( - isolate, templ, Utils::OpenHandle(*name), + i_isolate, templ, Utils::OpenHandle(*name), Utils::OpenHandle(*getter, true), Utils::OpenHandle(*setter, true), static_cast(attribute)); } @@ -1227,9 +1237,29 @@ static void InitializeFunctionTemplate(i::FunctionTemplateInfo info, info.set_flag(0); } -static Local ObjectTemplateNew( - i::Isolate* isolate, v8::Local constructor, - bool do_not_cache); +namespace { +Local ObjectTemplateNew(i::Isolate* i_isolate, + v8::Local constructor, + bool do_not_cache) { + API_RCS_SCOPE(i_isolate, ObjectTemplate, New); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::Handle struct_obj = i_isolate->factory()->NewStruct( + i::OBJECT_TEMPLATE_INFO_TYPE, i::AllocationType::kOld); + i::Handle obj = + i::Handle::cast(struct_obj); + { + // Disallow GC until all fields of obj have acceptable types. + i::DisallowGarbageCollection no_gc; + i::ObjectTemplateInfo raw = *obj; + InitializeTemplate(raw, Consts::OBJECT_TEMPLATE, do_not_cache); + raw.set_data(0); + if (!constructor.IsEmpty()) { + raw.set_constructor(*Utils::OpenHandle(*constructor)); + } + } + return Utils::ToLocal(obj); +} +} // namespace Local FunctionTemplate::PrototypeTemplate() { auto self = Utils::OpenHandle(this); @@ -1262,6 +1292,7 @@ void FunctionTemplate::SetPrototypeProviderTemplate( result); } +namespace { static void EnsureNotPublished(i::Handle info, const char* func) { DCHECK_IMPLIES(info->instantiated(), info->published()); @@ -1269,20 +1300,8 @@ static void EnsureNotPublished(i::Handle info, "FunctionTemplate already instantiated"); } -void FunctionTemplate::Inherit(v8::Local value) { - auto info = Utils::OpenHandle(this); - EnsureNotPublished(info, "v8::FunctionTemplate::Inherit"); - i::Isolate* i_isolate = info->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); - Utils::ApiCheck(info->GetPrototypeProviderTemplate().IsUndefined(i_isolate), - "v8::FunctionTemplate::Inherit", - "Protoype provider must be empty"); - i::FunctionTemplateInfo::SetParentTemplate(i_isolate, info, - Utils::OpenHandle(*value)); -} - -static Local FunctionTemplateNew( - i::Isolate* isolate, FunctionCallback callback, v8::Local data, +Local FunctionTemplateNew( + i::Isolate* i_isolate, FunctionCallback callback, v8::Local data, v8::Local signature, int length, ConstructorBehavior behavior, bool do_not_cache, v8::Local cached_property_name = v8::Local(), @@ -1291,7 +1310,7 @@ static Local FunctionTemplateNew( uint8_t instance_type = 0, uint8_t allowed_receiver_instance_type_range_start = 0, uint8_t allowed_receiver_instance_type_range_end = 0) { - i::Handle struct_obj = isolate->factory()->NewStruct( + i::Handle struct_obj = i_isolate->factory()->NewStruct( i::FUNCTION_TEMPLATE_INFO_TYPE, i::AllocationType::kOld); i::Handle obj = i::Handle::cast(struct_obj); @@ -1309,7 +1328,7 @@ static Local FunctionTemplateNew( } raw.set_cached_property_name( cached_property_name.IsEmpty() - ? i::ReadOnlyRoots(isolate).the_hole_value() + ? i::ReadOnlyRoots(i_isolate).the_hole_value() : *Utils::OpenHandle(*cached_property_name)); if (behavior == ConstructorBehavior::kThrow) raw.set_remove_prototype(true); raw.SetInstanceType(instance_type); @@ -1324,14 +1343,27 @@ static Local FunctionTemplateNew( } return Utils::ToLocal(obj); } +} // namespace + +void FunctionTemplate::Inherit(v8::Local value) { + auto info = Utils::OpenHandle(this); + EnsureNotPublished(info, "v8::FunctionTemplate::Inherit"); + i::Isolate* i_isolate = info->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + Utils::ApiCheck(info->GetPrototypeProviderTemplate().IsUndefined(i_isolate), + "v8::FunctionTemplate::Inherit", + "Protoype provider must be empty"); + i::FunctionTemplateInfo::SetParentTemplate(i_isolate, info, + Utils::OpenHandle(*value)); +} Local FunctionTemplate::New( - Isolate* isolate, FunctionCallback callback, v8::Local data, + Isolate* v8_isolate, FunctionCallback callback, v8::Local data, v8::Local signature, int length, ConstructorBehavior behavior, SideEffectType side_effect_type, const CFunction* c_function, uint16_t instance_type, uint16_t allowed_receiver_instance_type_range_start, uint16_t allowed_receiver_instance_type_range_end) { - i::Isolate* i_isolate = reinterpret_cast(isolate); + i::Isolate* i_isolate = reinterpret_cast(v8_isolate); // Changes to the environment cannot be captured in the snapshot. Expect no // function templates when the isolate is created for serialization. API_RCS_SCOPE(i_isolate, FunctionTemplate, New); @@ -1354,11 +1386,11 @@ Local FunctionTemplate::New( } Local FunctionTemplate::NewWithCFunctionOverloads( - Isolate* isolate, FunctionCallback callback, v8::Local data, + Isolate* v8_isolate, FunctionCallback callback, v8::Local data, v8::Local signature, int length, ConstructorBehavior behavior, SideEffectType side_effect_type, const MemorySpan& c_function_overloads) { - i::Isolate* i_isolate = reinterpret_cast(isolate); + i::Isolate* i_isolate = reinterpret_cast(v8_isolate); API_RCS_SCOPE(i_isolate, FunctionTemplate, New); if (!Utils::ApiCheck( @@ -1376,10 +1408,10 @@ Local FunctionTemplate::NewWithCFunctionOverloads( } Local FunctionTemplate::NewWithCache( - Isolate* isolate, FunctionCallback callback, Local cache_property, - Local data, Local signature, int length, - SideEffectType side_effect_type) { - i::Isolate* i_isolate = reinterpret_cast(isolate); + Isolate* v8_isolate, FunctionCallback callback, + Local cache_property, Local data, + Local signature, int length, SideEffectType side_effect_type) { + i::Isolate* i_isolate = reinterpret_cast(v8_isolate); API_RCS_SCOPE(i_isolate, FunctionTemplate, NewWithCache); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); return FunctionTemplateNew(i_isolate, callback, data, signature, length, @@ -1387,20 +1419,20 @@ Local FunctionTemplate::NewWithCache( side_effect_type); } -Local Signature::New(Isolate* isolate, +Local Signature::New(Isolate* v8_isolate, Local receiver) { return Utils::SignatureToLocal(Utils::OpenHandle(*receiver)); } Local AccessorSignature::New( - Isolate* isolate, Local receiver) { + Isolate* v8_isolate, Local receiver) { return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); } -#define SET_FIELD_WRAPPED(isolate, obj, setter, cdata) \ - do { \ - i::Handle foreign = FromCData(isolate, cdata); \ - (obj)->setter(*foreign); \ +#define SET_FIELD_WRAPPED(i_isolate, obj, setter, cdata) \ + do { \ + i::Handle foreign = FromCData(i_isolate, cdata); \ + (obj)->setter(*foreign); \ } while (false) void FunctionTemplate::SetCallHandler( @@ -1409,38 +1441,39 @@ void FunctionTemplate::SetCallHandler( const MemorySpan& c_function_overloads) { auto info = Utils::OpenHandle(this); EnsureNotPublished(info, "v8::FunctionTemplate::SetCallHandler"); - i::Isolate* isolate = info->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScope scope(isolate); - i::Handle obj = isolate->factory()->NewCallHandlerInfo( + i::Isolate* i_isolate = info->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::HandleScope scope(i_isolate); + i::Handle obj = i_isolate->factory()->NewCallHandlerInfo( side_effect_type == SideEffectType::kHasNoSideEffect); - SET_FIELD_WRAPPED(isolate, obj, set_callback, callback); - SET_FIELD_WRAPPED(isolate, obj, set_js_callback, obj->redirected_callback()); + SET_FIELD_WRAPPED(i_isolate, obj, set_callback, callback); + SET_FIELD_WRAPPED(i_isolate, obj, set_js_callback, + obj->redirected_callback()); if (data.IsEmpty()) { - data = v8::Undefined(reinterpret_cast(isolate)); + data = v8::Undefined(reinterpret_cast(i_isolate)); } obj->set_data(*Utils::OpenHandle(*data)); if (c_function_overloads.size() > 0) { // Stores the data for a sequence of CFunction overloads into a single // FixedArray, as [address_0, signature_0, ... address_n-1, signature_n-1]. i::Handle function_overloads = - isolate->factory()->NewFixedArray(static_cast( + i_isolate->factory()->NewFixedArray(static_cast( c_function_overloads.size() * i::FunctionTemplateInfo::kFunctionOverloadEntrySize)); int function_count = static_cast(c_function_overloads.size()); for (int i = 0; i < function_count; i++) { const CFunction& c_function = c_function_overloads.data()[i]; i::Handle address = - FromCData(isolate, c_function.GetAddress()); + FromCData(i_isolate, c_function.GetAddress()); function_overloads->set( i::FunctionTemplateInfo::kFunctionOverloadEntrySize * i, *address); i::Handle signature = - FromCData(isolate, c_function.GetTypeInfo()); + FromCData(i_isolate, c_function.GetTypeInfo()); function_overloads->set( i::FunctionTemplateInfo::kFunctionOverloadEntrySize * i + 1, *signature); } - i::FunctionTemplateInfo::SetCFunctionOverloads(isolate, info, + i::FunctionTemplateInfo::SetCFunctionOverloads(i_isolate, info, function_overloads); } info->set_call_code(*obj, kReleaseStore); @@ -1450,32 +1483,32 @@ namespace { template i::Handle MakeAccessorInfo( - i::Isolate* isolate, v8::Local name, Getter getter, Setter setter, + i::Isolate* i_isolate, v8::Local name, Getter getter, Setter setter, v8::Local data, v8::AccessControl settings, v8::Local signature, bool is_special_data_property, bool replace_on_access) { - i::Handle obj = isolate->factory()->NewAccessorInfo(); - SET_FIELD_WRAPPED(isolate, obj, set_getter, getter); + i::Handle obj = i_isolate->factory()->NewAccessorInfo(); + SET_FIELD_WRAPPED(i_isolate, obj, set_getter, getter); DCHECK_IMPLIES(replace_on_access, is_special_data_property && setter == nullptr); if (is_special_data_property && setter == nullptr) { setter = reinterpret_cast(&i::Accessors::ReconfigureToDataProperty); } - SET_FIELD_WRAPPED(isolate, obj, set_setter, setter); + SET_FIELD_WRAPPED(i_isolate, obj, set_setter, setter); i::Address redirected = obj->redirected_getter(); if (redirected != i::kNullAddress) { - SET_FIELD_WRAPPED(isolate, obj, set_js_getter, redirected); + SET_FIELD_WRAPPED(i_isolate, obj, set_js_getter, redirected); } i::Handle accessor_name = Utils::OpenHandle(*name); if (!accessor_name->IsUniqueName()) { - accessor_name = isolate->factory()->InternalizeString( + accessor_name = i_isolate->factory()->InternalizeString( i::Handle::cast(accessor_name)); } i::DisallowGarbageCollection no_gc; i::AccessorInfo raw_obj = *obj; if (data.IsEmpty()) { - raw_obj.set_data(i::ReadOnlyRoots(isolate).undefined_value()); + raw_obj.set_data(i::ReadOnlyRoots(i_isolate).undefined_value()); } else { raw_obj.set_data(*Utils::OpenHandle(*data)); } @@ -1500,125 +1533,105 @@ Local FunctionTemplate::InstanceTemplate() { "Reading from empty handle")) { return Local(); } - i::Isolate* isolate = handle->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - if (handle->GetInstanceTemplate().IsUndefined(isolate)) { + i::Isolate* i_isolate = handle->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + if (handle->GetInstanceTemplate().IsUndefined(i_isolate)) { Local templ = - ObjectTemplate::New(isolate, ToApiHandle(handle)); - i::FunctionTemplateInfo::SetInstanceTemplate(isolate, handle, + ObjectTemplate::New(i_isolate, ToApiHandle(handle)); + i::FunctionTemplateInfo::SetInstanceTemplate(i_isolate, handle, Utils::OpenHandle(*templ)); } i::Handle result( - i::ObjectTemplateInfo::cast(handle->GetInstanceTemplate()), isolate); + i::ObjectTemplateInfo::cast(handle->GetInstanceTemplate()), i_isolate); return Utils::ToLocal(result); } void FunctionTemplate::SetLength(int length) { auto info = Utils::OpenHandle(this); EnsureNotPublished(info, "v8::FunctionTemplate::SetLength"); - auto isolate = info->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + auto i_isolate = info->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); info->set_length(length); } void FunctionTemplate::SetClassName(Local name) { auto info = Utils::OpenHandle(this); EnsureNotPublished(info, "v8::FunctionTemplate::SetClassName"); - auto isolate = info->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + auto i_isolate = info->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); info->set_class_name(*Utils::OpenHandle(*name)); } void FunctionTemplate::SetAcceptAnyReceiver(bool value) { auto info = Utils::OpenHandle(this); EnsureNotPublished(info, "v8::FunctionTemplate::SetAcceptAnyReceiver"); - auto isolate = info->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + auto i_isolate = info->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); info->set_accept_any_receiver(value); } void FunctionTemplate::ReadOnlyPrototype() { auto info = Utils::OpenHandle(this); EnsureNotPublished(info, "v8::FunctionTemplate::ReadOnlyPrototype"); - auto isolate = info->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + auto i_isolate = info->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); info->set_read_only_prototype(true); } void FunctionTemplate::RemovePrototype() { auto info = Utils::OpenHandle(this); EnsureNotPublished(info, "v8::FunctionTemplate::RemovePrototype"); - auto isolate = info->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + auto i_isolate = info->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); info->set_remove_prototype(true); } // --- O b j e c t T e m p l a t e --- Local ObjectTemplate::New( - Isolate* isolate, v8::Local constructor) { - return New(reinterpret_cast(isolate), constructor); -} - -static Local ObjectTemplateNew( - i::Isolate* isolate, v8::Local constructor, - bool do_not_cache) { - API_RCS_SCOPE(isolate, ObjectTemplate, New); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::Handle struct_obj = isolate->factory()->NewStruct( - i::OBJECT_TEMPLATE_INFO_TYPE, i::AllocationType::kOld); - i::Handle obj = - i::Handle::cast(struct_obj); - { - // Disallow GC until all fields of obj have acceptable types. - i::DisallowGarbageCollection no_gc; - i::ObjectTemplateInfo raw = *obj; - InitializeTemplate(raw, Consts::OBJECT_TEMPLATE, do_not_cache); - raw.set_data(0); - if (!constructor.IsEmpty()) { - raw.set_constructor(*Utils::OpenHandle(*constructor)); - } - } - return Utils::ToLocal(obj); + Isolate* v8_isolate, v8::Local constructor) { + return New(reinterpret_cast(v8_isolate), constructor); } Local ObjectTemplate::New( - i::Isolate* isolate, v8::Local constructor) { - return ObjectTemplateNew(isolate, constructor, false); + i::Isolate* i_isolate, v8::Local constructor) { + return ObjectTemplateNew(i_isolate, constructor, false); } +namespace { // Ensure that the object template has a constructor. If no // constructor is available we create one. -static i::Handle EnsureConstructor( - i::Isolate* isolate, ObjectTemplate* object_template) { +i::Handle EnsureConstructor( + i::Isolate* i_isolate, ObjectTemplate* object_template) { i::Object obj = Utils::OpenHandle(object_template)->constructor(); - if (!obj.IsUndefined(isolate)) { + if (!obj.IsUndefined(i_isolate)) { i::FunctionTemplateInfo info = i::FunctionTemplateInfo::cast(obj); - return i::Handle(info, isolate); + return i::Handle(info, i_isolate); } Local templ = - FunctionTemplate::New(reinterpret_cast(isolate)); + FunctionTemplate::New(reinterpret_cast(i_isolate)); i::Handle constructor = Utils::OpenHandle(*templ); i::FunctionTemplateInfo::SetInstanceTemplate( - isolate, constructor, Utils::OpenHandle(object_template)); + i_isolate, constructor, Utils::OpenHandle(object_template)); Utils::OpenHandle(object_template)->set_constructor(*constructor); return constructor; } template -static void TemplateSetAccessor( - Template* template_obj, v8::Local name, Getter getter, Setter setter, - Data data, AccessControl settings, PropertyAttribute attribute, - v8::Local signature, bool is_special_data_property, - bool replace_on_access, SideEffectType getter_side_effect_type, - SideEffectType setter_side_effect_type) { +void TemplateSetAccessor(Template* template_obj, v8::Local name, + Getter getter, Setter setter, Data data, + AccessControl settings, PropertyAttribute attribute, + v8::Local signature, + bool is_special_data_property, bool replace_on_access, + SideEffectType getter_side_effect_type, + SideEffectType setter_side_effect_type) { auto info = Utils::OpenHandle(template_obj); - auto isolate = info->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScope scope(isolate); + auto i_isolate = info->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::HandleScope scope(i_isolate); i::Handle accessor_info = - MakeAccessorInfo(isolate, name, getter, setter, data, settings, signature, - is_special_data_property, replace_on_access); + MakeAccessorInfo(i_isolate, name, getter, setter, data, settings, + signature, is_special_data_property, replace_on_access); { i::DisallowGarbageCollection no_gc; i::AccessorInfo raw = *accessor_info; @@ -1627,8 +1640,9 @@ static void TemplateSetAccessor( raw.set_getter_side_effect_type(getter_side_effect_type); raw.set_setter_side_effect_type(setter_side_effect_type); } - i::ApiNatives::AddNativeDataProperty(isolate, info, accessor_info); + i::ApiNatives::AddNativeDataProperty(i_isolate, info, accessor_info); } +} // namespace void Template::SetNativeDataProperty(v8::Local name, AccessorGetterCallback getter, @@ -1693,10 +1707,10 @@ void Template::SetLazyDataProperty(v8::Local name, void Template::SetIntrinsicDataProperty(Local name, Intrinsic intrinsic, PropertyAttribute attribute) { auto templ = Utils::OpenHandle(this); - i::Isolate* isolate = templ->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScope scope(isolate); - i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), + i::Isolate* i_isolate = templ->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::HandleScope scope(i_isolate); + i::ApiNatives::AddDataProperty(i_isolate, templ, Utils::OpenHandle(*name), intrinsic, static_cast(attribute)); } @@ -1753,25 +1767,29 @@ void ObjectTemplate::SetAccessor(v8::Local name, getter_side_effect_type, setter_side_effect_type); } +namespace { template -static i::Handle CreateInterceptorInfo( - i::Isolate* isolate, Getter getter, Setter setter, Query query, +i::Handle CreateInterceptorInfo( + i::Isolate* i_isolate, Getter getter, Setter setter, Query query, Descriptor descriptor, Deleter remover, Enumerator enumerator, Definer definer, Local data, PropertyHandlerFlags flags) { - auto obj = i::Handle::cast(isolate->factory()->NewStruct( - i::INTERCEPTOR_INFO_TYPE, i::AllocationType::kOld)); + auto obj = + i::Handle::cast(i_isolate->factory()->NewStruct( + i::INTERCEPTOR_INFO_TYPE, i::AllocationType::kOld)); obj->set_flags(0); - if (getter != nullptr) SET_FIELD_WRAPPED(isolate, obj, set_getter, getter); - if (setter != nullptr) SET_FIELD_WRAPPED(isolate, obj, set_setter, setter); - if (query != nullptr) SET_FIELD_WRAPPED(isolate, obj, set_query, query); + if (getter != nullptr) SET_FIELD_WRAPPED(i_isolate, obj, set_getter, getter); + if (setter != nullptr) SET_FIELD_WRAPPED(i_isolate, obj, set_setter, setter); + if (query != nullptr) SET_FIELD_WRAPPED(i_isolate, obj, set_query, query); if (descriptor != nullptr) - SET_FIELD_WRAPPED(isolate, obj, set_descriptor, descriptor); - if (remover != nullptr) SET_FIELD_WRAPPED(isolate, obj, set_deleter, remover); + SET_FIELD_WRAPPED(i_isolate, obj, set_descriptor, descriptor); + if (remover != nullptr) + SET_FIELD_WRAPPED(i_isolate, obj, set_deleter, remover); if (enumerator != nullptr) - SET_FIELD_WRAPPED(isolate, obj, set_enumerator, enumerator); - if (definer != nullptr) SET_FIELD_WRAPPED(isolate, obj, set_definer, definer); + SET_FIELD_WRAPPED(i_isolate, obj, set_enumerator, enumerator); + if (definer != nullptr) + SET_FIELD_WRAPPED(i_isolate, obj, set_definer, definer); obj->set_can_intercept_symbols( !(static_cast(flags) & static_cast(PropertyHandlerFlags::kOnlyInterceptStrings))); @@ -1784,7 +1802,7 @@ static i::Handle CreateInterceptorInfo( static_cast(PropertyHandlerFlags::kHasNoSideEffect)); if (data.IsEmpty()) { - data = v8::Undefined(reinterpret_cast(isolate)); + data = v8::Undefined(reinterpret_cast(i_isolate)); } obj->set_data(*Utils::OpenHandle(*data)); return obj; @@ -1792,46 +1810,47 @@ static i::Handle CreateInterceptorInfo( template -static i::Handle CreateNamedInterceptorInfo( - i::Isolate* isolate, Getter getter, Setter setter, Query query, +i::Handle CreateNamedInterceptorInfo( + i::Isolate* i_isolate, Getter getter, Setter setter, Query query, Descriptor descriptor, Deleter remover, Enumerator enumerator, Definer definer, Local data, PropertyHandlerFlags flags) { auto interceptor = - CreateInterceptorInfo(isolate, getter, setter, query, descriptor, remover, - enumerator, definer, data, flags); + CreateInterceptorInfo(i_isolate, getter, setter, query, descriptor, + remover, enumerator, definer, data, flags); interceptor->set_is_named(true); return interceptor; } template -static i::Handle CreateIndexedInterceptorInfo( - i::Isolate* isolate, Getter getter, Setter setter, Query query, +i::Handle CreateIndexedInterceptorInfo( + i::Isolate* i_isolate, Getter getter, Setter setter, Query query, Descriptor descriptor, Deleter remover, Enumerator enumerator, Definer definer, Local data, PropertyHandlerFlags flags) { auto interceptor = - CreateInterceptorInfo(isolate, getter, setter, query, descriptor, remover, - enumerator, definer, data, flags); + CreateInterceptorInfo(i_isolate, getter, setter, query, descriptor, + remover, enumerator, definer, data, flags); interceptor->set_is_named(false); return interceptor; } template -static void ObjectTemplateSetNamedPropertyHandler( +void ObjectTemplateSetNamedPropertyHandler( ObjectTemplate* templ, Getter getter, Setter setter, Query query, Descriptor descriptor, Deleter remover, Enumerator enumerator, Definer definer, Local data, PropertyHandlerFlags flags) { - i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScope scope(isolate); - auto cons = EnsureConstructor(isolate, templ); + i::Isolate* i_isolate = Utils::OpenHandle(templ)->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::HandleScope scope(i_isolate); + auto cons = EnsureConstructor(i_isolate, templ); EnsureNotPublished(cons, "ObjectTemplateSetNamedPropertyHandler"); auto obj = - CreateNamedInterceptorInfo(isolate, getter, setter, query, descriptor, + CreateNamedInterceptorInfo(i_isolate, getter, setter, query, descriptor, remover, enumerator, definer, data, flags); - i::FunctionTemplateInfo::SetNamedPropertyHandler(isolate, cons, obj); + i::FunctionTemplateInfo::SetNamedPropertyHandler(i_isolate, cons, obj); } +} // namespace void ObjectTemplate::SetHandler( const NamedPropertyHandlerConfiguration& config) { @@ -1842,37 +1861,37 @@ void ObjectTemplate::SetHandler( } void ObjectTemplate::MarkAsUndetectable() { - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScope scope(isolate); - auto cons = EnsureConstructor(isolate, this); + i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::HandleScope scope(i_isolate); + auto cons = EnsureConstructor(i_isolate, this); EnsureNotPublished(cons, "v8::ObjectTemplate::MarkAsUndetectable"); cons->set_undetectable(true); } void ObjectTemplate::SetAccessCheckCallback(AccessCheckCallback callback, Local data) { - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScope scope(isolate); - auto cons = EnsureConstructor(isolate, this); + i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::HandleScope scope(i_isolate); + auto cons = EnsureConstructor(i_isolate, this); EnsureNotPublished(cons, "v8::ObjectTemplate::SetAccessCheckCallback"); - i::Handle struct_info = isolate->factory()->NewStruct( + i::Handle struct_info = i_isolate->factory()->NewStruct( i::ACCESS_CHECK_INFO_TYPE, i::AllocationType::kOld); i::Handle info = i::Handle::cast(struct_info); - SET_FIELD_WRAPPED(isolate, info, set_callback, callback); + SET_FIELD_WRAPPED(i_isolate, info, set_callback, callback); info->set_named_interceptor(i::Object()); info->set_indexed_interceptor(i::Object()); if (data.IsEmpty()) { - data = v8::Undefined(reinterpret_cast(isolate)); + data = v8::Undefined(reinterpret_cast(i_isolate)); } info->set_data(*Utils::OpenHandle(*data)); - i::FunctionTemplateInfo::SetAccessCheckInfo(isolate, cons, info); + i::FunctionTemplateInfo::SetAccessCheckInfo(i_isolate, cons, info); cons->set_needs_access_check(true); } @@ -1881,69 +1900,72 @@ void ObjectTemplate::SetAccessCheckCallbackAndHandler( const NamedPropertyHandlerConfiguration& named_handler, const IndexedPropertyHandlerConfiguration& indexed_handler, Local data) { - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScope scope(isolate); - auto cons = EnsureConstructor(isolate, this); + i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::HandleScope scope(i_isolate); + auto cons = EnsureConstructor(i_isolate, this); EnsureNotPublished(cons, "v8::ObjectTemplate::SetAccessCheckCallbackWithHandler"); - i::Handle struct_info = isolate->factory()->NewStruct( + i::Handle struct_info = i_isolate->factory()->NewStruct( i::ACCESS_CHECK_INFO_TYPE, i::AllocationType::kOld); i::Handle info = i::Handle::cast(struct_info); - SET_FIELD_WRAPPED(isolate, info, set_callback, callback); + SET_FIELD_WRAPPED(i_isolate, info, set_callback, callback); auto named_interceptor = CreateNamedInterceptorInfo( - isolate, named_handler.getter, named_handler.setter, named_handler.query, - named_handler.descriptor, named_handler.deleter, named_handler.enumerator, - named_handler.definer, named_handler.data, named_handler.flags); + i_isolate, named_handler.getter, named_handler.setter, + named_handler.query, named_handler.descriptor, named_handler.deleter, + named_handler.enumerator, named_handler.definer, named_handler.data, + named_handler.flags); info->set_named_interceptor(*named_interceptor); auto indexed_interceptor = CreateIndexedInterceptorInfo( - isolate, indexed_handler.getter, indexed_handler.setter, + i_isolate, indexed_handler.getter, indexed_handler.setter, indexed_handler.query, indexed_handler.descriptor, indexed_handler.deleter, indexed_handler.enumerator, indexed_handler.definer, indexed_handler.data, indexed_handler.flags); info->set_indexed_interceptor(*indexed_interceptor); if (data.IsEmpty()) { - data = v8::Undefined(reinterpret_cast(isolate)); + data = v8::Undefined(reinterpret_cast(i_isolate)); } info->set_data(*Utils::OpenHandle(*data)); - i::FunctionTemplateInfo::SetAccessCheckInfo(isolate, cons, info); + i::FunctionTemplateInfo::SetAccessCheckInfo(i_isolate, cons, info); cons->set_needs_access_check(true); } void ObjectTemplate::SetHandler( const IndexedPropertyHandlerConfiguration& config) { - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScope scope(isolate); - auto cons = EnsureConstructor(isolate, this); + i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::HandleScope scope(i_isolate); + auto cons = EnsureConstructor(i_isolate, this); EnsureNotPublished(cons, "v8::ObjectTemplate::SetHandler"); auto obj = CreateIndexedInterceptorInfo( - isolate, config.getter, config.setter, config.query, config.descriptor, + i_isolate, config.getter, config.setter, config.query, config.descriptor, config.deleter, config.enumerator, config.definer, config.data, config.flags); - i::FunctionTemplateInfo::SetIndexedPropertyHandler(isolate, cons, obj); + i::FunctionTemplateInfo::SetIndexedPropertyHandler(i_isolate, cons, obj); } void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, Local data) { - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - i::HandleScope scope(isolate); - auto cons = EnsureConstructor(isolate, this); + i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::HandleScope scope(i_isolate); + auto cons = EnsureConstructor(i_isolate, this); EnsureNotPublished(cons, "v8::ObjectTemplate::SetCallAsFunctionHandler"); - i::Handle obj = isolate->factory()->NewCallHandlerInfo(); - SET_FIELD_WRAPPED(isolate, obj, set_callback, callback); - SET_FIELD_WRAPPED(isolate, obj, set_js_callback, obj->redirected_callback()); + i::Handle obj = + i_isolate->factory()->NewCallHandlerInfo(); + SET_FIELD_WRAPPED(i_isolate, obj, set_callback, callback); + SET_FIELD_WRAPPED(i_isolate, obj, set_js_callback, + obj->redirected_callback()); if (data.IsEmpty()) { - data = v8::Undefined(reinterpret_cast(isolate)); + data = v8::Undefined(reinterpret_cast(i_isolate)); } obj->set_data(*Utils::OpenHandle(*data)); - i::FunctionTemplateInfo::SetInstanceCallHandler(isolate, cons, obj); + i::FunctionTemplateInfo::SetInstanceCallHandler(i_isolate, cons, obj); } int ObjectTemplate::InternalFieldCount() const { @@ -1951,18 +1973,18 @@ int ObjectTemplate::InternalFieldCount() const { } void ObjectTemplate::SetInternalFieldCount(int value) { - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); if (!Utils::ApiCheck(i::Smi::IsValid(value), "v8::ObjectTemplate::SetInternalFieldCount()", "Invalid embedder field count")) { return; } - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); if (value > 0) { // The embedder field count is set by the constructor function's // construct code, so we ensure that there is a constructor // function to do the setting. - EnsureConstructor(isolate, this); + EnsureConstructor(i_isolate, this); } Utils::OpenHandle(this)->set_embedder_field_count(value); } @@ -1973,8 +1995,8 @@ bool ObjectTemplate::IsImmutableProto() const { void ObjectTemplate::SetImmutableProto() { auto self = Utils::OpenHandle(this); - i::Isolate* isolate = self->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + i::Isolate* i_isolate = self->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); self->set_immutable_proto(true); } @@ -1984,8 +2006,8 @@ bool ObjectTemplate::IsCodeLike() const { void ObjectTemplate::SetCodeLike() { auto self = Utils::OpenHandle(this); - i::Isolate* isolate = self->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + i::Isolate* i_isolate = self->GetIsolate(); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); self->set_code_like(true); } @@ -2016,11 +2038,11 @@ ScriptCompiler::StreamedSource::~StreamedSource() = default; Local