diff --git a/deps/v8/.gitignore b/deps/v8/.gitignore index bfc93c7d444980..e805b2aabfeacc 100644 --- a/deps/v8/.gitignore +++ b/deps/v8/.gitignore @@ -40,6 +40,7 @@ .torquelint-cache .vscode /_* +/base /build /buildtools /check-header-includes @@ -77,6 +78,8 @@ !/third_party/googletest/src/googletest/include/gtest /third_party/googletest/src/googletest/include/gtest/* !/third_party/googletest/src/googletest/include/gtest/gtest_prod.h +!/third_party/highway +/third_party/highway/src !/third_party/inspector_protocol !/third_party/jsoncpp /third_party/jsoncpp/source @@ -96,6 +99,7 @@ /tools/luci-go /tools/oom_dump/oom_dump /tools/oom_dump/oom_dump.o +/tools/protoc_wrapper /tools/turbolizer/build /tools/turbolizer/.rpt2_cache /tools/turbolizer/deploy diff --git a/deps/v8/.gn b/deps/v8/.gn index 3a73ff4e2a1a08..afdb6fa1201d0e 100644 --- a/deps/v8/.gn +++ b/deps/v8/.gn @@ -25,6 +25,8 @@ no_check_targets = [ ] default_args = { + # Disable js dependencies like the closure compiler. + enable_js_protobuf = false # Disable rust dependencies. enable_rust = false } diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index 54fb45992db176..e53a6577c54950 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -57,6 +57,7 @@ Alexander Botero-Lowry Alexander Karpinsky Alexander Neville Alexandre Vassalotti +Alexey Pavlyutkin Alexis Campailla Allan Sandfeld Jensen Amos Lim @@ -100,6 +101,7 @@ Daniel Bevenius Daniel Dromboski Daniel James Daniel Shelton +Daniil Bakin Danylo Boiko Darshan Sen David Carlier @@ -258,6 +260,7 @@ Sander Mathijs van Veen Sandro Santilli Sanjoy Das Sam James +Sébastien Doeraene Seo Sanghyeon Shawn Anastasio Shawn Presser diff --git a/deps/v8/BUILD.bazel b/deps/v8/BUILD.bazel index 05b7472165ae85..0718b28b052946 100644 --- a/deps/v8/BUILD.bazel +++ b/deps/v8/BUILD.bazel @@ -28,6 +28,8 @@ load(":bazel/v8-non-pointer-compression.bzl", "v8_binary_non_pointer_compression # v8_custom_deps # v8_embed_script # v8_embedder_string +# v8_array_buffer_internal_field_count +# v8_array_buffer_view_internal_field_count # v8_promise_internal_field_count # v8_enable_vtunetracemark # v8_enable_fast_torque @@ -274,18 +276,6 @@ v8_flag( default = True, ) -# Shared RO heap. Flag has to be set to false when -# v8_enable_pointer_compression_shared_cage is set to false. -v8_flag( - name = "v8_enable_shared_ro_heap", - default = True, -) - -v8_flag( - name = "v8_enable_extensible_ro_snapshot", - default = True, -) - # Enable shared cage if v8_enable_pointer_compression # and v8_enable_pointer_compression_shared_cage. selects.config_setting_group( @@ -429,6 +419,8 @@ v8_config( "V8_ADVANCED_BIGINT_ALGORITHMS", "V8_CONCURRENT_MARKING", "V8_ENABLE_SPARKPLUG", + "V8_ENABLE_EXTENSIBLE_RO_SNAPSHOT", + "V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA", ] + select({ "@v8//bazel/config:is_debug": [ "DEBUG", @@ -497,13 +489,13 @@ v8_config( ], "//conditions:default": [], }) + select({ - ":is_v8_enable_shared_ro_heap": [ + # Shared RO heap is unconfigurable in bazel. However, we + # still have to make sure that the flag is disabled when + # v8_enable_pointer_compression_shared_cage is set to false. + ":is_v8_enable_pointer_compression_shared_cage": [ "V8_SHARED_RO_HEAP", ], - }) + select({ - ":is_v8_enable_extensible_ro_snapshot": [ - "V8_ENABLE_EXTENSIBLE_RO_SNAPSHOT", - ], + "//conditions:default": [], }) + select({ ":is_v8_enable_short_builtin_calls": [ "V8_SHORT_BUILTIN_CALLS", @@ -653,6 +645,7 @@ filegroup( "include/v8-promise.h", "include/v8-proxy.h", "include/v8-regexp.h", + "include/v8-sandbox.h", "include/v8-script.h", "include/v8-snapshot.h", "include/v8-statistics.h", @@ -798,6 +791,10 @@ filegroup( "src/base/strings.h", "src/base/sys-info.cc", "src/base/sys-info.h", + "src/base/template-meta-programming/algorithm.h", + "src/base/template-meta-programming/functional.h", + "src/base/template-meta-programming/list.h", + "src/base/template-meta-programming/string-literal.h", "src/base/template-utils.h", "src/base/threaded-list.h", "src/base/timezone-cache.h", @@ -969,6 +966,7 @@ filegroup( "src/builtins/promise-reaction-job.tq", "src/builtins/promise-resolve.tq", "src/builtins/promise-then.tq", + "src/builtins/promise-try.tq", "src/builtins/promise-withresolvers.tq", "src/builtins/proxy.tq", "src/builtins/proxy-constructor.tq", @@ -1070,6 +1068,7 @@ filegroup( "src/objects/js-atomics-synchronization.tq", "src/objects/js-collection.tq", "src/objects/js-collection-iterator.tq", + "src/objects/js-disposable-stack.tq", "src/objects/js-function.tq", "src/objects/js-generator.tq", "src/objects/js-iterator-helpers.tq", @@ -1209,15 +1208,6 @@ filegroup( ], ) -# Default setting for v8_enable_pointer_compression when target is x64. -selects.config_setting_group( - name = "is_v8_enable_webassembly_on_non_android_posix_x64", - match_all = [ - ":is_v8_enable_webassembly", - "@v8//bazel/config:is_non_android_posix_x64", - ], -) - filegroup( name = "v8_base_without_compiler_files", srcs = [ @@ -1281,6 +1271,7 @@ filegroup( "src/builtins/builtins-api.cc", "src/builtins/builtins-array.cc", "src/builtins/builtins-arraybuffer.cc", + "src/builtins/builtins-async-disposable-stack.cc", "src/builtins/builtins-async-module.cc", "src/builtins/builtins-atomics-synchronization.cc", "src/builtins/builtins-bigint.cc", @@ -1292,6 +1283,7 @@ filegroup( "src/builtins/builtins-date.cc", "src/builtins/builtins-definitions.h", "src/builtins/builtins-descriptors.h", + "src/builtins/builtins-disposable-stack.cc", "src/builtins/builtins-error.cc", "src/builtins/builtins-function.cc", "src/builtins/builtins-global.cc", @@ -1355,6 +1347,7 @@ filegroup( "src/codegen/flush-instruction-cache.h", "src/codegen/handler-table.cc", "src/codegen/handler-table.h", + "src/codegen/heap-object-list.h", "src/codegen/interface-descriptors.cc", "src/codegen/interface-descriptors.h", "src/codegen/interface-descriptors-inl.h", @@ -1409,6 +1402,7 @@ filegroup( "src/common/ptr-compr.cc", "src/common/ptr-compr.h", "src/common/ptr-compr-inl.h", + "src/common/simd128.h", "src/compiler-dispatcher/lazy-compile-dispatcher.cc", "src/compiler-dispatcher/lazy-compile-dispatcher.h", "src/compiler-dispatcher/optimizing-compile-dispatcher.cc", @@ -1572,6 +1566,7 @@ filegroup( "src/heap/base/active-system-pages.h", "src/heap/memory-chunk-metadata.cc", "src/heap/memory-chunk-metadata.h", + "src/heap/memory-chunk-metadata-inl.h", "src/heap/code-range.cc", "src/heap/code-range.h", "src/heap/trusted-range.cc", @@ -1599,8 +1594,6 @@ filegroup( "src/heap/cppgc-js/unified-heap-marking-verifier.h", "src/heap/cppgc-js/unified-heap-marking-visitor.cc", "src/heap/cppgc-js/unified-heap-marking-visitor.h", - "src/heap/cppgc-js/wrappable-info.h", - "src/heap/cppgc-js/wrappable-info-inl.h", "src/heap/ephemeron-remembered-set.h", "src/heap/ephemeron-remembered-set.cc", "src/heap/evacuation-allocator.cc", @@ -1621,8 +1614,6 @@ filegroup( "src/heap/free-list.h", "src/heap/free-list-inl.h", "src/heap/gc-callbacks.h", - "src/heap/gc-idle-time-handler.cc", - "src/heap/gc-idle-time-handler.h", "src/heap/gc-tracer.cc", "src/heap/gc-tracer.h", "src/heap/gc-tracer-inl.h", @@ -1648,8 +1639,9 @@ filegroup( "src/heap/incremental-marking-job.h", "src/heap/index-generator.cc", "src/heap/index-generator.h", - "src/heap/large-page.cc", - "src/heap/large-page.h", + "src/heap/large-page-metadata.cc", + "src/heap/large-page-metadata.h", + "src/heap/large-page-metadata-inl.h", "src/heap/large-spaces.cc", "src/heap/large-spaces.h", "src/heap/linear-allocation-area.h", @@ -1688,11 +1680,12 @@ filegroup( "src/heap/memory-allocator.h", "src/heap/memory-balancer.cc", "src/heap/memory-balancer.h", - "src/heap/mutable-page.cc", - "src/heap/mutable-page.h", + "src/heap/mutable-page-metadata.cc", + "src/heap/mutable-page-metadata.h", + "src/heap/mutable-page-metadata-inl.h", "src/heap/memory-chunk.cc", "src/heap/memory-chunk.h", - "src/heap/mutable-page-inl.h", + "src/heap/memory-chunk-inl.h", "src/heap/memory-chunk-layout.cc", "src/heap/memory-chunk-layout.h", "src/heap/memory-measurement.cc", @@ -1706,14 +1699,15 @@ filegroup( "src/heap/new-spaces.h", "src/heap/new-spaces-inl.h", "src/heap/object-lock.h", + "src/heap/object-lock-inl.h", "src/heap/object-stats.cc", "src/heap/object-stats.h", "src/heap/objects-visiting.cc", "src/heap/objects-visiting.h", "src/heap/objects-visiting-inl.h", - "src/heap/page.cc", - "src/heap/page.h", - "src/heap/page-inl.h", + "src/heap/page-metadata.cc", + "src/heap/page-metadata.h", + "src/heap/page-metadata-inl.h", "src/heap/paged-spaces.cc", "src/heap/paged-spaces.h", "src/heap/paged-spaces-inl.h", @@ -1774,8 +1768,8 @@ filegroup( "src/init/heap-symbols.h", "src/init/icu_util.cc", "src/init/icu_util.h", - "src/init/isolate-allocator.cc", - "src/init/isolate-allocator.h", + "src/init/isolate-group.cc", + "src/init/isolate-group.h", "src/init/setup-isolate.h", "src/init/startup-data-util.cc", "src/init/startup-data-util.h", @@ -1792,8 +1786,8 @@ filegroup( "src/interpreter/bytecode-array-writer.h", "src/interpreter/bytecode-decoder.cc", "src/interpreter/bytecode-decoder.h", - "src/interpreter/bytecode-flags.cc", - "src/interpreter/bytecode-flags.h", + "src/interpreter/bytecode-flags-and-tokens.cc", + "src/interpreter/bytecode-flags-and-tokens.h", "src/interpreter/bytecode-generator.cc", "src/interpreter/bytecode-generator.h", "src/interpreter/bytecode-jump-table.h", @@ -1877,6 +1871,7 @@ filegroup( "src/objects/call-site-info.cc", "src/objects/call-site-info.h", "src/objects/call-site-info-inl.h", + "src/objects/casting.h", "src/objects/cell.h", "src/objects/cell-inl.h", "src/objects/code.cc", @@ -1960,6 +1955,9 @@ filegroup( "src/objects/js-collection-inl.h", "src/objects/js-collection-iterator.h", "src/objects/js-collection-iterator-inl.h", + "src/objects/js-disposable-stack.cc", + "src/objects/js-disposable-stack.h", + "src/objects/js-disposable-stack-inl.h", "src/objects/js-function.cc", "src/objects/js-function.h", "src/objects/js-function-inl.h", @@ -2120,6 +2118,7 @@ filegroup( "src/objects/tagged-index.h", "src/objects/tagged-value.h", "src/objects/tagged-value-inl.h", + "src/objects/union.h", "src/objects/template-objects.cc", "src/objects/template-objects.h", "src/objects/template-objects-inl.h", @@ -2142,6 +2141,8 @@ filegroup( "src/objects/visitors.cc", "src/objects/visitors.h", "src/objects/visitors-inl.h", + "src/objects/waiter-queue-node.cc", + "src/objects/waiter-queue-node.h", "src/parsing/expression-scope.h", "src/parsing/func-name-inferrer.cc", "src/parsing/func-name-inferrer.h", @@ -2287,31 +2288,50 @@ filegroup( "src/runtime/runtime-weak-refs.cc", "src/sandbox/bounded-size.h", "src/sandbox/bounded-size-inl.h", + "src/sandbox/check.h", "src/sandbox/external-pointer.h", "src/sandbox/external-pointer-inl.h", "src/sandbox/external-pointer-table.cc", "src/sandbox/external-pointer-table.h", "src/sandbox/external-pointer-table-inl.h", + "src/sandbox/cppheap-pointer-inl.h", + "src/sandbox/cppheap-pointer-table.cc", + "src/sandbox/cppheap-pointer-table.h", + "src/sandbox/cppheap-pointer-table-inl.h", "src/sandbox/code-pointer-table.cc", "src/sandbox/code-pointer-table.h", "src/sandbox/code-pointer-table-inl.h", + "src/sandbox/js-dispatch-table.cc", + "src/sandbox/js-dispatch-table.h", + "src/sandbox/js-dispatch-table-inl.h", "src/sandbox/trusted-pointer-table.cc", "src/sandbox/trusted-pointer-table.h", "src/sandbox/trusted-pointer-table-inl.h", "src/sandbox/code-pointer.h", "src/sandbox/code-pointer-inl.h", + "src/sandbox/compactible-external-entity-table-inl.h", + "src/sandbox/compactible-external-entity-table.h", "src/sandbox/isolate.h", "src/sandbox/isolate-inl.h", "src/sandbox/indirect-pointer.h", "src/sandbox/indirect-pointer-tag.h", "src/sandbox/indirect-pointer-inl.h", "src/sandbox/code-entrypoint-tag.h", + "src/sandbox/external-buffer.h", + "src/sandbox/external-buffer-tag.h", + "src/sandbox/external-buffer-inl.h", + "src/sandbox/external-buffer-table.cc", + "src/sandbox/external-buffer-table-inl.h", + "src/sandbox/external-buffer-table.h", "src/sandbox/external-entity-table.h", "src/sandbox/external-entity-table-inl.h", + "src/sandbox/hardware-support.cc", + "src/sandbox/hardware-support.h", "src/sandbox/sandbox.cc", "src/sandbox/sandbox.h", "src/sandbox/sandboxed-pointer.h", "src/sandbox/sandboxed-pointer-inl.h", + "src/sandbox/tagged-payload.h", "src/sandbox/testing.cc", "src/sandbox/testing.h", "src/snapshot/code-serializer.cc", @@ -2364,6 +2384,7 @@ filegroup( "src/strings/char-predicates.h", "src/strings/char-predicates-inl.h", "src/strings/string-builder.cc", + "src/strings/string-builder.h", "src/strings/string-builder-inl.h", "src/strings/string-case.cc", "src/strings/string-case.h", @@ -2393,6 +2414,7 @@ filegroup( "src/torque/runtime-macro-shims.h", "src/tracing/trace-event.cc", "src/tracing/trace-event.h", + "src/tracing/trace-event-no-perfetto.h", "src/tracing/traced-value.cc", "src/tracing/traced-value.h", "src/tracing/tracing-category-observer.cc", @@ -2663,12 +2685,7 @@ filegroup( "src/wasm/baseline/ppc/liftoff-assembler-ppc-inl.h", ], }) + select({ - # Only for x64 builds and for arm64 with x64 host simulator. - ":is_v8_enable_webassembly_on_non_android_posix_x64": [ - "src/trap-handler/handler-inside-posix.cc", - "src/trap-handler/handler-outside-posix.cc", - ], - "@v8//bazel/config:is_macos_arm64": [ + "@v8//bazel/config:is_posix": [ "src/trap-handler/handler-inside-posix.cc", "src/trap-handler/handler-outside-posix.cc", ], @@ -2714,6 +2731,8 @@ filegroup( "src/maglev/maglev-ir.h", "src/maglev/maglev-phi-representation-selector.h", "src/maglev/maglev-pipeline-statistics.h", + "src/maglev/maglev-post-hoc-optimizations-processors.h", + "src/maglev/maglev-pre-regalloc-codegen-processors.h", "src/maglev/maglev-regalloc-data.h", "src/maglev/maglev-regalloc.h", "src/maglev/maglev-register-frame-array.h", @@ -2786,6 +2805,7 @@ filegroup( "src/wasm/baseline/liftoff-compiler.cc", "src/wasm/baseline/liftoff-compiler.h", "src/wasm/baseline/liftoff-register.h", + "src/wasm/baseline/liftoff-varstate.h", "src/wasm/baseline/parallel-move.cc", "src/wasm/baseline/parallel-move.h", "src/wasm/baseline/parallel-move-inl.h", @@ -2801,6 +2821,7 @@ filegroup( "src/wasm/constant-expression-interface.cc", "src/wasm/constant-expression-interface.h", "src/wasm/decoder.h", + "src/wasm/float16.h", "src/wasm/function-body-decoder.cc", "src/wasm/function-body-decoder.h", "src/wasm/function-body-decoder-impl.h", @@ -2831,6 +2852,7 @@ filegroup( "src/wasm/pgo.cc", "src/wasm/pgo.h", "src/wasm/serialized-signature-inl.h", + "src/wasm/signature-hashing.h", "src/wasm/simd-shuffle.cc", "src/wasm/simd-shuffle.h", "src/wasm/stacks.cc", @@ -2852,6 +2874,8 @@ filegroup( "src/wasm/wasm-code-manager.h", "src/wasm/wasm-debug.cc", "src/wasm/wasm-debug.h", + "src/wasm/wasm-deopt-data.cc", + "src/wasm/wasm-deopt-data.h", "src/wasm/wasm-disassembler.cc", "src/wasm/wasm-disassembler.h", "src/wasm/wasm-disassembler-impl.h", @@ -3022,8 +3046,6 @@ filegroup( "src/compiler/const-tracking-let-helpers.h", "src/compiler/control-equivalence.cc", "src/compiler/control-equivalence.h", - "src/compiler/control-flow-optimizer.cc", - "src/compiler/control-flow-optimizer.h", "src/compiler/control-path-state.h", "src/compiler/csa-load-elimination.cc", "src/compiler/csa-load-elimination.h", @@ -3032,8 +3054,6 @@ filegroup( "src/compiler/decompression-optimizer.cc", "src/compiler/decompression-optimizer.h", "src/compiler/diamond.h", - "src/compiler/effect-control-linearizer.cc", - "src/compiler/effect-control-linearizer.h", "src/compiler/escape-analysis.cc", "src/compiler/escape-analysis.h", "src/compiler/escape-analysis-reducer.cc", @@ -3177,18 +3197,20 @@ filegroup( "src/compiler/simplified-operator-reducer.h", "src/compiler/state-values-utils.cc", "src/compiler/state-values-utils.h", - "src/compiler/store-store-elimination.cc", - "src/compiler/store-store-elimination.h", "src/compiler/string-builder-optimizer.cc", "src/compiler/string-builder-optimizer.h", "src/compiler/turbofan.h", "src/compiler/turbofan-enabled.cc", + "src/compiler/turboshaft/access-builder.h", "src/compiler/turboshaft/analyzer-iterator.cc", "src/compiler/turboshaft/analyzer-iterator.h", "src/compiler/turboshaft/assembler.cc", "src/compiler/turboshaft/assembler.h", "src/compiler/turboshaft/assert-types-reducer.h", - "src/compiler/turboshaft/duplication-optimization-reducer.h", + "src/compiler/turboshaft/block-instrumentation-phase.cc", + "src/compiler/turboshaft/block-instrumentation-phase.h", + "src/compiler/turboshaft/block-instrumentation-reducer.cc", + "src/compiler/turboshaft/block-instrumentation-reducer.h", "src/compiler/turboshaft/branch-elimination-reducer.h", "src/compiler/turboshaft/build-graph-phase.cc", "src/compiler/turboshaft/build-graph-phase.h", @@ -3198,6 +3220,8 @@ filegroup( "src/compiler/turboshaft/dataview-lowering-reducer.h", "src/compiler/turboshaft/code-elimination-and-simplification-phase.cc", "src/compiler/turboshaft/code-elimination-and-simplification-phase.h", + "src/compiler/turboshaft/copying-phase.cc", + "src/compiler/turboshaft/copying-phase.h", "src/compiler/turboshaft/dead-code-elimination-reducer.h", "src/compiler/turboshaft/debug-feature-lowering-phase.cc", "src/compiler/turboshaft/debug-feature-lowering-phase.h", @@ -3208,6 +3232,7 @@ filegroup( "src/compiler/turboshaft/decompression-optimization-phase.h", "src/compiler/turboshaft/define-assembler-macros.inc", "src/compiler/turboshaft/deopt-data.h", + "src/compiler/turboshaft/duplication-optimization-reducer.h", "src/compiler/turboshaft/explicit-truncation-reducer.h", "src/compiler/turboshaft/fast-api-call-lowering-reducer.h", "src/compiler/turboshaft/fast-hash.h", @@ -3219,6 +3244,7 @@ filegroup( "src/compiler/turboshaft/graph-visualizer.h", "src/compiler/turboshaft/js-generic-lowering-reducer.h", "src/compiler/turboshaft/index.h", + "src/compiler/turboshaft/instruction-selection-normalization-reducer.h", "src/compiler/turboshaft/instruction-selection-phase.cc", "src/compiler/turboshaft/instruction-selection-phase.h", "src/compiler/turboshaft/late-escape-analysis-reducer.cc", @@ -3249,12 +3275,12 @@ filegroup( "src/compiler/turboshaft/operations.cc", "src/compiler/turboshaft/operations.h", "src/compiler/turboshaft/opmasks.h", - "src/compiler/turboshaft/copying-phase.cc", - "src/compiler/turboshaft/copying-phase.h", "src/compiler/turboshaft/optimize-phase.cc", "src/compiler/turboshaft/optimize-phase.h", "src/compiler/turboshaft/phase.cc", "src/compiler/turboshaft/phase.h", + "src/compiler/turboshaft/pipelines.cc", + "src/compiler/turboshaft/pipelines.h", "src/compiler/turboshaft/pretenuring-propagation-reducer.cc", "src/compiler/turboshaft/pretenuring-propagation-reducer.h", "src/compiler/turboshaft/recreate-schedule.cc", @@ -3262,6 +3288,7 @@ filegroup( "src/compiler/turboshaft/recreate-schedule-phase.cc", "src/compiler/turboshaft/recreate-schedule-phase.h", "src/compiler/turboshaft/reducer-traits.h", + "src/compiler/turboshaft/register-allocation-phase.h", "src/compiler/turboshaft/representations.cc", "src/compiler/turboshaft/representations.h", "src/compiler/turboshaft/required-optimization-reducer.h", @@ -3279,7 +3306,7 @@ filegroup( "src/compiler/turboshaft/stack-check-lowering-reducer.h", "src/compiler/turboshaft/store-store-elimination-phase.cc", "src/compiler/turboshaft/store-store-elimination-phase.h", - "src/compiler/turboshaft/store-store-elimination-reducer.h", + "src/compiler/turboshaft/store-store-elimination-reducer-inl.h", "src/compiler/turboshaft/structural-optimization-reducer.h", "src/compiler/turboshaft/tracing.h", "src/compiler/turboshaft/type-assertions-phase.cc", @@ -3304,6 +3331,7 @@ filegroup( "src/compiler/turboshaft/value-numbering-reducer.h", "src/compiler/turboshaft/variable-reducer.h", "src/compiler/turboshaft/wasm-js-lowering-reducer.h", + "src/compiler/turboshaft/zone-with-name.h", "src/compiler/type-cache.cc", "src/compiler/type-cache.h", "src/compiler/type-narrowing-reducer.cc", @@ -3425,6 +3453,36 @@ filegroup( "src/compiler/wasm-typer.h", ], "//conditions:default": [], + }) + select({ + # Turboshaft's Maglev graph builder needs some Maglev files. We only + # include them explicitely when Maglev is disabled. + ":enable_maglev": [], + "//conditions:default": [ + "src/maglev/maglev-basic-block.h", + "src/maglev/maglev-code-gen-state.h", + "src/maglev/maglev-compilation-info.cc", + "src/maglev/maglev-compilation-info.h", + "src/maglev/maglev-compilation-unit.cc", + "src/maglev/maglev-compilation-unit.h", + "src/maglev/maglev-graph-builder.cc", + "src/maglev/maglev-graph-builder.h", + "src/maglev/maglev-graph.h", + "src/maglev/maglev-graph-labeller.h", + "src/maglev/maglev-graph-printer.cc", + "src/maglev/maglev-graph-printer.h", + "src/maglev/maglev-graph-processor.h", + "src/maglev/maglev-graph-verifier.h", + "src/maglev/maglev-interpreter-frame-state.cc", + "src/maglev/maglev-interpreter-frame-state.h", + "src/maglev/maglev-ir.cc", + "src/maglev/maglev-ir.h", + "src/maglev/maglev-ir-inl.h", + "src/maglev/maglev-register-frame-array.h", + "src/maglev/maglev-phi-representation-selector.cc", + "src/maglev/maglev-phi-representation-selector.h", + "src/maglev/maglev-post-hoc-optimizations-processors.h", + "src/maglev/maglev-pre-regalloc-codegen-processors.h", + ], }), ) @@ -3474,6 +3532,7 @@ filegroup( "src/builtins/builtins-sharedarraybuffer-gen.cc", "src/builtins/builtins-string-gen.cc", "src/builtins/builtins-string-gen.h", + "src/builtins/builtins-string-tsa.cc", "src/builtins/builtins-temporal-gen.cc", "src/builtins/builtins-typed-array-gen.cc", "src/builtins/builtins-typed-array-gen.h", @@ -3484,6 +3543,7 @@ filegroup( "src/builtins/profile-data-reader.h", "src/builtins/setup-builtins-internal.cc", "src/builtins/torque-csa-header-includes.h", + "src/codegen/turboshaft-builtins-assembler-inl.h", "src/codegen/code-stub-assembler.cc", "third_party/v8/codegen/fp16-inl.h", "src/codegen/code-stub-assembler-inl.h", @@ -3519,32 +3579,6 @@ filegroup( "src/builtins/builtins-wasm-gen.h", ], "//conditions:default": [], - }) + select({ - # Turboshaft's Maglev graph builder needs some Maglev files. We only - # include them explicitely when Maglev is disabled. - ":enable_maglev": [], - "//conditions:default": [ - "src/maglev/maglev-basic-block.h", - "src/maglev/maglev-code-gen-state.h", - "src/maglev/maglev-compilation-info.cc", - "src/maglev/maglev-compilation-info.h", - "src/maglev/maglev-compilation-unit.cc", - "src/maglev/maglev-compilation-unit.h", - "src/maglev/maglev-graph-builder.cc", - "src/maglev/maglev-graph-builder.h", - "src/maglev/maglev-graph.h", - "src/maglev/maglev-graph-labeller.h", - "src/maglev/maglev-graph-printer.cc", - "src/maglev/maglev-graph-printer.h", - "src/maglev/maglev-graph-processor.h", - "src/maglev/maglev-graph-verifier.h", - "src/maglev/maglev-interpreter-frame-state.cc", - "src/maglev/maglev-interpreter-frame-state.h", - "src/maglev/maglev-ir.cc", - "src/maglev/maglev-ir.h", - "src/maglev/maglev-ir-inl.h", - "src/maglev/maglev-register-frame-array.h", - ], }), ) @@ -3660,6 +3694,7 @@ filegroup( "src/heap/base/active-system-pages.h", "src/heap/base/basic-slot-set.h", "src/heap/base/bytes.h", + "src/heap/base/cached-unordered-map.h", "src/heap/base/incremental-marking-schedule.cc", "src/heap/base/incremental-marking-schedule.h", "src/heap/base/memory-tagging.h", @@ -3739,6 +3774,8 @@ filegroup( "src/snapshot/embedded/platform-embedded-file-writer-mac.h", "src/snapshot/embedded/platform-embedded-file-writer-win.cc", "src/snapshot/embedded/platform-embedded-file-writer-win.h", + "src/snapshot/embedded/platform-embedded-file-writer-zos.cc", + "src/snapshot/embedded/platform-embedded-file-writer-zos.h", "src/snapshot/mksnapshot.cc", "src/snapshot/snapshot-empty.cc", "src/snapshot/static-roots-gen.cc", @@ -4188,7 +4225,6 @@ v8_library( deps = [ ":lib_fp16", ":v8_libbase", - "//external:base_trace_event_common", "//external:absl_btree", "//external:absl_flat_hash_map", "//external:absl_flat_hash_set", @@ -4372,6 +4408,11 @@ alias( v8_build_config( name = "v8_build_config", + arch = select({ + "@v8//bazel/config:v8_target_arm64": "arm64", + "@v8//bazel/config:v8_target_x64": "x64", + "//conditions:default": "x64", + }), ) # Runs mjsunit with d8. @@ -4389,6 +4430,15 @@ py_test( "--variant=google3_noicu", "--outdir noicu", "--verbose", + ] + select({ + "@v8//bazel/config:v8_target_arm64": [ + "--arch=arm64", + ], + "@v8//bazel/config:v8_target_x64": [ + "--arch=x64", + ], + "//conditions:default": [], + }) + [ "mjsunit", ], data = [ @@ -4419,6 +4469,15 @@ py_test( "--variant=google3_icu", "--outdir icu", "--verbose", + ] + select({ + "@v8//bazel/config:v8_target_arm64": [ + "--arch=arm64", + ], + "@v8//bazel/config:v8_target_x64": [ + "--arch=x64", + ], + "//conditions:default": [], + }) + [ "mjsunit", ], data = [ diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn index e2e0c16d97080d..92e8541951384f 100644 --- a/deps/v8/BUILD.gn +++ b/deps/v8/BUILD.gn @@ -31,10 +31,6 @@ declare_args() { # Dynamically set an additional dependency from v8/custom_deps. v8_custom_deps = "" - # Turns on all V8 debug features. Enables running V8 in a pseudo debug mode - # within a release Chrome. - v8_enable_debugging_features = is_debug - # Sets -DV8_ENABLE_FUTURE. v8_enable_future = false @@ -71,6 +67,12 @@ declare_args() { # Sets the number of internal fields on promise objects. v8_promise_internal_field_count = 0 + # Sets the number of internal fields on array buffer objects. + v8_array_buffer_internal_field_count = 0 + + # Sets the number of internal fields on array buffer view objects. + v8_array_buffer_view_internal_field_count = 0 + # Sets -dENABLE_GDB_JIT_INTERFACE. v8_enable_gdbjit = "" @@ -333,7 +335,7 @@ declare_args() { # Sets -DV8_COMPRESS_ZONES. v8_enable_zone_compression = "" - # Enable the experimental V8 sandbox. + # Enable the V8 sandbox. # Sets -DV8_ENABLE_SANDBOX. v8_enable_sandbox = "" @@ -404,9 +406,7 @@ declare_args() { # when this is set to 'false', one can run V8 in jitless mode at runtime by # passing the `--jitless` flag; but then you miss out on compile-time # optimizations. - # iOS (non-simulator) does not have executable pages for 3rd party - # applications yet so disable jit. - v8_jitless = v8_enable_lite_mode || target_is_ios_device + v8_jitless = v8_enable_lite_mode # Enable Sparkplug # Sets -DV8_ENABLE_SPARKPLUG. @@ -428,11 +428,19 @@ declare_args() { # Whether custom embedder snapshots may extend (= allocate new objects in) # ReadOnlySpace. v8_enable_extensible_ro_snapshot = true + + # Use sticky mark-bits for separating object generations. + v8_enable_sticky_mark_bits = false + + # Use the experimental TSA-based definition for some builtins. + v8_enable_experimental_tsa_builtins = false + + v8_dcheck_always_on = dcheck_always_on } # Derived defaults. if (cppgc_enable_verify_heap == "") { - cppgc_enable_verify_heap = v8_enable_debugging_features || dcheck_always_on + cppgc_enable_verify_heap = v8_enable_debugging_features || v8_dcheck_always_on } if (v8_enable_verify_heap == "") { v8_enable_verify_heap = v8_enable_debugging_features @@ -447,14 +455,14 @@ if (v8_enable_trace_maps == "") { v8_enable_trace_maps = v8_enable_debugging_features } if (v8_enable_test_features == "") { - v8_enable_test_features = v8_enable_debugging_features || dcheck_always_on + v8_enable_test_features = v8_enable_debugging_features || v8_dcheck_always_on } if (v8_enable_v8_checks == "") { v8_enable_v8_checks = v8_enable_debugging_features } if (v8_enable_heap_snapshot_verify == "") { v8_enable_heap_snapshot_verify = - v8_enable_debugging_features || dcheck_always_on + v8_enable_debugging_features || v8_dcheck_always_on } if (v8_enable_snapshot_code_comments) { assert(v8_code_comments == true || v8_code_comments == "", @@ -553,7 +561,7 @@ assert(!v8_enable_trace_ignition || v8_enable_trace_unoptimized, assert(!v8_enable_trace_baseline_exec || v8_enable_trace_unoptimized, "Baseline tracing requires unoptimized tracing to be enabled.") assert( - v8_enable_debugging_features == true || dcheck_always_on || + v8_enable_debugging_features == true || v8_dcheck_always_on || !v8_enable_slow_dchecks, "v8_enable_slow_dchecks requires v8_enable_debugging_features or dcheck_always_on.") @@ -619,7 +627,7 @@ if (v8_builtins_profiling_log_file == "default") { # * `v8_enable_webassembly` because it changes the set of opcodes which # affects graphs hashes. if (v8_enable_builtins_optimization && !v8_enable_builtins_profiling && - !is_debug && !dcheck_always_on && v8_enable_webassembly) { + !is_debug && !v8_dcheck_always_on && v8_enable_webassembly) { # This is about function arguments evaluation order on the machine building # mksnapshot, which makes node IDs not predictable for subgraphs like # Op1(Op2(), Op3()) and as a result different graph hashes. @@ -691,12 +699,6 @@ assert( !v8_enable_pointer_compression_shared_cage || v8_enable_pointer_compression, "Can't share a pointer compression cage if pointers aren't compressed") -assert( - !v8_enable_pointer_compression || - v8_enable_pointer_compression_shared_cage || - !v8_enable_external_code_space, - "Multi-cage pointer compression mode is not compatible with external code space") - assert( !v8_enable_pointer_compression_shared_cage || v8_current_cpu == "x64" || v8_current_cpu == "arm64" || v8_current_cpu == "riscv64" || @@ -807,6 +809,12 @@ config("libbase_config") { } } +config("zoslib_config") { + if (current_os == "zos") { + configs = [ "//third_party/zoslib:zoslib_config" ] + } +} + # Standalone cppgc cannot be built within chrome or with perfetto. assert(!cppgc_is_standalone || !build_with_chromium) assert(!cppgc_is_standalone || !v8_use_perfetto) @@ -863,10 +871,12 @@ config("external_startup_data") { # Make sure the |v8_generate_features_json| action is also updated when adding # or removing defines below. external_v8_defines = [ + "V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT=${v8_array_buffer_internal_field_count}", + "V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT=${v8_array_buffer_view_internal_field_count}", + "V8_PROMISE_INTERNAL_FIELD_COUNT=${v8_promise_internal_field_count}", "V8_ENABLE_CHECKS", "V8_COMPRESS_POINTERS", "V8_COMPRESS_POINTERS_IN_SHARED_CAGE", - "V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE", "V8_31BIT_SMIS_ON_64BIT_ARCH", "V8_COMPRESS_ZONES", "V8_ENABLE_SANDBOX", @@ -878,9 +888,21 @@ external_v8_defines = [ "V8_ENABLE_CONSERVATIVE_STACK_SCANNING", "V8_ENABLE_DIRECT_LOCAL", "V8_MINORMS_STRING_SHORTCUTTING", + "V8_HAVE_TARGET_OS", + "V8_TARGET_OS_ANDROID", + "V8_TARGET_OS_FUCHSIA", + "V8_TARGET_OS_IOS", + "V8_TARGET_OS_LINUX", + "V8_TARGET_OS_MACOS", + "V8_TARGET_OS_WIN", + "V8_TARGET_OS_CHROMEOS", ] -enabled_external_v8_defines = [] +enabled_external_v8_defines = [ + "V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT=${v8_array_buffer_internal_field_count}", + "V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT=${v8_array_buffer_view_internal_field_count}", + "V8_PROMISE_INTERNAL_FIELD_COUNT=${v8_promise_internal_field_count}", +] if (v8_enable_v8_checks) { enabled_external_v8_defines += [ "V8_ENABLE_CHECKS" ] @@ -889,8 +911,6 @@ if (v8_enable_pointer_compression) { enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS" ] if (v8_enable_pointer_compression_shared_cage) { enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS_IN_SHARED_CAGE" ] - } else { - enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE" ] } } if (v8_enable_pointer_compression || v8_enable_31bit_smis_on_64bit_arch) { @@ -926,6 +946,34 @@ if (v8_enable_direct_local) { if (v8_shortcut_strings_in_minor_ms) { enabled_external_v8_defines += [ "V8_MINORMS_STRING_SHORTCUTTING" ] } + +# V8_TARGET_OS_ defines. The target OS may differ from host OS e.g. in +# mksnapshot. We additionally set V8_HAVE_TARGET_OS to determine that a +# target OS has in fact been set; otherwise we internally assume that target +# OS == host OS (see v8config.h). +if (target_os == "android") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_ANDROID" ] +} else if (target_os == "fuchsia") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_FUCHSIA" ] +} else if (target_os == "ios") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_IOS" ] +} else if (target_os == "linux") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_LINUX" ] +} else if (target_os == "mac") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_MACOS" ] +} else if (target_os == "win") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_WIN" ] +} else if (target_os == "chromeos") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_CHROMEOS" ] +} + disabled_external_v8_defines = external_v8_defines - enabled_external_v8_defines # Put defines that are used in public headers here; public headers are @@ -1007,7 +1055,8 @@ config("features") { # Only targets in this file and its subdirs can depend on this. visibility = [ "./*" ] - defines = [] + defines = + [ "V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=${v8_typed_array_max_size_in_heap}" ] configs = [ ":v8_header_features", @@ -1022,6 +1071,11 @@ config("features") { defines += [ "CPPGC_ALLOW_ALLOCATIONS_IN_PREFINALIZERS" ] } + if (v8_enable_pointer_compression && + !v8_enable_pointer_compression_shared_cage) { + defines += [ "V8_COMPRESS_POINTERS_IN_MULTIPLE_CAGES" ] + } + if (v8_embedder_string != "") { defines += [ "V8_EMBEDDER_STRING=\"$v8_embedder_string\"" ] } @@ -1031,13 +1085,6 @@ config("features") { if (v8_log_builtins_block_count_input != "") { defines += [ "LOG_BUILTIN_BLOCK_COUNT" ] } - if (v8_promise_internal_field_count != 0) { - defines += - [ "V8_PROMISE_INTERNAL_FIELD_COUNT=${v8_promise_internal_field_count}" ] - } - defines += - [ "V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=${v8_typed_array_max_size_in_heap}" ] - if (v8_enable_future) { defines += [ "V8_ENABLE_FUTURE" ] } @@ -1253,6 +1300,12 @@ config("features") { if (v8_enable_local_off_stack_check) { defines += [ "V8_ENABLE_LOCAL_OFF_STACK_CHECK" ] } + if (v8_enable_sticky_mark_bits) { + defines += [ "V8_ENABLE_STICKY_MARK_BITS" ] + } + if (v8_enable_experimental_tsa_builtins) { + defines += [ "V8_ENABLE_EXPERIMENTAL_TSA_BUILTINS" ] + } } config("toolchain") { @@ -1351,7 +1404,7 @@ config("toolchain") { } if (host_byteorder == "little") { defines += [ "V8_TARGET_ARCH_S390_LE_SIM" ] - } else { + } else if (current_os != "zos") { cflags += [ "-march=z196" ] } } @@ -1385,20 +1438,10 @@ config("toolchain") { defines += [ "CAN_USE_RVV_INSTRUCTIONS" ] defines += [ "RVV_VLEN=${riscv_rvv_vlen}" ] } - if (riscv_use_zba || target_is_simulator) { - defines += [ "CAN_USE_ZBA_INSTRUCTIONS" ] - } - if (riscv_use_zbb || target_is_simulator) { - defines += [ "CAN_USE_ZBB_INSTRUCTIONS" ] - } - if (riscv_use_zbs || target_is_simulator) { - defines += [ "CAN_USE_ZBS_INSTRUCTIONS" ] - } } if (v8_current_cpu == "riscv64") { defines += [ "V8_TARGET_ARCH_RISCV64" ] defines += [ "__riscv_xlen=64" ] - defines += [ "CAN_USE_FPU_INSTRUCTIONS" ] if (!is_clang) { cflags += [ "-ffp-contract=off" ] } @@ -1407,7 +1450,6 @@ config("toolchain") { if (v8_current_cpu == "riscv32") { defines += [ "V8_TARGET_ARCH_RISCV32" ] defines += [ "__riscv_xlen=32" ] - defines += [ "CAN_USE_FPU_INSTRUCTIONS" ] } if (v8_current_cpu == "x86") { @@ -1430,37 +1472,10 @@ config("toolchain") { defines += [ "V8_ANDROID_LOG_STDOUT" ] } - # V8_TARGET_OS_ defines. The target OS may differ from host OS e.g. in - # mksnapshot. We additionally set V8_HAVE_TARGET_OS to determine that a - # target OS has in fact been set; otherwise we internally assume that target - # OS == host OS (see v8config.h). - if (target_os == "android") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_ANDROID" ] - } else if (target_os == "fuchsia") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_FUCHSIA" ] - } else if (target_os == "ios") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_IOS" ] - } else if (target_os == "linux") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_LINUX" ] - } else if (target_os == "mac") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_MACOS" ] - } else if (target_os == "win") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_WIN" ] - } else if (target_os == "chromeos") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_CHROMEOS" ] - } - # TODO(infra): Support v8_enable_prof on Windows. # TODO(infra): Add support for compiling with simulators. - if (v8_enable_debugging_features || dcheck_always_on) { + if (v8_enable_debugging_features || v8_dcheck_always_on) { defines += [ "DEBUG" ] if (v8_enable_slow_dchecks) { defines += [ "ENABLE_SLOW_DCHECKS" ] @@ -1807,6 +1822,7 @@ if (v8_postmortem_support) { "src/objects/abstract-code-inl.h", "src/objects/instruction-stream.h", "src/objects/instruction-stream-inl.h", + "src/objects/casting.h", "src/objects/code.h", "src/objects/code-inl.h", "src/objects/data-handler.h", @@ -1874,6 +1890,7 @@ if (v8_postmortem_support) { "src/objects/struct.h", "src/objects/struct-inl.h", "src/objects/tagged.h", + "src/objects/union.h", ] outputs = [ "$target_gen_dir/debug-support.cc" ] @@ -1960,6 +1977,7 @@ torque_files = [ "src/builtins/promise-reaction-job.tq", "src/builtins/promise-resolve.tq", "src/builtins/promise-then.tq", + "src/builtins/promise-try.tq", "src/builtins/promise-withresolvers.tq", "src/builtins/proxy-constructor.tq", "src/builtins/proxy-delete-property.tq", @@ -2061,6 +2079,7 @@ torque_files = [ "src/objects/js-atomics-synchronization.tq", "src/objects/js-collection-iterator.tq", "src/objects/js-collection.tq", + "src/objects/js-disposable-stack.tq", "src/objects/js-function.tq", "src/objects/js-generator.tq", "src/objects/js-iterator-helpers.tq", @@ -2268,6 +2287,12 @@ group("v8_abseil") { ] } +group("zoslib") { + if (current_os == "zos") { + deps = [ "//third_party/zoslib" ] + } +} + v8_header_set("torque_runtime_support") { visibility = [ ":*" ] @@ -2399,6 +2424,12 @@ template("run_mksnapshot") { data = [] + if (current_os != "zos") { + ext = "S" + } else { + ext = "s" + } + args = [ "./" + rebase_path(get_label_info(":mksnapshot($v8_snapshot_toolchain)", "root_out_dir") + "/mksnapshot", @@ -2414,7 +2445,7 @@ template("run_mksnapshot") { "--target_arch=$current_cpu", "--embedded_src", - rebase_path("$target_gen_dir/embedded${suffix}.S", root_build_dir), + rebase_path("$target_gen_dir/embedded${suffix}.${ext}", root_build_dir), ] if (v8_log_builtins_block_count_input != "") { @@ -2457,7 +2488,7 @@ template("run_mksnapshot") { args += invoker.args - outputs += [ "$target_gen_dir/embedded${suffix}.S" ] + outputs += [ "$target_gen_dir/embedded${suffix}.${ext}" ] if (invoker.embedded_variant != "") { args += [ "--embedded_variant", @@ -2636,7 +2667,7 @@ if (v8_verify_builtins_compatibility) { action("v8_dump_build_config") { script = "tools/testrunner/utils/dump_build_config.py" outputs = [ "$root_out_dir/v8_build_config.json" ] - is_DEBUG_defined = v8_enable_debugging_features || dcheck_always_on + is_DEBUG_defined = v8_enable_debugging_features || v8_dcheck_always_on is_full_debug = v8_enable_debugging_features && !v8_optimized_debug arch = v8_target_cpu @@ -2683,7 +2714,7 @@ action("v8_dump_build_config") { "concurrent_marking=$v8_enable_concurrent_marking", "conservative_stack_scanning=$v8_enable_conservative_stack_scanning", "current_cpu=\"$current_cpu\"", - "dcheck_always_on=$dcheck_always_on", + "dcheck_always_on=$v8_dcheck_always_on", "debug_code=$v8_enable_debug_code", "DEBUG_defined=$is_DEBUG_defined", "debugging_features=$v8_enable_debugging_features", @@ -2727,6 +2758,7 @@ action("v8_dump_build_config") { "verify_csa=$v8_enable_verify_csa", "verify_heap=$v8_enable_verify_heap", "verify_predictable=$v8_enable_verify_predictable", + "memory_corruption_api=$v8_enable_memory_corruption_api", ] } @@ -2803,7 +2835,11 @@ v8_source_set("v8_snapshot") { deps += [ ":asm_to_inline_asm_default" ] sources += [ "$target_gen_dir/embedded.cc" ] } else { - sources += [ "$target_gen_dir/embedded.S" ] + if (current_os != "zos") { + sources += [ "$target_gen_dir/embedded.S" ] + } else { + sources += [ "$target_gen_dir/embedded.s" ] + } } configs = [ ":internal_config" ] @@ -2883,6 +2919,7 @@ v8_source_set("v8_initializers") { "src/builtins/builtins-sharedarraybuffer-gen.cc", "src/builtins/builtins-string-gen.cc", "src/builtins/builtins-string-gen.h", + "src/builtins/builtins-string-tsa.cc", "src/builtins/builtins-temporal-gen.cc", "src/builtins/builtins-typed-array-gen.cc", "src/builtins/builtins-typed-array-gen.h", @@ -2896,6 +2933,8 @@ v8_source_set("v8_initializers") { "src/codegen/code-stub-assembler-inl.h", "src/codegen/code-stub-assembler.cc", "src/codegen/code-stub-assembler.h", + "src/codegen/heap-object-list.h", + "src/codegen/turboshaft-builtins-assembler-inl.h", "src/heap/setup-heap-internal.cc", "src/ic/accessor-assembler.cc", "src/ic/accessor-assembler.h", @@ -3082,6 +3121,7 @@ v8_header_set("v8_headers") { "include/v8-promise.h", "include/v8-proxy.h", "include/v8-regexp.h", + "include/v8-sandbox.h", "include/v8-script.h", "include/v8-snapshot.h", "include/v8-statistics.h", @@ -3188,7 +3228,6 @@ v8_header_set("v8_internal_headers") { sources = [ ### gcmole(all) ### "$target_gen_dir/builtins-generated/bytecodes-builtins-list.h", - "//base/trace_event/common/trace_event_common.h", "include/cppgc/common.h", "include/v8-inspector-protocol.h", "include/v8-inspector.h", @@ -3285,6 +3324,7 @@ v8_header_set("v8_internal_headers") { "src/common/operation.h", "src/common/ptr-compr-inl.h", "src/common/ptr-compr.h", + "src/common/simd128.h", "src/compiler-dispatcher/lazy-compile-dispatcher.h", "src/compiler-dispatcher/optimizing-compile-dispatcher.h", "src/compiler/access-builder.h", @@ -3327,13 +3367,11 @@ v8_header_set("v8_internal_headers") { "src/compiler/const-tracking-let-helpers.h", "src/compiler/constant-folding-reducer.h", "src/compiler/control-equivalence.h", - "src/compiler/control-flow-optimizer.h", "src/compiler/control-path-state.h", "src/compiler/csa-load-elimination.h", "src/compiler/dead-code-elimination.h", "src/compiler/decompression-optimizer.h", "src/compiler/diamond.h", - "src/compiler/effect-control-linearizer.h", "src/compiler/escape-analysis-reducer.h", "src/compiler/escape-analysis.h", "src/compiler/fast-api-calls.h", @@ -3411,12 +3449,14 @@ v8_header_set("v8_internal_headers") { "src/compiler/simplified-operator-reducer.h", "src/compiler/simplified-operator.h", "src/compiler/state-values-utils.h", - "src/compiler/store-store-elimination.h", "src/compiler/string-builder-optimizer.h", "src/compiler/turbofan.h", + "src/compiler/turboshaft/access-builder.h", "src/compiler/turboshaft/analyzer-iterator.h", "src/compiler/turboshaft/assembler.h", "src/compiler/turboshaft/assert-types-reducer.h", + "src/compiler/turboshaft/block-instrumentation-phase.h", + "src/compiler/turboshaft/block-instrumentation-reducer.h", "src/compiler/turboshaft/branch-elimination-reducer.h", "src/compiler/turboshaft/build-graph-phase.h", "src/compiler/turboshaft/builtin-call-descriptors.h", @@ -3439,6 +3479,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/graph-visualizer.h", "src/compiler/turboshaft/graph.h", "src/compiler/turboshaft/index.h", + "src/compiler/turboshaft/instruction-selection-normalization-reducer.h", "src/compiler/turboshaft/instruction-selection-phase.h", "src/compiler/turboshaft/js-generic-lowering-reducer.h", "src/compiler/turboshaft/late-escape-analysis-reducer.h", @@ -3461,10 +3502,12 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/opmasks.h", "src/compiler/turboshaft/optimize-phase.h", "src/compiler/turboshaft/phase.h", + "src/compiler/turboshaft/pipelines.h", "src/compiler/turboshaft/pretenuring-propagation-reducer.h", "src/compiler/turboshaft/recreate-schedule-phase.h", "src/compiler/turboshaft/recreate-schedule.h", "src/compiler/turboshaft/reducer-traits.h", + "src/compiler/turboshaft/register-allocation-phase.h", "src/compiler/turboshaft/representations.h", "src/compiler/turboshaft/required-optimization-reducer.h", "src/compiler/turboshaft/runtime-call-descriptors.h", @@ -3477,7 +3520,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/snapshot-table.h", "src/compiler/turboshaft/stack-check-lowering-reducer.h", "src/compiler/turboshaft/store-store-elimination-phase.h", - "src/compiler/turboshaft/store-store-elimination-reducer.h", + "src/compiler/turboshaft/store-store-elimination-reducer-inl.h", "src/compiler/turboshaft/structural-optimization-reducer.h", "src/compiler/turboshaft/tracing.h", "src/compiler/turboshaft/type-assertions-phase.h", @@ -3495,6 +3538,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/value-numbering-reducer.h", "src/compiler/turboshaft/variable-reducer.h", "src/compiler/turboshaft/wasm-dead-code-elimination-phase.h", + "src/compiler/turboshaft/zone-with-name.h", "src/compiler/type-cache.h", "src/compiler/type-narrowing-reducer.h", "src/compiler/typed-optimization.h", @@ -3607,8 +3651,6 @@ v8_header_set("v8_internal_headers") { "src/heap/cppgc-js/unified-heap-marking-state.h", "src/heap/cppgc-js/unified-heap-marking-verifier.h", "src/heap/cppgc-js/unified-heap-marking-visitor.h", - "src/heap/cppgc-js/wrappable-info-inl.h", - "src/heap/cppgc-js/wrappable-info.h", "src/heap/ephemeron-remembered-set.h", "src/heap/evacuation-allocator-inl.h", "src/heap/evacuation-allocator.h", @@ -3622,7 +3664,6 @@ v8_header_set("v8_internal_headers") { "src/heap/free-list-inl.h", "src/heap/free-list.h", "src/heap/gc-callbacks.h", - "src/heap/gc-idle-time-handler.h", "src/heap/gc-tracer-inl.h", "src/heap/gc-tracer.h", "src/heap/heap-allocator-inl.h", @@ -3637,7 +3678,8 @@ v8_header_set("v8_internal_headers") { "src/heap/incremental-marking-job.h", "src/heap/incremental-marking.h", "src/heap/index-generator.h", - "src/heap/large-page.h", + "src/heap/large-page-metadata-inl.h", + "src/heap/large-page-metadata.h", "src/heap/large-spaces.h", "src/heap/linear-allocation-area.h", "src/heap/list.h", @@ -3662,7 +3704,9 @@ v8_header_set("v8_internal_headers") { "src/heap/marking.h", "src/heap/memory-allocator.h", "src/heap/memory-balancer.h", + "src/heap/memory-chunk-inl.h", "src/heap/memory-chunk-layout.h", + "src/heap/memory-chunk-metadata-inl.h", "src/heap/memory-chunk-metadata.h", "src/heap/memory-chunk.h", "src/heap/memory-measurement-inl.h", @@ -3671,15 +3715,16 @@ v8_header_set("v8_internal_headers") { "src/heap/minor-gc-job.h", "src/heap/minor-mark-sweep-inl.h", "src/heap/minor-mark-sweep.h", - "src/heap/mutable-page-inl.h", - "src/heap/mutable-page.h", + "src/heap/mutable-page-metadata-inl.h", + "src/heap/mutable-page-metadata.h", "src/heap/new-spaces-inl.h", "src/heap/new-spaces.h", + "src/heap/object-lock-inl.h", "src/heap/object-lock.h", "src/heap/object-stats.h", "src/heap/objects-visiting-inl.h", "src/heap/objects-visiting.h", - "src/heap/page.h", + "src/heap/page-metadata.h", "src/heap/paged-spaces-inl.h", "src/heap/paged-spaces.h", "src/heap/parallel-work-item.h", @@ -3717,7 +3762,7 @@ v8_header_set("v8_internal_headers") { "src/init/bootstrapper.h", "src/init/heap-symbols.h", "src/init/icu_util.h", - "src/init/isolate-allocator.h", + "src/init/isolate-group.h", "src/init/setup-isolate.h", "src/init/startup-data-util.h", "src/init/v8.h", @@ -3727,7 +3772,7 @@ v8_header_set("v8_internal_headers") { "src/interpreter/bytecode-array-random-iterator.h", "src/interpreter/bytecode-array-writer.h", "src/interpreter/bytecode-decoder.h", - "src/interpreter/bytecode-flags.h", + "src/interpreter/bytecode-flags-and-tokens.h", "src/interpreter/bytecode-generator.h", "src/interpreter/bytecode-jump-table.h", "src/interpreter/bytecode-label.h", @@ -3778,6 +3823,7 @@ v8_header_set("v8_internal_headers") { "src/objects/bigint.h", "src/objects/call-site-info-inl.h", "src/objects/call-site-info.h", + "src/objects/casting.h", "src/objects/cell-inl.h", "src/objects/cell.h", "src/objects/code-inl.h", @@ -3841,6 +3887,8 @@ v8_header_set("v8_internal_headers") { "src/objects/js-collection-iterator-inl.h", "src/objects/js-collection-iterator.h", "src/objects/js-collection.h", + "src/objects/js-disposable-stack-inl.h", + "src/objects/js-disposable-stack.h", "src/objects/js-function-inl.h", "src/objects/js-function.h", "src/objects/js-generator-inl.h", @@ -3980,9 +4028,11 @@ v8_header_set("v8_internal_headers") { "src/objects/turboshaft-types-inl.h", "src/objects/turboshaft-types.h", "src/objects/type-hints.h", + "src/objects/union.h", "src/objects/value-serializer.h", "src/objects/visitors-inl.h", "src/objects/visitors.h", + "src/objects/waiter-queue-node.h", "src/parsing/expression-scope.h", "src/parsing/func-name-inferrer.h", "src/parsing/import-assertions.h", @@ -4051,25 +4101,40 @@ v8_header_set("v8_internal_headers") { "src/runtime/runtime.h", "src/sandbox/bounded-size-inl.h", "src/sandbox/bounded-size.h", + "src/sandbox/check.h", "src/sandbox/code-entrypoint-tag.h", "src/sandbox/code-pointer-inl.h", "src/sandbox/code-pointer-table-inl.h", "src/sandbox/code-pointer-table.h", "src/sandbox/code-pointer.h", + "src/sandbox/compactible-external-entity-table-inl.h", + "src/sandbox/compactible-external-entity-table.h", + "src/sandbox/cppheap-pointer-inl.h", + "src/sandbox/cppheap-pointer-table-inl.h", + "src/sandbox/cppheap-pointer-table.h", + "src/sandbox/external-buffer-inl.h", + "src/sandbox/external-buffer-table-inl.h", + "src/sandbox/external-buffer-table.h", + "src/sandbox/external-buffer-tag.h", + "src/sandbox/external-buffer.h", "src/sandbox/external-entity-table-inl.h", "src/sandbox/external-entity-table.h", "src/sandbox/external-pointer-inl.h", "src/sandbox/external-pointer-table-inl.h", "src/sandbox/external-pointer-table.h", "src/sandbox/external-pointer.h", + "src/sandbox/hardware-support.h", "src/sandbox/indirect-pointer-inl.h", "src/sandbox/indirect-pointer-tag.h", "src/sandbox/indirect-pointer.h", "src/sandbox/isolate-inl.h", "src/sandbox/isolate.h", + "src/sandbox/js-dispatch-table-inl.h", + "src/sandbox/js-dispatch-table.h", "src/sandbox/sandbox.h", "src/sandbox/sandboxed-pointer-inl.h", "src/sandbox/sandboxed-pointer.h", + "src/sandbox/tagged-payload.h", "src/sandbox/testing.h", "src/sandbox/trusted-pointer-table-inl.h", "src/sandbox/trusted-pointer-table.h", @@ -4101,6 +4166,7 @@ v8_header_set("v8_internal_headers") { "src/strings/char-predicates-inl.h", "src/strings/char-predicates.h", "src/strings/string-builder-inl.h", + "src/strings/string-builder.h", "src/strings/string-case.h", "src/strings/string-hasher-inl.h", "src/strings/string-hasher.h", @@ -4117,6 +4183,7 @@ v8_header_set("v8_internal_headers") { "src/third_party/siphash/halfsiphash.h", "src/third_party/utf8-decoder/utf8-decoder.h", "src/torque/runtime-macro-shims.h", + "src/tracing/trace-event-no-perfetto.h", "src/tracing/trace-event.h", "src/tracing/traced-value.h", "src/tracing/tracing-category-observer.h", @@ -4159,7 +4226,7 @@ v8_header_set("v8_internal_headers") { } if (v8_use_perfetto) { - sources -= [ "//base/trace_event/common/trace_event_common.h" ] + sources -= [ "src/tracing/trace-event-no-perfetto.h" ] sources += [ "src/tracing/code-data-source.h", "src/tracing/code-trace-context.h", @@ -4199,6 +4266,8 @@ v8_header_set("v8_internal_headers") { "src/maglev/maglev-ir.h", "src/maglev/maglev-phi-representation-selector.h", "src/maglev/maglev-pipeline-statistics.h", + "src/maglev/maglev-post-hoc-optimizations-processors.h", + "src/maglev/maglev-pre-regalloc-codegen-processors.h", "src/maglev/maglev-regalloc-data.h", "src/maglev/maglev-regalloc.h", "src/maglev/maglev-register-frame-array.h", @@ -4210,6 +4279,8 @@ v8_header_set("v8_internal_headers") { sources += [ "src/maglev/arm64/maglev-assembler-arm64-inl.h" ] } else if (v8_current_cpu == "x64") { sources += [ "src/maglev/x64/maglev-assembler-x64-inl.h" ] + } else if (v8_current_cpu == "s390x") { + sources += [ "src/maglev/s390/maglev-assembler-s390-inl.h" ] } } @@ -4256,6 +4327,7 @@ v8_header_set("v8_internal_headers") { "src/wasm/baseline/liftoff-assembler.h", "src/wasm/baseline/liftoff-compiler.h", "src/wasm/baseline/liftoff-register.h", + "src/wasm/baseline/liftoff-varstate.h", "src/wasm/baseline/parallel-move-inl.h", "src/wasm/baseline/parallel-move.h", "src/wasm/canonical-types.h", @@ -4265,6 +4337,7 @@ v8_header_set("v8_internal_headers") { "src/wasm/constant-expression-interface.h", "src/wasm/constant-expression.h", "src/wasm/decoder.h", + "src/wasm/float16.h", "src/wasm/function-body-decoder-impl.h", "src/wasm/function-body-decoder.h", "src/wasm/function-compiler.h", @@ -4283,6 +4356,7 @@ v8_header_set("v8_internal_headers") { "src/wasm/object-access.h", "src/wasm/pgo.h", "src/wasm/serialized-signature-inl.h", + "src/wasm/signature-hashing.h", "src/wasm/simd-shuffle.h", "src/wasm/stacks.h", "src/wasm/std-object-sizes.h", @@ -4296,6 +4370,7 @@ v8_header_set("v8_internal_headers") { "src/wasm/wasm-builtin-list.h", "src/wasm/wasm-code-manager.h", "src/wasm/wasm-debug.h", + "src/wasm/wasm-deopt-data.h", "src/wasm/wasm-disassembler-impl.h", "src/wasm/wasm-disassembler.h", "src/wasm/wasm-engine.h", @@ -4751,6 +4826,11 @@ v8_header_set("v8_internal_headers") { } } + frameworks = [] + if (is_ios) { + frameworks += [ "BrowserEngineKit.framework" ] + } + public_deps = [ ":torque_runtime_support", ":v8_flags", @@ -4805,11 +4885,9 @@ v8_compiler_sources = [ "src/compiler/const-tracking-let-helpers.cc", "src/compiler/constant-folding-reducer.cc", "src/compiler/control-equivalence.cc", - "src/compiler/control-flow-optimizer.cc", "src/compiler/csa-load-elimination.cc", "src/compiler/dead-code-elimination.cc", "src/compiler/decompression-optimizer.cc", - "src/compiler/effect-control-linearizer.cc", "src/compiler/escape-analysis-reducer.cc", "src/compiler/escape-analysis.cc", "src/compiler/fast-api-calls.cc", @@ -4876,7 +4954,6 @@ v8_compiler_sources = [ "src/compiler/simplified-operator-reducer.cc", "src/compiler/simplified-operator.cc", "src/compiler/state-values-utils.cc", - "src/compiler/store-store-elimination.cc", "src/compiler/string-builder-optimizer.cc", "src/compiler/turbofan-enabled.cc", "src/compiler/type-cache.cc", @@ -5082,6 +5159,8 @@ v8_source_set("v8_turboshaft") { sources = [ "src/compiler/turboshaft/analyzer-iterator.cc", "src/compiler/turboshaft/assembler.cc", + "src/compiler/turboshaft/block-instrumentation-phase.cc", + "src/compiler/turboshaft/block-instrumentation-reducer.cc", "src/compiler/turboshaft/build-graph-phase.cc", "src/compiler/turboshaft/code-elimination-and-simplification-phase.cc", "src/compiler/turboshaft/copying-phase.cc", @@ -5105,6 +5184,7 @@ v8_source_set("v8_turboshaft") { "src/compiler/turboshaft/operations.cc", "src/compiler/turboshaft/optimize-phase.cc", "src/compiler/turboshaft/phase.cc", + "src/compiler/turboshaft/pipelines.cc", "src/compiler/turboshaft/pretenuring-propagation-reducer.cc", "src/compiler/turboshaft/recreate-schedule-phase.cc", "src/compiler/turboshaft/recreate-schedule.cc", @@ -5131,6 +5211,7 @@ v8_source_set("v8_turboshaft") { "src/maglev/maglev-graph-printer.cc", "src/maglev/maglev-interpreter-frame-state.cc", "src/maglev/maglev-ir.cc", + "src/maglev/maglev-phi-representation-selector.cc", ] } @@ -5206,6 +5287,7 @@ v8_source_set("v8_base_without_compiler") { "src/builtins/builtins-api.cc", "src/builtins/builtins-array.cc", "src/builtins/builtins-arraybuffer.cc", + "src/builtins/builtins-async-disposable-stack.cc", "src/builtins/builtins-async-module.cc", "src/builtins/builtins-atomics-synchronization.cc", "src/builtins/builtins-bigint.cc", @@ -5214,6 +5296,7 @@ v8_source_set("v8_base_without_compiler") { "src/builtins/builtins-console.cc", "src/builtins/builtins-dataview.cc", "src/builtins/builtins-date.cc", + "src/builtins/builtins-disposable-stack.cc", "src/builtins/builtins-error.cc", "src/builtins/builtins-function.cc", "src/builtins/builtins-global.cc", @@ -5350,7 +5433,6 @@ v8_source_set("v8_base_without_compiler") { "src/heap/factory.cc", "src/heap/finalization-registry-cleanup-task.cc", "src/heap/free-list.cc", - "src/heap/gc-idle-time-handler.cc", "src/heap/gc-tracer.cc", "src/heap/heap-allocator.cc", "src/heap/heap-controller.cc", @@ -5361,7 +5443,7 @@ v8_source_set("v8_base_without_compiler") { "src/heap/incremental-marking-job.cc", "src/heap/incremental-marking.cc", "src/heap/index-generator.cc", - "src/heap/large-page.cc", + "src/heap/large-page-metadata.cc", "src/heap/large-spaces.cc", "src/heap/local-factory.cc", "src/heap/local-heap.cc", @@ -5380,11 +5462,11 @@ v8_source_set("v8_base_without_compiler") { "src/heap/memory-reducer.cc", "src/heap/minor-gc-job.cc", "src/heap/minor-mark-sweep.cc", - "src/heap/mutable-page.cc", + "src/heap/mutable-page-metadata.cc", "src/heap/new-spaces.cc", "src/heap/object-stats.cc", "src/heap/objects-visiting.cc", - "src/heap/page.cc", + "src/heap/page-metadata.cc", "src/heap/paged-spaces.cc", "src/heap/pretenuring-handler.cc", "src/heap/read-only-heap.cc", @@ -5407,7 +5489,7 @@ v8_source_set("v8_base_without_compiler") { "src/ic/stub-cache.cc", "src/init/bootstrapper.cc", "src/init/icu_util.cc", - "src/init/isolate-allocator.cc", + "src/init/isolate-group.cc", "src/init/startup-data-util.cc", "src/init/v8.cc", "src/interpreter/bytecode-array-builder.cc", @@ -5415,7 +5497,7 @@ v8_source_set("v8_base_without_compiler") { "src/interpreter/bytecode-array-random-iterator.cc", "src/interpreter/bytecode-array-writer.cc", "src/interpreter/bytecode-decoder.cc", - "src/interpreter/bytecode-flags.cc", + "src/interpreter/bytecode-flags-and-tokens.cc", "src/interpreter/bytecode-generator.cc", "src/interpreter/bytecode-label.cc", "src/interpreter/bytecode-node.cc", @@ -5467,6 +5549,7 @@ v8_source_set("v8_base_without_compiler") { "src/objects/js-collator.cc", "src/objects/js-date-time-format.cc", "src/objects/js-display-names.cc", + "src/objects/js-disposable-stack.cc", "src/objects/js-duration-format.cc", "src/objects/js-function.cc", "src/objects/js-list-format.cc", @@ -5515,6 +5598,7 @@ v8_source_set("v8_base_without_compiler") { "src/objects/type-hints.cc", "src/objects/value-serializer.cc", "src/objects/visitors.cc", + "src/objects/waiter-queue-node.cc", "src/parsing/func-name-inferrer.cc", "src/parsing/import-assertions.cc", "src/parsing/literal-buffer.cc", @@ -5594,7 +5678,11 @@ v8_source_set("v8_base_without_compiler") { "src/runtime/runtime-weak-refs.cc", "src/runtime/runtime.cc", "src/sandbox/code-pointer-table.cc", + "src/sandbox/cppheap-pointer-table.cc", + "src/sandbox/external-buffer-table.cc", "src/sandbox/external-pointer-table.cc", + "src/sandbox/hardware-support.cc", + "src/sandbox/js-dispatch-table.cc", "src/sandbox/sandbox.cc", "src/sandbox/testing.cc", "src/sandbox/trusted-pointer-table.cc", @@ -5693,6 +5781,11 @@ v8_source_set("v8_base_without_compiler") { "src/maglev/x64/maglev-assembler-x64.cc", "src/maglev/x64/maglev-ir-x64.cc", ] + } else if (v8_current_cpu == "s390x") { + sources += [ + "src/maglev/s390/maglev-assembler-s390.cc", + "src/maglev/s390/maglev-ir-s390.cc", + ] } } @@ -5744,6 +5837,7 @@ v8_source_set("v8_base_without_compiler") { "src/wasm/value-type.cc", "src/wasm/wasm-code-manager.cc", "src/wasm/wasm-debug.cc", + "src/wasm/wasm-deopt-data.cc", "src/wasm/wasm-disassembler.cc", "src/wasm/wasm-engine.cc", "src/wasm/wasm-external-refs.cc", @@ -6154,7 +6248,8 @@ v8_source_set("v8_base_without_compiler") { # to implement atomic memory access if (v8_current_cpu == "mips64" || v8_current_cpu == "mips64el" || v8_current_cpu == "ppc" || v8_current_cpu == "ppc64" || - v8_current_cpu == "s390" || v8_current_cpu == "s390x" || + (current_os != "zos" && + (v8_current_cpu == "s390" || v8_current_cpu == "s390x")) || v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { if (!is_clang) { libs += [ "atomic" ] @@ -6243,7 +6338,10 @@ v8_source_set("torque_base") { ":v8_shared_internal_headers", ] - public_deps = [ ":v8_libbase" ] + public_deps = [ + ":v8_config_headers", + ":v8_libbase", + ] # The use of exceptions for Torque in violation of the Chromium style-guide # is justified by the fact that it is only used from the non-essential @@ -6406,6 +6504,10 @@ v8_component("v8_libbase") { "src/base/strings.h", "src/base/sys-info.cc", "src/base/sys-info.h", + "src/base/template-meta-programming/algorithm.h", + "src/base/template-meta-programming/functional.h", + "src/base/template-meta-programming/list.h", + "src/base/template-meta-programming/string-literal.h", "src/base/template-utils.h", "src/base/threaded-list.h", "src/base/timezone-cache.h", @@ -6427,6 +6529,11 @@ v8_component("v8_libbase") { deps = [ ":v8_config_headers" ] + if (current_os == "zos") { + public_configs += [ ":zoslib_config" ] + deps += [ ":zoslib" ] + } + libs = [] data = [] @@ -6444,7 +6551,7 @@ v8_component("v8_libbase") { "src/base/platform/platform-posix.cc", "src/base/platform/platform-posix.h", ] - if (current_os != "aix") { + if (current_os != "aix" && current_os != "zos") { sources += [ "src/base/platform/platform-posix-time.cc", "src/base/platform/platform-posix-time.h", @@ -6512,7 +6619,6 @@ v8_component("v8_libbase") { sources += [ "src/base/debug/stack_trace_posix.cc", "src/base/platform/platform-darwin.cc", - "src/base/platform/platform-ios.cc", ] } else if (is_win) { # TODO(infra): Add support for cygwin. @@ -6536,6 +6642,11 @@ v8_component("v8_libbase") { } data_deps += [ "//build/win:runtime_libs" ] + } else if (current_os == "zos") { + sources += [ + "src/base/debug/stack_trace_zos.cc", + "src/base/platform/platform-zos.cc", + ] } if (v8_current_cpu == "mips64") { @@ -6597,7 +6708,6 @@ if (v8_use_libm_trig_functions) { v8_component("v8_libplatform") { sources = [ - "//base/trace_event/common/trace_event_common.h", "include/libplatform/libplatform-export.h", "include/libplatform/libplatform.h", "include/libplatform/v8-tracing.h", @@ -6624,6 +6734,7 @@ v8_component("v8_libplatform") { "src/libplatform/tracing/tracing-controller.cc", "src/libplatform/worker-thread.cc", "src/libplatform/worker-thread.h", + "src/tracing/trace-event-no-perfetto.h", ] configs = [ ":internal_config_base" ] @@ -6644,12 +6755,12 @@ v8_component("v8_libplatform") { if (v8_use_perfetto) { sources -= [ - "//base/trace_event/common/trace_event_common.h", "src/libplatform/tracing/trace-buffer.cc", "src/libplatform/tracing/trace-buffer.h", "src/libplatform/tracing/trace-object.cc", "src/libplatform/tracing/trace-writer.cc", "src/libplatform/tracing/trace-writer.h", + "src/tracing/trace-event-no-perfetto.h", ] sources += [ "src/libplatform/tracing/trace-event-listener.h" ] } @@ -6724,6 +6835,7 @@ v8_header_set("v8_heap_base_headers") { "src/heap/base/active-system-pages.h", "src/heap/base/basic-slot-set.h", "src/heap/base/bytes.h", + "src/heap/base/cached-unordered-map.h", "src/heap/base/incremental-marking-schedule.h", "src/heap/base/memory-tagging.h", "src/heap/base/stack.h", @@ -6746,7 +6858,12 @@ v8_source_set("v8_heap_base") { if (is_clang || !is_win) { if (current_cpu == "x64") { - sources += [ "src/heap/base/asm/x64/push_registers_asm.cc" ] + if (is_win) { + # Prefer a masm version with unwind directives. + sources += [ "src/heap/base/asm/x64/push_registers_masm.asm" ] + } else { + sources += [ "src/heap/base/asm/x64/push_registers_asm.cc" ] + } } else if (current_cpu == "x86") { sources += [ "src/heap/base/asm/ia32/push_registers_asm.cc" ] } else if (current_cpu == "arm") { @@ -6755,6 +6872,8 @@ v8_source_set("v8_heap_base") { sources += [ "src/heap/base/asm/arm64/push_registers_asm.cc" ] } else if (current_cpu == "ppc64") { sources += [ "src/heap/base/asm/ppc/push_registers_asm.cc" ] + } else if (current_os == "zos") { + sources += [ "src/heap/base/asm/zos/push_registers_asm.cc" ] } else if (current_cpu == "s390x") { sources += [ "src/heap/base/asm/s390/push_registers_asm.cc" ] } else if (current_cpu == "mips64el") { @@ -6848,6 +6967,10 @@ v8_header_set("cppgc_headers") { ":v8_libplatform", ] + if (current_os == "zos" && is_component_build) { + deps += [ ":zoslib" ] + } + public_deps = [ ":v8_config_headers" ] } @@ -6972,7 +7095,7 @@ v8_source_set("cppgc_base") { ] if (cppgc_is_standalone && !v8_use_perfetto) { - sources += [ "//base/trace_event/common/trace_event_common.h" ] + sources += [ "src/tracing/trace-event-no-perfetto.h" ] } else { public_deps += [ ":v8_tracing" ] } @@ -7112,6 +7235,8 @@ if (current_toolchain == v8_snapshot_toolchain) { "src/snapshot/embedded/platform-embedded-file-writer-mac.h", "src/snapshot/embedded/platform-embedded-file-writer-win.cc", "src/snapshot/embedded/platform-embedded-file-writer-win.h", + "src/snapshot/embedded/platform-embedded-file-writer-zos.cc", + "src/snapshot/embedded/platform-embedded-file-writer-zos.h", "src/snapshot/mksnapshot.cc", "src/snapshot/snapshot-empty.cc", "src/snapshot/static-roots-gen.cc", @@ -7122,7 +7247,10 @@ if (current_toolchain == v8_snapshot_toolchain) { sources += [ "src/deoptimizer/deoptimizer-cfi-empty.cc" ] } - configs = [ ":internal_config" ] + configs = [ + ":internal_config", + ":disable_icf", + ] deps = [ ":v8_base_without_compiler", @@ -7137,6 +7265,23 @@ if (current_toolchain == v8_snapshot_toolchain) { "//build/win:default_exe_manifest", ] } + + # This config disables a link time optimization "ICF", which may merge + # different functions into one if the function signature and body of them are + # identical. + # + # ICF breaks 1:1 mappings of the external references for V8 snapshot, so we + # disable it while taking a V8 snapshot. + config("disable_icf") { + visibility = [ ":*" ] # Only targets in this file can depend on this. + if (is_win) { + ldflags = [ "/OPT:NOICF" ] # link.exe, but also lld-link.exe. + } else if (is_apple && !use_lld) { + ldflags = [ "-Wl,-no_deduplicate" ] # ld64. + } else if (use_lld) { + ldflags = [ "-Wl,--icf=none" ] + } + } } if (current_toolchain == v8_snapshot_toolchain) { @@ -7350,14 +7495,21 @@ group("v8_fuzzers") { ] if (v8_enable_webassembly) { + if (!is_official_build) { + data_deps += [ + ":v8_simple_wasm_compile_all_fuzzer", + ":v8_simple_wasm_compile_fuzzer", + ":v8_simple_wasm_compile_simd_fuzzer", + ":v8_simple_wasm_compile_wasmgc_fuzzer", + ":v8_simple_wasm_deopt_fuzzer", + ":v8_simple_wasm_init_expr_fuzzer", + ] + } data_deps += [ ":v8_simple_multi_return_fuzzer", ":v8_simple_wasm_async_fuzzer", ":v8_simple_wasm_code_fuzzer", - ":v8_simple_wasm_compile_fuzzer", - ":v8_simple_wasm_compile_simd_fuzzer", ":v8_simple_wasm_fuzzer", - ":v8_simple_wasm_init_expr_fuzzer", ":v8_simple_wasm_streaming_fuzzer", ] } @@ -7532,6 +7684,9 @@ v8_executable("d8") { if (v8_enable_vtunejit) { deps += [ "src/third_party/vtune:v8_vtune" ] } + if (current_os == "zos" && is_component_build) { + deps += [ ":zoslib" ] + } } v8_executable("v8_hello_world") { @@ -7575,6 +7730,9 @@ v8_executable("v8_sample_process") { ":v8_libplatform", "//build/win:default_exe_manifest", ] + if (current_os == "zos" && is_component_build) { + deps += [ ":zoslib" ] + } } if (want_v8_shell) { @@ -7594,6 +7752,9 @@ if (want_v8_shell) { ":v8_libplatform", "//build/win:default_exe_manifest", ] + if (current_os == "zos" && is_component_build) { + deps += [ ":zoslib" ] + } } } @@ -7624,11 +7785,25 @@ v8_executable("cppgc_hello_world") { } template("v8_fuzzer") { - name = target_name - forward_variables_from(invoker, "*") - v8_executable("v8_simple_" + name) { + fuzzer_name = target_name + + v8_source_set(fuzzer_name) { + sources = invoker.sources + + deps = [ ":fuzzer_support" ] + if (defined(invoker.deps)) { + deps += invoker.deps + } + + configs = [ + ":external_config", + ":internal_config_base", + ] + } + + v8_executable("v8_simple_${fuzzer_name}") { deps = [ - ":" + name, + ":${fuzzer_name}", "//build/win:default_exe_manifest", ] @@ -7638,61 +7813,21 @@ template("v8_fuzzer") { } } -v8_source_set("json_fuzzer") { - sources = [ "test/fuzzer/json.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] -} - v8_fuzzer("json_fuzzer") { -} - -v8_source_set("parser_fuzzer") { - sources = [ "test/fuzzer/parser.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] + sources = [ "test/fuzzer/json.cc" ] } v8_fuzzer("parser_fuzzer") { -} - -v8_source_set("regexp_fuzzer") { - sources = [ "test/fuzzer/regexp.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] + sources = [ "test/fuzzer/parser.cc" ] } v8_fuzzer("regexp_fuzzer") { + sources = [ "test/fuzzer/regexp.cc" ] } if (v8_enable_webassembly) { - v8_source_set("multi_return_fuzzer") { - sources = [ "test/fuzzer/multi-return.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - v8_fuzzer("multi_return_fuzzer") { + sources = [ "test/fuzzer/multi-return.cc" ] } v8_source_set("wasm_test_common") { @@ -7723,67 +7858,11 @@ if (v8_enable_webassembly) { ] } - v8_source_set("wasm_fuzzer") { - sources = [ "test/fuzzer/wasm.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_fuzzer") { - } - - v8_source_set("wasm_async_fuzzer") { - sources = [ "test/fuzzer/wasm-async.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_async_fuzzer") { - } - - v8_source_set("wasm_code_fuzzer") { - sources = [ - "test/common/wasm/test-signatures.h", - "test/fuzzer/wasm-code.cc", - ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_code_fuzzer") { - } - - v8_source_set("lib_wasm_fuzzer_common") { + v8_source_set("wasm_fuzzer_common") { sources = [ "test/fuzzer/wasm-fuzzer-common.cc", "test/fuzzer/wasm-fuzzer-common.h", + "tools/wasm/mjsunit-module-disassembler-impl.h", ] deps = [ @@ -7806,100 +7885,81 @@ if (v8_enable_webassembly) { ] } - v8_source_set("wasm_compile_fuzzer") { - sources = [ - "test/common/wasm/test-signatures.h", - "test/fuzzer/wasm-compile.cc", - ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] + template("v8_wasm_fuzzer") { + forward_variables_from(invoker, "*") + v8_fuzzer(target_name) { + deps = [ + ":wasm_fuzzer_common", + ":wasm_test_common", + ] + } + } - configs = [ - ":external_config", - ":internal_config_base", - ] + v8_wasm_fuzzer("wasm_fuzzer") { + sources = [ "test/fuzzer/wasm.cc" ] } - v8_fuzzer("wasm_compile_fuzzer") { + v8_wasm_fuzzer("wasm_async_fuzzer") { + sources = [ "test/fuzzer/wasm-async.cc" ] } - v8_source_set("wasm_compile_simd_fuzzer") { + v8_wasm_fuzzer("wasm_code_fuzzer") { sources = [ "test/common/wasm/test-signatures.h", - "test/fuzzer/wasm-compile-simd.cc", - ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", + "test/fuzzer/wasm-code.cc", ] } - v8_fuzzer("wasm_compile_simd_fuzzer") { - } - - v8_source_set("wasm_streaming_fuzzer") { + v8_wasm_fuzzer("wasm_streaming_fuzzer") { sources = [ "test/fuzzer/wasm-streaming.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_streaming_fuzzer") { } - v8_source_set("wasm_init_expr_fuzzer") { - sources = [ "test/fuzzer/wasm-init-expr.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] + # Some fuzzers depend on fuzzing functionality linked into the v8 library. + # For binary size reasons this functionality is not available for official + # builds, therefore these fuzzers do not function there and should be skipped + # instead. + if (!is_official_build) { + v8_wasm_fuzzer("wasm_compile_all_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-compile-all.cc", + ] + } - configs = [ - ":external_config", - ":internal_config_base", - ] - } + v8_wasm_fuzzer("wasm_compile_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-compile.cc", + ] + } - v8_fuzzer("wasm_init_expr_fuzzer") { - } -} + v8_wasm_fuzzer("wasm_compile_simd_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-compile-simd.cc", + ] + } -v8_source_set("inspector_fuzzer") { - sources = [ "test/fuzzer/inspector-fuzzer.cc" ] + v8_wasm_fuzzer("wasm_compile_wasmgc_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-compile-wasmgc.cc", + ] + } - deps = [ - ":fuzzer_support", - "test/inspector:inspector_test", - ] + v8_wasm_fuzzer("wasm_init_expr_fuzzer") { + sources = [ "test/fuzzer/wasm-init-expr.cc" ] + } - configs = [ - ":external_config", - ":internal_config_base", - ] + v8_wasm_fuzzer("wasm_deopt_fuzzer") { + sources = [ "test/fuzzer/wasm-deopt.cc" ] + } + } # !is_official_build } v8_fuzzer("inspector_fuzzer") { + sources = [ "test/fuzzer/inspector-fuzzer.cc" ] + deps = [ "test/inspector:inspector_test" ] } # Target to build all generated .cc files. @@ -7916,334 +7976,6 @@ group("v8_generated_cc_files") { # Protobuf targets, used only when building outside of chromium. if (!build_with_chromium && v8_use_perfetto) { - # This config is applied to the autogenerated .pb.{cc,h} files in - # proto_library.gni. This config is propagated up to the source sets - # that depend on generated proto headers. - config("protobuf_gen_config") { - defines = [ - "GOOGLE_PROTOBUF_NO_RTTI", - "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER", - ] - cflags = [ - "-Wno-unknown-warning-option", - "-Wno-deprecated", - "-Wno-undef", - "-Wno-zero-as-null-pointer-constant", - "-Wno-thread-safety-attributes", - ] - include_dirs = [ "third_party/protobuf/src" ] - } - - # Configuration used to build libprotobuf_* and the protoc compiler. - config("protobuf_config") { - # Apply the lighter supressions and macro definitions from above. - configs = [ ":protobuf_gen_config" ] - - if (!is_win) { - defines = [ "HAVE_PTHREAD=1" ] - } - if (is_clang) { - cflags = [ - "-Wno-unused-private-field", - "-Wno-unused-function", - "-Wno-inconsistent-missing-override", - "-Wno-unknown-warning-option", - "-Wno-enum-compare-switch", - "-Wno-user-defined-warnings", - "-Wno-tautological-constant-compare", - ] - } - if (is_win && is_clang) { - cflags += [ "-Wno-microsoft-unqualified-friend" ] - } - } - - source_set("protobuf_lite") { - sources = [ - "third_party/protobuf/src/google/protobuf/any_lite.cc", - "third_party/protobuf/src/google/protobuf/arena.cc", - "third_party/protobuf/src/google/protobuf/arena.h", - "third_party/protobuf/src/google/protobuf/arena_impl.h", - "third_party/protobuf/src/google/protobuf/arenastring.h", - "third_party/protobuf/src/google/protobuf/extension_set.cc", - "third_party/protobuf/src/google/protobuf/extension_set.h", - "third_party/protobuf/src/google/protobuf/generated_enum_util.cc", - "third_party/protobuf/src/google/protobuf/generated_enum_util.h", - "third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.cc", - "third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.h", - "third_party/protobuf/src/google/protobuf/generated_message_util.cc", - "third_party/protobuf/src/google/protobuf/generated_message_util.h", - "third_party/protobuf/src/google/protobuf/has_bits.h", - "third_party/protobuf/src/google/protobuf/implicit_weak_message.cc", - "third_party/protobuf/src/google/protobuf/implicit_weak_message.h", - "third_party/protobuf/src/google/protobuf/inlined_string_field.h", - "third_party/protobuf/src/google/protobuf/io/coded_stream.cc", - "third_party/protobuf/src/google/protobuf/io/coded_stream.h", - "third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h", - "third_party/protobuf/src/google/protobuf/io/io_win32.cc", - "third_party/protobuf/src/google/protobuf/io/io_win32.h", - "third_party/protobuf/src/google/protobuf/io/strtod.cc", - "third_party/protobuf/src/google/protobuf/io/strtod.h", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.cc", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h", - "third_party/protobuf/src/google/protobuf/map.h", - "third_party/protobuf/src/google/protobuf/map_entry_lite.h", - "third_party/protobuf/src/google/protobuf/map_field_lite.h", - "third_party/protobuf/src/google/protobuf/map_type_handler.h", - "third_party/protobuf/src/google/protobuf/message_lite.cc", - "third_party/protobuf/src/google/protobuf/message_lite.h", - "third_party/protobuf/src/google/protobuf/repeated_field.cc", - "third_party/protobuf/src/google/protobuf/repeated_field.h", - "third_party/protobuf/src/google/protobuf/stubs/bytestream.cc", - "third_party/protobuf/src/google/protobuf/stubs/bytestream.h", - "third_party/protobuf/src/google/protobuf/stubs/callback.h", - "third_party/protobuf/src/google/protobuf/stubs/casts.h", - "third_party/protobuf/src/google/protobuf/stubs/common.cc", - "third_party/protobuf/src/google/protobuf/stubs/common.h", - "third_party/protobuf/src/google/protobuf/stubs/fastmem.h", - "third_party/protobuf/src/google/protobuf/stubs/hash.h", - "third_party/protobuf/src/google/protobuf/stubs/int128.cc", - "third_party/protobuf/src/google/protobuf/stubs/int128.h", - "third_party/protobuf/src/google/protobuf/stubs/logging.h", - "third_party/protobuf/src/google/protobuf/stubs/macros.h", - "third_party/protobuf/src/google/protobuf/stubs/map_util.h", - "third_party/protobuf/src/google/protobuf/stubs/mutex.h", - "third_party/protobuf/src/google/protobuf/stubs/once.h", - "third_party/protobuf/src/google/protobuf/stubs/platform_macros.h", - "third_party/protobuf/src/google/protobuf/stubs/port.h", - "third_party/protobuf/src/google/protobuf/stubs/status.cc", - "third_party/protobuf/src/google/protobuf/stubs/status.h", - "third_party/protobuf/src/google/protobuf/stubs/status_macros.h", - "third_party/protobuf/src/google/protobuf/stubs/statusor.cc", - "third_party/protobuf/src/google/protobuf/stubs/statusor.h", - "third_party/protobuf/src/google/protobuf/stubs/stl_util.h", - "third_party/protobuf/src/google/protobuf/stubs/stringpiece.cc", - "third_party/protobuf/src/google/protobuf/stubs/stringpiece.h", - "third_party/protobuf/src/google/protobuf/stubs/stringprintf.cc", - "third_party/protobuf/src/google/protobuf/stubs/stringprintf.h", - "third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc", - "third_party/protobuf/src/google/protobuf/stubs/strutil.cc", - "third_party/protobuf/src/google/protobuf/stubs/strutil.h", - "third_party/protobuf/src/google/protobuf/stubs/template_util.h", - "third_party/protobuf/src/google/protobuf/stubs/time.cc", - "third_party/protobuf/src/google/protobuf/stubs/time.h", - "third_party/protobuf/src/google/protobuf/wire_format_lite.cc", - "third_party/protobuf/src/google/protobuf/wire_format_lite.h", - ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - ":protobuf_config", - ] - if (is_win) { - configs -= [ "//build/config/win:lean_and_mean" ] - } - public_configs = [ ":protobuf_gen_config" ] - } - - # This target should be used only by the protoc compiler and by test targets. - source_set("protobuf_full") { - deps = [ ":protobuf_lite" ] - sources = [ - "third_party/protobuf/src/google/protobuf/any.cc", - "third_party/protobuf/src/google/protobuf/any.h", - "third_party/protobuf/src/google/protobuf/any.pb.cc", - "third_party/protobuf/src/google/protobuf/any.pb.h", - "third_party/protobuf/src/google/protobuf/api.pb.cc", - "third_party/protobuf/src/google/protobuf/api.pb.h", - "third_party/protobuf/src/google/protobuf/compiler/importer.cc", - "third_party/protobuf/src/google/protobuf/compiler/importer.h", - "third_party/protobuf/src/google/protobuf/compiler/parser.cc", - "third_party/protobuf/src/google/protobuf/compiler/parser.h", - "third_party/protobuf/src/google/protobuf/descriptor.cc", - "third_party/protobuf/src/google/protobuf/descriptor.h", - "third_party/protobuf/src/google/protobuf/descriptor.pb.cc", - "third_party/protobuf/src/google/protobuf/descriptor.pb.h", - "third_party/protobuf/src/google/protobuf/descriptor_database.cc", - "third_party/protobuf/src/google/protobuf/descriptor_database.h", - "third_party/protobuf/src/google/protobuf/duration.pb.cc", - "third_party/protobuf/src/google/protobuf/duration.pb.h", - "third_party/protobuf/src/google/protobuf/dynamic_message.cc", - "third_party/protobuf/src/google/protobuf/dynamic_message.h", - "third_party/protobuf/src/google/protobuf/empty.pb.cc", - "third_party/protobuf/src/google/protobuf/empty.pb.h", - "third_party/protobuf/src/google/protobuf/extension_set_heavy.cc", - "third_party/protobuf/src/google/protobuf/field_mask.pb.cc", - "third_party/protobuf/src/google/protobuf/field_mask.pb.h", - "third_party/protobuf/src/google/protobuf/generated_enum_reflection.h", - "third_party/protobuf/src/google/protobuf/generated_message_reflection.cc", - "third_party/protobuf/src/google/protobuf/generated_message_reflection.h", - "third_party/protobuf/src/google/protobuf/io/gzip_stream.cc", - "third_party/protobuf/src/google/protobuf/io/gzip_stream.h", - "third_party/protobuf/src/google/protobuf/io/printer.cc", - "third_party/protobuf/src/google/protobuf/io/printer.h", - "third_party/protobuf/src/google/protobuf/io/tokenizer.cc", - "third_party/protobuf/src/google/protobuf/io/tokenizer.h", - "third_party/protobuf/src/google/protobuf/map_entry.h", - "third_party/protobuf/src/google/protobuf/map_field.cc", - "third_party/protobuf/src/google/protobuf/map_field.h", - "third_party/protobuf/src/google/protobuf/map_field_inl.h", - "third_party/protobuf/src/google/protobuf/message.cc", - "third_party/protobuf/src/google/protobuf/message.h", - "third_party/protobuf/src/google/protobuf/metadata.h", - "third_party/protobuf/src/google/protobuf/reflection.h", - "third_party/protobuf/src/google/protobuf/reflection_internal.h", - "third_party/protobuf/src/google/protobuf/reflection_ops.cc", - "third_party/protobuf/src/google/protobuf/reflection_ops.h", - "third_party/protobuf/src/google/protobuf/service.cc", - "third_party/protobuf/src/google/protobuf/service.h", - "third_party/protobuf/src/google/protobuf/source_context.pb.cc", - "third_party/protobuf/src/google/protobuf/source_context.pb.h", - "third_party/protobuf/src/google/protobuf/struct.pb.cc", - "third_party/protobuf/src/google/protobuf/struct.pb.h", - "third_party/protobuf/src/google/protobuf/stubs/mathlimits.cc", - "third_party/protobuf/src/google/protobuf/stubs/mathlimits.h", - "third_party/protobuf/src/google/protobuf/stubs/mathutil.h", - "third_party/protobuf/src/google/protobuf/stubs/substitute.cc", - "third_party/protobuf/src/google/protobuf/stubs/substitute.h", - "third_party/protobuf/src/google/protobuf/text_format.cc", - "third_party/protobuf/src/google/protobuf/text_format.h", - "third_party/protobuf/src/google/protobuf/timestamp.pb.cc", - "third_party/protobuf/src/google/protobuf/timestamp.pb.h", - "third_party/protobuf/src/google/protobuf/type.pb.cc", - "third_party/protobuf/src/google/protobuf/type.pb.h", - "third_party/protobuf/src/google/protobuf/unknown_field_set.cc", - "third_party/protobuf/src/google/protobuf/unknown_field_set.h", - "third_party/protobuf/src/google/protobuf/util/field_comparator.cc", - "third_party/protobuf/src/google/protobuf/util/field_comparator.h", - "third_party/protobuf/src/google/protobuf/util/field_mask_util.cc", - "third_party/protobuf/src/google/protobuf/util/field_mask_util.h", - "third_party/protobuf/src/google/protobuf/util/internal/constants.h", - "third_party/protobuf/src/google/protobuf/util/internal/datapiece.cc", - "third_party/protobuf/src/google/protobuf/util/internal/datapiece.h", - "third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc", - "third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/error_listener.cc", - "third_party/protobuf/src/google/protobuf/util/internal/error_listener.h", - "third_party/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc", - "third_party/protobuf/src/google/protobuf/util/internal/field_mask_utility.h", - "third_party/protobuf/src/google/protobuf/util/internal/json_escaping.cc", - "third_party/protobuf/src/google/protobuf/util/internal/json_escaping.h", - "third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc", - "third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc", - "third_party/protobuf/src/google/protobuf/util/internal/json_stream_parser.h", - "third_party/protobuf/src/google/protobuf/util/internal/location_tracker.h", - "third_party/protobuf/src/google/protobuf/util/internal/object_location_tracker.h", - "third_party/protobuf/src/google/protobuf/util/internal/object_source.h", - "third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc", - "third_party/protobuf/src/google/protobuf/util/internal/object_writer.h", - "third_party/protobuf/src/google/protobuf/util/internal/proto_writer.cc", - "third_party/protobuf/src/google/protobuf/util/internal/proto_writer.h", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/type_info.cc", - "third_party/protobuf/src/google/protobuf/util/internal/type_info.h", - "third_party/protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc", - "third_party/protobuf/src/google/protobuf/util/internal/type_info_test_helper.h", - "third_party/protobuf/src/google/protobuf/util/internal/utility.cc", - "third_party/protobuf/src/google/protobuf/util/internal/utility.h", - "third_party/protobuf/src/google/protobuf/util/json_util.cc", - "third_party/protobuf/src/google/protobuf/util/json_util.h", - "third_party/protobuf/src/google/protobuf/util/message_differencer.cc", - "third_party/protobuf/src/google/protobuf/util/message_differencer.h", - "third_party/protobuf/src/google/protobuf/util/time_util.cc", - "third_party/protobuf/src/google/protobuf/util/time_util.h", - "third_party/protobuf/src/google/protobuf/util/type_resolver.h", - "third_party/protobuf/src/google/protobuf/util/type_resolver_util.cc", - "third_party/protobuf/src/google/protobuf/util/type_resolver_util.h", - "third_party/protobuf/src/google/protobuf/wire_format.cc", - "third_party/protobuf/src/google/protobuf/wire_format.h", - "third_party/protobuf/src/google/protobuf/wrappers.pb.cc", - "third_party/protobuf/src/google/protobuf/wrappers.pb.h", - ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - ":protobuf_config", - ] - if (is_win) { - configs -= [ "//build/config/win:lean_and_mean" ] - } - public_configs = [ ":protobuf_gen_config" ] - } - - if (current_toolchain == host_toolchain) { - source_set("protoc_lib") { - deps = [ ":protobuf_full" ] - sources = [ - "third_party/protobuf/src/google/protobuf/compiler/code_generator.cc", - "third_party/protobuf/src/google/protobuf/compiler/code_generator.h", - "third_party/protobuf/src/google/protobuf/compiler/command_line_interface.cc", - "third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h", - "third_party/protobuf/src/google/protobuf/compiler/plugin.cc", - "third_party/protobuf/src/google/protobuf/compiler/plugin.h", - "third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc", - "third_party/protobuf/src/google/protobuf/compiler/plugin.pb.h", - "third_party/protobuf/src/google/protobuf/compiler/subprocess.cc", - "third_party/protobuf/src/google/protobuf/compiler/subprocess.h", - "third_party/protobuf/src/google/protobuf/compiler/zip_writer.cc", - "third_party/protobuf/src/google/protobuf/compiler/zip_writer.h", - ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - ":protobuf_config", - ] - if (is_win) { - configs -= [ "//build/config/win:lean_and_mean" ] - } - public_configs = [ ":protobuf_gen_config" ] - } - - executable("protoc") { - deps = [ - ":protoc_lib", - "//build/win:default_exe_manifest", - ] - sources = [ "src/protobuf/protobuf-compiler-main.cc" ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - } # host_toolchain - v8_component("v8_libperfetto") { configs = [ ":v8_tracing_config" ] public_configs = [ "//third_party/perfetto/gn:public_config" ] diff --git a/deps/v8/COMMON_OWNERS b/deps/v8/COMMON_OWNERS index 9e9d51d5835a1d..5d4e99dec543bd 100644 --- a/deps/v8/COMMON_OWNERS +++ b/deps/v8/COMMON_OWNERS @@ -1,5 +1,6 @@ adamk@chromium.org ahaas@chromium.org +alexschulze@chromium.org bikineev@chromium.org bmeurer@chromium.org cbruni@chromium.org @@ -9,6 +10,7 @@ dinfuehr@chromium.org dlehmann@chromium.org dmercadier@chromium.org ecmziegler@chromium.org +evih@chromium.org gdeepti@chromium.org hablich@chromium.org hpayer@chromium.org @@ -16,21 +18,22 @@ ishell@chromium.org jgruber@chromium.org jkummerow@chromium.org leszeks@chromium.org +liviurau@chromium.org machenbach@chromium.org manoskouk@chromium.org -mathias@chromium.org marja@chromium.org +mathias@chromium.org mliedtke@chromium.org mlippautz@chromium.org -mslekova@chromium.org nicohartmann@chromium.org nikolaos@chromium.org +olivf@chromium.org omerkatz@chromium.org pthier@chromium.org +rezvan@chromium.org sroettger@google.com syg@chromium.org szuend@chromium.org -tebbi@chromium.org thibaudm@chromium.org vahl@chromium.org verwaest@chromium.org diff --git a/deps/v8/DEPS b/deps/v8/DEPS index 8f2b6e603dbde4..6b06081f88e887 100644 --- a/deps/v8/DEPS +++ b/deps/v8/DEPS @@ -57,7 +57,7 @@ vars = { 'checkout_fuchsia_no_hooks': False, # reclient CIPD package version - 'reclient_version': 're_client_version:0.134.1.2c9285b-gomaip', + 'reclient_version': 're_client_version:0.150.1.d9707319-gomaip', # Fetch configuration files required for the 'use_remoteexec' gn arg 'download_remoteexec_cfg': False, @@ -73,27 +73,27 @@ vars = { 'build_with_chromium': False, # GN CIPD package version. - 'gn_version': 'git_revision:59c4bb920542ee903ee1df39097ae024e2e8226f', + 'gn_version': 'git_revision:b2afae122eeb6ce09c52d63f67dc53fc517dbdc8', # ninja CIPD package version - # https://chrome-infra-packages.appspot.com/p/infra/3pp/tools/ninja - 'ninja_version': 'version:2@1.11.1.chromium.6', + # https://chrome-infra-packages.appspot.com/p/infra/3pp/build_support/ninja-1_11_1/ + 'ninja_version': 'version:2@1.11.1.chromium.2', # siso CIPD package version - 'siso_version': 'git_revision:110b1d8c0528de153cef259f09f3dc5ee627e6cb', + 'siso_version': 'git_revision:50a6db5dae3978d2d2e8dce29f6df024dde48d1b', # luci-go CIPD package version. - 'luci_go': 'git_revision:623f8d17a069eaea6d0fca13147888284ec76ff1', + 'luci_go': 'git_revision:771ea9a614a104c71655f699ef82219a2a474817', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Fuchsia sdk # and whatever else without interference from each other. - 'fuchsia_version': 'version:19.20240305.3.1', + 'fuchsia_version': 'version:22.20240717.4.1', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_build-tools_version # and whatever else without interference from each other. - 'android_sdk_build-tools_version': 'YK9Rzw3fDzMHVzatNN6VlyoD_81amLZpN1AbmkdOd6AC', + 'android_sdk_build-tools_version': 'DxwAZ3hD551Neu6ycuW5CPnXFrdleRBd93oX1eB_m9YC', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_emulator_version # and whatever else without interference from each other. @@ -109,11 +109,11 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_platform-tools_version # and whatever else without interference from each other. - 'android_sdk_platform-tools_version': 'HWVsGs2HCKgSVv41FsOcsfJbNcB0UFiNrF6Tc4yRArYC', + 'android_sdk_platform-tools_version': 'WihaseZR6cojZbkzIqwGhpTp92ztaGfqq8njBU8eTXYC', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_platforms_version # and whatever else without interference from each other. - 'android_sdk_platforms_version': 'u-bhWbTME6u-DjypTgr3ZikCyeAeU6txkR9ET6Uudc8C', + 'android_sdk_platforms_version': 'kIXA-9XuCfOESodXEdOBkW5f1ytrGWdbp3HFp1I8A_0C', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_sources_version # and whatever else without interference from each other. @@ -125,12 +125,10 @@ vars = { } deps = { - 'base/trace_event/common': - Var('chromium_url') + '/chromium/src/base/trace_event/common.git' + '@' + '29ac73db520575590c3aceb0a6f1f58dda8934f6', 'build': - Var('chromium_url') + '/chromium/src/build.git' + '@' + 'bca39698b291b392f0b4336857caf929c603ada3', + Var('chromium_url') + '/chromium/src/build.git' + '@' + '7a8285c06acd753e6228263f48e5595e20ca1577', 'buildtools': - Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + '68fce43789231d29d2028ca85530e4814aac6f50', + Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + '3ef44a2b92d5dd1faa5189a06f3a5febe6db2d58', 'buildtools/linux64': { 'packages': [ { @@ -139,7 +137,7 @@ deps = { } ], 'dep_type': 'cipd', - 'condition': 'host_os == "linux" and host_cpu != "s390" and host_cpu != "ppc"', + 'condition': 'host_os == "linux" and host_cpu != "s390" and host_os != "zos" and host_cpu != "ppc"', }, 'buildtools/mac': { 'packages': [ @@ -169,22 +167,22 @@ deps = { } ], 'dep_type': 'cipd', - 'condition': '(host_os == "linux" or host_os == "mac" or host_os == "win") and host_cpu != "s390" and host_cpu != "ppc" and (host_cpu != "arm64" or host_os == "mac")', + 'condition': '(host_os == "linux" or host_os == "mac" or host_os == "win") and host_cpu != "s390" and host_os != "zos" and host_cpu != "ppc" and (host_cpu != "arm64" or host_os == "mac")', }, 'test/benchmarks/data': Var('chromium_url') + '/v8/deps/third_party/benchmarks.git' + '@' + '05d7188267b4560491ff9155c5ee13e207ecd65f', 'test/mozilla/data': Var('chromium_url') + '/v8/deps/third_party/mozilla-tests.git' + '@' + 'f6c578a10ea707b1a8ab0b88943fe5115ce2b9be', 'test/test262/data': - Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + '0b1abd5ee70867311bea78e851bd609ad842011a', + Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + 'b01075d87cf48f69a468d75a0eb7c372902965c7', 'third_party/android_platform': { - 'url': Var('chromium_url') + '/chromium/src/third_party/android_platform.git' + '@' + 'eeb2d566f963bb66212fdc0d9bbe1dde550b4969', + 'url': Var('chromium_url') + '/chromium/src/third_party/android_platform.git' + '@' + '6337c445f9963ec3914e7e0c5787941d07b46509', 'condition': 'checkout_android', }, 'third_party/android_sdk/public': { 'packages': [ { - 'package': 'chromium/third_party/android_sdk/public/build-tools/34.0.0', + 'package': 'chromium/third_party/android_sdk/public/build-tools/35.0.0', 'version': Var('android_sdk_build-tools_version'), }, { @@ -204,7 +202,7 @@ deps = { 'version': Var('android_sdk_platform-tools_version'), }, { - 'package': 'chromium/third_party/android_sdk/public/platforms/android-34', + 'package': 'chromium/third_party/android_sdk/public/platforms/android-35', 'version': Var('android_sdk_platforms_version'), }, { @@ -223,26 +221,26 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_toolchain/android_toolchain', - 'version': 'wpJvg81kuXdMM66r_l9Doa-pLfR6S26Jd1x40LpwWEoC', + 'version': 'h9HeidXTeHQ-oskldbqCZx26-7VrVvXpLfqOI87uy4QC', }, ], 'condition': 'checkout_android', 'dep_type': 'cipd', }, 'third_party/boringssl': { - 'url': Var('chromium_url') + '/chromium/src/third_party/boringssl.git' + '@' + '9ead20bdbf0ecc33219d25fd3a426876c54d126e', + 'url': Var('chromium_url') + '/chromium/src/third_party/boringssl.git' + '@' + '35f4fcbdeae229a56fd50320dc03ae6de407aca4', 'condition': "checkout_centipede_deps", }, 'third_party/boringssl/src': { - 'url': Var('boringssl_url') + '/boringssl.git' + '@' + '414f69504d30d0848b69f6453ea7fb5e88004cb4', + 'url': Var('boringssl_url') + '/boringssl.git' + '@' + 'f01108e4761e1d4189cb134322c3cb01dc71ef87', 'condition': "checkout_centipede_deps", }, 'third_party/catapult': { - 'url': Var('chromium_url') + '/catapult.git' + '@' + '97c002a33e5b777eaa60e3ddc977a185f89446f7', + 'url': Var('chromium_url') + '/catapult.git' + '@' + '16999365265c9850d7b5c46e53ddd52aca56f8dc', 'condition': 'checkout_android', }, 'third_party/clang-format/script': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/clang/tools/clang-format.git' + '@' + 'e5337933f2951cacd3aeacd238ce4578163ca0b9', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/clang/tools/clang-format.git' + '@' + '3c0acd2d4e73dd911309d9e970ba09d58bf23a62', 'third_party/colorama/src': { 'url': Var('chromium_url') + '/external/colorama.git' + '@' + '3de9f013df4b470069d03d250224062e8cf15c49', 'condition': 'checkout_android', @@ -252,11 +250,11 @@ deps = { 'condition': 'checkout_android', }, 'third_party/depot_tools': - Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + 'fe6a359a803f55829ede3666215d080f6775f173', + Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + 'cdcdd6efeec145eb246eeac20c78f2c55c9d393e', 'third_party/fp16/src': Var('chromium_url') + '/external/github.com/Maratyszcza/FP16.git' + '@' + '0a92994d729ff76a58f692d3028ca1b64b145d91', 'third_party/fuchsia-gn-sdk': { - 'url': Var('chromium_url') + '/chromium/src/third_party/fuchsia-gn-sdk.git' + '@' + '727f65f8dae76c0d5c39c0f95d9d8f3a90de79f1', + 'url': Var('chromium_url') + '/chromium/src/third_party/fuchsia-gn-sdk.git' + '@' + '30fee7b68b3675e351fa47303c3b6ef322941ccd', 'condition': 'checkout_fuchsia', }, # Exists for rolling the Fuchsia SDK. Check out of the SDK should always @@ -278,15 +276,19 @@ deps = { 'url': Var('chromium_url') + '/external/github.com/google/benchmark.git' + '@' + '344117638c8ff7e239044fd0fa7085839fc03021', }, 'third_party/fuzztest': - Var('chromium_url') + '/chromium/src/third_party/fuzztest.git' + '@' + 'daea7ab861050a6445f59758f09cc3173f5add76', + Var('chromium_url') + '/chromium/src/third_party/fuzztest.git' + '@' + '69fe98bf87d80fdc773481ae5180c63e431a13a1', 'third_party/fuzztest/src': - Var('chromium_url') + '/external/github.com/google/fuzztest.git' + '@' + 'bddcd9f77ba0a81a99ce50bcadf5149efe545df0', + Var('chromium_url') + '/external/github.com/google/fuzztest.git' + '@' + '32eb84a95951fa3a0148fb3e6a1a02f830ded136', 'third_party/googletest/src': - Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + 'b479e7a3c161d7087113a05f8cb034b870313a55', + Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + 'cee1ba1f24fb12b9ae8f31e70dca3f73dbb12cc2', + 'third_party/highway/src': + Var('chromium_url') + '/external/github.com/google/highway.git' + '@' + '8295336dd70f1201d42c22ab5b0861de38cf8fbf', 'third_party/icu': - Var('chromium_url') + '/chromium/deps/icu.git' + '@' + 'a622de35ac311c5ad390a7af80724634e5dc61ed', - 'third_party/instrumented_libraries': - Var('chromium_url') + '/chromium/src/third_party/instrumented_libraries.git' + '@' + '0893d760101b3ddf9a2408b9d20f15ec2b80b2c1', + Var('chromium_url') + '/chromium/deps/icu.git' + '@' + '9408c6fd4a39e6fef0e1c4077602e1c83b15f3fb', + 'third_party/instrumented_libs': { + 'url': Var('chromium_url') + '/chromium/third_party/instrumented_libraries.git' + '@' + 'bb6dbcf2df7a9beb34c3773ef4df161800e3aed9', + 'condition': 'checkout_instrumented_libraries', + }, 'third_party/ittapi': { # Force checkout ittapi libraries to pass v8 header includes check on # bots that has check_v8_header_includes enabled. @@ -294,35 +296,153 @@ deps = { 'condition': "checkout_ittapi or check_v8_header_includes", }, 'third_party/jinja2': - Var('chromium_url') + '/chromium/src/third_party/jinja2.git' + '@' + 'c9c77525ea20c871a1d4658f8d312b51266d4bad', + Var('chromium_url') + '/chromium/src/third_party/jinja2.git' + '@' + '2f6f2ff5e4c1d727377f5e1b9e1903d871f41e74', 'third_party/jsoncpp/source': Var('chromium_url') + '/external/github.com/open-source-parsers/jsoncpp.git'+ '@' + '42e892d96e47b1f6e29844cc705e148ec4856448', 'third_party/libc++/src': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxx.git' + '@' + '80307e66e74bae927fb8709a549859e777e3bf0b', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxx.git' + '@' + '6bb75caa139ee1e686d2205910454cf6ea212e58', 'third_party/libc++abi/src': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + 'fc6253a642c9e336480b17fb17771e2c1efc7fff', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + 'a3c7d3e2f3e1e724b4651891b1a71257cbd88acc', 'third_party/libunwind/src': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/libunwind.git' + '@' + '8bad7bd6ec30f94bce82f7cb5b58ecbd6ce02996', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libunwind.git' + '@' + 'd09db732ff68f40fd3581306c650b17ea1955b4e', + 'third_party/llvm-build/Release+Asserts': { + 'dep_type': 'gcs', + 'bucket': 'chromium-browser-clang', + 'objects': [ + { + 'object_name': 'Linux_x64/clang-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': '2c48fb44f408328f59482a1dafb2143bb8b6b04be23f407600117e6f6d4fa437', + 'size_bytes': 51489572, + 'generation': 1721105679311662, + 'condition': 'host_os == "linux"', + }, + { + 'object_name': 'Linux_x64/clang-tidy-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': '3570497c3c507be0f8f4c0aa149a57fc600ed49252da42676996ea651df05e60', + 'size_bytes': 13081104, + 'generation': 1721105679453016, + 'condition': 'host_os == "linux" and checkout_clang_tidy', + }, + { + 'object_name': 'Linux_x64/llvm-code-coverage-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': 'dd6f1c05d5fe244b4524af86e6aa20de2d730f7d7e01fe4002b5aa72347b7658', + 'size_bytes': 2357488, + 'generation': 1721105679795112, + 'condition': 'host_os == "linux" and checkout_clang_coverage_tools', + }, + { + 'object_name': 'Linux_x64/llvmobjdump-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': 'a93d8b39ac573376a2db77b04f014d8751375de8c70ee16ca4713e5da467c5ec', + 'size_bytes': 5387304, + 'generation': 1721105679641287, + 'condition': '(checkout_linux or checkout_mac or checkout_android and host_os != "mac")', + }, + { + 'object_name': 'Mac/clang-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': '04956a3db535f4cf1ab0a6e40383cbb5db7d6ee09721e31a706d230af206eaa0', + 'size_bytes': 46446976, + 'generation': 1721105680965575, + 'condition': 'host_os == "mac" and host_cpu == "x64"', + }, + { + 'object_name': 'Mac/clang-mac-runtime-library-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': 'c684d46962bd39f785a143c2b28a0400c6e6d41a610a04ad6982f7513b930a35', + 'size_bytes': 865444, + 'generation': 1721105687851327, + 'condition': 'checkout_mac and not host_os == "mac"', + }, + { + 'object_name': 'Mac/clang-tidy-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': '1bcfd396959c5f0e835e33f7bd15f29b2a1b1b27c619480dab767d034da48098', + 'size_bytes': 12650532, + 'generation': 1721105681146275, + 'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clang_tidy', + }, + { + 'object_name': 'Mac/llvm-code-coverage-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': 'dbaf0d0bc4d19be0a9bd033b94033a2e9f826f8ed4ec3e9e6fa732ca3b4f1b6f', + 'size_bytes': 2234200, + 'generation': 1721105681470376, + 'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clang_coverage_tools', + }, + { + 'object_name': 'Mac_arm64/clang-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': '3d8d0a32604b9c8f9add4865d4e2b4950607d2a201bcd1c3de9e67e2998f1a84', + 'size_bytes': 42076344, + 'generation': 1721105689042846, + 'condition': 'host_os == "mac" and host_cpu == "arm64"', + }, + { + 'object_name': 'Mac_arm64/clang-tidy-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': '12524e94777f1d78489f58bcd966a341c8a61dca56175c7d6e8835240b2dcade', + 'size_bytes': 11612984, + 'generation': 1721105689155910, + 'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clang_tidy', + }, + { + 'object_name': 'Mac_arm64/llvm-code-coverage-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': '85db7e11d059902cd2c3d04e1d0380524d0ef4bf6ec3c93f0afdfd663d8b2a64', + 'size_bytes': 2005884, + 'generation': 1721105689448152, + 'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clang_coverage_tools', + }, + { + 'object_name': 'Win/clang-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': '34ba04b75548fdce4b3d2ba9dc8320a11afb0cad8622d537c1cf37f1c5587bab', + 'size_bytes': 41800448, + 'generation': 1721105697679553, + 'condition': 'host_os == "win"', + }, + { + 'object_name': 'Win/clang-tidy-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': '41fe89c54964a6a8efb66c398dbf763e8a4aca6a675c6f4d15a94c5236ba1ab7', + 'size_bytes': 12869556, + 'generation': 1721105697770165, + 'condition': 'host_os == "win" and checkout_clang_tidy', + }, + { + 'object_name': 'Win/clang-win-runtime-library-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': 'ce7886ecbfb129660a14cc11c4eacd6a2ef6488b36a88a7afb71a8cd22277da0', + 'size_bytes': 2842872, + 'generation': 1721105704724295, + 'condition': 'checkout_win and not host_os == "win"', + }, + { + 'object_name': 'Win/llvm-code-coverage-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': 'e5778f9a2fa59936676579b01b3b576d8c545b72e5261c47a36751d4f1f6b61a', + 'size_bytes': 2357104, + 'generation': 1721105698068261, + 'condition': 'host_os == "win" and checkout_clang_coverage_tools', + }, + { + 'object_name': 'Win/llvmobjdump-llvmorg-19-init-14561-gecea8371-3.tar.xz', + 'sha256sum': 'ad7d9162e1632b5c64188f95362318f0d31e09002be0615df847f2c23cddef4c', + 'size_bytes': 5362484, + 'generation': 1721105697937832, + 'condition': 'checkout_linux or checkout_mac or checkout_android and host_os == "win"', + }, + ], + }, 'third_party/logdog/logdog': Var('chromium_url') + '/infra/luci/luci-py/client/libs/logdog' + '@' + '0b2078a90f7a638d576b3a7c407d136f2fb62399', 'third_party/markupsafe': - Var('chromium_url') + '/chromium/src/third_party/markupsafe.git' + '@' + 'e582d7f0edb9d67499b0f5abd6ae5550e91da7f2', + Var('chromium_url') + '/chromium/src/third_party/markupsafe.git' + '@' + '6638e9b0a79afc2ff7edd9e84b518fe7d5d5fea9', 'third_party/ninja': { 'packages': [ { - 'package': 'infra/3pp/tools/ninja/${{platform}}', + 'package': 'infra/3pp/build_support/ninja-1_11_1/${{platform}}', 'version': Var('ninja_version'), } ], 'dep_type': 'cipd', - 'condition': 'host_cpu != "s390" and host_cpu != "ppc"' + 'condition': 'host_cpu != "s390" and host_os != "zos" and host_cpu != "ppc"' }, 'third_party/perfetto': Var('android_url') + '/platform/external/perfetto.git' + '@' + '6fc824d618d2f06b5d9cd8655ba0419b6b3b366e', - 'third_party/protobuf': - Var('chromium_url') + '/external/github.com/google/protobuf'+ '@' + '6a59a2ad1f61d9696092f79b6d74368b4d7970a3', + 'third_party/protobuf_chrome': + Var('chromium_url') + '/chromium/src/third_party/protobuf.git' + '@' + 'da2fe725b80ac0ba646fbf77d0ce5b4ac236f823', 'third_party/re2/src': - Var('chromium_url') + '/external/github.com/google/re2.git' + '@' + '108914d28a79243d4300e7e651cd0a0d5883ca0f', + Var('chromium_url') + '/external/github.com/google/re2.git' + '@' + '6dcd83d60f7944926bfd308cc13979fc53dd69ca', 'third_party/requests': { 'url': Var('chromium_url') + '/external/github.com/kennethreitz/requests.git' + '@' + 'c7e0fc087ceeadb8b4c84a0953a422c474093d6d', 'condition': 'checkout_android', @@ -335,12 +455,12 @@ deps = { } ], 'dep_type': 'cipd', - 'condition': 'not build_with_chromium and host_cpu != "s390" and host_cpu != "ppc"', + 'condition': 'not build_with_chromium and host_cpu != "s390" and host_os != "zos" and host_cpu != "ppc"', }, 'third_party/zlib': - Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + 'c5bf1b566e5df14e763507e2ce30cbfebefeeccf', + Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + 'c2469fdd73f192383d2d94288da0ff5b9a3869f5', 'tools/clang': - Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + '1ed379eda880f53d895559815cd3e30b370abff5', + Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + '4dc76da47b1145e53e508a23c1bf2204cf5ee7ee', 'tools/luci-go': { 'packages': [ { @@ -352,12 +472,18 @@ deps = { 'version': Var('luci_go'), }, ], - 'condition': 'host_cpu != "s390" and host_os != "aix"', + 'condition': 'host_cpu != "s390" and host_os != "zos" and host_os != "aix"', 'dep_type': 'cipd', }, + 'tools/protoc_wrapper': + Var('chromium_url') + '/chromium/src/tools/protoc_wrapper.git' + '@' + 'dbcbea90c20ae1ece442d8ef64e61c7b10e2b013', 'third_party/abseil-cpp': { - 'url': Var('chromium_url') + '/chromium/src/third_party/abseil-cpp.git' + '@' + 'b3ae305fd5dbc6ad41eed9add26768c29181219f', + 'url': Var('chromium_url') + '/chromium/src/third_party/abseil-cpp.git' + '@' + '9d1552f25c3d9e9114b7d7aed55790570a99bc4d', 'condition': 'not build_with_chromium', + }, + 'third_party/zoslib': { + 'url': Var('chromium_url') + '/external/github.com/ibmruntimes/zoslib.git' + '@' + '1e68de6e37efced3738a88536fccb6bbfe2d70b2', + 'condition': 'host_os == "zos"', } } @@ -456,57 +582,6 @@ hooks = [ '-o', 'tools/clang/dsymutil/bin/dsymutil', ], }, - # Pull clang-format binaries using checked-in hashes. - { - 'name': 'clang_format_win', - 'pattern': '.', - 'condition': 'host_os == "win"', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-clang-format', - '-s', 'buildtools/win/clang-format.exe.sha1', - ], - }, - { - 'name': 'clang_format_mac_x64', - 'pattern': '.', - 'condition': 'host_os == "mac" and host_cpu == "x64"', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-clang-format', - '-s', 'buildtools/mac/clang-format.x64.sha1', - '-o', 'buildtools/mac/clang-format', - ], - }, - { - 'name': 'clang_format_mac_arm64', - 'pattern': '.', - 'condition': 'host_os == "mac" and host_cpu == "arm64"', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-clang-format', - '-s', 'buildtools/mac/clang-format.arm64.sha1', - '-o', 'buildtools/mac/clang-format', - ], - }, - { - 'name': 'clang_format_linux', - 'pattern': '.', - 'condition': 'host_os == "linux"', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-clang-format', - '-s', 'buildtools/linux64/clang-format.sha1', - ], - }, { 'name': 'gcmole', 'pattern': '.', @@ -555,58 +630,6 @@ hooks = [ '-s', 'test/wasm-js/tests.tar.gz.sha1', ], }, - { - 'name': 'sysroot_arm', - 'pattern': '.', - 'condition': '(checkout_linux and checkout_arm)', - 'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py', - '--arch=arm'], - }, - { - 'name': 'sysroot_arm64', - 'pattern': '.', - 'condition': '(checkout_linux and checkout_arm64)', - 'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py', - '--arch=arm64'], - }, - { - 'name': 'sysroot_x86', - 'pattern': '.', - 'condition': '(checkout_linux and (checkout_x86 or checkout_x64))', - 'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py', - '--arch=x86'], - }, - { - 'name': 'sysroot_x64', - 'pattern': '.', - 'condition': 'checkout_linux and checkout_x64', - 'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py', - '--arch=x64'], - }, - { - 'name': 'msan_chained_origins_focal', - 'pattern': '.', - 'condition': 'checkout_instrumented_libraries', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-instrumented-libraries', - '-s', 'third_party/instrumented_libraries/binaries/msan-chained-origins-focal.tgz.sha1', - ], - }, - { - 'name': 'msan_no_origins_focal', - 'pattern': '.', - 'condition': 'checkout_instrumented_libraries', - 'action': [ 'python3', - 'third_party/depot_tools/download_from_google_storage.py', - '--no_resume', - '--no_auth', - '--bucket', 'chromium-instrumented-libraries', - '-s', 'third_party/instrumented_libraries/binaries/msan-no-origins-focal.tgz.sha1', - ], - }, { # Case-insensitivity for the Win SDK. Must run before win_toolchain below. 'name': 'ciopfs_linux', @@ -634,29 +657,6 @@ hooks = [ 'condition': 'checkout_mac', 'action': ['python3', 'build/mac_toolchain.py'], }, - { - # Note: On Win, this should run after win_toolchain, as it may use it. - 'name': 'clang', - 'pattern': '.', - # clang not supported on aix - 'condition': 'host_os != "aix"', - 'action': ['python3', 'tools/clang/scripts/update.py'], - }, - { - # This is supposed to support the same set of platforms as 'clang' above. - 'name': 'clang_coverage', - 'pattern': '.', - 'condition': 'checkout_clang_coverage_tools', - 'action': ['python3', 'tools/clang/scripts/update.py', - '--package=coverage_tools'], - }, - { - 'name': 'clang_tidy', - 'pattern': '.', - 'condition': 'checkout_clang_tidy', - 'action': ['python3', 'tools/clang/scripts/update.py', - '--package=clang-tidy'], - }, { # Update LASTCHANGE. 'name': 'lastchange', @@ -718,6 +718,7 @@ hooks = [ 'python3', 'tools/builtins-pgo/download_profiles.py', 'download', + '--quiet', ], }, { @@ -773,3 +774,9 @@ hooks = [ ], }, ] + +recursedeps = [ + 'build', + 'buildtools', + 'third_party/instrumented_libs', +] diff --git a/deps/v8/ENG_REVIEW_OWNERS b/deps/v8/ENG_REVIEW_OWNERS index 7d582ec7d4016b..27a979ebaf9d9e 100644 --- a/deps/v8/ENG_REVIEW_OWNERS +++ b/deps/v8/ENG_REVIEW_OWNERS @@ -4,8 +4,10 @@ adamk@chromium.org danno@chromium.org +gdeepti@chromium.org hpayer@chromium.org leszeks@chromium.org mlippautz@chromium.org +syg@chromium.org verwaest@chromium.org vahl@chromium.org diff --git a/deps/v8/PRESUBMIT.py b/deps/v8/PRESUBMIT.py index 42cebdd65328f3..5318df8fc473a9 100644 --- a/deps/v8/PRESUBMIT.py +++ b/deps/v8/PRESUBMIT.py @@ -31,10 +31,12 @@ for more details about the presubmit API built into gcl. """ +import ast import json import os import re import sys +import traceback # This line is 'magic' in that git-cl looks for it to decide whether to # use Python3 instead of Python2 when running the code in this file. @@ -138,6 +140,27 @@ def FilterJSFile(affected_file): return results +def _CheckPythonLiterals(input_api, output_api): + """Checks that all .pyl files are valid python literals.""" + affected_files = [ + af for af in input_api.AffectedFiles() + if af.LocalPath().endswith('.pyl') + ] + + results = [] + for af in affected_files: + try: + ast.literal_eval('\n'.join(af.NewContents())) + except SyntaxError as e: + results.append(output_api.PresubmitError( + f'Failed to parse python literal {af.LocalPath()}:\n' + + traceback.format_exc(0) + )) + + return results + + + def _CheckUnwantedDependencies(input_api, output_api): """Runs checkdeps on #include statements added in this change. Breaking - rules is an error, breaking ! rules is a @@ -416,6 +439,7 @@ def _CommonChecks(input_api, output_api): _CheckJSONFiles, _CheckNoexceptAnnotations, _RunTestsWithVPythonSpec, + _CheckPythonLiterals, ] return sum([check(input_api, output_api) for check in checks], []) diff --git a/deps/v8/WATCHLISTS b/deps/v8/WATCHLISTS index d853a0de2a2e36..6850defb79dd1e 100644 --- a/deps/v8/WATCHLISTS +++ b/deps/v8/WATCHLISTS @@ -73,6 +73,9 @@ 'maglev': { 'filepath': 'src/maglev/', }, + 'compiler': { + 'filepath': 'src/compiler', + }, 'parser': { 'filepath': 'src/ast/' \ '|src/parsing/', @@ -104,9 +107,6 @@ 'trap-handler': { 'filepath': 'src/trap-handler/', }, - 'tests': { - 'filepath': 'test/', - }, }, 'WATCHLISTS': { @@ -115,6 +115,9 @@ 'verwaest+watch@chromium.org', 'victorgomes+watch@chromium.org', ], + 'compiler': [ + 'dmercadier+watch@chromium.org', + ], 'snapshot': [ 'jgruber+watch@chromium.org', ], @@ -180,8 +183,5 @@ 'mark@chromium.org', 'mseaborn@chromium.org', ], - 'tests': [ - 'almuthanna+watch@chromium.org', - ], }, } diff --git a/deps/v8/WORKSPACE b/deps/v8/WORKSPACE index 96ef24384ed084..8692e456b9a87f 100644 --- a/deps/v8/WORKSPACE +++ b/deps/v8/WORKSPACE @@ -70,17 +70,6 @@ bind( actual = "@com_googlesource_chromium_icu//:icu", ) -new_local_repository( - name = "com_googlesource_chromium_base_trace_event_common", - build_file = "//:bazel/BUILD.trace_event_common", - path = "base/trace_event/common", -) - -bind( - name = "base_trace_event_common", - actual = "@com_googlesource_chromium_base_trace_event_common//:trace_event_common", -) - http_archive( name = "intel_ittapi", add_prefix = "third_party/ittapi", diff --git a/deps/v8/bazel/BUILD.trace_event_common b/deps/v8/bazel/BUILD.trace_event_common deleted file mode 100644 index 685b284071946c..00000000000000 --- a/deps/v8/bazel/BUILD.trace_event_common +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2021 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cc_library( - name = "trace_event_common", - hdrs = ["trace_event_common.h"], - include_prefix = "base/trace_event/common", - visibility = ["//visibility:public"], -) diff --git a/deps/v8/bazel/config/BUILD.bazel b/deps/v8/bazel/config/BUILD.bazel index 67454fa90eea46..c81f2782031269 100644 --- a/deps/v8/bazel/config/BUILD.bazel +++ b/deps/v8/bazel/config/BUILD.bazel @@ -201,14 +201,6 @@ selects.config_setting_group( ] ) -selects.config_setting_group( - name = "is_non_android_posix", - match_any = [ - ":is_linux", - ":is_macos", - ], -) - selects.config_setting_group( name = "is_posix_x64", match_all = [ @@ -217,14 +209,6 @@ selects.config_setting_group( ], ) -selects.config_setting_group( - name = "is_non_android_posix_x64", - match_all = [ - ":is_non_android_posix", - ":is_x64", - ], -) - selects.config_setting_group( name = "is_inline_asm_x64", match_all = [ @@ -305,14 +289,6 @@ selects.config_setting_group( ], ) -selects.config_setting_group( - name = "is_macos_arm64", - match_all = [ - ":is_macos", - ":is_arm64", - ], -) - config_setting( name = "is_compiler_default", flag_values = { diff --git a/deps/v8/bazel/defs.bzl b/deps/v8/bazel/defs.bzl index f23f48ef03ae6a..520a311595e488 100644 --- a/deps/v8/bazel/defs.bzl +++ b/deps/v8/bazel/defs.bzl @@ -109,7 +109,8 @@ def _default_args(): "-Werror", "-Wextra", "-Wno-unneeded-internal-declaration", - "-Wno-unknown-warning-option", + "-Wno-unknown-warning-option", # b/330781959 + "-Wno-cast-function-type-mismatch", # b/330781959 "-Wno-bitwise-instead-of-logical", "-Wno-builtin-assume-aligned-alignment", "-Wno-unused-parameter", @@ -122,7 +123,8 @@ def _default_args(): }) + select({ "@v8//bazel/config:is_clang": [ "-Wno-invalid-offsetof", - "-std=c++17", + "-Wno-deprecated-this-capture", + "-std=c++20", ], "@v8//bazel/config:is_gcc": [ "-Wno-extra", @@ -137,12 +139,13 @@ def _default_args(): "-Wno-redundant-move", "-Wno-return-type", "-Wno-stringop-overflow", + "-Wno-deprecated-this-capture", # Use GNU dialect, because GCC doesn't allow using # ##__VA_ARGS__ when in standards-conforming mode. - "-std=gnu++17", + "-std=gnu++2a", ], "@v8//bazel/config:is_windows": [ - "/std:c++17", + "/std:c++20", ], "//conditions:default": [], }) + select({ @@ -560,6 +563,7 @@ def build_config_content(cpu, icu): ("js_shared_memory", "false"), ("lite_mode", "false"), ("local_off_stack_check", "false"), + ("memory_corruption_api", "false"), ("mips_arch_variant", '""'), ("mips_use_msa", "false"), ("msan", "false"), @@ -589,8 +593,8 @@ def build_config_content(cpu, icu): # TODO(victorgomes): Create a rule (instead of a macro), that can # dynamically populate the build config. -def v8_build_config(name): - cpu = _quote("x64") +def v8_build_config(name, arch): + cpu = '"' + arch + '"' native.genrule( name = "noicu/" + name, outs = ["noicu/" + name + ".json"], diff --git a/deps/v8/bazel/v8-non-pointer-compression.bzl b/deps/v8/bazel/v8-non-pointer-compression.bzl index a9f73728301254..8c9294548406e0 100644 --- a/deps/v8/bazel/v8-non-pointer-compression.bzl +++ b/deps/v8/bazel/v8-non-pointer-compression.bzl @@ -3,7 +3,7 @@ Exposes the rule v8_binary_non_pointer_compression, which forces a label to be compiled without pointer compression. """ -def _v8_disable_pointer_compression(): +def _v8_disable_pointer_compression(settings, attr): return { "//:v8_enable_pointer_compression": "False", } diff --git a/deps/v8/build_overrides/build.gni b/deps/v8/build_overrides/build.gni index 32896733f83bf1..0a1fc3c46d23a6 100644 --- a/deps/v8/build_overrides/build.gni +++ b/deps/v8/build_overrides/build.gni @@ -17,11 +17,14 @@ build_with_node = false # chromium build. perfetto_build_with_embedder = true -# When embedding perfetto, its build files need to know in which BUILD.gn file -# the embedder (v8) declared the protobuf targets. In the v8 case they are -# declared in the root v8/BUILD.gn. -perfetto_protobuf_target_prefix = "//" -perfetto_protobuf_gni = "//gni/proto_library.gni" +# TODO(https://crbug.com/337736622): Perfetto and FuzzTest need to know the +# path to protobuf targets. V8 stores them in a different location than Chrome +# until M129. Thereafter, it can move to //third_party/protobuf and these +# variables can be removed. +protobuf_target_prefix = "//third_party/protobuf_chrome/" +perfetto_protobuf_target_prefix = protobuf_target_prefix +perfetto_protobuf_gni = "//third_party/protobuf_chrome/proto_library.gni" +perfetto_protobuf_src_dir = "//third_party/protobuf_chrome/src" # We use Perfetto's Trace Processor to convert traces to the legacy JSON # format. diff --git a/deps/v8/gni/proto_library.gni b/deps/v8/gni/proto_library.gni deleted file mode 100644 index a8690999f97710..00000000000000 --- a/deps/v8/gni/proto_library.gni +++ /dev/null @@ -1,282 +0,0 @@ -# Copyright 2019 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//build_overrides/build.gni") - -# This file should not be pulled in chromium builds. -assert(!build_with_chromium) - -if (host_os == "win") { - _host_executable_suffix = ".exe" -} else { - _host_executable_suffix = "" -} - -template("proto_library") { - assert(defined(invoker.sources)) - proto_sources = invoker.sources - - # All the proto imports should be relative to the project root. - proto_in_dir = "//" - if (defined(invoker.proto_in_dir)) { - proto_in_dir = invoker.proto_in_dir - } - assert(defined(invoker.proto_out_dir), - "proto_out_dir must be explicitly defined") - proto_out_dir = invoker.proto_out_dir - - # We don't support generate_python in the standalone build, but still must - # check that the caller sets this to false. This is because when building in - # the chromium tree, chromium's proto_library.gni in chrome (!= this) defaults - # generate_python = true. - assert(defined(invoker.generate_python) && !invoker.generate_python) - - import_dirs = [] - if (defined(invoker.import_dirs)) { - import_dirs = invoker.import_dirs - } - - # If false will not generate the default .pb.{cc,h} files. Used for custom - # codegen plugins. - generate_cc = true - if (defined(invoker.generate_cc)) { - generate_cc = invoker.generate_cc - } - - generate_descriptor = "" - if (defined(invoker.generate_descriptor)) { - generate_descriptor = invoker.generate_descriptor - } - - if (defined(invoker.generator_plugin_label)) { - plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)" - plugin_path = - get_label_info(plugin_host_label, "root_out_dir") + "/" + - get_label_info(plugin_host_label, "name") + _host_executable_suffix - generate_with_plugin = true - } else if (defined(invoker.generator_plugin_script)) { - plugin_path = invoker.generator_plugin_script - generate_with_plugin = true - } else { - generate_with_plugin = false - } - - if (generate_with_plugin) { - if (defined(invoker.generator_plugin_suffix)) { - generator_plugin_suffixes = [ - "${invoker.generator_plugin_suffix}.h", - "${invoker.generator_plugin_suffix}.cc", - ] - } else { - generator_plugin_suffixes = invoker.generator_plugin_suffixes - } - } - - out_dir = "$root_gen_dir/" + proto_out_dir - rel_out_dir = rebase_path(out_dir, root_build_dir) - - # exclude_imports is only used for generating the descriptor. Therefore, the - # check needs to be here to avoid complaints from GN about the unused - # variable. - if (generate_descriptor != "") { - if (defined(invoker.exclude_imports)) { - exclude_imports = invoker.exclude_imports - } else { - exclude_imports = false - } - } - - # Prevent unused errors when generating descriptor only. - if (generate_descriptor != "") { - not_needed([ "rel_out_dir" ]) - } - - protos = rebase_path(proto_sources, proto_in_dir) - protogens = [] - - if (generate_descriptor != "") { - protogens += [ "$out_dir/${generate_descriptor}" ] - } - - foreach(proto, protos) { - proto_dir = get_path_info(proto, "dir") - proto_name = get_path_info(proto, "name") - proto_path = proto_dir + "/" + proto_name - - # Prevent unused errors when generating descriptor only. - if (generate_descriptor != "") { - not_needed([ "proto_path" ]) - } - - if (generate_cc) { - protogens += [ - "$out_dir/$proto_path.pb.h", - "$out_dir/$proto_path.pb.cc", - ] - } - if (generate_with_plugin) { - foreach(suffix, generator_plugin_suffixes) { - protogens += [ "$out_dir/${proto_path}${suffix}" ] - } - } - } - - config_name = "${target_name}_config" - if (generate_descriptor == "") { - action_name = "${target_name}_gen" - source_set_name = target_name - } else { - action_name = target_name - } - - config(config_name) { - include_dirs = [ out_dir ] - } - - # The XXX_gen action that generates the .pb.{cc,h} files. - action(action_name) { - if (generate_descriptor == "") { - visibility = [ ":$source_set_name" ] - } - sources = proto_sources - outputs = get_path_info(protogens, "abspath") - - protoc_label = "//:protoc($host_toolchain)" - protoc_path = get_label_info(protoc_label, "root_out_dir") + "/protoc" + - _host_executable_suffix - protoc_rebased_path = "./" + rebase_path(protoc_path, root_build_dir) - script = "//gni/protoc.py" - args = [ - # Path should be rebased because |root_build_dir| for current toolchain - # may be different from |root_out_dir| of protoc built on host toolchain. - protoc_rebased_path, - "--proto_path", - rebase_path(proto_in_dir, root_build_dir), - ] - - foreach(path, import_dirs) { - args += [ - "--proto_path", - rebase_path(path, root_build_dir), - ] - } - - if (generate_cc) { - cc_generator_options_ = "" - if (defined(invoker.cc_generator_options)) { - cc_generator_options_ = invoker.cc_generator_options - } - args += [ - "--cpp_out", - cc_generator_options_ + rel_out_dir, - ] - } - if (generate_descriptor != "") { - depfile = "$out_dir/$generate_descriptor.d" - if (!exclude_imports) { - args += [ "--include_imports" ] - } - args += [ - "--descriptor_set_out", - rebase_path("$out_dir/$generate_descriptor", root_build_dir), - "--dependency_out", - rebase_path(depfile, root_build_dir), - ] - } - - if (generate_with_plugin) { - plugin_path_rebased = rebase_path(plugin_path, root_build_dir) - plugin_out_args = "" - if (defined(invoker.generator_plugin_options)) { - plugin_out_args += invoker.generator_plugin_options - } - plugin_out_args += ":$rel_out_dir" - - args += [ - "--plugin=protoc-gen-plugin=$plugin_path_rebased", - "--plugin_out=$plugin_out_args", - ] - } - - args += rebase_path(proto_sources, root_build_dir) - - inputs = [ protoc_path ] - deps = [ protoc_label ] - - # TODO(hjd): Avoid adding to deps here this. - # When we generate BUILD files we need find the transitive proto, - # dependencies, so also add link_deps to actual deps so they show up - # in gn desc. - if (defined(invoker.link_deps)) { - deps += invoker.link_deps - } - if (generate_with_plugin) { - inputs += [ plugin_path ] - if (defined(plugin_host_label)) { - # Action depends on native generator plugin but for host toolchain only. - deps += [ plugin_host_label ] - } - } - - if (defined(invoker.deps)) { - deps += invoker.deps - } - } # action(action_name) - - # The source_set that builds the generated .pb.cc files. - if (generate_descriptor == "") { - source_set(source_set_name) { - forward_variables_from(invoker, - [ - "defines", - "include_dirs", - "public_configs", - "testonly", - "visibility", - ]) - - sources = get_target_outputs(":$action_name") - - if (defined(invoker.extra_configs)) { - configs += invoker.extra_configs - } - - if (!defined(invoker.public_configs)) { - public_configs = [] - } - - public_configs += [ - "//:protobuf_gen_config", - ":$config_name", - ] - - # By default, propagate the config for |include_dirs| to dependent - # targets, so that public imports can be resolved to corresponding header - # files. In some cases, the embedder target handles include directory - # propagation itself, e.g. via a common config. - propagate_imports_configs = !defined(invoker.propagate_imports_configs) || - invoker.propagate_imports_configs - if (propagate_imports_configs) { - public_configs += [ ":$config_name" ] - } else { - configs += [ ":$config_name" ] - } - - # Use protobuf_full only for tests. - if (defined(invoker.use_protobuf_full) && - invoker.use_protobuf_full == true) { - deps = [ "//:protobuf_full" ] - } else if (generate_cc) { - deps = [ "//:protobuf_lite" ] - } else { - deps = [] - } - - deps += [ ":$action_name" ] - if (defined(invoker.deps)) { - deps += invoker.deps - } - } # source_set(source_set_name) - } -} # template diff --git a/deps/v8/gni/protoc.py b/deps/v8/gni/protoc.py deleted file mode 100755 index d529d1c65a536b..00000000000000 --- a/deps/v8/gni/protoc.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2021 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -"""Script to wrap protoc execution. - -This script exists to work-around the bad depfile generation by protoc when -generating descriptors.""" - -from __future__ import print_function -import argparse -import os -import sys -import subprocess -import tempfile -import uuid - -from codecs import open - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('--descriptor_set_out', default=None) - parser.add_argument('--dependency_out', default=None) - parser.add_argument('protoc') - args, remaining = parser.parse_known_args() - - if args.dependency_out and args.descriptor_set_out: - tmp_path = os.path.join(tempfile.gettempdir(), str(uuid.uuid4())) - custom = [ - '--descriptor_set_out', args.descriptor_set_out, '--dependency_out', - tmp_path - ] - try: - cmd = [args.protoc] + custom + remaining - subprocess.check_call(cmd) - with open(tmp_path, 'rb') as tmp_rd: - dependency_data = tmp_rd.read().decode('utf-8') - finally: - if os.path.exists(tmp_path): - os.unlink(tmp_path) - - with open(args.dependency_out, 'w', encoding='utf-8') as f: - f.write(args.descriptor_set_out + ":") - f.write(dependency_data) - else: - subprocess.check_call(sys.argv[1:]) - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/deps/v8/gni/v8.gni b/deps/v8/gni/v8.gni index 7c4e3ba5c34af2..9ee57a49806c1b 100644 --- a/deps/v8/gni/v8.gni +++ b/deps/v8/gni/v8.gni @@ -6,6 +6,7 @@ import("//build/config/chrome_build.gni") import("//build/config/compiler/pgo/pgo.gni") import("//build/config/gclient_args.gni") import("//build/config/ios/config.gni") +import("//build/config/ios/ios_sdk_overrides.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/config/v8_target_cpu.gni") import("//build_overrides/build.gni") @@ -39,6 +40,10 @@ declare_args() { # Includes profiles to optimize builtins. v8_enable_builtins_optimization = "" + # Turns on all V8 debug features. Enables running V8 in a pseudo debug mode + # within a release Chrome. + v8_enable_debugging_features = is_debug + # Enable ECMAScript Internationalization API. Enabling this feature will # add a dependency on the ICU library. v8_enable_i18n_support = true @@ -70,6 +75,14 @@ declare_args() { # Sets -DV8_LITE_MODE. v8_enable_lite_mode = false + # iOS executable code pages is in 17.4 SDK. We + # use target_os == "ios" here because it isn't equivalent + # to is_ios (is_ios is based on host_os). + if (target_os == "ios") { + # TODO(dtapuska): Change this to an assert. + v8_enable_lite_mode = ios_deployment_target != "17.4" + } + # Enable the Turbofan compiler. # Sets -dV8_ENABLE_TURBOFAN. v8_enable_turbofan = "" @@ -138,7 +151,7 @@ declare_args() { cppgc_enable_2gb_cage = false # Enable support for larger cages, up to 16GB. - cppgc_enable_larger_cage = false + cppgc_enable_larger_cage = true # Enable advanced BigInt algorithms, costing about 10-30 KB binary size # depending on platform. Disabled on Android to save binary size. @@ -147,11 +160,6 @@ declare_args() { # TODO: macros for determining endian type are clang specific. v8_use_libm_trig_functions = is_clang - # iOS device does not support executable code pages. Not we - # use target_os == "ios" here because it isn't equivalent - # to is_ios (is_ios is based on host_os). - target_is_ios_device = target_os == "ios" && target_environment == "device" - # Location of icu. v8_icu_path = "//third_party/icu" @@ -176,9 +184,9 @@ if (v8_enable_backtrace == "") { v8_enable_backtrace = is_debug && !v8_optimized_debug } -# If chromium is configured to use the perfetto client library, v8 should also +# Chromium is configured to use the perfetto client library, v8 should also # use perfetto for tracing. -if (build_with_chromium && use_perfetto_client_library) { +if (build_with_chromium) { v8_use_perfetto = true } @@ -196,18 +204,14 @@ if (v8_enable_builtins_optimization == "") { # v8_jitless. # WebAssembly is enabled by default, except in lite mode. if (v8_enable_webassembly == "") { - # iOS (non-simulator) does not have executable pages for 3rd party - # applications yet so disable webassembly. - v8_enable_webassembly = !v8_enable_lite_mode && !target_is_ios_device + v8_enable_webassembly = !v8_enable_lite_mode } assert(!(v8_enable_webassembly && v8_enable_lite_mode), "Webassembly is not available in lite mode.") # Turbofan is enabled by default, except in lite mode. if (v8_enable_turbofan == "") { - # iOS (non-simulator) does not have executable pages for 3rd party - # applications yet so disable turbofan. - v8_enable_turbofan = !v8_enable_lite_mode && !target_is_ios_device + v8_enable_turbofan = !v8_enable_lite_mode } assert(v8_enable_turbofan || !v8_enable_webassembly, "Webassembly is not available when Turbofan is disabled.") diff --git a/deps/v8/include/cppgc/allocation.h b/deps/v8/include/cppgc/allocation.h index 69883fb34d1e46..cdd3fd48f1fae6 100644 --- a/deps/v8/include/cppgc/allocation.h +++ b/deps/v8/include/cppgc/allocation.h @@ -47,7 +47,7 @@ namespace internal { // Similar to C++17 std::align_val_t; enum class AlignVal : size_t {}; -class V8_EXPORT MakeGarbageCollectedTraitInternal { +class MakeGarbageCollectedTraitInternal { protected: static inline void MarkObjectAsFullyConstructed(const void* payload) { // See api_constants for an explanation of the constants. @@ -121,16 +121,15 @@ class V8_EXPORT MakeGarbageCollectedTraitInternal { }; private: - static void* CPPGC_DEFAULT_ALIGNED Allocate(cppgc::AllocationHandle&, size_t, - GCInfoIndex); - static void* CPPGC_DOUBLE_WORD_ALIGNED Allocate(cppgc::AllocationHandle&, - size_t, AlignVal, - GCInfoIndex); - static void* CPPGC_DEFAULT_ALIGNED Allocate(cppgc::AllocationHandle&, size_t, - GCInfoIndex, CustomSpaceIndex); - static void* CPPGC_DOUBLE_WORD_ALIGNED Allocate(cppgc::AllocationHandle&, - size_t, AlignVal, GCInfoIndex, - CustomSpaceIndex); + V8_EXPORT static void* CPPGC_DEFAULT_ALIGNED + Allocate(cppgc::AllocationHandle&, size_t, GCInfoIndex); + V8_EXPORT static void* CPPGC_DOUBLE_WORD_ALIGNED + Allocate(cppgc::AllocationHandle&, size_t, AlignVal, GCInfoIndex); + V8_EXPORT static void* CPPGC_DEFAULT_ALIGNED + Allocate(cppgc::AllocationHandle&, size_t, GCInfoIndex, CustomSpaceIndex); + V8_EXPORT static void* CPPGC_DOUBLE_WORD_ALIGNED + Allocate(cppgc::AllocationHandle&, size_t, AlignVal, GCInfoIndex, + CustomSpaceIndex); friend class HeapObjectHeader; }; diff --git a/deps/v8/include/cppgc/heap-statistics.h b/deps/v8/include/cppgc/heap-statistics.h index 5e389874099426..c357f916f16a5b 100644 --- a/deps/v8/include/cppgc/heap-statistics.h +++ b/deps/v8/include/cppgc/heap-statistics.h @@ -102,6 +102,8 @@ struct HeapStatistics final { size_t resident_size_bytes = 0; /** Amount of memory actually used on the heap. */ size_t used_size_bytes = 0; + /** Memory retained in the page pool, not used directly by the heap. */ + size_t pooled_memory_size_bytes = 0; /** Detail level of this HeapStatistics. */ DetailLevel detail_level; diff --git a/deps/v8/include/cppgc/internal/api-constants.h b/deps/v8/include/cppgc/internal/api-constants.h index fed7005b46089b..8a0bb082fb9b20 100644 --- a/deps/v8/include/cppgc/internal/api-constants.h +++ b/deps/v8/include/cppgc/internal/api-constants.h @@ -30,10 +30,15 @@ static constexpr size_t kFullyConstructedBitFieldOffsetFromPayload = // Mask for in-construction bit. static constexpr uint16_t kFullyConstructedBitMask = uint16_t{1}; -static constexpr size_t kPageSize = size_t{1} << 17; +static constexpr size_t kPageSizeBits = 17; +static constexpr size_t kPageSize = size_t{1} << kPageSizeBits; #if defined(V8_HOST_ARCH_ARM64) && defined(V8_OS_DARWIN) constexpr size_t kGuardPageSize = 0; +#elif defined(V8_HOST_ARCH_PPC64) +constexpr size_t kGuardPageSize = 0; +#elif defined(V8_HOST_ARCH_LOONG64) || defined(V8_HOST_ARCH_MIPS64) +constexpr size_t kGuardPageSize = 0; #else constexpr size_t kGuardPageSize = 4096; #endif diff --git a/deps/v8/include/cppgc/internal/gc-info.h b/deps/v8/include/cppgc/internal/gc-info.h index c8cb99acbc0fde..d52710b369dc28 100644 --- a/deps/v8/include/cppgc/internal/gc-info.h +++ b/deps/v8/include/cppgc/internal/gc-info.h @@ -94,12 +94,11 @@ struct GCInfoTrait final { return index; } - static constexpr bool CheckCallbacksAreDefined() { + static constexpr void CheckCallbacksAreDefined() { // No USE() macro available. (void)static_cast(TraceTrait::Trace); (void)static_cast(FinalizerTrait::kCallback); (void)static_cast(NameTrait::GetName); - return true; } }; @@ -127,19 +126,22 @@ struct GCInfoFolding final { // configuration. Only a single GCInfo (for `ResultType` below) will actually // be instantiated but existence (and well-formedness) of all callbacks is // checked. - static constexpr bool kCheckTypeGuardAlwaysTrue = - GCInfoTrait::CheckCallbacksAreDefined() && + static constexpr bool WantToFold() { + if constexpr ((kHasVirtualDestructorAtBase || + kBothTypesAreTriviallyDestructible || + kHasCustomFinalizerDispatchAtBase) && + !kWantsDetailedObjectNames) { + GCInfoTrait::CheckCallbacksAreDefined(); GCInfoTrait::CheckCallbacksAreDefined(); + return true; + } + return false; + } // Folding would regress name resolution when deriving names from C++ // class names as it would just folds a name to the base class name. using ResultType = - std::conditional_t; + std::conditional_t; }; } // namespace internal diff --git a/deps/v8/include/cppgc/internal/member-storage.h b/deps/v8/include/cppgc/internal/member-storage.h index 61b255ba637a92..2b5bfec4ed5cc1 100644 --- a/deps/v8/include/cppgc/internal/member-storage.h +++ b/deps/v8/include/cppgc/internal/member-storage.h @@ -158,6 +158,12 @@ class V8_TRIVIAL_ABI CompressedPointer final { static V8_INLINE void* Decompress(IntegralType ptr) { CPPGC_DCHECK(CageBaseGlobal::IsSet()); const uintptr_t base = CageBaseGlobal::Get(); + return Decompress(ptr, base); + } + + static V8_INLINE void* Decompress(IntegralType ptr, uintptr_t base) { + CPPGC_DCHECK(CageBaseGlobal::IsSet()); + CPPGC_DCHECK(base == CageBaseGlobal::Get()); // Treat compressed pointer as signed and cast it to uint64_t, which will // sign-extend it. #if defined(CPPGC_2GB_CAGE) diff --git a/deps/v8/include/cppgc/internal/name-trait.h b/deps/v8/include/cppgc/internal/name-trait.h index 1d927a9d0a962c..6be298557df44b 100644 --- a/deps/v8/include/cppgc/internal/name-trait.h +++ b/deps/v8/include/cppgc/internal/name-trait.h @@ -121,7 +121,11 @@ class NameTrait final : public NameTraitBase { #undef PRETTY_FUNCTION_VALUE #else // !CPPGC_SUPPORTS_OBJECT_NAMES - return {NameProvider::kHiddenName, true}; + // We wanted to use a class name but were unable to provide one due to + // compiler limitations or build configuration. As such, return the hidden + // name with name_was_hidden=false, which will cause this object to be + // visible in the snapshot. + return {NameProvider::kHiddenName, false}; #endif // !CPPGC_SUPPORTS_OBJECT_NAMES } }; diff --git a/deps/v8/include/cppgc/name-provider.h b/deps/v8/include/cppgc/name-provider.h index 216f6098d99dd1..ec512441472d47 100644 --- a/deps/v8/include/cppgc/name-provider.h +++ b/deps/v8/include/cppgc/name-provider.h @@ -55,6 +55,13 @@ class V8_EXPORT NameProvider { * Specifies a name for the garbage-collected object. Such names will never * be hidden, as they are explicitly specified by the user of this API. * + * V8 may call this function while generating a heap snapshot or at other + * times. If V8 is currently generating a heap snapshot (according to + * HeapProfiler::IsTakingSnapshot), then the returned string must stay alive + * until the snapshot generation has completed. Otherwise, the returned string + * must stay alive forever. If you need a place to store a temporary string + * during snapshot generation, use HeapProfiler::CopyNameForHeapSnapshot. + * * @returns a human readable name for the object. */ virtual const char* GetHumanReadableName() const = 0; diff --git a/deps/v8/include/v8-array-buffer.h b/deps/v8/include/v8-array-buffer.h index ea6f5b5571a476..0a3d8170f68214 100644 --- a/deps/v8/include/v8-array-buffer.h +++ b/deps/v8/include/v8-array-buffer.h @@ -18,11 +18,12 @@ namespace v8 { class SharedArrayBuffer; #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT -// The number of required internal fields can be defined by embedder. +// Defined using gn arg `v8_array_buffer_internal_field_count`. #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 #endif enum class ArrayBufferCreationMode { kInternalized, kExternalized }; +enum class BackingStoreInitializationMode { kZeroInitialized, kUninitialized }; /** * A wrapper around the backing store (i.e. the raw memory) of an array buffer. @@ -87,6 +88,9 @@ class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase { * Assumes that the backing_store was allocated by the ArrayBuffer allocator * of the given isolate. */ + V8_DEPRECATED( + "Reallocate is unsafe, please do not use. Please allocate a new " + "BackingStore and copy instead.") static std::unique_ptr Reallocate( v8::Isolate* isolate, std::unique_ptr backing_store, size_t byte_length); @@ -179,6 +183,9 @@ class V8_EXPORT ArrayBuffer : public Object { * * The default implementation allocates a new block and copies data. */ + V8_DEPRECATED( + "Reallocate is unsafe, please do not use. Please allocate new memory " + "and copy instead.") virtual void* Reallocate(void* data, size_t old_length, size_t new_length); /** @@ -211,12 +218,15 @@ class V8_EXPORT ArrayBuffer : public Object { size_t MaxByteLength() const; /** - * Create a new ArrayBuffer. Allocate |byte_length| bytes. - * Allocated memory will be owned by a created ArrayBuffer and - * will be deallocated when it is garbage-collected, + * Create a new ArrayBuffer. Allocate |byte_length| bytes, which are either + * zero-initialized or uninitialized. Allocated memory will be owned by a + * created ArrayBuffer and will be deallocated when it is garbage-collected, * unless the object is externalized. */ - static Local New(Isolate* isolate, size_t byte_length); + static Local New( + Isolate* isolate, size_t byte_length, + BackingStoreInitializationMode initialization_mode = + BackingStoreInitializationMode::kZeroInitialized); /** * Create a new ArrayBuffer with an existing backing store. @@ -235,15 +245,18 @@ class V8_EXPORT ArrayBuffer : public Object { /** * Returns a new standalone BackingStore that is allocated using the array - * buffer allocator of the isolate. The result can be later passed to + * buffer allocator of the isolate. The allocation can either be zero + * intialized, or uninitialized. The result can be later passed to * ArrayBuffer::New. * * If the allocator returns nullptr, then the function may cause GCs in the * given isolate and re-try the allocation. If GCs do not help, then the * function will crash with an out-of-memory error. */ - static std::unique_ptr NewBackingStore(Isolate* isolate, - size_t byte_length); + static std::unique_ptr NewBackingStore( + Isolate* isolate, size_t byte_length, + BackingStoreInitializationMode initialization_mode = + BackingStoreInitializationMode::kZeroInitialized); /** * Returns a new standalone BackingStore that takes over the ownership of * the given buffer. The destructor of the BackingStore invokes the given @@ -287,7 +300,7 @@ class V8_EXPORT ArrayBuffer : public Object { * preventing JavaScript from ever accessing underlying backing store. * ArrayBuffer should have been externalized and must be detachable. */ - V8_DEPRECATE_SOON( + V8_DEPRECATED( "Use the version which takes a key parameter (passing a null handle is " "ok).") void Detach(); @@ -337,8 +350,9 @@ class V8_EXPORT ArrayBuffer : public Object { return static_cast(value); } - static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; - static const int kEmbedderFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; + static constexpr int kInternalFieldCount = + V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; + static constexpr int kEmbedderFieldCount = kInternalFieldCount; private: ArrayBuffer(); @@ -346,7 +360,7 @@ class V8_EXPORT ArrayBuffer : public Object { }; #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT -// The number of required internal fields can be defined by embedder. +// Defined using gn arg `v8_array_buffer_view_internal_field_count`. #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2 #endif @@ -393,10 +407,9 @@ class V8_EXPORT ArrayBufferView : public Object { return static_cast(value); } - static const int kInternalFieldCount = - V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; - static const int kEmbedderFieldCount = + static constexpr int kInternalFieldCount = V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; + static const int kEmbedderFieldCount = kInternalFieldCount; private: ArrayBufferView(); @@ -440,12 +453,15 @@ class V8_EXPORT SharedArrayBuffer : public Object { size_t MaxByteLength() const; /** - * Create a new SharedArrayBuffer. Allocate |byte_length| bytes. - * Allocated memory will be owned by a created SharedArrayBuffer and - * will be deallocated when it is garbage-collected, - * unless the object is externalized. + * Create a new SharedArrayBuffer. Allocate |byte_length| bytes, which are + * either zero-initialized or uninitialized. Allocated memory will be owned by + * a created SharedArrayBuffer and will be deallocated when it is + * garbage-collected, unless the object is externalized. */ - static Local New(Isolate* isolate, size_t byte_length); + static Local New( + Isolate* isolate, size_t byte_length, + BackingStoreInitializationMode initialization_mode = + BackingStoreInitializationMode::kZeroInitialized); /** * Create a new SharedArrayBuffer with an existing backing store. @@ -464,15 +480,18 @@ class V8_EXPORT SharedArrayBuffer : public Object { /** * Returns a new standalone BackingStore that is allocated using the array - * buffer allocator of the isolate. The result can be later passed to + * buffer allocator of the isolate. The allocation can either be zero + * intialized, or uninitialized. The result can be later passed to * SharedArrayBuffer::New. * * If the allocator returns nullptr, then the function may cause GCs in the * given isolate and re-try the allocation. If GCs do not help, then the * function will crash with an out-of-memory error. */ - static std::unique_ptr NewBackingStore(Isolate* isolate, - size_t byte_length); + static std::unique_ptr NewBackingStore( + Isolate* isolate, size_t byte_length, + BackingStoreInitializationMode initialization_mode = + BackingStoreInitializationMode::kZeroInitialized); /** * Returns a new standalone BackingStore that takes over the ownership of * the given buffer. The destructor of the BackingStore invokes the given @@ -506,7 +525,8 @@ class V8_EXPORT SharedArrayBuffer : public Object { return static_cast(value); } - static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; + static constexpr int kInternalFieldCount = + V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; private: SharedArrayBuffer(); diff --git a/deps/v8/include/v8-callbacks.h b/deps/v8/include/v8-callbacks.h index 4f5e716f8147a2..6096301258719e 100644 --- a/deps/v8/include/v8-callbacks.h +++ b/deps/v8/include/v8-callbacks.h @@ -152,9 +152,6 @@ using JitCodeEventHandler = void (*)(const JitCodeEvent* event); enum GCType { kGCTypeScavenge = 1 << 0, kGCTypeMinorMarkSweep = 1 << 1, - kGCTypeMinorMarkCompact V8_DEPRECATE_SOON( - "Use kGCTypeMinorMarkSweep instead of kGCTypeMinorMarkCompact.") = - kGCTypeMinorMarkSweep, kGCTypeMarkSweepCompact = 1 << 2, kGCTypeIncrementalMarking = 1 << 3, kGCTypeProcessWeakCallbacks = 1 << 4, @@ -234,7 +231,7 @@ using MessageCallback = void (*)(Local message, Local data); // --- Tracing --- -enum LogEventStatus : int { kStart = 0, kEnd = 1, kStamp = 2 }; +enum LogEventStatus : int { kStart = 0, kEnd = 1, kLog = 2 }; using LogEventCallback = void (*)(const char* name, int /* LogEventStatus */ status); @@ -341,6 +338,14 @@ using JavaScriptCompileHintsMagicEnabledCallback = // --- Callback for checking if WebAssembly JSPI is enabled --- using WasmJSPIEnabledCallback = bool (*)(Local context); +/** + * Import phases in import requests. + */ +enum class ModuleImportPhase { + kSource, + kEvaluation, +}; + /** * HostImportModuleDynamicallyCallback is called when we * require the embedder to load a module. This is used as part of the dynamic diff --git a/deps/v8/include/v8-context.h b/deps/v8/include/v8-context.h index 4849c925806f95..f432ff67f7053a 100644 --- a/deps/v8/include/v8-context.h +++ b/deps/v8/include/v8-context.h @@ -107,6 +107,10 @@ class V8_EXPORT Context : public Data { * configured if the default context snapshot contains no pointer embedder * data, or if no custom startup snapshot is configured in the * v8::CreateParams used to create the isolate. + * + * \param api_wrapper_deserializer An optional callback used to deserialize + * API wrapper objects that was initially set with v8::Object::Wrap() and then + * serialized using SerializeAPIWrapperCallback. */ static Local New( Isolate* isolate, ExtensionConfiguration* extensions = nullptr, @@ -116,17 +120,19 @@ class V8_EXPORT Context : public Data { DeserializeInternalFieldsCallback(), MicrotaskQueue* microtask_queue = nullptr, DeserializeContextDataCallback context_data_deserializer = - DeserializeContextDataCallback()); + DeserializeContextDataCallback(), + DeserializeAPIWrapperCallback api_wrapper_deserializer = + DeserializeAPIWrapperCallback()); /** * Create a new context from a (non-default) context snapshot. There * is no way to provide a global object template since we do not create * a new global object from template, but we can reuse a global object. * - * \param isolate See v8::Context::New. + * \param isolate See v8::Context::New(). * * \param context_snapshot_index The index of the context snapshot to - * deserialize from. Use v8::Context::New for the default snapshot. + * deserialize from. Use v8::Context::New() for the default snapshot. * * \param internal_fields_deserializer An optional callback used * to deserialize fields set by @@ -136,19 +142,23 @@ class V8_EXPORT Context : public Data { * pointer fields in the default context snapshot or if no startup * snapshot is configured when the isolate is created. * - * \param extensions See v8::Context::New. + * \param extensions See v8::Context::New(). * - * \param global_object See v8::Context::New. + * \param global_object See v8::Context::New(). * * \param internal_fields_deserializer Similar to - * internal_fields_deserializer in v8::Context::New but applies to + * internal_fields_deserializer in v8::Context::New() but applies to * the context specified by the context_snapshot_index. * - * \param microtask_queue See v8::Context::New. + * \param microtask_queue See v8::Context::New(). * * \param context_data_deserializer Similar to - * context_data_deserializer in v8::Context::New but applies to + * context_data_deserializer in v8::Context::New() but applies to * the context specified by the context_snapshot_index. + * + *\param api_wrapper_deserializer Similar to api_wrapper_deserializer in + * v8::Context::New() but applies to the context specified by the + * context_snapshot_index. */ static MaybeLocal FromSnapshot( Isolate* isolate, size_t context_snapshot_index, @@ -158,7 +168,9 @@ class V8_EXPORT Context : public Data { MaybeLocal global_object = MaybeLocal(), MicrotaskQueue* microtask_queue = nullptr, DeserializeContextDataCallback context_data_deserializer = - DeserializeContextDataCallback()); + DeserializeContextDataCallback(), + DeserializeAPIWrapperCallback api_wrapper_deserializer = + DeserializeAPIWrapperCallback()); /** * Returns an global object that isn't backed by an actual context. @@ -290,6 +302,8 @@ class V8_EXPORT Context : public Data { * SetAlignedPointerInEmbedderData with the same index. Note that index 0 * currently has a special meaning for Chrome's debugger. */ + V8_INLINE void* GetAlignedPointerFromEmbedderData(Isolate* isolate, + int index); V8_INLINE void* GetAlignedPointerFromEmbedderData(int index); /** @@ -444,6 +458,24 @@ Local Context::GetEmbedderData(int index) { #endif } +void* Context::GetAlignedPointerFromEmbedderData(Isolate* isolate, int index) { +#if !defined(V8_ENABLE_CHECKS) + using A = internal::Address; + using I = internal::Internals; + A ctx = internal::ValueHelper::ValueAsAddress(this); + A embedder_data = + I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset); + int value_offset = I::kEmbedderDataArrayHeaderSize + + (I::kEmbedderDataSlotSize * index) + + I::kEmbedderDataSlotExternalPointerOffset; + return reinterpret_cast( + I::ReadExternalPointerField( + isolate, embedder_data, value_offset)); +#else + return SlowGetAlignedPointerFromEmbedderData(index); +#endif +} + void* Context::GetAlignedPointerFromEmbedderData(int index) { #if !defined(V8_ENABLE_CHECKS) using A = internal::Address; diff --git a/deps/v8/include/v8-cppgc.h b/deps/v8/include/v8-cppgc.h index e0d76f45016e87..6ebae86c97f3b5 100644 --- a/deps/v8/include/v8-cppgc.h +++ b/deps/v8/include/v8-cppgc.h @@ -32,62 +32,15 @@ class CppHeap; class CustomSpaceStatisticsReceiver; -/** - * Describes how V8 wrapper objects maintain references to garbage-collected C++ - * objects. - */ -struct WrapperDescriptor final { - /** - * The index used on `v8::Ojbect::SetAlignedPointerFromInternalField()` and - * related APIs to add additional data to an object which is used to identify - * JS->C++ references. - */ - using InternalFieldIndex = int; - - /** - * Unknown embedder id. The value is reserved for internal usages and must not - * be used with `CppHeap`. - */ - static constexpr uint16_t kUnknownEmbedderId = UINT16_MAX; - - constexpr WrapperDescriptor(InternalFieldIndex wrappable_type_index, - InternalFieldIndex wrappable_instance_index, - uint16_t embedder_id_for_garbage_collected) - : wrappable_type_index(wrappable_type_index), - wrappable_instance_index(wrappable_instance_index), - embedder_id_for_garbage_collected(embedder_id_for_garbage_collected) {} - - /** - * Index of the wrappable type. - */ - InternalFieldIndex wrappable_type_index; - - /** - * Index of the wrappable instance. - */ - InternalFieldIndex wrappable_instance_index; - - /** - * Embedder id identifying instances of garbage-collected objects. It is - * expected that the first field of the wrappable type is a uint16_t holding - * the id. Only references to instances of wrappables types with an id of - * `embedder_id_for_garbage_collected` will be considered by CppHeap. - */ - uint16_t embedder_id_for_garbage_collected; -}; - struct V8_EXPORT CppHeapCreateParams { - CppHeapCreateParams( - std::vector> custom_spaces, - WrapperDescriptor wrapper_descriptor) - : custom_spaces(std::move(custom_spaces)), - wrapper_descriptor(wrapper_descriptor) {} + explicit CppHeapCreateParams( + std::vector> custom_spaces) + : custom_spaces(std::move(custom_spaces)) {} CppHeapCreateParams(const CppHeapCreateParams&) = delete; CppHeapCreateParams& operator=(const CppHeapCreateParams&) = delete; std::vector> custom_spaces; - WrapperDescriptor wrapper_descriptor; /** * Specifies which kind of marking are supported by the heap. The type may be * further reduced via runtime flags when attaching the heap to an Isolate. @@ -177,11 +130,6 @@ class V8_EXPORT CppHeap { void CollectGarbageInYoungGenerationForTesting( cppgc::EmbedderStackState stack_state); - /** - * \returns the wrapper descriptor of this CppHeap. - */ - v8::WrapperDescriptor wrapper_descriptor() const; - private: CppHeap() = default; diff --git a/deps/v8/include/v8-date.h b/deps/v8/include/v8-date.h index 8d82ccc9ea60bb..5c3cbd91c75afd 100644 --- a/deps/v8/include/v8-date.h +++ b/deps/v8/include/v8-date.h @@ -21,6 +21,10 @@ class V8_EXPORT Date : public Object { static V8_WARN_UNUSED_RESULT MaybeLocal New(Local context, double time); + static V8_WARN_UNUSED_RESULT MaybeLocal Parse( + Local context, + Local date_string); + /** * A specialization of Value::NumberValue that is more efficient * because we know the structure of this object. @@ -32,6 +36,11 @@ class V8_EXPORT Date : public Object { */ v8::Local ToISOString() const; + /** + * Generates UTC string representation. + */ + v8::Local ToUTCString() const; + V8_INLINE static Date* Cast(Value* value) { #ifdef V8_ENABLE_CHECKS CheckCast(value); diff --git a/deps/v8/include/v8-embedder-heap.h b/deps/v8/include/v8-embedder-heap.h index 236e1c1e94385c..7cc9aa0e637b75 100644 --- a/deps/v8/include/v8-embedder-heap.h +++ b/deps/v8/include/v8-embedder-heap.h @@ -29,6 +29,8 @@ class V8_EXPORT EmbedderRootsHandler { virtual ~EmbedderRootsHandler() = default; EmbedderRootsHandler() = default; + + V8_DEPRECATED("Use the default constructor instead.") explicit EmbedderRootsHandler(RootHandling default_traced_reference_handling) : default_traced_reference_handling_(default_traced_reference_handling) {} @@ -47,6 +49,7 @@ class V8_EXPORT EmbedderRootsHandler { * * The concrete implementations must be thread-safe. */ + V8_DEPRECATED("Use TracedReferenceHandling::kDroppable instead.") virtual bool IsRoot(const v8::TracedReference& handle) = 0; /** @@ -72,7 +75,7 @@ class V8_EXPORT EmbedderRootsHandler { private: const RootHandling default_traced_reference_handling_ = - RootHandling::kQueryEmbedderForNonDroppableReferences; + RootHandling::kDontQueryEmbedderForAnyReference; friend class internal::TracedHandles; }; diff --git a/deps/v8/include/v8-exception.h b/deps/v8/include/v8-exception.h index 86f8b3a4bafaba..a7f49b6c71b43c 100644 --- a/deps/v8/include/v8-exception.h +++ b/deps/v8/include/v8-exception.h @@ -8,6 +8,7 @@ #include #include "v8-local-handle.h" // NOLINT(build/include_directory) +#include "v8-object.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) namespace v8 { @@ -58,8 +59,77 @@ class V8_EXPORT Exception { * of a given exception, or an empty handle if not available. */ static Local GetStackTrace(Local exception); + + /** + * Captures the current stack trace and attaches it to the given object in the + * form of `stack` property. + */ + static Maybe CaptureStackTrace(Local context, + Local object); }; +/** + * This is a part of experimental Api and might be changed without further + * notice. + * Do not use it. + */ +enum class ExceptionContext : uint32_t { + kUnknown, + kConstructor, + kOperation, + kAttributeGet, + kAttributeSet, + kIndexedQuery, + kIndexedGetter, + kIndexedDescriptor, + kIndexedSetter, + kIndexedDefiner, + kIndexedDeleter, + kNamedQuery, + kNamedGetter, + kNamedDescriptor, + kNamedSetter, + kNamedDefiner, + kNamedDeleter, + kNamedEnumerator +}; + +/** + * This is a part of experimental Api and might be changed without further + * notice. + * Do not use it. + */ +class ExceptionPropagationMessage { + public: + ExceptionPropagationMessage(v8::Isolate* isolate, Local exception, + Local interface_name, + Local property_name, + ExceptionContext exception_context) + : isolate_(isolate), + exception_(exception), + interface_name_(interface_name), + property_name_(property_name), + exception_context_(exception_context) {} + + V8_INLINE Isolate* GetIsolate() const { return isolate_; } + V8_INLINE Local GetException() const { return exception_; } + V8_INLINE Local GetInterfaceName() const { return interface_name_; } + V8_INLINE Local GetPropertyName() const { return property_name_; } + V8_INLINE ExceptionContext GetExceptionContext() const { + return exception_context_; + } + + private: + Isolate* isolate_; + Local exception_; + Local interface_name_; + Local property_name_; + ExceptionContext exception_context_; +}; + +using ExceptionPropagationCallback = + void (*)(ExceptionPropagationMessage message); + /** * An external exception handler. */ diff --git a/deps/v8/include/v8-fast-api-calls.h b/deps/v8/include/v8-fast-api-calls.h index 74d4cb152ed6a6..1cd99cb880f023 100644 --- a/deps/v8/include/v8-fast-api-calls.h +++ b/deps/v8/include/v8-fast-api-calls.h @@ -337,7 +337,13 @@ struct FastApiTypedArrayBase { }; template -struct FastApiTypedArray : public FastApiTypedArrayBase { +struct V8_DEPRECATE_SOON( + "When an API function expects a TypedArray as a parameter, the type in the " + "signature should be `v8::Local` instead of " + "FastApiTypedArray<>. The API function then has to type-check the " + "parameter and convert it to a `v8::Local object_value; Local sequence_value; - const FastApiTypedArray* uint8_ta_value; - const FastApiTypedArray* int32_ta_value; - const FastApiTypedArray* uint32_ta_value; - const FastApiTypedArray* int64_ta_value; - const FastApiTypedArray* uint64_ta_value; - const FastApiTypedArray* float_ta_value; - const FastApiTypedArray* double_ta_value; const FastOneByteString* string_value; FastApiCallbackOptions* options_value; }; @@ -529,16 +528,22 @@ class V8_EXPORT CFunction { } template - static CFunction Make(F* func) { - return ArgUnwrap::Make(func); + static CFunction Make(F* func, + CFunctionInfo::Int64Representation int64_rep = + CFunctionInfo::Int64Representation::kNumber) { + CFunction result = ArgUnwrap::Make(func, int64_rep); + result.GetInt64Representation(); + return result; } // Provided for testing purposes. template static CFunction Make(R (*func)(Args...), - R_Patch (*patching_func)(Args_Patch...)) { - CFunction c_func = ArgUnwrap::Make(func); + R_Patch (*patching_func)(Args_Patch...), + CFunctionInfo::Int64Representation int64_rep = + CFunctionInfo::Int64Representation::kNumber) { + CFunction c_func = ArgUnwrap::Make(func, int64_rep); static_assert( sizeof...(Args_Patch) == sizeof...(Args), "The patching function must have the same number of arguments."); @@ -561,7 +566,9 @@ class V8_EXPORT CFunction { template class ArgUnwrap { public: - static CFunction Make(R (*func)(Args...)); + static CFunction Make(R (*func)(Args...), + CFunctionInfo::Int64Representation int64_rep = + CFunctionInfo::Int64Representation::kNumber); }; }; @@ -577,9 +584,11 @@ struct FastApiCallbackOptions { * returned instance may be filled with mock data. */ static FastApiCallbackOptions CreateForTesting(Isolate* isolate) { - return {false, {0}, nullptr}; + return {}; } + v8::Isolate* isolate = nullptr; + /** * If the callback wants to signal an error condition or to perform an * allocation, it must set options.fallback to true and do an early return @@ -591,21 +600,26 @@ struct FastApiCallbackOptions { * fallback conditions are checked, because otherwise executing the slow * callback might produce visible side-effects twice. */ - bool fallback; + V8_DEPRECATED( + "It is not necessary to use the `fallback` flag anymore, as it is " + "possible now to trigger GC, throw exceptions, and call back into " + "JavaScript even in API functions called with a fast API call.") + bool fallback = false; /** * The `data` passed to the FunctionTemplate constructor, or `undefined`. - * `data_ptr` allows for default constructing FastApiCallbackOptions. */ - union { - uintptr_t data_ptr; - v8::Local data; - }; + v8::Local data; /** * When called from WebAssembly, a view of the calling module's memory. */ - FastApiTypedArray* const wasm_memory; + V8_DEPRECATED( + "The wasm memory should either be provided as a field of the receiver, " + "the data object of the FunctionTemplate, or as a normal parameter of " + "the API function. Since regular API calls don't have this magic " + "`wasm_memory parameter, one of the options above should be possible.") + FastApiTypedArray* const wasm_memory = nullptr; }; namespace internal { @@ -929,8 +943,14 @@ class CFunctionBuilder { // static template -CFunction CFunction::ArgUnwrap::Make(R (*func)(Args...)) { - return internal::CFunctionBuilder().Fn(func).Build(); +CFunction CFunction::ArgUnwrap::Make( + R (*func)(Args...), CFunctionInfo::Int64Representation int64_rep) { + if (int64_rep == CFunctionInfo::Int64Representation::kNumber) { + return internal::CFunctionBuilder().Fn(func).Build(); + } + return internal::CFunctionBuilder() + .Fn(func) + .template Build(); } using CFunctionBuilder = internal::CFunctionBuilder; diff --git a/deps/v8/include/v8-function-callback.h b/deps/v8/include/v8-function-callback.h index 86a3ea72f4033c..7208c19ebf62c6 100644 --- a/deps/v8/include/v8-function-callback.h +++ b/deps/v8/include/v8-function-callback.h @@ -8,6 +8,7 @@ #include #include +#include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-primitive.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) @@ -31,6 +32,11 @@ namespace debug { class ConsoleCallArguments; } // namespace debug +namespace api_internal { +V8_EXPORT v8::Local GetFunctionTemplateData( + v8::Isolate* isolate, v8::Local raw_target); +} // namespace api_internal + template class ReturnValue { public: @@ -38,7 +44,7 @@ class ReturnValue { V8_INLINE ReturnValue(const ReturnValue& that) : value_(that.value_) { static_assert(std::is_base_of::value, "type check"); } - // Local setters + // Handle-based setters. template V8_INLINE void Set(const Global& handle); template @@ -51,15 +57,19 @@ class ReturnValue { V8_INLINE void Set(const Local handle); template V8_INLINE void SetNonEmpty(const Local handle); - // Fast primitive setters + // Fast primitive number setters. V8_INLINE void Set(bool value); V8_INLINE void Set(double i); + V8_INLINE void Set(int16_t i); V8_INLINE void Set(int32_t i); + V8_INLINE void Set(int64_t i); + V8_INLINE void Set(uint16_t i); V8_INLINE void Set(uint32_t i); - V8_INLINE void Set(uint16_t); + V8_INLINE void Set(uint64_t i); // Fast JS primitive setters V8_INLINE void SetNull(); V8_INLINE void SetUndefined(); + V8_INLINE void SetFalse(); V8_INLINE void SetEmptyString(); // Convenience getter for Isolate V8_INLINE Isolate* GetIsolate() const; @@ -83,14 +93,13 @@ class ReturnValue { template friend class PersistentValueMapBase; V8_INLINE void SetInternal(internal::Address value); - // Setting the hole value has different meanings depending on the usage: - // - for function template callbacks it means that the callback returns - // the undefined value, - // - for property getter callbacks is means that the callback returns - // the undefined value (for property setter callbacks the value returned - // is ignored), - // - for interceptor callbacks it means that the request was not handled. - V8_INLINE void SetTheHole(); + // Default value depends on : + // - -> true_value, + // - -> true_value, + // - -> 0, + // - -> undefined_value, + // - -> undefined_value. + V8_INLINE void SetDefaultValue(); V8_INLINE explicit ReturnValue(internal::Address* slot); // See FunctionCallbackInfo. @@ -127,6 +136,12 @@ class FunctionCallbackInfo { * referencing this callback was found (which in V8 internally is often * referred to as holder [sic]). */ + V8_DEPRECATED( + "V8 will stop providing access to hidden prototype (i.e. " + "JSGlobalObject). Use This() instead. \n" + "DO NOT try to workaround this by accessing JSGlobalObject via " + "v8::Object::GetPrototype() - it'll be deprecated soon too. \n" + "See http://crbug.com/333672197. ") V8_INLINE Local Holder() const; /** For construct calls, this returns the "new.target" value. */ V8_INLINE Local NewTarget() const; @@ -139,16 +154,22 @@ class FunctionCallbackInfo { /** The ReturnValue for the call. */ V8_INLINE ReturnValue GetReturnValue() const; + // This is a temporary replacement for Holder() added just for the purpose + // of testing the deprecated Holder() machinery until it's removed for real. + // DO NOT use it. + V8_INLINE Local HolderSoonToBeDeprecated() const; + private: friend class internal::FunctionCallbackArguments; friend class internal::CustomArguments; friend class debug::ConsoleCallArguments; + friend void internal::PrintFunctionCallbackInfo(void*); static constexpr int kHolderIndex = 0; static constexpr int kIsolateIndex = 1; - static constexpr int kUnusedIndex = 2; + static constexpr int kContextIndex = 2; static constexpr int kReturnValueIndex = 3; - static constexpr int kDataIndex = 4; + static constexpr int kTargetIndex = 4; static constexpr int kNewTargetIndex = 5; static constexpr int kArgsLength = 6; @@ -168,9 +189,13 @@ class FunctionCallbackInfo { V8_INLINE FunctionCallbackInfo(internal::Address* implicit_args, internal::Address* values, int length); + + // TODO(https://crbug.com/326505377): flatten the v8::FunctionCallbackInfo + // object to avoid indirect loads through values_ and implicit_args_ and + // reduce the number of instructions in the CallApiCallback builtin. internal::Address* implicit_args_; internal::Address* values_; - int length_; + internal::Address length_; }; /** @@ -244,8 +269,23 @@ class PropertyCallbackInfo { * * \note For security reasons, do not pass the object back into the runtime. */ + V8_DEPRECATE_SOON( + "V8 will stop providing access to hidden prototype (i.e. " + "JSGlobalObject). Use HolderV2() instead. \n" + "DO NOT try to workaround this by accessing JSGlobalObject via " + "v8::Object::GetPrototype() - it'll be deprecated soon too. \n" + "See http://crbug.com/333672197. ") V8_INLINE Local Holder() const; + /** + * \return The object in the prototype chain of the receiver that has the + * interceptor. Suppose you have `x` and its prototype is `y`, and `y` + * has an interceptor. Then `info.This()` is `x` and `info.Holder()` is `y`. + * In case the property is installed on the global object the Holder() + * would return the global proxy. + */ + V8_INLINE Local HolderV2() const; + /** * \return The return value of the callback. * Can be changed by calling Set(). @@ -266,24 +306,28 @@ class PropertyCallbackInfo { V8_INLINE bool ShouldThrowOnError() const; private: + template + friend class PropertyCallbackInfo; friend class MacroAssembler; friend class internal::PropertyCallbackArguments; friend class internal::CustomArguments; - static constexpr int kShouldThrowOnErrorIndex = 0; - static constexpr int kHolderIndex = 1; - static constexpr int kIsolateIndex = 2; - static constexpr int kUnusedIndex = 3; - static constexpr int kReturnValueIndex = 4; - static constexpr int kDataIndex = 5; - static constexpr int kThisIndex = 6; - static constexpr int kArgsLength = 7; + friend void internal::PrintPropertyCallbackInfo(void*); + + static constexpr int kPropertyKeyIndex = 0; + static constexpr int kShouldThrowOnErrorIndex = 1; + static constexpr int kHolderIndex = 2; + static constexpr int kIsolateIndex = 3; + static constexpr int kHolderV2Index = 4; + static constexpr int kReturnValueIndex = 5; + static constexpr int kDataIndex = 6; + static constexpr int kThisIndex = 7; + static constexpr int kArgsLength = 8; - static constexpr int kSize = 1 * internal::kApiSystemPointerSize; + static constexpr int kSize = kArgsLength * internal::kApiSystemPointerSize; - V8_INLINE explicit PropertyCallbackInfo(internal::Address* args) - : args_(args) {} + explicit PropertyCallbackInfo() = default; - internal::Address* args_; + mutable internal::Address args_[kArgsLength]; }; using FunctionCallback = void (*)(const FunctionCallbackInfo& info); @@ -312,7 +356,7 @@ template void ReturnValue::Set(const Global& handle) { static_assert(std::is_base_of::value, "type check"); if (V8_UNLIKELY(handle.IsEmpty())) { - SetTheHole(); + SetDefaultValue(); } else { SetInternal(handle.ptr()); } @@ -333,7 +377,7 @@ template void ReturnValue::Set(const BasicTracedReference& handle) { static_assert(std::is_base_of::value, "type check"); if (V8_UNLIKELY(handle.IsEmpty())) { - SetTheHole(); + SetDefaultValue(); } else { SetInternal(handle.ptr()); } @@ -352,10 +396,25 @@ void ReturnValue::SetNonEmpty(const BasicTracedReference& handle) { template template void ReturnValue::Set(const Local handle) { - static_assert(std::is_void::value || std::is_base_of::value, - "type check"); + // "V8_DEPRECATE_SOON" this method if |T| is |void|. +#ifdef V8_IMMINENT_DEPRECATION_WARNINGS + static constexpr bool is_allowed_void = false; + static_assert(!std::is_void::value, + "ReturnValue::Set(const Local) is deprecated. " + "Do nothing to indicate that the operation succeeded or use " + "SetFalse() to indicate that the operation failed (don't " + "forget to handle info.ShouldThrowOnError()). " + "See http://crbug.com/348660658 for details."); +#else + static constexpr bool is_allowed_void = std::is_void::value; +#endif // V8_IMMINENT_DEPRECATION_WARNINGS + static_assert(is_allowed_void || std::is_base_of::value, "type check"); if (V8_UNLIKELY(handle.IsEmpty())) { - SetTheHole(); + SetDefaultValue(); + } else if constexpr (is_allowed_void) { + // Simulate old behaviour for "v8::AccessorSetterCallback" for which + // it was possible to set the return value even for ReturnValue. + Set(handle->BooleanValue(GetIsolate())); } else { SetInternal(handle.ptr()); } @@ -364,12 +423,29 @@ void ReturnValue::Set(const Local handle) { template template void ReturnValue::SetNonEmpty(const Local handle) { - static_assert(std::is_void::value || std::is_base_of::value, - "type check"); + // "V8_DEPRECATE_SOON" this method if |T| is |void|. +#ifdef V8_IMMINENT_DEPRECATION_WARNINGS + static constexpr bool is_allowed_void = false; + static_assert(!std::is_void::value, + "ReturnValue::SetNonEmpty(const Local) is deprecated. " + "Do nothing to indicate that the operation succeeded or use " + "SetFalse() to indicate that the operation failed (don't " + "forget to handle info.ShouldThrowOnError()). " + "See http://crbug.com/348660658 for details."); +#else + static constexpr bool is_allowed_void = std::is_void::value; +#endif // V8_IMMINENT_DEPRECATION_WARNINGS + static_assert(is_allowed_void || std::is_base_of::value, "type check"); #ifdef V8_ENABLE_CHECKS internal::VerifyHandleIsNonEmpty(handle.IsEmpty()); #endif // V8_ENABLE_CHECKS - SetInternal(handle.ptr()); + if constexpr (is_allowed_void) { + // Simulate old behaviour for "v8::AccessorSetterCallback" for which + // it was possible to set the return value even for ReturnValue. + Set(handle->BooleanValue(GetIsolate())); + } else { + SetInternal(handle.ptr()); + } } template @@ -379,26 +455,32 @@ void ReturnValue::Set(double i) { } template -void ReturnValue::Set(int32_t i) { +void ReturnValue::Set(int16_t i) { static_assert(std::is_base_of::value, "type check"); using I = internal::Internals; - if (V8_LIKELY(I::IsValidSmi(i))) { - SetInternal(I::IntToSmi(i)); + static_assert(I::IsValidSmi(std::numeric_limits::min())); + static_assert(I::IsValidSmi(std::numeric_limits::max())); + SetInternal(I::IntegralToSmi(i)); +} + +template +void ReturnValue::Set(int32_t i) { + static_assert(std::is_base_of::value, "type check"); + if (const auto result = internal::Internals::TryIntegralToSmi(i)) { + SetInternal(*result); return; } SetNonEmpty(Integer::New(GetIsolate(), i)); } template -void ReturnValue::Set(uint32_t i) { +void ReturnValue::Set(int64_t i) { static_assert(std::is_base_of::value, "type check"); - // Can't simply use INT32_MAX here for whatever reason. - bool fits_into_int32_t = (i & (1U << 31)) == 0; - if (V8_LIKELY(fits_into_int32_t)) { - Set(static_cast(i)); + if (const auto result = internal::Internals::TryIntegralToSmi(i)) { + SetInternal(*result); return; } - SetNonEmpty(Integer::NewFromUnsigned(GetIsolate(), i)); + SetNonEmpty(Number::New(GetIsolate(), static_cast(i))); } template @@ -407,12 +489,33 @@ void ReturnValue::Set(uint16_t i) { using I = internal::Internals; static_assert(I::IsValidSmi(std::numeric_limits::min())); static_assert(I::IsValidSmi(std::numeric_limits::max())); - SetInternal(I::IntToSmi(i)); + SetInternal(I::IntegralToSmi(i)); +} + +template +void ReturnValue::Set(uint32_t i) { + static_assert(std::is_base_of::value, "type check"); + if (const auto result = internal::Internals::TryIntegralToSmi(i)) { + SetInternal(*result); + return; + } + SetNonEmpty(Integer::NewFromUnsigned(GetIsolate(), i)); +} + +template +void ReturnValue::Set(uint64_t i) { + static_assert(std::is_base_of::value, "type check"); + if (const auto result = internal::Internals::TryIntegralToSmi(i)) { + SetInternal(*result); + return; + } + SetNonEmpty(Number::New(GetIsolate(), static_cast(i))); } template void ReturnValue::Set(bool value) { - static_assert(std::is_base_of::value, "type check"); + static_assert(std::is_void::value || std::is_base_of::value, + "type check"); using I = internal::Internals; #if V8_STATIC_ROOTS_BOOL #ifdef V8_ENABLE_CHECKS @@ -433,13 +536,20 @@ void ReturnValue::Set(bool value) { } template -void ReturnValue::SetTheHole() { +void ReturnValue::SetDefaultValue() { using I = internal::Internals; + if constexpr (std::is_same_v || std::is_same_v) { + Set(true); + } else if constexpr (std::is_same_v) { + SetInternal(I::IntegralToSmi(0)); + } else { + static_assert(std::is_same_v || std::is_same_v); #if V8_STATIC_ROOTS_BOOL - SetInternal(I::StaticReadOnlyRoot::kTheHoleValue); + SetInternal(I::StaticReadOnlyRoot::kUndefinedValue); #else - *value_ = I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex); + *value_ = I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex); #endif // V8_STATIC_ROOTS_BOOL + } } template @@ -472,6 +582,22 @@ void ReturnValue::SetUndefined() { #endif // V8_STATIC_ROOTS_BOOL } +template +void ReturnValue::SetFalse() { + static_assert(std::is_void::value || std::is_base_of::value, + "type check"); + using I = internal::Internals; +#if V8_STATIC_ROOTS_BOOL +#ifdef V8_ENABLE_CHECKS + internal::PerformCastCheck( + internal::ValueHelper::SlotAsValue(value_)); +#endif // V8_ENABLE_CHECKS + SetInternal(I::StaticReadOnlyRoot::kFalseValue); +#else + *value_ = I::GetRoot(GetIsolate(), I::kFalseValueRootIndex); +#endif // V8_STATIC_ROOTS_BOOL +} + template void ReturnValue::SetEmptyString() { static_assert(std::is_base_of::value, "type check"); @@ -494,14 +620,6 @@ Isolate* ReturnValue::GetIsolate() const { template Local ReturnValue::Get() const { - using I = internal::Internals; -#if V8_STATIC_ROOTS_BOOL - if (I::is_identical(*value_, I::StaticReadOnlyRoot::kTheHoleValue)) { -#else - if (*value_ == I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex)) { -#endif // V8_STATIC_ROOTS_BOOL - return Undefined(GetIsolate()); - } return Local::New(GetIsolate(), internal::ValueHelper::SlotAsValue(value_)); } @@ -521,7 +639,7 @@ FunctionCallbackInfo::FunctionCallbackInfo(internal::Address* implicit_args, template Local FunctionCallbackInfo::operator[](int i) const { // values_ points to the first argument (not the receiver). - if (i < 0 || length_ <= i) return Undefined(GetIsolate()); + if (i < 0 || Length() <= i) return Undefined(GetIsolate()); return Local::FromSlot(values_ + i); } @@ -532,10 +650,15 @@ Local FunctionCallbackInfo::This() const { } template -Local FunctionCallbackInfo::Holder() const { +Local FunctionCallbackInfo::HolderSoonToBeDeprecated() const { return Local::FromSlot(&implicit_args_[kHolderIndex]); } +template +Local FunctionCallbackInfo::Holder() const { + return HolderSoonToBeDeprecated(); +} + template Local FunctionCallbackInfo::NewTarget() const { return Local::FromSlot(&implicit_args_[kNewTargetIndex]); @@ -543,7 +666,8 @@ Local FunctionCallbackInfo::NewTarget() const { template Local FunctionCallbackInfo::Data() const { - return Local::FromSlot(&implicit_args_[kDataIndex]); + auto target = Local::FromSlot(&implicit_args_[kTargetIndex]); + return api_internal::GetFunctionTemplateData(GetIsolate(), target); } template @@ -563,7 +687,7 @@ bool FunctionCallbackInfo::IsConstructCall() const { template int FunctionCallbackInfo::Length() const { - return length_; + return static_cast(length_); } template @@ -586,6 +710,23 @@ Local PropertyCallbackInfo::Holder() const { return Local::FromSlot(&args_[kHolderIndex]); } +namespace api_internal { +// Returns JSGlobalProxy if holder is JSGlobalObject or unmodified holder +// otherwise. +V8_EXPORT internal::Address ConvertToJSGlobalProxyIfNecessary( + internal::Address holder); +} // namespace api_internal + +template +Local PropertyCallbackInfo::HolderV2() const { + using I = internal::Internals; + if (!I::HasHeapObjectTag(args_[kHolderV2Index])) { + args_[kHolderV2Index] = + api_internal::ConvertToJSGlobalProxyIfNecessary(args_[kHolderIndex]); + } + return Local::FromSlot(&args_[kHolderV2Index]); +} + template ReturnValue PropertyCallbackInfo::GetReturnValue() const { return ReturnValue(&args_[kReturnValueIndex]); @@ -595,8 +736,8 @@ template bool PropertyCallbackInfo::ShouldThrowOnError() const { using I = internal::Internals; if (args_[kShouldThrowOnErrorIndex] != - I::IntToSmi(I::kInferShouldThrowMode)) { - return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(I::kDontThrow); + I::IntegralToSmi(I::kInferShouldThrowMode)) { + return args_[kShouldThrowOnErrorIndex] != I::IntegralToSmi(I::kDontThrow); } return v8::internal::ShouldThrowOnError( reinterpret_cast(GetIsolate())); diff --git a/deps/v8/include/v8-function.h b/deps/v8/include/v8-function.h index 30a9fcfe174acb..50f730f3929fe5 100644 --- a/deps/v8/include/v8-function.h +++ b/deps/v8/include/v8-function.h @@ -59,9 +59,6 @@ class V8_EXPORT Function : public Object { void SetName(Local name); Local GetName() const; - V8_DEPRECATED("No direct replacement") - MaybeLocal GetUnboundScript() const; - /** * Name inferred from variable or property assignment of this function. * Used to facilitate debugging and profiling of JavaScript code written diff --git a/deps/v8/include/v8-initialization.h b/deps/v8/include/v8-initialization.h index d3e35d6ec5f860..c3984668bb1100 100644 --- a/deps/v8/include/v8-initialization.h +++ b/deps/v8/include/v8-initialization.h @@ -52,6 +52,9 @@ using ReturnAddressLocationResolver = using DcheckErrorCallback = void (*)(const char* file, int line, const char* message); +using V8FatalErrorCallback = void (*)(const char* file, int line, + const char* message); + /** * Container class for static utility functions. */ @@ -77,6 +80,12 @@ class V8_EXPORT V8 { /** Set the callback to invoke in case of Dcheck failures. */ static void SetDcheckErrorHandler(DcheckErrorCallback that); + /** Set the callback to invoke in the case of CHECK failures or fatal + * errors. This is distinct from Isolate::SetFatalErrorHandler, which + * is invoked in response to API usage failures. + * */ + static void SetFatalErrorHandler(V8FatalErrorCallback that); + /** * Sets V8 flags from a string. */ @@ -97,10 +106,17 @@ class V8_EXPORT V8 { * is created. It always returns true. */ V8_INLINE static bool Initialize() { +#ifdef V8_TARGET_OS_ANDROID + const bool kV8TargetOsIsAndroid = true; +#else + const bool kV8TargetOsIsAndroid = false; +#endif + const int kBuildConfiguration = (internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) | (internal::SmiValuesAre31Bits() ? k31BitSmis : 0) | - (internal::SandboxIsEnabled() ? kSandbox : 0); + (internal::SandboxIsEnabled() ? kSandbox : 0) | + (kV8TargetOsIsAndroid ? kTargetOsIsAndroid : 0); return Initialize(kBuildConfiguration); } @@ -271,6 +287,7 @@ class V8_EXPORT V8 { kPointerCompression = 1 << 0, k31BitSmis = 1 << 1, kSandbox = 1 << 2, + kTargetOsIsAndroid = 1 << 3, }; /** diff --git a/deps/v8/include/v8-inspector.h b/deps/v8/include/v8-inspector.h index 182b193a0fd700..89bb0bbd539b28 100644 --- a/deps/v8/include/v8-inspector.h +++ b/deps/v8/include/v8-inspector.h @@ -297,9 +297,12 @@ class V8_EXPORT V8InspectorClient { return v8::MaybeLocal(); } - virtual void consoleTime(const StringView& title) {} - virtual void consoleTimeEnd(const StringView& title) {} - virtual void consoleTimeStamp(const StringView& title) {} + virtual void consoleTime(v8::Isolate* isolate, v8::Local label); + virtual void consoleTimeEnd(v8::Isolate* isolate, + v8::Local label); + virtual void consoleTimeStamp(v8::Isolate* isolate, + v8::Local label); + virtual void consoleClear(int contextGroupId) {} virtual double currentTimeMS() { return 0; } typedef void (*TimerCallback)(void*); diff --git a/deps/v8/include/v8-internal.h b/deps/v8/include/v8-internal.h index 322b22d98e8be4..8c385aa10a915b 100644 --- a/deps/v8/include/v8-internal.h +++ b/deps/v8/include/v8-internal.h @@ -11,7 +11,9 @@ #include #include +#include #include +#include #include #include "v8config.h" // NOLINT(build/include_directory) @@ -87,7 +89,10 @@ struct SmiTagging<4> { // Truncate and shift down (requires >> to be sign extending). return static_cast(static_cast(value)) >> shift_bits; } - V8_INLINE static constexpr bool IsValidSmi(intptr_t value) { + + template && + std::is_signed_v>* = nullptr> + V8_INLINE static constexpr bool IsValidSmi(T value) { // Is value in range [kSmiMinValue, kSmiMaxValue]. // Use unsigned operations in order to avoid undefined behaviour in case of // signed integer overflow. @@ -96,6 +101,28 @@ struct SmiTagging<4> { (static_cast(kSmiMaxValue) - static_cast(kSmiMinValue)); } + + template && + std::is_unsigned_v>* = nullptr> + V8_INLINE static constexpr bool IsValidSmi(T value) { + static_assert(kSmiMaxValue <= std::numeric_limits::max()); + return value <= static_cast(kSmiMaxValue); + } + + // Same as the `intptr_t` version but works with int64_t on 32-bit builds + // without slowing down anything else. + V8_INLINE static constexpr bool IsValidSmi(int64_t value) { + return (static_cast(value) - + static_cast(kSmiMinValue)) <= + (static_cast(kSmiMaxValue) - + static_cast(kSmiMinValue)); + } + + V8_INLINE static constexpr bool IsValidSmi(uint64_t value) { + static_assert(kSmiMaxValue <= std::numeric_limits::max()); + return value <= static_cast(kSmiMaxValue); + } }; // Smi constants for systems where tagged pointer is a 64-bit value. @@ -112,10 +139,21 @@ struct SmiTagging<8> { // Shift down and throw away top 32 bits. return static_cast(static_cast(value) >> shift_bits); } - V8_INLINE static constexpr bool IsValidSmi(intptr_t value) { + + template && + std::is_signed_v>* = nullptr> + V8_INLINE static constexpr bool IsValidSmi(T value) { // To be representable as a long smi, the value must be a 32-bit integer. return (value == static_cast(value)); } + + template && + std::is_unsigned_v>* = nullptr> + V8_INLINE static constexpr bool IsValidSmi(T value) { + return (static_cast(value) == + static_cast(static_cast(value))); + } }; #ifdef V8_COMPRESS_POINTERS @@ -253,15 +291,15 @@ static_assert(1ULL << (64 - kBoundedSizeShift) == // size allows omitting bounds checks on table accesses if the indices are // guaranteed (e.g. through shifting) to be below the maximum index. This // value must be a power of two. -constexpr size_t kExternalPointerTableReservationSize = 512 * MB; +constexpr size_t kExternalPointerTableReservationSize = 256 * MB; // The external pointer table indices stored in HeapObjects as external // pointers are shifted to the left by this amount to guarantee that they are // smaller than the maximum table size. -constexpr uint32_t kExternalPointerIndexShift = 6; +constexpr uint32_t kExternalPointerIndexShift = 7; #else -constexpr size_t kExternalPointerTableReservationSize = 1024 * MB; -constexpr uint32_t kExternalPointerIndexShift = 5; +constexpr size_t kExternalPointerTableReservationSize = 512 * MB; +constexpr uint32_t kExternalPointerIndexShift = 6; #endif // V8_TARGET_OS_ANDROID // The maximum number of entries in an external pointer table. @@ -301,6 +339,95 @@ using ExternalPointer_t = Address; constexpr ExternalPointer_t kNullExternalPointer = 0; constexpr ExternalPointerHandle kNullExternalPointerHandle = 0; +// See `ExternalPointerHandle` for the main documentation. The difference to +// `ExternalPointerHandle` is that the handle does not represent an arbitrary +// external pointer but always refers to an object managed by `CppHeap`. The +// handles are using in combination with a dedicated table for `CppHeap` +// references. +using CppHeapPointerHandle = uint32_t; + +// The actual pointer to objects located on the `CppHeap`. When pointer +// compression is enabled these pointers are stored as `CppHeapPointerHandle`. +// In non-compressed configurations the pointers are simply stored as raw +// pointers. +#ifdef V8_COMPRESS_POINTERS +using CppHeapPointer_t = CppHeapPointerHandle; +#else +using CppHeapPointer_t = Address; +#endif + +constexpr CppHeapPointer_t kNullCppHeapPointer = 0; +constexpr CppHeapPointerHandle kNullCppHeapPointerHandle = 0; + +constexpr uint64_t kCppHeapPointerMarkBit = 1ULL; +constexpr uint64_t kCppHeapPointerTagShift = 1; +constexpr uint64_t kCppHeapPointerPayloadShift = 16; + +#ifdef V8_COMPRESS_POINTERS +// CppHeapPointers use a dedicated pointer table. These constants control the +// size and layout of the table. See the corresponding constants for the +// external pointer table for further details. +constexpr size_t kCppHeapPointerTableReservationSize = + kExternalPointerTableReservationSize; +constexpr uint32_t kCppHeapPointerIndexShift = kExternalPointerIndexShift; + +constexpr int kCppHeapPointerTableEntrySize = 8; +constexpr int kCppHeapPointerTableEntrySizeLog2 = 3; +constexpr size_t kMaxCppHeapPointers = + kCppHeapPointerTableReservationSize / kCppHeapPointerTableEntrySize; +static_assert((1 << (32 - kCppHeapPointerIndexShift)) == kMaxCppHeapPointers, + "kCppHeapPointerTableReservationSize and " + "kCppHeapPointerIndexShift don't match"); + +#else // !V8_COMPRESS_POINTERS + +// Needed for the V8.SandboxedCppHeapPointersCount histogram. +constexpr size_t kMaxCppHeapPointers = 0; + +#endif // V8_COMPRESS_POINTERS + +// See `ExternalPointerHandle` for the main documentation. The difference to +// `ExternalPointerHandle` is that the handle always refers to a +// (external pointer, size) tuple. The handles are used in combination with a +// dedicated external buffer table (EBT). +using ExternalBufferHandle = uint32_t; + +// ExternalBuffer point to buffer located outside the sandbox. When the V8 +// sandbox is enabled, these are stored on heap as ExternalBufferHandles, +// otherwise they are simply raw pointers. +#ifdef V8_ENABLE_SANDBOX +using ExternalBuffer_t = ExternalBufferHandle; +#else +using ExternalBuffer_t = Address; +#endif + +#ifdef V8_TARGET_OS_ANDROID +// The size of the virtual memory reservation for the external buffer table. +// As with the external pointer table, a maximum table size in combination with +// shifted indices allows omitting bounds checks. +constexpr size_t kExternalBufferTableReservationSize = 64 * MB; + +// The external buffer handles are stores shifted to the left by this amount +// to guarantee that they are smaller than the maximum table size. +constexpr uint32_t kExternalBufferHandleShift = 10; +#else +constexpr size_t kExternalBufferTableReservationSize = 128 * MB; +constexpr uint32_t kExternalBufferHandleShift = 9; +#endif // V8_TARGET_OS_ANDROID + +// A null handle always references an entry that contains nullptr. +constexpr ExternalBufferHandle kNullExternalBufferHandle = 0; + +// The maximum number of entries in an external buffer table. +constexpr int kExternalBufferTableEntrySize = 16; +constexpr int kExternalBufferTableEntrySizeLog2 = 4; +constexpr size_t kMaxExternalBufferPointers = + kExternalBufferTableReservationSize / kExternalBufferTableEntrySize; +static_assert((1 << (32 - kExternalBufferHandleShift)) == + kMaxExternalBufferPointers, + "kExternalBufferTableReservationSize and " + "kExternalBufferHandleShift don't match"); + // // External Pointers. // @@ -365,7 +492,7 @@ constexpr ExternalPointerHandle kNullExternalPointerHandle = 0; // extension (MTE) which would use bits [56, 60). // // External pointer tables are also available even when the sandbox is off but -// pointer compression is on. In that case, the mechanism can be used to easy +// pointer compression is on. In that case, the mechanism can be used to ease // alignment requirements as it turns unaligned 64-bit raw pointers into // aligned 32-bit indices. To "opt-in" to the external pointer table mechanism // for this purpose, instead of using the ExternalPointer accessors one needs to @@ -380,7 +507,7 @@ constexpr uint64_t kExternalPointerTagShift = 48; // These are sorted so that tags can be grouped together and it can efficiently // be checked if a tag belongs to a given group. See for example the // IsSharedExternalPointerType routine. -constexpr uint64_t kAllExternalPointerTypeTags[] = { +constexpr uint64_t kAllTagsForAndBasedTypeChecking[] = { 0b00001111, 0b00010111, 0b00011011, 0b00011101, 0b00011110, 0b00100111, 0b00101011, 0b00101101, 0b00101110, 0b00110011, 0b00110101, 0b00110110, 0b00111001, 0b00111010, 0b00111100, 0b01000111, 0b01001011, 0b01001101, @@ -394,8 +521,8 @@ constexpr uint64_t kAllExternalPointerTypeTags[] = { 0b11001100, 0b11010001, 0b11010010, 0b11010100, 0b11011000, 0b11100001, 0b11100010, 0b11100100, 0b11101000, 0b11110000}; -#define TAG(i) \ - ((kAllExternalPointerTypeTags[i] << kExternalPointerTagShift) | \ +#define TAG(i) \ + ((kAllTagsForAndBasedTypeChecking[i] << kExternalPointerTagShift) | \ kExternalPointerMarkBit) // clang-format off @@ -414,26 +541,73 @@ constexpr uint64_t kAllExternalPointerTypeTags[] = { V(kExternalStringResourceTag, TAG(1)) \ V(kExternalStringResourceDataTag, TAG(2)) \ V(kLastSharedTag, TAG(2)) + // Leave some space in the tag range here for future shared tags. // External pointers using these tags are kept in a per-Isolate external // pointer table and can only be accessed when this Isolate is active. #define PER_ISOLATE_EXTERNAL_POINTER_TAGS(V) \ - V(kForeignForeignAddressTag, TAG(10)) \ - V(kNativeContextMicrotaskQueueTag, TAG(11)) \ - V(kEmbedderDataSlotPayloadTag, TAG(12)) \ + V(kNativeContextMicrotaskQueueTag, TAG(5)) \ + V(kEmbedderDataSlotPayloadTag, TAG(6)) \ /* This tag essentially stands for a `void*` pointer in the V8 API, and */ \ /* it is the Embedder's responsibility to ensure type safety (against */ \ /* substitution) and lifetime validity of these objects. */ \ - V(kExternalObjectValueTag, TAG(13)) \ - V(kFunctionTemplateInfoCallbackTag, TAG(14)) \ - V(kAccessorInfoGetterTag, TAG(15)) \ - V(kAccessorInfoSetterTag, TAG(16)) \ - V(kWasmInternalFunctionCallTargetTag, TAG(17)) \ - V(kWasmTypeInfoNativeTypeTag, TAG(18)) \ - V(kWasmExportedFunctionDataSignatureTag, TAG(19)) \ - V(kWasmContinuationJmpbufTag, TAG(20)) \ - V(kWasmIndirectFunctionTargetTag, TAG(21)) \ - V(kArrayBufferExtensionTag, TAG(22)) + V(kExternalObjectValueTag, TAG(7)) \ + V(kFunctionTemplateInfoCallbackTag, TAG(8)) \ + V(kAccessorInfoGetterTag, TAG(9)) \ + V(kAccessorInfoSetterTag, TAG(10)) \ + V(kWasmInternalFunctionCallTargetTag, TAG(11)) \ + V(kWasmTypeInfoNativeTypeTag, TAG(12)) \ + V(kWasmExportedFunctionDataSignatureTag, TAG(13)) \ + V(kWasmContinuationJmpbufTag, TAG(14)) \ + V(kWasmStackMemoryTag, TAG(15)) \ + V(kWasmIndirectFunctionTargetTag, TAG(16)) \ + /* Foreigns */ \ + V(kGenericForeignTag, TAG(20)) \ + V(kApiNamedPropertyQueryCallbackTag, TAG(21)) \ + V(kApiNamedPropertyGetterCallbackTag, TAG(22)) \ + V(kApiNamedPropertySetterCallbackTag, TAG(23)) \ + V(kApiNamedPropertyDescriptorCallbackTag, TAG(24)) \ + V(kApiNamedPropertyDefinerCallbackTag, TAG(25)) \ + V(kApiNamedPropertyDeleterCallbackTag, TAG(26)) \ + V(kApiIndexedPropertyQueryCallbackTag, TAG(27)) \ + V(kApiIndexedPropertyGetterCallbackTag, TAG(28)) \ + V(kApiIndexedPropertySetterCallbackTag, TAG(29)) \ + V(kApiIndexedPropertyDescriptorCallbackTag, TAG(30)) \ + V(kApiIndexedPropertyDefinerCallbackTag, TAG(31)) \ + V(kApiIndexedPropertyDeleterCallbackTag, TAG(32)) \ + V(kApiIndexedPropertyEnumeratorCallbackTag, TAG(33)) \ + V(kApiAccessCheckCallbackTag, TAG(34)) \ + V(kApiAbortScriptExecutionCallbackTag, TAG(35)) \ + V(kSyntheticModuleTag, TAG(36)) \ + V(kMicrotaskCallbackTag, TAG(37)) \ + V(kMicrotaskCallbackDataTag, TAG(38)) \ + V(kCFunctionTag, TAG(39)) \ + V(kCFunctionInfoTag, TAG(40)) \ + V(kMessageListenerTag, TAG(41)) \ + V(kWaiterQueueForeignTag, TAG(42)) \ + /* Managed */ \ + V(kFirstManagedResourceTag, TAG(50)) \ + V(kGenericManagedTag, TAG(50)) \ + V(kWasmWasmStreamingTag, TAG(51)) \ + V(kWasmFuncDataTag, TAG(52)) \ + V(kWasmManagedDataTag, TAG(53)) \ + V(kWasmNativeModuleTag, TAG(54)) \ + V(kIcuBreakIteratorTag, TAG(55)) \ + V(kIcuUnicodeStringTag, TAG(56)) \ + V(kIcuListFormatterTag, TAG(57)) \ + V(kIcuLocaleTag, TAG(58)) \ + V(kIcuSimpleDateFormatTag, TAG(59)) \ + V(kIcuDateIntervalFormatTag, TAG(60)) \ + V(kIcuRelativeDateTimeFormatterTag, TAG(61)) \ + V(kIcuLocalizedNumberFormatterTag, TAG(62)) \ + V(kIcuPluralRulesTag, TAG(63)) \ + V(kIcuCollatorTag, TAG(64)) \ + V(kDisplayNamesInternalTag, TAG(65)) \ + /* External resources whose lifetime is tied to */ \ + /* their entry in the external pointer table but */ \ + /* which are not referenced via a Managed */ \ + V(kArrayBufferExtensionTag, TAG(66)) \ + V(kLastManagedResourceTag, TAG(66)) \ // All external pointer tags. #define ALL_EXTERNAL_POINTER_TAGS(V) \ @@ -449,12 +623,18 @@ enum ExternalPointerTag : uint64_t { kExternalPointerNullTag = MAKE_TAG(1, 0b00000000), // External pointer tag that will match any external pointer. Use with care! kAnyExternalPointerTag = MAKE_TAG(1, 0b11111111), + // External pointer tag that will match any external pointer in a Foreign. + // Use with care! If desired, this could be made more fine-granular. + kAnyForeignTag = kAnyExternalPointerTag, // The free entry tag has all type bits set so every type check with a // different type fails. It also doesn't have the mark bit set as free // entries are (by definition) not alive. kExternalPointerFreeEntryTag = MAKE_TAG(0, 0b11111111), // Evacuation entries are used during external pointer table compaction. - kExternalPointerEvacuationEntryTag = MAKE_TAG(1, 0b11100111), + kExternalPointerEvacuationEntryTag = MAKE_TAG(1, 0b11111110), + // Tag for zapped/invalidated entries. Those are considered to no longer be + // in use and so have the marking bit cleared. + kExternalPointerZappedEntryTag = MAKE_TAG(0, 0b11111101), ALL_EXTERNAL_POINTER_TAGS(EXTERNAL_POINTER_TAG_ENUM) }; @@ -481,6 +661,15 @@ V8_INLINE static constexpr bool IsMaybeReadOnlyExternalPointerType( tag == kFunctionTemplateInfoCallbackTag; } +// True if the external pointer references an external object whose lifetime is +// tied to the entry in the external pointer table. +// In this case, the entry in the ExternalPointerTable always points to an +// object derived from ExternalPointerTable::ManagedResource. +V8_INLINE static constexpr bool IsManagedExternalPointerType( + ExternalPointerTag tag) { + return tag >= kFirstManagedResourceTag && tag <= kLastManagedResourceTag; +} + // Sanity checks. #define CHECK_SHARED_EXTERNAL_POINTER_TAGS(Tag, ...) \ static_assert(IsSharedExternalPointerType(Tag)); @@ -576,11 +765,11 @@ using CodePointerHandle = IndirectPointerHandle; // The size of the virtual memory reservation for the code pointer table. // As with the other tables, a maximum table size in combination with shifted // indices allows omitting bounds checks. -constexpr size_t kCodePointerTableReservationSize = 16 * MB; +constexpr size_t kCodePointerTableReservationSize = 128 * MB; // Code pointer handles are shifted by a different amount than indirect pointer // handles as the tables have a different maximum size. -constexpr uint32_t kCodePointerHandleShift = 12; +constexpr uint32_t kCodePointerHandleShift = 9; // A null handle always references an entry that contains nullptr. constexpr CodePointerHandle kNullCodePointerHandle = kNullIndirectPointerHandle; @@ -616,6 +805,29 @@ constexpr bool kAllCodeObjectsLiveInTrustedSpace = kRuntimeGeneratedCodeObjectsLiveInTrustedSpace && kBuiltinCodeObjectsLiveInTrustedSpace; +// +// JavaScript Dispatch Table +// +// A JSDispatchHandle represents a 32-bit index into a JSDispatchTable. +using JSDispatchHandle = uint32_t; + +constexpr JSDispatchHandle kNullJSDispatchHandle = 0; + +// The size of the virtual memory reservation for the JSDispatchTable. +// As with the other tables, a maximum table size in combination with shifted +// indices allows omitting bounds checks. +constexpr size_t kJSDispatchTableReservationSize = 128 * MB; +constexpr uint32_t kJSDispatchHandleShift = 9; + +// The maximum number of entries in a JSDispatchTable. +constexpr int kJSDispatchTableEntrySize = 16; +constexpr int kJSDispatchTableEntrySizeLog2 = 4; +constexpr size_t kMaxJSDispatchEntries = + kJSDispatchTableReservationSize / kJSDispatchTableEntrySize; +static_assert((1 << (32 - kJSDispatchHandleShift)) == kMaxJSDispatchEntries, + "kJSDispatchTableReservationSize and kJSDispatchEntryHandleShift " + "don't match"); + // {obj} must be the raw tagged pointer representation of a HeapObject // that's guaranteed to never be in ReadOnlySpace. V8_EXPORT internal::Isolate* IsolateFromNeverReadOnlySpaceObject(Address obj); @@ -647,6 +859,13 @@ class Internals { static const int kOddballKindOffset = 4 * kApiTaggedSize + kApiDoubleSize; static const int kJSObjectHeaderSize = 3 * kApiTaggedSize; +#ifdef V8_COMPRESS_POINTERS + static const int kJSAPIObjectWithEmbedderSlotsHeaderSize = + kJSObjectHeaderSize + kApiInt32Size; +#else // !V8_COMPRESS_POINTERS + static const int kJSAPIObjectWithEmbedderSlotsHeaderSize = + kJSObjectHeaderSize + kApiTaggedSize; +#endif // !V8_COMPRESS_POINTERS static const int kFixedArrayHeaderSize = 2 * kApiTaggedSize; static const int kEmbedderDataArrayHeaderSize = 2 * kApiTaggedSize; static const int kEmbedderDataSlotSize = kApiSystemPointerSize; @@ -676,6 +895,7 @@ class Internals { // ExternalPointerTable and TrustedPointerTable layout guarantees. static const int kExternalPointerTableBasePointerOffset = 0; static const int kExternalPointerTableSize = 2 * kApiSystemPointerSize; + static const int kExternalBufferTableSize = 2 * kApiSystemPointerSize; static const int kTrustedPointerTableSize = 2 * kApiSystemPointerSize; static const int kTrustedPointerTableBasePointerOffset = 0; @@ -719,16 +939,22 @@ class Internals { kIsolateEmbedderDataOffset + kNumIsolateDataSlots * kApiSystemPointerSize; static const int kIsolateSharedExternalPointerTableAddressOffset = kIsolateExternalPointerTableOffset + kExternalPointerTableSize; + static const int kIsolateCppHeapPointerTableOffset = + kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize; #ifdef V8_ENABLE_SANDBOX static const int kIsolateTrustedCageBaseOffset = - kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize; + kIsolateCppHeapPointerTableOffset + kExternalPointerTableSize; static const int kIsolateTrustedPointerTableOffset = kIsolateTrustedCageBaseOffset + kApiSystemPointerSize; - static const int kIsolateApiCallbackThunkArgumentOffset = + static const int kIsolateExternalBufferTableOffset = kIsolateTrustedPointerTableOffset + kTrustedPointerTableSize; + static const int kIsolateSharedExternalBufferTableAddressOffset = + kIsolateExternalBufferTableOffset + kExternalBufferTableSize; + static const int kIsolateApiCallbackThunkArgumentOffset = + kIsolateSharedExternalBufferTableAddressOffset + kApiSystemPointerSize; #else static const int kIsolateApiCallbackThunkArgumentOffset = - kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize; + kIsolateCppHeapPointerTableOffset + kExternalPointerTableSize; #endif // V8_ENABLE_SANDBOX #else static const int kIsolateApiCallbackThunkArgumentOffset = @@ -736,13 +962,12 @@ class Internals { #endif // V8_COMPRESS_POINTERS static const int kContinuationPreservedEmbedderDataOffset = kIsolateApiCallbackThunkArgumentOffset + kApiSystemPointerSize; - - static const int kWasm64OOBOffsetAlignmentPaddingSize = 0; - static const int kWasm64OOBOffsetOffset = - kContinuationPreservedEmbedderDataOffset + kApiSystemPointerSize + - kWasm64OOBOffsetAlignmentPaddingSize; static const int kIsolateRootsOffset = - kWasm64OOBOffsetOffset + sizeof(int64_t); + kContinuationPreservedEmbedderDataOffset + kApiSystemPointerSize; + + // Assert scopes + static const int kDisallowGarbageCollectionAlign = alignof(uint32_t); + static const int kDisallowGarbageCollectionSize = sizeof(uint32_t); #if V8_STATIC_ROOTS_BOOL @@ -753,7 +978,7 @@ class Internals { V(TrueValue, 0xc9) \ V(FalseValue, 0xad) \ V(EmptyString, 0xa1) \ - V(TheHoleValue, 0x719) + V(TheHoleValue, 0x741) using Tagged_t = uint32_t; struct StaticReadOnlyRoot { @@ -802,8 +1027,8 @@ class Internals { // Constants used by PropertyCallbackInfo to check if we should throw when an // error occurs. - static const int kThrowOnError = 0; - static const int kDontThrow = 1; + static const int kDontThrow = 0; + static const int kThrowOnError = 1; static const int kInferShouldThrowMode = 2; // Soft limit for AdjustAmountofExternalAllocatedMemory. Trigger an @@ -836,14 +1061,36 @@ class Internals { return PlatformSmiTagging::SmiToInt(value); } + V8_INLINE static constexpr Address AddressToSmi(Address value) { + return (value << (kSmiTagSize + PlatformSmiTagging::kSmiShiftSize)) | + kSmiTag; + } + V8_INLINE static constexpr Address IntToSmi(int value) { - return internal::IntToSmi(value); + return AddressToSmi(static_cast
(value)); + } + + template >* = nullptr> + V8_INLINE static constexpr Address IntegralToSmi(T value) { + return AddressToSmi(static_cast
(value)); } - V8_INLINE static constexpr bool IsValidSmi(intptr_t value) { + template >* = nullptr> + V8_INLINE static constexpr bool IsValidSmi(T value) { return PlatformSmiTagging::IsValidSmi(value); } + template >* = nullptr> + static constexpr std::optional
TryIntegralToSmi(T value) { + if (V8_LIKELY(PlatformSmiTagging::IsValidSmi(value))) { + return {AddressToSmi(static_cast
(value))}; + } + return {}; + } + #if V8_STATIC_ROOTS_BOOL V8_INLINE static bool is_identical(Address obj, Tagged_t constant) { return static_cast(obj) == constant; @@ -1116,7 +1363,7 @@ class V8_EXPORT StrongRootAllocatorBase { protected: explicit StrongRootAllocatorBase(Heap* heap) : heap_(heap) {} - explicit StrongRootAllocatorBase(v8::Isolate* isolate); + explicit StrongRootAllocatorBase(Isolate* isolate); // Allocate/deallocate a range of n elements of type internal::Address. Address* allocate_impl(size_t n); @@ -1132,17 +1379,15 @@ class V8_EXPORT StrongRootAllocatorBase { // and internal::StrongRootAllocator> register the allocated range // as strong roots. template -class StrongRootAllocator : public StrongRootAllocatorBase, - private std::allocator { +class StrongRootAllocator : private std::allocator { public: using value_type = T; - explicit StrongRootAllocator(Heap* heap) : StrongRootAllocatorBase(heap) {} - explicit StrongRootAllocator(v8::Isolate* isolate) - : StrongRootAllocatorBase(isolate) {} + explicit StrongRootAllocator(Heap* heap) {} + explicit StrongRootAllocator(Isolate* isolate) {} + explicit StrongRootAllocator(v8::Isolate* isolate) {} template - StrongRootAllocator(const StrongRootAllocator& other) noexcept - : StrongRootAllocatorBase(other) {} + StrongRootAllocator(const StrongRootAllocator& other) noexcept {} using std::allocator::allocate; using std::allocator::deallocate; @@ -1383,14 +1628,17 @@ class HandleHelper final { if (rhs.IsEmpty()) return false; return lhs.ptr() == rhs.ptr(); } - - static V8_EXPORT bool IsOnStack(const void* ptr); - static V8_EXPORT void VerifyOnStack(const void* ptr); - static V8_EXPORT void VerifyOnMainThread(); }; V8_EXPORT void VerifyHandleIsNonEmpty(bool is_empty); +// These functions are here just to match friend declarations in +// XxxCallbackInfo classes allowing these functions to access the internals +// of the info objects. These functions are supposed to be called by debugger +// macros. +void PrintFunctionCallbackInfo(void* function_callback_info); +void PrintPropertyCallbackInfo(void* property_callback_info); + } // namespace internal } // namespace v8 diff --git a/deps/v8/include/v8-isolate.h b/deps/v8/include/v8-isolate.h index 585b513fac446a..17c107766b9045 100644 --- a/deps/v8/include/v8-isolate.h +++ b/deps/v8/include/v8-isolate.h @@ -17,6 +17,7 @@ #include "v8-data.h" // NOLINT(build/include_directory) #include "v8-debug.h" // NOLINT(build/include_directory) #include "v8-embedder-heap.h" // NOLINT(build/include_directory) +#include "v8-exception.h" // NOLINT(build/include_directory) #include "v8-function-callback.h" // NOLINT(build/include_directory) #include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) @@ -276,11 +277,6 @@ class V8_EXPORT Isolate { */ bool allow_atomics_wait = true; - /** - * Termination is postponed when there is no active SafeForTerminationScope. - */ - bool only_terminate_in_safe_scope = false; - /** * The following parameters describe the offsets for addressing type info * for wrapped API objects and are used by the fast C API @@ -389,21 +385,6 @@ class V8_EXPORT Isolate { friend class internal::ThreadLocalTop; }; - /** - * This scope allows terminations inside direct V8 API calls and forbid them - * inside any recursive API calls without explicit SafeForTerminationScope. - */ - class V8_EXPORT V8_NODISCARD SafeForTerminationScope { - public: - V8_DEPRECATE_SOON("All code should be safe for termination") - explicit SafeForTerminationScope(v8::Isolate* v8_isolate) {} - ~SafeForTerminationScope() {} - - // Prevent copying of Scope objects. - SafeForTerminationScope(const SafeForTerminationScope&) = delete; - SafeForTerminationScope& operator=(const SafeForTerminationScope&) = delete; - }; - /** * Types of garbage collections that can be requested via * RequestGarbageCollectionForTesting. @@ -563,6 +544,9 @@ class V8_EXPORT Isolate { kWasmExnRef = 138, kWasmTypedFuncRef = 139, kInvalidatedStringWrapperToPrimitiveProtector = 140, + kDocumentAllLegacyCall = 141, + kDocumentAllLegacyConstruct = 142, + kConsoleContext = 143, // If you add new values here, you'll also need to update Chromium's: // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to @@ -580,6 +564,21 @@ class V8_EXPORT Isolate { kMessageWarning, }; + // The different priorities that an isolate can have. + enum class Priority { + // The isolate does not relate to content that is currently important + // to the user. Lowest priority. + kBestEffort, + + // The isolate contributes to content that is visible to the user, like a + // visible iframe that's not interacted directly with. High priority. + kUserVisible, + + // The isolate contributes to content that is of the utmost importance to + // the user, like visible content in the focused window. Highest priority. + kUserBlocking, + }; + using UseCounterCallback = void (*)(Isolate* isolate, UseCounterFeature feature); @@ -691,6 +690,11 @@ class V8_EXPORT Isolate { */ void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback); + /** + * Get the stackTraceLimit property of Error. + */ + int GetStackTraceLimit(); + #if defined(V8_OS_WIN) /** * This specifies the callback called when an ETW tracing session starts. @@ -1273,6 +1277,15 @@ class V8_EXPORT Isolate { */ void SetPromiseRejectCallback(PromiseRejectCallback callback); + /** + * This is a part of experimental Api and might be changed without further + * notice. + * Do not use it. + * + * Set callback to notify about a new exception being thrown. + */ + void SetExceptionPropagationCallback(ExceptionPropagationCallback callback); + /** * Runs the default MicrotaskQueue until it gets empty and perform other * microtask checkpoint steps, such as calling ClearKeptObjects. Asserts that @@ -1362,24 +1375,6 @@ class V8_EXPORT Isolate { */ void SetAddCrashKeyCallback(AddCrashKeyCallback); - /** - * Optional notification that the embedder is idle. - * V8 uses the notification to perform garbage collection. - * This call can be used repeatedly if the embedder remains idle. - * Returns true if the embedder should stop calling IdleNotificationDeadline - * until real work has been done. This indicates that V8 has done - * as much cleanup as it will be able to do. - * - * The deadline_in_seconds argument specifies the deadline V8 has to finish - * garbage collection work. deadline_in_seconds is compared with - * MonotonicallyIncreasingTime() and should be based on the same timebase as - * that function. There is no guarantee that the actual work will be done - * within the time limit. - */ - V8_DEPRECATE_SOON( - "Use MemoryPressureNotification() to influence the GC schedule.") - bool IdleNotificationDeadline(double deadline_in_seconds); - /** * Optional notification that the system is running low on memory. * V8 uses these notifications to attempt to free memory. @@ -1401,14 +1396,22 @@ class V8_EXPORT Isolate { * Optional notification that the isolate switched to the foreground. * V8 uses these notifications to guide heuristics. */ + V8_DEPRECATE_SOON("Use SetPriority(Priority::kUserBlocking) instead") void IsolateInForegroundNotification(); /** * Optional notification that the isolate switched to the background. * V8 uses these notifications to guide heuristics. */ + V8_DEPRECATE_SOON("Use SetPriority(Priority::kBestEffort) instead") void IsolateInBackgroundNotification(); + /** + * Optional notification that the isolate changed `priority`. + * V8 uses the priority value to guide heuristics. + */ + void SetPriority(Priority priority); + /** * Optional notification to tell V8 the current performance requirements * of the embedder based on RAIL. @@ -1592,6 +1595,9 @@ class V8_EXPORT Isolate { * Register callback to control whether compile hints magic comments are * enabled. */ + V8_DEPRECATED( + "Will be removed, use ScriptCompiler::CompileOptions for enabling the " + "compile hints magic comments") void SetJavaScriptCompileHintsMagicEnabledCallback( JavaScriptCompileHintsMagicEnabledCallback callback); @@ -1656,7 +1662,7 @@ class V8_EXPORT Isolate { * heap. GC is not invoked prior to iterating, therefore there is no * guarantee that visited objects are still alive. */ - V8_DEPRECATE_SOON("Will be removed without replacement. crbug.com/v8/14172") + V8_DEPRECATED("Will be removed without replacement. crbug.com/v8/14172") void VisitExternalResources(ExternalResourceVisitor* visitor); /** diff --git a/deps/v8/include/v8-local-handle.h b/deps/v8/include/v8-local-handle.h index fd543ae3aaa4fa..98feeeba76d47a 100644 --- a/deps/v8/include/v8-local-handle.h +++ b/deps/v8/include/v8-local-handle.h @@ -51,8 +51,6 @@ class Isolate; class Object; template class PersistentValueMapBase; -template -class PersistentValueVector; class Primitive; class Private; template @@ -382,8 +380,6 @@ class V8_TRIVIAL_ABI Local : public LocalBase, friend class InternalEscapableScope; template friend class PersistentValueMapBase; - template - friend class PersistentValueVector; template friend class ReturnValue; template @@ -439,12 +435,12 @@ class V8_TRIVIAL_ABI LocalUnchecked : public Local { // In this case, the check is also enforced in the copy constructor and we // need to suppress it. LocalUnchecked(const LocalUnchecked& other) - : Local(other, Local::do_not_check) {} - LocalUnchecked& operator=(const LocalUnchecked&) = default; + : Local(other, Local::do_not_check) noexcept {} + LocalUnchecked& operator=(const LocalUnchecked&) noexcept = default; #endif // Implicit conversion from Local. - LocalUnchecked(const Local& other) // NOLINT(runtime/explicit) + LocalUnchecked(const Local& other) noexcept // NOLINT(runtime/explicit) : Local(other, Local::do_not_check) {} }; @@ -460,8 +456,10 @@ class StrongRootAllocator> : public StrongRootAllocatorBase { static_assert(sizeof(value_type) == sizeof(Address)); explicit StrongRootAllocator(Heap* heap) : StrongRootAllocatorBase(heap) {} - explicit StrongRootAllocator(v8::Isolate* isolate) + explicit StrongRootAllocator(Isolate* isolate) : StrongRootAllocatorBase(isolate) {} + explicit StrongRootAllocator(v8::Isolate* isolate) + : StrongRootAllocatorBase(reinterpret_cast(isolate)) {} template StrongRootAllocator(const StrongRootAllocator& other) noexcept : StrongRootAllocatorBase(other) {} @@ -560,6 +558,7 @@ class LocalVector { LocalVector& operator=(std::initializer_list> init) { backing_.clear(); + backing_.reserve(init.size()); backing_.insert(backing_.end(), init.begin(), init.end()); return *this; } diff --git a/deps/v8/include/v8-message.h b/deps/v8/include/v8-message.h index 8f49a06dfa8080..9f933358792f0d 100644 --- a/deps/v8/include/v8-message.h +++ b/deps/v8/include/v8-message.h @@ -61,27 +61,6 @@ class ScriptOriginOptions { */ class V8_EXPORT ScriptOrigin { public: - V8_DEPRECATE_SOON("Use constructor without the isolate.") - V8_INLINE ScriptOrigin(Isolate* isolate, Local resource_name, - int resource_line_offset = 0, - int resource_column_offset = 0, - bool resource_is_shared_cross_origin = false, - int script_id = -1, - Local source_map_url = Local(), - bool resource_is_opaque = false, bool is_wasm = false, - bool is_module = false, - Local host_defined_options = Local()) - : resource_name_(resource_name), - resource_line_offset_(resource_line_offset), - resource_column_offset_(resource_column_offset), - options_(resource_is_shared_cross_origin, resource_is_opaque, is_wasm, - is_module), - script_id_(script_id), - source_map_url_(source_map_url), - host_defined_options_(host_defined_options) { - VerifyHostDefinedOptions(); - } - V8_INLINE ScriptOrigin(Local resource_name, int resource_line_offset = 0, int resource_column_offset = 0, diff --git a/deps/v8/include/v8-metrics.h b/deps/v8/include/v8-metrics.h index 46bc4679c5c83f..9e77744bb29d68 100644 --- a/deps/v8/include/v8-metrics.h +++ b/deps/v8/include/v8-metrics.h @@ -55,6 +55,10 @@ struct GarbageCollectionFullCycle { double efficiency_cpp_in_bytes_per_us = -1.0; double main_thread_efficiency_in_bytes_per_us = -1.0; double main_thread_efficiency_cpp_in_bytes_per_us = -1.0; + double collection_weight_in_percent = -1.0; + double collection_weight_cpp_in_percent = -1.0; + double main_thread_collection_weight_in_percent = -1.0; + double main_thread_collection_weight_cpp_in_percent = -1.0; int64_t incremental_marking_start_stop_wall_clock_duration_in_us = -1; }; diff --git a/deps/v8/include/v8-microtask-queue.h b/deps/v8/include/v8-microtask-queue.h index 85d227fa3fdce6..135dfb06a3bdd1 100644 --- a/deps/v8/include/v8-microtask-queue.h +++ b/deps/v8/include/v8-microtask-queue.h @@ -118,11 +118,6 @@ class V8_EXPORT V8_NODISCARD MicrotasksScope { public: enum Type { kRunMicrotasks, kDoNotRunMicrotasks }; - V8_DEPRECATE_SOON( - "May be incorrect if context was created with non-default microtask " - "queue") - MicrotasksScope(Isolate* isolate, Type type); - MicrotasksScope(Local context, Type type); MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type); ~MicrotasksScope(); diff --git a/deps/v8/include/v8-object.h b/deps/v8/include/v8-object.h index 6cdf53b19c7d05..d03b33acd7c83e 100644 --- a/deps/v8/include/v8-object.h +++ b/deps/v8/include/v8-object.h @@ -5,10 +5,12 @@ #ifndef INCLUDE_V8_OBJECT_H_ #define INCLUDE_V8_OBJECT_H_ +#include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-maybe.h" // NOLINT(build/include_directory) #include "v8-persistent-handle.h" // NOLINT(build/include_directory) #include "v8-primitive.h" // NOLINT(build/include_directory) +#include "v8-sandbox.h" // NOLINT(build/include_directory) #include "v8-traced-handle.h" // NOLINT(build/include_directory) #include "v8-value.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) @@ -146,18 +148,13 @@ enum PropertyAttribute { }; /** - * Accessor[Getter|Setter] are used as callback functions when - * setting|getting a particular property. See Object and ObjectTemplate's - * method SetAccessor. + * Accessor[Getter|Setter] are used as callback functions when setting|getting + * a particular data property. See Object::SetNativeDataProperty and + * ObjectTemplate::SetNativeDataProperty methods. */ -using AccessorGetterCallback = - void (*)(Local property, const PropertyCallbackInfo& info); using AccessorNameGetterCallback = void (*)(Local property, const PropertyCallbackInfo& info); -using AccessorSetterCallback = void (*)(Local property, - Local value, - const PropertyCallbackInfo& info); using AccessorNameSetterCallback = void (*)(Local property, Local value, const PropertyCallbackInfo& info); @@ -170,9 +167,11 @@ using AccessorNameSetterCallback = * the kind of cross-context access that should be allowed. * */ -enum AccessControl { - DEFAULT = 0, -}; +enum V8_DEPRECATE_SOON( + "This enum is no longer used and will be removed in V8 12.9.") + AccessControl { + DEFAULT V8_ENUM_DEPRECATE_SOON("not used") = 0, + }; /** * Property filter bits. They can be or'ed to build a composite filter. @@ -239,6 +238,9 @@ class V8_EXPORT Object : public Value { */ V8_WARN_UNUSED_RESULT Maybe Set(Local context, Local key, Local value); + V8_WARN_UNUSED_RESULT Maybe Set(Local context, + Local key, Local value, + MaybeLocal receiver); V8_WARN_UNUSED_RESULT Maybe Set(Local context, uint32_t index, Local value); @@ -294,6 +296,9 @@ class V8_EXPORT Object : public Value { V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, Local key); + V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, + Local key, + MaybeLocal receiver); V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, uint32_t index); @@ -339,17 +344,10 @@ class V8_EXPORT Object : public Value { V8_WARN_UNUSED_RESULT Maybe Delete(Local context, uint32_t index); - V8_DEPRECATE_SOON("Use SetNativeDataProperty instead") - V8_WARN_UNUSED_RESULT Maybe SetAccessor( - Local context, Local name, - AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter = nullptr, - MaybeLocal data = MaybeLocal(), - AccessControl deprecated_settings = DEFAULT, - PropertyAttribute attribute = None, - SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, - SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); - + /** + * Sets an accessor property like Template::SetAccessorProperty, but + * this method sets on this object directly. + */ void SetAccessorProperty(Local name, Local getter, Local setter = Local(), PropertyAttribute attributes = None); @@ -429,16 +427,41 @@ class V8_EXPORT Object : public Value { * be skipped by __proto__ and it does not consult the security * handler. */ + V8_DEPRECATE_SOON( + "V8 will stop providing access to hidden prototype (i.e. " + "JSGlobalObject). Use GetPrototypeV2() instead. " + "See http://crbug.com/333672197.") Local GetPrototype(); + /** + * Get the prototype object (same as getting __proto__ property). This does + * not consult the security handler. + * TODO(333672197): rename back to GetPrototype() once the old version goes + * through the deprecation process and is removed. + */ + Local GetPrototypeV2(); + /** * Set the prototype object. This does not skip objects marked to * be skipped by __proto__ and it does not consult the security * handler. */ + V8_DEPRECATE_SOON( + "V8 will stop providing access to hidden prototype (i.e. " + "JSGlobalObject). Use SetPrototypeV2() instead. " + "See http://crbug.com/333672197.") V8_WARN_UNUSED_RESULT Maybe SetPrototype(Local context, Local prototype); + /** + * Set the prototype object (same as setting __proto__ property). This does + * does not consult the security handler. + * TODO(333672197): rename back to SetPrototype() once the old version goes + * through the deprecation process and is removed. + */ + V8_WARN_UNUSED_RESULT Maybe SetPrototypeV2(Local context, + Local prototype); + /** * Finds an instance of the given function template in the prototype * chain. @@ -526,7 +549,72 @@ class V8_EXPORT Object : public Value { void* values[]); /** - * HasOwnProperty() is like JavaScript's Object.prototype.hasOwnProperty(). + * Unwraps a JS wrapper object. + * + * \param tag The tag for retrieving the wrappable instance. Must match the + * tag that has been used for a previous `Wrap()` operation. + * \param isolate The Isolate for the `wrapper` object. + * \param wrapper The JS wrapper object that should be unwrapped. + * \returns the C++ wrappable instance, or nullptr if the JS object has never + * been wrapped. + */ + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const v8::Local& wrapper); + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const PersistentBase& wrapper); + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper); + + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const v8::Local& wrapper, + CppHeapPointerTagRange tag_range); + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const PersistentBase& wrapper, + CppHeapPointerTagRange tag_range); + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper, + CppHeapPointerTagRange tag_range); + + /** + * Wraps a JS wrapper with a C++ instance. + * + * \param tag The pointer tag that should be used for storing this object. + * Future `Unwrap()` operations must provide a matching tag. + * \param isolate The Isolate for the `wrapper` object. + * \param wrapper The JS wrapper object. + * \param wrappable The C++ object instance that is wrapped by the JS object. + */ + template + static V8_INLINE void Wrap(v8::Isolate* isolate, + const v8::Local& wrapper, + void* wrappable); + template + static V8_INLINE void Wrap(v8::Isolate* isolate, + const PersistentBase& wrapper, + void* wrappable); + template + static V8_INLINE void Wrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper, + void* wrappable); + static V8_INLINE void Wrap(v8::Isolate* isolate, + const v8::Local& wrapper, + void* wrappable, CppHeapPointerTag tag); + static V8_INLINE void Wrap(v8::Isolate* isolate, + const PersistentBase& wrapper, + void* wrappable, CppHeapPointerTag tag); + static V8_INLINE void Wrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper, + void* wrappable, CppHeapPointerTag tag); + + /** + * HasOwnProperty() is like JavaScript's + * Object.prototype.hasOwnProperty(). * * See also v8::Object::Has() and v8::Object::HasRealNamedProperty(). */ @@ -610,12 +698,16 @@ class V8_EXPORT Object : public Value { /** * Returns the context in which the object was created. + * Prefer using version with Isolate parameter. */ + MaybeLocal GetCreationContext(v8::Isolate* isolate); MaybeLocal GetCreationContext(); /** - * Shortcut for GetCreationContext().ToLocalChecked(). + * Shortcut for GetCreationContext(...).ToLocalChecked(). + * Prefer using version with Isolate parameter. **/ + Local GetCreationContextChecked(v8::Isolate* isolate); Local GetCreationContextChecked(); /** Same as above, but works for Persistents */ @@ -634,7 +726,12 @@ class V8_EXPORT Object : public Value { * try to expand the embedder data attached to the context. * In case the Local is already available because of other reasons, * it's fine to keep using Context::GetAlignedPointerFromEmbedderData(). + * + * Prefer using version with Isolate parameter if you have an Isolate, + * otherwise use the other one. */ + void* GetAlignedPointerFromEmbedderDataInCreationContext(v8::Isolate* isolate, + int index); void* GetAlignedPointerFromEmbedderDataInCreationContext(int index); /** @@ -650,11 +747,15 @@ class V8_EXPORT Object : public Value { bool IsConstructor() const; /** - * True if this object can carry information relevant to the embedder in its - * embedder fields, false otherwise. This is generally true for objects - * constructed through function templates but also holds for other types where - * V8 automatically adds internal fields at compile time, such as e.g. - * v8::ArrayBuffer. + * Returns true if this object can be generally used to wrap object objects. + * This means that the object either follows the convention of using embedder + * fields to denote type/instance pointers or is using the Wrap()/Unwrap() + * APIs for the same purpose. Returns false otherwise. + * + * Note that there may be other objects that use embedder fields but are not + * used as API wrapper objects. E.g., v8::Promise may in certain configuration + * use embedder fields but promises are not generally supported as API + * wrappers. The method will return false in those cases. */ bool IsApiWrapper() const; @@ -729,6 +830,11 @@ class V8_EXPORT Object : public Value { bool IsCodeLike(Isolate* isolate) const; private: + static void* Unwrap(v8::Isolate* isolate, internal::Address wrapper_obj, + CppHeapPointerTagRange tag_range); + static void Wrap(v8::Isolate* isolate, internal::Address wrapper_obj, + CppHeapPointerTag tag, void* wrappable); + Object(); static void CheckCast(Value* obj); Local SlowGetInternalField(int index); @@ -747,7 +853,8 @@ Local Object::GetInternalField(int index) { // know where to find the internal fields and can return the value directly. int instance_type = I::GetInstanceType(obj); if (I::CanHaveInternalField(instance_type)) { - int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index); + int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize + + (I::kEmbedderDataSlotSize * index); A value = I::ReadRawField(obj, offset); #ifdef V8_COMPRESS_POINTERS // We read the full pointer value and then decompress it in order to avoid @@ -773,7 +880,8 @@ void* Object::GetAlignedPointerFromInternalField(v8::Isolate* isolate, // know where to find the internal fields and can return the value directly. auto instance_type = I::GetInstanceType(obj); if (V8_LIKELY(I::CanHaveInternalField(instance_type))) { - int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) + + int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize + + (I::kEmbedderDataSlotSize * index) + I::kEmbedderDataSlotExternalPointerOffset; A value = I::ReadExternalPointerField( @@ -793,7 +901,8 @@ void* Object::GetAlignedPointerFromInternalField(int index) { // know where to find the internal fields and can return the value directly. auto instance_type = I::GetInstanceType(obj); if (V8_LIKELY(I::CanHaveInternalField(instance_type))) { - int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) + + int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize + + (I::kEmbedderDataSlotSize * index) + I::kEmbedderDataSlotExternalPointerOffset; Isolate* isolate = I::GetIsolateForSandbox(obj); A value = @@ -805,6 +914,142 @@ void* Object::GetAlignedPointerFromInternalField(int index) { return SlowGetAlignedPointerFromInternalField(index); } +// static +template +T* Object::Unwrap(v8::Isolate* isolate, const v8::Local& wrapper) { + CppHeapPointerTagRange tag_range(tag, tag); + auto obj = internal::ValueHelper::ValueAsAddress(*wrapper); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range); +#else // defined(V8_ENABLE_CHECKS) + return reinterpret_cast(Unwrap(isolate, obj, tag_range)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase& wrapper) { + CppHeapPointerTagRange tag_range(tag, tag); + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range); +#else // defined(V8_ENABLE_CHECKS) + return reinterpret_cast(Unwrap(isolate, obj, tag_range)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +T* Object::Unwrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper) { + CppHeapPointerTagRange tag_range(tag, tag); + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range); +#else // defined(V8_ENABLE_CHECKS) + return reinterpret_cast(Unwrap(isolate, obj, tag_range)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +T* Object::Unwrap(v8::Isolate* isolate, const v8::Local& wrapper, + CppHeapPointerTagRange tag_range) { + auto obj = internal::ValueHelper::ValueAsAddress(*wrapper); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range); +#else // defined(V8_ENABLE_CHECKS) + return reinterpret_cast(Unwrap(isolate, obj, tag_range)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase& wrapper, + CppHeapPointerTagRange tag_range) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range); +#else // defined(V8_ENABLE_CHECKS) + + return reinterpret_cast(Unwrap(isolate, obj, tag_range)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +T* Object::Unwrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper, + CppHeapPointerTagRange tag_range) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range); +#else // defined(V8_ENABLE_CHECKS) + return reinterpret_cast(Unwrap(isolate, obj, tag_range)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +void Object::Wrap(v8::Isolate* isolate, const v8::Local& wrapper, + void* wrappable) { + auto obj = internal::ValueHelper::ValueAsAddress(*wrapper); + Wrap(isolate, obj, tag, wrappable); +} + +// static +template +void Object::Wrap(v8::Isolate* isolate, const PersistentBase& wrapper, + void* wrappable) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); + Wrap(isolate, obj, tag, wrappable); +} + +// static +template +void Object::Wrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper, + void* wrappable) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); + Wrap(isolate, obj, tag, wrappable); +} + +// static +void Object::Wrap(v8::Isolate* isolate, const v8::Local& wrapper, + void* wrappable, CppHeapPointerTag tag) { + auto obj = internal::ValueHelper::ValueAsAddress(*wrapper); + Wrap(isolate, obj, tag, wrappable); +} + +// static +void Object::Wrap(v8::Isolate* isolate, const PersistentBase& wrapper, + void* wrappable, CppHeapPointerTag tag) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); + Wrap(isolate, obj, tag, wrappable); +} + +// static +void Object::Wrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper, void* wrappable, + CppHeapPointerTag tag) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); + Wrap(isolate, obj, tag, wrappable); +} + Private* Private::Cast(Data* data) { #ifdef V8_ENABLE_CHECKS CheckCast(data); diff --git a/deps/v8/include/v8-persistent-handle.h b/deps/v8/include/v8-persistent-handle.h index 9db5af5dddd557..3067cb775fc7a8 100644 --- a/deps/v8/include/v8-persistent-handle.h +++ b/deps/v8/include/v8-persistent-handle.h @@ -15,8 +15,6 @@ namespace v8 { class Isolate; template class PersistentValueMapBase; -template -class PersistentValueVector; template class Global; template @@ -204,8 +202,6 @@ class PersistentBase : public api_internal::IndirectHandleBase { friend class ReturnValue; template friend class PersistentValueMapBase; - template - friend class PersistentValueVector; friend class Object; friend class internal::ValueHelper; @@ -236,21 +232,6 @@ class NonCopyablePersistentTraits { } }; -/** - * Helper class traits to allow copying and assignment of Persistent. - * This will clone the contents of storage cell, but not any of the flags, etc. - */ -template -struct CopyablePersistentTraits { - using CopyablePersistent = Persistent>; - static const bool kResetInDestructor = true; - template - static V8_INLINE void Copy(const Persistent& source, - CopyablePersistent* dest) { - // do nothing, just allow copy - } -}; - /** * A PersistentBase which allows copy and assignment. * diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h index 313c0287bcf882..56bfd7274826c0 100644 --- a/deps/v8/include/v8-platform.h +++ b/deps/v8/include/v8-platform.h @@ -79,8 +79,10 @@ class TaskRunner { * * Embedders should override PostTaskImpl instead of this. */ - virtual void PostTask(std::unique_ptr task) { - PostTaskImpl(std::move(task), SourceLocation::Current()); + void PostTask( + std::unique_ptr task, + const SourceLocation& location = SourceLocation::Current()) { + PostTaskImpl(std::move(task), location); } /** @@ -100,8 +102,10 @@ class TaskRunner { * * Embedders should override PostNonNestableTaskImpl instead of this. */ - virtual void PostNonNestableTask(std::unique_ptr task) { - PostNonNestableTaskImpl(std::move(task), SourceLocation::Current()); + void PostNonNestableTask( + std::unique_ptr task, + const SourceLocation& location = SourceLocation::Current()) { + PostNonNestableTaskImpl(std::move(task), location); } /** @@ -111,10 +115,10 @@ class TaskRunner { * * Embedders should override PostDelayedTaskImpl instead of this. */ - virtual void PostDelayedTask(std::unique_ptr task, - double delay_in_seconds) { - PostDelayedTaskImpl(std::move(task), delay_in_seconds, - SourceLocation::Current()); + void PostDelayedTask( + std::unique_ptr task, double delay_in_seconds, + const SourceLocation& location = SourceLocation::Current()) { + PostDelayedTaskImpl(std::move(task), delay_in_seconds, location); } /** @@ -135,10 +139,10 @@ class TaskRunner { * * Embedders should override PostNonNestableDelayedTaskImpl instead of this. */ - virtual void PostNonNestableDelayedTask(std::unique_ptr task, - double delay_in_seconds) { - PostNonNestableDelayedTaskImpl(std::move(task), delay_in_seconds, - SourceLocation::Current()); + void PostNonNestableDelayedTask( + std::unique_ptr task, double delay_in_seconds, + const SourceLocation& location = SourceLocation::Current()) { + PostNonNestableDelayedTaskImpl(std::move(task), delay_in_seconds, location); } /** @@ -151,8 +155,10 @@ class TaskRunner { * * Embedders should override PostIdleTaskImpl instead of this. */ - virtual void PostIdleTask(std::unique_ptr task) { - PostIdleTaskImpl(std::move(task), SourceLocation::Current()); + void PostIdleTask( + std::unique_ptr task, + const SourceLocation& location = SourceLocation::Current()) { + PostIdleTaskImpl(std::move(task), location); } /** @@ -389,7 +395,7 @@ class TracingController { /** * Adds a trace event to the platform tracing system. These function calls are - * usually the result of a TRACE_* macro from trace_event_common.h when + * usually the result of a TRACE_* macro from trace-event-no-perfetto.h when * tracing and the category of the particular trace are enabled. It is not * advisable to call these functions on their own; they are really only meant * to be used by the trace macros. The returned handle can be used by diff --git a/deps/v8/include/v8-primitive.h b/deps/v8/include/v8-primitive.h index eb0a791cf73946..1adb9cbcb22515 100644 --- a/deps/v8/include/v8-primitive.h +++ b/deps/v8/include/v8-primitive.h @@ -223,6 +223,12 @@ class V8_EXPORT String : public Name { */ bool IsExternalOneByte() const; + /** + * Returns the internalized string. See `NewStringType::kInternalized` for + * details on internalized strings. + */ + Local InternalizeString(Isolate* isolate); + class V8_EXPORT ExternalStringResourceBase { public: virtual ~ExternalStringResourceBase() = default; @@ -507,10 +513,15 @@ class V8_EXPORT String : public Name { * (e.g. due to an exception in the toString() method of the object) * then the length() method returns 0 and the * operator returns * NULL. + * + * WARNING: This will unconditionally copy the contents of the JavaScript + * string, and should be avoided in situations where performance is a concern. + * Consider using WriteUtf8() instead. */ class V8_EXPORT Utf8Value { public: - Utf8Value(Isolate* isolate, Local obj); + Utf8Value(Isolate* isolate, Local obj, + WriteOptions options = REPLACE_INVALID_UTF8); ~Utf8Value(); char* operator*() { return str_; } const char* operator*() const { return str_; } @@ -527,12 +538,19 @@ class V8_EXPORT String : public Name { /** * Converts an object to a two-byte (UTF-16-encoded) string. + * * If conversion to a string fails (eg. due to an exception in the toString() * method of the object) then the length() method returns 0 and the * operator * returns NULL. + * + * WARNING: This will unconditionally copy the contents of the JavaScript + * string, and should be avoided in situations where performance is a concern. */ class V8_EXPORT Value { public: + V8_DEPRECATE_SOON( + "Prefer using String::ValueView if you can, or string->Write to a " + "buffer if you cannot.") Value(Isolate* isolate, Local obj); ~Value(); uint16_t* operator*() { return str_; } @@ -548,6 +566,55 @@ class V8_EXPORT String : public Name { int length_; }; + /** + * Returns a view onto a string's contents. + * + * WARNING: This does not copy the string's contents, and will therefore be + * invalidated if the GC can move the string while the ValueView is alive. It + * is therefore required that no GC or allocation can happen while there is an + * active ValueView. This requirement may be relaxed in the future. + * + * V8 strings are either encoded as one-byte or two-bytes per character. + */ + class V8_EXPORT ValueView { + public: + ValueView(Isolate* isolate, Local str); + ~ValueView(); + const uint8_t* data8() const { +#if V8_ENABLE_CHECKS + CheckOneByte(true); +#endif + return data8_; + } + const uint16_t* data16() const { +#if V8_ENABLE_CHECKS + CheckOneByte(false); +#endif + return data16_; + } + int length() const { return length_; } + bool is_one_byte() const { return is_one_byte_; } + + // Disallow copying and assigning. + ValueView(const ValueView&) = delete; + void operator=(const ValueView&) = delete; + + private: + void CheckOneByte(bool is_one_byte) const; + + Local flat_str_; + union { + const uint8_t* data8_; + const uint16_t* data16_; + }; + int length_; + bool is_one_byte_; + // Avoid exposing the internal DisallowGarbageCollection scope. + alignas(internal::Internals:: + kDisallowGarbageCollectionAlign) char no_gc_debug_scope_ + [internal::Internals::kDisallowGarbageCollectionSize]; + }; + private: void VerifyExternalStringResourceBase(ExternalStringResourceBase* v, Encoding encoding) const; diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index 3ec0cd4bb31318..3451da26ba2d6b 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -899,9 +899,28 @@ class V8_EXPORT EmbedderGraph { /** * Returns a node corresponding to the given V8 value. Ownership is not * transferred. The result pointer is valid while the graph is alive. + * + * For now the variant that takes v8::Data is not marked as abstract for + * compatibility, but embedders who subclass EmbedderGraph are expected to + * implement it. Then in the implementation of the variant that takes + * v8::Value, they can simply forward the call to the one that takes + * v8::Local. */ virtual Node* V8Node(const v8::Local& value) = 0; + /** + * Returns a node corresponding to the given V8 value. Ownership is not + * transferred. The result pointer is valid while the graph is alive. + * + * For API compatibility, this default implementation just checks that the + * data is a v8::Value and forward it to the variant that takes v8::Value, + * which is currently required to be implemented. In the future we'll remove + * the v8::Value variant, and make this variant that takes v8::Data abstract + * instead. If the embedder subclasses v8::EmbedderGraph and also use + * v8::TracedReference, they must override this variant. + */ + virtual Node* V8Node(const v8::Local& value); + /** * Adds the given node to the graph and takes ownership of the node. * Returns a raw pointer to the node that is valid while the graph is alive. @@ -956,7 +975,7 @@ class V8_EXPORT HeapProfiler { /** * Callback function invoked during heap snapshot generation to retrieve - * the detachedness state of an object referenced by a TracedReference. + * the detachedness state of a JS object referenced by a TracedReference. * * The callback takes Local as parameter to allow the embedder to * unpack the TracedReference into a Local and reuse that Local for different @@ -1179,6 +1198,18 @@ class V8_EXPORT HeapProfiler { void SetGetDetachednessCallback(GetDetachednessCallback callback, void* data); + /** + * Returns whether the heap profiler is currently taking a snapshot. + */ + bool IsTakingSnapshot(); + + /** + * Allocates a copy of the provided string within the heap snapshot generator + * and returns a pointer to the copy. May only be called during heap snapshot + * generation. + */ + const char* CopyNameForHeapSnapshot(const char* name); + /** * Default value of persistent handle class ID. Must not be used to * define a class. Can be used to reset a class of a persistent diff --git a/deps/v8/include/v8-promise.h b/deps/v8/include/v8-promise.h index 9da8e4b4e86f9a..8c127c8122a2ec 100644 --- a/deps/v8/include/v8-promise.h +++ b/deps/v8/include/v8-promise.h @@ -14,7 +14,7 @@ namespace v8 { class Context; #ifndef V8_PROMISE_INTERNAL_FIELD_COUNT -// The number of required internal fields can be defined by embedder. +// Defined using gn arg `v8_promise_internal_field_count`. #define V8_PROMISE_INTERNAL_FIELD_COUNT 0 #endif @@ -115,7 +115,7 @@ class V8_EXPORT Promise : public Object { return static_cast(value); } - static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT; + static constexpr int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT; private: Promise(); diff --git a/deps/v8/include/v8-sandbox.h b/deps/v8/include/v8-sandbox.h new file mode 100644 index 00000000000000..6e93d4ae62167c --- /dev/null +++ b/deps/v8/include/v8-sandbox.h @@ -0,0 +1,173 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_V8_SANDBOX_H_ +#define INCLUDE_V8_SANDBOX_H_ + +#include + +#include "v8-internal.h" // NOLINT(build/include_directory) +#include "v8config.h" // NOLINT(build/include_directory) + +namespace v8 { + +/** + * A pointer tag used for wrapping and unwrapping `CppHeap` pointers as used + * with JS API wrapper objects that rely on `v8::Object::Wrap()` and + * `v8::Object::Unwrap()`. + * + * The CppHeapPointers use a range-based type checking scheme, where on access + * to a pointer, the actual type of the pointer is checked to be within a + * specified range of types. This allows supporting type hierarchies, where a + * type check for a supertype must succeed for any subtype. + * + * The tag is currently in practice limited to 15 bits since it needs to fit + * together with a marking bit into the unused parts of a pointer (the top 16 + * bits). + */ +enum class CppHeapPointerTag : uint16_t { + kFirstTag = 0, + kNullTag = 0, + + /** + * The lower type ids are reserved for the embedder to assign. For that, the + * main requirement is that all (transitive) child classes of a given parent + * class have type ids in the same range, and that there are no unrelated + * types in that range. For example, given the following type hierarchy: + * + * A F + * / \ + * B E + * / \ + * C D + * + * a potential type id assignment that satistifes these requirements is + * {C: 0, D: 1, B: 2, A: 3, E: 4, F: 5}. With that, the type check for type A + * would check for the range [0, 4], while the check for B would check range + * [0, 2], and for F it would simply check [5, 5]. + * + * In addition, there is an option for performance tweaks: if the size of the + * type range corresponding to a supertype is a power of two and starts at a + * power of two (e.g. [0x100, 0x13f]), then the compiler can often optimize + * the type check to use even fewer instructions (essentially replace a AND + + * SUB with a single AND). + */ + + kDefaultTag = 0x7000, + + kZappedEntryTag = 0x7ffd, + kEvacuationEntryTag = 0x7ffe, + kFreeEntryTag = 0x7fff, + // The tags are limited to 15 bits, so the last tag is 0x7fff. + kLastTag = 0x7fff, +}; + +// Convenience struct to represent tag ranges. This is used for type checks +// against supertypes, which cover a range of types (their subtypes). +// Both the lower- and the upper bound are inclusive. In other words, this +// struct represents the range [lower_bound, upper_bound]. +struct CppHeapPointerTagRange { + constexpr CppHeapPointerTagRange(CppHeapPointerTag lower, + CppHeapPointerTag upper) + : lower_bound(lower), upper_bound(upper) {} + CppHeapPointerTag lower_bound; + CppHeapPointerTag upper_bound; + + // Check whether the tag of the given CppHeapPointerTable entry is within + // this range. This method encodes implementation details of the + // CppHeapPointerTable, which is necessary as it is used by + // ReadCppHeapPointerField below. + // Returns true if the check is successful and the tag of the given entry is + // within this range, false otherwise. + bool CheckTagOf(uint64_t entry) { + // Note: the cast to uint32_t is important here. Otherwise, the uint16_t's + // would be promoted to int in the range check below, which would result in + // undefined behavior (signed integer undeflow) if the actual value is less + // than the lower bound. Then, the compiler would take advantage of the + // undefined behavior and turn the range check into a simple + // `actual_tag <= last_tag` comparison, which is incorrect. + uint32_t actual_tag = static_cast(entry); + // The actual_tag is shifted to the left by one and contains the marking + // bit in the LSB. To ignore that during the type check, simply add one to + // the (shifted) range. + constexpr int kTagShift = internal::kCppHeapPointerTagShift; + uint32_t first_tag = static_cast(lower_bound) << kTagShift; + uint32_t last_tag = (static_cast(upper_bound) << kTagShift) + 1; + return actual_tag >= first_tag && actual_tag <= last_tag; + } +}; + +constexpr CppHeapPointerTagRange kAnyCppHeapPointer( + CppHeapPointerTag::kFirstTag, CppHeapPointerTag::kLastTag); + +class SandboxHardwareSupport { + public: + /** + * Initialize sandbox hardware support. This needs to be called before + * creating any thread that might access sandbox memory since it sets up + * hardware permissions to the memory that will be inherited on clone. + */ + V8_EXPORT static void InitializeBeforeThreadCreation(); +}; + +namespace internal { + +#ifdef V8_COMPRESS_POINTERS +V8_INLINE static Address* GetCppHeapPointerTableBase(v8::Isolate* isolate) { + Address addr = reinterpret_cast
(isolate) + + Internals::kIsolateCppHeapPointerTableOffset + + Internals::kExternalPointerTableBasePointerOffset; + return *reinterpret_cast(addr); +} +#endif // V8_COMPRESS_POINTERS + +template +V8_INLINE static T* ReadCppHeapPointerField(v8::Isolate* isolate, + Address heap_object_ptr, int offset, + CppHeapPointerTagRange tag_range) { +#ifdef V8_COMPRESS_POINTERS + // See src/sandbox/cppheap-pointer-table-inl.h. Logic duplicated here so + // it can be inlined and doesn't require an additional call. + const CppHeapPointerHandle handle = + Internals::ReadRawField(heap_object_ptr, offset); + const uint32_t index = handle >> kExternalPointerIndexShift; + const Address* table = GetCppHeapPointerTableBase(isolate); + const std::atomic
* ptr = + reinterpret_cast*>(&table[index]); + Address entry = std::atomic_load_explicit(ptr, std::memory_order_relaxed); + + Address pointer = entry; + if (V8_LIKELY(tag_range.CheckTagOf(entry))) { + pointer = entry >> kCppHeapPointerPayloadShift; + } else { + // If the type check failed, we simply return nullptr here. That way: + // 1. The null handle always results in nullptr being returned here, which + // is a desired property. Otherwise, we would need an explicit check for + // the null handle above, and therefore an additional branch. This + // works because the 0th entry of the table always contains nullptr + // tagged with the null tag (i.e. an all-zeros entry). As such, + // regardless of whether the type check succeeds, the result will + // always be nullptr. + // 2. The returned pointer is guaranteed to crash even on platforms with + // top byte ignore (TBI), such as Arm64. The alternative would be to + // simply return the original entry with the left-shifted payload. + // However, due to TBI, an access to that may not always result in a + // crash (specifically, if the second most significant byte happens to + // be zero). In addition, there shouldn't be a difference on Arm64 + // between returning nullptr or the original entry, since it will + // simply compile to a `csel x0, x8, xzr, lo` instead of a + // `csel x0, x10, x8, lo` instruction. + pointer = 0; + } + return reinterpret_cast(pointer); +#else // !V8_COMPRESS_POINTERS + return reinterpret_cast( + Internals::ReadRawField
(heap_object_ptr, offset)); +#endif // !V8_COMPRESS_POINTERS +} + +} // namespace internal +} // namespace v8 + +#endif // INCLUDE_V8_SANDBOX_H_ diff --git a/deps/v8/include/v8-script.h b/deps/v8/include/v8-script.h index 75589863d9d1c7..f4c7412c5bf6e5 100644 --- a/deps/v8/include/v8-script.h +++ b/deps/v8/include/v8-script.h @@ -322,6 +322,14 @@ class V8_EXPORT Module : public Data { static void CheckCast(Data* obj); }; +class V8_EXPORT CompileHintsCollector : public Data { + public: + /** + * Returns the positions of lazy functions which were compiled and executed. + */ + std::vector GetCompileHints(Isolate* isolate) const; +}; + /** * A compiled JavaScript script, tied to a Context which was active when the * script was compiled. @@ -359,7 +367,15 @@ class V8_EXPORT Script : public Data { * If the script was compiled, returns the positions of lazy functions which * were eventually compiled and executed. */ + V8_DEPRECATE_SOON("Use GetCompileHintsCollector instead") std::vector GetProducedCompileHints() const; + + /** + * Get a compile hints collector object which we can use later for retrieving + * compile hints (= positions of lazy functions which were compiled and + * executed). + */ + Local GetCompileHintsCollector() const; }; enum class ScriptType { kClassic, kModule }; @@ -640,12 +656,33 @@ class V8_EXPORT ScriptCompiler { enum CompileOptions { kNoCompileOptions = 0, - kConsumeCodeCache, - kEagerCompile, - kProduceCompileHints, - kConsumeCompileHints + kConsumeCodeCache = 1 << 0, + kEagerCompile = 1 << 1, + kProduceCompileHints = 1 << 2, + kConsumeCompileHints = 1 << 3, + kFollowCompileHintsMagicComment = 1 << 4, }; + static inline bool CompileOptionsIsValid(CompileOptions compile_options) { + // kConsumeCodeCache is mutually exclusive with all other flag bits. + if ((compile_options & kConsumeCodeCache) && + compile_options != kConsumeCodeCache) { + return false; + } + // kEagerCompile is mutually exclusive with all other flag bits. + if ((compile_options & kEagerCompile) && compile_options != kEagerCompile) { + return false; + } + // We don't currently support producing and consuming compile hints at the + // same time. + constexpr int produce_and_consume = CompileOptions::kProduceCompileHints | + CompileOptions::kConsumeCompileHints; + if ((compile_options & produce_and_consume) == produce_and_consume) { + return false; + } + return true; + } + /** * The reason for which we are not requesting or providing a code cache. */ @@ -722,6 +759,8 @@ class V8_EXPORT ScriptCompiler { static ConsumeCodeCacheTask* StartConsumingCodeCache( Isolate* isolate, std::unique_ptr source); + static ConsumeCodeCacheTask* StartConsumingCodeCacheOnBackground( + Isolate* isolate, std::unique_ptr source); /** * Compiles a streamed script (bound to current context). @@ -787,15 +826,6 @@ class V8_EXPORT ScriptCompiler { * It is possible to specify multiple context extensions (obj in the above * example). */ - V8_DEPRECATED("Use CompileFunction") - static V8_WARN_UNUSED_RESULT MaybeLocal CompileFunctionInContext( - Local context, Source* source, size_t arguments_count, - Local arguments[], size_t context_extension_count, - Local context_extensions[], - CompileOptions options = kNoCompileOptions, - NoCacheReason no_cache_reason = kNoCacheNoReason, - Local* script_or_module_out = nullptr); - static V8_WARN_UNUSED_RESULT MaybeLocal CompileFunction( Local context, Source* source, size_t arguments_count = 0, Local arguments[] = nullptr, size_t context_extension_count = 0, diff --git a/deps/v8/include/v8-snapshot.h b/deps/v8/include/v8-snapshot.h index 9e5a53f134a82c..8c8390bab18f36 100644 --- a/deps/v8/include/v8-snapshot.h +++ b/deps/v8/include/v8-snapshot.h @@ -68,6 +68,22 @@ struct SerializeContextDataCallback { void* data; }; +/** + * Similar to `SerializeInternalFieldsCallback`, but is used exclusively to + * serialize API wrappers. The pointers for API wrappers always point into the + * CppHeap. + */ +struct SerializeAPIWrapperCallback { + using CallbackFunction = StartupData (*)(Local holder, + void* cpp_heap_pointer, void* data); + explicit SerializeAPIWrapperCallback(CallbackFunction function = nullptr, + void* data = nullptr) + : callback(function), data(data) {} + + CallbackFunction callback; + void* data; +}; + /** * Callback and supporting data used to implement embedder logic to deserialize * internal fields of v8::Objects. @@ -97,6 +113,17 @@ struct DeserializeContextDataCallback { void* data; }; +struct DeserializeAPIWrapperCallback { + using CallbackFunction = void (*)(Local holder, StartupData payload, + void* data); + explicit DeserializeAPIWrapperCallback(CallbackFunction function = nullptr, + void* data = nullptr) + : callback(function), data(data) {} + + CallbackFunction callback; + void* data; +}; + /** * Helper class to create a snapshot data blob. * @@ -187,13 +214,17 @@ class V8_EXPORT SnapshotCreator { * context embedder data set by * v8::Context::SetAlignedPointerInEmbedderData(). * + * \param api_wrapper_serializer An optional callback used to serialize API + * wrapper references set via `v8::Object::Wrap()`. */ void SetDefaultContext( Local context, SerializeInternalFieldsCallback internal_fields_serializer = SerializeInternalFieldsCallback(), SerializeContextDataCallback context_data_serializer = - SerializeContextDataCallback()); + SerializeContextDataCallback(), + SerializeAPIWrapperCallback api_wrapper_serializer = + SerializeAPIWrapperCallback()); /** * Add additional context to be included in the snapshot blob. @@ -204,12 +235,17 @@ class V8_EXPORT SnapshotCreator { * * \param context_data_serializer Similar to context_data_serializer * in SetDefaultContext() but only applies to the context being added. + * + * \param api_wrapper_serializer Similar to api_wrapper_serializer + * in SetDefaultContext() but only applies to the context being added. */ size_t AddContext(Local context, SerializeInternalFieldsCallback internal_fields_serializer = SerializeInternalFieldsCallback(), SerializeContextDataCallback context_data_serializer = - SerializeContextDataCallback()); + SerializeContextDataCallback(), + SerializeAPIWrapperCallback api_wrapper_serializer = + SerializeAPIWrapperCallback()); /** * Attach arbitrary V8::Data to the context snapshot, which can be retrieved diff --git a/deps/v8/include/v8-template.h b/deps/v8/include/v8-template.h index 6a0c898f4507d2..ba5ff7bff5ada9 100644 --- a/deps/v8/include/v8-template.h +++ b/deps/v8/include/v8-template.h @@ -60,6 +60,22 @@ class V8_EXPORT Template : public Data { V8_INLINE void Set(Isolate* isolate, const char* name, Local value, PropertyAttribute attributes = None); + /** + * Sets an "accessor property" on the object template, see + * https://tc39.es/ecma262/#sec-object-type. + * + * Whenever the property with the given name is accessed on objects + * created from this ObjectTemplate the getter and setter functions + * are called. + * + * \param name The name of the property for which an accessor is added. + * \param getter The callback to invoke when getting the property. + * \param setter The callback to invoke when setting the property. + * \param data A piece of data that will be passed to the getter and setter + * callbacks whenever they are invoked. + * \param attribute The attributes of the property for which an accessor + * is added. + */ void SetAccessorProperty( Local name, Local getter = Local(), @@ -67,12 +83,18 @@ class V8_EXPORT Template : public Data { PropertyAttribute attribute = None); /** + * Sets a "data property" on the object template, see + * https://tc39.es/ecma262/#sec-object-type. + * * Whenever the property with the given name is accessed on objects * created from this Template the getter and setter callbacks * are called instead of getting and setting the property directly * on the JavaScript object. + * Note that in case a property is written via a "child" object, the setter + * will not be called according to the JavaScript specification. See + * https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver. * - * \param name The name of the property for which an accessor is added. + * \param name The name of the data property for which an accessor is added. * \param getter The callback to invoke when getting the property. * \param setter The callback to invoke when setting the property. * \param data A piece of data that will be passed to the getter and setter @@ -80,27 +102,6 @@ class V8_EXPORT Template : public Data { * \param attribute The attributes of the property for which an accessor * is added. */ - V8_DEPRECATE_SOON("Use SetNativeDataProperty without AccessControl instead") - void SetNativeDataProperty( - Local name, AccessorGetterCallback getter, - AccessorSetterCallback setter, Local data, - PropertyAttribute attribute, AccessControl settings, - SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, - SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); - V8_DEPRECATE_SOON("Use SetNativeDataProperty without AccessControl instead") - void SetNativeDataProperty( - Local name, AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter, Local data, - PropertyAttribute attribute, AccessControl settings, - SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, - SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); - V8_DEPRECATE_SOON("Use SetNativeDataProperty with Local instead") - void SetNativeDataProperty( - Local name, AccessorGetterCallback getter, - AccessorSetterCallback setter = nullptr, - Local data = Local(), PropertyAttribute attribute = None, - SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, - SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); void SetNativeDataProperty( Local name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter = nullptr, @@ -142,7 +143,8 @@ enum class Intercepted : uint8_t { kNo = 0, kYes = 1 }; * Interceptor for get requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should + * looked up beyond the interceptor or in case an exception was thrown) it + * should * - (optionally) use info.GetReturnValue().Set()` to set the return value * (by default the result is set to v8::Undefined), * - return `Intercepted::kYes`. @@ -194,7 +196,8 @@ using GenericNamedPropertyGetterCallback = * Interceptor for set requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should return `Intercepted::kYes`. + * looked up beyond the interceptor or in case an exception was thrown) it + * should return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. * @@ -229,9 +232,10 @@ using GenericNamedPropertySetterCallback = * defineProperty(). * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should - * - use `info.GetReturnValue().Set()` to set to an Integer value encoding - * a `v8::PropertyAttribute` bits, + * looked up beyond the interceptor or in case an exception was thrown) it + * should + * - (optionally) use `info.GetReturnValue().Set()` to set to an Integer + * value encoding a `v8::PropertyAttribute` bits, * - return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. @@ -263,9 +267,10 @@ using GenericNamedPropertyQueryCallback = * Interceptor for delete requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should - * - use `info.GetReturnValue().Set()` to set to a Boolean value indicating - * whether the property deletion was successful or not, + * looked up beyond the interceptor or in case an exception was thrown) it + * should + * - (optionally) use `info.GetReturnValue().Set()` to set to a Boolean value + * indicating whether the property deletion was successful or not, * - return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. @@ -311,7 +316,8 @@ using GenericNamedPropertyEnumeratorCallback = NamedPropertyEnumeratorCallback; * Interceptor for defineProperty requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should return `Intercepted::kYes`. + * looked up beyond the interceptor or in case an exception was thrown) it + * should return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. * @@ -344,10 +350,11 @@ using GenericNamedPropertyDefinerCallback = * Interceptor for getOwnPropertyDescriptor requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should - * - use `info.GetReturnValue().Set()` to set the return value which must be - * object that can be converted to a PropertyDescriptor (for example, - * a value returned by `v8::Object::getOwnPropertyDescriptor`), + * looked up beyond the interceptor or in case an exception was thrown) it + * should + * - (optionally) use `info.GetReturnValue().Set()` to set the return value + * which must be object that can be converted to a PropertyDescriptor (for + * example, a value returned by `v8::Object::getOwnPropertyDescriptor`), * - return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. @@ -379,7 +386,7 @@ using GenericNamedPropertyDescriptorCallback = // removed. /** - * See `v8::GenericNamedPropertyGetterCallback`. + * See `v8::NamedPropertyGetterCallback`. */ using IndexedPropertyGetterCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -388,7 +395,7 @@ using IndexedPropertyGetterCallback = void (*)(uint32_t index, const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertySetterCallback`. + * See `v8::NamedPropertySetterCallback`. */ using IndexedPropertySetterCallbackV2 = Intercepted (*)( uint32_t index, Local value, const PropertyCallbackInfo& info); @@ -398,7 +405,7 @@ using IndexedPropertySetterCallback = const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyQueryCallback`. + * See `v8::NamedPropertyQueryCallback`. */ using IndexedPropertyQueryCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -407,7 +414,7 @@ using IndexedPropertyQueryCallback = void (*)(uint32_t index, const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDeleterCallback`. + * See `v8::NamedPropertyDeleterCallback`. */ using IndexedPropertyDeleterCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -425,7 +432,7 @@ using IndexedPropertyEnumeratorCallback = void (*)(const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDefinerCallback`. + * See `v8::NamedPropertyDefinerCallback`. */ using IndexedPropertyDefinerCallbackV2 = Intercepted (*)(uint32_t index, const PropertyDescriptor& desc, @@ -436,7 +443,7 @@ using IndexedPropertyDefinerCallback = const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDescriptorCallback`. + * See `v8::NamedPropertyDescriptorCallback`. */ using IndexedPropertyDescriptorCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -489,8 +496,8 @@ enum class ConstructorBehavior { kThrow, kAllow }; * proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2)); * * v8::Local instance_t = t->InstanceTemplate(); - * instance_t->SetAccessor( - String::NewFromUtf8Literal(isolate, "instance_accessor"), + * instance_t->SetNativeDataProperty( + * String::NewFromUtf8Literal(isolate, "instance_accessor"), * InstanceAccessorCallback); * instance_t->SetHandler( * NamedPropertyHandlerConfiguration(PropertyHandlerCallback)); @@ -752,34 +759,13 @@ struct NamedPropertyHandlerConfiguration { NamedPropertyDescriptorCallback descriptor, // Local data = Local(), PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), - query(reinterpret_cast(query)), - deleter(reinterpret_cast(deleter)), - enumerator(enumerator), - definer(reinterpret_cast(definer)), - descriptor(reinterpret_cast(descriptor)), - data(data), - flags(WithNewSignatureFlag(flags)) {} - - // This variant will be deprecated soon. - NamedPropertyHandlerConfiguration( - GenericNamedPropertyGetterCallback getter, - GenericNamedPropertySetterCallback setter, - GenericNamedPropertyQueryCallback query, - GenericNamedPropertyDeleterCallback deleter, - GenericNamedPropertyEnumeratorCallback enumerator, - GenericNamedPropertyDefinerCallback definer, - GenericNamedPropertyDescriptorCallback descriptor, - Local data = Local(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), - query(reinterpret_cast(query)), - deleter(reinterpret_cast(deleter)), + : getter(getter), + setter(setter), + query(query), + deleter(deleter), enumerator(enumerator), - definer(reinterpret_cast(definer)), - descriptor(reinterpret_cast(descriptor)), + definer(definer), + descriptor(descriptor), data(data), flags(flags) {} @@ -791,29 +777,10 @@ struct NamedPropertyHandlerConfiguration { NamedPropertyEnumeratorCallback enumerator = nullptr, Local data = Local(), PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), - query(reinterpret_cast(query)), - deleter(reinterpret_cast(deleter)), - enumerator(enumerator), - definer(nullptr), - descriptor(nullptr), - data(data), - flags(WithNewSignatureFlag(flags)) {} - - // This variant will be deprecated soon. - explicit NamedPropertyHandlerConfiguration( - GenericNamedPropertyGetterCallback getter, - GenericNamedPropertySetterCallback setter = nullptr, - GenericNamedPropertyQueryCallback query = nullptr, - GenericNamedPropertyDeleterCallback deleter = nullptr, - GenericNamedPropertyEnumeratorCallback enumerator = nullptr, - Local data = Local(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), - query(reinterpret_cast(query)), - deleter(reinterpret_cast(deleter)), + : getter(getter), + setter(setter), + query(query), + deleter(deleter), enumerator(enumerator), definer(nullptr), descriptor(nullptr), @@ -829,43 +796,23 @@ struct NamedPropertyHandlerConfiguration { NamedPropertyDefinerCallback definer, // Local data = Local(), PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), + : getter(getter), + setter(setter), query(nullptr), - deleter(reinterpret_cast(deleter)), + deleter(deleter), enumerator(enumerator), - definer(reinterpret_cast(definer)), - descriptor(reinterpret_cast(descriptor)), - data(data), - flags(WithNewSignatureFlag(flags)) {} - - // This variant will be deprecated soon. - NamedPropertyHandlerConfiguration( - GenericNamedPropertyGetterCallback getter, - GenericNamedPropertySetterCallback setter, - GenericNamedPropertyDescriptorCallback descriptor, - GenericNamedPropertyDeleterCallback deleter, - GenericNamedPropertyEnumeratorCallback enumerator, - GenericNamedPropertyDefinerCallback definer, - Local data = Local(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), - query(nullptr), - deleter(reinterpret_cast(deleter)), - enumerator(enumerator), - definer(reinterpret_cast(definer)), - descriptor(reinterpret_cast(descriptor)), + definer(definer), + descriptor(descriptor), data(data), flags(flags) {} - void* getter; // [Generic]NamedPropertyGetterCallback - void* setter; // [Generic]NamedPropertySetterCallback - void* query; // [Generic]NamedPropertyQueryCallback - void* deleter; // [Generic]NamedPropertyDeleterCallback + NamedPropertyGetterCallback getter; + NamedPropertySetterCallback setter; + NamedPropertyQueryCallback query; + NamedPropertyDeleterCallback deleter; NamedPropertyEnumeratorCallback enumerator; - void* definer; // [Generic]NamedPropertyDefinerCallback - void* descriptor; // [Generic]NamedPropertyDescriptorCallback + NamedPropertyDefinerCallback definer; + NamedPropertyDescriptorCallback descriptor; Local data; PropertyHandlerFlags flags; }; @@ -891,34 +838,13 @@ struct IndexedPropertyHandlerConfiguration { IndexedPropertyDescriptorCallbackV2 descriptor, // Local data = Local(), PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), - query(reinterpret_cast(query)), - deleter(reinterpret_cast(deleter)), - enumerator(enumerator), - definer(reinterpret_cast(definer)), - descriptor(reinterpret_cast(descriptor)), - data(data), - flags(WithNewSignatureFlag(flags)) {} - - // This variant will be deprecated soon. - IndexedPropertyHandlerConfiguration( - IndexedPropertyGetterCallback getter, // - IndexedPropertySetterCallback setter, // - IndexedPropertyQueryCallback query, // - IndexedPropertyDeleterCallback deleter, // - IndexedPropertyEnumeratorCallback enumerator, // - IndexedPropertyDefinerCallback definer, // - IndexedPropertyDescriptorCallback descriptor, // - Local data = Local(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), - query(reinterpret_cast(query)), - deleter(reinterpret_cast(deleter)), + : getter(getter), + setter(setter), + query(query), + deleter(deleter), enumerator(enumerator), - definer(reinterpret_cast(definer)), - descriptor(reinterpret_cast(descriptor)), + definer(definer), + descriptor(descriptor), data(data), flags(flags) {} @@ -930,29 +856,10 @@ struct IndexedPropertyHandlerConfiguration { IndexedPropertyEnumeratorCallback enumerator = nullptr, Local data = Local(), PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), - query(reinterpret_cast(query)), - deleter(reinterpret_cast(deleter)), - enumerator(enumerator), - definer(nullptr), - descriptor(nullptr), - data(data), - flags(WithNewSignatureFlag(flags)) {} - - // This variant will be deprecated soon. - explicit IndexedPropertyHandlerConfiguration( - IndexedPropertyGetterCallback getter, - IndexedPropertySetterCallback setter = nullptr, - IndexedPropertyQueryCallback query = nullptr, - IndexedPropertyDeleterCallback deleter = nullptr, - IndexedPropertyEnumeratorCallback enumerator = nullptr, - Local data = Local(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), - query(reinterpret_cast(query)), - deleter(reinterpret_cast(deleter)), + : getter(getter), + setter(setter), + query(query), + deleter(deleter), enumerator(enumerator), definer(nullptr), descriptor(nullptr), @@ -968,43 +875,23 @@ struct IndexedPropertyHandlerConfiguration { IndexedPropertyDefinerCallbackV2 definer, Local data = Local(), PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), - query(nullptr), - deleter(reinterpret_cast(deleter)), - enumerator(enumerator), - definer(reinterpret_cast(definer)), - descriptor(reinterpret_cast(descriptor)), - data(data), - flags(WithNewSignatureFlag(flags)) {} - - // This variant will be deprecated soon. - IndexedPropertyHandlerConfiguration( - IndexedPropertyGetterCallback getter, - IndexedPropertySetterCallback setter, - IndexedPropertyDescriptorCallback descriptor, - IndexedPropertyDeleterCallback deleter, - IndexedPropertyEnumeratorCallback enumerator, - IndexedPropertyDefinerCallback definer, - Local data = Local(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(reinterpret_cast(getter)), - setter(reinterpret_cast(setter)), + : getter(getter), + setter(setter), query(nullptr), - deleter(reinterpret_cast(deleter)), + deleter(deleter), enumerator(enumerator), - definer(reinterpret_cast(definer)), - descriptor(reinterpret_cast(descriptor)), + definer(definer), + descriptor(descriptor), data(data), flags(flags) {} - void* getter; // IndexedPropertyGetterCallback[V2] - void* setter; // IndexedPropertySetterCallback[V2] - void* query; // IndexedPropertyQueryCallback[V2] - void* deleter; // IndexedPropertyDeleterCallback[V2] + IndexedPropertyGetterCallbackV2 getter; + IndexedPropertySetterCallbackV2 setter; + IndexedPropertyQueryCallbackV2 query; + IndexedPropertyDeleterCallbackV2 deleter; IndexedPropertyEnumeratorCallback enumerator; - void* definer; // IndexedPropertyDefinerCallback[V2] - void* descriptor; // IndexedPropertyDescriptorCallback[V2] + IndexedPropertyDefinerCallbackV2 definer; + IndexedPropertyDescriptorCallbackV2 descriptor; Local data; PropertyHandlerFlags flags; }; @@ -1029,36 +916,6 @@ class V8_EXPORT ObjectTemplate : public Template { */ V8_WARN_UNUSED_RESULT MaybeLocal NewInstance(Local context); - /** - * Sets an accessor on the object template. - * - * Whenever the property with the given name is accessed on objects - * created from this ObjectTemplate the getter and setter callbacks - * are called instead of getting and setting the property directly - * on the JavaScript object. - * - * \param name The name of the property for which an accessor is added. - * \param getter The callback to invoke when getting the property. - * \param setter The callback to invoke when setting the property. - * \param data A piece of data that will be passed to the getter and setter - * callbacks whenever they are invoked. - * \param attribute The attributes of the property for which an accessor - * is added. - */ - V8_DEPRECATE_SOON("Use SetAccessor with Local instead") - void SetAccessor( - Local name, AccessorGetterCallback getter, - AccessorSetterCallback setter = nullptr, - Local data = Local(), PropertyAttribute attribute = None, - SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, - SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); - void SetAccessor( - Local name, AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter = nullptr, - Local data = Local(), PropertyAttribute attribute = None, - SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, - SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); - /** * Sets a named property handler on the object template. * @@ -1072,34 +929,6 @@ class V8_EXPORT ObjectTemplate : public Template { */ void SetHandler(const NamedPropertyHandlerConfiguration& configuration); - /** - * Sets an indexed property handler on the object template. - * - * Whenever an indexed property is accessed on objects created from - * this object template, the provided callback is invoked instead of - * accessing the property directly on the JavaScript object. - * - * \param getter The callback to invoke when getting a property. - * \param setter The callback to invoke when setting a property. - * \param query The callback to invoke to check if an object has a property. - * \param deleter The callback to invoke when deleting a property. - * \param enumerator The callback to invoke to enumerate all the indexed - * properties of an object. - * \param data A piece of data that will be passed to the callbacks - * whenever they are invoked. - */ - V8_DEPRECATE_SOON("Use SetHandler instead") - void SetIndexedPropertyHandler( - IndexedPropertyGetterCallback getter, - IndexedPropertySetterCallback setter = nullptr, - IndexedPropertyQueryCallback query = nullptr, - IndexedPropertyDeleterCallback deleter = nullptr, - IndexedPropertyEnumeratorCallback enumerator = nullptr, - Local data = Local()) { - SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query, - deleter, enumerator, data)); - } - /** * Sets an indexed property handler on the object template. * diff --git a/deps/v8/include/v8-traced-handle.h b/deps/v8/include/v8-traced-handle.h index c9fd357b871bf7..04752c4f2aeed0 100644 --- a/deps/v8/include/v8-traced-handle.h +++ b/deps/v8/include/v8-traced-handle.h @@ -62,11 +62,11 @@ class TracedReferenceBase : public api_internal::IndirectHandleBase { V8_INLINE void Reset(); /** - * Construct a Local from this handle. + * Construct a Local from this handle. */ - V8_INLINE Local Get(Isolate* isolate) const { - if (IsEmpty()) return Local(); - return Local::New(isolate, this->value()); + V8_INLINE Local Get(Isolate* isolate) const { + if (IsEmpty()) return Local(); + return Local::New(isolate, this->value()); } /** @@ -135,17 +135,6 @@ class BasicTracedReference : public TracedReferenceBase { const_cast&>(*this)); } - V8_DEPRECATE_SOON("Use Get to convert to Local instead") - V8_INLINE T* operator->() const { -#ifdef V8_ENABLE_CHECKS - CheckValue(); -#endif // V8_ENABLE_CHECKS - return this->template value(); - } - - V8_DEPRECATE_SOON("Use Get to convert to Local instead") - V8_INLINE T* operator*() const { return this->operator->(); } - private: /** * An empty BasicTracedReference without storage cell. diff --git a/deps/v8/include/v8-unwinder.h b/deps/v8/include/v8-unwinder.h index 8b71bb39b55f42..5771eb05a81ecf 100644 --- a/deps/v8/include/v8-unwinder.h +++ b/deps/v8/include/v8-unwinder.h @@ -42,7 +42,8 @@ enum StateTag : uint16_t { OTHER, EXTERNAL, ATOMICS_WAIT, - IDLE + IDLE, + LOGGING, }; // The output structure filled up by GetStackSample API function. diff --git a/deps/v8/include/v8-util.h b/deps/v8/include/v8-util.h index db6d1a2fe6befc..b7d53f14f75fe4 100644 --- a/deps/v8/include/v8-util.h +++ b/deps/v8/include/v8-util.h @@ -544,122 +544,6 @@ class StdGlobalValueMap : public GlobalValueMap { : GlobalValueMap(isolate) {} }; -class DefaultPersistentValueVectorTraits { - public: - typedef std::vector Impl; - - static void Append(Impl* impl, PersistentContainerValue value) { - impl->push_back(value); - } - static bool IsEmpty(const Impl* impl) { - return impl->empty(); - } - static size_t Size(const Impl* impl) { - return impl->size(); - } - static PersistentContainerValue Get(const Impl* impl, size_t i) { - return (i < impl->size()) ? impl->at(i) : kPersistentContainerNotFound; - } - static void ReserveCapacity(Impl* impl, size_t capacity) { - impl->reserve(capacity); - } - static void Clear(Impl* impl) { - impl->clear(); - } -}; - -/** - * A vector wrapper that safely stores Global values. - * C++11 embedders don't need this class, as they can use Global - * directly in std containers. - * - * This class relies on a backing vector implementation, whose type and methods - * are described by the Traits class. The backing map will handle values of type - * PersistentContainerValue, with all conversion into and out of V8 - * handles being transparently handled by this class. - */ -template -class V8_DEPRECATE_SOON("Use std::vector>.") PersistentValueVector { - public: - explicit PersistentValueVector(Isolate* isolate) : isolate_(isolate) { } - - ~PersistentValueVector() { - Clear(); - } - - /** - * Append a value to the vector. - */ - void Append(Local value) { - Global persistent(isolate_, value); - Traits::Append(&impl_, ClearAndLeak(&persistent)); - } - - /** - * Append a persistent's value to the vector. - */ - void Append(Global persistent) { - Traits::Append(&impl_, ClearAndLeak(&persistent)); - } - - /** - * Are there any values in the vector? - */ - bool IsEmpty() const { - return Traits::IsEmpty(&impl_); - } - - /** - * How many elements are in the vector? - */ - size_t Size() const { - return Traits::Size(&impl_); - } - - /** - * Retrieve the i-th value in the vector. - */ - Local Get(size_t index) const { - return Local::New(isolate_, internal::ValueHelper::SlotAsValue( - Traits::Get(&impl_, index))); - } - - /** - * Remove all elements from the vector. - */ - void Clear() { - size_t length = Traits::Size(&impl_); - for (size_t i = 0; i < length; i++) { - Global p; - p.slot() = reinterpret_cast(Traits::Get(&impl_, i)); - } - Traits::Clear(&impl_); - } - - /** - * Reserve capacity in the vector. - * (Efficiency gains depend on the backing implementation.) - */ - void ReserveCapacity(size_t capacity) { - Traits::ReserveCapacity(&impl_, capacity); - } - - private: - static PersistentContainerValue ClearAndLeak(Global* persistent) { - auto slot = persistent->slot(); - persistent->Clear(); - return reinterpret_cast(slot); - } - - static V* FromVal(PersistentContainerValue v) { - return internal::ValueHelper::SlotAsValue( - reinterpret_cast(v)); - } - - Isolate* isolate_; - typename Traits::Impl impl_; -}; - } // namespace v8 #endif // V8_UTIL_H diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index e665e9b67dfc98..e038daf0b24877 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -9,9 +9,9 @@ // NOTE these macros are used by some of the tool scripts and the build // system so their names cannot be changed without changing the scripts. #define V8_MAJOR_VERSION 12 -#define V8_MINOR_VERSION 4 -#define V8_BUILD_NUMBER 254 -#define V8_PATCH_LEVEL 21 +#define V8_MINOR_VERSION 8 +#define V8_BUILD_NUMBER 374 +#define V8_PATCH_LEVEL 13 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/include/v8-wasm.h b/deps/v8/include/v8-wasm.h index 71514615466eb3..f8e406c737e1cf 100644 --- a/deps/v8/include/v8-wasm.h +++ b/deps/v8/include/v8-wasm.h @@ -9,6 +9,7 @@ #include #include +#include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-memory-span.h" // NOLINT(build/include_directory) #include "v8-object.h" // NOLINT(build/include_directory) @@ -129,6 +130,8 @@ class V8_EXPORT WasmModuleObject : public Object { */ class V8_EXPORT WasmStreaming final { public: + static constexpr internal::ExternalPointerTag kManagedTag = + internal::kWasmWasmStreamingTag; class WasmStreamingImpl; explicit WasmStreaming(std::unique_ptr impl); diff --git a/deps/v8/include/v8config.h b/deps/v8/include/v8config.h index e649d8cce7d03d..4a6f255b38a7e2 100644 --- a/deps/v8/include/v8config.h +++ b/deps/v8/include/v8config.h @@ -5,8 +5,16 @@ #ifndef V8CONFIG_H_ #define V8CONFIG_H_ +// gcc 10 defines __cplusplus to "an unspecified value strictly larger than +// 201703L" for its experimental -std=gnu++2a config. +// TODO(leszeks): Change to `__cplusplus <= 202002L` once we only support +// compilers with full C++20 support. +#if __cplusplus <= 201703L +#error "C++20 or later required." +#endif + #ifdef V8_GN_HEADER -#if __cplusplus >= 201703L && !__has_include("v8-gn.h") +#if !__has_include("v8-gn.h") #error Missing v8-gn.h. The configuration for v8 is missing from the include \ path. Add it with -I to the command line #endif @@ -23,6 +31,8 @@ path. Add it with -I to the command line # include #elif defined(__linux__) # include +#elif defined(__MVS__) +# include "zos-base.h" #endif @@ -83,6 +93,7 @@ path. Add it with -I to the command line // V8_OS_STARBOARD - Starboard (platform abstraction for Cobalt) // V8_OS_AIX - AIX // V8_OS_WIN - Microsoft Windows +// V8_OS_ZOS - z/OS #if defined(__ANDROID__) # define V8_OS_ANDROID 1 @@ -163,6 +174,11 @@ path. Add it with -I to the command line #elif defined(_WIN32) # define V8_OS_WIN 1 # define V8_OS_STRING "windows" + +#elif defined(__MVS__) +# define V8_OS_POSIX 1 +# define V8_OS_ZOS 1 +# define V8_OS_STRING "zos" #endif // ----------------------------------------------------------------------------- @@ -477,22 +493,32 @@ path. Add it with -I to the command line # define V8_INLINE inline #endif +#if V8_HAS_BUILTIN_ASSUME #ifdef DEBUG -// In debug mode, check assumptions instead of actually adding annotations. -# define V8_ASSUME DCHECK -#elif V8_HAS_BUILTIN_ASSUME +// In debug mode, check assumptions in addition to adding annotations. +// This helps GCC (and maybe other compilers) figure out that certain +// situations are unreachable. +# define V8_ASSUME(condition) \ + do { \ + DCHECK(condition); \ + __builtin_assume(condition); \ + } while (false) +#else // DEBUG # define V8_ASSUME __builtin_assume +#endif // DEBUG #elif V8_HAS_BUILTIN_UNREACHABLE # define V8_ASSUME(condition) \ do { \ + DCHECK(condition); \ if (!(condition)) __builtin_unreachable(); \ } while (false) #else # define V8_ASSUME USE #endif -// Prefer c++20 std::assume_aligned -#if __cplusplus >= 202002L && defined(__cpp_lib_assume_aligned) +// Prefer c++20 std::assume_aligned. Don't use it on MSVC though, because it's +// not happy with our large 4GB alignment values. +#if __cplusplus >= 202002L && defined(__cpp_lib_assume_aligned) && !V8_CC_MSVC # define V8_ASSUME_ALIGNED(ptr, alignment) \ std::assume_aligned<(alignment)>(ptr) #elif V8_HAS_BUILTIN_ASSUME_ALIGNED diff --git a/deps/v8/infra/builder_properties.pyl b/deps/v8/infra/builder_properties.pyl new file mode 100644 index 00000000000000..af627c5bef31d7 --- /dev/null +++ b/deps/v8/infra/builder_properties.pyl @@ -0,0 +1,23 @@ +# Copyright 2024 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Override builder properties in V8's CI. This can be useful if a configuration +# change is suspected to cause a regression, and should be aligned with a +# specific V8 commit. + +# A typical scenario is a performance bot change. The perf bot itself is defined +# on the recipe side and applied independent of the V8 revision. A regression +# might falsely suspect the first revision using the new bot. Using this file, +# the bot can be migrated in a three step approach: + +# 1. Add {'buildername': {'swarming_bot_ids': ['new-bot']}} to this file. + +# It might take a while till all relevant CI bots have processed this revision. +# Cherry-picks for branches might also be needed. + +# 2. Add the new bot to the recipe itself. +# 3. Remove the override in this file again to ensure there is a single +# configuration only. + +{} diff --git a/deps/v8/infra/mb/mb_config.pyl b/deps/v8/infra/mb/mb_config.pyl index a498d240e3fd83..838e65812faa3a 100644 --- a/deps/v8/infra/mb/mb_config.pyl +++ b/deps/v8/infra/mb/mb_config.pyl @@ -66,7 +66,6 @@ 'V8 Linux - verify csa - builder': 'release_x86_verify_csa', # Linux64. 'V8 Linux64 - builder': 'release_x64_gcmole', - 'V8 Linux64 - builder (goma cache silo)': 'release_x64', 'V8 Linux64 - builder (reclient)': 'release_x64_reclient', 'V8 Linux64 - builder (reclient compare)': 'release_x64_reclient', 'V8 Linux64 - official - builder': 'official_x64_on_release_branch', @@ -82,8 +81,8 @@ 'V8 Linux64 - verify csa - builder': 'release_x64_verify_csa', 'V8 Linux64 - no wasm - builder': 'release_x64_webassembly_disabled', # Windows. + 'V8 Win - arm64 - debug builder': 'debug_arm64', 'V8 Win32 - builder': 'release_x86_minimal_symbols', - 'V8 Win32 - builder (goma cache silo)': 'release_x86', 'V8 Win32 - builder (reclient)': 'release_x86_minimal_symbols_reclient', 'V8 Win32 - builder (reclient compare)': 'release_x86_minimal_symbols_reclient', 'V8 Win32 - debug builder': 'debug_x86_minimal_symbols', @@ -95,6 +94,7 @@ 'V8 Win64 - builder (reclient compare)': 'release_x64_minimal_symbols_reclient', 'V8 Win64 - dev image': 'release_x64_minimal_symbols', 'V8 Win64 - debug builder': 'debug_x64_minimal_symbols', + 'V8 Win64 - drumbrake - debug builder': 'debug_x64_drumbrake', 'V8 Win64 - msvc - builder': 'release_x64_msvc', # Mac. 'V8 Mac64 - builder': 'release_x64', @@ -128,9 +128,12 @@ 'V8 Linux64 - disable runtime call stats - builder': 'release_x64_disable_runtime_call_stats', 'V8 Linux64 - debug - single generation - builder': 'debug_x64_single_generation', 'V8 Linux64 - no pointer compression - builder': 'release_x64_no_pointer_compression', + 'V8 Linux64 - sticky mark bits - debug builder': 'debug_x64_sticky_mark_bits', 'V8 Linux64 css - debug builder': 'debug_x64_conservative_stack_scanning', 'V8 Linux64 gcc - builder': 'release_x64_gcc', + 'V8 Linux64 - jammy - gcc - builder': 'release_x64_gcc', 'V8 Linux64 gcc - debug builder': 'debug_x64_gcc', + 'V8 Linux64 - jammy - gcc - debug builder': 'debug_x64_gcc', 'V8 Linux64 gcc light - debug builder': 'debug_x64_gcc', 'V8 Fuchsia - builder': 'release_x64_fuchsia', 'V8 Fuchsia - debug builder': 'debug_x64_fuchsia', @@ -217,6 +220,7 @@ 'V8 Arm - builder': 'release_arm', 'V8 Arm - debug builder': 'debug_arm', 'V8 Android Arm - builder': 'release_android_arm', + 'V8 Android Arm - verify deterministic - debug': 'debug_android_arm_verify_deterministic', 'V8 Linux - arm - sim - builder': 'release_simulate_arm_gcmole', 'V8 Linux - arm - sim - debug builder': 'debug_simulate_arm', 'V8 Linux - arm - sim - lite - builder': 'release_simulate_arm_lite', @@ -243,6 +247,7 @@ }, 'tryserver.v8': { 'v8_android_arm_compile_rel': 'release_android_arm', + 'v8_android_arm_verify_deterministic_dbg': 'debug_android_arm_verify_deterministic', 'v8_android_arm64_compile_dbg': 'debug_android_arm64', 'v8_android_arm64_n5x_compile_rel': 'release_android_arm64', 'v8_android_arm64_d8_compile_rel': 'release_android_arm64', @@ -253,6 +258,7 @@ 'v8_linux_verify_csa_compile_rel': 'release_x86_verify_csa', 'v8_linux_nodcheck_compile_rel': 'release_x86_minimal_symbols', 'v8_linux_compile_dbg': 'debug_x86_trybot', + 'v8_linux_full_compile_dbg': 'full_debug_x86', 'v8_linux_noi18n_compile_dbg': 'debug_x86_no_i18n', 'v8_linux_noi18n_compile_rel': 'release_x86_no_i18n_trybot', 'v8_linux_gc_stress_compile_dbg': 'debug_x86_trybot', @@ -278,8 +284,10 @@ 'v8_linux64_gc_stress_custom_snapshot_compile_dbg': 'debug_x64_trybot_custom', 'v8_linux64_gc_stress_compile_dbg': 'debug_x64_trybot', 'v8_linux64_gcc_compile_dbg': 'debug_x64_gcc', + 'v8_linux64_jammy_gcc_compile_dbg': 'debug_x64_gcc', 'v8_linux64_gcc_light_compile_dbg': 'debug_x64_gcc', 'v8_linux64_gcc_compile_rel': 'release_x64_gcc', + 'v8_linux64_jammy_gcc_compile_rel': 'release_x64_gcc', 'v8_linux64_header_includes_dbg': 'debug_x64_header_includes', 'v8_linux64_minor_mc_compile_dbg': 'debug_x64_trybot', 'v8_linux64_fyi_compile_rel': 'release_x64_test_features_trybot', @@ -306,6 +314,7 @@ 'v8_linux_riscv32_compile_rel': 'release_simulate_riscv32', 'v8_linux64_riscv64_compile_rel': 'release_simulate_riscv64', 'v8_linux64_riscv64_pointer_compression_compile_rel': 'release_simulate_riscv64_pointer_compression', + 'v8_linux64_sticky_mark_bits_compile_dbg': 'debug_x64_sticky_mark_bits', 'v8_linux64_tsan_compile_rel': 'release_x64_tsan_minimal_symbols', 'v8_linux64_tsan_compile_dbg': 'debug_x64_tsan_minimal_symbols', 'v8_linux64_tsan_no_cm_compile_rel': 'release_x64_tsan_no_cm', @@ -314,8 +323,8 @@ 'v8_linux64_ubsan_compile_rel': 'release_x64_ubsan_minimal_symbols', 'v8_linux64_verify_builtins_rel': 'release_x64_verify_builtins', 'v8_linux64_verify_deterministic_rel': 'release_x64_verify_deterministic', - 'v8_odroid_arm_compile_rel': 'release_arm', 'v8_linux_torque_compare': 'torque_compare', + 'v8_win_arm64_compile_dbg': 'debug_arm64', # TODO(machenbach): Remove after switching to x64 on infra side. 'v8_win_compile_dbg': 'debug_x86_trybot', 'v8_win_compile_rel': 'release_x86_trybot', @@ -323,6 +332,7 @@ 'v8_win64_asan_compile_rel': 'release_x64_asan_no_lsan', 'v8_win64_msvc_light_compile_rel': 'release_x64_msvc', 'v8_win64_compile_dbg': 'debug_x64_minimal_symbols', + 'v8_win64_drumbrake_compile_dbg': 'debug_x64_drumbrake', 'v8_win64_msvc_compile_rel': 'release_x64_msvc', 'v8_win64_compile_rel': 'release_x64_trybot', 'v8_mac_arm64_compile_rel': 'release_arm64', @@ -349,6 +359,12 @@ 'v8_numfuzz_compile_rel': 'release_x64', 'v8_numfuzz_compile_dbg': 'debug_x64', 'v8_numfuzz_tsan_compile_rel': 'release_x64_tsan', + + # PGO + 'v8_linux_pgo_compile_rel' : 'builtins_profiling_x86', + 'v8_linux64_pgo_compile_rel' : 'builtins_profiling_x64', + 'v8_win_pgo_compile_rel' : 'builtins_profiling_x86', + 'v8_win64_pgo_compile_rel' : 'builtins_profiling_x64', }, }, @@ -491,6 +507,8 @@ 'release_bot', 'simulate_s390x'], # Debug configs for arm. + 'debug_android_arm_verify_deterministic': [ + 'debug_bot', 'arm', 'android', 'minimal_symbols', 'v8_verify_deterministic'], 'debug_android_arm64': [ 'debug_bot', 'arm64', 'android', 'minimal_symbols'], 'debug_arm': [ @@ -673,6 +691,8 @@ 'debug_bot', 'x64', 'clang_coverage'], 'debug_x64_custom': [ 'debug_bot', 'x64', 'v8_snapshot_custom'], + 'debug_x64_drumbrake': [ + 'debug_bot', 'x64', 'v8_enable_drumbrake'], 'debug_x64_external_code_space': [ 'debug_bot', 'x64', 'external_code_space'], 'debug_x64_fuchsia': [ @@ -693,6 +713,8 @@ 'debug_bot', 'x64', 'no_sandbox'], 'debug_x64_single_generation': [ 'debug_bot', 'x64', 'v8_enable_single_generation'], + 'debug_x64_sticky_mark_bits': [ + 'debug_bot', 'x64', 'v8_enable_sticky_mark_bits'], 'debug_x64_trybot': [ 'debug_trybot', 'x64'], 'debug_x64_dict_tracking_trybot': [ @@ -724,8 +746,6 @@ 'debug', 'x86', 'reclient', 'v8_enable_slow_dchecks', 'v8_full_debug'], # Release configs for x86. - 'release_x86': [ - 'release_bot', 'x86'], 'release_x86_asan_symbolized_verify_heap': [ 'release_bot', 'x86', 'asan', 'lsan', 'symbolized', 'v8_verify_heap'], @@ -889,7 +909,7 @@ }, 'ios_simulator': { - 'gn_args': 'target_cpu="x64" target_os="ios"', + 'gn_args': 'target_cpu="x64" target_os="ios" use_blink=true', }, 'lld': { @@ -907,12 +927,12 @@ 'msan': { 'mixins': ['v8_enable_test_features'], - 'gn_args': 'is_msan=true msan_track_origins=2 instrumented_libraries_release="focal"', + 'gn_args': 'is_msan=true msan_track_origins=2 instrumented_libraries_release="noble"', }, 'msan_no_origins': { 'mixins': ['v8_enable_test_features'], - 'gn_args': 'is_msan=true msan_track_origins=0 instrumented_libraries_release="focal"', + 'gn_args': 'is_msan=true msan_track_origins=0 instrumented_libraries_release="noble"', }, 'msvc': { @@ -1056,6 +1076,10 @@ 'gn_args': 'v8_enable_verify_heap=false', }, + 'v8_enable_drumbrake': { + 'gn_args': 'v8_enable_drumbrake=true', + }, + 'v8_enable_memory_corruption_api': { 'gn_args': 'v8_enable_memory_corruption_api=true', }, @@ -1101,6 +1125,9 @@ 'gn_args': 'v8_enable_single_generation=true ' 'v8_disable_write_barriers=true', }, + 'v8_enable_sticky_mark_bits': { + 'gn_args': 'v8_enable_sticky_mark_bits=true', + }, 'v8_enable_test_features': { 'gn_args': 'v8_enable_test_features=true', }, diff --git a/deps/v8/infra/testing/builders.pyl b/deps/v8/infra/testing/builders.pyl index 7655763cab411c..194928d35984e0 100644 --- a/deps/v8/infra/testing/builders.pyl +++ b/deps/v8/infra/testing/builders.pyl @@ -110,6 +110,14 @@ }, ], }, + 'v8_linux_full_dbg': { + 'swarming_dimensions': { + 'os': 'Ubuntu-22.04', + }, + 'tests': [ + {'name': 'v8testing', 'variant': 'default', 'shards': 6}, + ], + }, 'v8_linux_gc_stress_dbg': { 'swarming_dimensions' : { 'os': 'Ubuntu-22.04', @@ -546,6 +554,14 @@ {'name': 'v8testing'}, ], }, + 'v8_linux64_jammy_gcc_rel': { + 'swarming_dimensions' : { + 'os': 'Ubuntu-22.04', + }, + 'tests': [ + {'name': 'v8testing'}, + ], + }, 'v8_linux64_minor_mc_dbg': { 'swarming_dimensions' : { 'cpu': 'x86-64-avx2', @@ -649,6 +665,15 @@ {'name': 'v8testing', 'variant': 'default'}, ], }, + 'v8_linux64_sandbox_testing_rel': { + 'swarming_dimensions' : { + 'cpu': 'x86-64', + 'os': 'Ubuntu-22.04', + }, + 'tests': [ + {'name': 'mjsunit', 'variant': 'default'}, + ], + }, 'v8_linux64_single_generation_dbg': { 'swarming_dimensions' : { 'os': 'Ubuntu-22.04', @@ -657,6 +682,15 @@ {'name': 'v8testing', 'shards': 3}, ], }, + 'v8_linux64_sticky_mark_bits_dbg': { + 'swarming_dimensions' : { + 'os': 'Ubuntu-22.04', + 'cpu': 'x86-64', + }, + 'tests': [ + {'name': 'v8testing', 'shards': 3}, + ], + }, 'v8_linux64_rel': { 'swarming_dimensions' : { 'cpu': 'x86-64-avx2', @@ -733,6 +767,7 @@ {'name': 'v8testing', 'variant': 'extra', 'shards': 6}, {'name': 'v8testing', 'variant': 'slow_path', 'shards': 2}, {'name': 'v8testing', 'variant': 'stress_concurrent_allocation', 'shards': 2}, + {'name': 'v8testing', 'variant': 'minor_ms', 'shards': 2}, ], }, 'v8_linux64_tsan_dbg': { @@ -870,24 +905,6 @@ ], }, ############################################################################## - # Odroids with native arm - 'v8_odroid_arm_rel': { - 'swarming_dimensions' : { - 'cores': '8', - 'cpu': 'armv7l-32-Hardkernel_ODROID-XU4', - 'os': 'Ubuntu', - }, - 'swarming_task_attrs': { - # Use same prio as CI due to limited resources. - 'priority': 25, - }, - 'tests': [ - {'name': 'benchmarks'}, - {'name': 'optimize_for_size'}, - {'name': 'v8testing', 'shards': 2}, - ], - }, - ############################################################################## # Win32 'v8_win_dbg': { 'swarming_dimensions' : { @@ -928,11 +945,21 @@ 'tests': [ {'name': 'mozilla'}, {'name': 'test262', 'variant': 'default', 'shards': 4}, - {'name': 'v8testing', 'shards': 3}, - {'name': 'v8testing', 'variant': 'extra', 'shards': 2}, + {'name': 'v8testing', 'shards': 4}, + {'name': 'v8testing', 'variant': 'extra', 'shards': 3}, {'name': 'v8testing', 'variant': 'minor_ms'}, ], }, + 'v8_win64_drumbrake_dbg': { + 'swarming_dimensions': { + 'cpu': 'x86-64', + 'os': 'Windows-10-19045', + }, + 'tests': [ + {'name': 'v8testing', 'shards': 4}, + {'name': 'v8testing', 'variant': 'extra', 'shards': 3}, + ], + }, 'v8_win64_msvc_rel': { 'swarming_dimensions' : { 'cpu': 'x86-64', @@ -1620,6 +1647,14 @@ {'name': 'v8testing'}, ], }, + 'V8 Linux64 - jammy - gcc': { + 'swarming_dimensions' : { + 'os': 'Ubuntu-22.04', + }, + 'tests': [ + {'name': 'v8testing'}, + ], + }, 'V8 Linux64 - gc stress': { 'swarming_dimensions': { 'cpu': 'x86-64-avx2', @@ -1698,6 +1733,15 @@ {'name': 'v8testing', 'shards': 2}, ], }, + 'V8 Linux64 - sandbox testing': { + 'swarming_dimensions' : { + 'cpu': 'x86-64', + 'os': 'Ubuntu-22.04', + }, + 'tests': [ + {'name': 'mjsunit', 'variant': 'default'}, + ], + }, 'V8 Linux64 - shared': { 'swarming_dimensions' : { 'os': 'Ubuntu-22.04', @@ -1708,6 +1752,15 @@ {'name': 'v8testing'}, ], }, + 'V8 Linux64 - sticky mark bits - debug': { + 'swarming_dimensions' : { + 'os': 'Ubuntu-22.04', + 'cpu': 'x86-64', + }, + 'tests': [ + {'name': 'v8testing', 'shards': 3}, + ], + }, 'V8 Linux64 - verify csa': { 'swarming_dimensions' : { 'os': 'Ubuntu-22.04', @@ -1770,6 +1823,7 @@ {'name': 'v8testing', 'variant': 'extra', 'shards': 5}, {'name': 'v8testing', 'variant': 'slow_path', 'shards': 2}, {'name': 'v8testing', 'variant': 'stress_concurrent_allocation', 'shards': 2}, + {'name': 'v8testing', 'variant': 'minor_ms', 'shards': 2}, ], }, 'V8 Linux64 TSAN - debug': { @@ -2005,6 +2059,21 @@ {'name': 'v8testing', 'variant': 'minor_ms'}, ], }, + 'V8 Win64 - drumbrake - debug': { + 'swarming_dimensions': { + 'cpu': 'x86-64', + 'os': 'Windows-10-19045', + }, + 'swarming_task_attrs': { + 'expiration': 14400, + 'hard_timeout': 7200, + 'priority': 35, + }, + 'tests': [ + {'name': 'v8testing', 'shards': 4}, + {'name': 'v8testing', 'variant': 'extra', 'shards': 3}, + ], + }, 'V8 Win64 - msvc': { 'swarming_dimensions': { 'os': 'Windows-10-19045', @@ -2045,83 +2114,6 @@ {'name': 'v8testing', 'variant': 'default', 'shards': 4}, ], }, - 'V8 Arm': { - 'swarming_dimensions': { - 'cores': '8', - 'cpu': 'armv7l-32-Hardkernel_ODROID-XU4', - 'os': 'Ubuntu', - }, - 'swarming_task_attrs': { - 'expiration': 21600, - 'hard_timeout': 5400, - }, - 'tests': [ - # Odroid. - { - 'name': 'benchmarks', - 'suffix': 'ODROID', - # Less parallelism to prevent OOMs in benchmarks. - 'test_args': ['-j2'], - }, - { - 'name': 'optimize_for_size', - 'suffix': 'ODROID', - }, - { - 'name': 'v8testing', - 'suffix': 'ODROID', - 'shards': 2, - }, - ], - }, - 'V8 Arm - debug': { - 'swarming_dimensions': { - 'cores': '8', - 'cpu': 'armv7l-32-Hardkernel_ODROID-XU4', - 'os': 'Ubuntu', - }, - 'swarming_task_attrs': { - 'expiration': 21600, - 'hard_timeout': 3600, - }, - 'tests': [ - # Odroid. - { - 'name': 'optimize_for_size', - 'suffix': 'ODROID', - 'variant': 'default', - 'test_args': ['--extra-flags=--verify-heap-skip-remembered-set'], - 'shards': 2, - }, - { - 'name': 'v8testing', - 'suffix': 'ODROID', - 'variant': 'default', - 'test_args': ['--extra-flags=--verify-heap-skip-remembered-set'], - 'shards': 3, - }, - ], - }, - 'V8 Arm GC Stress': { - 'swarming_dimensions': { - 'cores': '8', - 'cpu': 'armv7l-32-Hardkernel_ODROID-XU4', - 'os': 'Ubuntu', - }, - 'swarming_task_attrs': { - 'expiration': 21600, - 'hard_timeout': 7200, - }, - 'tests': [ - { - 'name': 'd8testing', - 'suffix': 'ODROID', - 'variant': 'default', - 'test_args': ['--gc-stress', '--extra-flags=--verify-heap-skip-remembered-set'], - 'shards': 3, - }, - ], - }, 'V8 Linux - arm - sim': { 'swarming_dimensions': { 'os': 'Ubuntu-22.04', @@ -2689,6 +2681,40 @@ }, ], }, + # PGO + 'v8_linux_pgo_rel' : { + 'swarming_dimensions' : { + 'os': 'Ubuntu-22.04', + }, + 'tests': [ + {'name': 'pgo_instrumentation'} + ], + }, + 'v8_linux64_pgo_rel' : { + 'swarming_dimensions' : { + 'os': 'Ubuntu-22.04', + }, + 'tests': [ + {'name': 'pgo_instrumentation'} + ], + }, + 'v8_win_pgo_rel' : { + 'swarming_dimensions' : { + 'cpu': 'x86-64', + 'os': 'Windows-10-19045', + }, + 'tests': [ + {'name': 'pgo_instrumentation'} + ], + }, + 'v8_win64_pgo_rel' : { + 'swarming_dimensions' : { + 'os': 'Windows-10-19045', + }, + 'tests': [ + {'name': 'pgo_instrumentation'} + ], + }, # Try perf bots 'v8_android_arm_perf_try': { 'tests': [ diff --git a/deps/v8/samples/process.cc b/deps/v8/samples/process.cc index d773e9b9d1870c..af57f39a073a62 100644 --- a/deps/v8/samples/process.cc +++ b/deps/v8/samples/process.cc @@ -150,9 +150,10 @@ class JsHttpRequestProcessor : public HttpRequestProcessor { const PropertyCallbackInfo& info); // Callbacks that access maps - static void MapGet(Local name, const PropertyCallbackInfo& info); - static void MapSet(Local name, Local value, - const PropertyCallbackInfo& info); + static v8::Intercepted MapGet(Local name, + const PropertyCallbackInfo& info); + static v8::Intercepted MapSet(Local name, Local value, + const PropertyCallbackInfo& info); // Utility methods for wrapping C++ objects as JavaScript objects, // and going back again. @@ -399,13 +400,12 @@ string ObjectToString(v8::Isolate* isolate, Local value) { return string(*utf8_value); } - -void JsHttpRequestProcessor::MapGet(Local name, - const PropertyCallbackInfo& info) { - if (name->IsSymbol()) return; +v8::Intercepted JsHttpRequestProcessor::MapGet( + Local name, const PropertyCallbackInfo& info) { + if (name->IsSymbol()) return v8::Intercepted::kNo; // Fetch the map wrapped by this object. - map* obj = UnwrapMap(info.Holder()); + map* obj = UnwrapMap(info.HolderV2()); // Convert the JavaScript string to a std::string. string key = ObjectToString(info.GetIsolate(), name.As()); @@ -414,7 +414,7 @@ void JsHttpRequestProcessor::MapGet(Local name, map::iterator iter = obj->find(key); // If the key is not present return an empty handle as signal - if (iter == obj->end()) return; + if (iter == obj->end()) return v8::Intercepted::kNo; // Otherwise fetch the value and wrap it in a JavaScript string const string& value = (*iter).second; @@ -422,15 +422,16 @@ void JsHttpRequestProcessor::MapGet(Local name, String::NewFromUtf8(info.GetIsolate(), value.c_str(), NewStringType::kNormal, static_cast(value.length())).ToLocalChecked()); + return v8::Intercepted::kYes; } - -void JsHttpRequestProcessor::MapSet(Local name, Local value_obj, - const PropertyCallbackInfo& info) { - if (name->IsSymbol()) return; +v8::Intercepted JsHttpRequestProcessor::MapSet( + Local name, Local value_obj, + const PropertyCallbackInfo& info) { + if (name->IsSymbol()) return v8::Intercepted::kNo; // Fetch the map wrapped by this object. - map* obj = UnwrapMap(info.Holder()); + map* obj = UnwrapMap(info.HolderV2()); // Convert the key and value to std::strings. string key = ObjectToString(info.GetIsolate(), name.As()); @@ -438,12 +439,9 @@ void JsHttpRequestProcessor::MapSet(Local name, Local value_obj, // Update the map. (*obj)[key] = value; - - // Return the value; any non-empty handle will work. - info.GetReturnValue().Set(value_obj); + return v8::Intercepted::kYes; } - Local JsHttpRequestProcessor::MakeMapTemplate( Isolate* isolate) { EscapableHandleScope handle_scope(isolate); @@ -510,7 +508,7 @@ HttpRequest* JsHttpRequestProcessor::UnwrapRequest(Local obj) { void JsHttpRequestProcessor::GetPath(Local name, const PropertyCallbackInfo& info) { // Extract the C++ request object from the JavaScript wrapper. - HttpRequest* request = UnwrapRequest(info.Holder()); + HttpRequest* request = UnwrapRequest(info.HolderV2()); // Fetch the path. const string& path = request->Path(); @@ -524,7 +522,7 @@ void JsHttpRequestProcessor::GetPath(Local name, void JsHttpRequestProcessor::GetReferrer( Local name, const PropertyCallbackInfo& info) { - HttpRequest* request = UnwrapRequest(info.Holder()); + HttpRequest* request = UnwrapRequest(info.HolderV2()); const string& path = request->Referrer(); info.GetReturnValue().Set( String::NewFromUtf8(info.GetIsolate(), path.c_str(), @@ -534,7 +532,7 @@ void JsHttpRequestProcessor::GetReferrer( void JsHttpRequestProcessor::GetHost(Local name, const PropertyCallbackInfo& info) { - HttpRequest* request = UnwrapRequest(info.Holder()); + HttpRequest* request = UnwrapRequest(info.HolderV2()); const string& path = request->Host(); info.GetReturnValue().Set( String::NewFromUtf8(info.GetIsolate(), path.c_str(), @@ -544,7 +542,7 @@ void JsHttpRequestProcessor::GetHost(Local name, void JsHttpRequestProcessor::GetUserAgent( Local name, const PropertyCallbackInfo& info) { - HttpRequest* request = UnwrapRequest(info.Holder()); + HttpRequest* request = UnwrapRequest(info.HolderV2()); const string& path = request->UserAgent(); info.GetReturnValue().Set( String::NewFromUtf8(info.GetIsolate(), path.c_str(), @@ -560,18 +558,20 @@ Local JsHttpRequestProcessor::MakeRequestTemplate( result->SetInternalFieldCount(1); // Add accessors for each of the fields of the request. - result->SetAccessor( + result->SetNativeDataProperty( String::NewFromUtf8Literal(isolate, "path", NewStringType::kInternalized), GetPath); - result->SetAccessor(String::NewFromUtf8Literal(isolate, "referrer", - NewStringType::kInternalized), - GetReferrer); - result->SetAccessor( + result->SetNativeDataProperty( + String::NewFromUtf8Literal(isolate, "referrer", + NewStringType::kInternalized), + GetReferrer); + result->SetNativeDataProperty( String::NewFromUtf8Literal(isolate, "host", NewStringType::kInternalized), GetHost); - result->SetAccessor(String::NewFromUtf8Literal(isolate, "userAgent", - NewStringType::kInternalized), - GetUserAgent); + result->SetNativeDataProperty( + String::NewFromUtf8Literal(isolate, "userAgent", + NewStringType::kInternalized), + GetUserAgent); // Again, return the result through the current handle scope. return handle_scope.Escape(result); diff --git a/deps/v8/src/DEPS b/deps/v8/src/DEPS index d9c58d01236454..8cd950b5d1f5ea 100644 --- a/deps/v8/src/DEPS +++ b/deps/v8/src/DEPS @@ -1,5 +1,4 @@ include_rules = [ - "+base/trace_event/common/trace_event_common.h", "+src", "-src/asmjs", "+src/asmjs/asm-js.h", @@ -38,9 +37,10 @@ include_rules = [ "+src/heap/local-heap-inl.h", "+src/heap/pretenuring-handler-inl.h", # TODO(v8:10496): Don't expose memory chunk outside of heap/. - "+src/heap/mutable-page.h", - "+src/heap/mutable-page-inl.h", + "+src/heap/mutable-page-metadata.h", + "+src/heap/mutable-page-metadata-inl.h", "+src/heap/memory-chunk.h", + "+src/heap/page-metadata-inl.h", "+src/heap/paged-spaces-inl.h", "+src/heap/parked-scope-inl.h", "+src/heap/parked-scope.h", @@ -55,7 +55,7 @@ include_rules = [ "+src/interpreter/bytecode-array-iterator.h", "+src/interpreter/bytecode-array-random-iterator.h", "+src/interpreter/bytecode-decoder.h", - "+src/interpreter/bytecode-flags.h", + "+src/interpreter/bytecode-flags-and-tokens.h", "+src/interpreter/bytecode-register.h", "+src/interpreter/bytecodes.h", "+src/interpreter/interpreter.h", @@ -69,6 +69,7 @@ include_rules = [ "+src/regexp/regexp-flags.h", "+src/regexp/regexp-stack.h", "+src/regexp/regexp-utils.h", + "+src/tracing/trace-event-no-perfetto.h", "-src/trap-handler", "+src/trap-handler/handler-inside-posix.h", "+src/trap-handler/handler-inside-win.h", diff --git a/deps/v8/src/api/OWNERS b/deps/v8/src/api/OWNERS index eb4a9242713213..aa5d9dd1fbd95b 100644 --- a/deps/v8/src/api/OWNERS +++ b/deps/v8/src/api/OWNERS @@ -4,7 +4,6 @@ ishell@chromium.org jkummerow@chromium.org leszeks@chromium.org mlippautz@chromium.org -mslekova@chromium.org verwaest@chromium.org # For v8-debug.h implementations. diff --git a/deps/v8/src/api/api-arguments-inl.h b/deps/v8/src/api/api-arguments-inl.h index de2648c8d60528..3ebc8a185f1237 100644 --- a/deps/v8/src/api/api-arguments-inl.h +++ b/deps/v8/src/api/api-arguments-inl.h @@ -17,16 +17,6 @@ namespace v8 { namespace internal { -#if DEBUG -bool IsApiCallResultType(Tagged obj) { - if (IsSmi(obj)) return true; - DCHECK(IsHeapObject(obj)); - return (IsString(obj) || IsSymbol(obj) || IsJSReceiver(obj) || - IsHeapNumber(obj) || IsBigInt(obj) || IsUndefined(obj) || - IsTrue(obj) || IsFalse(obj) || IsNull(obj)); -} -#endif // DEBUG - CustomArgumentsBase::CustomArgumentsBase(Isolate* isolate) : Relocatable(isolate) {} @@ -40,28 +30,12 @@ template Handle CustomArguments::GetReturnValue(Isolate* isolate) const { // Check the ReturnValue. FullObjectSlot slot = slot_at(kReturnValueIndex); - // Nothing was set, return empty handle as per previous behaviour. - Tagged raw_object = *slot; - if (IsTheHole(raw_object, isolate)) return Handle(); - DCHECK(IsApiCallResultType(raw_object)); - return Handle::cast(Handle(slot.location())); -} - -template -template -Handle CustomArguments::GetReturnValueNoHoleCheck( - Isolate* isolate) const { - // Check the ReturnValue. - FullObjectSlot slot = slot_at(kReturnValueIndex); - // TODO(ishell): remove the hole check once it's no longer possible to set - // return value to the hole. - CHECK(!IsTheHole(*slot, isolate)); - DCHECK(IsApiCallResultType(*slot)); - return Handle::cast(Handle(slot.location())); + DCHECK(Is(*slot)); + return Cast(Handle(slot.location())); } inline Tagged PropertyCallbackArguments::holder() const { - return JSObject::cast(*slot_at(T::kHolderIndex)); + return Cast(*slot_at(T::kHolderIndex)); } inline Tagged PropertyCallbackArguments::receiver() const { @@ -69,7 +43,7 @@ inline Tagged PropertyCallbackArguments::receiver() const { } inline Tagged FunctionCallbackArguments::holder() const { - return JSReceiver::cast(*slot_at(T::kHolderIndex)); + return Cast(*slot_at(T::kHolderIndex)); } #define DCHECK_NAME_COMPATIBLE(interceptor, name) \ @@ -78,39 +52,46 @@ inline Tagged FunctionCallbackArguments::holder() const { DCHECK_IMPLIES(IsSymbol(*name), interceptor->can_intercept_symbols()); #define PREPARE_CALLBACK_INFO_ACCESSOR(ISOLATE, F, API_RETURN_TYPE, \ - ACCESSOR_INFO, RECEIVER, ACCESSOR_KIND) \ + ACCESSOR_INFO, RECEIVER, ACCESSOR_KIND, \ + EXCEPTION_CONTEXT) \ if (ISOLATE->should_check_side_effects() && \ !ISOLATE->debug()->PerformSideEffectCheckForAccessor( \ ACCESSOR_INFO, RECEIVER, ACCESSOR_KIND)) { \ return {}; \ } \ - ExternalCallbackScope call_scope(ISOLATE, FUNCTION_ADDR(F)); \ - PropertyCallbackInfo callback_info(values_); - -#define PREPARE_CALLBACK_INFO_INTERCEPTOR(ISOLATE, F, API_RETURN_TYPE, \ - INTERCEPTOR_INFO) \ - if (ISOLATE->should_check_side_effects() && \ - !ISOLATE->debug()->PerformSideEffectCheckForInterceptor( \ - INTERCEPTOR_INFO)) { \ - return {}; \ - } \ - ExternalCallbackScope call_scope(ISOLATE, FUNCTION_ADDR(F)); \ - PropertyCallbackInfo callback_info(values_); - -Handle FunctionCallbackArguments::Call( - Tagged function) { + const PropertyCallbackInfo& callback_info = \ + GetPropertyCallbackInfo(); \ + ExternalCallbackScope call_scope(ISOLATE, FUNCTION_ADDR(F), \ + EXCEPTION_CONTEXT, &callback_info); + +#define PREPARE_CALLBACK_INFO_INTERCEPTOR(ISOLATE, F, API_RETURN_TYPE, \ + INTERCEPTOR_INFO, EXCEPTION_CONTEXT) \ + if (ISOLATE->should_check_side_effects() && \ + !ISOLATE->debug()->PerformSideEffectCheckForInterceptor( \ + INTERCEPTOR_INFO)) { \ + return {}; \ + } \ + const PropertyCallbackInfo& callback_info = \ + GetPropertyCallbackInfo(); \ + ExternalCallbackScope call_scope(ISOLATE, FUNCTION_ADDR(F), \ + EXCEPTION_CONTEXT, &callback_info); + +Handle FunctionCallbackArguments::CallOrConstruct( + Tagged function, bool is_construct) { Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kFunctionCallback); v8::FunctionCallback f = reinterpret_cast(function->callback(isolate)); - Handle receiver_check_unsupported; if (isolate->should_check_side_effects() && !isolate->debug()->PerformSideEffectCheckForCallback( handle(function, isolate))) { return {}; } - ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); FunctionCallbackInfo info(values_, argv_, argc_); + ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f), + is_construct ? ExceptionContext::kConstructor + : ExceptionContext::kOperation, + &info); f(info); return GetReturnValue(isolate); } @@ -126,353 +107,333 @@ PropertyCallbackArguments::~PropertyCallbackArguments(){ #endif // DEBUG } +Maybe PropertyCallbackArguments::GetBooleanReturnValue( + v8::Intercepted intercepted, const char* callback_kind_for_error_message, + bool ignore_return_value) { + Isolate* isolate = this->isolate(); + if (isolate->has_exception()) { + // TODO(ishell, 328490288): fix Node.js which has Setter/Definer + // interceptor callbacks not returning v8::Intercepted::kYes on exceptions. + if ((false) && DEBUG_BOOL && (intercepted == v8::Intercepted::kNo)) { + FATAL( + "Check failed: %s interceptor callback has thrown an " + "exception but hasn't returned v8::Intercepted::kYes.", + callback_kind_for_error_message); + } + return Nothing(); + } + + if (intercepted == v8::Intercepted::kNo) { + // Not intercepted, there must be no side effects including exceptions. + DCHECK(!isolate->has_exception()); + return Just(InterceptorResult::kNotIntercepted); + } + DCHECK_EQ(intercepted, v8::Intercepted::kYes); + AcceptSideEffects(); + + if (ignore_return_value) return Just(InterceptorResult::kTrue); + + bool result = IsTrue(*GetReturnValue(isolate), isolate); + + // TODO(ishell, 348688196): ensure callbacks comply with this and + // enable the check. + if ((false) && DEBUG_BOOL && !result && ShouldThrowOnError()) { + FATAL( + "Check failed: %s interceptor callback hasn't thrown an " + "exception on failure as requested.", + callback_kind_for_error_message); + } + return Just(result ? InterceptorResult::kTrue : InterceptorResult::kFalse); +} + // ------------------------------------------------------------------------- // Named Interceptor callbacks. -Handle PropertyCallbackArguments::CallNamedEnumerator( +Handle PropertyCallbackArguments::CallNamedEnumerator( Handle interceptor) { DCHECK(interceptor->is_named()); RCS_SCOPE(isolate(), RuntimeCallCounterId::kNamedEnumeratorCallback); return CallPropertyEnumerator(interceptor); } +// TODO(ishell): return std::optional. Handle PropertyCallbackArguments::CallNamedQuery( Handle interceptor, Handle name) { DCHECK_NAME_COMPATIBLE(interceptor, name); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedQueryCallback); - Handle receiver_check_unsupported; - if (interceptor->has_new_callbacks_signature()) { - NamedPropertyQueryCallback f = - ToCData(interceptor->query()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Integer, interceptor); - auto intercepted = f(v8::Utils::ToLocal(name), callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - return GetReturnValueNoHoleCheck(isolate); - - } else { - GenericNamedPropertyQueryCallback f = - ToCData(interceptor->query()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Integer, interceptor); - f(v8::Utils::ToLocal(name), callback_info); - return GetReturnValue(isolate); - } + slot_at(kPropertyKeyIndex).store(*name); + slot_at(kReturnValueIndex).store(Smi::FromInt(v8::None)); + NamedPropertyQueryCallback f = + ToCData( + interceptor->query()); + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Integer, interceptor, + ExceptionContext::kNamedQuery); + v8::Intercepted intercepted = f(v8::Utils::ToLocal(name), callback_info); + if (intercepted == v8::Intercepted::kNo) return {}; + return GetReturnValue(isolate); } -Handle PropertyCallbackArguments::CallNamedGetter( +Handle PropertyCallbackArguments::CallNamedGetter( Handle interceptor, Handle name) { DCHECK_NAME_COMPATIBLE(interceptor, name); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedGetterCallback); - if (interceptor->has_new_callbacks_signature()) { - NamedPropertyGetterCallback f = - ToCData(interceptor->getter()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); - auto intercepted = f(v8::Utils::ToLocal(name), callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - return GetReturnValueNoHoleCheck(isolate); - - } else { - GenericNamedPropertyGetterCallback f = - ToCData(interceptor->getter()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); - f(v8::Utils::ToLocal(name), callback_info); - return GetReturnValue(isolate); - } + slot_at(kPropertyKeyIndex).store(*name); + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); + NamedPropertyGetterCallback f = + ToCData( + interceptor->getter()); + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor, + ExceptionContext::kNamedGetter); + v8::Intercepted intercepted = f(v8::Utils::ToLocal(name), callback_info); + if (intercepted == v8::Intercepted::kNo) return {}; + return GetReturnValue(isolate); } -Handle PropertyCallbackArguments::CallNamedDescriptor( +Handle PropertyCallbackArguments::CallNamedDescriptor( Handle interceptor, Handle name) { DCHECK_NAME_COMPATIBLE(interceptor, name); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedDescriptorCallback); - if (interceptor->has_new_callbacks_signature()) { - NamedPropertyDescriptorCallback f = - ToCData(interceptor->descriptor()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); - auto intercepted = f(v8::Utils::ToLocal(name), callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - return GetReturnValueNoHoleCheck(isolate); - - } else { - GenericNamedPropertyDescriptorCallback f = - ToCData( - interceptor->descriptor()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); - f(v8::Utils::ToLocal(name), callback_info); - return GetReturnValue(isolate); - } + slot_at(kPropertyKeyIndex).store(*name); + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); + NamedPropertyDescriptorCallback f = + ToCData( + interceptor->descriptor()); + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor, + ExceptionContext::kNamedDescriptor); + v8::Intercepted intercepted = f(v8::Utils::ToLocal(name), callback_info); + if (intercepted == v8::Intercepted::kNo) return {}; + return GetReturnValue(isolate); } -// TODO(ishell): just return v8::Intercepted. -Handle PropertyCallbackArguments::CallNamedSetter( - Handle interceptor, Handle name, +v8::Intercepted PropertyCallbackArguments::CallNamedSetter( + DirectHandle interceptor, Handle name, Handle value) { DCHECK_NAME_COMPATIBLE(interceptor, name); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedSetterCallback); - if (interceptor->has_new_callbacks_signature()) { - NamedPropertySetterCallback f = - ToCData(interceptor->setter()); - Handle has_side_effects; - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, void, has_side_effects); - auto intercepted = - f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - // Non-empty handle indicates that the request was intercepted. - return isolate->factory()->undefined_value(); - - } else { - GenericNamedPropertySetterCallback f = - ToCData(interceptor->setter()); - Handle has_side_effects; - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, has_side_effects); - f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), callback_info); - return GetReturnValue(isolate); - } + slot_at(kPropertyKeyIndex).store(*name); + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).true_value()); + NamedPropertySetterCallback f = + ToCData( + interceptor->setter()); + Handle has_side_effects; + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, void, has_side_effects, + ExceptionContext::kNamedSetter); + v8::Intercepted intercepted = + f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), callback_info); + return intercepted; } -// TODO(ishell): just return v8::Intercepted. -Handle PropertyCallbackArguments::CallNamedDefiner( - Handle interceptor, Handle name, +v8::Intercepted PropertyCallbackArguments::CallNamedDefiner( + DirectHandle interceptor, Handle name, const v8::PropertyDescriptor& desc) { DCHECK_NAME_COMPATIBLE(interceptor, name); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedDefinerCallback); - if (interceptor->has_new_callbacks_signature()) { - NamedPropertyDefinerCallback f = - ToCData(interceptor->definer()); - Handle has_side_effects; - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, void, has_side_effects); - auto intercepted = f(v8::Utils::ToLocal(name), desc, callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - // Non-empty handle indicates that the request was intercepted. - return isolate->factory()->undefined_value(); - - } else { - GenericNamedPropertyDefinerCallback f = - ToCData(interceptor->definer()); - Handle has_side_effects; - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, has_side_effects); - f(v8::Utils::ToLocal(name), desc, callback_info); - return GetReturnValue(isolate); - } + slot_at(kPropertyKeyIndex).store(*name); + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).true_value()); + NamedPropertyDefinerCallback f = + ToCData(interceptor->definer()); + Handle has_side_effects; + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, void, has_side_effects, + ExceptionContext::kNamedDefiner); + v8::Intercepted intercepted = + f(v8::Utils::ToLocal(name), desc, callback_info); + return intercepted; } -// TODO(ishell): return Handle -Handle PropertyCallbackArguments::CallNamedDeleter( - Handle interceptor, Handle name) { +v8::Intercepted PropertyCallbackArguments::CallNamedDeleter( + DirectHandle interceptor, Handle name) { DCHECK_NAME_COMPATIBLE(interceptor, name); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedDeleterCallback); - if (interceptor->has_new_callbacks_signature()) { - NamedPropertyDeleterCallback f = - ToCData(interceptor->deleter()); - Handle has_side_effects; - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Boolean, - has_side_effects); - auto intercepted = f(v8::Utils::ToLocal(name), callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - return GetReturnValue(isolate); - - } else { - GenericNamedPropertyDeleterCallback f = - ToCData(interceptor->deleter()); - Handle has_side_effects; - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Boolean, - has_side_effects); - f(v8::Utils::ToLocal(name), callback_info); - return GetReturnValue(isolate); - } + slot_at(kPropertyKeyIndex).store(*name); + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).true_value()); + NamedPropertyDeleterCallback f = + ToCData(interceptor->deleter()); + Handle has_side_effects; + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Boolean, has_side_effects, + ExceptionContext::kNamedDeleter); + v8::Intercepted intercepted = f(v8::Utils::ToLocal(name), callback_info); + return intercepted; } // ------------------------------------------------------------------------- // Indexed Interceptor callbacks. -Handle PropertyCallbackArguments::CallIndexedEnumerator( +Handle PropertyCallbackArguments::CallIndexedEnumerator( Handle interceptor) { DCHECK(!interceptor->is_named()); RCS_SCOPE(isolate(), RuntimeCallCounterId::kIndexedEnumeratorCallback); return CallPropertyEnumerator(interceptor); } +// TODO(ishell): return std::optional. Handle PropertyCallbackArguments::CallIndexedQuery( Handle interceptor, uint32_t index) { DCHECK(!interceptor->is_named()); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kIndexedQueryCallback); - if (interceptor->has_new_callbacks_signature()) { - IndexedPropertyQueryCallbackV2 f = - ToCData(interceptor->query()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Integer, interceptor); - auto intercepted = f(index, callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - return GetReturnValueNoHoleCheck(isolate); - - } else { - IndexedPropertyQueryCallback f = - ToCData(interceptor->query()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Integer, interceptor); - f(index, callback_info); - return GetReturnValue(isolate); - } + index_ = index; + slot_at(kPropertyKeyIndex).store(Smi::zero()); // indexed callback marker + slot_at(kReturnValueIndex).store(Smi::FromInt(v8::None)); + IndexedPropertyQueryCallbackV2 f = + ToCData(interceptor->query()); + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Integer, interceptor, + ExceptionContext::kIndexedQuery); + v8::Intercepted intercepted = f(index, callback_info); + if (intercepted == v8::Intercepted::kNo) return {}; + return GetReturnValue(isolate); } -Handle PropertyCallbackArguments::CallIndexedGetter( +Handle PropertyCallbackArguments::CallIndexedGetter( Handle interceptor, uint32_t index) { DCHECK(!interceptor->is_named()); - RCS_SCOPE(isolate(), RuntimeCallCounterId::kNamedGetterCallback); - if (interceptor->has_new_callbacks_signature()) { - IndexedPropertyGetterCallbackV2 f = - ToCData(interceptor->getter()); - Isolate* isolate = this->isolate(); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); - auto intercepted = f(index, callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - return GetReturnValueNoHoleCheck(isolate); - - } else { - IndexedPropertyGetterCallback f = - ToCData(interceptor->getter()); - Isolate* isolate = this->isolate(); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); - f(index, callback_info); - return GetReturnValue(isolate); - } + Isolate* isolate = this->isolate(); + RCS_SCOPE(isolate, RuntimeCallCounterId::kNamedGetterCallback); + index_ = index; + slot_at(kPropertyKeyIndex).store(Smi::zero()); // indexed callback marker + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); + IndexedPropertyGetterCallbackV2 f = + ToCData(interceptor->getter()); + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor, + ExceptionContext::kIndexedGetter); + v8::Intercepted intercepted = f(index, callback_info); + if (intercepted == v8::Intercepted::kNo) return {}; + return GetReturnValue(isolate); } -Handle PropertyCallbackArguments::CallIndexedDescriptor( +Handle PropertyCallbackArguments::CallIndexedDescriptor( Handle interceptor, uint32_t index) { DCHECK(!interceptor->is_named()); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kIndexedDescriptorCallback); - if (interceptor->has_new_callbacks_signature()) { - IndexedPropertyDescriptorCallbackV2 f = - ToCData(interceptor->descriptor()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); - auto intercepted = f(index, callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - return GetReturnValueNoHoleCheck(isolate); - - } else { - IndexedPropertyDescriptorCallback f = - ToCData(interceptor->descriptor()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor); - f(index, callback_info); - return GetReturnValue(isolate); - } + index_ = index; + slot_at(kPropertyKeyIndex).store(Smi::zero()); // indexed callback marker + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); + IndexedPropertyDescriptorCallbackV2 f = + ToCData( + interceptor->descriptor()); + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, interceptor, + ExceptionContext::kIndexedDescriptor); + v8::Intercepted intercepted = f(index, callback_info); + if (intercepted == v8::Intercepted::kNo) return {}; + return GetReturnValue(isolate); } -// TODO(ishell): just return v8::Intercepted. -Handle PropertyCallbackArguments::CallIndexedSetter( - Handle interceptor, uint32_t index, Handle value) { +v8::Intercepted PropertyCallbackArguments::CallIndexedSetter( + DirectHandle interceptor, uint32_t index, + Handle value) { DCHECK(!interceptor->is_named()); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kIndexedSetterCallback); - if (interceptor->has_new_callbacks_signature()) { - IndexedPropertySetterCallbackV2 f = - ToCData(interceptor->setter()); - Handle has_side_effects; - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, void, has_side_effects); - auto intercepted = f(index, v8::Utils::ToLocal(value), callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - // Non-empty handle indicates that the request was intercepted. - return isolate->factory()->undefined_value(); - - } else { - IndexedPropertySetterCallback f = - ToCData(interceptor->setter()); - Handle has_side_effects; - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, has_side_effects); - f(index, v8::Utils::ToLocal(value), callback_info); - return GetReturnValue(isolate); - } + index_ = index; + slot_at(kPropertyKeyIndex).store(Smi::zero()); // indexed callback marker + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).true_value()); + IndexedPropertySetterCallbackV2 f = + ToCData(interceptor->setter()); + Handle has_side_effects; + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, void, has_side_effects, + ExceptionContext::kIndexedSetter); + v8::Intercepted intercepted = + f(index, v8::Utils::ToLocal(value), callback_info); + return intercepted; } -// TODO(ishell): just return v8::Intercepted. -Handle PropertyCallbackArguments::CallIndexedDefiner( - Handle interceptor, uint32_t index, +v8::Intercepted PropertyCallbackArguments::CallIndexedDefiner( + DirectHandle interceptor, uint32_t index, const v8::PropertyDescriptor& desc) { DCHECK(!interceptor->is_named()); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kIndexedDefinerCallback); - if (interceptor->has_new_callbacks_signature()) { - IndexedPropertyDefinerCallbackV2 f = - ToCData(interceptor->definer()); - Handle has_side_effects; - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, void, has_side_effects); - auto intercepted = f(index, desc, callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - // Non-empty handle indicates that the request was intercepted. - return isolate->factory()->undefined_value(); - - } else { - IndexedPropertyDefinerCallback f = - ToCData(interceptor->definer()); - Handle has_side_effects; - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Value, has_side_effects); - f(index, desc, callback_info); - return GetReturnValue(isolate); - } + index_ = index; + slot_at(kPropertyKeyIndex).store(Smi::zero()); // indexed callback marker + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).true_value()); + IndexedPropertyDefinerCallbackV2 f = + ToCData(interceptor->definer()); + Handle has_side_effects; + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, void, has_side_effects, + ExceptionContext::kIndexedDefiner); + v8::Intercepted intercepted = f(index, desc, callback_info); + return intercepted; } -// TODO(ishell): return Handle -Handle PropertyCallbackArguments::CallIndexedDeleter( +v8::Intercepted PropertyCallbackArguments::CallIndexedDeleter( Handle interceptor, uint32_t index) { DCHECK(!interceptor->is_named()); Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kIndexedDeleterCallback); - if (interceptor->has_new_callbacks_signature()) { - IndexedPropertyDeleterCallbackV2 f = - ToCData(interceptor->deleter()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Boolean, interceptor); - auto intercepted = f(index, callback_info); - if (intercepted == v8::Intercepted::kNo) return {}; - return GetReturnValueNoHoleCheck(isolate); - - } else { - IndexedPropertyDeleterCallback f = - ToCData(interceptor->deleter()); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Boolean, interceptor); - f(index, callback_info); - return GetReturnValue(isolate); - } + index_ = index; + slot_at(kPropertyKeyIndex).store(Smi::zero()); // indexed callback marker + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).true_value()); + IndexedPropertyDeleterCallbackV2 f = + ToCData(interceptor->deleter()); + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Boolean, interceptor, + ExceptionContext::kIndexedDeleter); + v8::Intercepted intercepted = f(index, callback_info); + return intercepted; } -Handle PropertyCallbackArguments::CallPropertyEnumerator( +Handle PropertyCallbackArguments::CallPropertyEnumerator( Handle interceptor) { // Named and indexed enumerator callbacks have same signatures. static_assert(std::is_same::value); - IndexedPropertyEnumeratorCallback f = - v8::ToCData(interceptor->enumerator()); Isolate* isolate = this->isolate(); - PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Array, interceptor); + slot_at(kPropertyKeyIndex).store(Smi::zero()); // not relevant + // Enumerator callback's return value is initialized with undefined even + // though it's supposed to return v8::Array. + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); + // TODO(ishell): consider making it return v8::Intercepted to indicate + // whether the result was set or not. + IndexedPropertyEnumeratorCallback f = + v8::ToCData( + interceptor->enumerator()); + PREPARE_CALLBACK_INFO_INTERCEPTOR(isolate, f, v8::Array, interceptor, + ExceptionContext::kNamedEnumerator); f(callback_info); - return GetReturnValue(isolate); + Handle result = GetReturnValue(isolate); + DCHECK(IsUndefined(*result) || IsJSObject(*result)); + return Cast(result); } // ------------------------------------------------------------------------- // Accessors -Handle PropertyCallbackArguments::CallAccessorGetter( - Handle info, Handle name) { +Handle PropertyCallbackArguments::CallAccessorGetter( + DirectHandle info, Handle name) { Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kAccessorGetterCallback); // Unlike interceptor callbacks we know that the property exists, so // the callback is allowed to have side effects. AcceptSideEffects(); + slot_at(kPropertyKeyIndex).store(*name); + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); AccessorNameGetterCallback f = reinterpret_cast(info->getter(isolate)); PREPARE_CALLBACK_INFO_ACCESSOR(isolate, f, v8::Value, info, - handle(receiver(), isolate), ACCESSOR_GETTER); + handle(receiver(), isolate), ACCESSOR_GETTER, + ExceptionContext::kAttributeGet); f(v8::Utils::ToLocal(name), callback_info); - return GetReturnValue(isolate); + return GetReturnValue(isolate); } -Handle PropertyCallbackArguments::CallAccessorSetter( - Handle accessor_info, Handle name, +bool PropertyCallbackArguments::CallAccessorSetter( + DirectHandle accessor_info, Handle name, Handle value) { Isolate* isolate = this->isolate(); RCS_SCOPE(isolate, RuntimeCallCounterId::kAccessorSetterCallback); @@ -480,12 +441,37 @@ Handle PropertyCallbackArguments::CallAccessorSetter( // the callback is allowed to have side effects. AcceptSideEffects(); + slot_at(kPropertyKeyIndex).store(*name); + slot_at(kReturnValueIndex).store(ReadOnlyRoots(isolate).true_value()); + // The actual type of setter callback is either + // v8::AccessorNameSetterCallback or + // i::Accesors::AccessorNameBooleanSetterCallback, depending on whether the + // AccessorInfo was created by the API or internally (see accessors.cc). + // Here we handle both cases using the AccessorNameSetterCallback signature + // and checking whether the returned result is set to default value + // (the undefined value). + // TODO(ishell, 348660658): update V8 Api to allow setter callbacks provide + // the result of [[Set]] operation according to JavaScript semantics. AccessorNameSetterCallback f = reinterpret_cast( accessor_info->setter(isolate)); PREPARE_CALLBACK_INFO_ACCESSOR(isolate, f, void, accessor_info, - handle(receiver(), isolate), ACCESSOR_SETTER); + handle(receiver(), isolate), ACCESSOR_SETTER, + ExceptionContext::kAttributeSet); f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), callback_info); - return GetReturnValue(isolate); + // Historically, in case of v8::AccessorNameSetterCallback it wasn't allowed + // to set the result and not setting the result was treated as successful + // execution. + // During interceptors Api refactoring it was temporarily allowed to call + // v8::ReturnValue::Set[NonEmpty](Local) and the result was just + // converted to v8::Boolean which was then treated as a result of [[Set]]. + // In case of AccessorNameBooleanSetterCallback, the result is always + // set to v8::Boolean or an exception is be thrown (in which case the + // result is ignored anyway). So, regardless of whether the signature was + // v8::AccessorNameSetterCallback or AccessorNameBooleanSetterCallback + // the result is guaranteed to be v8::Boolean value indicating success or + // failure. + Handle result = GetReturnValue(isolate); + return IsTrue(*result, isolate); } #undef PREPARE_CALLBACK_INFO_ACCESSOR diff --git a/deps/v8/src/api/api-arguments.cc b/deps/v8/src/api/api-arguments.cc index 289cd9f28b36f8..33d9d8fc7cc8f4 100644 --- a/deps/v8/src/api/api-arguments.cc +++ b/deps/v8/src/api/api-arguments.cc @@ -18,6 +18,13 @@ PropertyCallbackArguments::PropertyCallbackArguments( javascript_execution_counter_(isolate->javascript_execution_counter()) #endif // DEBUG { + if (DEBUG_BOOL) { + // Zap these fields to ensure that they are initialized by a subsequent + // CallXXX(..). + Tagged zap_value(kZapValue); + slot_at(T::kPropertyKeyIndex).store(zap_value); + slot_at(T::kReturnValueIndex).store(zap_value); + } slot_at(T::kThisIndex).store(self); slot_at(T::kHolderIndex).store(holder); slot_at(T::kDataIndex).store(data); @@ -28,32 +35,23 @@ PropertyCallbackArguments::PropertyCallbackArguments( value = should_throw.FromJust(); } slot_at(T::kShouldThrowOnErrorIndex).store(Smi::FromInt(value)); - // Here the hole is set as default value. - // It cannot escape into js as it's removed in Call below. - Tagged the_hole_value = ReadOnlyRoots(isolate).the_hole_value(); - slot_at(T::kReturnValueIndex).store(the_hole_value); - slot_at(T::kUnusedIndex).store(Smi::zero()); + slot_at(T::kHolderV2Index).store(Smi::zero()); DCHECK(IsHeapObject(*slot_at(T::kHolderIndex))); DCHECK(IsSmi(*slot_at(T::kIsolateIndex))); } FunctionCallbackArguments::FunctionCallbackArguments( - internal::Isolate* isolate, internal::Tagged data, - internal::Tagged holder, - internal::Tagged new_target, internal::Address* argv, + Isolate* isolate, Tagged target, + Tagged holder, Tagged new_target, Address* argv, int argc) : Super(isolate), argv_(argv), argc_(argc) { - slot_at(T::kDataIndex).store(data); + slot_at(T::kTargetIndex).store(target); slot_at(T::kHolderIndex).store(holder); slot_at(T::kNewTargetIndex).store(new_target); slot_at(T::kIsolateIndex) .store(Tagged(reinterpret_cast
(isolate))); - // Here the hole is set as default value. It's converted to and not - // directly exposed to js. - // TODO(cbruni): Remove and/or use custom sentinel value. - Tagged the_hole_value = ReadOnlyRoots(isolate).the_hole_value(); - slot_at(T::kReturnValueIndex).store(the_hole_value); - slot_at(T::kUnusedIndex).store(Smi::zero()); + slot_at(T::kReturnValueIndex).store(ReadOnlyRoots(isolate).undefined_value()); + slot_at(T::kContextIndex).store(isolate->context()); DCHECK(IsHeapObject(*slot_at(T::kHolderIndex))); DCHECK(IsSmi(*slot_at(T::kIsolateIndex))); } diff --git a/deps/v8/src/api/api-arguments.h b/deps/v8/src/api/api-arguments.h index 179559d8b251a0..22f583585edf6c 100644 --- a/deps/v8/src/api/api-arguments.h +++ b/deps/v8/src/api/api-arguments.h @@ -42,9 +42,6 @@ class CustomArguments : public CustomArgumentsBase { template Handle GetReturnValue(Isolate* isolate) const; - template - Handle GetReturnValueNoHoleCheck(Isolate* isolate) const; - inline Isolate* isolate() const { return reinterpret_cast((*slot_at(T::kIsolateIndex)).ptr()); } @@ -78,11 +75,18 @@ class PropertyCallbackArguments final static constexpr int kArgsLength = T::kArgsLength; static constexpr int kThisIndex = T::kThisIndex; static constexpr int kDataIndex = T::kDataIndex; - static constexpr int kUnusedIndex = T::kUnusedIndex; + static constexpr int kHolderV2Index = T::kHolderV2Index; static constexpr int kHolderIndex = T::kHolderIndex; static constexpr int kIsolateIndex = T::kIsolateIndex; static constexpr int kShouldThrowOnErrorIndex = T::kShouldThrowOnErrorIndex; - + static constexpr int kPropertyKeyIndex = T::kPropertyKeyIndex; + + // This constructor leaves kPropertyKeyIndex and kReturnValueIndex slots + // uninitialized in order to let them be initialized by the subsequent + // CallXXX(..) and avoid double initialization. As a consequence, there + // must be no GC call between this constructor and CallXXX(..). + // In debug mode these slots are zapped, so GC should be able to detect + // the misuse of this object. PropertyCallbackArguments(Isolate* isolate, Tagged data, Tagged self, Tagged holder, Maybe should_throw); @@ -96,52 +100,80 @@ class PropertyCallbackArguments final // ------------------------------------------------------------------------- // Accessor Callbacks - // Also used for AccessorSetterCallback. - inline Handle CallAccessorSetter(Handle info, - Handle name, - Handle value); - // Also used for AccessorGetterCallback, AccessorNameGetterCallback. - inline Handle CallAccessorGetter(Handle info, - Handle name); + + // Returns the result of [[Get]] operation or throws an exception. + // In case of exception empty handle is returned. + // TODO(ishell, 328490288): stop returning empty handles. + inline Handle CallAccessorGetter(DirectHandle info, + Handle name); + // Returns the result of [[Set]] operation or throws an exception. + V8_WARN_UNUSED_RESULT + inline bool CallAccessorSetter(DirectHandle info, + Handle name, Handle value); // ------------------------------------------------------------------------- // Named Interceptor Callbacks + + // Empty handle means that the request was not intercepted. + // Pending exception handling should be done by the caller. inline Handle CallNamedQuery(Handle interceptor, Handle name); - inline Handle CallNamedGetter(Handle interceptor, - Handle name); - inline Handle CallNamedSetter(Handle interceptor, - Handle name, - Handle value); - inline Handle CallNamedDefiner(Handle interceptor, - Handle name, - const v8::PropertyDescriptor& desc); - inline Handle CallNamedDeleter(Handle interceptor, - Handle name); - inline Handle CallNamedDescriptor(Handle interceptor, - Handle name); - inline Handle CallNamedEnumerator( + inline Handle CallNamedGetter(Handle interceptor, + Handle name); + + // Calls Setter/Definer/Deleter callback and returns whether the request + // was intercepted. + // Pending exception handling and interpretation of the result should be + // done by the caller using GetBooleanReturnValue(..). + inline v8::Intercepted CallNamedSetter( + DirectHandle interceptor, Handle name, + Handle value); + inline v8::Intercepted CallNamedDefiner( + DirectHandle interceptor, Handle name, + const v8::PropertyDescriptor& desc); + inline v8::Intercepted CallNamedDeleter( + DirectHandle interceptor, Handle name); + + // Empty handle means that the request was not intercepted. + // Pending exception handling should be done by the caller. + inline Handle CallNamedDescriptor(Handle interceptor, + Handle name); + // Returns JSArray-like object with property names or undefined. + inline Handle CallNamedEnumerator( Handle interceptor); // ------------------------------------------------------------------------- // Indexed Interceptor Callbacks + + // Empty handle means that the request was not intercepted. + // Pending exception handling should be done by the caller. inline Handle CallIndexedQuery(Handle interceptor, uint32_t index); - inline Handle CallIndexedGetter(Handle interceptor, - uint32_t index); - inline Handle CallIndexedSetter(Handle interceptor, - uint32_t index, Handle value); - inline Handle CallIndexedDefiner(Handle interceptor, - uint32_t index, - const v8::PropertyDescriptor& desc); - inline Handle CallIndexedDeleter(Handle interceptor, - uint32_t index); - inline Handle CallIndexedDescriptor( + inline Handle CallIndexedGetter(Handle interceptor, + uint32_t index); + + // Calls Setter/Definer/Deleter callback and returns whether the request + // was intercepted. + // Pending exception handling and interpretation of the result should be + // done by the caller using GetBooleanReturnValue(..). + inline v8::Intercepted CallIndexedSetter( + DirectHandle interceptor, uint32_t index, + Handle value); + inline v8::Intercepted CallIndexedDefiner( + DirectHandle interceptor, uint32_t index, + const v8::PropertyDescriptor& desc); + inline v8::Intercepted CallIndexedDeleter(Handle interceptor, + uint32_t index); + + // Empty handle means that the request was not intercepted. + // Pending exception handling should be done by the caller. + inline Handle CallIndexedDescriptor( Handle interceptor, uint32_t index); - inline Handle CallIndexedEnumerator( + // Returns JSArray-like object with property names or undefined. + inline Handle CallIndexedEnumerator( Handle interceptor); - // Accept potential JavaScript side effects that might occurr during life + // Accept potential JavaScript side effects that might occur during life // time of this object. inline void AcceptSideEffects() { #ifdef DEBUG @@ -149,21 +181,67 @@ class PropertyCallbackArguments final #endif // DEBUG } + // Converts the result of Setter/Definer/Deleter interceptor callback to + // Maybe. + // Currently, in certain scenarios the actual boolean result returned by + // the Setter/Definer operation is ignored and thus we don't need to process + // the actual return value. + inline Maybe GetBooleanReturnValue( + v8::Intercepted intercepted, const char* callback_kind_for_error_message, + bool ignore_return_value = false); + + // TODO(ishell): cleanup this hack by embedding the PropertyCallbackInfo + // into PropertyCallbackArguments object. + template + const v8::PropertyCallbackInfo& GetPropertyCallbackInfo() { + return *(reinterpret_cast*>(&values_[0])); + } + + // Forwards ShouldThrowOnError() request to the underlying + // v8::PropertyCallbackInfo<> object. + bool ShouldThrowOnError() { + return GetPropertyCallbackInfo().ShouldThrowOnError(); + } + + // Unofficial way of getting property key from v8::PropertyCallbackInfo. + template + static Tagged GetPropertyKey(const PropertyCallbackInfo& info) { + return Tagged(info.args_[kPropertyKeyIndex]); + } + template + static Handle GetPropertyKeyHandle( + const PropertyCallbackInfo& info) { + return Handle(&info.args_[kPropertyKeyIndex]); + } + + // Returns index value passed to CallIndexedXXX(). This works as long as + // all the calls to indexed interceptor callbacks are done via + // PropertyCallbackArguments. + template + static uint32_t GetPropertyIndex(const PropertyCallbackInfo& info) { + // Currently all indexed interceptor callbacks are called via + // PropertyCallbackArguments, so it's guaranteed that + // v8::PropertyCallbackInfo::args_ array IS the + // PropertyCallbackArguments::values_ array. As a result we can restore + // pointer to PropertyCallbackArguments object from the former. + Address ptr = reinterpret_cast
(&info.args_) - + offsetof(PropertyCallbackArguments, values_); + auto pca = reinterpret_cast(ptr); + return pca->index_; + } + private: - /* - * The following Call functions wrap the calling of all callbacks to handle - * calling either the old or the new style callbacks depending on which one - * has been registered. - * For old callbacks which return an empty handle, the ReturnValue is checked - * and used if it's been set to anything inside the callback. - * New style callbacks always use the return value. - */ - inline Handle CallPropertyEnumerator( + // Returns JSArray-like object with property names or undefined. + inline Handle CallPropertyEnumerator( Handle interceptor); inline Tagged holder() const; inline Tagged receiver() const; + // This field is used for propagating index value from CallIndexedXXX() + // to ExceptionPropagationCallback. + uint32_t index_ = kMaxUInt32; + #ifdef DEBUG // This stores current value of Isolate::javascript_execution_counter(). // It's used for detecting whether JavaScript code was executed between @@ -182,8 +260,8 @@ class FunctionCallbackArguments static constexpr int kHolderIndex = T::kHolderIndex; static constexpr int kIsolateIndex = T::kIsolateIndex; - static constexpr int kUnusedIndex = T::kUnusedIndex; - static constexpr int kDataIndex = T::kDataIndex; + static constexpr int kContextIndex = T::kContextIndex; + static constexpr int kTargetIndex = T::kTargetIndex; static constexpr int kNewTargetIndex = T::kNewTargetIndex; static_assert(T::kThisValuesIndex == BuiltinArguments::kReceiverArgsOffset); @@ -199,7 +277,8 @@ class FunctionCallbackArguments static_assert(T::kValuesOffset == offsetof(T, values_)); static_assert(T::kLengthOffset == offsetof(T, length_)); - FunctionCallbackArguments(Isolate* isolate, Tagged data, + FunctionCallbackArguments(Isolate* isolate, + Tagged target, Tagged holder, Tagged new_target, Address* argv, int argc); @@ -212,12 +291,20 @@ class FunctionCallbackArguments * and used if it's been set to anything inside the callback. * New style callbacks always use the return value. */ - inline Handle Call(Tagged function); + inline Handle CallOrConstruct(Tagged function, + bool is_construct); + + // Unofficial way of getting target FunctionTemplateInfo from + // v8::FunctionCallbackInfo. + template + static Tagged GetTarget(const FunctionCallbackInfo& info) { + return Tagged(info.implicit_args_[kTargetIndex]); + } private: inline Tagged holder() const; - internal::Address* argv_; + Address* argv_; int const argc_; }; diff --git a/deps/v8/src/api/api-inl.h b/deps/v8/src/api/api-inl.h index b8e60c48e651d8..c7be6489469700 100644 --- a/deps/v8/src/api/api-inl.h +++ b/deps/v8/src/api/api-inl.h @@ -17,37 +17,37 @@ namespace v8 { -template +template inline T ToCData(v8::internal::Tagged obj) { static_assert(sizeof(T) == sizeof(v8::internal::Address)); if (obj == v8::internal::Smi::zero()) return nullptr; return reinterpret_cast( - v8::internal::Foreign::cast(obj)->foreign_address()); + v8::internal::Cast(obj)->foreign_address()); } -template <> +template inline v8::internal::Address ToCData( v8::internal::Tagged obj) { if (obj == v8::internal::Smi::zero()) return v8::internal::kNullAddress; - return v8::internal::Foreign::cast(obj)->foreign_address(); + return v8::internal::Cast(obj)->foreign_address(); } -template -inline v8::internal::Handle FromCData( +template +inline v8::internal::Handle> FromCData( v8::internal::Isolate* isolate, T obj) { static_assert(sizeof(T) == sizeof(v8::internal::Address)); if (obj == nullptr) return handle(v8::internal::Smi::zero(), isolate); - return isolate->factory()->NewForeign( + return isolate->factory()->NewForeign( reinterpret_cast(obj)); } -template <> -inline v8::internal::Handle FromCData( +template +inline v8::internal::Handle> FromCData( v8::internal::Isolate* isolate, v8::internal::Address obj) { if (obj == v8::internal::kNullAddress) { return handle(v8::internal::Smi::zero(), isolate); } - return isolate->factory()->NewForeign(obj); + return isolate->factory()->NewForeign(obj); } template @@ -186,7 +186,7 @@ class V8_NODISCARD CallDepthScope { } ~CallDepthScope() { i::MicrotaskQueue* microtask_queue = - i::NativeContext::cast(isolate_->context())->microtask_queue(); + i::Cast(isolate_->context())->microtask_queue(); isolate_->thread_local_top()->DecrementCallDepth(this); // Clear the exception when exiting V8 to avoid memory leaks. @@ -271,7 +271,8 @@ template void CopySmiElementsToTypedBuffer(T* dst, uint32_t length, i::Tagged elements) { for (uint32_t i = 0; i < length; ++i) { - double value = i::Object::Number(elements->get(static_cast(i))); + double value = i::Object::NumberValue( + i::Cast(elements->get(static_cast(i)))); // TODO(mslekova): Avoid converting back-and-forth when possible, e.g // avoid int->double->int conversions to boost performance. dst[i] = i::ConvertDouble(value); @@ -313,11 +314,12 @@ bool CopyAndConvertArrayToCppBuffer(Local src, T* dst, i::Tagged elements = obj->elements(); switch (obj->GetElementsKind()) { case i::PACKED_SMI_ELEMENTS: - CopySmiElementsToTypedBuffer(dst, length, i::FixedArray::cast(elements)); + CopySmiElementsToTypedBuffer(dst, length, + i::Cast(elements)); return true; case i::PACKED_DOUBLE_ELEMENTS: CopyDoubleElementsToTypedBuffer(dst, length, - i::FixedDoubleArray::cast(elements)); + i::Cast(elements)); return true; default: return false; diff --git a/deps/v8/src/api/api-natives.cc b/deps/v8/src/api/api-natives.cc index e3ff723b53e38d..5e20b43cb4fb0a 100644 --- a/deps/v8/src/api/api-natives.cc +++ b/deps/v8/src/api/api-natives.cc @@ -5,6 +5,7 @@ #include "src/api/api-natives.h" #include "src/api/api-inl.h" +#include "src/common/globals.h" #include "src/common/message-template.h" #include "src/execution/isolate-inl.h" #include "src/execution/protectors-inl.h" @@ -58,10 +59,10 @@ MaybeHandle Instantiate( Isolate* isolate, Handle data, MaybeHandle maybe_name = MaybeHandle()) { if (IsFunctionTemplateInfo(*data)) { - return InstantiateFunction( - isolate, Handle::cast(data), maybe_name); + return InstantiateFunction(isolate, Cast(data), + maybe_name); } else if (IsObjectTemplateInfo(*data)) { - return InstantiateObject(isolate, Handle::cast(data), + return InstantiateObject(isolate, Cast(data), Handle(), false); } else { return data; @@ -75,33 +76,27 @@ MaybeHandle DefineAccessorProperty(Isolate* isolate, Handle setter, PropertyAttributes attributes) { DCHECK(!IsFunctionTemplateInfo(*getter) || - FunctionTemplateInfo::cast(*getter)->should_cache()); + Cast(*getter)->should_cache()); DCHECK(!IsFunctionTemplateInfo(*setter) || - FunctionTemplateInfo::cast(*setter)->should_cache()); + Cast(*setter)->should_cache()); if (IsFunctionTemplateInfo(*getter) && - FunctionTemplateInfo::cast(*getter)->BreakAtEntry(isolate)) { + Cast(*getter)->BreakAtEntry(isolate)) { ASSIGN_RETURN_ON_EXCEPTION( isolate, getter, - InstantiateFunction(isolate, - Handle::cast(getter)), - Object); - Handle trampoline = BUILTIN_CODE(isolate, DebugBreakTrampoline); - Handle::cast(getter)->set_code(*trampoline); + InstantiateFunction(isolate, Cast(getter))); + DirectHandle trampoline = BUILTIN_CODE(isolate, DebugBreakTrampoline); + Cast(getter)->set_code(*trampoline); } if (IsFunctionTemplateInfo(*setter) && - FunctionTemplateInfo::cast(*setter)->BreakAtEntry(isolate)) { + Cast(*setter)->BreakAtEntry(isolate)) { ASSIGN_RETURN_ON_EXCEPTION( isolate, setter, - InstantiateFunction(isolate, - Handle::cast(setter)), - Object); - Handle trampoline = BUILTIN_CODE(isolate, DebugBreakTrampoline); - Handle::cast(setter)->set_code(*trampoline); - } - RETURN_ON_EXCEPTION(isolate, - JSObject::DefineOwnAccessorIgnoreAttributes( - object, name, getter, setter, attributes), - Object); + InstantiateFunction(isolate, Cast(setter))); + DirectHandle trampoline = BUILTIN_CODE(isolate, DebugBreakTrampoline); + Cast(setter)->set_code(*trampoline); + } + RETURN_ON_EXCEPTION(isolate, JSObject::DefineOwnAccessorIgnoreAttributes( + object, name, getter, setter, attributes)); return object; } @@ -112,7 +107,7 @@ MaybeHandle DefineDataProperty(Isolate* isolate, PropertyAttributes attributes) { Handle value; ASSIGN_RETURN_ON_EXCEPTION(isolate, value, - Instantiate(isolate, prop_data, name), Object); + Instantiate(isolate, prop_data, name)); PropertyKey key(isolate, name); LookupIterator it(isolate, object, key, LookupIterator::OWN_SKIP_INTERCEPTOR); @@ -123,8 +118,7 @@ MaybeHandle DefineDataProperty(Isolate* isolate, if (it.IsFound()) { THROW_NEW_ERROR( isolate, - NewTypeError(MessageTemplate::kDuplicateTemplateProperty, name), - Object); + NewTypeError(MessageTemplate::kDuplicateTemplateProperty, name)); } #endif @@ -134,15 +128,15 @@ MaybeHandle DefineDataProperty(Isolate* isolate, return value; } -void DisableAccessChecks(Isolate* isolate, Handle object) { +void DisableAccessChecks(Isolate* isolate, DirectHandle object) { Handle old_map(object->map(), isolate); // Copy map so it won't interfere constructor's initial map. Handle new_map = Map::Copy(isolate, old_map, "DisableAccessChecks"); new_map->set_is_access_check_needed(false); - JSObject::MigrateToMap(isolate, Handle::cast(object), new_map); + JSObject::MigrateToMap(isolate, object, new_map); } -void EnableAccessChecks(Isolate* isolate, Handle object) { +void EnableAccessChecks(Isolate* isolate, DirectHandle object) { Handle old_map(object->map(), isolate); // Copy map so it won't interfere constructor's initial map. Handle new_map = Map::Copy(isolate, old_map, "EnableAccessChecks"); @@ -200,7 +194,7 @@ MaybeHandle ConfigureInstance(Isolate* isolate, Handle obj, while (!info.is_null()) { Tagged props = info->property_accessors(); if (!IsUndefined(props, isolate)) { - max_number_of_properties += ArrayList::cast(props)->length(); + max_number_of_properties += Cast(props)->length(); } info = info->GetParent(isolate); } @@ -226,8 +220,8 @@ MaybeHandle ConfigureInstance(Isolate* isolate, Handle obj, // Install accumulated accessors. for (int i = 0; i < valid_descriptors; i++) { - Handle accessor(AccessorInfo::cast(array->get(i)), isolate); - Handle name(Name::cast(accessor->name()), isolate); + Handle accessor(Cast(array->get(i)), isolate); + Handle name(Cast(accessor->name()), isolate); JSObject::SetAccessor(obj, name, accessor, accessor->initial_property_attributes()) .Assert(); @@ -236,36 +230,34 @@ MaybeHandle ConfigureInstance(Isolate* isolate, Handle obj, Tagged maybe_property_list = data->property_list(); if (IsUndefined(maybe_property_list, isolate)) return obj; - Handle properties(ArrayList::cast(maybe_property_list), isolate); + DirectHandle properties(Cast(maybe_property_list), + isolate); if (properties->length() == 0) return obj; int i = 0; for (int c = 0; c < data->number_of_properties(); c++) { - auto name = handle(Name::cast(properties->get(i++)), isolate); + auto name = handle(Cast(properties->get(i++)), isolate); Tagged bit = properties->get(i++); if (IsSmi(bit)) { - PropertyDetails details(Smi::cast(bit)); + PropertyDetails details(Cast(bit)); PropertyAttributes attributes = details.attributes(); PropertyKind kind = details.kind(); if (kind == PropertyKind::kData) { auto prop_data = handle(properties->get(i++), isolate); - RETURN_ON_EXCEPTION( - isolate, - DefineDataProperty(isolate, obj, name, prop_data, attributes), - JSObject); + RETURN_ON_EXCEPTION(isolate, DefineDataProperty(isolate, obj, name, + prop_data, attributes)); } else { auto getter = handle(properties->get(i++), isolate); auto setter = handle(properties->get(i++), isolate); - RETURN_ON_EXCEPTION(isolate, - DefineAccessorProperty(isolate, obj, name, getter, - setter, attributes), - JSObject); + RETURN_ON_EXCEPTION( + isolate, DefineAccessorProperty(isolate, obj, name, getter, setter, + attributes)); } } else { // Intrinsic data property --- Get appropriate value from the current // context. - PropertyDetails details(Smi::cast(properties->get(i++))); + PropertyDetails details(Cast(properties->get(i++))); PropertyAttributes attributes = details.attributes(); DCHECK_EQ(PropertyKind::kData, details.kind()); @@ -273,10 +265,8 @@ MaybeHandle ConfigureInstance(Isolate* isolate, Handle obj, static_cast(Smi::ToInt(properties->get(i++))); auto prop_data = handle(GetIntrinsic(isolate, intrinsic), isolate); - RETURN_ON_EXCEPTION( - isolate, - DefineDataProperty(isolate, obj, name, prop_data, attributes), - JSObject); + RETURN_ON_EXCEPTION(isolate, DefineDataProperty(isolate, obj, name, + prop_data, attributes)); } } return obj; @@ -287,7 +277,7 @@ bool IsSimpleInstantiation(Isolate* isolate, Tagged info, DisallowGarbageCollection no_gc; if (!IsJSFunction(new_target)) return false; - Tagged fun = JSFunction::cast(new_target); + Tagged fun = Cast(new_target); if (!fun->shared()->IsApiFunction()) return false; if (fun->shared()->api_func_data() != info->constructor()) return false; if (info->immutable_proto()) return false; @@ -303,7 +293,7 @@ MaybeHandle InstantiateObject(Isolate* isolate, bool should_cache = info->should_cache(); if (!new_target.is_null()) { if (IsSimpleInstantiation(isolate, *info, *new_target)) { - constructor = Handle::cast(new_target); + constructor = Cast(new_target); } else { // Disable caching for subclass instantiation. should_cache = false; @@ -328,27 +318,31 @@ MaybeHandle InstantiateObject(Isolate* isolate, // Enter a new scope. Recursion could otherwise create a lot of handles. HandleScope scope(isolate); Handle cons_templ( - FunctionTemplateInfo::cast(maybe_constructor_info), isolate); + Cast(maybe_constructor_info), isolate); Handle tmp_constructor; ASSIGN_RETURN_ON_EXCEPTION(isolate, tmp_constructor, - InstantiateFunction(isolate, cons_templ), - JSObject); + InstantiateFunction(isolate, cons_templ)); constructor = scope.CloseAndEscape(tmp_constructor); } if (new_target.is_null()) new_target = constructor; } + const auto new_js_object_type = + constructor->has_initial_map() && + IsJSApiWrapperObject(constructor->initial_map()) + ? NewJSObjectType::kAPIWrapper + : NewJSObjectType::kNoAPIWrapper; Handle object; ASSIGN_RETURN_ON_EXCEPTION( isolate, object, - JSObject::New(constructor, new_target, Handle::null()), - JSObject); + JSObject::New(constructor, new_target, Handle::null(), + new_js_object_type)); if (is_prototype) JSObject::OptimizeAsPrototype(object); - ASSIGN_RETURN_ON_EXCEPTION( - isolate, result, ConfigureInstance(isolate, object, info), JSObject); + ASSIGN_RETURN_ON_EXCEPTION(isolate, result, + ConfigureInstance(isolate, object, info)); if (info->immutable_proto()) { JSObject::SetImmutableProto(object); } @@ -376,16 +370,14 @@ MaybeHandle GetInstancePrototype(Isolate* isolate, Handle parent_instance; ASSIGN_RETURN_ON_EXCEPTION( isolate, parent_instance, - InstantiateFunction( - isolate, Handle::cast(function_template)), - JSFunction); + InstantiateFunction(isolate, + Cast(function_template))); Handle instance_prototype; // TODO(cbruni): decide what to do here. ASSIGN_RETURN_ON_EXCEPTION( isolate, instance_prototype, JSObject::GetProperty(isolate, parent_instance, - isolate->factory()->prototype_string()), - JSFunction); + isolate->factory()->prototype_string())); return scope.CloseAndEscape(instance_prototype); } } // namespace @@ -401,7 +393,7 @@ MaybeHandle InstantiateFunction( isolate, native_context, data->serial_number(), TemplateInfo::CachingMode::kUnlimited) .ToHandle(&result)) { - return Handle::cast(result); + return Cast(result); } } Handle prototype; @@ -411,29 +403,27 @@ MaybeHandle InstantiateFunction( Handle protoype_provider_templ( data->GetPrototypeProviderTemplate(), isolate); if (IsUndefined(*protoype_provider_templ, isolate)) { - prototype = isolate->factory()->NewJSObject(isolate->object_function()); + prototype = isolate->factory()->NewJSObject( + handle(native_context->object_function(), isolate)); } else { ASSIGN_RETURN_ON_EXCEPTION( isolate, prototype, - GetInstancePrototype(isolate, protoype_provider_templ), JSFunction); + GetInstancePrototype(isolate, protoype_provider_templ)); } } else { ASSIGN_RETURN_ON_EXCEPTION( isolate, prototype, - InstantiateObject(isolate, - Handle::cast(prototype_templ), - Handle(), true), - JSFunction); + InstantiateObject(isolate, Cast(prototype_templ), + Handle(), true)); } Handle parent(data->GetParentTemplate(), isolate); if (!IsUndefined(*parent, isolate)) { Handle parent_prototype; ASSIGN_RETURN_ON_EXCEPTION(isolate, parent_prototype, - GetInstancePrototype(isolate, parent), - JSFunction); + GetInstancePrototype(isolate, parent)); CHECK(IsHeapObject(*parent_prototype)); - JSObject::ForceSetPrototype(isolate, Handle::cast(prototype), - Handle::cast(parent_prototype)); + JSObject::ForceSetPrototype(isolate, Cast(prototype), + Cast(parent_prototype)); } } InstanceType function_type = JS_SPECIAL_API_OBJECT_TYPE; @@ -464,21 +454,21 @@ MaybeHandle InstantiateFunction( return function; } -void AddPropertyToPropertyList(Isolate* isolate, Handle templ, - int length, Handle* data) { +void AddPropertyToPropertyList(Isolate* isolate, + DirectHandle templ, int length, + Handle* data) { Tagged maybe_list = templ->property_list(); Handle list; if (IsUndefined(maybe_list, isolate)) { list = ArrayList::New(isolate, length, AllocationType::kOld); } else { - list = handle(ArrayList::cast(maybe_list), isolate); + list = handle(Cast(maybe_list), isolate); } templ->set_number_of_properties(templ->number_of_properties() + 1); for (int i = 0; i < length; i++) { - Handle value = - data[i].is_null() - ? Handle::cast(isolate->factory()->undefined_value()) - : data[i]; + DirectHandle value = + data[i].is_null() ? Cast(isolate->factory()->undefined_value()) + : data[i]; list = ArrayList::Add(isolate, list, value); } templ->set_property_list(*list); @@ -522,29 +512,32 @@ MaybeHandle ApiNatives::InstantiateObject( } MaybeHandle ApiNatives::InstantiateRemoteObject( - Handle data) { + DirectHandle data) { Isolate* isolate = data->GetIsolate(); InvokeScope invoke_scope(isolate); - Handle constructor( - FunctionTemplateInfo::cast(data->constructor()), isolate); - Handle object_map = isolate->factory()->NewContextlessMap( + DirectHandle constructor( + Cast(data->constructor()), isolate); + DirectHandle object_map = isolate->factory()->NewContextlessMap( JS_SPECIAL_API_OBJECT_TYPE, - JSObject::kHeaderSize + + JSSpecialObject::kHeaderSize + data->embedder_field_count() * kEmbedderDataSlotSize, TERMINAL_FAST_ELEMENTS_KIND); object_map->SetConstructor(*constructor); object_map->set_is_access_check_needed(true); object_map->set_may_have_interesting_properties(true); - Handle object = isolate->factory()->NewJSObjectFromMap(object_map); + Handle object = isolate->factory()->NewJSObjectFromMap( + object_map, AllocationType::kYoung, DirectHandle::null(), + NewJSObjectType::kAPIWrapper); JSObject::ForceSetPrototype(isolate, object, isolate->factory()->null_value()); return object; } -void ApiNatives::AddDataProperty(Isolate* isolate, Handle info, +void ApiNatives::AddDataProperty(Isolate* isolate, + DirectHandle info, Handle name, Handle value, PropertyAttributes attributes) { PropertyDetails details(PropertyKind::kData, attributes, @@ -554,7 +547,8 @@ void ApiNatives::AddDataProperty(Isolate* isolate, Handle info, AddPropertyToPropertyList(isolate, info, arraysize(data), data); } -void ApiNatives::AddDataProperty(Isolate* isolate, Handle info, +void ApiNatives::AddDataProperty(Isolate* isolate, + DirectHandle info, Handle name, v8::Intrinsic intrinsic, PropertyAttributes attributes) { auto value = handle(Smi::FromInt(intrinsic), isolate); @@ -567,7 +561,7 @@ void ApiNatives::AddDataProperty(Isolate* isolate, Handle info, } void ApiNatives::AddAccessorProperty(Isolate* isolate, - Handle info, + DirectHandle info, Handle name, Handle getter, Handle setter, @@ -582,14 +576,14 @@ void ApiNatives::AddAccessorProperty(Isolate* isolate, } void ApiNatives::AddNativeDataProperty(Isolate* isolate, - Handle info, - Handle property) { + DirectHandle info, + DirectHandle property) { Tagged maybe_list = info->property_accessors(); Handle list; if (IsUndefined(maybe_list, isolate)) { list = ArrayList::New(isolate, 1, AllocationType::kOld); } else { - list = handle(ArrayList::cast(maybe_list), isolate); + list = handle(Cast(maybe_list), isolate); } list = ArrayList::Add(isolate, list, property); info->set_property_accessors(*list); @@ -597,7 +591,7 @@ void ApiNatives::AddNativeDataProperty(Isolate* isolate, Handle ApiNatives::CreateApiFunction( Isolate* isolate, Handle native_context, - Handle obj, Handle prototype, + DirectHandle obj, Handle prototype, InstanceType type, MaybeHandle maybe_name) { RCS_SCOPE(isolate, RuntimeCallCounterId::kCreateApiFunction); Handle shared = @@ -628,7 +622,7 @@ Handle ApiNatives::CreateApiFunction( if (IsTheHole(*prototype, isolate)) { prototype = isolate->factory()->NewFunctionPrototype(result); } else if (IsUndefined(obj->GetPrototypeProviderTemplate(), isolate)) { - JSObject::AddProperty(isolate, Handle::cast(prototype), + JSObject::AddProperty(isolate, Cast(prototype), isolate->factory()->constructor_string(), result, DONT_ENUM); } @@ -636,8 +630,8 @@ Handle ApiNatives::CreateApiFunction( int embedder_field_count = 0; bool immutable_proto = false; if (!IsUndefined(obj->GetInstanceTemplate(), isolate)) { - Handle GetInstanceTemplate = Handle( - ObjectTemplateInfo::cast(obj->GetInstanceTemplate()), isolate); + DirectHandle GetInstanceTemplate( + Cast(obj->GetInstanceTemplate()), isolate); embedder_field_count = GetInstanceTemplate->embedder_field_count(); immutable_proto = GetInstanceTemplate->immutable_proto(); } @@ -688,8 +682,7 @@ Handle ApiNatives::CreateApiFunction( if (immutable_proto) map->set_is_immutable_proto(true); - JSFunction::SetInitialMap(isolate, result, map, - Handle::cast(prototype)); + JSFunction::SetInitialMap(isolate, result, map, Cast(prototype)); return result; } diff --git a/deps/v8/src/api/api-natives.h b/deps/v8/src/api/api-natives.h index fc11ca81691f7c..50f40e0b2d942f 100644 --- a/deps/v8/src/api/api-natives.h +++ b/deps/v8/src/api/api-natives.h @@ -43,29 +43,31 @@ class ApiNatives { Handle new_target = Handle()); V8_WARN_UNUSED_RESULT static MaybeHandle InstantiateRemoteObject( - Handle data); + DirectHandle data); static Handle CreateApiFunction( Isolate* isolate, Handle native_context, - Handle obj, Handle prototype, + DirectHandle obj, Handle prototype, InstanceType type, MaybeHandle name = MaybeHandle()); - static void AddDataProperty(Isolate* isolate, Handle info, + static void AddDataProperty(Isolate* isolate, DirectHandle info, Handle name, Handle value, PropertyAttributes attributes); - static void AddDataProperty(Isolate* isolate, Handle info, + static void AddDataProperty(Isolate* isolate, DirectHandle info, Handle name, v8::Intrinsic intrinsic, PropertyAttributes attributes); - static void AddAccessorProperty(Isolate* isolate, Handle info, + static void AddAccessorProperty(Isolate* isolate, + DirectHandle info, Handle name, Handle getter, Handle setter, PropertyAttributes attributes); - static void AddNativeDataProperty(Isolate* isolate, Handle info, - Handle property); + static void AddNativeDataProperty(Isolate* isolate, + DirectHandle info, + DirectHandle property); }; } // namespace internal diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index 28f0389258cc95..f8d3c5aa1231f4 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -12,6 +12,7 @@ #include // For move #include +#include "include/v8-array-buffer.h" #include "include/v8-callbacks.h" #include "include/v8-cppgc.h" #include "include/v8-date.h" @@ -28,6 +29,7 @@ #include "include/v8-unwinder-state.h" #include "include/v8-util.h" #include "include/v8-wasm.h" +#include "src/api/api-arguments.h" #include "src/api/api-inl.h" #include "src/api/api-natives.h" #include "src/base/functional.h" @@ -37,6 +39,7 @@ #include "src/base/platform/time.h" #include "src/base/safe_conversions.h" #include "src/base/utils/random-number-generator.h" +#include "src/base/vector.h" #include "src/builtins/accessors.h" #include "src/builtins/builtins-utils.h" #include "src/codegen/compilation-cache.h" @@ -77,6 +80,7 @@ #include "src/logging/tracing-flags.h" #include "src/numbers/conversions-inl.h" #include "src/objects/api-callbacks.h" +#include "src/objects/backing-store.h" #include "src/objects/contexts.h" #include "src/objects/embedder-data-array-inl.h" #include "src/objects/embedder-data-slot-inl.h" @@ -180,8 +184,8 @@ namespace v8 { static OOMErrorCallback g_oom_error_callback = nullptr; -static ScriptOrigin GetScriptOriginForScript(i::Isolate* i_isolate, - i::Handle script) { +static ScriptOrigin GetScriptOriginForScript( + i::Isolate* i_isolate, i::DirectHandle script) { i::DirectHandle scriptName(script->GetNameOrSourceURL(), i_isolate); i::DirectHandle source_map_url(script->source_mapping_url(), @@ -568,21 +572,25 @@ Isolate* SnapshotCreator::GetIsolate() { void SnapshotCreator::SetDefaultContext( Local context, SerializeInternalFieldsCallback internal_fields_serializer, - SerializeContextDataCallback context_data_serializer) { + SerializeContextDataCallback context_data_serializer, + SerializeAPIWrapperCallback api_wrapper_serializer) { impl_->SetDefaultContext( Utils::OpenHandle(*context), i::SerializeEmbedderFieldsCallback(internal_fields_serializer, - context_data_serializer)); + context_data_serializer, + api_wrapper_serializer)); } size_t SnapshotCreator::AddContext( Local context, SerializeInternalFieldsCallback internal_fields_serializer, - SerializeContextDataCallback context_data_serializer) { + SerializeContextDataCallback context_data_serializer, + SerializeAPIWrapperCallback api_wrapper_serializer) { return impl_->AddContext( Utils::OpenHandle(*context), i::SerializeEmbedderFieldsCallback(internal_fields_serializer, - context_data_serializer)); + context_data_serializer, + api_wrapper_serializer)); } size_t SnapshotCreator::AddData(i::Address object) { @@ -609,13 +617,16 @@ void V8::SetDcheckErrorHandler(DcheckErrorCallback that) { v8::base::SetDcheckFunction(that); } +void V8::SetFatalErrorHandler(V8FatalErrorCallback that) { + v8::base::SetFatalFunction(that); +} + void V8::SetFlagsFromString(const char* str) { SetFlagsFromString(str, strlen(str)); } void V8::SetFlagsFromString(const char* str, size_t length) { i::FlagList::SetFlagsFromString(str, length); - i::FlagList::EnforceFlagImplications(); } void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { @@ -726,7 +737,7 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, namespace api_internal { void StackAllocated::VerifyOnStack() const { if (internal::StackAllocatedCheck::Get()) { - internal::HandleHelper::VerifyOnStack(this); + DCHECK(::heap::base::Stack::IsOnStack(this)); } } } // namespace api_internal @@ -760,22 +771,6 @@ void DisposeTracedReference(internal::Address* location) { TracedHandles::Destroy(location); } -// static -bool HandleHelper::IsOnStack(const void* ptr) { - return v8::base::Stack::GetCurrentStackPosition() <= ptr && - ptr <= v8::base::Stack::GetStackStartUnchecked(); -} - -// static -void HandleHelper::VerifyOnStack(const void* ptr) { DCHECK(IsOnStack(ptr)); } - -// static -void HandleHelper::VerifyOnMainThread() { - // The following verifies that we are on the main thread, as - // LocalHeap::Current is not set in that case. - DCHECK_NULL(LocalHeap::Current()); -} - #if V8_STATIC_ROOTS_BOOL // Check static root constants exposed in v8-internal.h. @@ -980,10 +975,10 @@ bool Data::IsValue() const { i::DisallowGarbageCollection no_gc; i::Tagged self = *Utils::OpenDirectHandle(this); if (i::IsSmi(self)) return true; - i::Tagged heap_object = i::HeapObject::cast(self); + i::Tagged heap_object = i::Cast(self); DCHECK(!IsTheHole(heap_object)); if (i::IsSymbol(heap_object)) { - return !i::Symbol::cast(heap_object)->is_private(); + return !i::Cast(heap_object)->is_private(); } return IsPrimitiveHeapObject(heap_object) || IsJSReceiver(heap_object); } @@ -1071,7 +1066,7 @@ static i::Handle EmbedderDataFor(Context* context, 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()), i_isolate); + i::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")) { @@ -1090,7 +1085,7 @@ uint32_t Context::GetNumberOfEmbedderDataFields() { "Not a native context"); // TODO(ishell): remove cast once embedder_data slot has a proper type. return static_cast( - i::EmbedderDataArray::cast(context->embedder_data())->length()); + i::Cast(context->embedder_data())->length()); } v8::Local Context::SlowGetEmbedderData(int index) { @@ -1133,10 +1128,10 @@ void* Context::SlowGetAlignedPointerFromEmbedderData(int index) { void Context::SetAlignedPointerInEmbedderData(int index, void* value) { const char* location = "v8::Context::SetAlignedPointerInEmbedderData()"; i::Isolate* i_isolate = Utils::OpenDirectHandle(this)->GetIsolate(); - i::Handle data = + i::DirectHandle data = EmbedderDataFor(this, index, true, location); - bool ok = - i::EmbedderDataSlot(*data, index).store_aligned_pointer(i_isolate, value); + bool ok = i::EmbedderDataSlot(*data, index) + .store_aligned_pointer(i_isolate, *data, value); Utils::ApiCheck(ok, location, "Pointer is not aligned"); DCHECK_EQ(value, GetAlignedPointerFromEmbedderData(index)); } @@ -1227,8 +1222,8 @@ void FunctionTemplate::SetPrototypeProviderTemplate( auto self = Utils::OpenHandle(this); i::Isolate* i_isolate = self->GetIsolateChecked(); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); - i::Handle result = - Utils::OpenHandle(*prototype_provider); + i::DirectHandle result = + Utils::OpenDirectHandle(*prototype_provider); Utils::ApiCheck(i::IsUndefined(self->GetPrototypeTemplate(), i_isolate), "v8::FunctionTemplate::SetPrototypeProviderTemplate", "Protoype must be undefined"); @@ -1389,10 +1384,11 @@ Local Signature::New(Isolate* v8_isolate, return Local::Cast(receiver); } -#define SET_FIELD_WRAPPED(i_isolate, obj, setter, cdata) \ - do { \ - i::Handle foreign = FromCData(i_isolate, cdata); \ - (obj)->setter(*foreign); \ +#define SET_FIELD_WRAPPED(i_isolate, obj, setter, cdata, tag) \ + do { \ + i::DirectHandle> foreign = \ + FromCData(i_isolate, cdata); \ + (obj)->setter(*foreign); \ } while (false) void FunctionTemplate::SetCallHandler( @@ -1416,19 +1412,20 @@ void FunctionTemplate::SetCallHandler( if (!c_function_overloads.empty()) { // 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 = + i::DirectHandle function_overloads = 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(i_isolate, c_function.GetAddress()); + i::DirectHandle address = FromCData( + i_isolate, c_function.GetAddress()); function_overloads->set( i::FunctionTemplateInfo::kFunctionOverloadEntrySize * i, *address); - i::Handle signature = - FromCData(i_isolate, c_function.GetTypeInfo()); + i::DirectHandle signature = + FromCData(i_isolate, + c_function.GetTypeInfo()); function_overloads->set( i::FunctionTemplateInfo::kFunctionOverloadEntrySize * i + 1, *signature); @@ -1445,13 +1442,11 @@ i::Handle MakeAccessorInfo(i::Isolate* i_isolate, v8::Local name, Getter getter, Setter setter, v8::Local data, - bool is_special_data_property, bool replace_on_access) { i::Handle obj = i_isolate->factory()->NewAccessorInfo(); obj->set_getter(i_isolate, reinterpret_cast(getter)); - DCHECK_IMPLIES(replace_on_access, - is_special_data_property && setter == nullptr); - if (is_special_data_property && setter == nullptr) { + DCHECK_IMPLIES(replace_on_access, setter == nullptr); + if (setter == nullptr) { setter = reinterpret_cast(&i::Accessors::ReconfigureToDataProperty); } obj->set_setter(i_isolate, reinterpret_cast(setter)); @@ -1459,7 +1454,7 @@ i::Handle MakeAccessorInfo(i::Isolate* i_isolate, auto accessor_name = Utils::OpenHandle(*name); if (!IsUniqueName(*accessor_name)) { accessor_name = i_isolate->factory()->InternalizeString( - i::Handle::cast(accessor_name)); + i::Cast(accessor_name)); } i::DisallowGarbageCollection no_gc; i::Tagged raw_obj = *obj; @@ -1469,7 +1464,6 @@ i::Handle MakeAccessorInfo(i::Isolate* i_isolate, raw_obj->set_data(*Utils::OpenDirectHandle(*data)); } raw_obj->set_name(*accessor_name); - raw_obj->set_is_special_data_property(is_special_data_property); raw_obj->set_replace_on_access(replace_on_access); raw_obj->set_initial_property_attributes(i::NONE); return obj; @@ -1489,7 +1483,8 @@ Local FunctionTemplate::InstanceTemplate() { auto maybe_templ = constructor->GetInstanceTemplate(); if (!i::IsUndefined(maybe_templ, i_isolate)) { return Utils::ToLocal( - i::direct_handle(i::ObjectTemplateInfo::cast(maybe_templ), i_isolate), + i::direct_handle(i::Cast(maybe_templ), + i_isolate), i_isolate); } constexpr bool do_not_cache = false; @@ -1562,7 +1557,7 @@ i::Handle EnsureConstructor( Utils::OpenDirectHandle(object_template)->constructor(); if (!IsUndefined(obj, i_isolate)) { i::Tagged info = - i::FunctionTemplateInfo::cast(obj); + i::Cast(obj); return i::Handle(info, i_isolate); } Local templ = @@ -1577,17 +1572,15 @@ i::Handle EnsureConstructor( template void TemplateSetAccessor(Template* template_obj, v8::Local name, Getter getter, Setter setter, Data data, - PropertyAttribute attribute, - bool is_special_data_property, bool replace_on_access, + PropertyAttribute attribute, bool replace_on_access, SideEffectType getter_side_effect_type, SideEffectType setter_side_effect_type) { auto info = Utils::OpenHandle(template_obj); auto i_isolate = info->GetIsolateChecked(); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); i::HandleScope scope(i_isolate); - i::Handle accessor_info = - MakeAccessorInfo(i_isolate, name, getter, setter, data, - is_special_data_property, replace_on_access); + i::Handle accessor_info = MakeAccessorInfo( + i_isolate, name, getter, setter, data, replace_on_access); { i::DisallowGarbageCollection no_gc; i::Tagged raw = *accessor_info; @@ -1600,49 +1593,14 @@ void TemplateSetAccessor(Template* template_obj, v8::Local name, } } // namespace -void Template::SetNativeDataProperty(v8::Local name, - AccessorGetterCallback getter, - AccessorSetterCallback setter, - v8::Local data, - PropertyAttribute attribute, - v8::AccessControl settings, - SideEffectType getter_side_effect_type, - SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, setter, data, attribute, true, false, - getter_side_effect_type, setter_side_effect_type); -} - void Template::SetNativeDataProperty(v8::Local name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter, v8::Local data, PropertyAttribute attribute, - v8::AccessControl settings, - SideEffectType getter_side_effect_type, - SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, setter, data, attribute, true, false, - getter_side_effect_type, setter_side_effect_type); -} - -void Template::SetNativeDataProperty(v8::Local name, - AccessorGetterCallback getter, - AccessorSetterCallback setter, - v8::Local data, - PropertyAttribute attribute, SideEffectType getter_side_effect_type, SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, setter, data, attribute, true, false, - getter_side_effect_type, setter_side_effect_type); -} - -void Template::SetNativeDataProperty(v8::Local name, - AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter, - v8::Local data, - PropertyAttribute attribute, - SideEffectType getter_side_effect_type, - SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, setter, data, attribute, true, false, + TemplateSetAccessor(this, name, getter, setter, data, attribute, false, getter_side_effect_type, setter_side_effect_type); } @@ -1652,10 +1610,9 @@ void Template::SetLazyDataProperty(v8::Local name, PropertyAttribute attribute, SideEffectType getter_side_effect_type, SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, - static_cast(nullptr), data, - attribute, true, true, getter_side_effect_type, - setter_side_effect_type); + TemplateSetAccessor( + this, name, getter, static_cast(nullptr), + data, attribute, true, getter_side_effect_type, setter_side_effect_type); } void Template::SetIntrinsicDataProperty(Local name, Intrinsic intrinsic, @@ -1669,66 +1626,65 @@ void Template::SetIntrinsicDataProperty(Local name, Intrinsic intrinsic, static_cast(attribute)); } -void ObjectTemplate::SetAccessor(v8::Local name, - AccessorGetterCallback getter, - AccessorSetterCallback setter, - v8::Local data, - PropertyAttribute attribute, - SideEffectType getter_side_effect_type, - SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, setter, data, attribute, - i::v8_flags.disable_old_api_accessors, false, - getter_side_effect_type, setter_side_effect_type); -} - -void ObjectTemplate::SetAccessor(v8::Local name, - AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter, - v8::Local data, - PropertyAttribute attribute, - SideEffectType getter_side_effect_type, - SideEffectType setter_side_effect_type) { - TemplateSetAccessor(this, name, getter, setter, data, attribute, - i::v8_flags.disable_old_api_accessors, false, - getter_side_effect_type, setter_side_effect_type); -} - namespace { -template +enum class PropertyType { kNamed, kIndexed }; +template i::Handle CreateInterceptorInfo( i::Isolate* i_isolate, Getter getter, Setter setter, Query query, Descriptor descriptor, Deleter remover, Enumerator enumerator, Definer definer, Local data, base::Flags flags) { - auto obj = - i::Handle::cast(i_isolate->factory()->NewStruct( - i::INTERCEPTOR_INFO_TYPE, i::AllocationType::kOld)); + // TODO(saelo): instead of an in-sandbox struct with a lot of external + // pointers (with different tags), consider creating an object in trusted + // space instead. That way, only a single reference going out of the sandbox + // would be required. + auto obj = i::Cast(i_isolate->factory()->NewStruct( + i::INTERCEPTOR_INFO_TYPE, i::AllocationType::kOld)); obj->set_flags(0); - 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); +#define CALLBACK_TAG(NAME) \ + property_type == PropertyType::kNamed \ + ? internal::kApiNamedProperty##NAME##CallbackTag \ + : internal::kApiIndexedProperty##NAME##CallbackTag; + + if (getter != nullptr) { + constexpr internal::ExternalPointerTag tag = CALLBACK_TAG(Getter); + SET_FIELD_WRAPPED(i_isolate, obj, set_getter, getter, tag); + } + if (setter != nullptr) { + constexpr internal::ExternalPointerTag tag = CALLBACK_TAG(Setter); + SET_FIELD_WRAPPED(i_isolate, obj, set_setter, setter, tag); + } + if (query != nullptr) { + constexpr internal::ExternalPointerTag tag = CALLBACK_TAG(Query); + SET_FIELD_WRAPPED(i_isolate, obj, set_query, query, tag); + } if (descriptor != nullptr) { - SET_FIELD_WRAPPED(i_isolate, obj, set_descriptor, descriptor); + constexpr internal::ExternalPointerTag tag = CALLBACK_TAG(Descriptor); + SET_FIELD_WRAPPED(i_isolate, obj, set_descriptor, descriptor, tag); } if (remover != nullptr) { - SET_FIELD_WRAPPED(i_isolate, obj, set_deleter, remover); + constexpr internal::ExternalPointerTag tag = CALLBACK_TAG(Deleter); + SET_FIELD_WRAPPED(i_isolate, obj, set_deleter, remover, tag); } if (enumerator != nullptr) { - SET_FIELD_WRAPPED(i_isolate, obj, set_enumerator, enumerator); + SET_FIELD_WRAPPED(i_isolate, obj, set_enumerator, enumerator, + internal::kApiIndexedPropertyEnumeratorCallbackTag); } if (definer != nullptr) { - SET_FIELD_WRAPPED(i_isolate, obj, set_definer, definer); + constexpr internal::ExternalPointerTag tag = CALLBACK_TAG(Definer); + SET_FIELD_WRAPPED(i_isolate, obj, set_definer, definer, tag); } + +#undef CALLBACK_TAG + obj->set_can_intercept_symbols( !(flags & PropertyHandlerFlags::kOnlyInterceptStrings)); obj->set_non_masking(flags & PropertyHandlerFlags::kNonMasking); obj->set_has_no_side_effect(flags & PropertyHandlerFlags::kHasNoSideEffect); - obj->set_has_new_callbacks_signature( - flags & PropertyHandlerFlags::kInternalNewCallbacksSignatures); - if (data.IsEmpty()) { data = v8::Undefined(reinterpret_cast(i_isolate)); } @@ -1743,9 +1699,9 @@ i::Handle CreateNamedInterceptorInfo( Descriptor descriptor, Deleter remover, Enumerator enumerator, Definer definer, Local data, base::Flags flags) { - auto interceptor = - CreateInterceptorInfo(i_isolate, getter, setter, query, descriptor, - remover, enumerator, definer, data, flags); + auto interceptor = CreateInterceptorInfo( + i_isolate, getter, setter, query, descriptor, remover, enumerator, + definer, data, flags); interceptor->set_is_named(true); return interceptor; } @@ -1757,9 +1713,9 @@ i::Handle CreateIndexedInterceptorInfo( Descriptor descriptor, Deleter remover, Enumerator enumerator, Definer definer, Local data, base::Flags flags) { - auto interceptor = - CreateInterceptorInfo(i_isolate, getter, setter, query, descriptor, - remover, enumerator, definer, data, flags); + auto interceptor = CreateInterceptorInfo( + i_isolate, getter, setter, query, descriptor, remover, enumerator, + definer, data, flags); interceptor->set_is_named(false); return interceptor; } @@ -1809,11 +1765,12 @@ void ObjectTemplate::SetAccessCheckCallback(AccessCheckCallback callback, i::Handle struct_info = i_isolate->factory()->NewStruct( i::ACCESS_CHECK_INFO_TYPE, i::AllocationType::kOld); - auto info = i::Handle::cast(struct_info); + auto info = i::Cast(struct_info); - SET_FIELD_WRAPPED(i_isolate, info, set_callback, callback); - info->set_named_interceptor(i::Tagged()); - info->set_indexed_interceptor(i::Tagged()); + SET_FIELD_WRAPPED(i_isolate, info, set_callback, callback, + internal::kApiAccessCheckCallbackTag); + info->set_named_interceptor(i::Smi::zero()); + info->set_indexed_interceptor(i::Smi::zero()); if (data.IsEmpty()) { data = v8::Undefined(reinterpret_cast(i_isolate)); @@ -1838,9 +1795,10 @@ void ObjectTemplate::SetAccessCheckCallbackAndHandler( i::Handle struct_info = i_isolate->factory()->NewStruct( i::ACCESS_CHECK_INFO_TYPE, i::AllocationType::kOld); - auto info = i::Handle::cast(struct_info); + auto info = i::Cast(struct_info); - SET_FIELD_WRAPPED(i_isolate, info, set_callback, callback); + SET_FIELD_WRAPPED(i_isolate, info, set_callback, callback, + internal::kApiAccessCheckCallbackTag); auto named_interceptor = CreateNamedInterceptorInfo( i_isolate, named_handler.getter, named_handler.setter, named_handler.query, named_handler.descriptor, named_handler.deleter, @@ -2013,7 +1971,7 @@ int UnboundScript::GetId() const { DCHECK(!InReadOnlySpace(*function_info)); API_RCS_SCOPE(i::GetIsolateFromWritableObject(*function_info), UnboundScript, GetId); - return i::Script::cast(function_info->script())->id(); + return i::Cast(function_info->script())->id(); } int UnboundScript::GetLineNumber(int code_pos) { @@ -2025,7 +1983,7 @@ int UnboundScript::GetLineNumber(int code_pos) { i::Isolate* i_isolate = i::GetIsolateFromWritableObject(*obj); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); API_RCS_SCOPE(i_isolate, UnboundScript, GetLineNumber); - i::Handle script(i::Script::cast(obj->script()), i_isolate); + i::Handle script(i::Cast(obj->script()), i_isolate); return i::Script::GetLineNumber(script, code_pos); } else { return -1; @@ -2041,7 +1999,7 @@ int UnboundScript::GetColumnNumber(int code_pos) { i::Isolate* i_isolate = i::GetIsolateFromWritableObject(*obj); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); API_RCS_SCOPE(i_isolate, UnboundScript, GetColumnNumber); - i::Handle script(i::Script::cast(obj->script()), i_isolate); + i::Handle script(i::Cast(obj->script()), i_isolate); return i::Script::GetColumnNumber(script, code_pos); } else { return -1; @@ -2057,7 +2015,7 @@ Local UnboundScript::GetScriptName() { i::Isolate* i_isolate = i::GetIsolateFromWritableObject(*obj); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); API_RCS_SCOPE(i_isolate, UnboundScript, GetName); - i::Tagged name = i::Script::cast(obj->script())->name(); + i::Tagged name = i::Cast(obj->script())->name(); return Utils::ToLocal(i::direct_handle(name, i_isolate), i_isolate); } else { return Local(); @@ -2073,7 +2031,7 @@ Local UnboundScript::GetSourceURL() { i::Isolate* i_isolate = i::GetIsolateFromWritableObject(*obj); API_RCS_SCOPE(i_isolate, UnboundScript, GetSourceURL); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); - i::Tagged url = i::Script::cast(obj->script())->source_url(); + i::Tagged url = i::Cast(obj->script())->source_url(); return Utils::ToLocal(i::direct_handle(url, i_isolate), i_isolate); } else { return Local(); @@ -2090,7 +2048,7 @@ Local UnboundScript::GetSourceMappingURL() { API_RCS_SCOPE(i_isolate, UnboundScript, GetSourceMappingURL); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); i::Tagged url = - i::Script::cast(obj->script())->source_mapping_url(); + i::Cast(obj->script())->source_mapping_url(); return Utils::ToLocal(i::direct_handle(url, i_isolate), i_isolate); } else { return Local(); @@ -2106,7 +2064,7 @@ Local UnboundModuleScript::GetSourceURL() { i::Isolate* i_isolate = i::GetIsolateFromWritableObject(*obj); API_RCS_SCOPE(i_isolate, UnboundModuleScript, GetSourceURL); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); - i::Tagged url = i::Script::cast(obj->script())->source_url(); + i::Tagged url = i::Cast(obj->script())->source_url(); return Utils::ToLocal(i::direct_handle(url, i_isolate), i_isolate); } else { return Local(); @@ -2123,7 +2081,7 @@ Local UnboundModuleScript::GetSourceMappingURL() { API_RCS_SCOPE(i_isolate, UnboundModuleScript, GetSourceMappingURL); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); i::Tagged url = - i::Script::cast(obj->script())->source_mapping_url(); + i::Cast(obj->script())->source_mapping_url(); return Utils::ToLocal(i::direct_handle(url, i_isolate), i_isolate); } else { return Local(); @@ -2159,11 +2117,11 @@ MaybeLocal Script::Run(Local context, i::ETWJITInterface::MaybeSetHandlerNow(i_isolate); } #endif - auto fun = i::Handle::cast(Utils::OpenHandle(this)); + auto fun = i::Cast(Utils::OpenHandle(this)); i::Handle receiver = i_isolate->global_proxy(); // TODO(cbruni, chromium:1244145): Remove once migrated to the context. i::Handle options( - i::Script::cast(fun->shared()->script())->host_defined_options(), + i::Cast(fun->shared()->script())->host_defined_options(), i_isolate); Local result; has_exception = !ToLocal( @@ -2204,7 +2162,7 @@ Local Script::GetResourceName() { CHECK(IsScript(sfi->script())); i::Isolate* i_isolate = func->GetIsolate(); return ToApiHandle( - i::direct_handle(i::Script::cast(sfi->script())->name(), i_isolate), + i::direct_handle(i::Cast(sfi->script())->name(), i_isolate), i_isolate); } @@ -2214,12 +2172,44 @@ std::vector Script::GetProducedCompileHints() const { i::Isolate* i_isolate = func->GetIsolate(); i::Tagged sfi = func->shared(); CHECK(IsScript(sfi->script())); - i::Tagged script = i::Script::cast(sfi->script()); + i::Tagged script = i::Cast(sfi->script()); i::Tagged maybe_array_list = script->compiled_lazy_function_positions(); std::vector result; if (!IsUndefined(maybe_array_list, i_isolate)) { - i::Tagged array_list = i::ArrayList::cast(maybe_array_list); + i::Tagged array_list = + i::Cast(maybe_array_list); + result.reserve(array_list->length()); + for (int i = 0; i < array_list->length(); ++i) { + i::Tagged item = array_list->get(i); + CHECK(IsSmi(item)); + result.push_back(i::Smi::ToInt(item)); + } + } + return result; +} + +Local Script::GetCompileHintsCollector() const { + i::DisallowGarbageCollection no_gc; + auto func = Utils::OpenDirectHandle(this); + i::Isolate* i_isolate = func->GetIsolate(); + i::Tagged sfi = func->shared(); + CHECK(IsScript(sfi->script())); + i::Handle script(i::Cast(sfi->script()), i_isolate); + return ToApiHandle(script); +} + +std::vector CompileHintsCollector::GetCompileHints( + Isolate* v8_isolate) const { + i::DisallowGarbageCollection no_gc; + auto script = Utils::OpenDirectHandle(this); + i::Isolate* i_isolate = reinterpret_cast(v8_isolate); + i::Tagged maybe_array_list = + script->compiled_lazy_function_positions(); + std::vector result; + if (!IsUndefined(maybe_array_list, i_isolate)) { + i::Tagged array_list = + i::Cast(maybe_array_list); result.reserve(array_list->length()); for (int i = 0; i < array_list->length(); ++i) { i::Tagged item = array_list->get(i); @@ -2317,8 +2307,9 @@ Module::Status Module::GetStatus() const { case i::Module::kLinked: return kInstantiated; case i::Module::kEvaluating: - case i::Module::kEvaluatingAsync: return kEvaluating; + case i::Module::kEvaluatingAsync: + // TODO(syg): Expose kEvaluatingAsync in API as well. case i::Module::kEvaluated: return kEvaluated; case i::Module::kErrored: @@ -2348,10 +2339,9 @@ Local Module::GetModuleRequests() const { self->GetReadOnlyRoots().empty_fixed_array_handle()); } else { return ToApiHandle( - i::direct_handle(i::DirectHandle::cast(self) - ->info() - ->module_requests(), - i_isolate), + i::direct_handle( + i::Cast(self)->info()->module_requests(), + i_isolate), i_isolate); } } @@ -2364,8 +2354,8 @@ Location Module::SourceOffsetToLocation(int offset) const { Utils::ApiCheck( i::IsSourceTextModule(*self), "v8::Module::SourceOffsetToLocation", "v8::Module::SourceOffsetToLocation must be used on an SourceTextModule"); - i::Handle script( - i::DirectHandle::cast(self)->GetScript(), i_isolate); + i::Handle script(i::Cast(self)->GetScript(), + i_isolate); i::Script::PositionInfo info; i::Script::GetPositionInfo(script, offset, &info); return v8::Location(info.line, info.column); @@ -2391,9 +2381,9 @@ Local Module::GetUnboundModuleScript() { auto i_isolate = self->GetIsolate(); DCHECK_NO_SCRIPT_NO_EXCEPTION(i_isolate); return ToApiHandle( - i::direct_handle(i::DirectHandle::cast(self) - ->GetSharedFunctionInfo(), - i_isolate), + i::direct_handle( + i::Cast(self)->GetSharedFunctionInfo(), + i_isolate), i_isolate); } @@ -2402,7 +2392,7 @@ int Module::ScriptId() const { Utils::ApiCheck(i::IsSourceTextModule(self), "v8::Module::ScriptId", "v8::Module::ScriptId must be used on an SourceTextModule"); DCHECK_NO_SCRIPT_NO_EXCEPTION(self->GetIsolate()); - return i::SourceTextModule::cast(self)->GetScript()->id(); + return i::Cast(self)->GetScript()->id(); } bool Module::IsGraphAsync() const { @@ -2438,7 +2428,7 @@ Maybe Module::InstantiateModule(Local context, auto i_isolate = reinterpret_cast(context->GetIsolate()); ENTER_V8(i_isolate, context, Module, InstantiateModule, i::HandleScope); has_exception = !i::Module::Instantiate(i_isolate, Utils::OpenHandle(this), - context, callback, nullptr); + context, callback); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); return Just(true); } @@ -2470,11 +2460,12 @@ Local Module::CreateSyntheticModule( auto i_isolate = reinterpret_cast(v8_isolate); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); auto i_module_name = Utils::OpenHandle(*module_name); - i::Handle i_export_names = i_isolate->factory()->NewFixedArray( - static_cast(export_names.size())); + i::DirectHandle i_export_names = + i_isolate->factory()->NewFixedArray( + static_cast(export_names.size())); for (int i = 0; i < i_export_names->length(); ++i) { - i::Handle str = i_isolate->factory()->InternalizeString( - Utils::OpenHandle(*export_names[i])); + i::DirectHandle str = i_isolate->factory()->InternalizeString( + Utils::OpenDirectHandle(*export_names[i])); i_export_names->set(i, *str); } return v8::Utils::ToLocal( @@ -2496,7 +2487,7 @@ Maybe Module::SetSyntheticModuleExport(Isolate* v8_isolate, ENTER_V8_NO_SCRIPT(i_isolate, v8_isolate->GetCurrentContext(), Module, SetSyntheticModuleExport, i::HandleScope); has_exception = i::SyntheticModule::SetExport( - i_isolate, i::Handle::cast(self), + i_isolate, i::Cast(self), i_export_name, i_export_value) .IsNothing(); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); @@ -2513,8 +2504,9 @@ Module::GetStalledTopLevelAwaitMessages(Isolate* isolate) { "called on a SourceTextModule"); std::vector< std::tuple, i::Handle>> - stalled_awaits = i::DirectHandle::cast(self) - ->GetStalledTopLevelAwaitMessages(i_isolate); + stalled_awaits = + i::Cast(self)->GetStalledTopLevelAwaitMessages( + i_isolate); LocalVector modules(isolate); LocalVector messages(isolate); @@ -2572,7 +2564,7 @@ MaybeLocal ScriptCompiler::CompileUnboundInternal( source->host_defined_options, source->resource_options); i::MaybeHandle maybe_function_info; - if (options == kConsumeCodeCache) { + if (options & kConsumeCodeCache) { if (source->consume_cache_task) { // Take ownership of the internal deserialization task and clear it off // the consume task on the source. @@ -2597,7 +2589,7 @@ MaybeLocal ScriptCompiler::CompileUnboundInternal( &source->compilation_details); source->cached_data->rejected = cached_data->rejected(); } - } else if (options == kConsumeCompileHints) { + } else if (options & kConsumeCompileHints) { maybe_function_info = i::Compiler::GetSharedFunctionInfoForScriptWithCompileHints( i_isolate, str, script_details, source->compile_hint_callback, @@ -2645,10 +2637,9 @@ MaybeLocal