From 1c39b5296d6c4f2addf67188ce2f6ae037dc52f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 18 Apr 2024 07:06:43 +0200 Subject: [PATCH 01/13] deps: update V8 to 12.3.219.16 --- deps/v8/.gitignore | 12 +- deps/v8/AUTHORS | 1 + deps/v8/BUILD.bazel | 17 +- deps/v8/BUILD.gn | 68 +- deps/v8/DEPS | 59 +- deps/v8/PRESUBMIT.py | 5 +- deps/v8/build_overrides/build.gni | 7 + deps/v8/gni/v8.gni | 7 + .../v8/include/cppgc/internal/api-constants.h | 2 +- deps/v8/include/v8-array-buffer.h | 6 + deps/v8/include/v8-callbacks.h | 18 +- deps/v8/include/v8-context.h | 6 +- deps/v8/include/v8-forward.h | 1 + deps/v8/include/v8-function-callback.h | 3 +- deps/v8/include/v8-internal.h | 4 - deps/v8/include/v8-isolate.h | 15 +- deps/v8/include/v8-local-handle.h | 3 + deps/v8/include/v8-persistent-handle.h | 2 +- deps/v8/include/v8-script.h | 13 +- deps/v8/include/v8-snapshot.h | 7 +- deps/v8/include/v8-template.h | 51 +- deps/v8/include/v8-traced-handle.h | 29 - deps/v8/include/v8-util.h | 25 +- deps/v8/include/v8-version.h | 6 +- deps/v8/infra/testing/builders.pyl | 2 - deps/v8/samples/shell.cc | 119 +- deps/v8/src/DEPS | 7 + deps/v8/src/api/api-inl.h | 4 +- deps/v8/src/api/api.cc | 157 +- deps/v8/src/api/api.h | 181 +- deps/v8/src/ast/ast-source-ranges.h | 34 + deps/v8/src/ast/ast-traversal-visitor.h | 15 +- deps/v8/src/ast/ast-value-factory.cc | 2 +- deps/v8/src/ast/ast.cc | 31 +- deps/v8/src/ast/ast.h | 97 +- deps/v8/src/ast/modules.cc | 58 +- deps/v8/src/ast/modules.h | 24 +- deps/v8/src/ast/prettyprinter.cc | 28 +- deps/v8/src/ast/scopes.cc | 13 +- deps/v8/src/ast/scopes.h | 1 + deps/v8/src/base/bounds.h | 14 + deps/v8/src/base/macros.h | 8 +- deps/v8/src/base/optional.h | 867 +---- .../src/base/platform/condition-variable.cc | 2 +- deps/v8/src/base/platform/memory.h | 4 - deps/v8/src/base/platform/platform-posix.cc | 1 + .../src/base/platform/platform-starboard.cc | 66 +- deps/v8/src/base/platform/platform-win32.cc | 1 + deps/v8/src/base/platform/semaphore.cc | 2 +- deps/v8/src/base/platform/time.cc | 37 +- deps/v8/src/baseline/baseline-compiler.cc | 29 + deps/v8/src/baseline/baseline-compiler.h | 1 + deps/v8/src/builtins/accessors.cc | 14 +- deps/v8/src/builtins/arm/builtins-arm.cc | 8 +- deps/v8/src/builtins/arm64/builtins-arm64.cc | 19 +- deps/v8/src/builtins/base.tq | 7 +- .../builtins/builtins-async-generator-gen.cc | 4 +- .../src/builtins/builtins-collections-gen.cc | 7 +- .../src/builtins/builtins-constructor-gen.cc | 8 +- deps/v8/src/builtins/builtins-definitions.h | 30 +- .../v8/src/builtins/builtins-generator-gen.cc | 3 + deps/v8/src/builtins/builtins-ic-gen.cc | 10 + deps/v8/src/builtins/builtins-internal-gen.cc | 24 +- deps/v8/src/builtins/builtins-object-gen.cc | 14 +- deps/v8/src/builtins/builtins-object.cc | 10 +- deps/v8/src/builtins/builtins-regexp-gen.cc | 37 +- deps/v8/src/builtins/builtins.cc | 22 + deps/v8/src/builtins/builtins.h | 4 + deps/v8/src/builtins/collections.tq | 15 +- deps/v8/src/builtins/js-to-js.tq | 9 + deps/v8/src/builtins/js-to-wasm.tq | 4 + .../builtins/promise-abstract-operations.tq | 7 +- deps/v8/src/builtins/promise-constructor.tq | 7 + deps/v8/src/builtins/riscv/builtins-riscv.cc | 5 +- deps/v8/src/builtins/wasm-strings.tq | 10 + deps/v8/src/builtins/wasm-to-js.tq | 3 + deps/v8/src/builtins/wasm.tq | 4 + deps/v8/src/builtins/x64/builtins-x64.cc | 27 +- deps/v8/src/codegen/arm/assembler-arm.cc | 16 +- .../arm/interface-descriptors-arm-inl.h | 5 + .../v8/src/codegen/arm/macro-assembler-arm.cc | 65 +- deps/v8/src/codegen/arm/macro-assembler-arm.h | 31 +- .../arm64/interface-descriptors-arm64-inl.h | 5 + .../codegen/arm64/macro-assembler-arm64.cc | 86 +- .../src/codegen/arm64/macro-assembler-arm64.h | 33 +- deps/v8/src/codegen/code-stub-assembler.cc | 277 +- deps/v8/src/codegen/code-stub-assembler.h | 96 +- deps/v8/src/codegen/compiler.cc | 65 +- deps/v8/src/codegen/compiler.h | 2 +- .../src/codegen/external-reference-table.cc | 31 +- .../v8/src/codegen/external-reference-table.h | 2 +- .../src/codegen/ia32/macro-assembler-ia32.cc | 50 +- .../src/codegen/ia32/macro-assembler-ia32.h | 18 +- .../src/codegen/interface-descriptors-inl.h | 11 +- deps/v8/src/codegen/interface-descriptors.cc | 3 +- deps/v8/src/codegen/interface-descriptors.h | 74 +- .../loong64/macro-assembler-loong64.cc | 5 +- .../codegen/loong64/macro-assembler-loong64.h | 4 - deps/v8/src/codegen/macro-assembler.h | 5 + .../codegen/mips64/macro-assembler-mips64.cc | 5 +- .../codegen/mips64/macro-assembler-mips64.h | 4 - .../v8/src/codegen/ppc/macro-assembler-ppc.cc | 5 +- deps/v8/src/codegen/ppc/macro-assembler-ppc.h | 8 +- .../codegen/riscv/macro-assembler-riscv.cc | 73 +- .../src/codegen/riscv/macro-assembler-riscv.h | 17 +- .../src/codegen/s390/macro-assembler-s390.cc | 7 +- .../src/codegen/s390/macro-assembler-s390.h | 8 +- deps/v8/src/codegen/script-details.h | 3 - deps/v8/src/codegen/source-position.h | 2 + .../x64/interface-descriptors-x64-inl.h | 5 + .../v8/src/codegen/x64/macro-assembler-x64.cc | 96 +- deps/v8/src/codegen/x64/macro-assembler-x64.h | 28 +- deps/v8/src/common/globals.h | 45 +- deps/v8/src/common/message-template.h | 5 + deps/v8/src/common/ptr-compr-inl.h | 8 +- deps/v8/src/common/ptr-compr.h | 15 + deps/v8/src/compiler/access-builder.cc | 12 + deps/v8/src/compiler/access-builder.h | 1 + .../backend/arm/code-generator-arm.cc | 39 +- .../backend/arm/instruction-selector-arm.cc | 5 +- .../backend/arm64/code-generator-arm64.cc | 36 +- .../arm64/instruction-selector-arm64.cc | 7 +- .../compiler/backend/code-generator-impl.h | 7 + .../v8/src/compiler/backend/code-generator.cc | 46 +- .../backend/ia32/code-generator-ia32.cc | 22 +- .../backend/ia32/instruction-selector-ia32.cc | 20 +- .../backend/instruction-selector-adapter.h | 54 +- .../backend/instruction-selector-impl.h | 34 +- .../compiler/backend/instruction-selector.cc | 73 +- .../compiler/backend/instruction-selector.h | 34 +- deps/v8/src/compiler/backend/instruction.cc | 17 +- deps/v8/src/compiler/backend/instruction.h | 18 +- .../backend/loong64/code-generator-loong64.cc | 19 +- .../loong64/instruction-selector-loong64.cc | 2 +- .../backend/mips64/code-generator-mips64.cc | 19 +- .../mips64/instruction-selector-mips64.cc | 2 +- .../backend/ppc/code-generator-ppc.cc | 8 +- .../backend/ppc/instruction-selector-ppc.cc | 2749 +++++++-------- .../compiler/backend/register-allocator.cc | 6 + .../backend/riscv/code-generator-riscv.cc | 16 +- .../riscv/instruction-selector-riscv32.cc | 2 +- .../riscv/instruction-selector-riscv64.cc | 2 +- .../backend/s390/code-generator-s390.cc | 8 +- .../backend/s390/instruction-selector-s390.cc | 34 +- .../backend/x64/code-generator-x64.cc | 31 +- .../backend/x64/instruction-selector-x64.cc | 36 +- .../v8/src/compiler/bytecode-graph-builder.cc | 25 + deps/v8/src/compiler/c-linkage.cc | 2 + deps/v8/src/compiler/code-assembler.h | 2 +- .../src/compiler/compilation-dependencies.cc | 70 +- .../src/compiler/compilation-dependencies.h | 7 +- .../compiler/const-tracking-let-helpers.cc | 71 + .../src/compiler/const-tracking-let-helpers.h | 30 + .../src/compiler/effect-control-linearizer.cc | 58 +- deps/v8/src/compiler/fast-api-calls.cc | 7 +- deps/v8/src/compiler/fast-api-calls.h | 20 + deps/v8/src/compiler/frame.cc | 5 +- deps/v8/src/compiler/frame.h | 14 +- deps/v8/src/compiler/graph-assembler.cc | 5 +- deps/v8/src/compiler/graph-assembler.h | 2 +- deps/v8/src/compiler/graph-visualizer.cc | 12 +- deps/v8/src/compiler/heap-refs.cc | 26 +- deps/v8/src/compiler/heap-refs.h | 16 +- deps/v8/src/compiler/js-call-reducer.cc | 64 +- deps/v8/src/compiler/js-call-reducer.h | 2 + .../src/compiler/js-context-specialization.cc | 59 +- .../src/compiler/js-context-specialization.h | 1 + deps/v8/src/compiler/js-generic-lowering.cc | 15 +- deps/v8/src/compiler/js-inlining.cc | 4 +- .../js-native-context-specialization.cc | 58 +- deps/v8/src/compiler/js-operator.cc | 14 +- deps/v8/src/compiler/js-operator.h | 1 + deps/v8/src/compiler/js-typed-lowering.cc | 27 + deps/v8/src/compiler/linkage.cc | 24 +- deps/v8/src/compiler/linkage.h | 25 +- deps/v8/src/compiler/machine-operator.cc | 34 +- deps/v8/src/compiler/machine-operator.h | 9 +- deps/v8/src/compiler/opcodes.h | 2 + deps/v8/src/compiler/operator-properties.cc | 1 + deps/v8/src/compiler/pipeline.cc | 321 +- deps/v8/src/compiler/pipeline.h | 18 + .../src/compiler/property-access-builder.cc | 5 +- deps/v8/src/compiler/simplified-lowering.cc | 15 + deps/v8/src/compiler/simplified-operator.cc | 1 + deps/v8/src/compiler/simplified-operator.h | 1 + .../compiler/turboshaft/analyzer-iterator.cc | 20 +- .../compiler/turboshaft/analyzer-iterator.h | 10 +- deps/v8/src/compiler/turboshaft/assembler.h | 240 +- .../turboshaft/assert-types-reducer.h | 2 +- .../turboshaft/branch-elimination-reducer.h | 42 +- .../turboshaft/builtin-call-descriptors.h | 15 +- ...de-elimination-and-simplification-phase.cc | 7 +- .../src/compiler/turboshaft/copying-phase.h | 1102 ++---- .../compiler/turboshaft/csa-optimize-phase.cc | 31 +- .../compiler/turboshaft/csa-optimize-phase.h | 6 + ...-reducer.h => dataview-lowering-reducer.h} | 10 +- .../dead-code-elimination-reducer.h | 37 +- .../debug-feature-lowering-phase.cc | 2 +- .../debug-feature-lowering-reducer.h | 6 +- .../turboshaft/decompression-optimization.cc | 7 +- .../turboshaft/define-assembler-macros.inc | 59 +- .../duplication-optimization-reducer.h | 2 +- .../turboshaft/explicit-truncation-reducer.h | 12 +- ...cer.h => fast-api-call-lowering-reducer.h} | 70 +- .../src/compiler/turboshaft/graph-builder.cc | 339 +- deps/v8/src/compiler/turboshaft/graph.h | 45 +- .../turboshaft/int64-lowering-phase.cc | 4 +- .../turboshaft/int64-lowering-reducer.h | 54 +- .../turboshaft/late-escape-analysis-reducer.h | 2 +- .../late-load-elimination-reducer.cc | 178 +- .../late-load-elimination-reducer.h | 208 +- .../load-store-simplification-reducer.h | 137 +- .../v8/src/compiler/turboshaft/loop-finder.cc | 26 +- deps/v8/src/compiler/turboshaft/loop-finder.h | 32 +- .../compiler/turboshaft/loop-peeling-phase.cc | 4 +- .../turboshaft/loop-peeling-reducer.h | 11 +- .../turboshaft/loop-unrolling-phase.cc | 4 +- .../turboshaft/loop-unrolling-reducer.cc | 2 +- .../turboshaft/loop-unrolling-reducer.h | 87 +- .../turboshaft/machine-lowering-phase.cc | 17 +- .../turboshaft/machine-lowering-reducer-inl.h | 300 +- .../turboshaft/machine-optimization-reducer.h | 90 +- .../turboshaft/maglev-graph-building-phase.cc | 641 +++- .../turboshaft/memory-optimization-reducer.h | 164 +- .../compiler/turboshaft/operation-matcher.h | 11 + deps/v8/src/compiler/turboshaft/operations.cc | 37 + deps/v8/src/compiler/turboshaft/operations.h | 466 ++- deps/v8/src/compiler/turboshaft/opmasks.h | 32 +- .../src/compiler/turboshaft/optimize-phase.cc | 4 +- deps/v8/src/compiler/turboshaft/phase.h | 21 +- .../pretenuring-propagation-reducer.h | 2 +- .../compiler/turboshaft/recreate-schedule.cc | 20 +- .../compiler/turboshaft/reduce-args-helper.h | 601 ---- .../src/compiler/turboshaft/representations.h | 57 +- .../required-optimization-reducer.h | 10 +- .../turboshaft/select-lowering-reducer.h | 2 +- .../turboshaft/simplified-lowering-phase.cc | 2 +- .../turboshaft/simplified-lowering-reducer.h | 16 +- ...ducer.h => stack-check-lowering-reducer.h} | 12 +- .../store-store-elimination-phase.cc | 4 +- .../store-store-elimination-reducer.h | 2 +- .../structural-optimization-reducer.h | 2 +- .../turboshaft/type-assertions-phase.cc | 5 +- .../turboshaft/type-inference-reducer.h | 2 +- .../turboshaft/typed-optimizations-phase.cc | 3 +- .../turboshaft/typed-optimizations-reducer.h | 2 +- deps/v8/src/compiler/turboshaft/utils.h | 5 +- .../turboshaft/value-numbering-reducer.h | 2 +- .../compiler/turboshaft/variable-reducer.h | 18 +- .../turboshaft/wasm-assembler-helpers.h | 14 +- .../wasm-dead-code-elimination-phase.cc | 7 +- .../turboshaft/wasm-gc-optimize-phase.cc | 5 +- ... => wasm-gc-typed-optimization-reducer.cc} | 66 +- ...h => wasm-gc-typed-optimization-reducer.h} | 30 +- .../turboshaft/wasm-js-lowering-reducer.h | 9 +- .../wasm-load-elimination-reducer.h | 2 +- .../turboshaft/wasm-lowering-phase.cc | 3 +- .../turboshaft/wasm-lowering-reducer.h | 42 +- .../turboshaft/wasm-optimize-phase.cc | 5 +- .../compiler/turboshaft/wasm-revec-phase.cc | 2 +- .../compiler/turboshaft/wasm-revec-reducer.cc | 270 +- .../compiler/turboshaft/wasm-revec-reducer.h | 109 +- .../turboshaft/wasm-turboshaft-compiler.h | 21 +- deps/v8/src/compiler/typer.cc | 6 + deps/v8/src/compiler/types.cc | 1 + deps/v8/src/compiler/verifier.cc | 5 + deps/v8/src/compiler/wasm-call-descriptors.h | 5 + .../src/compiler/wasm-compiler-definitions.cc | 1 + .../src/compiler/wasm-compiler-definitions.h | 2 +- deps/v8/src/compiler/wasm-compiler.cc | 271 +- deps/v8/src/compiler/wasm-compiler.h | 13 +- deps/v8/src/compiler/wasm-gc-lowering.cc | 3 +- deps/v8/src/compiler/wasm-graph-assembler.cc | 14 + deps/v8/src/compiler/wasm-graph-assembler.h | 2 + deps/v8/src/compiler/wasm-inlining.cc | 54 +- deps/v8/src/compiler/wasm-inlining.h | 15 +- deps/v8/src/d8/d8-test.cc | 4 +- deps/v8/src/d8/d8.cc | 669 ++-- deps/v8/src/d8/d8.h | 14 +- deps/v8/src/debug/debug-interface.cc | 181 +- deps/v8/src/debug/debug-scopes.cc | 78 +- deps/v8/src/debug/debug.cc | 130 +- deps/v8/src/debug/debug.h | 10 +- deps/v8/src/debug/liveedit.cc | 6 +- deps/v8/src/deoptimizer/deoptimize-reason.h | 1 + deps/v8/src/deoptimizer/deoptimizer.cc | 7 +- .../src/diagnostics/basic-block-profiler.cc | 2 +- deps/v8/src/diagnostics/etw-jit-win.cc | 2 +- deps/v8/src/diagnostics/gdb-jit.cc | 2 +- deps/v8/src/diagnostics/objects-debug.cc | 81 +- deps/v8/src/diagnostics/objects-printer.cc | 64 +- deps/v8/src/execution/arm64/simulator-arm64.h | 2 +- deps/v8/src/execution/embedder-state.cc | 2 +- deps/v8/src/execution/frames.cc | 41 +- deps/v8/src/execution/frames.h | 6 +- deps/v8/src/execution/isolate-inl.h | 4 + deps/v8/src/execution/isolate-utils-inl.h | 6 +- deps/v8/src/execution/isolate.cc | 628 ++-- deps/v8/src/execution/isolate.h | 55 +- .../externalize-string-extension.cc | 4 +- deps/v8/src/extensions/gc-extension.cc | 46 +- deps/v8/src/extensions/gc-extension.h | 9 +- deps/v8/src/flags/flag-definitions.h | 70 +- deps/v8/src/flags/flags.cc | 145 +- deps/v8/src/flags/flags.h | 13 + deps/v8/src/handles/traced-handles-inl.h | 2 +- deps/v8/src/handles/traced-handles.cc | 2 - deps/v8/src/handles/traced-handles.h | 9 +- deps/v8/src/heap/basic-memory-chunk.cc | 49 +- deps/v8/src/heap/basic-memory-chunk.h | 192 +- deps/v8/src/heap/cppgc-js/cpp-heap.cc | 34 +- deps/v8/src/heap/cppgc-js/cpp-heap.h | 10 + deps/v8/src/heap/cppgc-js/cpp-snapshot.cc | 91 +- deps/v8/src/heap/cppgc/allocation.cc | 4 +- deps/v8/src/heap/cppgc/garbage-collector.h | 5 + deps/v8/src/heap/cppgc/gc-invoker.cc | 11 + deps/v8/src/heap/cppgc/gc-invoker.h | 3 + deps/v8/src/heap/cppgc/globals.h | 8 +- deps/v8/src/heap/cppgc/heap-base.cc | 4 +- deps/v8/src/heap/cppgc/heap-base.h | 2 +- deps/v8/src/heap/cppgc/heap-consistency.cc | 2 +- deps/v8/src/heap/cppgc/heap-object-header.h | 8 +- deps/v8/src/heap/cppgc/heap.cc | 5 +- deps/v8/src/heap/cppgc/heap.h | 6 + deps/v8/src/heap/cppgc/memory.h | 2 +- deps/v8/src/heap/cppgc/object-allocator.cc | 19 +- deps/v8/src/heap/cppgc/object-allocator.h | 29 + deps/v8/src/heap/cppgc/object-start-bitmap.h | 4 +- deps/v8/src/heap/cppgc/platform.cc | 2 +- deps/v8/src/heap/factory-base-inl.h | 19 +- deps/v8/src/heap/factory-base.cc | 47 +- deps/v8/src/heap/factory-base.h | 10 +- deps/v8/src/heap/factory-inl.h | 6 +- deps/v8/src/heap/factory.cc | 75 +- deps/v8/src/heap/factory.h | 14 +- deps/v8/src/heap/heap-allocator-inl.h | 2 +- deps/v8/src/heap/heap-allocator.h | 2 + deps/v8/src/heap/heap-inl.h | 3 +- deps/v8/src/heap/heap-write-barrier-inl.h | 115 +- deps/v8/src/heap/heap.cc | 119 +- deps/v8/src/heap/heap.h | 10 +- deps/v8/src/heap/incremental-marking.cc | 4 - deps/v8/src/heap/large-page.h | 2 - deps/v8/src/heap/local-heap-inl.h | 5 + deps/v8/src/heap/local-heap.h | 5 + deps/v8/src/heap/main-allocator-inl.h | 3 + deps/v8/src/heap/main-allocator.cc | 64 +- deps/v8/src/heap/main-allocator.h | 6 +- deps/v8/src/heap/mark-compact.cc | 8 +- deps/v8/src/heap/mark-sweep-utilities.cc | 3 + deps/v8/src/heap/marking-inl.h | 12 +- deps/v8/src/heap/marking-visitor-inl.h | 54 +- deps/v8/src/heap/marking-visitor.h | 3 + deps/v8/src/heap/marking.h | 4 +- deps/v8/src/heap/memory-allocator.cc | 14 +- deps/v8/src/heap/memory-chunk-header.cc | 39 + deps/v8/src/heap/memory-chunk-header.h | 272 ++ deps/v8/src/heap/memory-chunk-layout.cc | 7 +- deps/v8/src/heap/memory-chunk-layout.h | 4 +- deps/v8/src/heap/memory-chunk.h | 4 +- deps/v8/src/heap/memory-measurement-inl.h | 7 +- deps/v8/src/heap/memory-measurement.cc | 4 +- deps/v8/src/heap/new-spaces.cc | 31 +- deps/v8/src/heap/new-spaces.h | 15 +- deps/v8/src/heap/object-stats.cc | 6 +- deps/v8/src/heap/objects-visiting-inl.h | 30 +- deps/v8/src/heap/objects-visiting.h | 143 +- deps/v8/src/heap/page.h | 17 +- deps/v8/src/heap/paged-spaces.h | 15 - deps/v8/src/heap/read-only-spaces.cc | 4 +- deps/v8/src/heap/reference-summarizer.cc | 3 + deps/v8/src/heap/setup-heap-internal.cc | 22 + deps/v8/src/heap/sweeper.cc | 102 +- deps/v8/src/heap/sweeper.h | 35 +- deps/v8/src/ic/accessor-assembler.cc | 85 +- deps/v8/src/ic/accessor-assembler.h | 7 + deps/v8/src/ic/handler-configuration-inl.h | 5 +- deps/v8/src/ic/handler-configuration.cc | 26 +- deps/v8/src/ic/handler-configuration.h | 8 +- deps/v8/src/ic/ic.cc | 403 ++- deps/v8/src/ic/ic.h | 23 +- deps/v8/src/ic/keyed-store-generic.cc | 21 +- deps/v8/src/init/bootstrapper.cc | 25 +- deps/v8/src/init/heap-symbols.h | 1 - deps/v8/src/init/isolate-allocator.cc | 8 - deps/v8/src/init/isolate-allocator.h | 20 +- deps/v8/src/init/v8.cc | 10 +- deps/v8/src/inspector/v8-console.cc | 8 +- .../src/interpreter/block-coverage-builder.h | 16 + .../src/interpreter/bytecode-array-builder.cc | 106 +- .../src/interpreter/bytecode-array-builder.h | 2 +- .../src/interpreter/bytecode-array-writer.cc | 2 +- deps/v8/src/interpreter/bytecode-generator.cc | 322 +- deps/v8/src/interpreter/bytecode-generator.h | 3 + deps/v8/src/interpreter/bytecodes.h | 4 + .../src/interpreter/constant-array-builder.cc | 14 +- .../src/interpreter/constant-array-builder.h | 2 +- .../src/interpreter/control-flow-builders.cc | 37 + .../src/interpreter/control-flow-builders.h | 75 + .../src/interpreter/interpreter-assembler.cc | 6 +- .../src/interpreter/interpreter-generator.cc | 35 +- deps/v8/src/json/json-parser.cc | 724 ++-- deps/v8/src/logging/runtime-call-stats.cc | 3 +- deps/v8/src/logging/runtime-call-stats.h | 4 + .../src/maglev/arm/maglev-assembler-arm-inl.h | 23 +- .../maglev/arm64/maglev-assembler-arm64-inl.h | 23 +- deps/v8/src/maglev/maglev-assembler.cc | 84 +- deps/v8/src/maglev/maglev-assembler.h | 42 +- deps/v8/src/maglev/maglev-code-generator.cc | 8 +- .../maglev/maglev-concurrent-dispatcher.cc | 7 + deps/v8/src/maglev/maglev-graph-builder.cc | 403 ++- deps/v8/src/maglev/maglev-graph-builder.h | 142 +- .../maglev/maglev-interpreter-frame-state.cc | 8 +- .../maglev/maglev-interpreter-frame-state.h | 4 +- deps/v8/src/maglev/maglev-ir.cc | 155 +- deps/v8/src/maglev/maglev-ir.h | 594 ++-- .../src/maglev/x64/maglev-assembler-x64-inl.h | 23 +- deps/v8/src/numbers/conversions.h | 5 +- deps/v8/src/objects/bytecode-array-inl.h | 16 +- deps/v8/src/objects/bytecode-array.h | 6 +- deps/v8/src/objects/bytecode-array.tq | 4 +- deps/v8/src/objects/code-inl.h | 86 +- deps/v8/src/objects/code.cc | 11 +- deps/v8/src/objects/code.h | 32 +- deps/v8/src/objects/compressed-slots-inl.h | 8 + deps/v8/src/objects/compressed-slots.h | 1 + deps/v8/src/objects/contexts.cc | 72 + deps/v8/src/objects/contexts.h | 17 +- deps/v8/src/objects/contexts.tq | 95 + deps/v8/src/objects/deoptimization-data-inl.h | 2 +- deps/v8/src/objects/deoptimization-data.cc | 18 +- deps/v8/src/objects/deoptimization-data.h | 11 +- deps/v8/src/objects/dependent-code.cc | 6 + deps/v8/src/objects/dependent-code.h | 3 + deps/v8/src/objects/descriptor-array-inl.h | 1 + deps/v8/src/objects/dictionary.h | 5 +- deps/v8/src/objects/feedback-vector.cc | 28 +- deps/v8/src/objects/feedback-vector.h | 1 + deps/v8/src/objects/fixed-array-inl.h | 44 +- deps/v8/src/objects/fixed-array.h | 91 +- deps/v8/src/objects/fixed-array.tq | 8 +- deps/v8/src/objects/hash-table-inl.h | 12 +- deps/v8/src/objects/hash-table.h | 11 +- deps/v8/src/objects/heap-object.h | 6 + deps/v8/src/objects/instance-type-checker.h | 3 +- deps/v8/src/objects/instance-type-inl.h | 8 + deps/v8/src/objects/instance-type.h | 33 +- deps/v8/src/objects/instruction-stream-inl.h | 9 +- deps/v8/src/objects/js-display-names.cc | 2 +- deps/v8/src/objects/js-function.cc | 1 + deps/v8/src/objects/js-generator.h | 2 +- deps/v8/src/objects/js-objects-inl.h | 3 +- deps/v8/src/objects/js-objects.cc | 223 +- deps/v8/src/objects/js-regexp.cc | 34 +- deps/v8/src/objects/literal-objects.h | 1 + deps/v8/src/objects/lookup.cc | 11 +- deps/v8/src/objects/lookup.h | 34 +- deps/v8/src/objects/map-inl.h | 11 + deps/v8/src/objects/map-updater.cc | 10 + deps/v8/src/objects/map.cc | 23 +- deps/v8/src/objects/map.h | 153 +- deps/v8/src/objects/object-list-macros.h | 72 +- deps/v8/src/objects/object-macros.h | 47 +- .../objects/objects-body-descriptors-inl.h | 94 +- deps/v8/src/objects/objects-definitions.h | 108 +- deps/v8/src/objects/objects-inl.h | 16 +- deps/v8/src/objects/objects.cc | 152 +- deps/v8/src/objects/objects.h | 8 +- deps/v8/src/objects/property-cell-inl.h | 11 + deps/v8/src/objects/property-cell.h | 24 + deps/v8/src/objects/property-cell.tq | 9 + deps/v8/src/objects/property-details.h | 4 + deps/v8/src/objects/regexp-match-info.h | 8 + deps/v8/src/objects/scope-info.cc | 12 +- deps/v8/src/objects/scope-info.tq | 1 + .../v8/src/objects/shared-function-info-inl.h | 13 +- deps/v8/src/objects/shared-function-info.h | 7 +- deps/v8/src/objects/source-text-module.cc | 4 +- deps/v8/src/objects/source-text-module.h | 8 +- deps/v8/src/objects/source-text-module.tq | 4 +- .../src/objects/swiss-name-dictionary-inl.h | 1 + deps/v8/src/objects/tagged-field-inl.h | 7 +- deps/v8/src/objects/tagged-field.h | 62 +- deps/v8/src/objects/tagged-impl-inl.h | 11 +- deps/v8/src/objects/template-objects.cc | 2 +- deps/v8/src/objects/templates-inl.h | 2 + deps/v8/src/objects/templates.cc | 168 + deps/v8/src/objects/templates.h | 23 + deps/v8/src/objects/templates.tq | 6 + deps/v8/src/objects/transitions.cc | 18 +- deps/v8/src/objects/transitions.h | 8 +- deps/v8/src/objects/trusted-object-inl.h | 47 +- deps/v8/src/objects/trusted-object.h | 25 +- deps/v8/src/parsing/import-assertions.cc | 2 +- deps/v8/src/parsing/import-assertions.h | 10 +- deps/v8/src/parsing/keywords-gen.h | 240 +- deps/v8/src/parsing/keywords.txt | 103 +- deps/v8/src/parsing/parse-info.cc | 4 - deps/v8/src/parsing/parser-base.h | 1038 +++--- deps/v8/src/parsing/parser.cc | 364 +- deps/v8/src/parsing/parser.h | 37 +- deps/v8/src/parsing/preparser.cc | 24 +- deps/v8/src/parsing/preparser.h | 25 +- deps/v8/src/parsing/rewriter.cc | 6 +- deps/v8/src/parsing/scanner-inl.h | 366 +- deps/v8/src/parsing/scanner.cc | 122 +- deps/v8/src/parsing/scanner.h | 32 +- deps/v8/src/parsing/token.cc | 12 +- deps/v8/src/parsing/token.h | 303 +- .../src/profiler/heap-snapshot-generator.cc | 28 +- .../regexp/arm/regexp-macro-assembler-arm.cc | 3 +- .../arm64/regexp-macro-assembler-arm64.cc | 3 +- .../ia32/regexp-macro-assembler-ia32.cc | 3 +- .../loong64/regexp-macro-assembler-loong64.cc | 3 +- .../mips64/regexp-macro-assembler-mips64.cc | 3 +- .../regexp/ppc/regexp-macro-assembler-ppc.cc | 3 +- deps/v8/src/regexp/regexp-ast.cc | 6 +- deps/v8/src/regexp/regexp-ast.h | 16 +- deps/v8/src/regexp/regexp-compiler-tonode.cc | 15 +- deps/v8/src/regexp/regexp-parser.cc | 105 +- deps/v8/src/regexp/regexp-utils.cc | 27 +- deps/v8/src/regexp/regexp-utils.h | 3 + .../riscv/regexp-macro-assembler-riscv.cc | 3 +- .../s390/regexp-macro-assembler-s390.cc | 7 +- .../regexp/x64/regexp-macro-assembler-x64.cc | 3 +- deps/v8/src/roots/roots.h | 22 +- deps/v8/src/roots/static-roots.h | 1340 ++++---- deps/v8/src/runtime/runtime-classes.cc | 18 +- deps/v8/src/runtime/runtime-debug.cc | 4 +- deps/v8/src/runtime/runtime-forin.cc | 9 +- deps/v8/src/runtime/runtime-internal.cc | 11 + deps/v8/src/runtime/runtime-module.cc | 6 +- deps/v8/src/runtime/runtime-object.cc | 2 +- deps/v8/src/runtime/runtime-promise.cc | 8 +- deps/v8/src/runtime/runtime-regexp.cc | 114 +- deps/v8/src/runtime/runtime-scopes.cc | 13 +- deps/v8/src/runtime/runtime-shadow-realm.cc | 4 +- deps/v8/src/runtime/runtime-test-wasm.cc | 49 +- deps/v8/src/runtime/runtime-test.cc | 5 +- deps/v8/src/runtime/runtime-wasm.cc | 64 +- deps/v8/src/runtime/runtime.h | 4 +- deps/v8/src/sandbox/README.md | 6 + deps/v8/src/sandbox/code-entrypoint-tag.h | 43 +- deps/v8/src/sandbox/code-pointer-table-inl.h | 6 + deps/v8/src/sandbox/code-pointer-table.h | 4 +- .../src/sandbox/external-pointer-table-inl.h | 10 - deps/v8/src/sandbox/external-pointer-table.cc | 36 +- deps/v8/src/sandbox/external-pointer-table.h | 20 +- deps/v8/src/sandbox/indirect-pointer-tag.h | 2 +- deps/v8/src/sandbox/sandbox.h | 33 +- deps/v8/src/snapshot/code-serializer.cc | 37 +- deps/v8/src/snapshot/code-serializer.h | 5 +- deps/v8/src/snapshot/mksnapshot.cc | 38 +- deps/v8/src/snapshot/read-only-serializer.cc | 2 +- deps/v8/src/snapshot/serializer.cc | 13 +- deps/v8/src/snapshot/snapshot.cc | 30 +- deps/v8/src/snapshot/snapshot.h | 16 +- deps/v8/src/torque/constants.h | 1 + deps/v8/src/torque/global-context.h | 1 + deps/v8/src/torque/implementation-visitor.cc | 3 +- deps/v8/src/torque/type-oracle.h | 4 + deps/v8/src/torque/types.cc | 5 + deps/v8/src/tracing/DEPS | 7 +- deps/v8/src/tracing/code-data-source.cc | 282 ++ deps/v8/src/tracing/code-data-source.h | 155 + deps/v8/src/tracing/code-trace-context.h | 95 + deps/v8/src/tracing/perfetto-logger.cc | 470 +++ deps/v8/src/tracing/perfetto-logger.h | 73 + deps/v8/src/tracing/perfetto-utils.cc | 23 + deps/v8/src/tracing/perfetto-utils.h | 71 + deps/v8/src/utils/bit-vector.h | 27 +- deps/v8/src/utils/boxed-float.h | 23 + deps/v8/src/wasm/DEPS | 18 +- .../baseline/arm/liftoff-assembler-arm-inl.h | 244 +- .../arm64/liftoff-assembler-arm64-inl.h | 406 ++- .../ia32/liftoff-assembler-ia32-inl.h | 29 +- .../src/wasm/baseline/liftoff-assembler-inl.h | 25 +- deps/v8/src/wasm/baseline/liftoff-assembler.h | 13 +- deps/v8/src/wasm/baseline/liftoff-compiler.cc | 242 +- .../loong64/liftoff-assembler-loong64-inl.h | 3 +- .../mips64/liftoff-assembler-mips64-inl.h | 3 +- .../baseline/ppc/liftoff-assembler-ppc-inl.h | 21 +- .../riscv/liftoff-assembler-riscv-inl.h | 4 +- .../riscv/liftoff-assembler-riscv32-inl.h | 17 + .../riscv/liftoff-assembler-riscv64-inl.h | 17 + .../s390/liftoff-assembler-s390-inl.h | 20 +- .../baseline/x64/liftoff-assembler-x64-inl.h | 33 +- deps/v8/src/wasm/c-api.cc | 12 +- deps/v8/src/wasm/canonical-types.cc | 25 +- deps/v8/src/wasm/canonical-types.h | 3 + .../v8/src/wasm/compilation-environment-inl.h | 30 + deps/v8/src/wasm/compilation-environment.h | 8 + .../src/wasm/constant-expression-interface.cc | 41 +- deps/v8/src/wasm/constant-expression.cc | 38 +- deps/v8/src/wasm/constant-expression.h | 7 +- deps/v8/src/wasm/decoder.h | 3 +- deps/v8/src/wasm/function-body-decoder-impl.h | 104 +- deps/v8/src/wasm/function-body-decoder.cc | 32 +- deps/v8/src/wasm/function-body-decoder.h | 11 +- deps/v8/src/wasm/function-compiler.cc | 33 +- deps/v8/src/wasm/function-compiler.h | 3 +- deps/v8/src/wasm/graph-builder-interface.cc | 39 + deps/v8/src/wasm/inlining-tree.h | 43 +- deps/v8/src/wasm/module-compiler.cc | 68 +- deps/v8/src/wasm/module-decoder-impl.h | 302 +- deps/v8/src/wasm/module-decoder.cc | 9 +- deps/v8/src/wasm/module-decoder.h | 4 +- deps/v8/src/wasm/module-instantiate.cc | 157 +- deps/v8/src/wasm/object-access.h | 5 + deps/v8/src/wasm/string-builder-multiline.h | 1 + .../v8/src/wasm/turboshaft-graph-interface.cc | 902 ++--- deps/v8/src/wasm/turboshaft-graph-interface.h | 74 + deps/v8/src/wasm/wasm-builtin-list.h | 1 + deps/v8/src/wasm/wasm-code-manager.cc | 19 +- deps/v8/src/wasm/wasm-code-manager.h | 11 +- deps/v8/src/wasm/wasm-constants.h | 1 + deps/v8/src/wasm/wasm-debug.cc | 9 +- deps/v8/src/wasm/wasm-disassembler-impl.h | 12 +- deps/v8/src/wasm/wasm-disassembler.cc | 172 +- deps/v8/src/wasm/wasm-engine.cc | 61 +- deps/v8/src/wasm/wasm-external-refs.cc | 5 - deps/v8/src/wasm/wasm-feature-flags.h | 37 +- deps/v8/src/wasm/wasm-features.cc | 13 +- deps/v8/src/wasm/wasm-features.h | 5 +- deps/v8/src/wasm/wasm-js.cc | 201 +- deps/v8/src/wasm/wasm-js.h | 6 + deps/v8/src/wasm/wasm-module-builder.cc | 8 +- deps/v8/src/wasm/wasm-module-builder.h | 7 +- deps/v8/src/wasm/wasm-module.cc | 4 +- deps/v8/src/wasm/wasm-module.h | 40 +- deps/v8/src/wasm/wasm-objects-inl.h | 84 +- deps/v8/src/wasm/wasm-objects.cc | 680 ++-- deps/v8/src/wasm/wasm-objects.h | 165 +- deps/v8/src/wasm/wasm-objects.tq | 21 +- deps/v8/src/wasm/wasm-subtyping.cc | 36 +- deps/v8/src/wasm/wasm-subtyping.h | 11 +- deps/v8/src/wasm/well-known-imports.cc | 2 + deps/v8/src/wasm/well-known-imports.h | 1 + deps/v8/src/wasm/wrappers.cc | 900 +++++ deps/v8/test/cctest/cctest.cc | 11 +- deps/v8/test/cctest/cctest.status | 4 +- .../cctest/compiler/test-code-generator.cc | 7 +- .../test-js-context-specialization.cc | 4 + .../test/cctest/compiler/test-run-machops.cc | 1 + .../cctest/compiler/test-run-native-calls.cc | 1 + deps/v8/test/cctest/heap/heap-utils.h | 4 +- .../heap/test-external-string-tracker.cc | 30 +- deps/v8/test/cctest/heap/test-heap.cc | 633 ++-- deps/v8/test/cctest/heap/test-spaces.cc | 6 +- deps/v8/test/cctest/test-accessors.cc | 8 +- deps/v8/test/cctest/test-api-array-buffer.cc | 2 +- deps/v8/test/cctest/test-api.cc | 408 ++- deps/v8/test/cctest/test-cpu-profiler.cc | 98 +- deps/v8/test/cctest/test-debug.cc | 54 +- .../test/cctest/test-field-type-tracking.cc | 1 + deps/v8/test/cctest/test-heap-profiler.cc | 21 +- deps/v8/test/cctest/test-liveedit.cc | 5 +- deps/v8/test/cctest/test-lockers.cc | 5 +- deps/v8/test/cctest/test-log-stack-tracer.cc | 3 +- deps/v8/test/cctest/test-serialize.cc | 224 +- deps/v8/test/cctest/test-shared-strings.cc | 1 + deps/v8/test/cctest/test-strings.cc | 4 +- deps/v8/test/cctest/trace-extension.cc | 6 +- .../cctest/wasm/test-liftoff-inspection.cc | 15 +- .../cctest/wasm/test-run-wasm-wrappers.cc | 12 - deps/v8/test/cctest/wasm/test-run-wasm.cc | 5 +- deps/v8/test/cctest/wasm/wasm-run-utils.cc | 85 +- deps/v8/test/cctest/wasm/wasm-run-utils.h | 6 +- .../test/debugger/debug/debug-materialized.js | 2 - .../debugger/debug/es6/debug-blockscopes.js | 1 - .../debug-evaluate-receiver-before-super.js | 2 - .../throw-with-throw-in-reject.js | 11 +- .../debug/es6/default-parameters-debug.js | 2 +- .../debug/es6/regress/regress-468661.js | 2 - .../es8/async-debug-caught-exception-cases.js | 4 +- .../es8/async-function-debug-evaluate.js | 2 +- .../wasm/gdb-server/test_files/test_memory.js | 7 +- deps/v8/test/fuzzer/wasm-compile.cc | 708 +++- deps/v8/test/fuzzer/wasm-fuzzer-common.cc | 54 +- .../break-on-exception-async-gen-expected.txt | 13 +- .../debugger/break-on-exception-async-gen.js | 35 + ...eption-framework-promise-tree-expected.txt | 228 +- ...tion-promise-catch-prediction-expected.txt | 2998 ++++++++--------- ...k-on-exception-promise-catch-prediction.js | 304 +- .../restart-top-frame-local-variables.js | 2 - .../inspector/debugger/tdz-modules-scopes.js | 2 +- deps/v8/test/inspector/debugger/tdz-scopes.js | 2 +- .../debugger/value-unavailable-scopes.js | 2 +- .../debugger/wasm-evaluate-on-call-frame.js | 10 +- .../test/inspector/debugger/wasm-gc-anyref.js | 2 +- .../inspector/debugger/wasm-global-names.js | 4 +- .../inspector/debugger/wasm-scope-info.js | 2 +- deps/v8/test/inspector/inspector.status | 6 + deps/v8/test/inspector/isolate-data.cc | 6 +- deps/v8/test/inspector/isolate-data.h | 2 +- .../regress-crbug-1509340-expected.txt | 7 +- .../regress/regress-crbug-1509340.js | 11 +- .../regress-crbug-1510427-expected.txt | 74 + .../regress/regress-crbug-1510427.js | 58 + .../fail/modules-import-assertions-fail-1.out | 1 + .../fail/modules-import-assertions-fail-2.out | 3 +- .../v8/test/message/wasm-recognize-imports.js | 2 + .../test/message/wasm-recognize-imports.out | 9 +- .../compiler/call-with-arraylike-or-spread.js | 15 +- .../mjsunit/compiler/conditional-chain.js | 123 + .../mjsunit/compiler/optimized-array-at.js | 4 +- .../mjsunit/compiler/regress-324782095.js | 29 + .../mjsunit/compiler/regress-crbug-1519399.js | 19 + .../mjsunit/compiler/regress-crbug-1520774.js | 20 + ...ady-not-constant-global-no-deopt-maglev.js | 44 + ...et-already-not-constant-no-deopt-maglev.js | 42 + .../test/mjsunit/const-tracking-let-basic.js | 33 + .../const-tracking-let-globalic-slow-path.js | 122 + ...const-tracking-let-initial-value-maglev.js | 27 + ...st-tracking-let-initialization-baseline.js | 23 + .../const-tracking-let-invalidate-eval.js | 25 + ...cking-let-invalidate-function-baseline1.js | 37 + ...cking-let-invalidate-function-baseline2.js | 37 + ...cking-let-invalidate-function-baseline3.js | 37 + ...ng-let-invalidate-function-interpreter1.js | 35 + ...ng-let-invalidate-function-interpreter2.js | 34 + ...ng-let-invalidate-function-interpreter3.js | 35 + ...racking-let-invalidate-function-maglev1.js | 41 + ...racking-let-invalidate-function-maglev2.js | 39 + ...racking-let-invalidate-function-maglev3.js | 39 + ...cking-let-invalidate-function-turbofan1.js | 47 + ...cking-let-invalidate-function-turbofan2.js | 43 + ...cking-let-invalidate-function-turbofan3.js | 43 + ...let-invalidate-inner-function-baseline1.js | 45 + ...let-invalidate-inner-function-baseline2.js | 46 + ...-invalidate-inner-function-interpreter1.js | 41 + ...-invalidate-inner-function-interpreter2.js | 42 + ...g-let-invalidate-inner-function-maglev1.js | 47 + ...g-let-invalidate-inner-function-maglev2.js | 48 + ...let-invalidate-inner-function-turbofan1.js | 49 + ...let-invalidate-inner-function-turbofan2.js | 50 + ...g-let-invalidate-maglev-representations.js | 66 + ...t-tracking-let-invalidate-repl-baseline.js | 39 + ...racking-let-invalidate-repl-interpreter.js | 34 + ...nst-tracking-let-invalidate-repl-maglev.js | 39 + ...t-tracking-let-invalidate-repl-turbofan.js | 39 + ...ing-let-invalidate-storeglobal-baseline.js | 21 + ...-let-invalidate-storeglobal-interpreter.js | 18 + ...cking-let-invalidate-storeglobal-maglev.js | 21 + ...ing-let-invalidate-storeglobal-turbofan.js | 21 + ...acking-let-invalidate-toplevel-baseline.js | 31 + ...ing-let-invalidate-toplevel-interpreter.js | 26 + ...tracking-let-invalidate-toplevel-maglev.js | 35 + ...acking-let-invalidate-toplevel-turbofan.js | 35 + .../mjsunit/const-tracking-let-multiple.js | 97 + ...let-no-deopt-write-if-already-not-const.js | 41 + .../mjsunit/const-tracking-let-not-const.js | 26 + .../const-tracking-let-other-script.js | 22 + ...nst-tracking-let-read-is-inner-function.js | 34 + .../const-tracking-let-read-uninitialized.js | 22 + .../const-tracking-let-repl-initialize.js | 19 + .../const-tracking-let-repl-side-data-sync.js | 17 + .../test/mjsunit/const-tracking-let-repl.js | 27 + .../const-tracking-let-uninitialized.js | 25 + ...acking-let-wont-prevent-osr-to-turbofan.js | 26 + deps/v8/test/mjsunit/getters-on-elements.js | 12 +- .../modules-import-assertions-dynamic-7.mjs | 10 +- .../modules-import-attributes-dynamic-7.mjs | 18 +- .../harmony/regexp-duplicate-named-groups.js | 161 + .../v8/test/mjsunit/harmony/set-difference.js | 17 + .../test/mjsunit/maglev/regress-324459570.js | 27 + .../test/mjsunit/maglev/regress-41497204.js | 23 + deps/v8/test/mjsunit/maglev/regress-cse.js | 85 + deps/v8/test/mjsunit/mjsunit.status | 20 +- deps/v8/test/mjsunit/optimized-typeof.js | 9 + .../test/mjsunit/regress/regress-1523415.js | 30 + .../test/mjsunit/regress/regress-41497374.js | 28 + .../regress/regress-crbug-325135399.js | 20 + .../test/mjsunit/regress/regress-v8-14493.js | 55 + .../wasm/global-initializer-error-offset.js | 4 +- .../mjsunit/regress/wasm/regress-10702.js | 2 +- .../mjsunit/regress/wasm/regress-1074586.js | 2 +- .../mjsunit/regress/wasm/regress-10898.js | 9 +- .../mjsunit/regress/wasm/regress-1145135.js | 2 +- .../mjsunit/regress/wasm/regress-1146861.js | 2 +- .../mjsunit/regress/wasm/regress-1153442.js | 4 +- .../mjsunit/regress/wasm/regress-1161654.js | 2 +- .../mjsunit/regress/wasm/regress-1247659.js | 2 +- .../mjsunit/regress/wasm/regress-12624.js | 2 +- .../mjsunit/regress/wasm/regress-13732.js | 3 +- .../mjsunit/regress/wasm/regress-1374535.js | 2 +- .../mjsunit/regress/wasm/regress-1388942.js | 2 +- .../mjsunit/regress/wasm/regress-14600.js | 34 + .../mjsunit/regress/wasm/regress-1514072-2.js | 68 + .../mjsunit/regress/wasm/regress-1516319.js | 2 +- .../mjsunit/regress/wasm/regress-1518257.js | 48 + .../mjsunit/regress/wasm/regress-1521371.js | 51 + .../mjsunit/regress/wasm/regress-1523313.js | 23 + .../mjsunit/regress/wasm/regress-1523316.js | 68 + .../mjsunit/regress/wasm/regress-1523407.js | 76 + .../mjsunit/regress/wasm/regress-1523414.js | 82 + .../mjsunit/regress/wasm/regress-1523740.js | 7 + .../mjsunit/regress/wasm/regress-324475066.js | 33 + .../mjsunit/regress/wasm/regress-324690505.js | 73 + .../mjsunit/regress/wasm/regress-325372946.js | 46 + .../mjsunit/regress/wasm/regress-325878101.js | 26 + .../mjsunit/regress/wasm/regress-329130358.js | 27 + .../test/mjsunit/regress/wasm/regress-7582.js | 2 +- .../mjsunit/regress/wasm/regress-820802.js | 2 +- .../mjsunit/regress/wasm/regress-910824.js | 4 +- .../regress/wasm/regress-crbug-1407594.js | 2 +- .../regress/wasm/regress-crbug-1486362.js | 12 +- ...hared-external-string-dictionary-lookup.js | 32 + .../turboshaft/turboshaft-maglev-frontend.js | 238 +- .../mjsunit/wasm/array-bulk-operations.js | 3 +- .../test/mjsunit/wasm/array-copy-benchmark.js | 4 +- .../mjsunit/wasm/array-init-from-segment.js | 4 +- deps/v8/test/mjsunit/wasm/bulk-memory.js | 10 +- .../wasm/compiled-module-serialization.js | 2 +- deps/v8/test/mjsunit/wasm/data-segments.js | 8 +- .../wasm/element-segments-with-reftypes.js | 4 +- deps/v8/test/mjsunit/wasm/exnref-global.js | 4 +- deps/v8/test/mjsunit/wasm/exnref.js | 2 +- deps/v8/test/mjsunit/wasm/export-global.js | 2 +- .../mjsunit/wasm/export-mutable-global.js | 10 +- .../test/mjsunit/wasm/extended-constants.js | 4 +- .../v8/test/mjsunit/wasm/externref-globals.js | 71 +- deps/v8/test/mjsunit/wasm/externref-table.js | 3 +- .../mjsunit/wasm/gc-js-interop-objects.js | 1 + deps/v8/test/mjsunit/wasm/gc-optimizations.js | 2 +- deps/v8/test/mjsunit/wasm/globals.js | 28 +- .../mjsunit/wasm/import-mutable-global.js | 8 +- deps/v8/test/mjsunit/wasm/import-table.js | 4 +- .../mjsunit/wasm/imported-strings-invalid.js | 21 +- deps/v8/test/mjsunit/wasm/imported-strings.js | 48 +- deps/v8/test/mjsunit/wasm/indirect-tables.js | 2 +- deps/v8/test/mjsunit/wasm/inlining.js | 191 +- .../mjsunit/wasm/instantiate-module-basic.js | 4 +- .../wasm/interrupt-worker-with-perf.js | 7 + deps/v8/test/mjsunit/wasm/js-api.js | 2 +- deps/v8/test/mjsunit/wasm/js-to-js.js | 8 + .../mjsunit/wasm/js-to-wasm-invalid-sig.js | 10 + deps/v8/test/mjsunit/wasm/module-memory.js | 2 +- deps/v8/test/mjsunit/wasm/multi-memory.js | 11 +- deps/v8/test/mjsunit/wasm/mutable-globals.js | 2 +- .../test/mjsunit/wasm/origin-trial-flags.js | 28 +- .../mjsunit/wasm/reference-globals-import.js | 12 +- .../v8/test/mjsunit/wasm/reference-globals.js | 45 +- .../mjsunit/wasm/shared-everything/basic.js | 163 + deps/v8/test/mjsunit/wasm/simd-globals.js | 2 +- .../test/mjsunit/wasm/simd-lane-memory64.js | 2 +- .../mjsunit/wasm/simd-relaxed-lane-select.js | 58 + .../test/mjsunit/wasm/speculative-inlining.js | 37 +- .../mjsunit/wasm/stack-switching-export.js | 2 +- deps/v8/test/mjsunit/wasm/stack-switching.js | 10 +- .../mjsunit/wasm/stringref-instance-type.js | 51 + deps/v8/test/mjsunit/wasm/stringrefs-exec.js | 10 +- .../test/mjsunit/wasm/stringrefs-invalid.js | 2 +- deps/v8/test/mjsunit/wasm/stringrefs-js.js | 8 +- .../mjsunit/wasm/stringrefs-regressions.js | 2 +- deps/v8/test/mjsunit/wasm/stringrefs-valid.js | 2 +- .../mjsunit/wasm/stringview-valuestack.js | 2 +- .../mjsunit/wasm/test-wasm-module-builder.js | 4 +- deps/v8/test/mjsunit/wasm/turboshaft/basic.js | 17 + .../wasm/type-reflection-with-externref.js | 2 +- deps/v8/test/mjsunit/wasm/type-reflection.js | 4 +- .../test/mjsunit/wasm/wasm-module-builder.js | 71 +- deps/v8/test/mkgrokdump/mkgrokdump.cc | 16 +- .../flatMap/callback-with-side-effects.js | 28 + .../duplicate-named-groups-replace.js | 28 + .../duplicate-named-groups-search.js | 13 + .../named-groups/duplicate-named-groups.js | 16 + deps/v8/test/test262/test262.status | 51 +- deps/v8/test/test262/testcfg.py | 1 + deps/v8/test/test262/tools/export.py | 10 +- deps/v8/test/test262/tools/v8_exporter.py | 23 +- deps/v8/test/unittests/BUILD.gn | 48 + deps/v8/test/unittests/DEPS | 1 + deps/v8/test/unittests/PRESUBMIT.py | 15 + .../unittests/api/access-check-unittest.cc | 6 +- .../test/unittests/api/api-wasm-unittest.cc | 22 +- .../unittests/api/deserialize-unittest.cc | 7 +- .../api/dictionary-template-unittest.cc | 136 + .../backend/instruction-selector-unittest.cc | 14 +- .../backend/instruction-selector-unittest.h | 1 + .../test/unittests/compiler/frame-unittest.cc | 22 +- .../compiler/linkage-tail-call-unittest.cc | 3 +- .../run-bytecode-graph-builder-unittest.cc | 37 +- .../compiler/run-tail-calls-unittest.cc | 1 + .../compiler/simplified-lowering-unittest.cc | 35 +- .../turboshaft/control-flow-unittest.cc | 178 + .../late-load-elimination-reducer-unittest.cc | 352 ++ .../compiler/turboshaft/reducer-test.h | 64 +- .../flags/flag-definitions-unittest.cc | 54 + deps/v8/test/unittests/fuzztest-adapter.h | 14 + .../v8/test/unittests/fuzztest-init-adapter.h | 14 + deps/v8/test/unittests/fuzztest.cc | 57 + deps/v8/test/unittests/fuzztest.h | 65 + .../v8/test/unittests/gen_fuzztest_configs.py | 126 + .../unittests/gen_fuzztest_configs_test.py | 113 + .../embedder-roots-handler-unittest.cc | 14 - .../cppgc-js/traced-reference-unittest.cc | 36 +- .../unified-heap-snapshot-unittest.cc | 2 +- .../heap/cppgc-js/unified-heap-unittest.cc | 86 +- .../cppgc-js/young-unified-heap-unittest.cc | 53 +- .../heap/cppgc/gc-invoker-unittest.cc | 3 + .../heap/cppgc/heap-growing-unittest.cc | 8 + .../unittests/heap/global-handles-unittest.cc | 2 +- deps/v8/test/unittests/heap/heap-unittest.cc | 36 + deps/v8/test/unittests/heap/heap-utils.h | 4 +- .../test/unittests/heap/iterators-unittest.cc | 2 +- .../v8/test/unittests/heap/spaces-unittest.cc | 15 +- .../bytecode-array-builder-unittest.cc | 128 +- .../bytecode-array-iterator-unittest.cc | 4 +- ...bytecode-array-random-iterator-unittest.cc | 28 +- .../bytecode-array-writer-unittest.cc | 28 +- .../bytecode-expectations-printer.cc | 2 +- .../bytecode-expectations-printer.h | 2 +- .../AsyncGenerators.golden | 142 +- .../PrivateAccessorAccess.golden | 8 +- .../PrivateMethodAccess.golden | 4 +- .../StaticPrivateMethodAccess.golden | 30 +- .../interpreter/bytecodes-unittest.cc | 18 +- .../constant-array-builder-unittest.cc | 16 +- .../interpreter-assembler-unittest.cc | 38 - .../interpreter/interpreter-unittest.cc | 201 +- .../v8/test/unittests/logging/log-unittest.cc | 2 +- .../unittests/objects/modules-unittest.cc | 54 +- .../test/unittests/objects/roots-unittest.cc | 8 +- .../test/unittests/parser/decls-unittest.cc | 37 + .../test/unittests/parser/parsing-unittest.cc | 506 +-- .../test/unittests/parser/scanner-unittest.cc | 14 +- .../test/unittests/regexp/regexp-unittest.cc | 12 +- deps/v8/test/unittests/run-all-unittests.cc | 10 + .../unittests/sandbox/sandbox-unittest.cc | 26 +- deps/v8/test/unittests/testcfg.py | 7 + .../test/unittests/torque/torque-unittest.cc | 1 + deps/v8/test/unittests/unittests.status | 6 + .../unittests/utils/bit-vector-unittest.cc | 131 +- .../wasm/function-body-decoder-unittest.cc | 112 +- .../unittests/wasm/module-decoder-unittest.cc | 104 +- .../test/unittests/wasm/subtyping-unittest.cc | 67 +- .../wasm-disassembler-unittest-gc.wasm.inc | 10 +- .../wasm-disassembler-unittest-gc.wat.inc | 20 +- ...sm-disassembler-unittest-stringref.wat.inc | 3 + .../wasm/wasm-disassembler-unittest.cc | 6 +- deps/v8/test/wasm-js/tests.tar.gz.sha1 | 2 +- .../v8/test/wasm-spec-tests/tests.tar.gz.sha1 | 2 +- deps/v8/third_party/abseil-cpp/BUILD.bazel | 12 +- deps/v8/third_party/abseil-cpp/BUILD.gn | 1 + .../abseil-cpp/CMake/AbseilHelpers.cmake | 10 +- deps/v8/third_party/abseil-cpp/DIR_METADATA | 5 +- deps/v8/third_party/abseil-cpp/MODULE.bazel | 3 + .../abseil-cpp/PrivacyInfo.xcprivacy | 14 + .../v8/third_party/abseil-cpp/README.chromium | 2 +- .../third_party/abseil-cpp/WORKSPACE.bzlmod | 19 + .../third_party/abseil-cpp/absl/BUILD.bazel | 11 - .../abseil-cpp/absl/abseil.podspec.gen.py | 3 + .../abseil-cpp/absl/base/BUILD.bazel | 18 +- .../abseil-cpp/absl/base/attributes.h | 59 +- .../third_party/abseil-cpp/absl/base/config.h | 8 +- .../third_party/abseil-cpp/absl/base/macros.h | 36 + .../abseil-cpp/absl/container/BUILD.bazel | 51 +- .../abseil-cpp/absl/container/BUILD.gn | 20 + .../abseil-cpp/absl/container/CMakeLists.txt | 11 + .../abseil-cpp/absl/container/flat_hash_map.h | 27 +- .../absl/container/flat_hash_map_test.cc | 12 + .../abseil-cpp/absl/container/flat_hash_set.h | 26 +- .../absl/container/flat_hash_set_test.cc | 12 + .../container/internal/common_policy_traits.h | 31 +- .../internal/common_policy_traits_test.cc | 65 +- .../internal/compressed_tuple_test.cc | 2 - .../container/internal/container_memory.h | 35 +- .../internal/container_memory_test.cc | 32 + .../internal/hash_function_defaults.h | 69 +- .../internal/hash_function_defaults_test.cc | 147 +- .../container/internal/hash_policy_testing.h | 3 +- .../container/internal/hash_policy_traits.h | 35 + .../internal/hash_policy_traits_test.cc | 64 + .../container/internal/hashtablez_sampler.cc | 3 +- .../absl/container/internal/raw_hash_set.cc | 4 +- .../absl/container/internal/raw_hash_set.h | 312 +- .../internal/raw_hash_set_allocator_test.cc | 8 +- .../internal/raw_hash_set_benchmark.cc | 18 +- .../internal/raw_hash_set_probe_benchmark.cc | 5 + .../container/internal/raw_hash_set_test.cc | 150 +- .../abseil-cpp/absl/container/node_hash_map.h | 23 +- .../abseil-cpp/absl/container/node_hash_set.h | 22 +- .../absl/copts/GENERATED_AbseilCopts.cmake | 2 + .../abseil-cpp/absl/copts/GENERATED_copts.bzl | 2 + .../abseil-cpp/absl/copts/copts.py | 1 + .../abseil-cpp/absl/crc/BUILD.bazel | 4 +- .../third_party/abseil-cpp/absl/crc/BUILD.gn | 2 +- .../abseil-cpp/absl/crc/CMakeLists.txt | 1 + .../absl/crc/internal/crc_cord_state.cc | 7 +- .../absl/debugging/failure_signal_handler.h | 2 +- .../absl/debugging/internal/demangle.cc | 137 +- .../absl/debugging/internal/demangle_test.cc | 151 + .../internal/stacktrace_aarch64-inl.inc | 15 +- .../abseil-cpp/absl/flags/BUILD.bazel | 12 +- .../abseil-cpp/absl/flags/BUILD.gn | 4 +- .../abseil-cpp/absl/flags/CMakeLists.txt | 7 +- .../absl/flags/commandlineflag_test.cc | 9 +- .../third_party/abseil-cpp/absl/flags/flag.h | 2 + .../abseil-cpp/absl/flags/flag_test.cc | 54 +- .../abseil-cpp/absl/flags/internal/flag.h | 6 +- .../absl/flags/internal/usage_test.cc | 6 + .../abseil-cpp/absl/flags/parse_test.cc | 7 + .../abseil-cpp/absl/flags/reflection_test.cc | 11 +- .../abseil-cpp/absl/hash/BUILD.bazel | 6 +- .../abseil-cpp/absl/hash/internal/hash.cc | 2 +- .../absl/hash/internal/low_level_hash.cc | 84 +- .../absl/hash/internal/low_level_hash.h | 4 + .../absl/hash/internal/low_level_hash_test.cc | 180 +- .../absl/hash/internal/spy_hash_state.h | 24 +- .../abseil-cpp/absl/log/internal/BUILD.bazel | 2 +- .../abseil-cpp/absl/log/log_sink.h | 15 +- .../abseil-cpp/absl/meta/type_traits.h | 10 +- .../abseil-cpp/absl/meta/type_traits_test.cc | 9 +- .../abseil-cpp/absl/numeric/BUILD.bazel | 2 +- .../abseil-cpp/absl/numeric/int128.cc | 3 - .../abseil-cpp/absl/numeric/int128.h | 5 - .../absl/numeric/int128_stream_test.cc | 6 +- .../abseil-cpp/absl/numeric/int128_test.cc | 8 - .../abseil-cpp/absl/profiling/BUILD.bazel | 2 +- .../abseil-cpp/absl/random/BUILD.bazel | 8 +- .../abseil-cpp/absl/random/BUILD.gn | 2 + .../abseil-cpp/absl/random/CMakeLists.txt | 2 + .../absl/random/internal/BUILD.bazel | 8 +- .../abseil-cpp/absl/random/seed_sequences.h | 2 + .../abseil-cpp/absl/strings/BUILD.bazel | 11 +- .../abseil-cpp/absl/strings/BUILD.gn | 3 +- .../abseil-cpp/absl/strings/CMakeLists.txt | 2 + .../abseil-cpp/absl/strings/cord.h | 5 +- .../abseil-cpp/absl/strings/cord_test.cc | 32 +- .../abseil-cpp/absl/strings/escaping.cc | 114 +- .../abseil-cpp/absl/strings/escaping.h | 33 +- .../abseil-cpp/absl/strings/escaping_test.cc | 29 + .../absl/strings/internal/cord_internal.h | 31 +- .../absl/strings/internal/cordz_handle.cc | 48 +- .../abseil-cpp/absl/strings/str_cat.h | 5 + .../abseil-cpp/absl/strings/str_split.h | 2 +- .../abseil-cpp/absl/strings/string_view.h | 2 +- .../absl/strings/string_view_test.cc | 4 - .../absl/synchronization/BUILD.bazel | 14 +- .../absl/synchronization/lifetime_test.cc | 5 +- .../abseil-cpp/absl/time/BUILD.bazel | 2 +- .../third_party/abseil-cpp/absl/time/clock.cc | 16 +- .../abseil-cpp/absl/time/duration.cc | 2 +- .../abseil-cpp/absl/types/optional_test.cc | 45 +- .../third_party/abseil-cpp/absl/types/span.h | 2 +- .../abseil-cpp/symbols_arm64_dbg.def | 193 +- .../abseil-cpp/symbols_arm64_rel.def | 33 +- .../abseil-cpp/symbols_x64_dbg.def | 193 +- .../abseil-cpp/symbols_x64_rel.def | 37 +- .../abseil-cpp/symbols_x64_rel_asan.def | 34 +- .../abseil-cpp/symbols_x86_dbg.def | 193 +- .../abseil-cpp/symbols_x86_rel.def | 36 +- .../inspector_protocol/crdtp/dispatch_test.cc | 20 +- .../inspector_protocol/crdtp/json_test.cc | 19 +- deps/v8/third_party/jinja2/DIR_METADATA | 3 + deps/v8/third_party/markupsafe/DIR_METADATA | 5 +- deps/v8/third_party/re2/BUILD.gn | 56 + deps/v8/third_party/re2/DEPS | 7 + deps/v8/third_party/re2/DIR_METADATA | 3 + deps/v8/third_party/re2/LICENSE | 27 + deps/v8/third_party/re2/OWNERS | 2 + deps/v8/third_party/re2/README.v8 | 13 + deps/v8/third_party/zlib/DIR_METADATA | 3 + deps/v8/third_party/zlib/chromeconf.h | 1 - deps/v8/third_party/zlib/zutil.h | 23 +- .../clusterfuzz/foozzie/v8_fuzz_flags.json | 3 +- .../tools/clusterfuzz/js_fuzzer/exceptions.js | 27 + .../clusterfuzz/js_fuzzer/script_mutator.js | 4 +- .../js_fuzzer/test/test_regressions.js | 29 +- .../regress/contradictions/input1.js | 5 + .../regress/contradictions/input2.js | 5 + .../{numbers/db => empty_db}/index.json | 0 .../test_data/regress/strict/db/index.json | 1 - .../trials/clusterfuzz_trials_config.json | 7 +- .../debug_helper/get-object-properties.cc | 2 +- deps/v8/tools/debug_helper/heap-constants.cc | 12 +- deps/v8/tools/dev/gm.py | 10 +- deps/v8/tools/dev/update-compile-commands.py | 30 +- deps/v8/tools/gdbinit | 115 +- deps/v8/tools/gen-keywords-gen-h.py | 10 +- .../tools/generate-header-include-checks.py | 5 + deps/v8/tools/lldb_commands.py | 88 +- deps/v8/tools/run_perf.py | 29 +- deps/v8/tools/testrunner/local/variants.py | 2 + deps/v8/tools/testrunner/testproc/fuzzer.py | 1 + deps/v8/tools/unittests/run_perf_test.py | 59 + deps/v8/tools/wasm/module-inspector.cc | 100 +- 1088 files changed, 35316 insertions(+), 19266 deletions(-) create mode 100644 deps/v8/src/compiler/const-tracking-let-helpers.cc create mode 100644 deps/v8/src/compiler/const-tracking-let-helpers.h rename deps/v8/src/compiler/turboshaft/{dataview-reducer.h => dataview-lowering-reducer.h} (94%) rename deps/v8/src/compiler/turboshaft/{fast-api-call-reducer.h => fast-api-call-lowering-reducer.h} (93%) delete mode 100644 deps/v8/src/compiler/turboshaft/reduce-args-helper.h rename deps/v8/src/compiler/turboshaft/{stack-check-reducer.h => stack-check-lowering-reducer.h} (90%) rename deps/v8/src/compiler/turboshaft/{wasm-gc-type-reducer.cc => wasm-gc-typed-optimization-reducer.cc} (86%) rename deps/v8/src/compiler/turboshaft/{wasm-gc-type-reducer.h => wasm-gc-typed-optimization-reducer.h} (93%) create mode 100644 deps/v8/src/heap/memory-chunk-header.cc create mode 100644 deps/v8/src/heap/memory-chunk-header.h create mode 100644 deps/v8/src/tracing/code-data-source.cc create mode 100644 deps/v8/src/tracing/code-data-source.h create mode 100644 deps/v8/src/tracing/code-trace-context.h create mode 100644 deps/v8/src/tracing/perfetto-logger.cc create mode 100644 deps/v8/src/tracing/perfetto-logger.h create mode 100644 deps/v8/src/tracing/perfetto-utils.cc create mode 100644 deps/v8/src/tracing/perfetto-utils.h create mode 100644 deps/v8/src/wasm/compilation-environment-inl.h create mode 100644 deps/v8/src/wasm/wrappers.cc create mode 100644 deps/v8/test/inspector/regress/regress-crbug-1510427-expected.txt create mode 100644 deps/v8/test/inspector/regress/regress-crbug-1510427.js create mode 100644 deps/v8/test/mjsunit/compiler/conditional-chain.js create mode 100644 deps/v8/test/mjsunit/compiler/regress-324782095.js create mode 100644 deps/v8/test/mjsunit/compiler/regress-crbug-1519399.js create mode 100644 deps/v8/test/mjsunit/compiler/regress-crbug-1520774.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-already-not-constant-global-no-deopt-maglev.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-already-not-constant-no-deopt-maglev.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-basic.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-globalic-slow-path.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-initial-value-maglev.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-initialization-baseline.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-eval.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-baseline1.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-baseline2.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-baseline3.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-interpreter1.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-interpreter2.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-interpreter3.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-maglev1.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-maglev2.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-maglev3.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-turbofan1.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-turbofan2.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-function-turbofan3.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-inner-function-baseline1.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-inner-function-baseline2.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-inner-function-interpreter1.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-inner-function-interpreter2.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-inner-function-maglev1.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-inner-function-maglev2.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-inner-function-turbofan1.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-inner-function-turbofan2.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-maglev-representations.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-repl-baseline.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-repl-interpreter.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-repl-maglev.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-repl-turbofan.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-storeglobal-baseline.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-storeglobal-interpreter.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-storeglobal-maglev.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-storeglobal-turbofan.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-toplevel-baseline.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-toplevel-interpreter.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-toplevel-maglev.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-invalidate-toplevel-turbofan.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-multiple.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-no-deopt-write-if-already-not-const.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-not-const.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-other-script.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-read-is-inner-function.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-read-uninitialized.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-repl-initialize.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-repl-side-data-sync.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-repl.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-uninitialized.js create mode 100644 deps/v8/test/mjsunit/const-tracking-let-wont-prevent-osr-to-turbofan.js create mode 100644 deps/v8/test/mjsunit/harmony/regexp-duplicate-named-groups.js create mode 100644 deps/v8/test/mjsunit/maglev/regress-324459570.js create mode 100644 deps/v8/test/mjsunit/maglev/regress-41497204.js create mode 100644 deps/v8/test/mjsunit/maglev/regress-cse.js create mode 100644 deps/v8/test/mjsunit/regress/regress-1523415.js create mode 100644 deps/v8/test/mjsunit/regress/regress-41497374.js create mode 100644 deps/v8/test/mjsunit/regress/regress-crbug-325135399.js create mode 100644 deps/v8/test/mjsunit/regress/regress-v8-14493.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-14600.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-1514072-2.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-1518257.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-1521371.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-1523313.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-1523316.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-1523407.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-1523414.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-1523740.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-324475066.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-324690505.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-325372946.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-325878101.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-329130358.js create mode 100644 deps/v8/test/mjsunit/wasm/interrupt-worker-with-perf.js create mode 100644 deps/v8/test/mjsunit/wasm/js-to-wasm-invalid-sig.js create mode 100644 deps/v8/test/mjsunit/wasm/shared-everything/basic.js create mode 100644 deps/v8/test/mjsunit/wasm/simd-relaxed-lane-select.js create mode 100644 deps/v8/test/mjsunit/wasm/stringref-instance-type.js create mode 100644 deps/v8/test/test262/local-tests/test/staging/built-ins/Array/prototype/flatMap/callback-with-side-effects.js create mode 100644 deps/v8/test/test262/local-tests/test/staging/built-ins/RegExp/named-groups/duplicate-named-groups-replace.js create mode 100644 deps/v8/test/test262/local-tests/test/staging/built-ins/RegExp/named-groups/duplicate-named-groups-search.js create mode 100644 deps/v8/test/test262/local-tests/test/staging/built-ins/RegExp/named-groups/duplicate-named-groups.js create mode 100644 deps/v8/test/unittests/PRESUBMIT.py create mode 100644 deps/v8/test/unittests/api/dictionary-template-unittest.cc create mode 100644 deps/v8/test/unittests/compiler/turboshaft/control-flow-unittest.cc create mode 100644 deps/v8/test/unittests/compiler/turboshaft/late-load-elimination-reducer-unittest.cc create mode 100644 deps/v8/test/unittests/fuzztest-adapter.h create mode 100644 deps/v8/test/unittests/fuzztest-init-adapter.h create mode 100644 deps/v8/test/unittests/fuzztest.cc create mode 100644 deps/v8/test/unittests/fuzztest.h create mode 100644 deps/v8/test/unittests/gen_fuzztest_configs.py create mode 100644 deps/v8/test/unittests/gen_fuzztest_configs_test.py create mode 100644 deps/v8/third_party/abseil-cpp/PrivacyInfo.xcprivacy create mode 100644 deps/v8/third_party/abseil-cpp/WORKSPACE.bzlmod create mode 100644 deps/v8/third_party/re2/BUILD.gn create mode 100644 deps/v8/third_party/re2/DEPS create mode 100644 deps/v8/third_party/re2/DIR_METADATA create mode 100644 deps/v8/third_party/re2/LICENSE create mode 100644 deps/v8/third_party/re2/OWNERS create mode 100644 deps/v8/third_party/re2/README.v8 create mode 100644 deps/v8/tools/clusterfuzz/js_fuzzer/test_data/regress/contradictions/input1.js create mode 100644 deps/v8/tools/clusterfuzz/js_fuzzer/test_data/regress/contradictions/input2.js rename deps/v8/tools/clusterfuzz/js_fuzzer/test_data/regress/{numbers/db => empty_db}/index.json (100%) delete mode 100644 deps/v8/tools/clusterfuzz/js_fuzzer/test_data/regress/strict/db/index.json diff --git a/deps/v8/.gitignore b/deps/v8/.gitignore index dbe1504e0931d8..31d395a0fef5a4 100644 --- a/deps/v8/.gitignore +++ b/deps/v8/.gitignore @@ -63,13 +63,10 @@ /test/wasm-spec-tests/tests.tar.gz /third_party/* !/third_party/antlr4 -!/third_party/cpu_features -/third_party/cpu_features/src -!/third_party/inspector_protocol -!/third_party/jsoncpp -/third_party/jsoncpp/source !/third_party/colorama /third_party/colorama/src +!/third_party/cpu_features +/third_party/cpu_features/src !/third_party/glibc !/third_party/googletest /third_party/googletest/src/* @@ -80,6 +77,11 @@ !/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/inspector_protocol +!/third_party/jsoncpp +/third_party/jsoncpp/source +!/third_party/re2 +/third_party/re2/src !/third_party/test262-harness !/third_party/v8 !/third_party/wasm-api diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index 2136b85df21be9..9bd9ff447e5d03 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -311,3 +311,4 @@ Zhongping Wang Yang Xiang Kotaro Ohsugi Jing Peiyang +magic-akari diff --git a/deps/v8/BUILD.bazel b/deps/v8/BUILD.bazel index 03ff0d8b3b0aca..2351c1e3300e0b 100644 --- a/deps/v8/BUILD.bazel +++ b/deps/v8/BUILD.bazel @@ -1689,6 +1689,8 @@ filegroup( "src/heap/memory-balancer.h", "src/heap/memory-chunk.cc", "src/heap/memory-chunk.h", + "src/heap/memory-chunk-header.cc", + "src/heap/memory-chunk-header.h", "src/heap/memory-chunk-inl.h", "src/heap/memory-chunk-layout.cc", "src/heap/memory-chunk-layout.h", @@ -2792,6 +2794,7 @@ filegroup( "src/wasm/code-space-access.cc", "src/wasm/code-space-access.h", "src/wasm/compilation-environment.h", + "src/wasm/compilation-environment-inl.h", "src/wasm/constant-expression.cc", "src/wasm/constant-expression.h", "src/wasm/constant-expression-interface.cc", @@ -2883,6 +2886,7 @@ filegroup( "src/wasm/wasm-value.h", "src/wasm/well-known-imports.cc", "src/wasm/well-known-imports.h", + "src/wasm/wrappers.cc", ], "//conditions:default": [], }), @@ -3011,6 +3015,8 @@ filegroup( "src/compiler/compiler-source-position-table.h", "src/compiler/constant-folding-reducer.cc", "src/compiler/constant-folding-reducer.h", + "src/compiler/const-tracking-let-helpers.cc", + "src/compiler/const-tracking-let-helpers.h", "src/compiler/control-equivalence.cc", "src/compiler/control-equivalence.h", "src/compiler/control-flow-optimizer.cc", @@ -3185,7 +3191,7 @@ filegroup( "src/compiler/turboshaft/builtin-call-descriptors.h", "src/compiler/turboshaft/csa-optimize-phase.cc", "src/compiler/turboshaft/csa-optimize-phase.h", - "src/compiler/turboshaft/dataview-reducer.h", + "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/dead-code-elimination-reducer.h", @@ -3199,7 +3205,7 @@ filegroup( "src/compiler/turboshaft/define-assembler-macros.inc", "src/compiler/turboshaft/deopt-data.h", "src/compiler/turboshaft/explicit-truncation-reducer.h", - "src/compiler/turboshaft/fast-api-call-reducer.h", + "src/compiler/turboshaft/fast-api-call-lowering-reducer.h", "src/compiler/turboshaft/fast-hash.h", "src/compiler/turboshaft/graph.cc", "src/compiler/turboshaft/graph.h", @@ -3249,7 +3255,6 @@ filegroup( "src/compiler/turboshaft/recreate-schedule.h", "src/compiler/turboshaft/recreate-schedule-phase.cc", "src/compiler/turboshaft/recreate-schedule-phase.h", - "src/compiler/turboshaft/reduce-args-helper.h", "src/compiler/turboshaft/reducer-traits.h", "src/compiler/turboshaft/representations.cc", "src/compiler/turboshaft/representations.h", @@ -3265,7 +3270,7 @@ filegroup( "src/compiler/turboshaft/simplify-tf-loops.h", "src/compiler/turboshaft/snapshot-table.h", "src/compiler/turboshaft/snapshot-table-opindex.h", - "src/compiler/turboshaft/stack-check-reducer.h", + "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", @@ -3374,8 +3379,8 @@ filegroup( "src/compiler/turboshaft/wasm-assembler-helpers.h", "src/compiler/turboshaft/wasm-gc-optimize-phase.cc", "src/compiler/turboshaft/wasm-gc-optimize-phase.h", - "src/compiler/turboshaft/wasm-gc-type-reducer.cc", - "src/compiler/turboshaft/wasm-gc-type-reducer.h", + "src/compiler/turboshaft/wasm-gc-typed-optimization-reducer.cc", + "src/compiler/turboshaft/wasm-gc-typed-optimization-reducer.h", "src/compiler/turboshaft/wasm-load-elimination-reducer.h", "src/compiler/turboshaft/wasm-lowering-phase.cc", "src/compiler/turboshaft/wasm-lowering-phase.h", diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn index 133701b20ed9ba..a28da024c76279 100644 --- a/deps/v8/BUILD.gn +++ b/deps/v8/BUILD.gn @@ -1149,6 +1149,9 @@ config("features") { if (v8_fuzzilli) { defines += [ "V8_FUZZILLI" ] } + if (v8_enable_fuzztest) { + defines += [ "V8_ENABLE_FUZZTEST" ] + } if (v8_enable_short_builtin_calls) { defines += [ "V8_SHORT_BUILTIN_CALLS" ] } @@ -1482,7 +1485,6 @@ config("toolchain") { if (is_clang) { cflags += [ - "-Wmissing-field-initializers", "-Wunreachable-code", # TODO(v8:12245): Fix shadowing instances and remove. @@ -1496,11 +1498,6 @@ config("toolchain") { # warning. cflags += [ "-Wctad-maybe-unsupported" ] } - - if (v8_current_cpu == "x64" || v8_current_cpu == "arm64" || - v8_current_cpu == "mips64el" || v8_current_cpu == "riscv64") { - cflags += [ "-Wshorten-64-to-32" ] - } } if (is_clang || !is_win) { @@ -1700,20 +1697,6 @@ config("toolchain") { # Fix build with older versions of GCC # Ported from v8 bazel: https://crrev.com/c/3368869 "-Wno-stringop-overflow", - - # Fix a number of bogus errors with gcc12 - # TODO(miladfarca): re-evaluate for future gcc upgrades - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111499 - "-Wno-stringop-overread", - - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104336 - "-Wno-restrict", - - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 - "-Wno-array-bounds", - - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108517 - "-Wno-nonnull", ] } @@ -1723,6 +1706,17 @@ config("toolchain") { } } +config("strict_warnings") { + cflags = [] + if (is_clang) { + if (v8_current_cpu == "x64" || v8_current_cpu == "arm64" || + v8_current_cpu == "mips64el" || v8_current_cpu == "riscv64") { + cflags += [ "-Wshorten-64-to-32" ] + } + cflags += [ "-Wmissing-field-initializers" ] + } +} + # For code that is hot during mksnapshot. In fast-mksnapshot builds, we # optimize some files even in debug builds to speed up mksnapshot times. config("always_turbofanimize") { @@ -3304,6 +3298,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/common-operator.h", "src/compiler/compilation-dependencies.h", "src/compiler/compiler-source-position-table.h", + "src/compiler/const-tracking-let-helpers.h", "src/compiler/constant-folding-reducer.h", "src/compiler/control-equivalence.h", "src/compiler/control-flow-optimizer.h", @@ -3401,7 +3396,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/code-elimination-and-simplification-phase.h", "src/compiler/turboshaft/copying-phase.h", "src/compiler/turboshaft/csa-optimize-phase.h", - "src/compiler/turboshaft/dataview-reducer.h", + "src/compiler/turboshaft/dataview-lowering-reducer.h", "src/compiler/turboshaft/dead-code-elimination-reducer.h", "src/compiler/turboshaft/debug-feature-lowering-phase.h", "src/compiler/turboshaft/debug-feature-lowering-reducer.h", @@ -3411,7 +3406,7 @@ v8_header_set("v8_internal_headers") { "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-reducer.h", + "src/compiler/turboshaft/fast-api-call-lowering-reducer.h", "src/compiler/turboshaft/fast-hash.h", "src/compiler/turboshaft/graph-builder.h", "src/compiler/turboshaft/graph-visualizer.h", @@ -3440,7 +3435,6 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/pretenuring-propagation-reducer.h", "src/compiler/turboshaft/recreate-schedule-phase.h", "src/compiler/turboshaft/recreate-schedule.h", - "src/compiler/turboshaft/reduce-args-helper.h", "src/compiler/turboshaft/reducer-traits.h", "src/compiler/turboshaft/representations.h", "src/compiler/turboshaft/required-optimization-reducer.h", @@ -3452,7 +3446,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/simplify-tf-loops.h", "src/compiler/turboshaft/snapshot-table-opindex.h", "src/compiler/turboshaft/snapshot-table.h", - "src/compiler/turboshaft/stack-check-reducer.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/structural-optimization-reducer.h", @@ -3640,6 +3634,7 @@ v8_header_set("v8_internal_headers") { "src/heap/marking.h", "src/heap/memory-allocator.h", "src/heap/memory-balancer.h", + "src/heap/memory-chunk-header.h", "src/heap/memory-chunk-inl.h", "src/heap/memory-chunk-layout.h", "src/heap/memory-chunk.h", @@ -4136,6 +4131,12 @@ v8_header_set("v8_internal_headers") { if (v8_use_perfetto) { sources -= [ "//base/trace_event/common/trace_event_common.h" ] + sources += [ + "src/tracing/code-data-source.h", + "src/tracing/code-trace-context.h", + "src/tracing/perfetto-logger.h", + "src/tracing/perfetto-utils.h", + ] } if (v8_enable_sparkplug) { @@ -4195,7 +4196,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/int64-lowering-reducer.h", "src/compiler/turboshaft/wasm-assembler-helpers.h", "src/compiler/turboshaft/wasm-gc-optimize-phase.h", - "src/compiler/turboshaft/wasm-gc-type-reducer.h", + "src/compiler/turboshaft/wasm-gc-typed-optimization-reducer.h", "src/compiler/turboshaft/wasm-js-lowering-reducer.h", "src/compiler/turboshaft/wasm-load-elimination-reducer.h", "src/compiler/turboshaft/wasm-lowering-phase.h", @@ -4230,6 +4231,7 @@ v8_header_set("v8_internal_headers") { "src/wasm/baseline/parallel-move.h", "src/wasm/canonical-types.h", "src/wasm/code-space-access.h", + "src/wasm/compilation-environment-inl.h", "src/wasm/compilation-environment.h", "src/wasm/constant-expression-interface.h", "src/wasm/constant-expression.h", @@ -4759,6 +4761,7 @@ v8_compiler_sources = [ "src/compiler/common-operator.cc", "src/compiler/compilation-dependencies.cc", "src/compiler/compiler-source-position-table.cc", + "src/compiler/const-tracking-let-helpers.cc", "src/compiler/constant-folding-reducer.cc", "src/compiler/control-equivalence.cc", "src/compiler/control-flow-optimizer.cc", @@ -4935,7 +4938,7 @@ if (v8_enable_webassembly) { "src/compiler/int64-lowering.cc", "src/compiler/turboshaft/int64-lowering-phase.cc", "src/compiler/turboshaft/wasm-gc-optimize-phase.cc", - "src/compiler/turboshaft/wasm-gc-type-reducer.cc", + "src/compiler/turboshaft/wasm-gc-typed-optimization-reducer.cc", "src/compiler/turboshaft/wasm-lowering-phase.cc", "src/compiler/turboshaft/wasm-optimize-phase.cc", "src/compiler/turboshaft/wasm-turboshaft-compiler.cc", @@ -5330,6 +5333,7 @@ v8_source_set("v8_base_without_compiler") { "src/heap/marking.cc", "src/heap/memory-allocator.cc", "src/heap/memory-balancer.cc", + "src/heap/memory-chunk-header.cc", "src/heap/memory-chunk-layout.cc", "src/heap/memory-chunk.cc", "src/heap/memory-measurement.cc", @@ -5651,6 +5655,14 @@ v8_source_set("v8_base_without_compiler") { } } + if (v8_use_perfetto) { + sources += [ + "src/tracing/code-data-source.cc", + "src/tracing/perfetto-logger.cc", + "src/tracing/perfetto-utils.cc", + ] + } + if (v8_enable_webassembly) { sources += [ ### gcmole(all) ### @@ -5706,6 +5718,7 @@ v8_source_set("v8_base_without_compiler") { "src/wasm/wasm-serialization.cc", "src/wasm/wasm-subtyping.cc", "src/wasm/well-known-imports.cc", + "src/wasm/wrappers.cc", ] } @@ -8131,7 +8144,6 @@ if (!build_with_chromium && v8_use_perfetto) { "//third_party/perfetto/src/tracing/core", # TODO(skyostil): Support non-POSIX platforms. - "//third_party/perfetto/protos/perfetto/config:cpp", "//third_party/perfetto/protos/perfetto/trace/track_event:zero", "//third_party/perfetto/src/tracing:in_process_backend", "//third_party/perfetto/src/tracing:platform_impl", @@ -8139,6 +8151,8 @@ if (!build_with_chromium && v8_use_perfetto) { public_deps = [ "//third_party/perfetto/include/perfetto/trace_processor", + "//third_party/perfetto/protos/perfetto/config:cpp", + "//third_party/perfetto/protos/perfetto/trace/chrome:zero", "//third_party/perfetto/src/trace_processor:export_json", "//third_party/perfetto/src/tracing:client_api", ] diff --git a/deps/v8/DEPS b/deps/v8/DEPS index badda7719a4500..6c3ca4e741a6e0 100644 --- a/deps/v8/DEPS +++ b/deps/v8/DEPS @@ -27,6 +27,7 @@ vars = { 'checkout_fuchsia_boot_images': "terminal.x64", 'checkout_fuchsia_product_bundles': '"{checkout_fuchsia_boot_images}" != ""', + 'checkout_centipede_deps': False, 'checkout_instrumented_libraries': False, 'checkout_ittapi': False, @@ -41,8 +42,9 @@ vars = { # Fetch and build V8 builtins with PGO profiles 'checkout_v8_builtins_pgo_profiles': False, - 'chromium_url': 'https://chromium.googlesource.com', 'android_url': 'https://android.googlesource.com', + 'boringssl_url': 'https://boringssl.googlesource.com', + 'chromium_url': 'https://chromium.googlesource.com', 'download_gcmole': False, 'download_jsfunfuzz': False, 'download_prebuilt_bazel': False, @@ -55,7 +57,7 @@ vars = { 'checkout_fuchsia_no_hooks': False, # reclient CIPD package version - 'reclient_version': 're_client_version:0.126.0.4aaef37-gomaip', + 'reclient_version': 're_client_version:0.131.1.784ddbb-gomaip', # Fetch configuration files required for the 'use_remoteexec' gn arg 'download_remoteexec_cfg': False, @@ -71,19 +73,19 @@ vars = { 'build_with_chromium': False, # GN CIPD package version. - 'gn_version': 'git_revision:b5adfe5f574d7110b80feb9aae6fae97c366840b', + 'gn_version': 'git_revision:0a2b8eac80f164f10b2cbc126890db0d295790cd', # ninja CIPD package version # https://chrome-infra-packages.appspot.com/p/infra/3pp/tools/ninja 'ninja_version': 'version:2@1.11.1.chromium.6', # luci-go CIPD package version. - 'luci_go': 'git_revision:0d11be367258bfe14a13ff1afcf43a0bc6aedb45', + 'luci_go': 'git_revision:3df60a11d33a59614c0e8d2bccc58d8c30984901', # 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:17.20240120.1.1', + 'fuchsia_version': 'version:18.20240215.1.1', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling android_sdk_build-tools_version @@ -123,9 +125,9 @@ deps = { 'base/trace_event/common': Var('chromium_url') + '/chromium/src/base/trace_event/common.git' + '@' + '29ac73db520575590c3aceb0a6f1f58dda8934f6', 'build': - Var('chromium_url') + '/chromium/src/build.git' + '@' + '28cd6ea727d171ec990e6174308451d4178d7f8e', + Var('chromium_url') + '/chromium/src/build.git' + '@' + 'e5cf1b3ceb3fec6aa5c57b34dede99d36cede32d', 'buildtools': - Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + '17ce6d2f0416038de7989bc71d055c07d333ccb5', + Var('chromium_url') + '/chromium/src/buildtools.git' + '@' + '342659133d7d0b33f4e24b640a9ad78c0c423633', 'buildtools/linux64': { 'packages': [ { @@ -171,7 +173,7 @@ deps = { 'test/mozilla/data': Var('chromium_url') + '/v8/deps/third_party/mozilla-tests.git' + '@' + 'f6c578a10ea707b1a8ab0b88943fe5115ce2b9be', 'test/test262/data': - Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + 'a1ba783ca340e4bf3d80b5f5e11fa54f2ee5f1ef', + Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + 'e4f91b6381d7694265031caad0c71d733ac132f3', 'third_party/android_platform': { 'url': Var('chromium_url') + '/chromium/src/third_party/android_platform.git' + '@' + 'eeb2d566f963bb66212fdc0d9bbe1dde550b4969', 'condition': 'checkout_android', @@ -224,8 +226,16 @@ deps = { 'condition': 'checkout_android', 'dep_type': 'cipd', }, + 'third_party/boringssl': { + 'url': Var('chromium_url') + '/chromium/src/third_party/boringssl.git' + '@' + '9ead20bdbf0ecc33219d25fd3a426876c54d126e', + 'condition': "checkout_centipede_deps", + }, + 'third_party/boringssl/src': { + 'url': Var('boringssl_url') + '/boringssl.git' + '@' + '414f69504d30d0848b69f6453ea7fb5e88004cb4', + 'condition': "checkout_centipede_deps", + }, 'third_party/catapult': { - 'url': Var('chromium_url') + '/catapult.git' + '@' + '3e413d7b62c09fda8713146714ba2146a0369d86', + 'url': Var('chromium_url') + '/catapult.git' + '@' + '3d6c15240b480da1e498a64a72ea77a61ba335e1', 'condition': 'checkout_android', }, 'third_party/clang-format/script': @@ -239,11 +249,11 @@ deps = { 'condition': 'checkout_android', }, 'third_party/depot_tools': - Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + '46cb7d0aca592cd20ddc2f6cb16ee386b2abbf0d', + Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + '9d7c8e76f82ddc6a3bbc307217e31dec44a0f73a', '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' + '@' + '6ad82eadcb1a4404964a8d86c544fda1dab7af94', + 'url': Var('chromium_url') + '/chromium/src/third_party/fuchsia-gn-sdk.git' + '@' + 'fa3c41d7a15127a989111fcede8dae9265f8566b', 'condition': 'checkout_fuchsia', }, # Exists for rolling the Fuchsia SDK. Check out of the SDK should always @@ -259,17 +269,21 @@ deps = { 'dep_type': 'cipd', }, 'third_party/google_benchmark_chrome': { - 'url': Var('chromium_url') + '/chromium/src/third_party/google_benchmark.git' + '@' + '992199c3cb1076d307816e963ed4b5102df53c65', + 'url': Var('chromium_url') + '/chromium/src/third_party/google_benchmark.git' + '@' + 'c300add93460c31efe53fa71e61427fa1bc09e6a', }, 'third_party/google_benchmark_chrome/src': { 'url': Var('chromium_url') + '/external/github.com/google/benchmark.git' + '@' + 'b177433f3ee2513b1075140c723d73ab8901790f', }, + 'third_party/fuzztest': + Var('chromium_url') + '/chromium/src/third_party/fuzztest.git' + '@' + '9fc64e5930915bfb5a593b7e12487d78283e8221', + 'third_party/fuzztest/src': + Var('chromium_url') + '/external/github.com/google/fuzztest.git' + '@' + '61d95200e7ece7d121cab26f0c39fbf392e6566e', 'third_party/googletest/src': Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + 'af29db7ec28d6df1c7f0f745186884091e602e07', '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' + '@' + '0011c28c8d35fc5093bb29631d05428932cd1206', + Var('chromium_url') + '/chromium/src/third_party/instrumented_libraries.git' + '@' + '0893d760101b3ddf9a2408b9d20f15ec2b80b2c1', 'third_party/ittapi': { # Force checkout ittapi libraries to pass v8 header includes check on # bots that has check_v8_header_includes enabled. @@ -277,19 +291,19 @@ deps = { 'condition': "checkout_ittapi or check_v8_header_includes", }, 'third_party/jinja2': - Var('chromium_url') + '/chromium/src/third_party/jinja2.git' + '@' + 'e2d024354e11cc6b041b0cff032d73f0c7e43a07', + Var('chromium_url') + '/chromium/src/third_party/jinja2.git' + '@' + 'c9c77525ea20c871a1d4658f8d312b51266d4bad', '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' + '@' + '28aa23ffb4c7344914a5b4ac7169f12e5a12333f', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxx.git' + '@' + '6d83791af99ea95f04986d64f111b84ce0b3c6f5', 'third_party/libc++abi/src': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + 'ea028d4d2b8a901f6302f5371c68a24480766e2b', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + 'a7b3d968a3a923886fea64b424bd770e69dc4ea4', 'third_party/libunwind/src': - Var('chromium_url') + '/external/github.com/llvm/llvm-project/libunwind.git' + '@' + 'f400fdb561d4416b59b8f8a33d8ec8b79da60495', + Var('chromium_url') + '/external/github.com/llvm/llvm-project/libunwind.git' + '@' + '8bad7bd6ec30f94bce82f7cb5b58ecbd6ce02996', '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' + '@' + '0bad08bb207bbfc1d6f3bbc82b9242b0c50e5794', + Var('chromium_url') + '/chromium/src/third_party/markupsafe.git' + '@' + 'e582d7f0edb9d67499b0f5abd6ae5550e91da7f2', 'third_party/ninja': { 'packages': [ { @@ -304,14 +318,16 @@ deps = { Var('android_url') + '/platform/external/perfetto.git' + '@' + '6fc824d618d2f06b5d9cd8655ba0419b6b3b366e', 'third_party/protobuf': Var('chromium_url') + '/external/github.com/google/protobuf'+ '@' + '6a59a2ad1f61d9696092f79b6d74368b4d7970a3', + 'third_party/re2/src': + Var('chromium_url') + '/external/github.com/google/re2.git' + '@' + 'd00d1e93781e6ebe415771a952689dff8f260d44', 'third_party/requests': { 'url': Var('chromium_url') + '/external/github.com/kennethreitz/requests.git' + '@' + 'c7e0fc087ceeadb8b4c84a0953a422c474093d6d', 'condition': 'checkout_android', }, 'third_party/zlib': - Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + '63c0cec0344e6ba70f22bd690187088299baaa94', + Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + '4b5807f344182fd392849b820642457212618e5f', 'tools/clang': - Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + 'f0b1beffd512e855db0f46571958cfc83c8b05a9', + Var('chromium_url') + '/chromium/src/tools/clang.git' + '@' + 'a4df104173dae7d49205ed8abefc920b7c5162d2', 'tools/luci-go': { 'packages': [ { @@ -327,7 +343,7 @@ deps = { 'dep_type': 'cipd', }, 'third_party/abseil-cpp': { - 'url': Var('chromium_url') + '/chromium/src/third_party/abseil-cpp.git' + '@' + '5ff8c1facf6b2e54811969ae7b90152bc1f44269', + 'url': Var('chromium_url') + '/chromium/src/third_party/abseil-cpp.git' + '@' + 'f1c5751a2cb4102efbffc4110ee7551b3c54cfea', 'condition': 'not build_with_chromium', } } @@ -338,6 +354,7 @@ include_rules = [ '+unicode', '+third_party/fdlibm', '+third_party/ittapi/include', + '+third_party/fuzztest', # Abseil features are allow-listed. Please use your best judgement when adding # to this set -- if in doubt, email v8-dev@. For general guidance, refer to # the Chromium guidelines (though note that some requirements in V8 may be diff --git a/deps/v8/PRESUBMIT.py b/deps/v8/PRESUBMIT.py index 244f4ab168ad8e..42cebdd65328f3 100644 --- a/deps/v8/PRESUBMIT.py +++ b/deps/v8/PRESUBMIT.py @@ -443,10 +443,7 @@ def _CheckCommitMessageBugEntry(input_api, output_api): continue if ':' not in bug and not bug.startswith('b/'): try: - if int(bug) > 10000000: - results.append( - 'Buganizer entry requires issue tracker prefix b/{}'.format(bug)) - else: + if int(bug) < 10000000: if int(bug) > 200000: prefix_guess = 'chromium' else: diff --git a/deps/v8/build_overrides/build.gni b/deps/v8/build_overrides/build.gni index 64abd3e92a5dd8..9830dfc51d0213 100644 --- a/deps/v8/build_overrides/build.gni +++ b/deps/v8/build_overrides/build.gni @@ -6,6 +6,13 @@ # Chromium specific targets in a client project's GN file etc. build_with_chromium = false +# Variable that can be used to support multiple build scenarios, like when +# V8 is embedded within a target. +build_with_v8_embedder = false + +# Not all of V8's dependencies are available in V8's Node.js build. +build_with_node = false + # Used by perfetto to distinguish from its own standalone build and the # chromium build. perfetto_build_with_embedder = true diff --git a/deps/v8/gni/v8.gni b/deps/v8/gni/v8.gni index 72381c75cae640..185de67a52237b 100644 --- a/deps/v8/gni/v8.gni +++ b/deps/v8/gni/v8.gni @@ -8,6 +8,7 @@ import("//build/config/gclient_args.gni") import("//build/config/ios/config.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/config/v8_target_cpu.gni") +import("//build_overrides/build.gni") import("release_branch_toggle.gni") import("split_static_library.gni") @@ -96,6 +97,11 @@ declare_args() { # Add fuzzilli fuzzer support. v8_fuzzilli = false + # Enable FuzzTest + v8_enable_fuzztest = !build_with_v8_embedder && + !(defined(build_with_node) && build_with_node) && + !(is_win && is_component_build) && is_clang + # Scan the call stack conservatively during garbage collection. v8_enable_conservative_stack_scanning = false @@ -228,6 +234,7 @@ v8_remove_configs = [] v8_add_configs = [ v8_path_prefix + ":features", v8_path_prefix + ":toolchain", + v8_path_prefix + ":strict_warnings", ] if (is_debug && !v8_optimized_debug) { diff --git a/deps/v8/include/cppgc/internal/api-constants.h b/deps/v8/include/cppgc/internal/api-constants.h index 4e2a637e420560..fed7005b46089b 100644 --- a/deps/v8/include/cppgc/internal/api-constants.h +++ b/deps/v8/include/cppgc/internal/api-constants.h @@ -32,7 +32,7 @@ static constexpr uint16_t kFullyConstructedBitMask = uint16_t{1}; static constexpr size_t kPageSize = size_t{1} << 17; -#if defined(V8_TARGET_ARCH_ARM64) && defined(V8_OS_DARWIN) +#if defined(V8_HOST_ARCH_ARM64) && defined(V8_OS_DARWIN) constexpr size_t kGuardPageSize = 0; #else constexpr size_t kGuardPageSize = 4096; diff --git a/deps/v8/include/v8-array-buffer.h b/deps/v8/include/v8-array-buffer.h index 804fc42c4b56dd..ea6f5b5571a476 100644 --- a/deps/v8/include/v8-array-buffer.h +++ b/deps/v8/include/v8-array-buffer.h @@ -318,6 +318,12 @@ class V8_EXPORT ArrayBuffer : public Object { */ std::shared_ptr GetBackingStore(); + /** + * More efficient shortcut for + * GetBackingStore()->IsResizableByUserJavaScript(). + */ + bool IsResizableByUserJavaScript() const; + /** * More efficient shortcut for GetBackingStore()->Data(). The returned pointer * is valid as long as the ArrayBuffer is alive. diff --git a/deps/v8/include/v8-callbacks.h b/deps/v8/include/v8-callbacks.h index 2a25b9ee04e003..4f5e716f8147a2 100644 --- a/deps/v8/include/v8-callbacks.h +++ b/deps/v8/include/v8-callbacks.h @@ -327,10 +327,6 @@ using WasmAsyncResolvePromiseCallback = void (*)( using WasmLoadSourceMapCallback = Local (*)(Isolate* isolate, const char* name); -// --- Callback for checking if WebAssembly GC is enabled --- -// If the callback returns true, it will also enable Wasm stringrefs. -using WasmGCEnabledCallback = bool (*)(Local context); - // --- Callback for checking if WebAssembly imported strings are enabled --- using WasmImportedStringsEnabledCallback = bool (*)(Local context); @@ -342,6 +338,9 @@ using SharedArrayBufferConstructorEnabledCallback = using JavaScriptCompileHintsMagicEnabledCallback = bool (*)(Local context); +// --- Callback for checking if WebAssembly JSPI is enabled --- +using WasmJSPIEnabledCallback = bool (*)(Local context); + /** * HostImportModuleDynamicallyCallback is called when we * require the embedder to load a module. This is used as part of the dynamic @@ -352,11 +351,11 @@ using JavaScriptCompileHintsMagicEnabledCallback = * * The specifier is the name of the module that should be imported. * - * The import_assertions are import assertions for this request in the form: + * The import_attributes are import attributes for this request in the form: * [key1, value1, key2, value2, ...] where the keys and values are of type * v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and * returned from ModuleRequest::GetImportAssertions(), this array does not - * contain the source Locations of the assertions. + * contain the source Locations of the attributes. * * The embedder must compile, instantiate, evaluate the Module, and * obtain its namespace object. @@ -368,15 +367,10 @@ using JavaScriptCompileHintsMagicEnabledCallback = * fails (e.g. due to stack overflow), the embedder must propagate * that exception by returning an empty MaybeLocal. */ -using HostImportModuleDynamicallyWithImportAssertionsCallback = - MaybeLocal (*)(Local context, - Local referrer, - Local specifier, - Local import_assertions); using HostImportModuleDynamicallyCallback = MaybeLocal (*)( Local context, Local host_defined_options, Local resource_name, Local specifier, - Local import_assertions); + Local import_attributes); /** * Callback for requesting a compile hint for a function from the embedder. The diff --git a/deps/v8/include/v8-context.h b/deps/v8/include/v8-context.h index 5552c7a809cbf1..c81dc80c526ca2 100644 --- a/deps/v8/include/v8-context.h +++ b/deps/v8/include/v8-context.h @@ -459,12 +459,12 @@ void* Context::GetAlignedPointerFromEmbedderData(int index) { template MaybeLocal Context::GetDataFromSnapshotOnce(size_t index) { - auto slot = GetDataFromSnapshotOnce(index); - if (slot) { + if (auto slot = GetDataFromSnapshotOnce(index); slot) { internal::PerformCastCheck( internal::ValueHelper::SlotAsValue(slot)); + return Local::FromSlot(slot); } - return Local::FromSlot(slot); + return {}; } Context* Context::Cast(v8::Data* data) { diff --git a/deps/v8/include/v8-forward.h b/deps/v8/include/v8-forward.h index db3a2017b7e5ee..435fe856d97f56 100644 --- a/deps/v8/include/v8-forward.h +++ b/deps/v8/include/v8-forward.h @@ -27,6 +27,7 @@ class Context; class DataView; class Data; class Date; +class DictionaryTemplate; class Extension; class External; class FixedArray; diff --git a/deps/v8/include/v8-function-callback.h b/deps/v8/include/v8-function-callback.h index a21d59d1299a28..22b5328d101f89 100644 --- a/deps/v8/include/v8-function-callback.h +++ b/deps/v8/include/v8-function-callback.h @@ -475,7 +475,8 @@ Local ReturnValue::Get() const { #endif // V8_STATIC_ROOTS_BOOL return Undefined(GetIsolate()); } - return Local::New(GetIsolate(), reinterpret_cast(value_)); + return Local::New(GetIsolate(), + internal::ValueHelper::SlotAsValue(value_)); } template diff --git a/deps/v8/include/v8-internal.h b/deps/v8/include/v8-internal.h index a10735dac9006a..48001c68b0b433 100644 --- a/deps/v8/include/v8-internal.h +++ b/deps/v8/include/v8-internal.h @@ -616,8 +616,6 @@ constexpr bool kAllCodeObjectsLiveInTrustedSpace = kRuntimeGeneratedCodeObjectsLiveInTrustedSpace && kBuiltinCodeObjectsLiveInTrustedSpace; -constexpr bool kInterpreterDataObjectsLiveInTrustedSpace = false; - // {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); @@ -781,8 +779,6 @@ class Internals { static const int kNodeStateMask = 0x3; static const int kNodeStateIsWeakValue = 2; - static const int kTracedNodeClassIdOffset = kApiSystemPointerSize; - static const int kFirstNonstringType = 0x80; static const int kOddballType = 0x83; static const int kForeignType = 0xcc; diff --git a/deps/v8/include/v8-isolate.h b/deps/v8/include/v8-isolate.h index add965abeb7350..a3ceec01334ea0 100644 --- a/deps/v8/include/v8-isolate.h +++ b/deps/v8/include/v8-isolate.h @@ -1579,19 +1579,14 @@ class V8_EXPORT Isolate { void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback); - /** - * Register callback to control whether Wasm GC is enabled. - * The callback overwrites the value of the flag. - * If the callback returns true, it will also enable Wasm stringrefs. - */ - void SetWasmGCEnabledCallback(WasmGCEnabledCallback callback); - void SetWasmImportedStringsEnabledCallback( WasmImportedStringsEnabledCallback callback); void SetSharedArrayBufferConstructorEnabledCallback( SharedArrayBufferConstructorEnabledCallback callback); + void SetWasmJSPIEnabledCallback(WasmJSPIEnabledCallback callback); + /** * Register callback to control whether compile hints magic comments are * enabled. @@ -1751,12 +1746,12 @@ uint32_t Isolate::GetNumberOfDataSlots() { template MaybeLocal Isolate::GetDataFromSnapshotOnce(size_t index) { - auto slot = GetDataFromSnapshotOnce(index); - if (slot) { + if (auto slot = GetDataFromSnapshotOnce(index); slot) { internal::PerformCastCheck( internal::ValueHelper::SlotAsValue(slot)); + return Local::FromSlot(slot); } - return Local::FromSlot(slot); + return {}; } } // namespace v8 diff --git a/deps/v8/include/v8-local-handle.h b/deps/v8/include/v8-local-handle.h index 37efafdd647035..46f7308431af0d 100644 --- a/deps/v8/include/v8-local-handle.h +++ b/deps/v8/include/v8-local-handle.h @@ -62,6 +62,7 @@ class ReturnValue; class String; template class Traced; +class TypecheckWitness; class Utils; namespace debug { @@ -405,6 +406,8 @@ class V8_TRIVIAL_ABI Local : public LocalBase, } #ifdef V8_ENABLE_DIRECT_LOCAL + friend class TypecheckWitness; + V8_INLINE static Local FromAddress(internal::Address ptr) { return Local(LocalBase(ptr)); } diff --git a/deps/v8/include/v8-persistent-handle.h b/deps/v8/include/v8-persistent-handle.h index 9db5af5dddd557..49518fe3631945 100644 --- a/deps/v8/include/v8-persistent-handle.h +++ b/deps/v8/include/v8-persistent-handle.h @@ -241,7 +241,7 @@ class NonCopyablePersistentTraits { * This will clone the contents of storage cell, but not any of the flags, etc. */ template -struct CopyablePersistentTraits { +struct V8_DEPRECATED("Use v8::Global instead") CopyablePersistentTraits { using CopyablePersistent = Persistent>; static const bool kResetInDestructor = true; template diff --git a/deps/v8/include/v8-script.h b/deps/v8/include/v8-script.h index a2d0bcaad343a6..db22de9b18797b 100644 --- a/deps/v8/include/v8-script.h +++ b/deps/v8/include/v8-script.h @@ -136,19 +136,24 @@ class V8_EXPORT ModuleRequest : public Data { int GetSourceOffset() const; /** - * Contains the import assertions for this request in the form: + * Contains the import attributes for this request in the form: * [key1, value1, source_offset1, key2, value2, source_offset2, ...]. * The keys and values are of type v8::String, and the source offsets are of * type Int32. Use Module::SourceOffsetToLocation to convert the source * offsets to Locations with line/column numbers. * - * All assertions present in the module request will be supplied in this + * All attributes present in the module request will be supplied in this * list, regardless of whether they are supported by the host. Per * https://tc39.es/proposal-import-attributes/#sec-hostgetsupportedimportattributes, - * hosts are expected to throw for assertions that they do not support (as + * hosts are expected to throw for attributes that they do not support (as * opposed to, for example, ignoring them). */ - Local GetImportAssertions() const; + Local GetImportAttributes() const; + + V8_DEPRECATE_SOON("Use GetImportAttributes instead") + Local GetImportAssertions() const { + return GetImportAttributes(); + } V8_INLINE static ModuleRequest* Cast(Data* data); diff --git a/deps/v8/include/v8-snapshot.h b/deps/v8/include/v8-snapshot.h index 70d2ca5ecf5e88..a1dc0c3881c22d 100644 --- a/deps/v8/include/v8-snapshot.h +++ b/deps/v8/include/v8-snapshot.h @@ -14,6 +14,10 @@ namespace v8 { class Object; +namespace internal { +class SnapshotCreatorImpl; +} // namespace internal + class V8_EXPORT StartupData { public: /** @@ -206,7 +210,8 @@ class V8_EXPORT SnapshotCreator { size_t AddData(Local context, internal::Address object); size_t AddData(internal::Address object); - void* data_; + internal::SnapshotCreatorImpl* impl_; + friend class internal::SnapshotCreatorImpl; }; template diff --git a/deps/v8/include/v8-template.h b/deps/v8/include/v8-template.h index c18baf95c2e472..674d4201d5d782 100644 --- a/deps/v8/include/v8-template.h +++ b/deps/v8/include/v8-template.h @@ -5,6 +5,9 @@ #ifndef INCLUDE_V8_TEMPLATE_H_ #define INCLUDE_V8_TEMPLATE_H_ +#include +#include + #include "v8-data.h" // NOLINT(build/include_directory) #include "v8-function-callback.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) @@ -778,7 +781,11 @@ class V8_EXPORT ObjectTemplate : public Template { Isolate* isolate, Local constructor = Local()); - /** Creates a new instance of this template.*/ + /** + * Creates a new instance of this template. + * + * \param context The context in which the instance is created. + */ V8_WARN_UNUSED_RESULT MaybeLocal NewInstance(Local context); /** @@ -950,6 +957,41 @@ class V8_EXPORT ObjectTemplate : public Template { friend class FunctionTemplate; }; +/** + * A template to create dictionary objects at runtime. + */ +class V8_EXPORT DictionaryTemplate final { + public: + /** Creates a new template. Also declares data properties that can be passed + * on instantiation of the template. Properties can only be declared on + * construction and are then immutable. The values are passed on creating the + * object via `NewInstance()`. + * + * \param names the keys that can be passed on instantiation. + */ + static Local New( + Isolate* isolate, MemorySpan names); + + /** + * Creates a new instance of this template. + * + * \param context The context used to create the dictionary object. + * \param property_values Values of properties that were declared using + * `DeclareDataProperties()`. The span only passes values and expectes the + * order to match the declaration. Non-existent properties are signaled via + * empty `MaybeLocal`s. + */ + V8_WARN_UNUSED_RESULT Local NewInstance( + Local context, MemorySpan> property_values); + + V8_INLINE static DictionaryTemplate* Cast(Data* data); + + private: + static void CheckCast(Data* that); + + DictionaryTemplate(); +}; + /** * A Signature specifies which receiver is valid for a function. * @@ -995,6 +1037,13 @@ ObjectTemplate* ObjectTemplate::Cast(Data* data) { return reinterpret_cast(data); } +DictionaryTemplate* DictionaryTemplate::Cast(Data* data) { +#ifdef V8_ENABLE_CHECKS + CheckCast(data); +#endif + return reinterpret_cast(data); +} + Signature* Signature::Cast(Data* data) { #ifdef V8_ENABLE_CHECKS CheckCast(data); diff --git a/deps/v8/include/v8-traced-handle.h b/deps/v8/include/v8-traced-handle.h index 7abe0b9446ef42..c9fd357b871bf7 100644 --- a/deps/v8/include/v8-traced-handle.h +++ b/deps/v8/include/v8-traced-handle.h @@ -77,19 +77,6 @@ class TracedReferenceBase : public api_internal::IndirectHandleBase { return this->GetSlotThreadSafe() == nullptr; } - /** - * Assigns a wrapper class ID to the handle. - */ - V8_DEPRECATED("Embedders need to maintain state for references themselves.") - V8_INLINE void SetWrapperClassId(uint16_t class_id); - - /** - * Returns the class ID previously assigned to this handle or 0 if no class ID - * was previously assigned. - */ - V8_DEPRECATED("Embedders need to maintain state for references themselves.") - V8_INLINE uint16_t WrapperClassId() const; - protected: V8_INLINE TracedReferenceBase() = default; @@ -440,22 +427,6 @@ TracedReference& TracedReference::operator=(const TracedReference& rhs) { return *this; } -void TracedReferenceBase::SetWrapperClassId(uint16_t class_id) { - using I = internal::Internals; - if (IsEmpty()) return; - uint8_t* addr = - reinterpret_cast(slot()) + I::kTracedNodeClassIdOffset; - *reinterpret_cast(addr) = class_id; -} - -uint16_t TracedReferenceBase::WrapperClassId() const { - using I = internal::Internals; - if (IsEmpty()) return 0; - uint8_t* addr = - reinterpret_cast(slot()) + I::kTracedNodeClassIdOffset; - return *reinterpret_cast(addr); -} - } // namespace v8 #endif // INCLUDE_V8_TRACED_HANDLE_H_ diff --git a/deps/v8/include/v8-util.h b/deps/v8/include/v8-util.h index c845c9924cd403..db6d1a2fe6befc 100644 --- a/deps/v8/include/v8-util.h +++ b/deps/v8/include/v8-util.h @@ -240,8 +240,9 @@ class PersistentValueMapBase { : value_(other.value_) { } Local NewLocal(Isolate* isolate) const { - return Local::New( - isolate, internal::ValueHelper::SlotAsValue(FromVal(value_))); + return Local::New(isolate, + internal::ValueHelper::SlotAsValue( + reinterpret_cast(value_))); } bool IsEmpty() const { return value_ == kPersistentContainerNotFound; @@ -298,7 +299,8 @@ class PersistentValueMapBase { typename Traits::Impl* impl() { return &impl_; } static V* FromVal(PersistentContainerValue v) { - return reinterpret_cast(v); + return internal::ValueHelper::SlotAsValue( + reinterpret_cast(v)); } static PersistentContainerValue ClearAndLeak(Global* persistent) { @@ -318,7 +320,7 @@ class PersistentValueMapBase { */ static Global Release(PersistentContainerValue v) { Global p; - p.slot() = reinterpret_cast(FromVal(v)); + p.slot() = reinterpret_cast(v); if (Traits::kCallbackType != kNotWeak && p.IsWeak()) { Traits::DisposeCallbackData( p.template ClearWeak()); @@ -328,8 +330,8 @@ class PersistentValueMapBase { void RemoveWeak(const K& key) { Global p; - p.slot() = reinterpret_cast( - FromVal(Traits::Remove(&impl_, key))); + p.slot() = + reinterpret_cast(Traits::Remove(&impl_, key)); p.Reset(); } @@ -345,8 +347,7 @@ class PersistentValueMapBase { PersistentContainerValue value) { bool hasValue = value != kPersistentContainerNotFound; if (hasValue) { - returnValue->SetInternal( - *reinterpret_cast(FromVal(value))); + returnValue->SetInternal(*reinterpret_cast(value)); } return hasValue; } @@ -620,7 +621,7 @@ class V8_DEPRECATE_SOON("Use std::vector>.") PersistentValueVector { */ Local Get(size_t index) const { return Local::New(isolate_, internal::ValueHelper::SlotAsValue( - FromVal(Traits::Get(&impl_, index)))); + Traits::Get(&impl_, index))); } /** @@ -630,8 +631,7 @@ class V8_DEPRECATE_SOON("Use std::vector>.") PersistentValueVector { size_t length = Traits::Size(&impl_); for (size_t i = 0; i < length; i++) { Global p; - p.slot() = - reinterpret_cast(FromVal(Traits::Get(&impl_, i))); + p.slot() = reinterpret_cast(Traits::Get(&impl_, i)); } Traits::Clear(&impl_); } @@ -652,7 +652,8 @@ class V8_DEPRECATE_SOON("Use std::vector>.") PersistentValueVector { } static V* FromVal(PersistentContainerValue v) { - return reinterpret_cast(v); + return internal::ValueHelper::SlotAsValue( + reinterpret_cast(v)); } Isolate* isolate_; diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index d702a676db560d..c3c0da86379d07 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 2 -#define V8_BUILD_NUMBER 281 -#define V8_PATCH_LEVEL 27 +#define V8_MINOR_VERSION 3 +#define V8_BUILD_NUMBER 219 +#define V8_PATCH_LEVEL 16 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/infra/testing/builders.pyl b/deps/v8/infra/testing/builders.pyl index de03e53600b813..674f5f2d572151 100644 --- a/deps/v8/infra/testing/builders.pyl +++ b/deps/v8/infra/testing/builders.pyl @@ -376,7 +376,6 @@ }, 'tests': [ {'name': 'v8testing', 'variant': 'default'}, - {'name': 'v8testing', 'variant': 'future'}, ], }, 'v8_linux64_coverage_rel': { @@ -1435,7 +1434,6 @@ }, 'tests': [ {'name': 'v8testing', 'variant': 'default'}, - {'name': 'v8testing', 'variant': 'future'}, ], }, 'V8 Linux64 - custom snapshot - debug': { diff --git a/deps/v8/samples/shell.cc b/deps/v8/samples/shell.cc index 835dfcb0d6bbb7..7ec41b104947bc 100644 --- a/deps/v8/samples/shell.cc +++ b/deps/v8/samples/shell.cc @@ -48,11 +48,11 @@ * For a more sophisticated shell, consider using the debug shell D8. */ - -v8::Local CreateShellContext(v8::Isolate* isolate); -void RunShell(v8::Local context, v8::Platform* platform); -int RunMain(v8::Isolate* isolate, v8::Platform* platform, int argc, - char* argv[]); +v8::Global CreateShellContext(v8::Isolate* isolate); +void RunShell(v8::Isolate* isolate, const v8::Global& context, + v8::Platform* platform); +int RunMain(v8::Isolate* isolate, const v8::Global& context, + v8::Platform* platform, int argc, char* argv[]); bool ExecuteString(v8::Isolate* isolate, v8::Local source, v8::Local name, bool print_result, bool report_exceptions); @@ -64,10 +64,8 @@ void Version(const v8::FunctionCallbackInfo& info); v8::MaybeLocal ReadFile(v8::Isolate* isolate, const char* name); void ReportException(v8::Isolate* isolate, v8::TryCatch* handler); - static bool run_shell; - int main(int argc, char* argv[]) { v8::V8::InitializeICUDefaultLocation(argv[0]); v8::V8::InitializeExternalStartupData(argv[0]); @@ -83,15 +81,13 @@ int main(int argc, char* argv[]) { int result; { v8::Isolate::Scope isolate_scope(isolate); - v8::HandleScope handle_scope(isolate); - v8::Local context = CreateShellContext(isolate); + v8::Global context = CreateShellContext(isolate); if (context.IsEmpty()) { fprintf(stderr, "Error creating context\n"); return 1; } - v8::Context::Scope context_scope(context); - result = RunMain(isolate, platform.get(), argc, argv); - if (run_shell) RunShell(context, platform.get()); + result = RunMain(isolate, context, platform.get(), argc, argv); + if (run_shell) RunShell(isolate, context, platform.get()); } isolate->Dispose(); v8::V8::Dispose(); @@ -100,16 +96,15 @@ int main(int argc, char* argv[]) { return result; } - // Extracts a C string from a V8 Utf8Value. const char* ToCString(const v8::String::Utf8Value& value) { return *value ? *value : ""; } - // Creates a new execution environment containing the built-in // functions. -v8::Local CreateShellContext(v8::Isolate* isolate) { +v8::Global CreateShellContext(v8::Isolate* isolate) { + v8::HandleScope handle_scope(isolate); // Create a template for the global object. v8::Local global = v8::ObjectTemplate::New(isolate); // Bind the global 'print' function to the C++ Print callback. @@ -122,10 +117,11 @@ v8::Local CreateShellContext(v8::Isolate* isolate) { global->Set(isolate, "quit", v8::FunctionTemplate::New(isolate, Quit)); // Bind the 'version' function global->Set(isolate, "version", v8::FunctionTemplate::New(isolate, Version)); - return v8::Context::New(isolate, NULL, global); + // Return the context. + v8::Local context = v8::Context::New(isolate, nullptr, global); + return v8::Global(isolate, context); } - // The callback that is invoked by v8 whenever the JavaScript 'print' // function is called. Prints its arguments on stdout separated by // spaces and ending with a newline. @@ -155,7 +151,7 @@ void Read(const v8::FunctionCallbackInfo& info) { return; } v8::String::Utf8Value file(info.GetIsolate(), info[0]); - if (*file == NULL) { + if (*file == nullptr) { info.GetIsolate()->ThrowError("Error loading file"); return; } @@ -175,7 +171,7 @@ void Load(const v8::FunctionCallbackInfo& info) { for (int i = 0; i < info.Length(); i++) { v8::HandleScope handle_scope(info.GetIsolate()); v8::String::Utf8Value file(info.GetIsolate(), info[i]); - if (*file == NULL) { + if (*file == nullptr) { info.GetIsolate()->ThrowError("Error loading file"); return; } @@ -203,6 +199,8 @@ void Quit(const v8::FunctionCallbackInfo& info) { exit(exit_code); } +// The callback that is invoked by v8 whenever the JavaScript 'version' +// function is called. Returns a string containing the current V8 version. void Version(const v8::FunctionCallbackInfo& info) { info.GetReturnValue().Set( v8::String::NewFromUtf8(info.GetIsolate(), v8::V8::GetVersion()) @@ -212,7 +210,7 @@ void Version(const v8::FunctionCallbackInfo& info) { // Reads a file into a v8 string. v8::MaybeLocal ReadFile(v8::Isolate* isolate, const char* name) { FILE* file = fopen(name, "rb"); - if (file == NULL) return v8::MaybeLocal(); + if (file == nullptr) return {}; fseek(file, 0, SEEK_END); size_t size = ftell(file); @@ -224,7 +222,7 @@ v8::MaybeLocal ReadFile(v8::Isolate* isolate, const char* name) { i += fread(&chars[i], 1, size - i, file); if (ferror(file)) { fclose(file); - return v8::MaybeLocal(); + return {}; } } fclose(file); @@ -234,10 +232,9 @@ v8::MaybeLocal ReadFile(v8::Isolate* isolate, const char* name) { return result; } - // Process remaining command line arguments and execute files -int RunMain(v8::Isolate* isolate, v8::Platform* platform, int argc, - char* argv[]) { +int RunMain(v8::Isolate* isolate, const v8::Global& context, + v8::Platform* platform, int argc, char* argv[]) { for (int i = 1; i < argc; i++) { const char* str = argv[i]; if (strcmp(str, "--shell") == 0) { @@ -251,25 +248,41 @@ int RunMain(v8::Isolate* isolate, v8::Platform* platform, int argc, "Warning: unknown flag %s.\nTry --help for options\n", str); } else if (strcmp(str, "-e") == 0 && i + 1 < argc) { // Execute argument given to -e option directly. - v8::Local file_name = - v8::String::NewFromUtf8Literal(isolate, "unnamed"); - v8::Local source; - if (!v8::String::NewFromUtf8(isolate, argv[++i]).ToLocal(&source)) { - return 1; + bool success; + { + // Enter the execution environment before evaluating any code. + v8::HandleScope handle_scope(isolate); + v8::Context::Scope context_scope(context.Get(isolate)); + v8::Local file_name = + v8::String::NewFromUtf8Literal(isolate, "unnamed"); + v8::Local source; + if (!v8::String::NewFromUtf8(isolate, argv[++i]).ToLocal(&source)) { + return 1; + } + success = ExecuteString(isolate, source, file_name, false, true); } - bool success = ExecuteString(isolate, source, file_name, false, true); + // It is important not to pump the message loop when there are v8::Local + // handles on the stack, as this may trigger a stackless GC. while (v8::platform::PumpMessageLoop(platform, isolate)) continue; if (!success) return 1; } else { // Use all other arguments as names of files to load and run. - v8::Local file_name = - v8::String::NewFromUtf8(isolate, str).ToLocalChecked(); - v8::Local source; - if (!ReadFile(isolate, str).ToLocal(&source)) { - fprintf(stderr, "Error reading '%s'\n", str); - continue; + bool success; + { + // Enter the execution environment before evaluating any code. + v8::HandleScope handle_scope(isolate); + v8::Context::Scope context_scope(context.Get(isolate)); + v8::Local file_name = + v8::String::NewFromUtf8(isolate, str).ToLocalChecked(); + v8::Local source; + if (!ReadFile(isolate, str).ToLocal(&source)) { + fprintf(stderr, "Error reading '%s'\n", str); + continue; + } + success = ExecuteString(isolate, source, file_name, false, true); } - bool success = ExecuteString(isolate, source, file_name, false, true); + // It is important not to pump the message loop when there are v8::Local + // handles on the stack, as this may trigger a stackless GC. while (v8::platform::PumpMessageLoop(platform, isolate)) continue; if (!success) return 1; } @@ -277,32 +290,33 @@ int RunMain(v8::Isolate* isolate, v8::Platform* platform, int argc, return 0; } - // The read-eval-execute loop of the shell. -void RunShell(v8::Local context, v8::Platform* platform) { +void RunShell(v8::Isolate* isolate, const v8::Global& context, + v8::Platform* platform) { fprintf(stderr, "V8 version %s [sample shell]\n", v8::V8::GetVersion()); static const int kBufferSize = 256; - // Enter the execution environment before evaluating any code. - v8::Context::Scope context_scope(context); - v8::Local name( - v8::String::NewFromUtf8Literal(context->GetIsolate(), "(shell)")); while (true) { char buffer[kBufferSize]; fprintf(stderr, "> "); char* str = fgets(buffer, kBufferSize, stdin); - if (str == NULL) break; - v8::HandleScope handle_scope(context->GetIsolate()); - ExecuteString( - context->GetIsolate(), - v8::String::NewFromUtf8(context->GetIsolate(), str).ToLocalChecked(), - name, true, true); - while (v8::platform::PumpMessageLoop(platform, context->GetIsolate())) - continue; + if (str == nullptr) break; + { + // Enter the execution environment before evaluating any code. + v8::HandleScope handle_scope(isolate); + v8::Context::Scope context_scope(context.Get(isolate)); + v8::Local name( + v8::String::NewFromUtf8Literal(isolate, "(shell)")); + ExecuteString(isolate, + v8::String::NewFromUtf8(isolate, str).ToLocalChecked(), + name, true, true); + } + // It is important not to pump the message loop when there are v8::Local + // handles on the stack, as this may trigger a stackless GC. + while (v8::platform::PumpMessageLoop(platform, isolate)) continue; } fprintf(stderr, "\n"); } - // Executes a string within the current v8 context. bool ExecuteString(v8::Isolate* isolate, v8::Local source, v8::Local name, bool print_result, @@ -339,7 +353,6 @@ bool ExecuteString(v8::Isolate* isolate, v8::Local source, } } - void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) { v8::HandleScope handle_scope(isolate); v8::String::Utf8Value exception(isolate, try_catch->Exception()); diff --git a/deps/v8/src/DEPS b/deps/v8/src/DEPS index 791550a933f5d4..aeedfd8bb70aee 100644 --- a/deps/v8/src/DEPS +++ b/deps/v8/src/DEPS @@ -39,6 +39,7 @@ include_rules = [ # TODO(v8:10496): Don't expose memory chunk outside of heap/. "+src/heap/memory-chunk.h", "+src/heap/memory-chunk-inl.h", + "+src/heap/memory-chunk-header.h", "+src/heap/paged-spaces-inl.h", "+src/heap/parked-scope-inl.h", "+src/heap/parked-scope.h", @@ -107,6 +108,12 @@ specific_include_rules = { "external-pointer-table\.cc": [ "+src/heap/read-only-spaces.h", ], + # keep the includes to a minimum since this header will be included via write barriers. + "memory-chunk-header\.h": [ + "-src", + "+src/base/build_config.h", + "+src/flags/flags.h", + ], "script\.h": [ "+src/heap/factory.h", "+src/heap/factory-base.h", diff --git a/deps/v8/src/api/api-inl.h b/deps/v8/src/api/api-inl.h index 2b9deff7d37a69..b8e60c48e651d8 100644 --- a/deps/v8/src/api/api-inl.h +++ b/deps/v8/src/api/api-inl.h @@ -179,7 +179,7 @@ class V8_NODISCARD CallDepthScope { CallDepthScope(i::Isolate* isolate, Local context) : isolate_(isolate), saved_context_(isolate->context(), isolate_) { isolate_->thread_local_top()->IncrementCallDepth(this); - i::Tagged env = *Utils::OpenHandle(*context); + i::Tagged env = *Utils::OpenDirectHandle(*context); isolate->set_context(env); if (do_callback) isolate_->FireBeforeCallEnteredCallback(); @@ -304,7 +304,7 @@ bool CopyAndConvertArrayToCppBuffer(Local src, T* dst, } i::DisallowGarbageCollection no_gc; - i::Tagged obj = *Utils::OpenHandle(*src); + i::Tagged obj = *Utils::OpenDirectHandle(*src); if (i::Object::IterationHasObservableEffects(obj)) { // The array has a custom iterator. return false; diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index 8b709703b5fb51..9ca94b045c26c9 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -24,6 +24,7 @@ #include "include/v8-primitive-object.h" #include "include/v8-profiler.h" #include "include/v8-source-location.h" +#include "include/v8-template.h" #include "include/v8-unwinder-state.h" #include "include/v8-util.h" #include "include/v8-wasm.h" @@ -86,6 +87,7 @@ #include "src/objects/js-array-buffer-inl.h" #include "src/objects/js-array-inl.h" #include "src/objects/js-collection-inl.h" +#include "src/objects/js-objects.h" #include "src/objects/js-promise-inl.h" #include "src/objects/js-regexp-inl.h" #include "src/objects/js-weak-refs-inl.h" @@ -101,6 +103,7 @@ #include "src/objects/shared-function-info.h" #include "src/objects/slots.h" #include "src/objects/smi.h" +#include "src/objects/string.h" #include "src/objects/synthetic-module-inl.h" #include "src/objects/templates.h" #include "src/objects/value-serializer.h" @@ -537,7 +540,7 @@ SnapshotCreator::SnapshotCreator(Isolate* v8_isolate, const intptr_t* external_references, const StartupData* existing_snapshot, bool owns_isolate) - : data_(new i::SnapshotCreatorImpl( + : impl_(new i::SnapshotCreatorImpl( reinterpret_cast(v8_isolate), external_references, existing_snapshot, owns_isolate)) {} @@ -546,50 +549,43 @@ SnapshotCreator::SnapshotCreator(const intptr_t* external_references, : SnapshotCreator(nullptr, external_references, existing_snapshot) {} SnapshotCreator::SnapshotCreator(const v8::Isolate::CreateParams& params) - : data_(new i::SnapshotCreatorImpl(params)) {} + : impl_(new i::SnapshotCreatorImpl(params)) {} SnapshotCreator::SnapshotCreator(v8::Isolate* isolate, const v8::Isolate::CreateParams& params) - : data_(new i::SnapshotCreatorImpl(reinterpret_cast(isolate), + : impl_(new i::SnapshotCreatorImpl(reinterpret_cast(isolate), params)) {} SnapshotCreator::~SnapshotCreator() { - DCHECK_NOT_NULL(data_); - auto impl = static_cast(data_); - delete impl; + DCHECK_NOT_NULL(impl_); + delete impl_; } Isolate* SnapshotCreator::GetIsolate() { - auto impl = static_cast(data_); - return reinterpret_cast(impl->isolate()); + return reinterpret_cast(impl_->isolate()); } void SnapshotCreator::SetDefaultContext( Local context, SerializeInternalFieldsCallback callback) { - auto impl = static_cast(data_); - impl->SetDefaultContext(Utils::OpenHandle(*context), callback); + impl_->SetDefaultContext(Utils::OpenHandle(*context), callback); } size_t SnapshotCreator::AddContext(Local context, SerializeInternalFieldsCallback callback) { - auto impl = static_cast(data_); - return impl->AddContext(Utils::OpenHandle(*context), callback); + return impl_->AddContext(Utils::OpenHandle(*context), callback); } size_t SnapshotCreator::AddData(i::Address object) { - auto impl = static_cast(data_); - return impl->AddData(object); + return impl_->AddData(object); } size_t SnapshotCreator::AddData(Local context, i::Address object) { - auto impl = static_cast(data_); - return impl->AddData(Utils::OpenHandle(*context), object); + return impl_->AddData(Utils::OpenHandle(*context), object); } StartupData SnapshotCreator::CreateBlob( SnapshotCreator::FunctionCodeHandling function_code_handling) { - auto impl = static_cast(data_); - return impl->CreateBlob(function_code_handling); + return impl_->CreateBlob(function_code_handling); } bool StartupData::CanBeRehashed() const { @@ -1949,6 +1945,24 @@ void ObjectTemplate::SetCodeLike() { self->set_code_like(true); } +Local DictionaryTemplate::New( + Isolate* isolate, MemorySpan names) { + i::Isolate* i_isolate = reinterpret_cast(isolate); + API_RCS_SCOPE(i_isolate, DictionaryTemplate, New); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + return Utils::ToLocal(i::DictionaryTemplateInfo::Create(i_isolate, names)); +} + +Local DictionaryTemplate::NewInstance( + Local context, MemorySpan> property_values) { + i::Isolate* i_isolate = reinterpret_cast(context->GetIsolate()); + API_RCS_SCOPE(i_isolate, DictionaryTemplate, NewInstance); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + auto self = Utils::OpenDirectHandle(this); + return ToApiHandle(i::DictionaryTemplateInfo::NewInstance( + Utils::OpenHandle(*context), self, property_values)); +} + // --- S c r i p t s --- // Internally, UnboundScript and UnboundModuleScript are SharedFunctionInfos, @@ -2294,11 +2308,11 @@ int ModuleRequest::GetSourceOffset() const { return Utils::OpenDirectHandle(this)->position(); } -Local ModuleRequest::GetImportAssertions() const { +Local ModuleRequest::GetImportAttributes() const { auto self = Utils::OpenDirectHandle(this); i::Isolate* i_isolate = self->GetIsolate(); return ToApiHandle( - i::direct_handle(self->import_assertions(), i_isolate), i_isolate); + i::direct_handle(self->import_attributes(), i_isolate), i_isolate); } Module::Status Module::GetStatus() const { @@ -3866,7 +3880,7 @@ bool Value::IsInt32() const { } bool Value::IsUint32() const { - auto obj = *Utils::OpenHandle(this); + auto obj = *Utils::OpenDirectHandle(this); if (i::IsSmi(obj)) return i::Smi::ToInt(obj) >= 0; if (i::IsNumber(obj)) { double value = i::Object::Number(obj); @@ -4271,6 +4285,10 @@ void* v8::ArrayBuffer::Data() const { return Utils::OpenDirectHandle(this)->backing_store(); } +bool v8::ArrayBuffer::IsResizableByUserJavaScript() const { + return Utils::OpenDirectHandle(this)->is_resizable_by_js(); +} + std::shared_ptr v8::SharedArrayBuffer::GetBackingStore() { auto self = Utils::OpenDirectHandle(this); std::shared_ptr backing_store = self->GetBackingStore(); @@ -4306,7 +4324,7 @@ void v8::TypedArray::CheckCast(Value* that) { #define CHECK_TYPED_ARRAY_CAST(Type, typeName, TYPE, ctype) \ void v8::Type##Array::CheckCast(Value* that) { \ - auto obj = *Utils::OpenHandle(that); \ + auto obj = *Utils::OpenDirectHandle(that); \ Utils::ApiCheck( \ i::IsJSTypedArray(obj) && \ i::JSTypedArray::cast(obj)->type() == i::kExternal##Type##Array, \ @@ -5359,6 +5377,30 @@ bool v8::Object::IsUndetectable() const { return i::IsUndetectable(*self); } +namespace { +#ifdef V8_ENABLE_DIRECT_LOCAL +// A newly allocated vector is required to convert from an array of direct +// locals to an array of indirect handles. +std::vector> PrepareArguments(int argc, + Local argv[]) { + std::vector> args(argc); + for (int i = 0; i < argc; ++i) { + args[i] = Utils::OpenHandle(*argv[i]); + } + return args; +} +#else // !V8_ENABLE_DIRECT_LOCAL +// A simple cast is used to convert from an array of indirect locals to an +// array of indirect handles. A MemorySpan object is returned, as no +// deallocation is necessary. +v8::MemorySpan> PrepareArguments(int argc, + Local argv[]) { + return {reinterpret_cast*>(argv), + static_cast(argc)}; +} +#endif // V8_ENABLE_DIRECT_LOCAL +} // namespace + MaybeLocal Object::CallAsFunction(Local context, Local recv, int argc, Local argv[]) { @@ -5371,10 +5413,11 @@ MaybeLocal Object::CallAsFunction(Local context, auto self = Utils::OpenHandle(this); auto recv_obj = Utils::OpenHandle(*recv); static_assert(sizeof(v8::Local) == sizeof(i::Handle)); - i::Handle* args = reinterpret_cast*>(argv); + auto args = PrepareArguments(argc, argv); Local result; has_exception = !ToLocal( - i::Execution::Call(i_isolate, self, recv_obj, argc, args), &result); + i::Execution::Call(i_isolate, self, recv_obj, argc, args.data()), + &result); RETURN_ON_FAILED_EXECUTION(Value); RETURN_ESCAPED(result); } @@ -5390,10 +5433,10 @@ MaybeLocal Object::CallAsConstructor(Local context, int argc, i_isolate); auto self = Utils::OpenHandle(this); static_assert(sizeof(v8::Local) == sizeof(i::Handle)); - i::Handle* args = reinterpret_cast*>(argv); + auto args = PrepareArguments(argc, argv); Local result; has_exception = !ToLocal( - i::Execution::New(i_isolate, self, self, argc, args), &result); + i::Execution::New(i_isolate, self, self, argc, args.data()), &result); RETURN_ON_FAILED_EXECUTION(Value); RETURN_ESCAPED(result); } @@ -5446,10 +5489,10 @@ MaybeLocal Function::NewInstanceWithSideEffectType( } } } - i::Handle* args = reinterpret_cast*>(argv); + auto args = PrepareArguments(argc, argv); Local result; has_exception = !ToLocal( - i::Execution::New(i_isolate, self, self, argc, args), &result); + i::Execution::New(i_isolate, self, self, argc, args.data()), &result); RETURN_ON_FAILED_EXECUTION(Object); RETURN_ESCAPED(result); } @@ -5468,19 +5511,11 @@ MaybeLocal Function::Call(Local context, "Function to be called is a null pointer"); auto recv_obj = Utils::OpenHandle(*recv); static_assert(sizeof(v8::Local) == sizeof(i::Handle)); - -#ifdef V8_ENABLE_DIRECT_LOCAL - i::Handle* args = new i::Handle[argc]; - for (int i = 0; i < argc; ++i) { - args[i] = Utils::OpenHandle(*argv[i]); - } -#else // !V8_ENABLE_DIRECT_LOCAL - i::Handle* args = reinterpret_cast*>(argv); -#endif // V8_ENABLE_DIRECT_LOCAL - + auto args = PrepareArguments(argc, argv); Local result; has_exception = !ToLocal( - i::Execution::Call(i_isolate, self, recv_obj, argc, args), &result); + i::Execution::Call(i_isolate, self, recv_obj, argc, args.data()), + &result); RETURN_ON_FAILED_EXECUTION(Value); RETURN_ESCAPED(result); } @@ -7328,6 +7363,13 @@ void v8::ObjectTemplate::CheckCast(Data* that) { "Value is not an ObjectTemplate"); } +void v8::DictionaryTemplate::CheckCast(Data* that) { + auto obj = Utils::OpenDirectHandle(that); + Utils::ApiCheck(i::IsDictionaryTemplateInfo(*obj), + "v8::DictionaryTemplate::Cast", + "Value is not an DictionaryTemplate"); +} + void v8::FunctionTemplate::CheckCast(Data* that) { auto obj = Utils::OpenDirectHandle(that); Utils::ApiCheck(i::IsFunctionTemplateInfo(*obj), "v8::FunctionTemplate::Cast", @@ -8087,7 +8129,7 @@ uint32_t GetLength(Tagged array) { } // namespace internal uint32_t v8::Array::Length() const { - return i::GetLength(*Utils::OpenHandle(this)); + return i::GetLength(*Utils::OpenDirectHandle(this)); } namespace internal { @@ -8259,13 +8301,27 @@ Maybe v8::Array::Iterate(Local context, } v8::TypecheckWitness::TypecheckWitness(Isolate* isolate) +#ifdef V8_ENABLE_DIRECT_LOCAL + // An empty local suffices. + : cached_map_() +#else // We need to reserve a handle that we can patch later. - // TODO(13270): When we switch to CSS, we can use a direct pointer - // instead of a handle. - : cached_map_(v8::Number::New(isolate, 1)) {} + // We initialize it with something that cannot compare equal to any map. + : cached_map_(v8::Number::New(isolate, 1)) +#endif +{ +} void v8::TypecheckWitness::Update(Local baseline) { i::Tagged obj = *Utils::OpenDirectHandle(*baseline); +#ifdef V8_ENABLE_DIRECT_LOCAL + if (IsSmi(obj)) { + cached_map_ = Local(); + } else { + i::Tagged map = i::HeapObject::cast(obj)->map(); + cached_map_ = Local::FromAddress(map->ptr()); + } +#else i::Tagged map = i::Smi::zero(); if (!IsSmi(obj)) map = i::HeapObject::cast(obj)->map(); // Design overview: in the {TypecheckWitness} constructor, we create @@ -8274,12 +8330,12 @@ void v8::TypecheckWitness::Update(Local baseline) { // to allow having short-lived HandleScopes (e.g. in {FastIterateArray} // above) while a {TypecheckWitness} is alive: it therefore cannot hold // on to one of the short-lived handles. - // Calling {OpenHandle} on the {cached_map_} only serves to "reinterpret_cast" - // it to an {i::Handle} on which we can call {PatchValue}. - // TODO(13270): When we switch to CSS, this can become simpler: we can - // then simply overwrite the direct pointer. + // Calling {OpenIndirectHandle} on the {cached_map_} only serves to + // "reinterpret_cast" it to an {i::IndirectHandle} on which we can call + // {PatchValue}. auto cache = Utils::OpenIndirectHandle(*cached_map_); cache.PatchValue(map); +#endif } Local v8::Map::New(Isolate* v8_isolate) { @@ -10384,13 +10440,13 @@ CALLBACK_SETTER(WasmAsyncResolvePromiseCallback, CALLBACK_SETTER(WasmLoadSourceMapCallback, WasmLoadSourceMapCallback, wasm_load_source_map_callback) -CALLBACK_SETTER(WasmGCEnabledCallback, WasmGCEnabledCallback, - wasm_gc_enabled_callback) - CALLBACK_SETTER(WasmImportedStringsEnabledCallback, WasmImportedStringsEnabledCallback, wasm_imported_strings_enabled_callback) +CALLBACK_SETTER(WasmJSPIEnabledCallback, WasmJSPIEnabledCallback, + wasm_jspi_enabled_callback) + CALLBACK_SETTER(SharedArrayBufferConstructorEnabledCallback, SharedArrayBufferConstructorEnabledCallback, sharedarraybuffer_constructor_enabled_callback) @@ -10410,6 +10466,7 @@ void Isolate::InstallConditionalFeatures(Local context) { i::WasmJs::InstallConditionalFeatures(i_isolate, Utils::OpenHandle(*context)); } + #endif // V8_ENABLE_WEBASSEMBLY } diff --git a/deps/v8/src/api/api.h b/deps/v8/src/api/api.h index 359783d78a899d..bbc42ef09680bd 100644 --- a/deps/v8/src/api/api.h +++ b/deps/v8/src/api/api.h @@ -30,6 +30,7 @@ namespace v8 { +class DictionaryTemplate; class Extension; class Signature; class Template; @@ -96,97 +97,99 @@ class RegisteredExtension { static RegisteredExtension* first_extension_; }; -#define TO_LOCAL_LIST(V) \ - V(ToLocal, AccessorPair, debug::AccessorPair) \ - V(ToLocal, NativeContext, Context) \ - V(ToLocal, Object, Value) \ - V(ToLocal, Module, Module) \ - V(ToLocal, Name, Name) \ - V(ToLocal, String, String) \ - V(ToLocal, Symbol, Symbol) \ - V(ToLocal, JSRegExp, RegExp) \ - V(ToLocal, JSReceiver, Object) \ - V(ToLocal, JSObject, Object) \ - V(ToLocal, JSFunction, Function) \ - V(ToLocal, JSArray, Array) \ - V(ToLocal, JSMap, Map) \ - V(ToLocal, JSSet, Set) \ - V(ToLocal, JSProxy, Proxy) \ - V(ToLocal, JSArrayBuffer, ArrayBuffer) \ - V(ToLocal, JSArrayBufferView, ArrayBufferView) \ - V(ToLocal, JSDataView, DataView) \ - V(ToLocal, JSRabGsabDataView, DataView) \ - V(ToLocal, JSTypedArray, TypedArray) \ - V(ToLocalShared, JSArrayBuffer, SharedArrayBuffer) \ - V(ToLocal, FunctionTemplateInfo, FunctionTemplate) \ - V(ToLocal, ObjectTemplateInfo, ObjectTemplate) \ - V(SignatureToLocal, FunctionTemplateInfo, Signature) \ - V(MessageToLocal, Object, Message) \ - V(PromiseToLocal, JSObject, Promise) \ - V(StackTraceToLocal, FixedArray, StackTrace) \ - V(StackFrameToLocal, StackFrameInfo, StackFrame) \ - V(NumberToLocal, Object, Number) \ - V(IntegerToLocal, Object, Integer) \ - V(Uint32ToLocal, Object, Uint32) \ - V(ToLocal, BigInt, BigInt) \ - V(ExternalToLocal, JSObject, External) \ - V(CallableToLocal, JSReceiver, Function) \ - V(ToLocalPrimitive, Object, Primitive) \ - V(FixedArrayToLocal, FixedArray, FixedArray) \ - V(PrimitiveArrayToLocal, FixedArray, PrimitiveArray) \ +#define TO_LOCAL_LIST(V) \ + V(ToLocal, AccessorPair, debug::AccessorPair) \ + V(ToLocal, NativeContext, Context) \ + V(ToLocal, Object, Value) \ + V(ToLocal, Module, Module) \ + V(ToLocal, Name, Name) \ + V(ToLocal, String, String) \ + V(ToLocal, Symbol, Symbol) \ + V(ToLocal, JSRegExp, RegExp) \ + V(ToLocal, JSReceiver, Object) \ + V(ToLocal, JSObject, Object) \ + V(ToLocal, JSFunction, Function) \ + V(ToLocal, JSArray, Array) \ + V(ToLocal, JSMap, Map) \ + V(ToLocal, JSSet, Set) \ + V(ToLocal, JSProxy, Proxy) \ + V(ToLocal, JSArrayBuffer, ArrayBuffer) \ + V(ToLocal, JSArrayBufferView, ArrayBufferView) \ + V(ToLocal, JSDataView, DataView) \ + V(ToLocal, JSRabGsabDataView, DataView) \ + V(ToLocal, JSTypedArray, TypedArray) \ + V(ToLocalShared, JSArrayBuffer, SharedArrayBuffer) \ + V(ToLocal, FunctionTemplateInfo, FunctionTemplate) \ + V(ToLocal, ObjectTemplateInfo, ObjectTemplate) \ + V(ToLocal, DictionaryTemplateInfo, DictionaryTemplate) \ + V(SignatureToLocal, FunctionTemplateInfo, Signature) \ + V(MessageToLocal, Object, Message) \ + V(PromiseToLocal, JSObject, Promise) \ + V(StackTraceToLocal, FixedArray, StackTrace) \ + V(StackFrameToLocal, StackFrameInfo, StackFrame) \ + V(NumberToLocal, Object, Number) \ + V(IntegerToLocal, Object, Integer) \ + V(Uint32ToLocal, Object, Uint32) \ + V(ToLocal, BigInt, BigInt) \ + V(ExternalToLocal, JSObject, External) \ + V(CallableToLocal, JSReceiver, Function) \ + V(ToLocalPrimitive, Object, Primitive) \ + V(FixedArrayToLocal, FixedArray, FixedArray) \ + V(PrimitiveArrayToLocal, FixedArray, PrimitiveArray) \ V(ToLocal, ScriptOrModule, ScriptOrModule) -#define OPEN_HANDLE_LIST(V) \ - V(Template, TemplateInfo) \ - V(FunctionTemplate, FunctionTemplateInfo) \ - V(ObjectTemplate, ObjectTemplateInfo) \ - V(Signature, FunctionTemplateInfo) \ - V(Data, Object) \ - V(RegExp, JSRegExp) \ - V(Object, JSReceiver) \ - V(Array, JSArray) \ - V(Map, JSMap) \ - V(Set, JSSet) \ - V(ArrayBuffer, JSArrayBuffer) \ - V(ArrayBufferView, JSArrayBufferView) \ - V(TypedArray, JSTypedArray) \ - V(Uint8Array, JSTypedArray) \ - V(Uint8ClampedArray, JSTypedArray) \ - V(Int8Array, JSTypedArray) \ - V(Uint16Array, JSTypedArray) \ - V(Int16Array, JSTypedArray) \ - V(Uint32Array, JSTypedArray) \ - V(Int32Array, JSTypedArray) \ - V(Float32Array, JSTypedArray) \ - V(Float64Array, JSTypedArray) \ - V(DataView, JSDataViewOrRabGsabDataView) \ - V(SharedArrayBuffer, JSArrayBuffer) \ - V(Name, Name) \ - V(String, String) \ - V(Symbol, Symbol) \ - V(Script, JSFunction) \ - V(UnboundModuleScript, SharedFunctionInfo) \ - V(UnboundScript, SharedFunctionInfo) \ - V(Module, Module) \ - V(Function, JSReceiver) \ - V(Message, JSMessageObject) \ - V(Context, NativeContext) \ - V(External, Object) \ - V(StackTrace, FixedArray) \ - V(StackFrame, StackFrameInfo) \ - V(Proxy, JSProxy) \ - V(debug::GeneratorObject, JSGeneratorObject) \ - V(debug::ScriptSource, HeapObject) \ - V(debug::Script, Script) \ - V(debug::EphemeronTable, EphemeronHashTable) \ - V(debug::AccessorPair, AccessorPair) \ - V(Promise, JSPromise) \ - V(Primitive, Object) \ - V(PrimitiveArray, FixedArray) \ - V(BigInt, BigInt) \ - V(ScriptOrModule, ScriptOrModule) \ - V(FixedArray, FixedArray) \ - V(ModuleRequest, ModuleRequest) \ +#define OPEN_HANDLE_LIST(V) \ + V(Template, TemplateInfo) \ + V(FunctionTemplate, FunctionTemplateInfo) \ + V(ObjectTemplate, ObjectTemplateInfo) \ + V(DictionaryTemplate, DictionaryTemplateInfo) \ + V(Signature, FunctionTemplateInfo) \ + V(Data, Object) \ + V(RegExp, JSRegExp) \ + V(Object, JSReceiver) \ + V(Array, JSArray) \ + V(Map, JSMap) \ + V(Set, JSSet) \ + V(ArrayBuffer, JSArrayBuffer) \ + V(ArrayBufferView, JSArrayBufferView) \ + V(TypedArray, JSTypedArray) \ + V(Uint8Array, JSTypedArray) \ + V(Uint8ClampedArray, JSTypedArray) \ + V(Int8Array, JSTypedArray) \ + V(Uint16Array, JSTypedArray) \ + V(Int16Array, JSTypedArray) \ + V(Uint32Array, JSTypedArray) \ + V(Int32Array, JSTypedArray) \ + V(Float32Array, JSTypedArray) \ + V(Float64Array, JSTypedArray) \ + V(DataView, JSDataViewOrRabGsabDataView) \ + V(SharedArrayBuffer, JSArrayBuffer) \ + V(Name, Name) \ + V(String, String) \ + V(Symbol, Symbol) \ + V(Script, JSFunction) \ + V(UnboundModuleScript, SharedFunctionInfo) \ + V(UnboundScript, SharedFunctionInfo) \ + V(Module, Module) \ + V(Function, JSReceiver) \ + V(Message, JSMessageObject) \ + V(Context, NativeContext) \ + V(External, Object) \ + V(StackTrace, FixedArray) \ + V(StackFrame, StackFrameInfo) \ + V(Proxy, JSProxy) \ + V(debug::GeneratorObject, JSGeneratorObject) \ + V(debug::ScriptSource, HeapObject) \ + V(debug::Script, Script) \ + V(debug::EphemeronTable, EphemeronHashTable) \ + V(debug::AccessorPair, AccessorPair) \ + V(Promise, JSPromise) \ + V(Primitive, Object) \ + V(PrimitiveArray, FixedArray) \ + V(BigInt, BigInt) \ + V(ScriptOrModule, ScriptOrModule) \ + V(FixedArray, FixedArray) \ + V(ModuleRequest, ModuleRequest) \ IF_WASM(V, WasmMemoryObject, WasmMemoryObject) class Utils { diff --git a/deps/v8/src/ast/ast-source-ranges.h b/deps/v8/src/ast/ast-source-ranges.h index 7edd07658be948..b29f4cf07da5dc 100644 --- a/deps/v8/src/ast/ast-source-ranges.h +++ b/deps/v8/src/ast/ast-source-ranges.h @@ -46,6 +46,7 @@ struct SourceRange { V(BinaryOperation) \ V(Block) \ V(CaseClause) \ + V(ConditionalChain) \ V(Conditional) \ V(Expression) \ V(FunctionLiteral) \ @@ -142,6 +143,39 @@ class CaseClauseSourceRanges final : public AstNodeSourceRanges { SourceRange body_range_; }; +class ConditionalChainSourceRanges final : public AstNodeSourceRanges { + public: + explicit ConditionalChainSourceRanges(Zone* zone) + : then_ranges_(zone), else_ranges_(zone) {} + + SourceRange GetRangeAtIndex(SourceRangeKind kind, size_t index) { + if (kind == SourceRangeKind::kThen) { + DCHECK_LT(index, then_ranges_.size()); + return then_ranges_[index]; + } + DCHECK_EQ(kind, SourceRangeKind::kElse); + DCHECK_LT(index, else_ranges_.size()); + return else_ranges_[index]; + } + + void AddThenRanges(const SourceRange& range) { + then_ranges_.push_back(range); + } + + void AddElseRange(const SourceRange& else_range) { + else_ranges_.push_back(else_range); + } + + size_t RangeCount() const { return then_ranges_.size(); } + + SourceRange GetRange(SourceRangeKind kind) override { UNREACHABLE(); } + bool HasRange(SourceRangeKind kind) override { return false; } + + private: + ZoneVector then_ranges_; + ZoneVector else_ranges_; +}; + class ConditionalSourceRanges final : public AstNodeSourceRanges { public: explicit ConditionalSourceRanges(const SourceRange& then_range, diff --git a/deps/v8/src/ast/ast-traversal-visitor.h b/deps/v8/src/ast/ast-traversal-visitor.h index c1755e6c72eb57..3b4f7e22ad380b 100644 --- a/deps/v8/src/ast/ast-traversal-visitor.h +++ b/deps/v8/src/ast/ast-traversal-visitor.h @@ -295,6 +295,17 @@ void AstTraversalVisitor::VisitNativeFunctionLiteral( PROCESS_EXPRESSION(expr); } +template +void AstTraversalVisitor::VisitConditionalChain( + ConditionalChain* expr) { + PROCESS_EXPRESSION(expr); + for (size_t i = 0; i < expr->conditional_chain_length(); ++i) { + RECURSE_EXPRESSION(Visit(expr->condition_at(i))); + RECURSE_EXPRESSION(Visit(expr->then_expression_at(i))); + } + RECURSE(Visit(expr->else_expression())); +} + template void AstTraversalVisitor::VisitConditional(Conditional* expr) { PROCESS_EXPRESSION(expr); @@ -561,8 +572,8 @@ void AstTraversalVisitor::VisitImportCallExpression( ImportCallExpression* expr) { PROCESS_EXPRESSION(expr); RECURSE_EXPRESSION(Visit(expr->specifier())); - if (expr->import_assertions()) { - RECURSE_EXPRESSION(Visit(expr->import_assertions())); + if (expr->import_options()) { + RECURSE_EXPRESSION(Visit(expr->import_options())); } } diff --git a/deps/v8/src/ast/ast-value-factory.cc b/deps/v8/src/ast/ast-value-factory.cc index 239f0a6e8d3168..f7470b5cff60c5 100644 --- a/deps/v8/src/ast/ast-value-factory.cc +++ b/deps/v8/src/ast/ast-value-factory.cc @@ -60,7 +60,7 @@ class OneByteStringStream { template void AstRawString::Internalize(IsolateT* isolate) { DCHECK(!has_string_); - if (literal_bytes_.length() == 0) { + if (literal_bytes_.empty()) { set_string(isolate->factory()->empty_string()); } else if (is_one_byte()) { OneByteStringKey key(raw_hash_field_, literal_bytes_); diff --git a/deps/v8/src/ast/ast.cc b/deps/v8/src/ast/ast.cc index feced7e38df4f5..55b20131a5ca6c 100644 --- a/deps/v8/src/ast/ast.cc +++ b/deps/v8/src/ast/ast.cc @@ -847,8 +847,8 @@ template EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT) static bool IsCommutativeOperationWithSmiLiteral(Token::Value op) { // Add is not commutative due to potential for string addition. - return op == Token::MUL || op == Token::BIT_AND || op == Token::BIT_OR || - op == Token::BIT_XOR; + return op == Token::kMul || op == Token::kBitAnd || op == Token::kBitOr || + op == Token::kBitXor; } // Check for the pattern: x + 1. @@ -869,32 +869,9 @@ bool BinaryOperation::IsSmiLiteralOperation(Expression** subexpr, MatchSmiLiteralOperation(right_, left_, subexpr, literal)); } -static bool IsTypeof(Expression* expr) { - UnaryOperation* maybe_unary = expr->AsUnaryOperation(); - return maybe_unary != nullptr && maybe_unary->op() == Token::TYPEOF; -} - -// Check for the pattern: typeof equals . -static bool MatchLiteralCompareTypeof(Expression* left, Token::Value op, - Expression* right, Expression** expr, - Literal** literal) { - if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) { - *expr = left->AsUnaryOperation()->expression(); - *literal = right->AsLiteral(); - return true; - } - return false; -} - -bool CompareOperation::IsLiteralCompareTypeof(Expression** expr, - Literal** literal) { - return MatchLiteralCompareTypeof(left_, op(), right_, expr, literal) || - MatchLiteralCompareTypeof(right_, op(), left_, expr, literal); -} - static bool IsVoidOfLiteral(Expression* expr) { UnaryOperation* maybe_unary = expr->AsUnaryOperation(); - return maybe_unary != nullptr && maybe_unary->op() == Token::VOID && + return maybe_unary != nullptr && maybe_unary->op() == Token::kVoid && maybe_unary->expression()->IsLiteral(); } @@ -902,7 +879,7 @@ static bool MatchLiteralStrictCompareBoolean(Expression* left, Token::Value op, Expression* right, Expression** expr, Literal** literal) { - if (left->IsBooleanLiteral() && op == Token::EQ_STRICT) { + if (left->IsBooleanLiteral() && op == Token::kEqStrict) { *expr = right; *literal = left->AsLiteral(); return true; diff --git a/deps/v8/src/ast/ast.h b/deps/v8/src/ast/ast.h index 5843b3f6a9698a..483f5a2c908e11 100644 --- a/deps/v8/src/ast/ast.h +++ b/deps/v8/src/ast/ast.h @@ -91,6 +91,7 @@ namespace internal { V(ClassLiteral) \ V(CompareOperation) \ V(CompoundAssignment) \ + V(ConditionalChain) \ V(Conditional) \ V(CountOperation) \ V(EmptyParentheses) \ @@ -1938,7 +1939,7 @@ class NaryOperation final : public Expression { subsequent_(zone) { bit_field_ |= OperatorField::encode(op); DCHECK(Token::IsBinaryOp(op)); - DCHECK_NE(op, Token::EXP); + DCHECK_NE(op, Token::kExp); subsequent_.reserve(initial_subsequent_size); } @@ -2002,7 +2003,6 @@ class CompareOperation final : public Expression { Expression* right() const { return right_; } // Match special cases. - bool IsLiteralCompareTypeof(Expression** expr, Literal** literal); bool IsLiteralStrictCompareBoolean(Expression** expr, Literal** literal); bool IsLiteralCompareUndefined(Expression** expr); bool IsLiteralCompareNull(Expression** expr); @@ -2045,6 +2045,77 @@ class Spread final : public Expression { Expression* expression_; }; +class ConditionalChain : public Expression { + public: + Expression* condition_at(size_t index) const { + return conditional_chain_entries_[index].condition; + } + Expression* then_expression_at(size_t index) const { + return conditional_chain_entries_[index].then_expression; + } + int condition_position_at(size_t index) const { + return conditional_chain_entries_[index].condition_position; + } + size_t conditional_chain_length() const { + return conditional_chain_entries_.size(); + } + Expression* else_expression() const { return else_expression_; } + void set_else_expression(Expression* s) { else_expression_ = s; } + + void AddChainEntry(Expression* cond, Expression* then, int pos) { + conditional_chain_entries_.emplace_back(cond, then, pos); + } + + private: + friend class AstNodeFactory; + friend Zone; + + ConditionalChain(Zone* zone, size_t initial_size, int pos) + : Expression(pos, kConditionalChain), + conditional_chain_entries_(zone), + else_expression_(nullptr) { + conditional_chain_entries_.reserve(initial_size); + } + + // Conditional Chain Expression stores the conditional chain entries out of + // line, along with their operation's position. The else expression is stored + // inline. This Expression is reserved for ternary operations that have more + // than one conditional chain entry. For ternary operations with only one + // conditional chain entry, the Conditional Expression is used instead. + // + // So an conditional chain: + // + // cond ? then : cond ? then : cond ? then : else + // + // is stored as: + // + // [(cond, then), (cond, then),...] else + // '-----------------------------' '----' + // conditional chain entries else + // + // Example: + // + // Expression: v1 == 1 ? "a" : v2 == 2 ? "b" : "c" + // + // conditionat_chain_entries_: [(v1 == 1, "a", 0), (v2 == 2, "b", 14)] + // else_expression_: "c" + // + // Example of a _not_ expected expression (only one chain entry): + // + // Expression: v1 == 1 ? "a" : "b" + // + + struct ConditionalChainEntry { + Expression* condition; + Expression* then_expression; + int condition_position; + ConditionalChainEntry(Expression* cond, Expression* then, int pos) + : condition(cond), then_expression(then), condition_position(pos) {} + }; + ZoneVector conditional_chain_entries_; + Expression* else_expression_; +}; + class Conditional final : public Expression { public: Expression* condition() const { return condition_; } @@ -2666,7 +2737,7 @@ class SuperCallReference final : public Expression { class ImportCallExpression final : public Expression { public: Expression* specifier() const { return specifier_; } - Expression* import_assertions() const { return import_assertions_; } + Expression* import_options() const { return import_options_; } private: friend class AstNodeFactory; @@ -2675,16 +2746,16 @@ class ImportCallExpression final : public Expression { ImportCallExpression(Expression* specifier, int pos) : Expression(pos, kImportCallExpression), specifier_(specifier), - import_assertions_(nullptr) {} + import_options_(nullptr) {} - ImportCallExpression(Expression* specifier, Expression* import_assertions, + ImportCallExpression(Expression* specifier, Expression* import_options, int pos) : Expression(pos, kImportCallExpression), specifier_(specifier), - import_assertions_(import_assertions) {} + import_options_(import_options) {} Expression* specifier_; - Expression* import_assertions_; + Expression* import_options_; }; // This class is produced when parsing the () in arrow functions without any @@ -3216,6 +3287,10 @@ class AstNodeFactory final { return zone_->New(expression, pos, expr_pos); } + ConditionalChain* NewConditionalChain(size_t initial_size, int pos) { + return zone_->New(zone_, initial_size, pos); + } + Conditional* NewConditional(Expression* condition, Expression* then_expression, Expression* else_expression, @@ -3232,11 +3307,11 @@ class AstNodeFactory final { DCHECK_NOT_NULL(target); DCHECK_NOT_NULL(value); - if (op != Token::INIT && target->IsVariableProxy()) { + if (op != Token::kInit && target->IsVariableProxy()) { target->AsVariableProxy()->set_is_assigned(); } - if (op == Token::ASSIGN || op == Token::INIT) { + if (op == Token::kAssign || op == Token::kInit) { return zone_->New(AstNode::kAssignment, op, target, value, pos); } else { @@ -3371,9 +3446,9 @@ class AstNodeFactory final { } ImportCallExpression* NewImportCallExpression(Expression* specifier, - Expression* import_assertions, + Expression* import_options, int pos) { - return zone_->New(specifier, import_assertions, pos); + return zone_->New(specifier, import_options, pos); } InitializeClassMembersStatement* NewInitializeClassMembersStatement( diff --git a/deps/v8/src/ast/modules.cc b/deps/v8/src/ast/modules.cc index 2b07460c256bc7..6624b9cc930e77 100644 --- a/deps/v8/src/ast/modules.cc +++ b/deps/v8/src/ast/modules.cc @@ -27,10 +27,10 @@ bool SourceTextModuleDescriptor::ModuleRequestComparer::operator()( return specifier_comparison < 0; } - auto lhsIt = lhs->import_assertions()->cbegin(); - auto rhsIt = rhs->import_assertions()->cbegin(); - for (; lhsIt != lhs->import_assertions()->cend() && - rhsIt != rhs->import_assertions()->cend(); + auto lhsIt = lhs->import_attributes()->cbegin(); + auto rhsIt = rhs->import_attributes()->cbegin(); + for (; lhsIt != lhs->import_attributes()->cend() && + rhsIt != rhs->import_attributes()->cend(); ++lhsIt, ++rhsIt) { if (int assertion_key_comparison = AstRawString::Compare(lhsIt->first, rhsIt->first)) { @@ -43,9 +43,9 @@ bool SourceTextModuleDescriptor::ModuleRequestComparer::operator()( } } - if (lhs->import_assertions()->size() != rhs->import_assertions()->size()) { - return (lhs->import_assertions()->size() < - rhs->import_assertions()->size()); + if (lhs->import_attributes()->size() != rhs->import_attributes()->size()) { + return (lhs->import_attributes()->size() < + rhs->import_attributes()->size()); } return false; @@ -54,32 +54,32 @@ bool SourceTextModuleDescriptor::ModuleRequestComparer::operator()( void SourceTextModuleDescriptor::AddImport( const AstRawString* import_name, const AstRawString* local_name, const AstRawString* module_request, - const ImportAssertions* import_assertions, const Scanner::Location loc, + const ImportAttributes* import_attributes, const Scanner::Location loc, const Scanner::Location specifier_loc, Zone* zone) { Entry* entry = zone->New(loc); entry->local_name = local_name; entry->import_name = import_name; entry->module_request = - AddModuleRequest(module_request, import_assertions, specifier_loc, zone); + AddModuleRequest(module_request, import_attributes, specifier_loc, zone); AddRegularImport(entry); } void SourceTextModuleDescriptor::AddStarImport( const AstRawString* local_name, const AstRawString* module_request, - const ImportAssertions* import_assertions, const Scanner::Location loc, + const ImportAttributes* import_attributes, const Scanner::Location loc, const Scanner::Location specifier_loc, Zone* zone) { Entry* entry = zone->New(loc); entry->local_name = local_name; entry->module_request = - AddModuleRequest(module_request, import_assertions, specifier_loc, zone); + AddModuleRequest(module_request, import_attributes, specifier_loc, zone); AddNamespaceImport(entry, zone); } void SourceTextModuleDescriptor::AddEmptyImport( const AstRawString* module_request, - const ImportAssertions* import_assertions, + const ImportAttributes* import_attributes, const Scanner::Location specifier_loc, Zone* zone) { - AddModuleRequest(module_request, import_assertions, specifier_loc, zone); + AddModuleRequest(module_request, import_attributes, specifier_loc, zone); } void SourceTextModuleDescriptor::AddExport(const AstRawString* local_name, @@ -94,7 +94,7 @@ void SourceTextModuleDescriptor::AddExport(const AstRawString* local_name, void SourceTextModuleDescriptor::AddExport( const AstRawString* import_name, const AstRawString* export_name, const AstRawString* module_request, - const ImportAssertions* import_assertions, const Scanner::Location loc, + const ImportAttributes* import_attributes, const Scanner::Location loc, const Scanner::Location specifier_loc, Zone* zone) { DCHECK_NOT_NULL(import_name); DCHECK_NOT_NULL(export_name); @@ -102,17 +102,17 @@ void SourceTextModuleDescriptor::AddExport( entry->export_name = export_name; entry->import_name = import_name; entry->module_request = - AddModuleRequest(module_request, import_assertions, specifier_loc, zone); + AddModuleRequest(module_request, import_attributes, specifier_loc, zone); AddSpecialExport(entry, zone); } void SourceTextModuleDescriptor::AddStarExport( const AstRawString* module_request, - const ImportAssertions* import_assertions, const Scanner::Location loc, + const ImportAttributes* import_attributes, const Scanner::Location loc, const Scanner::Location specifier_loc, Zone* zone) { Entry* entry = zone->New(loc); entry->module_request = - AddModuleRequest(module_request, import_assertions, specifier_loc, zone); + AddModuleRequest(module_request, import_attributes, specifier_loc, zone); AddSpecialExport(entry, zone); } @@ -128,28 +128,28 @@ Handle ToStringOrUndefined(IsolateT* isolate, template Handle SourceTextModuleDescriptor::AstModuleRequest::Serialize( IsolateT* isolate) const { - // The import assertions will be stored in this array in the form: + // The import attributes will be stored in this array in the form: // [key1, value1, location1, key2, value2, location2, ...] - Handle import_assertions_array = + Handle import_attributes_array = isolate->factory()->NewFixedArray( - static_cast(import_assertions()->size() * - ModuleRequest::kAssertionEntrySize), + static_cast(import_attributes()->size() * + ModuleRequest::kAttributeEntrySize), AllocationType::kOld); { DisallowGarbageCollection no_gc; - Tagged raw_import_assertions = *import_assertions_array; + Tagged raw_import_attributes = *import_attributes_array; int i = 0; - for (auto iter = import_assertions()->cbegin(); - iter != import_assertions()->cend(); - ++iter, i += ModuleRequest::kAssertionEntrySize) { - raw_import_assertions->set(i, *iter->first->string()); - raw_import_assertions->set(i + 1, *iter->second.first->string()); - raw_import_assertions->set(i + 2, + for (auto iter = import_attributes()->cbegin(); + iter != import_attributes()->cend(); + ++iter, i += ModuleRequest::kAttributeEntrySize) { + raw_import_attributes->set(i, *iter->first->string()); + raw_import_attributes->set(i + 1, *iter->second.first->string()); + raw_import_attributes->set(i + 2, Smi::FromInt(iter->second.second.beg_pos)); } } return v8::internal::ModuleRequest::New(isolate, specifier()->string(), - import_assertions_array, position()); + import_attributes_array, position()); } template Handle SourceTextModuleDescriptor::AstModuleRequest::Serialize(Isolate* isolate) const; diff --git a/deps/v8/src/ast/modules.h b/deps/v8/src/ast/modules.h index f496a0bb85a3c3..02a0bd6a8d3e48 100644 --- a/deps/v8/src/ast/modules.h +++ b/deps/v8/src/ast/modules.h @@ -38,14 +38,14 @@ class SourceTextModuleDescriptor : public ZoneObject { void AddImport(const AstRawString* import_name, const AstRawString* local_name, const AstRawString* module_request, - const ImportAssertions* import_assertions, + const ImportAttributes* import_attributes, const Scanner::Location loc, const Scanner::Location specifier_loc, Zone* zone); // import * as x from "foo.js"; void AddStarImport(const AstRawString* local_name, const AstRawString* module_request, - const ImportAssertions* import_assertions, + const ImportAttributes* import_attributes, const Scanner::Location loc, const Scanner::Location specifier_loc, Zone* zone); @@ -53,7 +53,7 @@ class SourceTextModuleDescriptor : public ZoneObject { // import {} from "foo.js"; // export {} from "foo.js"; (sic!) void AddEmptyImport(const AstRawString* module_request, - const ImportAssertions* import_assertions, + const ImportAttributes* import_attributes, const Scanner::Location specifier_loc, Zone* zone); // export {x}; @@ -70,13 +70,13 @@ class SourceTextModuleDescriptor : public ZoneObject { void AddExport(const AstRawString* export_name, const AstRawString* import_name, const AstRawString* module_request, - const ImportAssertions* import_assertions, + const ImportAttributes* import_attributes, const Scanner::Location loc, const Scanner::Location specifier_loc, Zone* zone); // export * from "foo.js"; void AddStarExport(const AstRawString* module_request, - const ImportAssertions* import_assertions, + const ImportAttributes* import_attributes, const Scanner::Location loc, const Scanner::Location specifier_loc, Zone* zone); @@ -125,10 +125,10 @@ class SourceTextModuleDescriptor : public ZoneObject { class AstModuleRequest : public ZoneObject { public: AstModuleRequest(const AstRawString* specifier, - const ImportAssertions* import_assertions, int position, + const ImportAttributes* import_attributes, int position, int index) : specifier_(specifier), - import_assertions_(import_assertions), + import_attributes_(import_attributes), position_(position), index_(index) {} @@ -136,8 +136,8 @@ class SourceTextModuleDescriptor : public ZoneObject { Handle Serialize(IsolateT* isolate) const; const AstRawString* specifier() const { return specifier_; } - const ImportAssertions* import_assertions() const { - return import_assertions_; + const ImportAttributes* import_attributes() const { + return import_attributes_; } int position() const { return position_; } @@ -145,7 +145,7 @@ class SourceTextModuleDescriptor : public ZoneObject { private: const AstRawString* specifier_; - const ImportAssertions* import_assertions_; + const ImportAttributes* import_attributes_; // The JS source code position of the request, used for reporting errors. int position_; @@ -264,13 +264,13 @@ class SourceTextModuleDescriptor : public ZoneObject { void AssignCellIndices(); int AddModuleRequest(const AstRawString* specifier, - const ImportAssertions* import_assertions, + const ImportAttributes* import_attributes, Scanner::Location specifier_loc, Zone* zone) { DCHECK_NOT_NULL(specifier); int module_requests_count = static_cast(module_requests_.size()); auto it = module_requests_ .insert(zone->New( - specifier, import_assertions, specifier_loc.beg_pos, + specifier, import_attributes, specifier_loc.beg_pos, module_requests_count)) .first; return (*it)->index(); diff --git a/deps/v8/src/ast/prettyprinter.cc b/deps/v8/src/ast/prettyprinter.cc index 5ed4a4fa5b8436..2876beb19e643b 100644 --- a/deps/v8/src/ast/prettyprinter.cc +++ b/deps/v8/src/ast/prettyprinter.cc @@ -256,6 +256,13 @@ void CallPrinter::VisitInitializeClassStaticElementsStatement( void CallPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {} +void CallPrinter::VisitConditionalChain(ConditionalChain* node) { + for (size_t i = 0; i < node->conditional_chain_length(); ++i) { + Find(node->condition_at(i)); + Find(node->then_expression_at(i)); + } + Find(node->else_expression()); +} void CallPrinter::VisitConditional(Conditional* node) { Find(node->condition()); @@ -500,7 +507,7 @@ void CallPrinter::VisitSuperCallForwardArgs(SuperCallForwardArgs* node) { void CallPrinter::VisitUnaryOperation(UnaryOperation* node) { Token::Value op = node->op(); bool needsSpace = - op == Token::DELETE || op == Token::TYPEOF || op == Token::VOID; + op == Token::kDelete || op == Token::kTypeOf || op == Token::kVoid; Print("("); Print(Token::String(op)); if (needsSpace) Print(" "); @@ -572,8 +579,8 @@ void CallPrinter::VisitTemplateLiteral(TemplateLiteral* node) { void CallPrinter::VisitImportCallExpression(ImportCallExpression* node) { Print("ImportCall("); Find(node->specifier(), true); - if (node->import_assertions()) { - Find(node->import_assertions(), true); + if (node->import_options()) { + Find(node->import_options(), true); } Print(")"); } @@ -1176,6 +1183,17 @@ void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) { PrintLiteralIndented("NAME", node->raw_name(), false); } +void AstPrinter::VisitConditionalChain(ConditionalChain* node) { + IndentedScope indent(this, "CONDITIONAL_CHAIN", node->position()); + PrintIndentedVisit("CONDITION", node->condition_at(0)); + PrintIndentedVisit("THEN", node->then_expression_at(0)); + for (size_t i = 1; i < node->conditional_chain_length(); ++i) { + IndentedScope indent(this, "ELSE IF", node->condition_position_at(i)); + PrintIndentedVisit("CONDITION", node->condition_at(i)); + PrintIndentedVisit("THEN", node->then_expression_at(i)); + } + PrintIndentedVisit("ELSE", node->else_expression()); +} void AstPrinter::VisitConditional(Conditional* node) { IndentedScope indent(this, "CONDITIONAL", node->position()); @@ -1471,8 +1489,8 @@ void AstPrinter::VisitTemplateLiteral(TemplateLiteral* node) { void AstPrinter::VisitImportCallExpression(ImportCallExpression* node) { IndentedScope indent(this, "IMPORT-CALL", node->position()); Visit(node->specifier()); - if (node->import_assertions()) { - Visit(node->import_assertions()); + if (node->import_options()) { + Visit(node->import_options()); } } diff --git a/deps/v8/src/ast/scopes.cc b/deps/v8/src/ast/scopes.cc index 6dfcd45cf208e5..581156baf34e6d 100644 --- a/deps/v8/src/ast/scopes.cc +++ b/deps/v8/src/ast/scopes.cc @@ -679,7 +679,7 @@ void DeclarationScope::HoistSloppyBlockFunctions(AstNodeFactory* factory) { DCHECK(is_being_lazily_parsed_); bool was_added; Variable* var = DeclareVariableName(name, VariableMode::kVar, &was_added); - if (sloppy_block_function->init() == Token::ASSIGN) { + if (sloppy_block_function->init() == Token::kAssign) { var->SetMaybeAssigned(); } } @@ -1077,14 +1077,15 @@ Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode, DCHECK(!already_resolved_); // Private methods should be declared with ClassScope::DeclarePrivateName() DCHECK(!IsPrivateMethodOrAccessorVariableMode(mode)); - // This function handles VariableMode::kVar, VariableMode::kLet, and - // VariableMode::kConst modes. VariableMode::kDynamic variables are - // introduced during variable allocation, and VariableMode::kTemporary - // variables are allocated via NewTemporary(). + // This function handles VariableMode::kVar, VariableMode::kLet, + // VariableMode::kConst, and VariableMode::kUsing modes. + // VariableMode::kDynamic variables are introduced during variable allocation, + // and VariableMode::kTemporary variables are allocated via NewTemporary(). DCHECK(IsDeclaredVariableMode(mode)); DCHECK_IMPLIES(GetDeclarationScope()->is_being_lazily_parsed(), mode == VariableMode::kVar || mode == VariableMode::kLet || - mode == VariableMode::kConst); + mode == VariableMode::kConst || + mode == VariableMode::kUsing); DCHECK(!GetDeclarationScope()->was_lazily_parsed()); Variable* var = Declare(zone(), name, mode, kind, init_flag, kNotAssigned, was_added); diff --git a/deps/v8/src/ast/scopes.h b/deps/v8/src/ast/scopes.h index 751aaee3d11ecc..cea379caec837d 100644 --- a/deps/v8/src/ast/scopes.h +++ b/deps/v8/src/ast/scopes.h @@ -486,6 +486,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { switch (scope_type_) { case MODULE_SCOPE: case WITH_SCOPE: // DebugEvaluateContext as well + case SCRIPT_SCOPE: // Side data for const tracking let. return true; default: DCHECK_IMPLIES(sloppy_eval_can_extend_vars_, diff --git a/deps/v8/src/base/bounds.h b/deps/v8/src/base/bounds.h index 143ea82c5788af..85f7bba6896ad0 100644 --- a/deps/v8/src/base/bounds.h +++ b/deps/v8/src/base/bounds.h @@ -25,6 +25,20 @@ inline constexpr bool IsInRange(T value, U lower_limit, U higher_limit) { static_cast(lower_limit)); } +// Like IsInRange but for the half-open range [lower_limit, higher_limit). +template +inline constexpr bool IsInHalfOpenRange(T value, U lower_limit, + U higher_limit) { + DCHECK_LE(lower_limit, higher_limit); + static_assert(sizeof(U) <= sizeof(T)); + using unsigned_T = typename std::make_unsigned::type; + // Use static_cast to support enum classes. + return static_cast(static_cast(value) - + static_cast(lower_limit)) < + static_cast(static_cast(higher_limit) - + static_cast(lower_limit)); +} + // Checks if [index, index+length) is in range [0, max). Note that this check // works even if {index+length} would wrap around. template -#include - -#include "src/base/logging.h" +#include namespace v8 { namespace base { -// Specification: -// http://en.cppreference.com/w/cpp/utility/optional/in_place_t -struct in_place_t {}; - -// Specification: -// http://en.cppreference.com/w/cpp/utility/optional/nullopt_t -struct nullopt_t { - constexpr explicit nullopt_t(int) {} -}; - -// Specification: -// http://en.cppreference.com/w/cpp/utility/optional/in_place -constexpr in_place_t in_place = {}; - -// Specification: -// http://en.cppreference.com/w/cpp/utility/optional/nullopt -constexpr nullopt_t nullopt(0); - -// Forward declaration, which is referred by following helpers. -template -class Optional; - -namespace internal { - -template ::value> -struct OptionalStorageBase { - // Initializing |empty_| here instead of using default member initializing - // to avoid errors in g++ 4.8. - constexpr OptionalStorageBase() : empty_('\0') {} - - template - constexpr explicit OptionalStorageBase(in_place_t, Args&&... args) - : is_populated_(true), value_(std::forward(args)...) {} - - // When T is not trivially destructible we must call its - // destructor before deallocating its memory. - // Note that this hides the (implicitly declared) move constructor, which - // would be used for constexpr move constructor in OptionalStorage. - // It is needed iff T is trivially move constructible. However, the current - // is_trivially_{copy,move}_constructible implementation requires - // is_trivially_destructible (which looks a bug, cf: - // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51452 and - // http://cplusplus.github.io/LWG/lwg-active.html#2116), so it is not - // necessary for this case at the moment. Please see also the destructor - // comment in "is_trivially_destructible = true" specialization below. - ~OptionalStorageBase() { - if (is_populated_) value_.~T(); - } - - template - void Init(Args&&... args) { - DCHECK(!is_populated_); - ::new (&value_) T(std::forward(args)...); - is_populated_ = true; - } - - bool is_populated_ = false; - union { - // |empty_| exists so that the union will always be initialized, even when - // it doesn't contain a value. Union members must be initialized for the - // constructor to be 'constexpr'. - char empty_; - T value_; - }; -}; - -template -struct OptionalStorageBase { - // Initializing |empty_| here instead of using default member initializing - // to avoid errors in g++ 4.8. - constexpr OptionalStorageBase() : empty_('\0') {} - - template - constexpr explicit OptionalStorageBase(in_place_t, Args&&... args) - : is_populated_(true), value_(std::forward(args)...) {} - - // When T is trivially destructible (i.e. its destructor does nothing) there - // is no need to call it. Implicitly defined destructor is trivial, because - // both members (bool and union containing only variants which are trivially - // destructible) are trivially destructible. - // Explicitly-defaulted destructor is also trivial, but do not use it here, - // because it hides the implicit move constructor. It is needed to implement - // constexpr move constructor in OptionalStorage iff T is trivially move - // constructible. Note that, if T is trivially move constructible, the move - // constructor of OptionalStorageBase is also implicitly defined and it is - // trivially move constructor. If T is not trivially move constructible, - // "not declaring move constructor without destructor declaration" here means - // "delete move constructor", which works because any move constructor of - // OptionalStorage will not refer to it in that case. - - template - void Init(Args&&... args) { - DCHECK(!is_populated_); - ::new (&value_) T(std::forward(args)...); - is_populated_ = true; - } - - bool is_populated_ = false; - union { - // |empty_| exists so that the union will always be initialized, even when - // it doesn't contain a value. Union members must be initialized for the - // constructor to be 'constexpr'. - char empty_; - T value_; - }; -}; - -// Implement conditional constexpr copy and move constructors. These are -// constexpr if is_trivially_{copy,move}_constructible::value is true -// respectively. If each is true, the corresponding constructor is defined as -// "= default;", which generates a constexpr constructor (In this case, -// the condition of constexpr-ness is satisfied because the base class also has -// compiler generated constexpr {copy,move} constructors). Note that -// placement-new is prohibited in constexpr. -template ::value, - bool = std::is_trivially_move_constructible::value> -struct OptionalStorage : OptionalStorageBase { - // This is no trivially {copy,move} constructible case. Other cases are - // defined below as specializations. - - // Accessing the members of template base class requires explicit - // declaration. - using OptionalStorageBase::is_populated_; - using OptionalStorageBase::value_; - using OptionalStorageBase::Init; - - // Inherit constructors (specifically, the in_place constructor). - using OptionalStorageBase::OptionalStorageBase; - - // User defined constructor deletes the default constructor. - // Define it explicitly. - OptionalStorage() = default; - - OptionalStorage(const OptionalStorage& other) V8_NOEXCEPT { - if (other.is_populated_) Init(other.value_); - } - - OptionalStorage(OptionalStorage&& other) V8_NOEXCEPT { - if (other.is_populated_) Init(std::move(other.value_)); - } -}; - -template -struct OptionalStorage - : OptionalStorageBase { - using OptionalStorageBase::is_populated_; - using OptionalStorageBase::value_; - using OptionalStorageBase::Init; - using OptionalStorageBase::OptionalStorageBase; - - OptionalStorage() = default; - OptionalStorage(const OptionalStorage& other) V8_NOEXCEPT = default; - - OptionalStorage(OptionalStorage&& other) V8_NOEXCEPT { - if (other.is_populated_) Init(std::move(other.value_)); - } -}; - -template -struct OptionalStorage - : OptionalStorageBase { - using OptionalStorageBase::is_populated_; - using OptionalStorageBase::value_; - using OptionalStorageBase::Init; - using OptionalStorageBase::OptionalStorageBase; - - OptionalStorage() = default; - OptionalStorage(OptionalStorage&& other) V8_NOEXCEPT = default; - - OptionalStorage(const OptionalStorage& other) V8_NOEXCEPT { - if (other.is_populated_) Init(other.value_); - } -}; - -template -struct OptionalStorage - : OptionalStorageBase { - // If both trivially {copy,move} constructible are true, it is not necessary - // to use user-defined constructors. So, just inheriting constructors - // from the base class works. - using OptionalStorageBase::OptionalStorageBase; -}; - -// Base class to support conditionally usable copy-/move- constructors -// and assign operators. +// These aliases are deprecated, use std::optional directly. template -class OptionalBase { - // This class provides implementation rather than public API, so everything - // should be hidden. Often we use composition, but we cannot in this case - // because of C++ language restriction. - protected: - constexpr OptionalBase() = default; - constexpr OptionalBase(const OptionalBase& other) V8_NOEXCEPT = default; - constexpr OptionalBase(OptionalBase&& other) V8_NOEXCEPT = default; - - template - constexpr explicit OptionalBase(in_place_t, Args&&... args) - : storage_(in_place, std::forward(args)...) {} - - // Implementation of converting constructors. - template - explicit OptionalBase(const OptionalBase& other) V8_NOEXCEPT { - if (other.storage_.is_populated_) storage_.Init(other.storage_.value_); - } - - template - explicit OptionalBase(OptionalBase&& other) V8_NOEXCEPT { - if (other.storage_.is_populated_) - storage_.Init(std::move(other.storage_.value_)); - } - - ~OptionalBase() = default; - - OptionalBase& operator=(const OptionalBase& other) V8_NOEXCEPT { - CopyAssign(other); - return *this; - } - - OptionalBase& operator=(OptionalBase&& other) V8_NOEXCEPT { - MoveAssign(std::move(other)); - return *this; - } - - template - void CopyAssign(const OptionalBase& other) { - if (other.storage_.is_populated_) - InitOrAssign(other.storage_.value_); - else - FreeIfNeeded(); - } - - template - void MoveAssign(OptionalBase&& other) { - if (other.storage_.is_populated_) - InitOrAssign(std::move(other.storage_.value_)); - else - FreeIfNeeded(); - } - - template - void InitOrAssign(U&& value) { - if (storage_.is_populated_) - storage_.value_ = std::forward(value); - else - storage_.Init(std::forward(value)); - } - - void FreeIfNeeded() { - if (!storage_.is_populated_) return; - storage_.value_.~T(); - storage_.is_populated_ = false; - } - - // For implementing conversion, allow access to other typed OptionalBase - // class. - template - friend class OptionalBase; - - OptionalStorage storage_; -}; - -// The following {Copy,Move}{Constructible,Assignable} structs are helpers to -// implement constructor/assign-operator overloading. Specifically, if T is -// is not movable but copyable, Optional's move constructor should not -// participate in overload resolution. This inheritance trick implements that. -template -struct CopyConstructible {}; - -template <> -struct CopyConstructible { - constexpr CopyConstructible() = default; - constexpr CopyConstructible(const CopyConstructible&) V8_NOEXCEPT = delete; - constexpr CopyConstructible(CopyConstructible&&) V8_NOEXCEPT = default; - CopyConstructible& operator=(const CopyConstructible&) V8_NOEXCEPT = default; - CopyConstructible& operator=(CopyConstructible&&) V8_NOEXCEPT = default; -}; - -template -struct MoveConstructible {}; - -template <> -struct MoveConstructible { - constexpr MoveConstructible() = default; - constexpr MoveConstructible(const MoveConstructible&) V8_NOEXCEPT = default; - constexpr MoveConstructible(MoveConstructible&&) V8_NOEXCEPT = delete; - MoveConstructible& operator=(const MoveConstructible&) V8_NOEXCEPT = default; - MoveConstructible& operator=(MoveConstructible&&) V8_NOEXCEPT = default; -}; - -template -struct CopyAssignable {}; - -template <> -struct CopyAssignable { - constexpr CopyAssignable() = default; - constexpr CopyAssignable(const CopyAssignable&) V8_NOEXCEPT = default; - constexpr CopyAssignable(CopyAssignable&&) V8_NOEXCEPT = default; - CopyAssignable& operator=(const CopyAssignable&) V8_NOEXCEPT = delete; - CopyAssignable& operator=(CopyAssignable&&) V8_NOEXCEPT = default; -}; - -template -struct MoveAssignable {}; - -template <> -struct MoveAssignable { - constexpr MoveAssignable() = default; - constexpr MoveAssignable(const MoveAssignable&) V8_NOEXCEPT = default; - constexpr MoveAssignable(MoveAssignable&&) V8_NOEXCEPT = default; - MoveAssignable& operator=(const MoveAssignable&) V8_NOEXCEPT = default; - MoveAssignable& operator=(MoveAssignable&&) V8_NOEXCEPT = delete; -}; - -// Helper to conditionally enable converting constructors and assign operators. -template -struct IsConvertibleFromOptional - : std::integral_constant< - bool, std::is_constructible&>::value || - std::is_constructible&>::value || - std::is_constructible&&>::value || - std::is_constructible&&>::value || - std::is_convertible&, T>::value || - std::is_convertible&, T>::value || - std::is_convertible&&, T>::value || - std::is_convertible&&, T>::value> {}; - -template -struct IsAssignableFromOptional - : std::integral_constant< - bool, IsConvertibleFromOptional::value || - std::is_assignable&>::value || - std::is_assignable&>::value || - std::is_assignable&&>::value || - std::is_assignable&&>::value> {}; - -// Forward compatibility for C++17. -// Introduce one more deeper nested namespace to avoid leaking using std::swap. -namespace swappable_impl { -using std::swap; - -struct IsSwappableImpl { - // Tests if swap can be called. Check(0) returns true_type iff swap - // is available for T. Otherwise, Check's overload resolution falls back - // to Check(...) declared below thanks to SFINAE, so returns false_type. - template - static auto Check(int i) - -> decltype(swap(std::declval(), std::declval()), std::true_type()); - - template - static std::false_type Check(...); -}; -} // namespace swappable_impl - -template -struct IsSwappable : decltype(swappable_impl::IsSwappableImpl::Check(0)) {}; - -// Forward compatibility for C++20. -template -using RemoveCvRefT = - typename std::remove_cv::type>::type; - -} // namespace internal - -// On Windows, by default, empty-base class optimization does not work, -// which means even if the base class is empty struct, it still consumes one -// byte for its body. __declspec(empty_bases) enables the optimization. -// cf) -// https://blogs.msdn.microsoft.com/vcblog/2016/03/30/optimizing-the-layout-of-empty-base-classes-in-vs2015-update-2-3/ -#ifdef OS_WIN -#define OPTIONAL_DECLSPEC_EMPTY_BASES __declspec(empty_bases) -#else -#define OPTIONAL_DECLSPEC_EMPTY_BASES -#endif - -// base::Optional is a Chromium version of the C++17 optional class: -// std::optional documentation: -// http://en.cppreference.com/w/cpp/utility/optional -// Chromium documentation: -// https://chromium.googlesource.com/chromium/src/+/master/docs/optional.md -// -// These are the differences between the specification and the implementation: -// - Constructors do not use 'constexpr' as it is a C++14 extension. -// - 'constexpr' might be missing in some places for reasons specified locally. -// - No exceptions are thrown, because they are banned from Chromium. -// All copy/move constructors or assignment operators are marked V8_NOEXCEPT. -// - All the non-members are in the 'base' namespace instead of 'std'. -// -// Note that T cannot have a constructor T(Optional) etc. Optional checks -// T's constructor (specifically via IsConvertibleFromOptional), and in the -// check whether T can be constructible from Optional, which is recursive -// so it does not work. As of Feb 2018, std::optional C++17 implementation in -// both clang and gcc has same limitation. MSVC SFINAE looks to have different -// behavior, but anyway it reports an error, too. -template -class OPTIONAL_DECLSPEC_EMPTY_BASES Optional - : public internal::OptionalBase, - public internal::CopyConstructible::value>, - public internal::MoveConstructible::value>, - public internal::CopyAssignable::value && - std::is_copy_assignable::value>, - public internal::MoveAssignable::value && - std::is_move_assignable::value> { - public: -#undef OPTIONAL_DECLSPEC_EMPTY_BASES - using value_type = T; - - // Defer default/copy/move constructor implementation to OptionalBase. - constexpr Optional() = default; - constexpr Optional(const Optional& other) V8_NOEXCEPT = default; - constexpr Optional(Optional&& other) V8_NOEXCEPT = default; - - constexpr Optional(nullopt_t) {} // NOLINT(runtime/explicit) - - // Converting copy constructor. "explicit" only if - // std::is_convertible::value is false. It is implemented by - // declaring two almost same constructors, but that condition in enable_if - // is different, so that either one is chosen, thanks to SFINAE. - template ::value && - !internal::IsConvertibleFromOptional::value && - std::is_convertible::value, - bool>::type = false> - Optional(const Optional& other) V8_NOEXCEPT - : internal::OptionalBase(other) {} - - template ::value && - !internal::IsConvertibleFromOptional::value && - !std::is_convertible::value, - bool>::type = false> - explicit Optional(const Optional& other) V8_NOEXCEPT - : internal::OptionalBase(other) {} - - // Converting move constructor. Similar to converting copy constructor, - // declaring two (explicit and non-explicit) constructors. - template ::value && - !internal::IsConvertibleFromOptional::value && - std::is_convertible::value, - bool>::type = false> - Optional(Optional&& other) V8_NOEXCEPT - : internal::OptionalBase(std::move(other)) {} - - template ::value && - !internal::IsConvertibleFromOptional::value && - !std::is_convertible::value, - bool>::type = false> - explicit Optional(Optional&& other) V8_NOEXCEPT - : internal::OptionalBase(std::move(other)) {} - - template - constexpr explicit Optional(in_place_t, Args&&... args) - : internal::OptionalBase(in_place, std::forward(args)...) {} - - template &, Args...>::value>::type> - constexpr explicit Optional(in_place_t, std::initializer_list il, - Args&&... args) - : internal::OptionalBase(in_place, il, std::forward(args)...) {} - - // Forward value constructor. Similar to converting constructors, - // conditionally explicit. - template < - typename U = value_type, - typename std::enable_if< - std::is_constructible::value && - !std::is_same, in_place_t>::value && - !std::is_same, Optional>::value && - std::is_convertible::value, - bool>::type = false> - constexpr Optional(U&& value) // NOLINT(runtime/explicit) - : internal::OptionalBase(in_place, std::forward(value)) {} - - template < - typename U = value_type, - typename std::enable_if< - std::is_constructible::value && - !std::is_same, in_place_t>::value && - !std::is_same, Optional>::value && - !std::is_convertible::value, - bool>::type = false> - constexpr explicit Optional(U&& value) - : internal::OptionalBase(in_place, std::forward(value)) {} - - ~Optional() = default; - - // Defer copy-/move- assign operator implementation to OptionalBase. - Optional& operator=(const Optional& other) V8_NOEXCEPT = default; - Optional& operator=(Optional&& other) V8_NOEXCEPT = default; - - Optional& operator=(nullopt_t) { - FreeIfNeeded(); - return *this; - } - - // Perfect-forwarded assignment. - template - typename std::enable_if< - !std::is_same, Optional>::value && - std::is_constructible::value && - std::is_assignable::value && - (!std::is_scalar::value || - !std::is_same::type, T>::value), - Optional&>::type - operator=(U&& value) V8_NOEXCEPT { - InitOrAssign(std::forward(value)); - return *this; - } - - // Copy assign the state of other. - template - typename std::enable_if::value && - std::is_constructible::value && - std::is_assignable::value, - Optional&>::type - operator=(const Optional& other) V8_NOEXCEPT { - CopyAssign(other); - return *this; - } - - // Move assign the state of other. - template - typename std::enable_if::value && - std::is_constructible::value && - std::is_assignable::value, - Optional&>::type - operator=(Optional&& other) V8_NOEXCEPT { - MoveAssign(std::move(other)); - return *this; - } - - constexpr const T* operator->() const { - DCHECK(storage_.is_populated_); - return &storage_.value_; - } - - constexpr T* operator->() { - DCHECK(storage_.is_populated_); - return &storage_.value_; - } - - constexpr const T& operator*() const& { - DCHECK(storage_.is_populated_); - return storage_.value_; - } - - constexpr T& operator*() & { - DCHECK(storage_.is_populated_); - return storage_.value_; - } - - constexpr const T&& operator*() const&& { - DCHECK(storage_.is_populated_); - return std::move(storage_.value_); - } - - constexpr T&& operator*() && { - DCHECK(storage_.is_populated_); - return std::move(storage_.value_); - } - - constexpr explicit operator bool() const { return storage_.is_populated_; } - - constexpr bool has_value() const { return storage_.is_populated_; } - - T& value() & { - CHECK(storage_.is_populated_); - return storage_.value_; - } - - const T& value() const & { - CHECK(storage_.is_populated_); - return storage_.value_; - } - - T&& value() && { - CHECK(storage_.is_populated_); - return std::move(storage_.value_); - } - - const T&& value() const && { - CHECK(storage_.is_populated_); - return std::move(storage_.value_); - } - - template - constexpr T value_or(U&& default_value) const & { - // TODO(mlamouri): add the following assert when possible: - // static_assert(std::is_copy_constructible::value, - // "T must be copy constructible"); - static_assert(std::is_convertible::value, - "U must be convertible to T"); - return storage_.is_populated_ - ? storage_.value_ - : static_cast(std::forward(default_value)); - } - - template - constexpr T value_or(U&& default_value) && { - // TODO(mlamouri): add the following assert when possible: - // static_assert(std::is_move_constructible::value, - // "T must be move constructible"); - static_assert(std::is_convertible::value, - "U must be convertible to T"); - return storage_.is_populated_ - ? std::move(storage_.value_) - : static_cast(std::forward(default_value)); - } - - void swap(Optional& other) { - if (!storage_.is_populated_ && !other.storage_.is_populated_) return; - - if (storage_.is_populated_ != other.storage_.is_populated_) { - if (storage_.is_populated_) { - other.storage_.Init(std::move(storage_.value_)); - FreeIfNeeded(); - } else { - storage_.Init(std::move(other.storage_.value_)); - other.FreeIfNeeded(); - } - return; - } - - DCHECK(storage_.is_populated_ && other.storage_.is_populated_); - using std::swap; - swap(**this, *other); - } - - void reset() { FreeIfNeeded(); } - - template - T& emplace(Args&&... args) { - FreeIfNeeded(); - storage_.Init(std::forward(args)...); - return storage_.value_; - } - - template - typename std::enable_if< - std::is_constructible&, Args&&...>::value, - T&>::type - emplace(std::initializer_list il, Args&&... args) { - FreeIfNeeded(); - storage_.Init(il, std::forward(args)...); - return storage_.value_; - } - - private: - // Accessing template base class's protected member needs explicit - // declaration to do so. - using internal::OptionalBase::CopyAssign; - using internal::OptionalBase::FreeIfNeeded; - using internal::OptionalBase::InitOrAssign; - using internal::OptionalBase::MoveAssign; - using internal::OptionalBase::storage_; -}; - -// Here after defines comparation operators. The definition follows -// http://en.cppreference.com/w/cpp/utility/optional/operator_cmp -// while bool() casting is replaced by has_value() to meet the chromium -// style guide. -template -bool operator==(const Optional& lhs, const Optional& rhs) { - if (lhs.has_value() != rhs.has_value()) return false; - if (!lhs.has_value()) return true; - return *lhs == *rhs; -} - -template -bool operator!=(const Optional& lhs, const Optional& rhs) { - if (lhs.has_value() != rhs.has_value()) return true; - if (!lhs.has_value()) return false; - return *lhs != *rhs; -} - -template -bool operator<(const Optional& lhs, const Optional& rhs) { - if (!rhs.has_value()) return false; - if (!lhs.has_value()) return true; - return *lhs < *rhs; -} - -template -bool operator<=(const Optional& lhs, const Optional& rhs) { - if (!lhs.has_value()) return true; - if (!rhs.has_value()) return false; - return *lhs <= *rhs; -} - -template -bool operator>(const Optional& lhs, const Optional& rhs) { - if (!lhs.has_value()) return false; - if (!rhs.has_value()) return true; - return *lhs > *rhs; -} - -template -bool operator>=(const Optional& lhs, const Optional& rhs) { - if (!rhs.has_value()) return true; - if (!lhs.has_value()) return false; - return *lhs >= *rhs; -} - -template -constexpr bool operator==(const Optional& opt, nullopt_t) { - return !opt; -} - -template -constexpr bool operator==(nullopt_t, const Optional& opt) { - return !opt; -} - -template -constexpr bool operator!=(const Optional& opt, nullopt_t) { - return opt.has_value(); -} - -template -constexpr bool operator!=(nullopt_t, const Optional& opt) { - return opt.has_value(); -} - -template -constexpr bool operator<(const Optional& opt, nullopt_t) { - return false; -} - -template -constexpr bool operator<(nullopt_t, const Optional& opt) { - return opt.has_value(); -} - -template -constexpr bool operator<=(const Optional& opt, nullopt_t) { - return !opt; -} - -template -constexpr bool operator<=(nullopt_t, const Optional& opt) { - return true; -} - -template -constexpr bool operator>(const Optional& opt, nullopt_t) { - return opt.has_value(); -} - -template -constexpr bool operator>(nullopt_t, const Optional& opt) { - return false; -} - -template -constexpr bool operator>=(const Optional& opt, nullopt_t) { - return true; -} - -template -constexpr bool operator>=(nullopt_t, const Optional& opt) { - return !opt; -} - -template -constexpr bool operator==(const Optional& opt, const U& value) { - return opt.has_value() ? *opt == value : false; -} - -template -constexpr bool operator==(const U& value, const Optional& opt) { - return opt.has_value() ? value == *opt : false; -} - -template -constexpr bool operator!=(const Optional& opt, const U& value) { - return opt.has_value() ? *opt != value : true; -} - -template -constexpr bool operator!=(const U& value, const Optional& opt) { - return opt.has_value() ? value != *opt : true; -} - -template -constexpr bool operator<(const Optional& opt, const U& value) { - return opt.has_value() ? *opt < value : true; -} - -template -constexpr bool operator<(const U& value, const Optional& opt) { - return opt.has_value() ? value < *opt : false; -} - -template -constexpr bool operator<=(const Optional& opt, const U& value) { - return opt.has_value() ? *opt <= value : true; -} - -template -constexpr bool operator<=(const U& value, const Optional& opt) { - return opt.has_value() ? value <= *opt : false; -} - -template -constexpr bool operator>(const Optional& opt, const U& value) { - return opt.has_value() ? *opt > value : false; -} - -template -constexpr bool operator>(const U& value, const Optional& opt) { - return opt.has_value() ? value > *opt : true; -} - -template -constexpr bool operator>=(const Optional& opt, const U& value) { - return opt.has_value() ? *opt >= value : false; -} - -template -constexpr bool operator>=(const U& value, const Optional& opt) { - return opt.has_value() ? value >= *opt : true; -} - -template -constexpr Optional::type> make_optional(T&& value) { - return Optional::type>(std::forward(value)); -} - -template -constexpr Optional make_optional(Args&&... args) { - return Optional(in_place, std::forward(args)...); -} - -template -constexpr Optional make_optional(std::initializer_list il, - Args&&... args) { - return Optional(in_place, il, std::forward(args)...); -} +using Optional [[deprecated]] = std::optional; -// Partial specialization for a function template is not allowed. Also, it is -// not allowed to add overload function to std namespace, while it is allowed -// to specialize the template in std. Thus, swap() (kind of) overloading is -// defined in base namespace, instead. -template -typename std::enable_if::value && - internal::IsSwappable::value>::type -swap(Optional& lhs, Optional& rhs) { - lhs.swap(rhs); -} +using std::in_place; +using std::make_optional; +using std::nullopt; +using std::nullopt_t; } // namespace base } // namespace v8 diff --git a/deps/v8/src/base/platform/condition-variable.cc b/deps/v8/src/base/platform/condition-variable.cc index b7b21c99473b36..7c5d8f7f27a4c8 100644 --- a/deps/v8/src/base/platform/condition-variable.cc +++ b/deps/v8/src/base/platform/condition-variable.cc @@ -190,7 +190,7 @@ void ConditionVariable::Wait(Mutex* mutex) { } bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { - SbTime microseconds = static_cast(rel_time.InMicroseconds()); + int64_t microseconds = static_cast(rel_time.InMicroseconds()); SbConditionVariableResult result = SbConditionVariableWaitTimed( &native_handle_, &mutex->native_handle(), microseconds); DCHECK(result != kSbConditionVariableFailed); diff --git a/deps/v8/src/base/platform/memory.h b/deps/v8/src/base/platform/memory.h index 48b0d70ec16b88..77e3fe9d4d9acc 100644 --- a/deps/v8/src/base/platform/memory.h +++ b/deps/v8/src/base/platform/memory.h @@ -83,8 +83,6 @@ inline void* AlignedAlloc(size_t size, size_t alignment) { // posix_memalign is not exposed in some Android versions, so we fall back to // memalign. See http://code.google.com/p/android/issues/detail?id=35391. return memalign(alignment, size); -#elif V8_OS_STARBOARD - return SbMemoryAllocateAligned(alignment, size); #else // POSIX void* ptr; if (posix_memalign(&ptr, alignment, size)) ptr = nullptr; @@ -95,8 +93,6 @@ inline void* AlignedAlloc(size_t size, size_t alignment) { inline void AlignedFree(void* ptr) { #if V8_OS_WIN _aligned_free(ptr); -#elif V8_OS_STARBOARD - SbMemoryFreeAligned(ptr); #else // Using regular Free() is not correct in general. For most platforms, // including V8_LIBC_BIONIC, it is though. diff --git a/deps/v8/src/base/platform/platform-posix.cc b/deps/v8/src/base/platform/platform-posix.cc index 116ba4f9d9fda8..529a073040af1f 100644 --- a/deps/v8/src/base/platform/platform-posix.cc +++ b/deps/v8/src/base/platform/platform-posix.cc @@ -967,6 +967,7 @@ void OS::PrintError(const char* format, ...) { va_start(args, format); VPrintError(format, args); va_end(args); + fflush(stderr); } diff --git a/deps/v8/src/base/platform/platform-starboard.cc b/deps/v8/src/base/platform/platform-starboard.cc index 1550a214d8c1c6..af257a2d00081c 100644 --- a/deps/v8/src/base/platform/platform-starboard.cc +++ b/deps/v8/src/base/platform/platform-starboard.cc @@ -6,6 +6,9 @@ // abstraction layer for Cobalt, an HTML5 container used mainly by YouTube // apps in the living room. +#include +#include + #include "src/base/lazy-instance.h" #include "src/base/macros.h" #include "src/base/platform/platform.h" @@ -16,10 +19,9 @@ #include "starboard/common/condition_variable.h" #include "starboard/common/log.h" #include "starboard/common/string.h" +#include "starboard/common/time.h" #include "starboard/configuration.h" #include "starboard/configuration_constants.h" -#include "starboard/memory.h" -#include "starboard/time.h" #include "starboard/time_zone.h" namespace v8 { @@ -82,18 +84,11 @@ void OS::Initialize(AbortMode abort_mode, const char* const gc_fake_mmap) { } int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { -#if SB_API_VERSION >= 12 - if (!SbTimeIsTimeThreadNowSupported()) return -1; -#endif - -#if SB_API_VERSION >= 12 || SB_HAS(TIME_THREAD_NOW) - SbTimeMonotonic thread_now = SbTimeGetMonotonicThreadNow(); - *secs = thread_now / kSbTimeSecond; - *usecs = thread_now % kSbTimeSecond; + const int64_t us_time = starboard::CurrentMonotonicThreadTime(); + if (us_time == 0) return -1; + *secs = us_time / TimeConstants::kMicroSecondsPerSecond; + *usecs = us_time % TimeConstants::kMicroSecondsPerSecond; return 0; -#else - return -1; -#endif } double OS::TimeCurrentMillis() { return Time::Now().ToJsTime(); } @@ -130,13 +125,13 @@ void OS::SetRandomMmapSeed(int64_t seed) { SB_NOTIMPLEMENTED(); } void* OS::GetRandomMmapAddr() { return nullptr; } void* Allocate(void* address, size_t size, OS::MemoryPermission access) { - SbMemoryMapFlags sb_flags; + int prot_flags; switch (access) { case OS::MemoryPermission::kNoAccess: - sb_flags = SbMemoryMapFlags(0); + prot_flags = PROT_NONE; break; case OS::MemoryPermission::kReadWrite: - sb_flags = SbMemoryMapFlags(kSbMemoryMapProtectReadWrite); + prot_flags = PROT_READ | PROT_WRITE; break; default: SB_LOG(ERROR) << "The requested memory allocation access is not" @@ -144,8 +139,8 @@ void* Allocate(void* address, size_t size, OS::MemoryPermission access) { << static_cast(access); return nullptr; } - void* result = SbMemoryMap(size, sb_flags, "v8::Base::Allocate"); - if (result == SB_MEMORY_MAP_FAILED) { + void* result = mmap(nullptr, size, prot_flags, MAP_PRIVATE | MAP_ANON, -1, 0); + if (result == MAP_FAILED) { return nullptr; } return result; @@ -188,30 +183,29 @@ void* OS::Allocate(void* address, size_t size, size_t alignment, // static void OS::Free(void* address, const size_t size) { - CHECK(SbMemoryUnmap(address, size)); + CHECK_EQ(munmap(address, size), 0); } // static void OS::Release(void* address, size_t size) { - CHECK(SbMemoryUnmap(address, size)); + CHECK_EQ(munmap(address, size), 0); } // static bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) { - SbMemoryMapFlags new_protection; + int new_protection; switch (access) { case OS::MemoryPermission::kNoAccess: - new_protection = SbMemoryMapFlags(0); + new_protection = PROT_NONE; break; case OS::MemoryPermission::kRead: - new_protection = SbMemoryMapFlags(kSbMemoryMapProtectRead); + new_protection = PROT_READ; case OS::MemoryPermission::kReadWrite: - new_protection = SbMemoryMapFlags(kSbMemoryMapProtectReadWrite); + new_protection = PROT_READ | PROT_WRITE; break; case OS::MemoryPermission::kReadExecute: #if SB_CAN(MAP_EXECUTABLE_MEMORY) - new_protection = - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectExec); + new_protection = PROT_READ | PROT_EXEC; #else UNREACHABLE(); #endif @@ -220,7 +214,7 @@ bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) { // All other types are not supported by Starboard. return false; } - return SbMemoryProtect(address, size, new_protection); + return mprotect(address, size, new_protection) == 0; } // static @@ -348,7 +342,7 @@ int OS::SNPrintF(char* str, int length, const char* format, ...) { } int OS::VSNPrintF(char* str, int length, const char* format, va_list args) { - int n = SbStringFormat(str, length, format, args); + int n = vsnprintf(str, length, format, args); if (n < 0 || n >= length) { // If the length is zero, the assignment fails. if (length > 0) str[length - 1] = '\0'; @@ -363,7 +357,7 @@ int OS::VSNPrintF(char* str, int length, const char* format, va_list args) { // void OS::StrNCpy(char* dest, int length, const char* src, size_t n) { - SbStringCopy(dest, src, n); + strncpy(dest, src, n); } // ---------------------------------------------------------------------------- @@ -448,14 +442,18 @@ class StarboardDefaultTimezoneCache : public StarboardTimezoneCache { return SbTimeZoneGetName(); } double LocalTimeOffset(double time_ms, bool is_utc) override { - // SbTimeZOneGetCurrent returns an offset west of Greenwich, which has the + // SbTimeZoneGetCurrent returns an offset west of Greenwich, which has the // opposite sign V8 expects. // The starboard function returns offset in minutes. We convert to return // value in milliseconds. return SbTimeZoneGetCurrent() * 60.0 * msPerSecond * (-1); } double DaylightSavingsOffset(double time_ms) override { - EzTimeValue value = EzTimeValueFromSbTime(SbTimeGetNow()); + int64_t posix_microseconds = starboard::CurrentPosixTime(); + EzTimeValue value = { + posix_microseconds / TimeConstants::kMicroSecondsPerSecond, + (int32_t)(posix_microseconds % TimeConstants::kMicroSecondsPerSecond) + }; EzTimeExploded ez_exploded; bool result = EzTimeValueExplode(&value, kEzTimeZoneLocal, &ez_exploded, NULL); @@ -489,6 +487,12 @@ bool OS::DiscardSystemPages(void* address, size_t size) { return true; } +// static +Stack::StackSlot Stack::GetStackStart() { + SB_NOTIMPLEMENTED(); + return nullptr; +} + // static Stack::StackSlot Stack::GetCurrentStackPosition() { void* addresses[kStackSize]; diff --git a/deps/v8/src/base/platform/platform-win32.cc b/deps/v8/src/base/platform/platform-win32.cc index a5558c738ba839..c23b399e091dc4 100644 --- a/deps/v8/src/base/platform/platform-win32.cc +++ b/deps/v8/src/base/platform/platform-win32.cc @@ -702,6 +702,7 @@ void OS::PrintError(const char* format, ...) { va_start(args, format); VPrintError(format, args); va_end(args); + fflush(stderr); } diff --git a/deps/v8/src/base/platform/semaphore.cc b/deps/v8/src/base/platform/semaphore.cc index 3e9f6334d9c4c3..2ac431dbf60b98 100644 --- a/deps/v8/src/base/platform/semaphore.cc +++ b/deps/v8/src/base/platform/semaphore.cc @@ -170,7 +170,7 @@ void Semaphore::Signal() { native_handle_.Put(); } void Semaphore::Wait() { native_handle_.Take(); } bool Semaphore::WaitFor(const TimeDelta& rel_time) { - SbTime microseconds = rel_time.InMicroseconds(); + int64_t microseconds = rel_time.InMicroseconds(); return native_handle_.TakeWait(microseconds); } diff --git a/deps/v8/src/base/platform/time.cc b/deps/v8/src/base/platform/time.cc index b6da0a690c0e14..dda0823c6597b5 100644 --- a/deps/v8/src/base/platform/time.cc +++ b/deps/v8/src/base/platform/time.cc @@ -22,6 +22,10 @@ #include #endif +#if V8_OS_STARBOARD +#include +#endif // V8_OS_STARBOARD + #include #include @@ -41,7 +45,7 @@ #include "src/base/platform/platform.h" #if V8_OS_STARBOARD -#include "starboard/time.h" +#include "starboard/common/time.h" #endif namespace { @@ -402,7 +406,7 @@ FILETIME Time::ToFiletime() const { return ft; } -#elif V8_OS_POSIX +#elif V8_OS_POSIX || V8_OS_STARBOARD Time Time::Now() { struct timeval tv; @@ -482,13 +486,7 @@ struct timeval Time::ToTimeval() const { return tv; } -#elif V8_OS_STARBOARD - -Time Time::Now() { return Time(SbTimeToPosix(SbTimeGetNow())); } - -Time Time::NowFromSystemTime() { return Now(); } - -#endif // V8_OS_STARBOARD +#endif // V8_OS_POSIX || V8_OS_STARBOARD Time Time::FromJsTime(double ms_since_epoch) { // The epoch is a valid time, so this constructor doesn't interpret @@ -753,7 +751,7 @@ TimeTicks TimeTicks::Now() { #elif V8_OS_POSIX ticks = ClockNow(CLOCK_MONOTONIC); #elif V8_OS_STARBOARD - ticks = SbTimeGetMonotonicNow(); + ticks = starboard::CurrentMonotonicTime(); #else #error platform does not implement TimeTicks::Now. #endif // V8_OS_DARWIN @@ -780,13 +778,7 @@ bool TimeTicks::IsHighResolution() { bool ThreadTicks::IsSupported() { #if V8_OS_STARBOARD -#if SB_API_VERSION >= 12 - return SbTimeIsTimeThreadNowSupported(); -#elif SB_HAS(TIME_THREAD_NOW) - return true; -#else - return false; -#endif + return starboard::CurrentMonotonicThreadTime() != 0; #elif defined(__PASE__) // Thread CPU time accounting is unavailable in PASE return false; @@ -803,15 +795,10 @@ bool ThreadTicks::IsSupported() { ThreadTicks ThreadTicks::Now() { #if V8_OS_STARBOARD -#if SB_API_VERSION >= 12 - if (SbTimeIsTimeThreadNowSupported()) - return ThreadTicks(SbTimeGetMonotonicThreadNow()); - UNREACHABLE(); -#elif SB_HAS(TIME_THREAD_NOW) - return ThreadTicks(SbTimeGetMonotonicThreadNow()); -#else + const int64_t now = starboard::CurrentMonotonicThreadTime(); + if (now != 0) + return ThreadTicks(now); UNREACHABLE(); -#endif #elif V8_OS_DARWIN return ThreadTicks(ComputeThreadTicks()); #elif V8_OS_FUCHSIA diff --git a/deps/v8/src/baseline/baseline-compiler.cc b/deps/v8/src/baseline/baseline-compiler.cc index 30b371264dc132..58ea23043da452 100644 --- a/deps/v8/src/baseline/baseline-compiler.cc +++ b/deps/v8/src/baseline/baseline-compiler.cc @@ -422,6 +422,9 @@ Tagged BaselineCompiler::IndexAsSmi(int operand_index) { Tagged BaselineCompiler::IntAsSmi(int operand_index) { return Smi::FromInt(Int(operand_index)); } +Tagged BaselineCompiler::UintAsSmi(int operand_index) { + return Smi::FromInt(Uint(operand_index)); +} Tagged BaselineCompiler::Flag8AsSmi(int operand_index) { return Smi::FromInt(Flag8(operand_index)); } @@ -647,6 +650,8 @@ constexpr static bool BuiltinMayDeopt(Builtin id) { case Builtin::kBaselineOutOfLinePrologue: case Builtin::kIncBlockCounter: case Builtin::kToObject: + case Builtin::kStoreScriptContextSlotBaseline: + case Builtin::kStoreCurrentScriptContextSlotBaseline: // This one explicitly skips the construct if the debugger is enabled. case Builtin::kFindNonDefaultConstructorOrConstruct: return false; @@ -812,6 +817,30 @@ void BaselineCompiler::VisitStaCurrentContextSlot() { context, Context::OffsetOfElementAt(Index(0)), value); } +void BaselineCompiler::VisitStaScriptContextSlot() { + Register value = WriteBarrierDescriptor::ValueRegister(); + Register context = WriteBarrierDescriptor::ObjectRegister(); + DCHECK(!AreAliased(value, context, kInterpreterAccumulatorRegister)); + __ Move(value, kInterpreterAccumulatorRegister); + LoadRegister(context, 0); + SaveAccumulatorScope accumulator_scope(this, &basm_); + CallBuiltin( + context, // context + value, // value + IndexAsSmi(1), // slot + UintAsTagged(2)); // depth +} + +void BaselineCompiler::VisitStaCurrentScriptContextSlot() { + Register value = WriteBarrierDescriptor::ValueRegister(); + DCHECK(!AreAliased(value, kInterpreterAccumulatorRegister)); + SaveAccumulatorScope accumulator_scope(this, &basm_); + __ Move(value, kInterpreterAccumulatorRegister); + CallBuiltin( + value, // value + IndexAsSmi(0)); // slot +} + void BaselineCompiler::VisitLdaLookupSlot() { CallRuntime(Runtime::kLoadLookupSlot, Constant(0)); } diff --git a/deps/v8/src/baseline/baseline-compiler.h b/deps/v8/src/baseline/baseline-compiler.h index 17e996d5328cd6..c06fdafddf44c9 100644 --- a/deps/v8/src/baseline/baseline-compiler.h +++ b/deps/v8/src/baseline/baseline-compiler.h @@ -91,6 +91,7 @@ class BaselineCompiler { Tagged UintAsTagged(int operand_index); Tagged IndexAsSmi(int operand_index); Tagged IntAsSmi(int operand_index); + Tagged UintAsSmi(int operand_index); Tagged Flag8AsSmi(int operand_index); Tagged Flag16AsSmi(int operand_index); diff --git a/deps/v8/src/builtins/accessors.cc b/deps/v8/src/builtins/accessors.cc index a0f35d99b096c1..a85d738681745c 100644 --- a/deps/v8/src/builtins/accessors.cc +++ b/deps/v8/src/builtins/accessors.cc @@ -151,7 +151,8 @@ void Accessors::ArrayLengthGetter( RCS_SCOPE(isolate, RuntimeCallCounterId::kArrayLengthGetter); DisallowGarbageCollection no_gc; HandleScope scope(isolate); - Tagged holder = JSArray::cast(*Utils::OpenHandle(*info.Holder())); + Tagged holder = + JSArray::cast(*Utils::OpenDirectHandle(*info.Holder())); Tagged result = holder->length(); info.GetReturnValue().Set(Utils::ToLocal(Handle(result, isolate))); } @@ -163,7 +164,7 @@ void Accessors::ArrayLengthSetter( RCS_SCOPE(isolate, RuntimeCallCounterId::kArrayLengthSetter); HandleScope scope(isolate); - DCHECK(Object::SameValue(*Utils::OpenHandle(*name), + DCHECK(Object::SameValue(*Utils::OpenDirectHandle(*name), ReadOnlyRoots(isolate).length_string())); Handle object = Utils::OpenHandle(*info.Holder()); @@ -233,7 +234,7 @@ void Accessors::ModuleNamespaceEntryGetter( i::Isolate* isolate = reinterpret_cast(info.GetIsolate()); HandleScope scope(isolate); Tagged holder = - JSModuleNamespace::cast(*Utils::OpenHandle(*info.Holder())); + JSModuleNamespace::cast(*Utils::OpenDirectHandle(*info.Holder())); Handle result; if (holder->GetExport(isolate, Handle::cast(Utils::OpenHandle(*name))) .ToHandle(&result)) { @@ -281,12 +282,13 @@ void Accessors::StringLengthGetter( // v8::Object, but internally we have callbacks on entities which are higher // in the hierarchy, in this case for String values. - Tagged value = *Utils::OpenHandle(*v8::Local(info.This())); + Tagged value = + *Utils::OpenDirectHandle(*v8::Local(info.This())); if (!IsString(value)) { // Not a string value. That means that we either got a String wrapper or // a Value with a String wrapper in its prototype chain. - value = - JSPrimitiveWrapper::cast(*Utils::OpenHandle(*info.Holder()))->value(); + value = JSPrimitiveWrapper::cast(*Utils::OpenDirectHandle(*info.Holder())) + ->value(); } Tagged result = Smi::FromInt(String::cast(value)->length()); info.GetReturnValue().Set(Utils::ToLocal(Handle(result, isolate))); diff --git a/deps/v8/src/builtins/arm/builtins-arm.cc b/deps/v8/src/builtins/arm/builtins-arm.cc index 2adb7dd73173fc..79124bd196a57f 100644 --- a/deps/v8/src/builtins/arm/builtins-arm.cc +++ b/deps/v8/src/builtins/arm/builtins-arm.cc @@ -930,7 +930,7 @@ void ResetFeedbackVectorOsrUrgency(MacroAssembler* masm, void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) { UseScratchRegisterScope temps(masm); // Need a few extra registers - temps.Include({r4, r8, r9}); + temps.Include({r4, r5, r8, r9}); auto descriptor = Builtins::CallInterfaceDescriptorFor(Builtin::kBaselineOutOfLinePrologue); @@ -943,7 +943,11 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) { FieldMemOperand(closure, JSFunction::kFeedbackCellOffset)); __ ldr(feedback_vector, FieldMemOperand(feedback_cell, FeedbackCell::kValueOffset)); - __ AssertFeedbackVector(feedback_vector); + { + UseScratchRegisterScope temps(masm); + Register temporary = temps.Acquire(); + __ AssertFeedbackVector(feedback_vector, temporary); + } // Check the tiering state. Label flags_need_processing; diff --git a/deps/v8/src/builtins/arm64/builtins-arm64.cc b/deps/v8/src/builtins/arm64/builtins-arm64.cc index 8221c3a6c3f6c7..5c607660fb913a 100644 --- a/deps/v8/src/builtins/arm64/builtins-arm64.cc +++ b/deps/v8/src/builtins/arm64/builtins-arm64.cc @@ -491,9 +491,8 @@ static void GetSharedFunctionInfoBytecodeOrBaseline( &done); } - __ LoadTrustedPointerField( - bytecode, FieldMemOperand(data, InterpreterData::kBytecodeArrayOffset), - kBytecodeArrayIndirectPointerTag); + __ LoadProtectedPointerField( + bytecode, FieldMemOperand(data, InterpreterData::kBytecodeArrayOffset)); __ Bind(&done); __ IsObjectType(bytecode, scratch1, scratch1, BYTECODE_ARRAY_TYPE); @@ -1557,7 +1556,7 @@ void Builtins::Generate_InterpreterEntryTrampoline( __ Move(x2, kInterpreterBytecodeArrayRegister); static_assert(kJavaScriptCallCodeStartRegister == x2, "ABI mismatch"); __ ReplaceClosureCodeWithOptimizedCode(x2, closure); - __ JumpCodeObject(x2); + __ JumpCodeObject(x2, kJSEntrypointTag); __ bind(&install_baseline_code); __ GenerateTailCallToReturnedCode(Runtime::kInstallBaselineCode); @@ -2026,9 +2025,9 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) { kInterpreterDispatchTableRegister, INTERPRETER_DATA_TYPE); __ B(ne, &builtin_trampoline); - __ LoadCodePointerField( + __ LoadProtectedPointerField( x1, FieldMemOperand(x1, InterpreterData::kInterpreterTrampolineOffset)); - __ LoadCodeInstructionStart(x1, x1); + __ LoadCodeInstructionStart(x1, x1, kJSEntrypointTag); __ B(&trampoline_loaded); __ Bind(&builtin_trampoline); @@ -2280,17 +2279,17 @@ void OnStackReplacement(MacroAssembler* masm, OsrSourceTier source, // Load deoptimization data from the code object. // = [#deoptimization_data_offset] - __ LoadTaggedField( + __ LoadProtectedPointerField( x1, FieldMemOperand(x0, Code::kDeoptimizationDataOrInterpreterDataOffset)); // Load the OSR entrypoint offset from the deoptimization data. // = [#header_size + #osr_pc_offset] __ SmiUntagField( - x1, FieldMemOperand(x1, FixedArray::OffsetOfElementAt( + x1, FieldMemOperand(x1, TrustedFixedArray::OffsetOfElementAt( DeoptimizationData::kOsrPcOffsetIndex))); - __ LoadCodeInstructionStart(x0, x0); + __ LoadCodeInstructionStart(x0, x0, kJSEntrypointTag); // Compute the target address = code_entry + osr_offset // = + @@ -5509,7 +5508,7 @@ void Generate_BaselineOrInterpreterEntry(MacroAssembler* masm, FrameScope scope(masm, StackFrame::INTERNAL); __ CallCFunction(get_baseline_pc, 3, 0); } - __ LoadCodeInstructionStart(code_obj, code_obj); + __ LoadCodeInstructionStart(code_obj, code_obj, kJSEntrypointTag); __ Add(code_obj, code_obj, kReturnRegister0); __ Pop(kInterpreterAccumulatorRegister, padreg); diff --git a/deps/v8/src/builtins/base.tq b/deps/v8/src/builtins/base.tq index 4745af7a0c2e11..090e2ee31ad20d 100644 --- a/deps/v8/src/builtins/base.tq +++ b/deps/v8/src/builtins/base.tq @@ -243,7 +243,10 @@ type IndirectPointer generates 'TNode' constexpr 'IndirectPointerHandle'; // TODO(saelo): implement accessors and type checkers for these fields. -type IndirectPointer extends IndirectPointer; +type IndirectPointer extends + IndirectPointer; +type ProtectedPointer extends Tagged; +type ProtectedPointer extends ProtectedPointer; extern class InstructionStream extends TrustedObject; type BuiltinPtr extends Smi generates 'TNode'; @@ -419,6 +422,7 @@ extern enum MessageTemplate { kTypedArraySetOffsetOutOfBounds, kInvalidArgument, kInvalidRegExpExecResult, + kInvalidSizeValue, kRegExpNonRegExp, kRegExpNonObject, kPromiseNonCallable, @@ -477,6 +481,7 @@ extern enum MessageTemplate { kIteratorResultNotAnObject, kFlattenPastSafeLength, kStrictReadOnlyProperty, + kInvalidUsingInForInLoop, ... } diff --git a/deps/v8/src/builtins/builtins-async-generator-gen.cc b/deps/v8/src/builtins/builtins-async-generator-gen.cc index c859031d424d89..10ffd889f7f8cc 100644 --- a/deps/v8/src/builtins/builtins-async-generator-gen.cc +++ b/deps/v8/src/builtins/builtins-async-generator-gen.cc @@ -413,8 +413,10 @@ TF_BUILTIN(AsyncGeneratorAwaitResolveClosure, AsyncGeneratorBuiltinsAssembler) { TF_BUILTIN(AsyncGeneratorAwaitRejectClosure, AsyncGeneratorBuiltinsAssembler) { auto value = Parameter(Descriptor::kValue); auto context = Parameter(Descriptor::kContext); + // Restart in Rethrow mode, as this exception was already thrown and we don't + // want to trigger a second debug break event or change the message location. AsyncGeneratorAwaitResumeClosure(context, value, - JSAsyncGeneratorObject::kThrow); + JSAsyncGeneratorObject::kRethrow); } TF_BUILTIN(AsyncGeneratorAwaitUncaught, AsyncGeneratorBuiltinsAssembler) { diff --git a/deps/v8/src/builtins/builtins-collections-gen.cc b/deps/v8/src/builtins/builtins-collections-gen.cc index 6fea5c37e8c2f2..e5e6026ce61632 100644 --- a/deps/v8/src/builtins/builtins-collections-gen.cc +++ b/deps/v8/src/builtins/builtins-collections-gen.cc @@ -2782,9 +2782,10 @@ TNode WeakCollectionsBuiltinsAssembler::ShouldShrink( TNode WeakCollectionsBuiltinsAssembler::ValueIndexFromKeyIndex( TNode key_index) { - return IntPtrAdd(key_index, - IntPtrConstant(EphemeronHashTable::ShapeT::kEntryValueIndex - - EphemeronHashTable::kEntryKeyIndex)); + return IntPtrAdd( + key_index, + IntPtrConstant(EphemeronHashTable::TodoShape::kEntryValueIndex - + EphemeronHashTable::kEntryKeyIndex)); } TF_BUILTIN(WeakMapConstructor, WeakCollectionsBuiltinsAssembler) { diff --git a/deps/v8/src/builtins/builtins-constructor-gen.cc b/deps/v8/src/builtins/builtins-constructor-gen.cc index 367365a92de155..3224b2996a4041 100644 --- a/deps/v8/src/builtins/builtins-constructor-gen.cc +++ b/deps/v8/src/builtins/builtins-constructor-gen.cc @@ -373,12 +373,8 @@ TNode ConstructorBuiltinsAssembler::FastNewObject( } BIND(&allocate_properties); { - if (V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL) { - properties = - AllocateSwissNameDictionary(SwissNameDictionary::kInitialCapacity); - } else { - properties = AllocateNameDictionary(NameDictionary::kInitialCapacity); - } + properties = + AllocatePropertyDictionary(PropertyDictionary::kInitialCapacity); Goto(&instantiate_map); } diff --git a/deps/v8/src/builtins/builtins-definitions.h b/deps/v8/src/builtins/builtins-definitions.h index 0a037ba91d4829..8cdba0d032eea4 100644 --- a/deps/v8/src/builtins/builtins-definitions.h +++ b/deps/v8/src/builtins/builtins-definitions.h @@ -665,7 +665,9 @@ namespace internal { TFH(StoreGlobalICTrampoline, StoreGlobal) \ TFH(StoreGlobalICBaseline, StoreGlobalBaseline) \ TFH(StoreIC, StoreWithVector) \ + TFH(StoreIC_Megamorphic, StoreWithVector) \ TFH(StoreICTrampoline, Store) \ + TFH(StoreICTrampoline_Megamorphic, Store) \ TFH(StoreICBaseline, StoreBaseline) \ TFH(DefineNamedOwnIC, StoreWithVector) \ TFH(DefineNamedOwnICTrampoline, Store) \ @@ -892,8 +894,8 @@ namespace internal { kMatchInfo) \ TFS(RegExpExecInternal, NeedsContext::kYes, kRegExp, kString, kLastIndex, \ kMatchInfo) \ - ASM(RegExpInterpreterTrampoline, CCall) \ - ASM(RegExpExperimentalTrampoline, CCall) \ + ASM(RegExpInterpreterTrampoline, RegExpTrampoline) \ + ASM(RegExpExperimentalTrampoline, RegExpTrampoline) \ \ /* Set */ \ TFS(FindOrderedHashSetEntry, NeedsContext::kYes, kTable, kKey) \ @@ -2029,14 +2031,6 @@ namespace internal { BUILTIN_LIST(V, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \ IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN) -#define BUILTIN_LIST_A(V) \ - BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \ - IGNORE_BUILTIN, IGNORE_BUILTIN, V) - -#define BUILTIN_LIST_TFS(V) \ - BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, V, \ - IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN) - #define BUILTIN_LIST_TFJ(V) \ BUILTIN_LIST(IGNORE_BUILTIN, V, IGNORE_BUILTIN, IGNORE_BUILTIN, \ IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN) @@ -2045,6 +2039,22 @@ namespace internal { BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, V, IGNORE_BUILTIN, \ IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN) +#define BUILTIN_LIST_TFS(V) \ + BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, V, \ + IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN) + +#define BUILTIN_LIST_TFH(V) \ + BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \ + V, IGNORE_BUILTIN, IGNORE_BUILTIN) + +#define BUILTIN_LIST_BCH(V) \ + BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \ + IGNORE_BUILTIN, V, IGNORE_BUILTIN) + +#define BUILTIN_LIST_A(V) \ + BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \ + IGNORE_BUILTIN, IGNORE_BUILTIN, V) + } // namespace internal } // namespace v8 diff --git a/deps/v8/src/builtins/builtins-generator-gen.cc b/deps/v8/src/builtins/builtins-generator-gen.cc index d67dc0ef59f7e3..a6d4a45101e7fd 100644 --- a/deps/v8/src/builtins/builtins-generator-gen.cc +++ b/deps/v8/src/builtins/builtins-generator-gen.cc @@ -106,6 +106,9 @@ void GeneratorBuiltinsAssembler::InnerResume( case JSGeneratorObject::kThrow: builtin_result = CallRuntime(Runtime::kThrow, context, value); break; + case JSGeneratorObject::kRethrow: + // Currently only async generators use this mode. + UNREACHABLE(); } args->PopAndReturn(builtin_result); } diff --git a/deps/v8/src/builtins/builtins-ic-gen.cc b/deps/v8/src/builtins/builtins-ic-gen.cc index d6c1c0136bbd45..da645619dc5a74 100644 --- a/deps/v8/src/builtins/builtins-ic-gen.cc +++ b/deps/v8/src/builtins/builtins-ic-gen.cc @@ -101,10 +101,20 @@ void Builtins::Generate_StoreIC(compiler::CodeAssemblerState* state) { AccessorAssembler assembler(state); assembler.GenerateStoreIC(); } +void Builtins::Generate_StoreIC_Megamorphic( + compiler::CodeAssemblerState* state) { + AccessorAssembler assembler(state); + assembler.GenerateStoreIC_Megamorphic(); +} void Builtins::Generate_StoreICTrampoline(compiler::CodeAssemblerState* state) { AccessorAssembler assembler(state); assembler.GenerateStoreICTrampoline(); } +void Builtins::Generate_StoreICTrampoline_Megamorphic( + compiler::CodeAssemblerState* state) { + AccessorAssembler assembler(state); + assembler.GenerateStoreICTrampoline_Megamorphic(); +} void Builtins::Generate_StoreICBaseline(compiler::CodeAssemblerState* state) { AccessorAssembler assembler(state); assembler.GenerateStoreICBaseline(); diff --git a/deps/v8/src/builtins/builtins-internal-gen.cc b/deps/v8/src/builtins/builtins-internal-gen.cc index 9602300cc7e054..9b3c69a4dbf5ee 100644 --- a/deps/v8/src/builtins/builtins-internal-gen.cc +++ b/deps/v8/src/builtins/builtins-internal-gen.cc @@ -137,10 +137,10 @@ class WriteBarrierCodeStubAssembler : public CodeStubAssembler { } TNode IsPageFlagSet(TNode object, int mask) { - TNode page = PageFromAddress(object); + TNode header = PageHeaderFromAddress(object); TNode flags = UncheckedCast( - Load(MachineType::Pointer(), page, - IntPtrConstant(BasicMemoryChunk::kFlagsOffset))); + Load(MachineType::Pointer(), header, + IntPtrConstant(MemoryChunkLayout::kFlagsOffset))); return WordNotEqual(WordAnd(flags, IntPtrConstant(mask)), IntPtrConstant(0)); } @@ -156,8 +156,8 @@ class WriteBarrierCodeStubAssembler : public CodeStubAssembler { void GetMarkBit(TNode object, TNode* cell, TNode* mask) { TNode page = PageFromAddress(object); - TNode bitmap = - IntPtrAdd(page, IntPtrConstant(MemoryChunk::kMarkingBitmapOffset)); + TNode bitmap = IntPtrAdd( + page, IntPtrConstant(MemoryChunkLayout::kMarkingBitmapOffset)); { // Temp variable to calculate cell offset in bitmap. @@ -165,8 +165,10 @@ class WriteBarrierCodeStubAssembler : public CodeStubAssembler { int shift = MarkingBitmap::kBitsPerCellLog2 + kTaggedSizeLog2 - MarkingBitmap::kBytesPerCellLog2; r0 = WordShr(object, IntPtrConstant(shift)); - r0 = WordAnd(r0, IntPtrConstant((kPageAlignmentMask >> shift) & - ~(MarkingBitmap::kBytesPerCell - 1))); + r0 = WordAnd( + r0, IntPtrConstant( + (MemoryChunkHeader::GetAlignmentMaskForAssembler() >> shift) & + ~(MarkingBitmap::kBytesPerCell - 1))); *cell = IntPtrAdd(bitmap, Signed(r0)); } { @@ -185,11 +187,12 @@ class WriteBarrierCodeStubAssembler : public CodeStubAssembler { void InsertIntoRememberedSet(TNode object, TNode slot, SaveFPRegsMode fp_mode) { Label slow_path(this), next(this); - TNode page = PageFromAddress(object); + TNode page_header = PageHeaderFromAddress(object); + TNode page = PageFromPageHeader(page_header); // Load address of SlotSet TNode slot_set = LoadSlotSet(page, &slow_path); - TNode slot_offset = IntPtrSub(slot, page); + TNode slot_offset = IntPtrSub(slot, page_header); // Load bucket TNode bucket = LoadBucket(slot_set, slot_offset, &slow_path); @@ -1423,7 +1426,8 @@ void Builtins::Generate_MaglevOptimizeCodeOrTailCallOptimizedCodeSlot( using D = MaglevOptimizeCodeOrTailCallOptimizedCodeSlotDescriptor; Register flags = D::GetRegisterParameter(D::kFlags); Register feedback_vector = D::GetRegisterParameter(D::kFeedbackVector); - masm->AssertFeedbackVector(feedback_vector); + Register temporary = D::GetRegisterParameter(D::kTemporary); + masm->AssertFeedbackVector(feedback_vector, temporary); masm->OptimizeCodeOrTailCallOptimizedCodeSlot(flags, feedback_vector); masm->Trap(); } diff --git a/deps/v8/src/builtins/builtins-object-gen.cc b/deps/v8/src/builtins/builtins-object-gen.cc index 712fe0ceb06aff..2c5d35c3395b71 100644 --- a/deps/v8/src/builtins/builtins-object-gen.cc +++ b/deps/v8/src/builtins/builtins-object-gen.cc @@ -1072,13 +1072,8 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) { BIND(&null_proto); { map = LoadSlowObjectWithNullPrototypeMap(native_context); - if constexpr (V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL) { - new_properties = - AllocateSwissNameDictionary(SwissNameDictionary::kInitialCapacity); - } else { - new_properties = - AllocateNameDictionary(NameDictionary::kInitialCapacity); - } + new_properties = + AllocatePropertyDictionary(PropertyDictionary::kInitialCapacity); Goto(&instantiate_map); } @@ -1419,10 +1414,7 @@ TNode ObjectBuiltinsAssembler::FromPropertyDescriptor( native_context, Context::SLOW_OBJECT_WITH_OBJECT_PROTOTYPE_MAP)); // We want to preallocate the slots for value, writable, get, set, // enumerable and configurable - a total of 6 - TNode properties = - V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL - ? TNode(AllocateSwissNameDictionary(6)) - : AllocateNameDictionary(6); + TNode properties = AllocatePropertyDictionary(6); TNode js_desc = AllocateJSObjectFromMap(map, properties); Label bailout(this, Label::kDeferred); diff --git a/deps/v8/src/builtins/builtins-object.cc b/deps/v8/src/builtins/builtins-object.cc index 247927cd9e1cf6..3196d73fa52136 100644 --- a/deps/v8/src/builtins/builtins-object.cc +++ b/deps/v8/src/builtins/builtins-object.cc @@ -115,10 +115,9 @@ Tagged ObjectLookupAccessor(Isolate* isolate, Handle object, LookupIterator it(isolate, object, lookup_key, LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); - for (; it.IsFound(); it.Next()) { + for (;; it.Next()) { switch (it.state()) { case LookupIterator::INTERCEPTOR: - case LookupIterator::NOT_FOUND: case LookupIterator::TRANSITION: UNREACHABLE(); @@ -151,8 +150,9 @@ Tagged ObjectLookupAccessor(Isolate* isolate, Handle object, return ObjectLookupAccessor(isolate, prototype, key, component); } case LookupIterator::WASM_OBJECT: - case LookupIterator::INTEGER_INDEXED_EXOTIC: + case LookupIterator::TYPED_ARRAY_INDEX_NOT_FOUND: case LookupIterator::DATA: + case LookupIterator::NOT_FOUND: return ReadOnlyRoots(isolate).undefined_value(); case LookupIterator::ACCESSOR: { @@ -165,11 +165,11 @@ Tagged ObjectLookupAccessor(Isolate* isolate, Handle object, isolate, holder_realm, Handle::cast(maybe_pair), component); } + continue; } } + UNREACHABLE(); } - - return ReadOnlyRoots(isolate).undefined_value(); } } // namespace diff --git a/deps/v8/src/builtins/builtins-regexp-gen.cc b/deps/v8/src/builtins/builtins-regexp-gen.cc index 672a46f0136a59..e3befac11c7f92 100644 --- a/deps/v8/src/builtins/builtins-regexp-gen.cc +++ b/deps/v8/src/builtins/builtins-regexp-gen.cc @@ -312,19 +312,45 @@ TNode RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo( // implementation of CreateDataProperty instead. // At this point the spec says to call CreateDataProperty. However, we can - // skip most of the steps and go straight to adding a dictionary entry - // because we know a bunch of useful facts: + // skip most of the steps and go straight to adding/updating a dictionary + // entry because we know a bunch of useful facts: // - All keys are non-numeric internalized strings - // - No keys repeat // - Receiver has no prototype // - Receiver isn't used as a prototype // - Receiver isn't any special object like a Promise intrinsic object // - Receiver is extensible // - Receiver has no interceptors Label add_dictionary_property_slow(this, Label::kDeferred); + TVARIABLE(IntPtrT, var_name_index); + Label add_name_entry_find_index(this), + add_name_entry_known_index(this, &var_name_index), + duplicate_name(this, &var_name_index), next(this); + NameDictionaryLookup( + CAST(properties), name, &duplicate_name, &var_name_index, + &add_name_entry_find_index, kFindExisting, + &add_name_entry_known_index); + BIND(&duplicate_name); + GotoIf(IsUndefined(capture), &next); + CSA_DCHECK(this, + TaggedEqual(LoadValueByKeyIndex( + CAST(properties), var_name_index.value()), + UndefinedConstant())); + StoreValueByKeyIndex(CAST(properties), + var_name_index.value(), capture); + Goto(&next); + + BIND(&add_name_entry_find_index); + FindInsertionEntry(CAST(properties), name, + &var_name_index); + Goto(&add_name_entry_known_index); + + BIND(&add_name_entry_known_index); AddToDictionary(CAST(properties), name, capture, - &add_dictionary_property_slow); + &add_dictionary_property_slow, + var_name_index.value()); + Goto(&next); + BIND(&next); var_i = i_plus_2; Branch(IntPtrGreaterThanOrEqual(var_i.value(), names_length), &maybe_build_indices, &inner_loop); @@ -578,7 +604,8 @@ TNode RegExpBuiltinsAssembler::RegExpExecInternal( // instead of referencing the CodeWrapper object, we could directly load // the entrypoint from that via LoadCodeEntrypointViaCodePointerField. This // will save an indirection when the sandbox is enabled. - TNode code_entry = LoadCodeInstructionStart(code); + TNode code_entry = + LoadCodeInstructionStart(code, kRegExpEntrypointTag); // AIX uses function descriptors on CFunction calls. code_entry in this case // may also point to a Regex interpreter entry trampoline which does not diff --git a/deps/v8/src/builtins/builtins.cc b/deps/v8/src/builtins/builtins.cc index 6ba148eac268f4..6a909d15ee7128 100644 --- a/deps/v8/src/builtins/builtins.cc +++ b/deps/v8/src/builtins/builtins.cc @@ -462,6 +462,28 @@ bool Builtins::IsCpp(Builtin builtin) { return Builtins::KindOf(builtin) == CPP; } +// static +CodeEntrypointTag Builtins::EntrypointTagFor(Builtin builtin) { + if (builtin == Builtin::kNoBuiltinId) { + // Special case needed for example for tests. + return kDefaultCodeEntrypointTag; + } + + Kind kind = Builtins::KindOf(builtin); + switch (kind) { + case BCH: + return kBytecodeHandlerEntrypointTag; + case TFH: + return kICHandlerEntrypointTag; + case ASM: + // TODO(saelo) consider using this approach for the other kinds as well. + return CallInterfaceDescriptorFor(builtin).tag(); + default: + // TODO(saelo): use more fine-grained tags here. + return kDefaultCodeEntrypointTag; + } +} + // static bool Builtins::AllowDynamicFunction(Isolate* isolate, Handle target, Handle target_global_proxy) { diff --git a/deps/v8/src/builtins/builtins.h b/deps/v8/src/builtins/builtins.h index 6d747e02cca03f..f2b9bd48134a74 100644 --- a/deps/v8/src/builtins/builtins.h +++ b/deps/v8/src/builtins/builtins.h @@ -9,6 +9,7 @@ #include "src/builtins/builtins-definitions.h" #include "src/common/globals.h" #include "src/objects/type-hints.h" +#include "src/sandbox/code-entrypoint-tag.h" namespace v8 { namespace internal { @@ -193,6 +194,9 @@ class Builtins { static Kind KindOf(Builtin builtin); static const char* KindNameOf(Builtin builtin); + // The tag for the builtins entrypoint. + V8_EXPORT_PRIVATE static CodeEntrypointTag EntrypointTagFor(Builtin builtin); + static bool IsCpp(Builtin builtin); // True, iff the given code object is a builtin. Note that this does not diff --git a/deps/v8/src/builtins/collections.tq b/deps/v8/src/builtins/collections.tq index b257bb5298d72a..7d4f506519c9d9 100644 --- a/deps/v8/src/builtins/collections.tq +++ b/deps/v8/src/builtins/collections.tq @@ -288,21 +288,26 @@ transitioning macro GetSetRecord( // 6. Let intSize be ! ToIntegerOrInfinity(numSize). const intSize = ToInteger_Inline(numSize); - // 7. Let has be ? Get(obj, "has"). + // 7. If intSize < 0, throw a RangeError exception. + if (intSize < 0) { + ThrowRangeError(MessageTemplate::kInvalidSizeValue, intSize); + } + + // 8. Let has be ? Get(obj, "has"). let has = GetProperty(obj, kHasString); - // 8. If IsCallable(has) is false, throw a TypeError exception. + // 9. If IsCallable(has) is false, throw a TypeError exception. has = Cast(has) otherwise ThrowCalledNonCallable(kHasString); - // 9. Let keys be ? Get(obj, "keys"). + // 10. Let keys be ? Get(obj, "keys"). let keys = GetProperty(obj, kKeysString); - // 10. If IsCallable(keys) is false, throw a TypeError exception. + // 11. If IsCallable(keys) is false, throw a TypeError exception. keys = Cast(keys) otherwise ThrowCalledNonCallable(kKeysString); - // 11. Return a new Set Record { [[Set]]: obj, [[Size]]: intSize, [[Has]]: + // 12. Return a new Set Record { [[Set]]: obj, [[Size]]: intSize, [[Has]]: // has, [[Keys]]: keys }. return SetRecord{object: obj, size: intSize, has: has, keys: keys}; } diff --git a/deps/v8/src/builtins/js-to-js.tq b/deps/v8/src/builtins/js-to-js.tq index 46dd70b4927673..691271e9caf0c5 100644 --- a/deps/v8/src/builtins/js-to-js.tq +++ b/deps/v8/src/builtins/js-to-js.tq @@ -42,6 +42,8 @@ macro ConvertToAndFromWasm(context: Context, wasmType: int32, value: JSAny): } else if (wasmType == kWasmF64Type) { return Convert(WasmTaggedToFloat64(value)); } else { + const wasmKind = wasmType & kValueTypeKindBitsMask; + dcheck(wasmKind == ValueKind::kRef || wasmKind == ValueKind::kRefNull); if (value == Null) { // At the moment it is not possible to define non-nullable types for // WebAssembly.Functions. @@ -61,6 +63,13 @@ macro ConvertToAndFromWasm(context: Context, wasmType: int32, value: JSAny): } } +extern runtime WasmThrowJSTypeError(Context): never; + +transitioning javascript builtin JSToJSWrapperInvalidSig( + js-implicit context: NativeContext)(): JSAny { + runtime::WasmThrowJSTypeError(context); +} + transitioning javascript builtin JSToJSWrapper( js-implicit context: NativeContext, receiver: JSAny, target: JSFunction)( ...arguments): JSAny { diff --git a/deps/v8/src/builtins/js-to-wasm.tq b/deps/v8/src/builtins/js-to-wasm.tq index 45d31c65917f99..19d6a1077e943b 100644 --- a/deps/v8/src/builtins/js-to-wasm.tq +++ b/deps/v8/src/builtins/js-to-wasm.tq @@ -504,6 +504,8 @@ macro JSToWasmWrapperHelper( } else if (retType == kWasmF64Type) { allocator.AllocFP64(); } else { + const retKind = retType & kValueTypeKindBitsMask; + dcheck(retKind == ValueKind::kRef || retKind == ValueKind::kRefNull); // Also check if there are any reference return values, as this allows // us to skip code when we process return values. hasRefReturns = true; @@ -600,6 +602,8 @@ macro JSToWasmWrapperHelper( *toHighRef = Signed(pair.high); } } else { + const paramKind = paramType & kValueTypeKindBitsMask; + dcheck(paramKind == ValueKind::kRef || paramKind == ValueKind::kRefNull); // The byte array where we store converted parameters is not GC-safe. // Therefore we can only copy references into this array once no GC can // happen anymore. Any conversion of a primitive type can execute diff --git a/deps/v8/src/builtins/promise-abstract-operations.tq b/deps/v8/src/builtins/promise-abstract-operations.tq index 7ee1f5db9eecc9..fdbc6faa9776e0 100644 --- a/deps/v8/src/builtins/promise-abstract-operations.tq +++ b/deps/v8/src/builtins/promise-abstract-operations.tq @@ -305,6 +305,7 @@ macro CreatePromiseCapability( struct PromiseResolvingFunctions { resolve: JSFunction; reject: JSFunction; + context: Context; } @export @@ -322,7 +323,11 @@ macro CreatePromiseResolvingFunctions( const rejectInfo = PromiseCapabilityDefaultRejectSharedFunConstant(); const reject: JSFunction = AllocateFunctionWithMapAndContext(map, rejectInfo, promiseContext); - return PromiseResolvingFunctions{resolve: resolve, reject: reject}; + return PromiseResolvingFunctions{ + resolve: resolve, + reject: reject, + context: promiseContext + }; } transitioning macro InnerNewPromiseCapability( diff --git a/deps/v8/src/builtins/promise-constructor.tq b/deps/v8/src/builtins/promise-constructor.tq index 5611e228b50cfd..c77e0501cced8a 100644 --- a/deps/v8/src/builtins/promise-constructor.tq +++ b/deps/v8/src/builtins/promise-constructor.tq @@ -82,6 +82,13 @@ transitioning javascript builtin PromiseConstructor( try { Call(context, UnsafeCast(executor), Undefined, resolve, reject); } catch (e, _message) { + // We need to disable the debug event, as we have already paused on this + // exception. + const promiseContext = + %RawDownCast(funcs.context); + *ContextSlot( + promiseContext, PromiseResolvingFunctionContextSlot::kDebugEventSlot) = + False; Call(context, reject, Undefined, e); } diff --git a/deps/v8/src/builtins/riscv/builtins-riscv.cc b/deps/v8/src/builtins/riscv/builtins-riscv.cc index f0ae7947325539..94593f08920567 100644 --- a/deps/v8/src/builtins/riscv/builtins-riscv.cc +++ b/deps/v8/src/builtins/riscv/builtins-riscv.cc @@ -3028,7 +3028,10 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size, // Check result for exception sentinel. Label exception_returned; - __ Branch(&exception_returned, eq, a0, RootIndex::kException); + // The returned value may be a trusted object, living outside of the main + // pointer compression cage, so we need to use full pointer comparison here. + __ CompareRootAndBranch(a0, RootIndex::kException, eq, &exception_returned, + ComparisonMode::kFullPointer); // Check that there is no exception, otherwise we // should have returned the exception sentinel. diff --git a/deps/v8/src/builtins/wasm-strings.tq b/deps/v8/src/builtins/wasm-strings.tq index eda80d707302bd..fb103155db439f 100644 --- a/deps/v8/src/builtins/wasm-strings.tq +++ b/deps/v8/src/builtins/wasm-strings.tq @@ -63,6 +63,16 @@ transitioning javascript builtin WebAssemblyStringIntoUtf8Array( } } +transitioning javascript builtin WebAssemblyStringToUtf8Array( + js-implicit context: Context)(...arguments): JSAny { + try { + const string = Cast(arguments[0]) otherwise goto IllegalCast; + return runtime::WasmStringToUtf8Array(context, string); + } label IllegalCast deferred { + Trap(context, MessageTemplate::kWasmTrapIllegalCast); + } +} + transitioning javascript builtin WebAssemblyStringToWtf16Array( js-implicit context: Context)(...arguments): JSAny { try { diff --git a/deps/v8/src/builtins/wasm-to-js.tq b/deps/v8/src/builtins/wasm-to-js.tq index b3c2ce29cd71e9..87e43f6f7835c3 100644 --- a/deps/v8/src/builtins/wasm-to-js.tq +++ b/deps/v8/src/builtins/wasm-to-js.tq @@ -81,6 +81,7 @@ transitioning macro WasmToJSWrapper(ref: WasmApiFunctionRef): WasmToJSResult { const returnCount = Convert(*torque_internal::unsafe::NewReference( serializedSig.object, serializedSig.offset)); + dcheck(returnCount < serializedSig.length); const paramCount: intptr = serializedSig.length - returnCount - 1; const returnTypes = Subslice(serializedSig, Convert(1), returnCount) otherwise unreachable; @@ -261,6 +262,8 @@ transitioning macro WasmToJSWrapper(ref: WasmApiFunctionRef): WasmToJSResult { *toHighRef = Signed(pair.high); } } else { + const retKind = retType & kValueTypeKindBitsMask; + dcheck(retKind == ValueKind::kRef || retKind == ValueKind::kRefNull); dcheck(ref.instance == Undefined || Is(ref.instance)); const trustedData = ref.instance == Undefined ? Undefined : diff --git a/deps/v8/src/builtins/wasm.tq b/deps/v8/src/builtins/wasm.tq index 1e5d82ee37e208..4179bcb7fd474e 100644 --- a/deps/v8/src/builtins/wasm.tq +++ b/deps/v8/src/builtins/wasm.tq @@ -62,6 +62,7 @@ extern runtime WasmStringEncodeWtf8( Context, WasmTrustedInstanceData, Smi, Smi, String, Number): Number; extern runtime WasmStringEncodeWtf8Array( Context, Smi, String, WasmArray, Number): Number; +extern runtime WasmStringToUtf8Array(Context, String): WasmArray; extern runtime WasmStringEncodeWtf16( Context, WasmTrustedInstanceData, Smi, String, Number, Smi, Smi): JSAny; extern runtime WasmStringAsWtf8(Context, String): ByteArray; @@ -995,6 +996,9 @@ builtin WasmStringEncodeWtf8Array( WasmUint32ToNumber(start)); return ChangeNumberToUint32(result); } +builtin WasmStringToUtf8Array(string: String): WasmArray { + return runtime::WasmStringToUtf8Array(LoadContextFromFrame(), string); +} builtin WasmStringEncodeWtf16(string: String, offset: uint32, memory: Smi): uint32 { const trustedData = LoadInstanceDataFromFrame(); diff --git a/deps/v8/src/builtins/x64/builtins-x64.cc b/deps/v8/src/builtins/x64/builtins-x64.cc index 2d3080c59ab4f6..68d1f2c6641cef 100644 --- a/deps/v8/src/builtins/x64/builtins-x64.cc +++ b/deps/v8/src/builtins/x64/builtins-x64.cc @@ -759,9 +759,8 @@ static void GetSharedFunctionInfoBytecodeOrBaseline( &done); } - __ LoadTrustedPointerField( - bytecode, FieldOperand(data, InterpreterData::kBytecodeArrayOffset), - kBytecodeArrayIndirectPointerTag, scratch1); + __ LoadProtectedPointerField( + bytecode, FieldOperand(data, InterpreterData::kBytecodeArrayOffset)); __ bind(&done); __ IsObjectType(bytecode, BYTECODE_ARRAY_TYPE, scratch1); @@ -1298,7 +1297,7 @@ void Builtins::Generate_InterpreterEntryTrampoline( __ ReplaceClosureCodeWithOptimizedCode( rcx, closure, kInterpreterBytecodeArrayRegister, WriteBarrierDescriptor::SlotAddressRegister()); - __ JumpCodeObject(rcx); + __ JumpCodeObject(rcx, kJSEntrypointTag); __ bind(&install_baseline_code); __ GenerateTailCallToReturnedCode(Runtime::kInstallBaselineCode); @@ -1707,11 +1706,9 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) { GetSharedFunctionInfoData(masm, rbx, shared_function_info, kScratchRegister); __ IsObjectType(rbx, INTERPRETER_DATA_TYPE, kScratchRegister); __ j(not_equal, &builtin_trampoline, Label::kNear); - - __ LoadCodePointerField( - rbx, FieldOperand(rbx, InterpreterData::kInterpreterTrampolineOffset), - kScratchRegister); - __ LoadCodeInstructionStart(rbx, rbx); + __ LoadProtectedPointerField( + rbx, FieldOperand(rbx, InterpreterData::kInterpreterTrampolineOffset)); + __ LoadCodeInstructionStart(rbx, rbx, kJSEntrypointTag); __ jmp(&trampoline_loaded, Label::kNear); __ bind(&builtin_trampoline); @@ -1841,7 +1838,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) { FieldOperand(closure, JSFunction::kFeedbackCellOffset)); __ LoadTaggedField(feedback_vector, FieldOperand(feedback_cell, FeedbackCell::kValueOffset)); - __ AssertFeedbackVector(feedback_vector); + __ AssertFeedbackVector(feedback_vector, kScratchRegister); // Check the tiering state. Label flags_need_processing; @@ -2935,18 +2932,18 @@ void OnStackReplacement(MacroAssembler* masm, OsrSourceTier source, } // Load deoptimization data from the code object. - const TaggedRegister deopt_data(rbx); - __ LoadTaggedField( + const Register deopt_data(rbx); + __ LoadProtectedPointerField( deopt_data, FieldOperand(rax, Code::kDeoptimizationDataOrInterpreterDataOffset)); // Load the OSR entrypoint offset from the deoptimization data. __ SmiUntagField( rbx, - FieldOperand(deopt_data, FixedArray::OffsetOfElementAt( + FieldOperand(deopt_data, TrustedFixedArray::OffsetOfElementAt( DeoptimizationData::kOsrPcOffsetIndex))); - __ LoadCodeInstructionStart(rax, rax); + __ LoadCodeInstructionStart(rax, rax, kJSEntrypointTag); // Compute the target address = code_entry + osr_offset __ addq(rax, rbx); @@ -4990,7 +4987,7 @@ void Generate_BaselineOrInterpreterEntry(MacroAssembler* masm, __ movq(kCArgRegs[2], kInterpreterBytecodeArrayRegister); __ CallCFunction(get_baseline_pc, 3); } - __ LoadCodeInstructionStart(code_obj, code_obj); + __ LoadCodeInstructionStart(code_obj, code_obj, kJSEntrypointTag); __ addq(code_obj, kReturnRegister0); __ popq(kInterpreterAccumulatorRegister); diff --git a/deps/v8/src/codegen/arm/assembler-arm.cc b/deps/v8/src/codegen/arm/assembler-arm.cc index defa349c741bce..33289ffa1c4b31 100644 --- a/deps/v8/src/codegen/arm/assembler-arm.cc +++ b/deps/v8/src/codegen/arm/assembler-arm.cc @@ -1250,7 +1250,7 @@ void Assembler::AddrMode1(Instr instr, Register rd, Register rn, // pool only for a MOV instruction which does not set the flags. DCHECK(!rn.is_valid()); Move32BitImmediate(rd, x, cond); - } else if ((opcode == ADD) && !set_flags && (rd == rn) && + } else if ((opcode == ADD || opcode == SUB) && !set_flags && (rd == rn) && !temps.CanAcquire()) { // Split the operation into a sequence of additions if we cannot use a // scratch register. In this case, we cannot re-use rn and the assembler @@ -1266,10 +1266,20 @@ void Assembler::AddrMode1(Instr instr, Register rd, Register rn, // immediate allows us to more efficiently split it: int trailing_zeroes = base::bits::CountTrailingZeros(imm) & ~1u; uint32_t mask = (0xFF << trailing_zeroes); - add(rd, rd, Operand(imm & mask), LeaveCC, cond); + if (opcode == ADD) { + add(rd, rd, Operand(imm & mask), LeaveCC, cond); + } else { + DCHECK_EQ(opcode, SUB); + sub(rd, rd, Operand(imm & mask), LeaveCC, cond); + } imm = imm & ~mask; } while (!ImmediateFitsAddrMode1Instruction(imm)); - add(rd, rd, Operand(imm), LeaveCC, cond); + if (opcode == ADD) { + add(rd, rd, Operand(imm), LeaveCC, cond); + } else { + DCHECK_EQ(opcode, SUB); + sub(rd, rd, Operand(imm), LeaveCC, cond); + } } else { // The immediate operand cannot be encoded as a shifter operand, so load // it first to a scratch register and change the original instruction to diff --git a/deps/v8/src/codegen/arm/interface-descriptors-arm-inl.h b/deps/v8/src/codegen/arm/interface-descriptors-arm-inl.h index 2bf8f367cf6d29..2142ca9119c4c3 100644 --- a/deps/v8/src/codegen/arm/interface-descriptors-arm-inl.h +++ b/deps/v8/src/codegen/arm/interface-descriptors-arm-inl.h @@ -164,6 +164,11 @@ constexpr Register MaglevOptimizeCodeOrTailCallOptimizedCodeSlotDescriptor:: FeedbackVectorRegister() { return r5; } +// static +constexpr Register +MaglevOptimizeCodeOrTailCallOptimizedCodeSlotDescriptor::TemporaryRegister() { + return r4; +} // static constexpr auto CallTrampolineDescriptor::registers() { diff --git a/deps/v8/src/codegen/arm/macro-assembler-arm.cc b/deps/v8/src/codegen/arm/macro-assembler-arm.cc index da092e1b703504..2310cd9e75b413 100644 --- a/deps/v8/src/codegen/arm/macro-assembler-arm.cc +++ b/deps/v8/src/codegen/arm/macro-assembler-arm.cc @@ -363,7 +363,8 @@ void MacroAssembler::TailCallBuiltin(Builtin builtin, Condition cond) { } void MacroAssembler::LoadCodeInstructionStart(Register destination, - Register code_object) { + Register code_object, + CodeEntrypointTag tag) { ASM_CODE_COMMENT(this); ldr(destination, FieldMemOperand(code_object, Code::kInstructionStartOffset)); } @@ -2006,10 +2007,8 @@ void MacroAssembler::AssertFeedbackCell(Register object, Register scratch) { Assert(eq, AbortReason::kExpectedFeedbackCell); } } -void MacroAssembler::AssertFeedbackVector(Register object) { +void MacroAssembler::AssertFeedbackVector(Register object, Register scratch) { if (v8_flags.debug_code) { - UseScratchRegisterScope temps(this); - Register scratch = temps.Acquire(); CompareObjectType(object, scratch, scratch, FEEDBACK_VECTOR_TYPE); Assert(eq, AbortReason::kExpectedFeedbackVector); } @@ -2729,20 +2728,22 @@ void MacroAssembler::MovToFloatParameters(DwVfpRegister src1, } } -void MacroAssembler::CallCFunction(ExternalReference function, - int num_reg_arguments, - int num_double_arguments, - SetIsolateDataSlots set_isolate_data_slots) { +int MacroAssembler::CallCFunction(ExternalReference function, + int num_reg_arguments, + int num_double_arguments, + SetIsolateDataSlots set_isolate_data_slots, + Label* return_label) { UseScratchRegisterScope temps(this); Register scratch = temps.Acquire(); Move(scratch, function); - CallCFunction(scratch, num_reg_arguments, num_double_arguments, - set_isolate_data_slots); + return CallCFunction(scratch, num_reg_arguments, num_double_arguments, + set_isolate_data_slots, return_label); } -void MacroAssembler::CallCFunction(Register function, int num_reg_arguments, - int num_double_arguments, - SetIsolateDataSlots set_isolate_data_slots) { +int MacroAssembler::CallCFunction(Register function, int num_reg_arguments, + int num_double_arguments, + SetIsolateDataSlots set_isolate_data_slots, + Label* return_label) { ASM_CODE_COMMENT(this); DCHECK_LE(num_reg_arguments + num_double_arguments, kMaxCParameters); DCHECK(has_frame()); @@ -2767,13 +2768,19 @@ void MacroAssembler::CallCFunction(Register function, int num_reg_arguments, } #endif + Label get_pc; + if (set_isolate_data_slots == SetIsolateDataSlots::kYes) { + Register pc_scratch = r5; + Push(pc_scratch); + GetLabelAddress(pc_scratch, &get_pc); + // Save the frame pointer and PC so that the stack layout remains iterable, // even without an ExitFrame which normally exists between JS and C frames. // See x64 code for reasoning about how to address the isolate data fields. if (root_array_available()) { - str(pc, MemOperand(kRootRegister, - IsolateData::fast_c_call_caller_pc_offset())); + str(pc_scratch, MemOperand(kRootRegister, + IsolateData::fast_c_call_caller_pc_offset())); str(fp, MemOperand(kRootRegister, IsolateData::fast_c_call_caller_fp_offset())); } else { @@ -2783,19 +2790,24 @@ void MacroAssembler::CallCFunction(Register function, int num_reg_arguments, Move(addr_scratch, ExternalReference::fast_c_call_caller_pc_address(isolate())); - str(pc, MemOperand(addr_scratch)); + str(pc_scratch, MemOperand(addr_scratch)); Move(addr_scratch, ExternalReference::fast_c_call_caller_fp_address(isolate())); str(fp, MemOperand(addr_scratch)); Pop(addr_scratch); } + + Pop(pc_scratch); } // Just call directly. The function called cannot cause a GC, or // allow preemption, so the return address in the link register // stays correct. Call(function); + int call_pc_offset = pc_offset(); + bind(&get_pc); + if (return_label) bind(return_label); if (set_isolate_data_slots == SetIsolateDataSlots::kYes) { // We don't unset the PC; the FP is the source of truth. @@ -2827,17 +2839,22 @@ void MacroAssembler::CallCFunction(Register function, int num_reg_arguments, } else { add(sp, sp, Operand(stack_passed_arguments * kPointerSize)); } + + return call_pc_offset; } -void MacroAssembler::CallCFunction(ExternalReference function, - int num_arguments, - SetIsolateDataSlots set_isolate_data_slots) { - CallCFunction(function, num_arguments, 0, set_isolate_data_slots); +int MacroAssembler::CallCFunction(ExternalReference function, int num_arguments, + SetIsolateDataSlots set_isolate_data_slots, + Label* return_label) { + return CallCFunction(function, num_arguments, 0, set_isolate_data_slots, + return_label); } -void MacroAssembler::CallCFunction(Register function, int num_arguments, - SetIsolateDataSlots set_isolate_data_slots) { - CallCFunction(function, num_arguments, 0, set_isolate_data_slots); +int MacroAssembler::CallCFunction(Register function, int num_arguments, + SetIsolateDataSlots set_isolate_data_slots, + Label* return_label) { + return CallCFunction(function, num_arguments, 0, set_isolate_data_slots, + return_label); } void MacroAssembler::CheckPageFlag(Register object, int mask, Condition cc, @@ -2848,7 +2865,7 @@ void MacroAssembler::CheckPageFlag(Register object, int mask, Condition cc, DCHECK(!AreAliased(object, scratch)); DCHECK(cc == eq || cc == ne); Bfc(scratch, object, 0, kPageSizeBits); - ldr(scratch, MemOperand(scratch, BasicMemoryChunk::kFlagsOffset)); + ldr(scratch, MemOperand(scratch, MemoryChunkLayout::kFlagsOffset)); tst(scratch, Operand(mask)); b(cc, condition_met); } diff --git a/deps/v8/src/codegen/arm/macro-assembler-arm.h b/deps/v8/src/codegen/arm/macro-assembler-arm.h index c8c80f06629c07..91d4dd7810252b 100644 --- a/deps/v8/src/codegen/arm/macro-assembler-arm.h +++ b/deps/v8/src/codegen/arm/macro-assembler-arm.h @@ -252,23 +252,23 @@ class V8_EXPORT_PRIVATE MacroAssembler : public MacroAssemblerBase { // garbage collection, since that might move the code and invalidate the // return address (unless this is somehow accounted for by the called // function). - enum class SetIsolateDataSlots { - kNo, - kYes, - }; - void CallCFunction( + int CallCFunction( ExternalReference function, int num_arguments, - SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes); - void CallCFunction( + SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes, + Label* return_label = nullptr); + int CallCFunction( Register function, int num_arguments, - SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes); - void CallCFunction( + SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes, + Label* return_label = nullptr); + int CallCFunction( ExternalReference function, int num_reg_arguments, int num_double_arguments, - SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes); - void CallCFunction( + SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes, + Label* return_label = nullptr); + int CallCFunction( Register function, int num_reg_arguments, int num_double_arguments, - SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes); + SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes, + Label* return_label = nullptr); void MovFromFloatParameter(DwVfpRegister dst); void MovFromFloatResult(DwVfpRegister dst); @@ -337,7 +337,9 @@ class V8_EXPORT_PRIVATE MacroAssembler : public MacroAssemblerBase { void TailCallBuiltin(Builtin builtin, Condition cond = al); // Load the code entry point from the Code object. - void LoadCodeInstructionStart(Register destination, Register code_object); + void LoadCodeInstructionStart( + Register destination, Register code_object, + CodeEntrypointTag tag = kDefaultCodeEntrypointTag); void CallCodeObject(Register code_object); void JumpCodeObject(Register code_object, JumpMode jump_mode = JumpMode::kJump); @@ -875,7 +877,8 @@ class V8_EXPORT_PRIVATE MacroAssembler : public MacroAssemblerBase { // Tiering support. void AssertFeedbackCell(Register object, Register scratch) NOOP_UNLESS_DEBUG_CODE; - void AssertFeedbackVector(Register object) NOOP_UNLESS_DEBUG_CODE; + void AssertFeedbackVector(Register object, + Register scratch) NOOP_UNLESS_DEBUG_CODE; void ReplaceClosureCodeWithOptimizedCode(Register optimized_code, Register closure); void GenerateTailCallToReturnedCode(Runtime::FunctionId function_id); diff --git a/deps/v8/src/codegen/arm64/interface-descriptors-arm64-inl.h b/deps/v8/src/codegen/arm64/interface-descriptors-arm64-inl.h index 1cbfd20744973c..0502dc16737acf 100644 --- a/deps/v8/src/codegen/arm64/interface-descriptors-arm64-inl.h +++ b/deps/v8/src/codegen/arm64/interface-descriptors-arm64-inl.h @@ -154,6 +154,11 @@ constexpr Register MaglevOptimizeCodeOrTailCallOptimizedCodeSlotDescriptor:: FeedbackVectorRegister() { return x9; } +// static +constexpr Register +MaglevOptimizeCodeOrTailCallOptimizedCodeSlotDescriptor::TemporaryRegister() { + return x4; +} // static constexpr auto TypeofDescriptor::registers() { return RegisterArray(x0); } diff --git a/deps/v8/src/codegen/arm64/macro-assembler-arm64.cc b/deps/v8/src/codegen/arm64/macro-assembler-arm64.cc index 20d8de3552b5c8..636dcdc874382c 100644 --- a/deps/v8/src/codegen/arm64/macro-assembler-arm64.cc +++ b/deps/v8/src/codegen/arm64/macro-assembler-arm64.cc @@ -1440,7 +1440,7 @@ void TailCallOptimizedCodeSlot(MacroAssembler* masm, __ ReplaceClosureCodeWithOptimizedCode(optimized_code_entry, closure); static_assert(kJavaScriptCallCodeStartRegister == x2, "ABI mismatch"); __ Move(x2, optimized_code_entry); - __ JumpCodeObject(x2); + __ JumpCodeObject(x2, kJSEntrypointTag); // Optimized code slot contains deoptimized code or code is cleared and // optimized code marker isn't updated. Evict the code, update the marker @@ -1507,7 +1507,7 @@ void MacroAssembler::GenerateTailCallToReturnedCode( } static_assert(kJavaScriptCallCodeStartRegister == x2, "ABI mismatch"); - JumpCodeObject(x2); + JumpCodeObject(x2, kJSEntrypointTag); } // Read off the flags in the feedback vector and check if there @@ -2061,31 +2061,37 @@ int MacroAssembler::ActivationFrameAlignment() { #endif // V8_HOST_ARCH_ARM64 } -void MacroAssembler::CallCFunction(ExternalReference function, - int num_of_reg_args, - SetIsolateDataSlots set_isolate_data_slots) { - CallCFunction(function, num_of_reg_args, 0, set_isolate_data_slots); +int MacroAssembler::CallCFunction(ExternalReference function, + int num_of_reg_args, + SetIsolateDataSlots set_isolate_data_slots, + Label* return_location) { + return CallCFunction(function, num_of_reg_args, 0, set_isolate_data_slots, + return_location); } -void MacroAssembler::CallCFunction(ExternalReference function, - int num_of_reg_args, int num_of_double_args, - SetIsolateDataSlots set_isolate_data_slots) { +int MacroAssembler::CallCFunction(ExternalReference function, + int num_of_reg_args, int num_of_double_args, + SetIsolateDataSlots set_isolate_data_slots, + Label* return_location) { // Note: The "CallCFunction" code comment will be generated by the other // CallCFunction method called below. UseScratchRegisterScope temps(this); Register temp = temps.AcquireX(); Mov(temp, function); - CallCFunction(temp, num_of_reg_args, num_of_double_args, - set_isolate_data_slots); + return CallCFunction(temp, num_of_reg_args, num_of_double_args, + set_isolate_data_slots, return_location); } -void MacroAssembler::CallCFunction(Register function, int num_of_reg_args, - int num_of_double_args, - SetIsolateDataSlots set_isolate_data_slots) { +int MacroAssembler::CallCFunction(Register function, int num_of_reg_args, + int num_of_double_args, + SetIsolateDataSlots set_isolate_data_slots, + Label* return_location) { ASM_CODE_COMMENT(this); DCHECK_LE(num_of_reg_args + num_of_double_args, kMaxCParameters); DCHECK(has_frame()); + Label get_pc; + if (set_isolate_data_slots == SetIsolateDataSlots::kYes) { // Save the frame pointer and PC so that the stack layout remains iterable, // even without an ExitFrame which normally exists between JS and C frames. @@ -2093,8 +2099,6 @@ void MacroAssembler::CallCFunction(Register function, int num_of_reg_args, Register addr_scratch = x5; Push(pc_scratch, addr_scratch); - Label get_pc; - Bind(&get_pc); Adr(pc_scratch, &get_pc); // See x64 code for reasoning about how to address the isolate data fields. @@ -2119,6 +2123,9 @@ void MacroAssembler::CallCFunction(Register function, int num_of_reg_args, // Call directly. The function called cannot cause a GC, or allow preemption, // so the return address in the link register stays correct. Call(function); + int call_pc_offset = pc_offset(); + bind(&get_pc); + if (return_location) bind(return_location); if (set_isolate_data_slots == SetIsolateDataSlots::kYes) { // We don't unset the PC; the FP is the source of truth. @@ -2148,6 +2155,8 @@ void MacroAssembler::CallCFunction(Register function, int num_of_reg_args, RoundUp(num_of_double_args - kFPRegisterPassedArguments, 2); Drop(claim_slots); } + + return call_pc_offset; } void MacroAssembler::LoadFromConstantsTable(Register destination, @@ -2459,27 +2468,30 @@ void MacroAssembler::TailCallBuiltin(Builtin builtin, Condition cond) { } void MacroAssembler::LoadCodeInstructionStart(Register destination, - Register code_object) { + Register code_object, + CodeEntrypointTag tag) { ASM_CODE_COMMENT(this); #ifdef V8_ENABLE_SANDBOX LoadCodeEntrypointViaCodePointer( destination, - FieldMemOperand(code_object, Code::kSelfIndirectPointerOffset)); + FieldMemOperand(code_object, Code::kSelfIndirectPointerOffset), tag); #else Ldr(destination, FieldMemOperand(code_object, Code::kInstructionStartOffset)); #endif } -void MacroAssembler::CallCodeObject(Register code_object) { +void MacroAssembler::CallCodeObject(Register code_object, + CodeEntrypointTag tag) { ASM_CODE_COMMENT(this); - LoadCodeInstructionStart(code_object, code_object); + LoadCodeInstructionStart(code_object, code_object, tag); Call(code_object); } -void MacroAssembler::JumpCodeObject(Register code_object, JumpMode jump_mode) { +void MacroAssembler::JumpCodeObject(Register code_object, CodeEntrypointTag tag, + JumpMode jump_mode) { ASM_CODE_COMMENT(this); DCHECK_EQ(JumpMode::kJump, jump_mode); - LoadCodeInstructionStart(code_object, code_object); + LoadCodeInstructionStart(code_object, code_object, tag); // We jump through x17 here because for Branch Identification (BTI) we use // "Call" (`bti c`) rather than "Jump" (`bti j`) landing pads for tail-called // code. See TailCallBuiltin for more information. @@ -2496,12 +2508,13 @@ void MacroAssembler::CallJSFunction(Register function_object) { // from the code pointer table instead of going through the Code object. In // this way, we avoid one memory load on this code path. LoadCodeEntrypointViaCodePointer( - code, FieldMemOperand(function_object, JSFunction::kCodeOffset)); + code, FieldMemOperand(function_object, JSFunction::kCodeOffset), + kJSEntrypointTag); Call(code); #else LoadTaggedField(code, FieldMemOperand(function_object, JSFunction::kCodeOffset)); - CallCodeObject(code); + CallCodeObject(code, kJSEntrypointTag); #endif } @@ -2513,7 +2526,8 @@ void MacroAssembler::JumpJSFunction(Register function_object, // from the code pointer table instead of going through the Code object. In // this way, we avoid one memory load on this code path. LoadCodeEntrypointViaCodePointer( - code, FieldMemOperand(function_object, JSFunction::kCodeOffset)); + code, FieldMemOperand(function_object, JSFunction::kCodeOffset), + kJSEntrypointTag); DCHECK_EQ(jump_mode, JumpMode::kJump); // We jump through x17 here because for Branch Identification (BTI) we use // "Call" (`bti c`) rather than "Jump" (`bti j`) landing pads for tail-called @@ -2524,7 +2538,7 @@ void MacroAssembler::JumpJSFunction(Register function_object, #else LoadTaggedField(code, FieldMemOperand(function_object, JSFunction::kCodeOffset)); - JumpCodeObject(code, jump_mode); + JumpCodeObject(code, kJSEntrypointTag, jump_mode); #endif } @@ -3479,8 +3493,8 @@ void MacroAssembler::CheckPageFlag(const Register& object, int mask, ASM_CODE_COMMENT(this); UseScratchRegisterScope temps(this); Register scratch = temps.AcquireX(); - And(scratch, object, ~kPageAlignmentMask); - Ldr(scratch, MemOperand(scratch, BasicMemoryChunk::kFlagsOffset)); + And(scratch, object, ~MemoryChunkHeader::GetAlignmentMaskForAssembler()); + Ldr(scratch, MemOperand(scratch, MemoryChunkLayout::kFlagsOffset)); if (cc == ne) { TestAndBranchIfAnySet(scratch, mask, condition_met); } else { @@ -3705,17 +3719,23 @@ void MacroAssembler::ResolveCodePointerHandle(Register destination, Orr(destination, destination, Immediate(kHeapObjectTag)); } -void MacroAssembler::LoadCodeEntrypointViaCodePointer( - Register destination, MemOperand field_operand) { +void MacroAssembler::LoadCodeEntrypointViaCodePointer(Register destination, + MemOperand field_operand, + CodeEntrypointTag tag) { + DCHECK_NE(tag, kInvalidEntrypointTag); ASM_CODE_COMMENT(this); UseScratchRegisterScope temps(this); - Register table = temps.AcquireX(); - Mov(table, ExternalReference::code_pointer_table_address()); + Register scratch = temps.AcquireX(); + Mov(scratch, ExternalReference::code_pointer_table_address()); Ldr(destination.W(), field_operand); // TODO(saelo): can the offset computation be done more efficiently? Mov(destination, Operand(destination, LSR, kCodePointerHandleShift)); Mov(destination, Operand(destination, LSL, kCodePointerTableEntrySizeLog2)); - Ldr(destination, MemOperand(table, destination)); + Ldr(destination, MemOperand(scratch, destination)); + if (tag != 0) { + Mov(scratch, Immediate(tag)); + Eor(destination, destination, scratch); + } } #endif // V8_ENABLE_SANDBOX diff --git a/deps/v8/src/codegen/arm64/macro-assembler-arm64.h b/deps/v8/src/codegen/arm64/macro-assembler-arm64.h index e17dc8f6ee8792..b861b0dbe9b86a 100644 --- a/deps/v8/src/codegen/arm64/macro-assembler-arm64.h +++ b/deps/v8/src/codegen/arm64/macro-assembler-arm64.h @@ -1063,9 +1063,10 @@ class V8_EXPORT_PRIVATE MacroAssembler : public MacroAssemblerBase { void TailCallBuiltin(Builtin builtin, Condition cond = al); // Load code entry point from the Code object. - void LoadCodeInstructionStart(Register destination, Register code_object); - void CallCodeObject(Register code_object); - void JumpCodeObject(Register code_object, + void LoadCodeInstructionStart(Register destination, Register code_object, + CodeEntrypointTag tag); + void CallCodeObject(Register code_object, CodeEntrypointTag tag); + void JumpCodeObject(Register code_object, CodeEntrypointTag tag, JumpMode jump_mode = JumpMode::kJump); // Convenience functions to call/jmp to the code of a JSFunction object. @@ -1083,25 +1084,24 @@ class V8_EXPORT_PRIVATE MacroAssembler : public MacroAssemblerBase { DeoptimizeKind kind, Label* ret, Label* jump_deoptimization_entry_label); - // Calls a C function. - // The called function is not allowed to trigger a + // Calls a C function and cleans up the space for arguments allocated + // by PrepareCallCFunction. The called function is not allowed to trigger a // garbage collection, since that might move the code and invalidate the // return address (unless this is somehow accounted for by the called // function). - enum class SetIsolateDataSlots { - kNo, - kYes, - }; - void CallCFunction( + int CallCFunction( ExternalReference function, int num_reg_arguments, - SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes); - void CallCFunction( + SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes, + Label* return_location = nullptr); + int CallCFunction( ExternalReference function, int num_reg_arguments, int num_double_arguments, - SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes); - void CallCFunction( + SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes, + Label* return_location = nullptr); + int CallCFunction( Register function, int num_reg_arguments, int num_double_arguments, - SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes); + SetIsolateDataSlots set_isolate_data_slots = SetIsolateDataSlots::kYes, + Label* return_location = nullptr); // Performs a truncating conversion of a floating point number as used by // the JS bitwise operations. See ECMA-262 9.5: ToInt32. @@ -1632,7 +1632,8 @@ class V8_EXPORT_PRIVATE MacroAssembler : public MacroAssemblerBase { // Only available when the sandbox is enabled as it requires the code pointer // table. void LoadCodeEntrypointViaCodePointer(Register destination, - MemOperand field_operand); + MemOperand field_operand, + CodeEntrypointTag tag); #endif // Load a protected pointer field. diff --git a/deps/v8/src/codegen/code-stub-assembler.cc b/deps/v8/src/codegen/code-stub-assembler.cc index ec9f176f342d64..cc80f7aaccacb3 100644 --- a/deps/v8/src/codegen/code-stub-assembler.cc +++ b/deps/v8/src/codegen/code-stub-assembler.cc @@ -1842,12 +1842,12 @@ void CodeStubAssembler::StoreExternalPointerToObject(TNode object, #endif // V8_ENABLE_SANDBOX } -TNode CodeStubAssembler::LoadTrustedPointerFromObject( +TNode CodeStubAssembler::LoadTrustedPointerFromObject( TNode object, int field_offset, IndirectPointerTag tag) { #ifdef V8_ENABLE_SANDBOX return LoadIndirectPointerFromObject(object, field_offset, tag); #else - return LoadObjectField(object, field_offset); + return LoadObjectField(object, field_offset); #endif // V8_ENABLE_SANDBOX } @@ -1858,7 +1858,7 @@ TNode CodeStubAssembler::LoadCodePointerFromObject( } #ifdef V8_ENABLE_SANDBOX -TNode CodeStubAssembler::LoadIndirectPointerFromObject( +TNode CodeStubAssembler::LoadIndirectPointerFromObject( TNode object, int field_offset, IndirectPointerTag tag) { TNode handle = LoadObjectField(object, field_offset); @@ -1871,13 +1871,13 @@ TNode CodeStubAssembler::IsTrustedPointerHandle( Int32Constant(0)); } -TNode CodeStubAssembler::ResolveIndirectPointerHandle( +TNode CodeStubAssembler::ResolveIndirectPointerHandle( TNode handle, IndirectPointerTag tag) { // The tag implies which pointer table to use. if (tag == kUnknownIndirectPointerTag) { // In this case we have to rely on the handle marking to determine which // pointer table to use. - return Select( + return Select( IsTrustedPointerHandle(handle), [=] { return ResolveTrustedPointerHandle(handle, tag); }, [=] { return ResolveCodePointerHandle(handle); }); @@ -1903,7 +1903,7 @@ TNode CodeStubAssembler::ResolveCodePointerHandle( return UncheckedCast(BitcastWordToTagged(value)); } -TNode CodeStubAssembler::ResolveTrustedPointerHandle( +TNode CodeStubAssembler::ResolveTrustedPointerHandle( TNode handle, IndirectPointerTag tag) { TNode table = ExternalConstant( ExternalReference::trusted_pointer_table_base_address(isolate())); @@ -1919,7 +1919,7 @@ TNode CodeStubAssembler::ResolveTrustedPointerHandle( // to set it using a bitwise OR as it may or may not be set. value = UncheckedCast(WordOr(value, UintPtrConstant(kHeapObjectTag))); - return UncheckedCast(BitcastWordToTagged(value)); + return UncheckedCast(BitcastWordToTagged(value)); } TNode CodeStubAssembler::ComputeCodePointerTableEntryOffset( @@ -1935,16 +1935,36 @@ TNode CodeStubAssembler::ComputeCodePointerTableEntryOffset( } TNode CodeStubAssembler::LoadCodeEntrypointViaCodePointerField( - TNode object, TNode field_offset) { + TNode object, TNode field_offset, + CodeEntrypointTag tag) { TNode handle = LoadObjectField(object, field_offset); TNode table = ExternalConstant(ExternalReference::code_pointer_table_address()); TNode offset = ComputeCodePointerTableEntryOffset(handle); - return Load(table, offset); + TNode entry = Load(table, offset); + if (tag != 0) { + entry = UncheckedCast(WordXor(entry, UintPtrConstant(tag))); + } + return UncheckedCast(UncheckedCast(entry)); } #endif // V8_ENABLE_SANDBOX +TNode CodeStubAssembler::LoadProtectedPointerFromObject( + TNode object, int offset) { +#ifdef V8_ENABLE_SANDBOX + TNode trusted_cage_base = LoadPointerFromRootRegister( + IntPtrConstant(IsolateData::trusted_cage_base_offset())); + TNode offset_from_cage_base = + ChangeUint32ToWord(LoadObjectField(object, offset)); + TNode pointer = + UncheckedCast(WordOr(trusted_cage_base, offset_from_cage_base)); + return UncheckedCast(BitcastWordToTagged(pointer)); +#else + return LoadObjectField(object, offset); +#endif +} + TNode CodeStubAssembler::LoadFromParentFrame(int offset) { TNode frame_pointer = LoadParentFramePointer(); return LoadFullTagged(frame_pointer, IntPtrConstant(offset)); @@ -2099,13 +2119,8 @@ TNode CodeStubAssembler::LoadSlowProperties( }; NodeGenerator cast_properties = [=] { TNode dict = CAST(properties); - if constexpr (V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL) { - CSA_DCHECK(this, Word32Or(IsSwissNameDictionary(dict), - IsGlobalDictionary(dict))); - } else { - CSA_DCHECK(this, - Word32Or(IsNameDictionary(dict), IsGlobalDictionary(dict))); - } + CSA_DCHECK(this, + Word32Or(IsPropertyDictionary(dict), IsGlobalDictionary(dict))); return dict; }; return Select(TaggedIsSmi(properties), make_empty, @@ -2640,6 +2655,12 @@ TNode CodeStubAssembler::LoadArrayLength( return LoadAndUntagWeakFixedArrayLength(array); } +template <> +TNode CodeStubAssembler::LoadArrayLength( + TNode array) { + return SmiUntag(LoadArrayCapacity(array)); +} + template TNode CodeStubAssembler::LoadArrayElement(TNode array, int array_header_size, @@ -2673,6 +2694,9 @@ template V8_EXPORT_PRIVATE TNode CodeStubAssembler::LoadArrayElement< template V8_EXPORT_PRIVATE TNode CodeStubAssembler::LoadArrayElement( TNode, int, TNode, int); +template V8_EXPORT_PRIVATE TNode +CodeStubAssembler::LoadArrayElement( + TNode, int, TNode, int); template TNode CodeStubAssembler::LoadFixedArrayElement( @@ -3468,27 +3492,17 @@ TNode CodeStubAssembler::LoadSharedFunctionInfoBytecodeArray( this, Word32Equal(DecodeWord32(code_flags), Int32Constant(static_cast(CodeKind::BASELINE)))); #endif // DEBUG - TNode baseline_data = LoadObjectField( + TNode baseline_data = LoadProtectedPointerFromObject( code, Code::kDeoptimizationDataOrInterpreterDataOffset); var_result = baseline_data; - // As long as InterpreterData objects still live inside the sandbox, Code - // references BytecodeArrays through their in-sandbox wrapper object. - static_assert(!kInterpreterDataObjectsLiveInTrustedSpace); - GotoIfNot(HasInstanceType(var_result.value(), BYTECODE_WRAPPER_TYPE), - &check_for_interpreter_data); - TNode bytecode = LoadTrustedPointerFromObject( - var_result.value(), BytecodeWrapper::kBytecodeOffset, - kBytecodeArrayIndirectPointerTag); - var_result = bytecode; - Goto(&done); } + Goto(&check_for_interpreter_data); BIND(&check_for_interpreter_data); GotoIfNot(HasInstanceType(var_result.value(), INTERPRETER_DATA_TYPE), &done); - TNode bytecode_array = CAST(LoadTrustedPointerFromObject( - var_result.value(), InterpreterData::kBytecodeArrayOffset, - kBytecodeArrayIndirectPointerTag)); + TNode bytecode_array = CAST(LoadProtectedPointerFromObject( + CAST(var_result.value()), InterpreterData::kBytecodeArrayOffset)); var_result = bytecode_array; Goto(&done); @@ -4229,6 +4243,40 @@ TNode CodeStubAssembler::AllocateNameDictionaryWithCapacity( return result; } +TNode CodeStubAssembler::AllocatePropertyDictionary( + int at_least_space_for) { + TNode dict; + if constexpr (V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL) { + dict = AllocateSwissNameDictionary(at_least_space_for); + } else { + dict = AllocateNameDictionary(at_least_space_for); + } + return TNode::UncheckedCast(dict); +} + +TNode CodeStubAssembler::AllocatePropertyDictionary( + TNode at_least_space_for, AllocationFlags flags) { + TNode dict; + if constexpr (V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL) { + dict = AllocateSwissNameDictionary(at_least_space_for); + } else { + dict = AllocateNameDictionary(at_least_space_for, flags); + } + return TNode::UncheckedCast(dict); +} + +TNode +CodeStubAssembler::AllocatePropertyDictionaryWithCapacity( + TNode capacity, AllocationFlags flags) { + TNode dict; + if constexpr (V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL) { + dict = AllocateSwissNameDictionaryWithCapacity(capacity); + } else { + dict = AllocateNameDictionaryWithCapacity(capacity, flags); + } + return TNode::UncheckedCast(dict); +} + TNode CodeStubAssembler::CopyNameDictionary( TNode dictionary, Label* large_object_fallback) { Comment("Copy boilerplate property dict"); @@ -4423,9 +4471,8 @@ void CodeStubAssembler::InitializeJSObjectFromMap( StoreObjectFieldRoot(object, JSObject::kPropertiesOrHashOffset, RootIndex::kEmptyFixedArray); } else { - CSA_DCHECK(this, Word32Or(Word32Or(Word32Or(IsPropertyArray(*properties), - IsNameDictionary(*properties)), - IsSwissNameDictionary(*properties)), + CSA_DCHECK(this, Word32Or(Word32Or(IsPropertyArray(*properties), + IsPropertyDictionary(*properties)), IsEmptyFixedArray(*properties))); StoreObjectFieldNoWriteBarrier(object, JSObject::kPropertiesOrHashOffset, *properties); @@ -5013,9 +5060,9 @@ TNode CodeStubAssembler::ExtractToFixedArray( #ifndef V8_ENABLE_SINGLE_GENERATION #ifdef DEBUG TNode object_word = BitcastTaggedToWord(to_elements); - TNode object_page = PageFromAddress(object_word); - TNode page_flags = - Load(object_page, IntPtrConstant(Page::kFlagsOffset)); + TNode object_page_header = PageHeaderFromAddress(object_word); + TNode page_flags = Load( + object_page_header, IntPtrConstant(MemoryChunkLayout::kFlagsOffset)); CSA_DCHECK( this, WordNotEqual( @@ -5414,9 +5461,10 @@ void CodeStubAssembler::JumpIfPointersFromHereAreInteresting( TNode object, Label* interesting) { Label finished(this); TNode object_word = BitcastTaggedToWord(object); - TNode object_page = PageFromAddress(object_word); - TNode page_flags = UncheckedCast(Load( - MachineType::IntPtr(), object_page, IntPtrConstant(Page::kFlagsOffset))); + TNode object_page_header = PageHeaderFromAddress(object_word); + TNode page_flags = UncheckedCast( + Load(MachineType::IntPtr(), object_page_header, + IntPtrConstant(MemoryChunkLayout::kFlagsOffset))); Branch( WordEqual(WordAnd(page_flags, IntPtrConstant( @@ -7617,19 +7665,15 @@ TNode CodeStubAssembler::IsEphemeronHashTable(TNode object) { return HasInstanceType(object, EPHEMERON_HASH_TABLE_TYPE); } -TNode CodeStubAssembler::IsNameDictionary(TNode object) { - return HasInstanceType(object, NAME_DICTIONARY_TYPE); +TNode CodeStubAssembler::IsPropertyDictionary(TNode object) { + return HasInstanceType(object, PROPERTY_DICTIONARY_TYPE); } + TNode CodeStubAssembler::IsOrderedNameDictionary( TNode object) { return HasInstanceType(object, ORDERED_NAME_DICTIONARY_TYPE); } -TNode CodeStubAssembler::IsSwissNameDictionary( - TNode object) { - return HasInstanceType(object, SWISS_NAME_DICTIONARY_TYPE); -} - TNode CodeStubAssembler::IsGlobalDictionary(TNode object) { return HasInstanceType(object, GLOBAL_DICTIONARY_TYPE); } @@ -7823,10 +7867,10 @@ TNode CodeStubAssembler::IsNumberArrayIndex(TNode number) { TNode CodeStubAssembler::LoadBasicMemoryChunkFlags( TNode object) { TNode object_word = BitcastTaggedToWord(object); - TNode page = PageFromAddress(object_word); + TNode page_header = PageHeaderFromAddress(object_word); return UncheckedCast( - Load(MachineType::Pointer(), page, - IntPtrConstant(BasicMemoryChunk::kFlagsOffset))); + Load(MachineType::Pointer(), page_header, + IntPtrConstant(MemoryChunkLayout::kFlagsOffset))); } template @@ -9410,7 +9454,8 @@ TNode CodeStubAssembler::NameToIndexHashTableLookup( template void CodeStubAssembler::NameDictionaryLookup( TNode dictionary, TNode unique_name, Label* if_found, - TVariable* var_name_index, Label* if_not_found, LookupMode mode) { + TVariable* var_name_index, Label* if_not_found_no_insertion_index, + LookupMode mode, Label* if_not_found_with_insertion_index) { static_assert(std::is_same::value || std::is_same::value || std::is_same::value, @@ -9418,8 +9463,13 @@ void CodeStubAssembler::NameDictionaryLookup( DCHECK_IMPLIES(var_name_index != nullptr, MachineType::PointerRepresentation() == var_name_index->rep()); DCHECK_IMPLIES(mode == kFindInsertionIndex, if_found == nullptr); + DCHECK_IMPLIES(if_not_found_with_insertion_index != nullptr, + var_name_index != nullptr); Comment("NameDictionaryLookup"); CSA_DCHECK(this, IsUniqueName(unique_name)); + if (if_not_found_with_insertion_index == nullptr) { + if_not_found_with_insertion_index = if_not_found_no_insertion_index; + } Label if_not_computed(this, Label::kDeferred); @@ -9453,16 +9503,17 @@ void CodeStubAssembler::NameDictionaryLookup( TNode current = CAST(UnsafeLoadFixedArrayElement(dictionary, index)); - GotoIf(TaggedEqual(current, undefined), if_not_found); + GotoIf(TaggedEqual(current, undefined), if_not_found_with_insertion_index); if (mode == kFindExisting) { - if (Dictionary::ShapeT::kMatchNeedsHoleCheck) { + if (Dictionary::TodoShape::kMatchNeedsHoleCheck) { GotoIf(TaggedEqual(current, TheHoleConstant()), &next_probe); } current = LoadName(current); GotoIf(TaggedEqual(current, unique_name), if_found); } else { DCHECK_EQ(kFindInsertionIndex, mode); - GotoIf(TaggedEqual(current, TheHoleConstant()), if_not_found); + GotoIf(TaggedEqual(current, TheHoleConstant()), + if_not_found_with_insertion_index); } Goto(&next_probe); @@ -9507,14 +9558,19 @@ void CodeStubAssembler::NameDictionaryLookup( std::make_pair(MachineType::Pointer(), isolate_ptr), std::make_pair(MachineType::TaggedPointer(), dictionary), std::make_pair(MachineType::TaggedPointer(), unique_name))); + if (var_name_index) *var_name_index = EntryToIndex(entry); if (mode == kFindExisting) { GotoIf(IntPtrEqual(entry, IntPtrConstant(InternalIndex::NotFound().raw_value())), - if_not_found); + if_not_found_no_insertion_index); Goto(if_found); } else { - Goto(if_not_found); + CSA_DCHECK( + this, + WordNotEqual(entry, + IntPtrConstant(InternalIndex::NotFound().raw_value()))); + Goto(if_not_found_with_insertion_index); } } } @@ -9524,10 +9580,11 @@ template V8_EXPORT_PRIVATE void CodeStubAssembler::NameDictionaryLookup(TNode, TNode, Label*, TVariable*, - Label*, LookupMode); + Label*, LookupMode, + Label*); template V8_EXPORT_PRIVATE void CodeStubAssembler::NameDictionaryLookup< GlobalDictionary>(TNode, TNode, Label*, - TVariable*, Label*, LookupMode); + TVariable*, Label*, LookupMode, Label*); TNode CodeStubAssembler::ComputeSeededHash(TNode key) { const TNode function_addr = @@ -9547,10 +9604,13 @@ TNode CodeStubAssembler::ComputeSeededHash(TNode key) { template <> void CodeStubAssembler::NameDictionaryLookup( TNode dictionary, TNode unique_name, - Label* if_found, TVariable* var_name_index, Label* if_not_found, - LookupMode mode) { + Label* if_found, TVariable* var_name_index, + Label* if_not_found_no_insertion_index, LookupMode mode, + Label* if_not_found_with_insertion_index) { + // TODO(pthier): Support path for not found with valid insertion index for + // SwissNameDictionary. SwissNameDictionaryFindEntry(dictionary, unique_name, if_found, - var_name_index, if_not_found); + var_name_index, if_not_found_no_insertion_index); } void CodeStubAssembler::NumberDictionaryLookup( @@ -9707,9 +9767,9 @@ void CodeStubAssembler::InsertEntry( } template -void CodeStubAssembler::AddToDictionary(TNode dictionary, - TNode key, TNode value, - Label* bailout) { +void CodeStubAssembler::AddToDictionary( + TNode dictionary, TNode key, TNode value, + Label* bailout, base::Optional> insertion_index) { CSA_DCHECK(this, Word32BinaryNot(IsEmptyPropertyDictionary(dictionary))); TNode capacity = GetCapacity(dictionary); TNode nof = GetNumberOfElements(dictionary); @@ -9737,16 +9797,21 @@ void CodeStubAssembler::AddToDictionary(TNode dictionary, SetNextEnumerationIndex(dictionary, new_enum_index); SetNumberOfElements(dictionary, new_nof); - TVARIABLE(IntPtrT, var_key_index); - FindInsertionEntry(dictionary, key, &var_key_index); - InsertEntry(dictionary, key, value, var_key_index.value(), - enum_index); + if (insertion_index.has_value()) { + InsertEntry(dictionary, key, value, *insertion_index, + enum_index); + } else { + TVARIABLE(IntPtrT, var_key_index); + FindInsertionEntry(dictionary, key, &var_key_index); + InsertEntry(dictionary, key, value, var_key_index.value(), + enum_index); + } } template <> -void CodeStubAssembler::AddToDictionary(TNode dictionary, - TNode key, TNode value, - Label* bailout) { +void CodeStubAssembler::AddToDictionary( + TNode dictionary, TNode key, TNode value, + Label* bailout, base::Optional> insertion_index) { PropertyDetails d(PropertyKind::kData, NONE, PropertyDetails::kConstIfDictConstnessTracking); @@ -9765,11 +9830,13 @@ void CodeStubAssembler::AddToDictionary(TNode dictionary, Goto(¬_private); BIND(¬_private); + // TODO(pthier): Use insertion_index if it was provided. SwissNameDictionaryAdd(dictionary, key, value, var_details.value(), bailout); } template void CodeStubAssembler::AddToDictionary( - TNode, TNode, TNode, Label*); + TNode, TNode, TNode, Label*, + base::Optional>); template TNode CodeStubAssembler::GetNumberOfElements( @@ -11083,9 +11150,9 @@ TNode CodeStubAssembler::GetInterestingProperty( TNode properties = LoadObjectField(holder, JSObject::kPropertiesOrHashOffset); CSA_DCHECK(this, TaggedIsNotSmi(properties)); + CSA_DCHECK(this, IsPropertyDictionary(CAST(properties))); // TODO(pthier): Support swiss dictionaries. if constexpr (!V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL) { - CSA_DCHECK(this, IsNameDictionary(CAST(properties))); TNode flags = GetNameDictionaryFlags(CAST(properties)); GotoIf(IsSetSmi(flags, @@ -12748,10 +12815,10 @@ void CodeStubAssembler::TrapAllocationMemento(TNode object, TNode object_word = BitcastTaggedToWord(object); // TODO(v8:11641): Skip TrapAllocationMemento when allocation-site // tracking is disabled. - TNode object_page = PageFromAddress(object_word); + TNode object_page_header = PageHeaderFromAddress(object_word); { - TNode page_flags = - Load(object_page, IntPtrConstant(Page::kFlagsOffset)); + TNode page_flags = Load( + object_page_header, IntPtrConstant(MemoryChunkLayout::kFlagsOffset)); GotoIf(WordEqual( WordAnd(page_flags, IntPtrConstant(MemoryChunk::kIsInYoungGenerationMask)), @@ -12767,20 +12834,23 @@ void CodeStubAssembler::TrapAllocationMemento(TNode object, TNode memento_last_word = IntPtrAdd( object_word, IntPtrConstant(kMementoLastWordOffset - kHeapObjectTag)); - TNode memento_last_word_page = PageFromAddress(memento_last_word); + TNode memento_last_word_page_header = + PageHeaderFromAddress(memento_last_word); TNode new_space_top = Load(new_space_top_address); - TNode new_space_top_page = PageFromAddress(new_space_top); + TNode new_space_top_page_header = + PageHeaderFromAddress(new_space_top); // If the object is in new space, we need to check whether respective // potential memento object is on the same page as the current top. - GotoIf(WordEqual(memento_last_word_page, new_space_top_page), &top_check); + GotoIf(WordEqual(memento_last_word_page_header, new_space_top_page_header), + &top_check); // The object is on a different page than allocation top. Bail out if the // object sits on the page boundary as no memento can follow and we cannot // touch the memory following it. - Branch(WordEqual(object_page, memento_last_word_page), &map_check, - &no_memento_found); + Branch(WordEqual(object_page_header, memento_last_word_page_header), + &map_check, &no_memento_found); // If top is on the same page as the current object, we need to check whether // we are below top. @@ -12804,9 +12874,22 @@ void CodeStubAssembler::TrapAllocationMemento(TNode object, Comment("] TrapAllocationMemento"); } +TNode CodeStubAssembler::PageHeaderFromAddress( + TNode address) { + DCHECK(!V8_ENABLE_THIRD_PARTY_HEAP_BOOL); + return WordAnd( + address, + IntPtrConstant(~MemoryChunkHeader::GetAlignmentMaskForAssembler())); +} + +TNode CodeStubAssembler::PageFromPageHeader(TNode address) { + DCHECK(!V8_ENABLE_THIRD_PARTY_HEAP_BOOL); + return address; +} + TNode CodeStubAssembler::PageFromAddress(TNode address) { DCHECK(!V8_ENABLE_THIRD_PARTY_HEAP_BOOL); - return WordAnd(address, IntPtrConstant(~kPageAlignmentMask)); + return PageFromPageHeader(PageHeaderFromAddress(address)); } TNode CodeStubAssembler::CreateAllocationSiteInFeedbackVector( @@ -13230,6 +13313,18 @@ TNode CodeStubAssembler::GotoIfHasContextExtensionUpToDepth( Goto(&context_search); BIND(&context_search); { +#if DEBUG + // Const tracking let data is stored in the extension slot of a + // ScriptContext - however, it's unrelated to the sloppy eval variable + // extension. We should never iterate through a ScriptContext here. + auto scope_info = LoadScopeInfo(cur_context.value()); + TNode flags = + LoadAndUntagToWord32ObjectField(scope_info, ScopeInfo::kFlagsOffset); + auto scope_type = DecodeWord32(flags); + CSA_DCHECK(this, Word32NotEqual(scope_type, + Int32Constant(ScopeType::SCRIPT_SCOPE))); +#endif + // Check if context has an extension slot. TNode has_extension = LoadScopeInfoHasExtensionField(LoadScopeInfo(cur_context.value())); @@ -16301,8 +16396,8 @@ TNode CodeStubAssembler::GetSharedFunctionInfoCode( CSA_DCHECK(this, Word32Equal(data_type, Int32Constant(INTERPRETER_DATA_TYPE))); { - TNode trampoline = LoadCodePointerFromObject( - CAST(sfi_data), InterpreterData::kInterpreterTrampolineOffset); + TNode trampoline = CAST(LoadProtectedPointerFromObject( + CAST(sfi_data), InterpreterData::kInterpreterTrampolineOffset)); sfi_code = trampoline; } Goto(&done); @@ -16329,12 +16424,13 @@ TNode CodeStubAssembler::GetSharedFunctionInfoCode( return sfi_code.value(); } -TNode CodeStubAssembler::LoadCodeInstructionStart(TNode code) { +TNode CodeStubAssembler::LoadCodeInstructionStart( + TNode code, CodeEntrypointTag tag) { #ifdef V8_ENABLE_SANDBOX // In this case, the entrypoint is stored in the code pointer table entry // referenced via the Code object's 'self' indirect pointer. return LoadCodeEntrypointViaCodePointerField( - code, Code::kSelfIndirectPointerOffset); + code, Code::kSelfIndirectPointerOffset, tag); #else return LoadObjectField(code, Code::kInstructionStartOffset); #endif @@ -16439,15 +16535,14 @@ TNode CodeStubAssembler::CheckEnumCache(TNode receiver, // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85149 // TODO(miladfarca): Use `if constexpr` once all compilers handle this // properly. + CSA_DCHECK(this, Word32Or(IsPropertyDictionary(properties), + IsGlobalDictionary(properties))); if (V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL) { - CSA_DCHECK(this, Word32Or(IsSwissNameDictionary(properties), - IsGlobalDictionary(properties))); - length = Select( - IsSwissNameDictionary(properties), + IsPropertyDictionary(properties), [=] { return GetNumberOfElements( - UncheckedCast(properties)); + UncheckedCast(properties)); }, [=] { return GetNumberOfElements( @@ -16455,8 +16550,6 @@ TNode CodeStubAssembler::CheckEnumCache(TNode receiver, }); } else { - CSA_DCHECK(this, Word32Or(IsNameDictionary(properties), - IsGlobalDictionary(properties))); static_assert(static_cast(NameDictionary::kNumberOfElementsIndex) == static_cast(GlobalDictionary::kNumberOfElementsIndex)); length = GetNumberOfElements(UncheckedCast(properties)); diff --git a/deps/v8/src/codegen/code-stub-assembler.h b/deps/v8/src/codegen/code-stub-assembler.h index 3b2793a4913439..7d687744c10ed1 100644 --- a/deps/v8/src/codegen/code-stub-assembler.h +++ b/deps/v8/src/codegen/code-stub-assembler.h @@ -18,6 +18,7 @@ #include "src/objects/arguments.h" #include "src/objects/bigint.h" #include "src/objects/cell.h" +#include "src/objects/dictionary.h" #include "src/objects/feedback-vector.h" #include "src/objects/heap-number.h" #include "src/objects/hole.h" @@ -358,6 +359,14 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; #define CSA_SLOW_DCHECK(csa, ...) ((void)0) #endif +// Similar to SBXCHECK in C++, these become a CSA_CHECK in sandbox-enabled +// builds, otherwise a CSA_DCHECK. +#ifdef V8_ENABLE_SANDBOX +#define CSA_SBXCHECK(csa, ...) CSA_CHECK(csa, __VA_ARGS__) +#else +#define CSA_SBXCHECK(csa, ...) CSA_DCHECK(csa, __VA_ARGS__) +#endif + // Provides JavaScript-specific "macro-assembler" functionality on top of the // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, // it's possible to add JavaScript-specific useful CodeAssembler "macros" @@ -922,7 +931,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler void FastCheck(TNode condition); - TNode LoadCodeInstructionStart(TNode code); + TNode LoadCodeInstructionStart(TNode code, + CodeEntrypointTag tag); TNode IsMarkedForDeoptimization(TNode code); // The following Call wrappers call an object according to the semantics that @@ -1193,9 +1203,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler // Load a trusted pointer field. // When the sandbox is enabled, these are indirect pointers using the trusted // pointer table. Otherwise they are regular tagged fields. - TNode LoadTrustedPointerFromObject(TNode object, - int offset, - IndirectPointerTag tag); + TNode LoadTrustedPointerFromObject(TNode object, + int offset, + IndirectPointerTag tag); // Load a code pointer field. // These are special versions of trusted pointers that, when the sandbox is @@ -1204,9 +1214,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler #ifdef V8_ENABLE_SANDBOX // Load an indirect pointer field. - TNode LoadIndirectPointerFromObject(TNode object, - int offset, - IndirectPointerTag tag); + TNode LoadIndirectPointerFromObject(TNode object, + int offset, + IndirectPointerTag tag); // Determines whether the given indirect pointer handle is a trusted pointer // handle or a code pointer handle. @@ -1214,14 +1224,14 @@ class V8_EXPORT_PRIVATE CodeStubAssembler // Retrieve the heap object referenced by the given indirect pointer handle, // which can either be a trusted pointer handle or a code pointer handle. - TNode ResolveIndirectPointerHandle( + TNode ResolveIndirectPointerHandle( TNode handle, IndirectPointerTag tag); // Retrieve the Code object referenced by the given trusted pointer handle. TNode ResolveCodePointerHandle(TNode handle); // Retrieve the heap object referenced by the given trusted pointer handle. - TNode ResolveTrustedPointerHandle( + TNode ResolveTrustedPointerHandle( TNode handle, IndirectPointerTag tag); // Helper function to compute the offset into the code pointer table from a @@ -1233,14 +1243,19 @@ class V8_EXPORT_PRIVATE CodeStubAssembler // Only available when the sandbox is enabled as it requires the code pointer // table. TNode LoadCodeEntrypointViaCodePointerField(TNode object, - int offset) { - return LoadCodeEntrypointViaCodePointerField(object, - IntPtrConstant(offset)); + int offset, + CodeEntrypointTag tag) { + return LoadCodeEntrypointViaCodePointerField(object, IntPtrConstant(offset), + tag); } TNode LoadCodeEntrypointViaCodePointerField(TNode object, - TNode offset); + TNode offset, + CodeEntrypointTag tag); #endif + TNode LoadProtectedPointerFromObject( + TNode object, int offset); + TNode LoadForeignForeignAddressPtr(TNode object) { return LoadExternalPointerFromObject(object, Foreign::kForeignAddressOffset, kForeignForeignAddressTag); @@ -1289,11 +1304,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler TNode object) { #ifdef V8_ENABLE_SANDBOX return LoadCodeEntrypointViaCodePointerField( - object, WasmInternalFunction::kCodeOffset); + object, WasmInternalFunction::kCodeOffset, kWasmEntrypointTag); #else TNode code = LoadObjectField(object, WasmInternalFunction::kCodeOffset); - return LoadCodeInstructionStart(code); + return LoadCodeInstructionStart(code, kWasmEntrypointTag); #endif // V8_ENABLE_SANDBOX } @@ -2192,6 +2207,14 @@ class V8_EXPORT_PRIVATE CodeStubAssembler AllocationFlags = AllocationFlag::kNone); TNode AllocateNameDictionaryWithCapacity( TNode capacity, AllocationFlags = AllocationFlag::kNone); + + TNode AllocatePropertyDictionary(int at_least_space_for); + TNode AllocatePropertyDictionary( + TNode at_least_space_for, + AllocationFlags = AllocationFlag::kNone); + TNode AllocatePropertyDictionaryWithCapacity( + TNode capacity, AllocationFlags = AllocationFlag::kNone); + TNode CopyNameDictionary(TNode dictionary, Label* large_object_fallback); @@ -2865,7 +2888,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler TNode IsConstructorMap(TNode map); TNode IsConstructor(TNode object); TNode IsDeprecatedMap(TNode map); - TNode IsNameDictionary(TNode object); + TNode IsPropertyDictionary(TNode object); TNode IsOrderedNameDictionary(TNode object); TNode IsGlobalDictionary(TNode object); TNode IsExtensibleMap(TNode map); @@ -2978,7 +3001,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler TNode IsStringInstanceType(TNode instance_type); TNode IsString(TNode object); TNode IsSeqOneByteString(TNode object); - TNode IsSwissNameDictionary(TNode object); TNode IsSymbolInstanceType(TNode instance_type); TNode IsInternalizedStringInstanceType(TNode instance_type); @@ -3511,24 +3533,40 @@ class V8_EXPORT_PRIVATE CodeStubAssembler template void SetNameDictionaryFlags(TNode, TNode flags); - // Looks up an entry in a NameDictionaryBase successor. If the entry is found - // control goes to {if_found} and {var_name_index} contains an index of the - // key field of the entry found. If the key is not found control goes to - // {if_not_found}. enum LookupMode { kFindExisting, kFindInsertionIndex }; template TNode LoadName(TNode key); + // Looks up an entry in a NameDictionaryBase successor. + // For {mode} == kFindExisting: + // If the entry is found control goes to {if_found} and {var_name_index} + // contains an index of the key field of the entry found. + // If the key is not found and {if_not_found_with_insertion_index} is + // provided, control goes to {if_not_found_with_insertion_index} and + // {var_name_index} contains the index of the key field to insert the given + // name at. + // Otherwise control goes to {if_not_found_no_insertion_index}. + // For {mode} == kFindInsertionIndex: + // {if_not_found_no_insertion_index} and {if_not_found_with_insertion_index} + // are treated equally. If {if_not_found_with_insertion_index} is provided, + // control goes to {if_not_found_with_insertion_index}, otherwise control + // goes to {if_not_found_no_insertion_index}. In both cases {var_name_index} + // contains the index of the key field to insert the given name at. template void NameDictionaryLookup(TNode dictionary, TNode unique_name, Label* if_found, TVariable* var_name_index, - Label* if_not_found, - LookupMode mode = kFindExisting); + Label* if_not_found_no_insertion_index, + LookupMode mode = kFindExisting, + Label* if_not_found_with_insertion_index = nullptr); TNode ComputeSeededHash(TNode key); + // Looks up an entry in a NameDictionaryBase successor. If the entry is found + // control goes to {if_found} and {var_name_index} contains an index of the + // key field of the entry found. If the key is not found control goes to + // {if_not_found}. void NumberDictionaryLookup(TNode dictionary, TNode intptr_index, Label* if_found, TVariable* var_entry, @@ -3548,8 +3586,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler TNode enum_index); template - void AddToDictionary(TNode dictionary, TNode key, - TNode value, Label* bailout); + void AddToDictionary( + TNode dictionary, TNode key, TNode value, + Label* bailout, + base::Optional> insertion_index = base::nullopt); // Tries to check if {object} has own {unique_name} property. void TryHasOwnProperty(TNode object, TNode map, @@ -3875,6 +3915,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler void TrapAllocationMemento(TNode object, Label* memento_found); + // Helpers to look up MemoryChunk/Page metadata for a given address. + // Equivalent to MemoryChunkHeader::FromAddress(). + TNode PageHeaderFromAddress(TNode address); + // Equivalent to MemoryChunkHeader::MemoryChunk(). + TNode PageFromPageHeader(TNode address); + // Equivalent to BasicMemoryChunk::FromAddress(). TNode PageFromAddress(TNode address); // Store a weak in-place reference into the FeedbackVector. diff --git a/deps/v8/src/codegen/compiler.cc b/deps/v8/src/codegen/compiler.cc index c38fad5d3a38df..93ef078548674b 100644 --- a/deps/v8/src/codegen/compiler.cc +++ b/deps/v8/src/codegen/compiler.cc @@ -1720,8 +1720,10 @@ BackgroundCompileTask::BackgroundCompileTask( BackgroundCompileTask::~BackgroundCompileTask() = default; +namespace { + void SetScriptFieldsFromDetails(Isolate* isolate, Tagged