diff --git a/.bazelrc b/.bazelrc index 7a92aa5ec24..510ccdc5b6e 100644 --- a/.bazelrc +++ b/.bazelrc @@ -78,6 +78,9 @@ build:unix --host_cxxopt=-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES # Need to redefine _WIN32_WINNT to build dawn on Windows build:windows --per_file_copt='external/dawn@-Wno-macro-redefined' build:windows --host_per_file_copt='external/dawn@-Wno-macro-redefined' +# V8 now requires Windows 10, Bazel fails to set this properly. +build:windows --per_file_copt=external/v8/src/base/platform/platform-win32.cc@-D_WIN32_WINNT=0x0A00 +build:windows --host_per_file_copt=external/v8/src/base/platform/platform-win32.cc@-D_WIN32_WINNT=0x0A00 # typescript configuration # do more correct type checking diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 172c3d8d9dd..b0a582d2aa9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,7 +2,7 @@ FROM mcr.microsoft.com/devcontainers/base:jammy # Install dependencies, including clang via through LLVM APT repository. Note that this # will also install lldb and clangd alongside dependencies. -ARG LLVM_VERSION=15 +ARG LLVM_VERSION=16 RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install --no-install-recommends software-properties-common python3 python3-distutils tclsh \ && curl -fSsL -o /tmp/llvm.sh https://apt.llvm.org/llvm.sh && chmod +x /tmp/llvm.sh && bash /tmp/llvm.sh ${LLVM_VERSION} \ diff --git a/.github/workflows/npm-types.yml b/.github/workflows/npm-types.yml index 333f3887698..03818fcbd5d 100644 --- a/.github/workflows/npm-types.yml +++ b/.github/workflows/npm-types.yml @@ -50,10 +50,10 @@ jobs: wget https://apt.llvm.org/llvm.sh sed -i '/apt-get install/d' llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 15 - sudo apt-get install -y --no-install-recommends clang-15 lld-15 libunwind-15 libc++abi1-15 libc++1-15 libc++-15-dev - echo "build:linux --action_env=CC=/usr/lib/llvm-15/bin/clang --action_env=CXX=/usr/lib/llvm-15/bin/clang++" >> .bazelrc - echo "build:linux --host_action_env=CC=/usr/lib/llvm-15/bin/clang --host_action_env=CXX=/usr/lib/llvm-15/bin/clang++" >> .bazelrc + sudo ./llvm.sh 16 + sudo apt-get install -y --no-install-recommends clang-16 lld-16 libunwind-16 libc++abi1-16 libc++1-16 libc++-16-dev + echo "build:linux --action_env=CC=/usr/lib/llvm-16/bin/clang --action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc + echo "build:linux --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc - name: build types run: | bazel build --disk_cache=~/bazel-disk-cache --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=release_linux //types:types diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index cdd55611eb1..1b6f26530d4 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -101,10 +101,10 @@ jobs: wget https://apt.llvm.org/llvm.sh sed -i '/apt-get install/d' llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 15 - sudo apt-get install -y --no-install-recommends clang-15 lld-15 libunwind-15 libc++abi1-15 libc++1-15 libc++-15-dev - echo "build:linux --action_env=CC=/usr/lib/llvm-15/bin/clang --action_env=CXX=/usr/lib/llvm-15/bin/clang++" >> .bazelrc - echo "build:linux --host_action_env=CC=/usr/lib/llvm-15/bin/clang --host_action_env=CXX=/usr/lib/llvm-15/bin/clang++" >> .bazelrc + sudo ./llvm.sh 16 + sudo apt-get install -y --no-install-recommends clang-16 lld-16 libunwind-16 libc++abi1-16 libc++1-16 libc++-16-dev + echo "build:linux --action_env=CC=/usr/lib/llvm-16/bin/clang --action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc + echo "build:linux --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc - name: Build type generating Worker run: | bazel build --disk_cache=~/bazel-disk-cache --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=release_linux //types:types_worker diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 126ef543f75..ab1dc9acf55 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -88,10 +88,10 @@ jobs: wget https://apt.llvm.org/llvm.sh sed -i '/apt-get install/d' llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 15 - sudo apt-get install -y --no-install-recommends clang-15 lld-15 libunwind-15 libc++abi1-15 libc++1-15 libc++-15-dev - echo "build:linux --action_env=CC=/usr/lib/llvm-15/bin/clang --action_env=CXX=/usr/lib/llvm-15/bin/clang++" >> .bazelrc - echo "build:linux --host_action_env=CC=/usr/lib/llvm-15/bin/clang --host_action_env=CXX=/usr/lib/llvm-15/bin/clang++" >> .bazelrc + sudo ./llvm.sh 16 + sudo apt-get install -y --no-install-recommends clang-16 lld-16 libunwind-16 libc++abi1-16 libc++1-16 libc++-16-dev + echo "build:linux --action_env=CC=/usr/lib/llvm-16/bin/clang --action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc + echo "build:linux --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc - name: Setup macOS if: runner.os == 'macOS' run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41431e8f89f..155acaafce7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,22 +75,20 @@ jobs: # libc++, but this appears to cause errors so they are also being explicitly installed. # Since the GitHub runner image comes with a number of preinstalled packages, we don't need # to use APT much otherwise. - # TODO(cleanup): Upgrade this to LLVM 16 as soon as it is available on the latest Ubuntu - # LTS release. Debian includes LLVM 16 since the Bookworm 12.4 point release. run: | export DEBIAN_FRONTEND=noninteractive wget https://apt.llvm.org/llvm.sh sed -i '/apt-get install/d' llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 15 - sudo apt-get install -y --no-install-recommends clang-15 lld-15 libunwind-15 libc++abi1-15 libc++1-15 libc++-15-dev libclang-rt-15-dev - echo "build:linux --action_env=CC=/usr/lib/llvm-15/bin/clang --action_env=CXX=/usr/lib/llvm-15/bin/clang++" >> .bazelrc - echo "build:linux --host_action_env=CC=/usr/lib/llvm-15/bin/clang --host_action_env=CXX=/usr/lib/llvm-15/bin/clang++" >> .bazelrc - sed -i -e "s%llvm-symbolizer%/usr/lib/llvm-15/bin/llvm-symbolizer%" .bazelrc + sudo ./llvm.sh 16 + sudo apt-get install -y --no-install-recommends clang-16 lld-16 libunwind-16 libc++abi1-16 libc++1-16 libc++-16-dev libclang-rt-16-dev + echo "build:linux --action_env=CC=/usr/lib/llvm-16/bin/clang --action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc + echo "build:linux --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc + sed -i -e "s%llvm-symbolizer%/usr/lib/llvm-16/bin/llvm-symbolizer%" .bazelrc - name: Setup macOS if: matrix.os.name == 'macOS' # TODO: We want to symbolize stacks for crashes on CI. Xcode is currently based on LLVM 16 - # and the macos-13 image has llvm@15 installed: + # but the macos-13 image has llvm@15 installed: # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md # # Not enabled because symbolication does not work on workerd macOS builds yet and running diff --git a/Dockerfile.release b/Dockerfile.release index 40db989c4ee..5f084d926eb 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -1,6 +1,5 @@ -# TODO(later): llvm-toolchain-16 is expected to be backported to Bullseye with the 11.9 point -# release (https://tracker.debian.org/pkg/llvm-toolchain-16). Switch to using the regular packages -# instead of packages from LLVM's APT repo once 11.9 is available and we have upgraded to LLVM 16. +# TODO(later): llvm-toolchain-16 has been backported to Bullseye with the 11.9 point release – +# switch to using the regular packages instead of LLVM's APT repo here. FROM node:bullseye AS builder WORKDIR /workerd @@ -13,12 +12,12 @@ RUN wget https://apt.llvm.org/llvm.sh # Drop the install step here so we can install just the packages we need. RUN sed -i '/apt-get install/d' llvm.sh RUN chmod +x llvm.sh -RUN ./llvm.sh 15 -RUN apt-get install -y --no-install-recommends clang-15 lld-15 libunwind-15 libc++abi1-15 libc++1-15 libc++-15-dev libclang-rt-15-dev +RUN ./llvm.sh 16 +RUN apt-get install -y --no-install-recommends clang-16 lld-16 libunwind-16 libc++abi1-16 libc++1-16 libc++-16-dev libclang-rt-16-dev COPY . . -RUN echo "build:linux --action_env=CC=/usr/lib/llvm-15/bin/clang --action_env=CXX=/usr/lib/llvm-15/bin/clang++" >> .bazelrc -RUN echo "build:linux --host_action_env=CC=/usr/lib/llvm-15/bin/clang --host_action_env=CXX=/usr/lib/llvm-15/bin/clang++" >> .bazelrc +RUN echo "build:linux --action_env=CC=/usr/lib/llvm-16/bin/clang --action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc +RUN echo "build:linux --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc COPY .bazel-cache /bazel-disk-cache RUN npm install -g pnpm@latest-7 RUN pnpm install diff --git a/README.md b/README.md index 1bd3eeb1679..08dfce29161 100644 --- a/README.md +++ b/README.md @@ -72,11 +72,11 @@ To build `workerd`, you need: * [Bazel](https://bazel.build/) * If you use [Bazelisk](https://github.com/bazelbuild/bazelisk) (recommended), it will automatically download and use the right version of Bazel for building workerd. * On Linux: - * We use the clang/LLVM toolchain to build workerd and support version 15 and higher. Earlier versions of clang may still work, but are not officially supported. - * Clang 15+ (e.g. package `clang-15` on Debian Bookworm). If clang is installed as `clang-` please create a symlink to it in your PATH named `clang`, or use `--action_env=CC=clang-` on `bazel` command lines to specify the compiler name. + * We use the clang/LLVM toolchain to build workerd and support version 16 and higher. Earlier versions of clang may still work, but are not officially supported. + * Clang 16+ (e.g. package `clang-16` on Debian Bookworm). If clang is installed as `clang-` please create a symlink to it in your PATH named `clang`, or use `--action_env=CC=clang-` on `bazel` command lines to specify the compiler name. - * libc++ 15+ (e.g. packages `libc++-15-dev` and `libc++abi-15-dev`) - * LLD 15+ (e.g. package `lld-15`). The build may still succeed if a recent version of GNU gold or the system linker is installed, but lld is highly recommended for link performance. + * libc++ 16+ (e.g. packages `libc++-16-dev` and `libc++abi-16-dev`) + * LLD 16+ (e.g. package `lld-16`). The build may still succeed if a recent version of GNU gold or the system linker is installed, but lld is highly recommended for link performance. * `python3`, `python3-distutils`, and `tcl8.6` * On macOS: * Xcode 15 installation (available on macOS 13 and higher). Full Xcode is required, the Xcode command line tools alone are not sufficient for building. diff --git a/WORKSPACE b/WORKSPACE index 93b0f511b13..ea1e6d4bdce 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -214,7 +214,7 @@ http_archive( # to confusing compiler errors in tcmalloc in the past. git_repository( name = "com_google_absl", - commit = "bfe59c2726fda7494a800f7d0ee461f0564653b3", + commit = "9d1552f25c3d9e9114b7d7aed55790570a99bc4d", remote = "https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp.git", ) @@ -483,26 +483,30 @@ http_archive( "//:patches/v8/0007-Implement-Promise-Context-Tagging.patch", "//:patches/v8/0008-Enable-V8-shared-linkage.patch", "//:patches/v8/0009-Randomize-the-initial-ExecutionContextId-used-by-the.patch", - "//:patches/v8/0010-Always-enable-continuation-preserved-data-in-the-bui.patch", - "//:patches/v8/0011-increase-visibility-of-virtual-method.patch", - "//:patches/v8/0012-Add-ValueSerializer-SetTreatFunctionsAsHostObjects.patch", - "//:patches/v8/0013-Set-torque-generator-path-to-external-v8.-This-allow.patch", - "//:patches/v8/0014-Modify-where-to-look-for-fp16-dependency.-This-depen.patch", - "//:patches/v8/0015-Expose-v8-Symbol-GetDispose.patch", - "//:patches/v8/0016-Rename-V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE-V8_COMPR.patch", - "//:patches/v8/0017-Revert-TracedReference-deref-API-removal.patch", - "//:patches/v8/0018-Revert-heap-Add-masm-specific-unwinding-annotations-.patch", - "//:patches/v8/0019-Update-illegal-invocation-error-message-in-v8.patch", + "//:patches/v8/0010-increase-visibility-of-virtual-method.patch", + "//:patches/v8/0011-Add-ValueSerializer-SetTreatFunctionsAsHostObjects.patch", + "//:patches/v8/0012-Set-torque-generator-path-to-external-v8.-This-allow.patch", + "//:patches/v8/0013-Modify-where-to-look-for-fp16-dependency.-This-depen.patch", + "//:patches/v8/0014-Expose-v8-Symbol-GetDispose.patch", + "//:patches/v8/0015-Rename-V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE-V8_COMPR.patch", + "//:patches/v8/0016-Revert-TracedReference-deref-API-removal.patch", + "//:patches/v8/0017-Revert-heap-Add-masm-specific-unwinding-annotations-.patch", + "//:patches/v8/0018-Update-illegal-invocation-error-message-in-v8.patch", + # TODO(cleanup): Patches backported from V8 12.9 – adding these fixes a race condition + # leading to a segfault in several wasm-related tests under ASan. These are already included + # in 12.9 so remove the patches when updating to that version. + "//:patches/v8/0019-wasm-Fix-more-code-logging-races.patch", + "//:patches/v8/0020-wasm-Remove-destructor-of-LogCodesTask.patch", ], - integrity = "sha256-TKEA0q6AADxlgXHIprTaw/CgQDBB6Vhug3JWlXmFKrg=", - strip_prefix = "v8-12.7.224.13", - url = "https://github.com/v8/v8/archive/refs/tags/12.7.224.13.tar.gz", + integrity = "sha256-yoLczQj1XEZL4EHVRjAwpVjgr9/q0YlRGnNX47Ke2ws=", + strip_prefix = "v8-12.8.374.10", + url = "https://github.com/v8/v8/archive/refs/tags/12.8.374.10.tar.gz", ) git_repository( name = "com_googlesource_chromium_icu", build_file = "@v8//:bazel/BUILD.icu", - commit = "98f2494518c2dbb9c488e83e507b070ea5910e95", + commit = "9408c6fd4a39e6fef0e1c4077602e1c83b15f3fb", patch_cmds = ["find source -name BUILD.bazel | xargs rm"], patch_cmds_win = ["Get-ChildItem -Path source -File -Include BUILD.bazel -Recurse | Remove-Item"], remote = "https://chromium.googlesource.com/chromium/deps/icu.git", diff --git a/compile_flags.txt b/compile_flags.txt index 67fb89da0d8..0f7c9e8e0c3 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -15,8 +15,8 @@ -Iexternal/perfetto/include/perfetto/base/build_configs/bazel/ -Iexternal/ssl/src/include -Isrc --isystem/usr/lib/llvm-15/include/c++/v1 --isystem/usr/lib/llvm-15/lib/clang/15.0.7/include +-isystem/usr/lib/llvm-16/include/c++/v1 +-isystem/usr/lib/llvm-16/lib/clang/16/include -isystem/usr/local/include -isystem/usr/include/x86_64-linux-gnu -isystem/usr/include diff --git a/doxyfile b/doxyfile index 562175436c8..9f7e6fa7bc1 100644 --- a/doxyfile +++ b/doxyfile @@ -1219,8 +1219,8 @@ CLANG_OPTIONS = -std=c++20 \ -I/usr/include/c++/11/bits \ -I/usr/include/x86_64-linux-gnu \ -I/usr/include/x86_64-linux-gnu/c++/11 \ - -I/usr/lib/llvm-15/include/c++/v1 \ - -I/usr/lib/llvm-15/lib/clang/15.0.7/include + -I/usr/lib/llvm-16/include/c++/v1 \ + -I/usr/lib/llvm-16/lib/clang/16/include # If clang assisted parsing is enabled you can provide the clang parser with the # path to the directory containing a file called compile_commands.json. This diff --git a/patches/v8/0001-Allow-manually-setting-ValueDeserializer-format-vers.patch b/patches/v8/0001-Allow-manually-setting-ValueDeserializer-format-vers.patch index 34683f295d0..3de1ee8b3f5 100644 --- a/patches/v8/0001-Allow-manually-setting-ValueDeserializer-format-vers.patch +++ b/patches/v8/0001-Allow-manually-setting-ValueDeserializer-format-vers.patch @@ -1,4 +1,4 @@ -From 9c1e267f52dfe7cd9264680452068ede59805a52 Mon Sep 17 00:00:00 2001 +From 2a878e3f5a956e375cb59e4bccd0f2fa6591d66a Mon Sep 17 00:00:00 2001 From: Alex Robinson Date: Wed, 2 Mar 2022 15:58:04 -0600 Subject: Allow manually setting ValueDeserializer format version @@ -35,10 +35,10 @@ index 0cb3e045bc46ec732956318b980e749d1847d06d..40ad805c7970cc9379e69f046205836d * Reads raw data in various common formats to the buffer. * Note that integer types are read in base-128 varint format, not with a diff --git a/src/api/api.cc b/src/api/api.cc -index 25ec0de2ff0b71451c64b47e83006e22813c44fa..cfb628582eda59cee9426fb8f286f8e5892b0536 100644 +index f8d3c5aa1231f4b62a614bc0c705366d922b4c75..20f02c0eee7a8f921d8e4c0ae2f06df34c22bf6f 100644 --- a/src/api/api.cc +++ b/src/api/api.cc -@@ -3570,6 +3570,10 @@ uint32_t ValueDeserializer::GetWireFormatVersion() const { +@@ -3599,6 +3599,10 @@ uint32_t ValueDeserializer::GetWireFormatVersion() const { return private_->deserializer.GetWireFormatVersion(); } @@ -50,7 +50,7 @@ index 25ec0de2ff0b71451c64b47e83006e22813c44fa..cfb628582eda59cee9426fb8f286f8e5 PREPARE_FOR_EXECUTION(context, ValueDeserializer, ReadValue); i::MaybeHandle result; diff --git a/src/objects/value-serializer.h b/src/objects/value-serializer.h -index 0d38d4a0e0421f449629ab7fb0f2ac6a0093e59b..4e1fbcb160f7f89740a490ddbc448bce2ae6e3a3 100644 +index 094210f286ab107f93b4a0e1529210a5328e0df0..8ec0a77210dda063a8c64d3c52b3209a8194827b 100644 --- a/src/objects/value-serializer.h +++ b/src/objects/value-serializer.h @@ -218,6 +218,13 @@ class ValueDeserializer { diff --git a/patches/v8/0002-Allow-manually-setting-ValueSerializer-format-versio.patch b/patches/v8/0002-Allow-manually-setting-ValueSerializer-format-versio.patch index 3491c16d42e..2df37b5e6ba 100644 --- a/patches/v8/0002-Allow-manually-setting-ValueSerializer-format-versio.patch +++ b/patches/v8/0002-Allow-manually-setting-ValueSerializer-format-versio.patch @@ -1,4 +1,4 @@ -From 3253a1204a2c8403ae3d6ed74099275d0ade9541 Mon Sep 17 00:00:00 2001 +From 89b24ba580034518e735c60838819c062b985c11 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 16 Mar 2022 08:59:21 -0700 Subject: Allow manually setting ValueSerializer format version @@ -22,10 +22,10 @@ index 40ad805c7970cc9379e69f046205836dbd760373..596be18adeb3a5a81794aaa44b1d347d * Writes out a header, which includes the format version. */ diff --git a/src/api/api.cc b/src/api/api.cc -index cfb628582eda59cee9426fb8f286f8e5892b0536..e2c3f310a8d85823e5873d3682122eec8f3d441c 100644 +index 20f02c0eee7a8f921d8e4c0ae2f06df34c22bf6f..404d19e8c5cf4b4505fb9106f0b649b44708e729 100644 --- a/src/api/api.cc +++ b/src/api/api.cc -@@ -3438,6 +3438,10 @@ ValueSerializer::ValueSerializer(Isolate* v8_isolate, Delegate* delegate) +@@ -3467,6 +3467,10 @@ ValueSerializer::ValueSerializer(Isolate* v8_isolate, Delegate* delegate) ValueSerializer::~ValueSerializer() { delete private_; } @@ -37,7 +37,7 @@ index cfb628582eda59cee9426fb8f286f8e5892b0536..e2c3f310a8d85823e5873d3682122eec void ValueSerializer::SetTreatArrayBufferViewsAsHostObjects(bool mode) { diff --git a/src/objects/value-serializer.cc b/src/objects/value-serializer.cc -index 3c6ed8f827a126701b212526f9603832ddb2bce8..2e574704650c3b5d860fc21d083e9e6fed9ddfcf 100644 +index e606ad4f8da446c0edb1b2696eec9701b166719a..96ad656a42173b66974539472467c497b89dc587 100644 --- a/src/objects/value-serializer.cc +++ b/src/objects/value-serializer.cc @@ -291,6 +291,7 @@ ValueSerializer::ValueSerializer(Isolate* isolate, @@ -67,7 +67,7 @@ index 3c6ed8f827a126701b212526f9603832ddb2bce8..2e574704650c3b5d860fc21d083e9e6f } void ValueSerializer::SetTreatArrayBufferViewsAsHostObjects(bool mode) { -@@ -1034,10 +1043,12 @@ Maybe ValueSerializer::WriteJSArrayBufferView( +@@ -1033,10 +1042,12 @@ Maybe ValueSerializer::WriteJSArrayBufferView( WriteVarint(static_cast(tag)); WriteVarint(static_cast(view->byte_offset())); WriteVarint(static_cast(view->byte_length())); @@ -83,7 +83,7 @@ index 3c6ed8f827a126701b212526f9603832ddb2bce8..2e574704650c3b5d860fc21d083e9e6f } diff --git a/src/objects/value-serializer.h b/src/objects/value-serializer.h -index 4e1fbcb160f7f89740a490ddbc448bce2ae6e3a3..c3a44e9f64f944641eea417584429a0b147ef654 100644 +index 8ec0a77210dda063a8c64d3c52b3209a8194827b..27d5d03518e7bfecde240b658f63456c899f378c 100644 --- a/src/objects/value-serializer.h +++ b/src/objects/value-serializer.h @@ -54,6 +54,11 @@ class ValueSerializer { diff --git a/patches/v8/0003-Add-ArrayBuffer-MaybeNew.patch b/patches/v8/0003-Add-ArrayBuffer-MaybeNew.patch index 286d23bd6b0..5d367fada53 100644 --- a/patches/v8/0003-Add-ArrayBuffer-MaybeNew.patch +++ b/patches/v8/0003-Add-ArrayBuffer-MaybeNew.patch @@ -1,4 +1,4 @@ -From 1d861f69dcf5d40faf94b2c844f96432a190b4f2 Mon Sep 17 00:00:00 2001 +From 66ed20eae671ff611f2367ed894340cac7543236 Mon Sep 17 00:00:00 2001 From: Kenton Varda Date: Fri, 16 Sep 2022 21:41:45 -0500 Subject: Add `ArrayBuffer::MaybeNew()`. @@ -8,10 +8,10 @@ In Cloudflare's edge runtime, this is part of a larger patch that allows gracefu (We would like to upstream our internal patch, just need to find the time...) diff --git a/include/v8-array-buffer.h b/include/v8-array-buffer.h -index d625b85496bb4a4b3bb6a48f4f0c48de514d3e37..f8f0abc7e2e6e26815f305e621301b27161f87fd 100644 +index 0a3d8170f68214750907d0469df1a9c652da340e..368250248010b28ea6bf8f83c9836bdca2595f0e 100644 --- a/include/v8-array-buffer.h +++ b/include/v8-array-buffer.h -@@ -216,6 +216,14 @@ class V8_EXPORT ArrayBuffer : public Object { +@@ -217,6 +217,14 @@ class V8_EXPORT ArrayBuffer : public Object { */ size_t MaxByteLength() const; @@ -24,5 +24,5 @@ index d625b85496bb4a4b3bb6a48f4f0c48de514d3e37..f8f0abc7e2e6e26815f305e621301b27 + } + /** - * Create a new ArrayBuffer. Allocate |byte_length| bytes. - * Allocated memory will be owned by a created ArrayBuffer and + * Create a new ArrayBuffer. Allocate |byte_length| bytes, which are either + * zero-initialized or uninitialized. Allocated memory will be owned by a diff --git a/patches/v8/0004-Allow-Windows-builds-under-Bazel.patch b/patches/v8/0004-Allow-Windows-builds-under-Bazel.patch index 81b6483f3a3..9f846dc9afd 100644 --- a/patches/v8/0004-Allow-Windows-builds-under-Bazel.patch +++ b/patches/v8/0004-Allow-Windows-builds-under-Bazel.patch @@ -1,14 +1,14 @@ -From 955b1cda5189cc04f6a94e4b65c512acd0ec9219 Mon Sep 17 00:00:00 2001 +From ba70d45d8258bd31100a63db615a82cb58d95664 Mon Sep 17 00:00:00 2001 From: Brendan Coll Date: Thu, 16 Mar 2023 11:56:10 +0000 Subject: Allow Windows builds under Bazel diff --git a/BUILD.bazel b/BUILD.bazel -index 30be47fa333f75b2572927f8d7b836a99ee76181..338e21dfa9d6aa88711526dece59fb792e84bff7 100644 +index 0718b28b05294698a38de1e13d34fe7a585038ac..e805a5174b9cfe1578c9423b5bbba4004614f0f7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel -@@ -768,6 +768,7 @@ filegroup( +@@ -771,6 +771,7 @@ filegroup( "src/base/platform/mutex.h", "src/base/platform/platform.cc", "src/base/platform/platform.h", @@ -16,7 +16,7 @@ index 30be47fa333f75b2572927f8d7b836a99ee76181..338e21dfa9d6aa88711526dece59fb79 "src/base/platform/semaphore.cc", "src/base/platform/semaphore.h", "src/base/platform/time.cc", -@@ -811,7 +812,6 @@ filegroup( +@@ -814,7 +815,6 @@ filegroup( ] + select({ "@v8//bazel/config:is_posix": [ "src/base/platform/platform-posix.cc", @@ -24,7 +24,7 @@ index 30be47fa333f75b2572927f8d7b836a99ee76181..338e21dfa9d6aa88711526dece59fb79 "src/base/platform/platform-posix-time.cc", "src/base/platform/platform-posix-time.h", ], -@@ -834,6 +834,7 @@ filegroup( +@@ -837,6 +837,7 @@ filegroup( "@v8//bazel/config:is_windows": [ "src/base/debug/stack_trace_win.cc", "src/base/platform/platform-win32.cc", @@ -32,7 +32,7 @@ index 30be47fa333f75b2572927f8d7b836a99ee76181..338e21dfa9d6aa88711526dece59fb79 "src/base/win32-headers.h", ], }), -@@ -1215,6 +1216,7 @@ filegroup( +@@ -1219,6 +1220,7 @@ filegroup( "include/v8-wasm-trap-handler-posix.h", "src/api/api.cc", "src/api/api.h", @@ -40,7 +40,7 @@ index 30be47fa333f75b2572927f8d7b836a99ee76181..338e21dfa9d6aa88711526dece59fb79 "src/api/api-arguments.cc", "src/api/api-arguments.h", "src/api/api-arguments-inl.h", -@@ -2678,6 +2680,11 @@ filegroup( +@@ -2689,6 +2691,11 @@ filegroup( "src/trap-handler/handler-inside-posix.cc", "src/trap-handler/handler-outside-posix.cc", ], @@ -52,7 +52,7 @@ index 30be47fa333f75b2572927f8d7b836a99ee76181..338e21dfa9d6aa88711526dece59fb79 "//conditions:default": [], }) + select({ "@v8//bazel/config:v8_arm64_simulator": [ -@@ -2685,13 +2692,6 @@ filegroup( +@@ -2696,13 +2703,6 @@ filegroup( "src/trap-handler/trap-handler-simulator.h", ], "//conditions:default": [], @@ -66,7 +66,7 @@ index 30be47fa333f75b2572927f8d7b836a99ee76181..338e21dfa9d6aa88711526dece59fb79 }) + select({ "@v8//bazel/config:is_windows_64bit": [ "src/diagnostics/unwinding-info-win64.cc", -@@ -3693,6 +3693,9 @@ filegroup( +@@ -3717,6 +3717,9 @@ filegroup( "@v8//bazel/config:is_msvc_asm_ia32": ["src/heap/base/asm/ia32/push_registers_masm.asm"], "@v8//bazel/config:is_msvc_asm_x64": ["src/heap/base/asm/x64/push_registers_masm.asm"], "@v8//bazel/config:is_msvc_asm_arm64": ["src/heap/base/asm/arm64/push_registers_masm.S"], @@ -76,7 +76,7 @@ index 30be47fa333f75b2572927f8d7b836a99ee76181..338e21dfa9d6aa88711526dece59fb79 }), ) -@@ -4068,9 +4071,11 @@ filegroup( +@@ -4094,9 +4097,11 @@ filegroup( "src/d8/d8-js.cc", "src/d8/d8-platforms.cc", "src/d8/d8-platforms.h", @@ -90,7 +90,7 @@ index 30be47fa333f75b2572927f8d7b836a99ee76181..338e21dfa9d6aa88711526dece59fb79 ) genrule( -@@ -4420,7 +4425,7 @@ py_test( +@@ -4446,7 +4451,7 @@ py_test( ":noicu/d8", ":noicu/v8_build_config", "//testing/pybase", @@ -99,7 +99,7 @@ index 30be47fa333f75b2572927f8d7b836a99ee76181..338e21dfa9d6aa88711526dece59fb79 main = "tools/run-tests.py", python_version = "PY3", tags = [ -@@ -4459,7 +4464,7 @@ py_test( +@@ -4485,7 +4490,7 @@ py_test( ":icu/d8", ":icu/v8_build_config", "//testing/pybase", diff --git a/patches/v8/0005-Disable-bazel-whole-archive-build.patch b/patches/v8/0005-Disable-bazel-whole-archive-build.patch index 921ada60e96..e5511fafc85 100644 --- a/patches/v8/0005-Disable-bazel-whole-archive-build.patch +++ b/patches/v8/0005-Disable-bazel-whole-archive-build.patch @@ -1,4 +1,4 @@ -From 67f680b997ee83e78d7b496640ba500c8ead5311 Mon Sep 17 00:00:00 2001 +From 8d00e3a1c7ada125c05ef95e0109125e9ae64f23 Mon Sep 17 00:00:00 2001 From: Felix Hanau Date: Tue, 11 Apr 2023 14:41:31 -0400 Subject: Disable bazel whole-archive build diff --git a/patches/v8/0006-Speed-up-V8-bazel-build-by-always-using-target-cfg.patch b/patches/v8/0006-Speed-up-V8-bazel-build-by-always-using-target-cfg.patch index 42cb389a92e..21e2f5ca0bc 100644 --- a/patches/v8/0006-Speed-up-V8-bazel-build-by-always-using-target-cfg.patch +++ b/patches/v8/0006-Speed-up-V8-bazel-build-by-always-using-target-cfg.patch @@ -1,4 +1,4 @@ -From 278a7759097eecc930167cad67457aac7dadbb02 Mon Sep 17 00:00:00 2001 +From 1ce25051dcd85c5782012ba42929329ff491bb1a Mon Sep 17 00:00:00 2001 From: Felix Hanau Date: Wed, 7 Jun 2023 21:40:54 -0400 Subject: Speed up V8 bazel build by always using target cfg @@ -12,7 +12,7 @@ generated files as the output set. While unrelated to the build cfg change, this also improves build times. diff --git a/BUILD.bazel b/BUILD.bazel -index 338e21dfa9d6aa88711526dece59fb792e84bff7..5aeac1aa629fcb2879a33e242bf96f5a8fe1ff13 100644 +index e805a5174b9cfe1578c9423b5bbba4004614f0f7..e1779cc185fb6c2614b3a7d5b39305baea9a5efa 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -17,6 +17,7 @@ load( @@ -23,7 +23,7 @@ index 338e21dfa9d6aa88711526dece59fb792e84bff7..5aeac1aa629fcb2879a33e242bf96f5a ) load(":bazel/v8-non-pointer-compression.bzl", "v8_binary_non_pointer_compression") -@@ -4078,22 +4079,20 @@ filegroup( +@@ -4104,22 +4105,20 @@ filegroup( }), ) @@ -52,7 +52,7 @@ index 338e21dfa9d6aa88711526dece59fb792e84bff7..5aeac1aa629fcb2879a33e242bf96f5a ) v8_mksnapshot( -@@ -4293,8 +4292,6 @@ v8_binary( +@@ -4319,8 +4318,6 @@ v8_binary( srcs = [ "src/regexp/gen-regexp-special-case.cc", "src/regexp/special-case.h", @@ -61,7 +61,7 @@ index 338e21dfa9d6aa88711526dece59fb792e84bff7..5aeac1aa629fcb2879a33e242bf96f5a ], copts = ["-Wno-implicit-fallthrough"], defines = [ -@@ -4306,6 +4303,7 @@ v8_binary( +@@ -4332,6 +4329,7 @@ v8_binary( ], deps = [ "//external:absl_optional", diff --git a/patches/v8/0007-Implement-Promise-Context-Tagging.patch b/patches/v8/0007-Implement-Promise-Context-Tagging.patch index dd0eb2816a6..a42aeffce56 100644 --- a/patches/v8/0007-Implement-Promise-Context-Tagging.patch +++ b/patches/v8/0007-Implement-Promise-Context-Tagging.patch @@ -1,14 +1,14 @@ -From ee11b275f3fd56682e04868149ef26c1a9f94e3d Mon Sep 17 00:00:00 2001 +From 038e2c4a3e1072aafae2088b591d1f2318f4868a Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 22 Jun 2023 15:29:26 -0700 Subject: Implement Promise Context Tagging diff --git a/include/v8-callbacks.h b/include/v8-callbacks.h -index 23ca5506e57090ea9262647ce06e50072b2f44c3..6b3f451b3fcb06509e4b01ab63abdcd7ed2d660c 100644 +index 6096301258719eb2713d8d6c08b7d4d926b6cd9a..2e5d3909dd2dae88d2146cbaab534c43a1460b38 100644 --- a/include/v8-callbacks.h +++ b/include/v8-callbacks.h -@@ -454,6 +454,15 @@ using FilterETWSessionByURLCallback = +@@ -462,6 +462,15 @@ using FilterETWSessionByURLCallback = bool (*)(Local context, const std::string& etw_filter_payload); #endif // V8_OS_WIN @@ -25,10 +25,10 @@ index 23ca5506e57090ea9262647ce06e50072b2f44c3..6b3f451b3fcb06509e4b01ab63abdcd7 #endif // INCLUDE_V8_ISOLATE_CALLBACKS_H_ diff --git a/include/v8-isolate.h b/include/v8-isolate.h -index ff4cfaad1c64a5eec96f3f64a85803c50a2ca98d..5bcfabe73edc375a22c309726f0bf08e741ce83c 100644 +index 17c107766b90454c2c25f9c4174cea6de42e0285..7a4586fefbf3d0a029eea3e6c98b9edc7a4c32af 100644 --- a/include/v8-isolate.h +++ b/include/v8-isolate.h -@@ -1680,6 +1680,9 @@ class V8_EXPORT Isolate { +@@ -1717,6 +1717,9 @@ class V8_EXPORT Isolate { */ void LocaleConfigurationChangeNotification(); @@ -38,7 +38,7 @@ index ff4cfaad1c64a5eec96f3f64a85803c50a2ca98d..5bcfabe73edc375a22c309726f0bf08e Isolate() = delete; ~Isolate() = delete; Isolate(const Isolate&) = delete; -@@ -1724,6 +1727,19 @@ MaybeLocal Isolate::GetDataFromSnapshotOnce(size_t index) { +@@ -1761,6 +1764,19 @@ MaybeLocal Isolate::GetDataFromSnapshotOnce(size_t index) { return {}; } @@ -59,10 +59,10 @@ index ff4cfaad1c64a5eec96f3f64a85803c50a2ca98d..5bcfabe73edc375a22c309726f0bf08e #endif // INCLUDE_V8_ISOLATE_H_ diff --git a/src/api/api.cc b/src/api/api.cc -index e2c3f310a8d85823e5873d3682122eec8f3d441c..a0988b509630a854c167cb634dde5b059ec9c0c1 100644 +index 404d19e8c5cf4b4505fb9106f0b649b44708e729..8b8633b5e35ddc1a3c6eab202116c68bdf4cb56b 100644 --- a/src/api/api.cc +++ b/src/api/api.cc -@@ -12070,6 +12070,23 @@ std::string SourceLocation::ToString() const { +@@ -12213,6 +12213,23 @@ std::string SourceLocation::ToString() const { return std::string(function_) + "@" + file_ + ":" + std::to_string(line_); } @@ -87,7 +87,7 @@ index e2c3f310a8d85823e5873d3682122eec8f3d441c..a0988b509630a854c167cb634dde5b05 EXPORT_CONTEXTUAL_VARIABLE(v8::internal::StackAllocatedCheck) diff --git a/src/builtins/promise-abstract-operations.tq b/src/builtins/promise-abstract-operations.tq -index 834007399ffdec3d7edc9cf6607a1ab22a15a1e4..a7698102cc44f88973463ac63707075a0fb51669 100644 +index 834007399ffdec3d7edc9cf6607a1ab22a15a1e4..9e7d3512dd66c6d2c076031b4a4282de33065555 100644 --- a/src/builtins/promise-abstract-operations.tq +++ b/src/builtins/promise-abstract-operations.tq @@ -20,6 +20,9 @@ extern transitioning runtime PromiseResolveAfterResolved( @@ -100,15 +100,15 @@ index 834007399ffdec3d7edc9cf6607a1ab22a15a1e4..a7698102cc44f88973463ac63707075a } // https://tc39.es/ecma262/#sec-promise-abstract-operations -@@ -458,12 +461,13 @@ transitioning macro PerformPromiseThenImpl( +@@ -458,12 +461,14 @@ transitioning macro PerformPromiseThenImpl( // PromiseReaction holding both the onFulfilled and onRejected callbacks. // Once the {promise} is resolved we decide on the concrete handler to // push onto the microtask queue. + const delegate = runtime::PromiseContextCheck(promise); const promiseReactions = - UnsafeCast<(Zero | PromiseReaction)>(promise.reactions_or_result); -- + UnsafeCast<(Zero | PromiseReaction)>(delegate.reactions_or_result); + const reaction = NewPromiseReaction( promiseReactions, resultPromiseOrCapability, onFulfilled, onRejected); - promise.reactions_or_result = reaction; @@ -117,7 +117,7 @@ index 834007399ffdec3d7edc9cf6607a1ab22a15a1e4..a7698102cc44f88973463ac63707075a } else { const reactionsOrResult = promise.reactions_or_result; let microtask: PromiseReactionJobTask; -@@ -485,8 +489,8 @@ transitioning macro PerformPromiseThenImpl( +@@ -485,8 +490,8 @@ transitioning macro PerformPromiseThenImpl( } } EnqueueMicrotask(handlerContext, microtask); @@ -150,10 +150,10 @@ index 7ace785675fe1b8ae005a1c38f9c0c32e41ac7f3..88efee16b51a6e26bd20fc4ed1222091 } diff --git a/src/builtins/promise-misc.tq b/src/builtins/promise-misc.tq -index e5c452e8af9d497c435fba8853f7e7065ced71cd..4549e8420443edef37fa93b78fe9e7b63e4ee9e5 100644 +index 8accbc33c6872bee1533897a8a846d0456ecf79f..6b409b806468ae0dd9007cb1ac82e546aa6f652f 100644 --- a/src/builtins/promise-misc.tq +++ b/src/builtins/promise-misc.tq -@@ -47,6 +47,7 @@ macro PromiseInit(promise: JSPromise): void { +@@ -52,6 +52,7 @@ macro PromiseInit(promise: JSPromise): void { is_silent: false, async_task_id: 0 }); @@ -161,7 +161,7 @@ index e5c452e8af9d497c435fba8853f7e7065ced71cd..4549e8420443edef37fa93b78fe9e7b6 promise_internal::ZeroOutEmbedderOffsets(promise); } -@@ -66,6 +67,7 @@ macro InnerNewJSPromise(implicit context: Context)(): JSPromise { +@@ -71,6 +72,7 @@ macro InnerNewJSPromise(implicit context: Context)(): JSPromise { is_silent: false, async_task_id: 0 }); @@ -169,7 +169,7 @@ index e5c452e8af9d497c435fba8853f7e7065ced71cd..4549e8420443edef37fa93b78fe9e7b6 return promise; } -@@ -265,6 +267,7 @@ transitioning macro NewJSPromise(implicit context: Context)(parent: Object): +@@ -270,6 +272,7 @@ transitioning macro NewJSPromise(implicit context: Context)(parent: Object): JSPromise { const instance = InnerNewJSPromise(); PromiseInit(instance); @@ -177,7 +177,7 @@ index e5c452e8af9d497c435fba8853f7e7065ced71cd..4549e8420443edef37fa93b78fe9e7b6 RunAnyPromiseHookInit(instance, parent); return instance; } -@@ -288,6 +291,7 @@ transitioning macro NewJSPromise( +@@ -293,6 +296,7 @@ transitioning macro NewJSPromise( instance.reactions_or_result = result; instance.SetStatus(status); promise_internal::ZeroOutEmbedderOffsets(instance); @@ -186,10 +186,10 @@ index e5c452e8af9d497c435fba8853f7e7065ced71cd..4549e8420443edef37fa93b78fe9e7b6 return instance; } diff --git a/src/compiler/js-create-lowering.cc b/src/compiler/js-create-lowering.cc -index 07b6e2cd02f97fc1aa99f91bd9c166304482f8e7..6826686c07f4a02b856f2d5d5015c857919e8115 100644 +index 07da2db2bb38d95636777c0d2ac7e7aa4993514f..b7ecbde6cae44ea61be58f05a370ac3e120fb4c4 100644 --- a/src/compiler/js-create-lowering.cc +++ b/src/compiler/js-create-lowering.cc -@@ -1081,10 +1081,12 @@ Reduction JSCreateLowering::ReduceJSCreatePromise(Node* node) { +@@ -1084,10 +1084,12 @@ Reduction JSCreateLowering::ReduceJSCreatePromise(Node* node) { jsgraph()->EmptyFixedArrayConstant()); a.Store(AccessBuilder::ForJSObjectOffset(JSPromise::kReactionsOrResultOffset), jsgraph()->ZeroConstant()); @@ -204,10 +204,10 @@ index 07b6e2cd02f97fc1aa99f91bd9c166304482f8e7..6826686c07f4a02b856f2d5d5015c857 offset < JSPromise::kSizeWithEmbedderFields; offset += kTaggedSize) { a.Store(AccessBuilder::ForJSObjectOffset(offset), diff --git a/src/diagnostics/objects-printer.cc b/src/diagnostics/objects-printer.cc -index e9e52b205b0e6dc877cfbf168b8be386ef811dc6..7222a7e5655c9af97d5e27a3b29fb88ff7d5c4ca 100644 +index 0124198dd87e60c2054776e06f1384679da9f36a..4da8a5a5aeb051c16be082339f3998fbdd99ad9b 100644 --- a/src/diagnostics/objects-printer.cc +++ b/src/diagnostics/objects-printer.cc -@@ -753,6 +753,7 @@ void JSPromise::JSPromisePrint(std::ostream& os) { +@@ -846,6 +846,7 @@ void JSPromise::JSPromisePrint(std::ostream& os) { } os << "\n - has_handler: " << has_handler(); os << "\n - is_silent: " << is_silent(); @@ -216,7 +216,7 @@ index e9e52b205b0e6dc877cfbf168b8be386ef811dc6..7222a7e5655c9af97d5e27a3b29fb88f } diff --git a/src/execution/isolate-inl.h b/src/execution/isolate-inl.h -index 256db29d140785084190ee7287480698a6498d74..ea09d04f1d09a5ac3b5b0c946d20a7e09e46982e 100644 +index f81666ddd2f513a9a1f39b9e486b451bf3c7574d..9e0969460fd33d8cc893e04d3418e1cbed01d6a0 100644 --- a/src/execution/isolate-inl.h +++ b/src/execution/isolate-inl.h @@ -134,6 +134,26 @@ bool Isolate::is_execution_terminating() { @@ -247,10 +247,10 @@ index 256db29d140785084190ee7287480698a6498d74..ea09d04f1d09a5ac3b5b0c946d20a7e0 Tagged Isolate::VerifyBuiltinsResult(Tagged result) { if (is_execution_terminating() && !v8_flags.strict_termination_checks) { diff --git a/src/execution/isolate.cc b/src/execution/isolate.cc -index 839c5921aade84c60f81bb9dd330e2a0e67e9a4a..0be551f52ef81d5dd16344ecc570dc4517346af9 100644 +index 922d728161538461b55e731ed82904cdd224ed78..24e6b532164d3610a9273770038a4306769fdc09 100644 --- a/src/execution/isolate.cc +++ b/src/execution/isolate.cc -@@ -586,6 +586,8 @@ void Isolate::Iterate(RootVisitor* v, ThreadLocalTop* thread) { +@@ -588,6 +588,8 @@ void Isolate::Iterate(RootVisitor* v, ThreadLocalTop* thread) { FullObjectSlot(&thread->pending_message_)); v->VisitRootPointer(Root::kStackRoots, nullptr, FullObjectSlot(&thread->context_)); @@ -259,7 +259,7 @@ index 839c5921aade84c60f81bb9dd330e2a0e67e9a4a..0be551f52ef81d5dd16344ecc570dc45 for (v8::TryCatch* block = thread->try_catch_handler_; block != nullptr; block = block->next_) { -@@ -5152,6 +5154,7 @@ bool Isolate::Init(SnapshotData* startup_snapshot_data, +@@ -5401,6 +5403,7 @@ bool Isolate::Init(SnapshotData* startup_snapshot_data, shared_heap_object_cache_.push_back(ReadOnlyRoots(this).undefined_value()); } @@ -267,7 +267,7 @@ index 839c5921aade84c60f81bb9dd330e2a0e67e9a4a..0be551f52ef81d5dd16344ecc570dc45 InitializeThreadLocal(); // Profiler has to be created after ThreadLocal is initialized -@@ -7003,5 +7006,39 @@ void DefaultWasmAsyncResolvePromiseCallback( +@@ -7240,5 +7243,39 @@ void DefaultWasmAsyncResolvePromiseCallback( CHECK(ret.IsJust() ? ret.FromJust() : isolate->IsExecutionTerminating()); } @@ -292,7 +292,7 @@ index 839c5921aade84c60f81bb9dd330e2a0e67e9a4a..0be551f52ef81d5dd16344ecc570dc45 + PromiseCrossContextCallbackScope callback_scope(*this); + CHECK(IsJSReceiver(promise->context_tag())); + -+ Handle context_tag(JSObject::cast(promise->context_tag()), this); ++ Handle context_tag(Cast(promise->context_tag()), this); + v8::Local result; + API_ASSIGN_RETURN_ON_EXCEPTION_VALUE ( + this, result, @@ -308,12 +308,12 @@ index 839c5921aade84c60f81bb9dd330e2a0e67e9a4a..0be551f52ef81d5dd16344ecc570dc45 } // namespace internal } // namespace v8 diff --git a/src/execution/isolate.h b/src/execution/isolate.h -index e4edc7965f0a13bbb462931281924c2c19dc287f..43c9d12edeae725ead98057a67e77b61bf6ffffd 100644 +index db1afe3715e7ee032e1be54153a2588deb05f34d..4cca9257840fb7e71ddaac967f5a0515b830863d 100644 --- a/src/execution/isolate.h +++ b/src/execution/isolate.h -@@ -2216,6 +2216,14 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory { - std::list>& - async_waiter_queue_nodes(); +@@ -2225,6 +2225,14 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory { + v8::ExceptionContext callback_kind); + void SetExceptionPropagationCallback(ExceptionPropagationCallback callback); + inline Tagged promise_context_tag(); + inline bool has_promise_context_tag(); @@ -326,7 +326,7 @@ index e4edc7965f0a13bbb462931281924c2c19dc287f..43c9d12edeae725ead98057a67e77b61 #ifdef V8_ENABLE_WASM_SIMD256_REVEC void set_wasm_revec_verifier_for_test( compiler::turboshaft::WasmRevecVerifier* verifier) { -@@ -2728,12 +2736,19 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory { +@@ -2737,12 +2745,19 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory { int current_thread_counter_ = 0; #endif @@ -347,10 +347,10 @@ index e4edc7965f0a13bbb462931281924c2c19dc287f..43c9d12edeae725ead98057a67e77b61 // The current entered Isolate and its thread data. Do not access these diff --git a/src/heap/factory.cc b/src/heap/factory.cc -index 2becca079e010aed2c19836e8bc20c69d0efc457..1c3dbbf29301ba2d3e6ae8b652eb58f9f98f8549 100644 +index 5aba656b043139cdafafb181dd81a852fd6c5487..45122eba3b04c25149900dc0e2a433b9285b8e44 100644 --- a/src/heap/factory.cc +++ b/src/heap/factory.cc -@@ -4242,6 +4242,12 @@ Handle Factory::NewJSPromiseWithoutHook() { +@@ -4271,6 +4271,12 @@ Handle Factory::NewJSPromiseWithoutHook() { DisallowGarbageCollection no_gc; Tagged raw = *promise; raw->set_reactions_or_result(Smi::zero(), SKIP_WRITE_BARRIER); @@ -364,22 +364,22 @@ index 2becca079e010aed2c19836e8bc20c69d0efc457..1c3dbbf29301ba2d3e6ae8b652eb58f9 // TODO(v8) remove once embedder data slots are always zero-initialized. InitEmbedderFields(*promise, Smi::zero()); diff --git a/src/objects/js-promise.tq b/src/objects/js-promise.tq -index 29acfa259048f1dae2dfcb02ef57ca4ef69e2d9a..b9602cc98d5fb33a4a28d7ced8c5011215b89302 100644 +index 29acfa259048f1dae2dfcb02ef57ca4ef69e2d9a..1c137d27219afe1298326604a5d172b49810a1c1 100644 --- a/src/objects/js-promise.tq +++ b/src/objects/js-promise.tq @@ -32,6 +32,7 @@ extern class JSPromise extends JSObjectWithEmbedderSlots { // Smi 0 terminated list of PromiseReaction objects in case the JSPromise was // not settled yet, otherwise the result. reactions_or_result: Zero|PromiseReaction|JSAny; -+ context_tag: Zero|JSAny; ++ context_tag: Object; flags: SmiTagged; } diff --git a/src/profiler/heap-snapshot-generator.cc b/src/profiler/heap-snapshot-generator.cc -index 9f92ebe9dc1d2412551be30a5299882883510316..edd38e2459a88df693dcb3fd0e092ca269b0d0f4 100644 +index 86b7b9a05eaa8a63e6649e39bdb7e8917a2aecfb..2b0b03facc2ce4bee9cba93caaad067a1c1a6c29 100644 --- a/src/profiler/heap-snapshot-generator.cc +++ b/src/profiler/heap-snapshot-generator.cc -@@ -1831,6 +1831,9 @@ void V8HeapExplorer::ExtractJSPromiseReferences(HeapEntry* entry, +@@ -1909,6 +1909,9 @@ void V8HeapExplorer::ExtractJSPromiseReferences(HeapEntry* entry, SetInternalReference(entry, "reactions_or_result", promise->reactions_or_result(), JSPromise::kReactionsOrResultOffset); @@ -390,10 +390,10 @@ index 9f92ebe9dc1d2412551be30a5299882883510316..edd38e2459a88df693dcb3fd0e092ca2 void V8HeapExplorer::ExtractJSGeneratorObjectReferences( diff --git a/src/runtime/runtime-promise.cc b/src/runtime/runtime-promise.cc -index d83a785531185a0b5df6c9d4e24ec0253da8fb79..69b200748c31ffe91834dde9680b984d2ae3a63e 100644 +index 5b4b9c2e9de41673105efe28b2e731550581ee7b..f51989cd466e3bcf1727ac65cb471903c00497f6 100644 --- a/src/runtime/runtime-promise.cc +++ b/src/runtime/runtime-promise.cc -@@ -196,5 +196,40 @@ RUNTIME_FUNCTION(Runtime_ConstructInternalAggregateErrorHelper) { +@@ -197,5 +197,40 @@ RUNTIME_FUNCTION(Runtime_ConstructInternalAggregateErrorHelper) { return *result; } @@ -435,10 +435,10 @@ index d83a785531185a0b5df6c9d4e24ec0253da8fb79..69b200748c31ffe91834dde9680b984d } // namespace internal } // namespace v8 diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h -index 711acf4c331479d04bda1033cd3b220ccc89eb4e..bf6c26e3b3db4bfb564091c59399bdcc9b5a68b3 100644 +index 3fa07b54517f8097947ff3eead162b0f4c8031bd..75755ad5354f27fe068679513440dcdb257a3e56 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h -@@ -398,7 +398,9 @@ namespace internal { +@@ -400,7 +400,9 @@ namespace internal { F(PromiseRejectAfterResolved, 2, 1) \ F(PromiseResolveAfterResolved, 2, 1) \ F(ConstructAggregateErrorHelper, 4, 1) \ diff --git a/patches/v8/0008-Enable-V8-shared-linkage.patch b/patches/v8/0008-Enable-V8-shared-linkage.patch index f4e6f91f127..700e109dc50 100644 --- a/patches/v8/0008-Enable-V8-shared-linkage.patch +++ b/patches/v8/0008-Enable-V8-shared-linkage.patch @@ -1,14 +1,14 @@ -From c14d05513814dc04b3c8e32facf812358e882df5 Mon Sep 17 00:00:00 2001 +From 5480b515df0bdf43042a29ff03e0e45f98755ba1 Mon Sep 17 00:00:00 2001 From: Felix Hanau Date: Sun, 9 Jul 2023 18:46:20 -0400 Subject: Enable V8 shared linkage diff --git a/BUILD.bazel b/BUILD.bazel -index 5aeac1aa629fcb2879a33e242bf96f5a8fe1ff13..bdf7568ff0ac11d2393fc398b9f4fb84b936bd07 100644 +index e1779cc185fb6c2614b3a7d5b39305baea9a5efa..3f1a94c7bd2c31a1581ff3aaa215fb5a682c51b3 100644 --- a/BUILD.bazel +++ b/BUILD.bazel -@@ -1484,7 +1484,6 @@ filegroup( +@@ -1490,7 +1490,6 @@ filegroup( "src/execution/futex-emulation.h", "src/execution/interrupts-scope.cc", "src/execution/interrupts-scope.h", @@ -16,7 +16,7 @@ index 5aeac1aa629fcb2879a33e242bf96f5a8fe1ff13..bdf7568ff0ac11d2393fc398b9f4fb84 "src/execution/isolate.h", "src/execution/isolate-data.h", "src/execution/isolate-inl.h", -@@ -3758,6 +3757,10 @@ filegroup( +@@ -3784,6 +3783,10 @@ filegroup( "src/snapshot/snapshot-empty.cc", "src/snapshot/static-roots-gen.cc", "src/snapshot/static-roots-gen.h", @@ -27,7 +27,7 @@ index 5aeac1aa629fcb2879a33e242bf96f5a8fe1ff13..bdf7568ff0ac11d2393fc398b9f4fb84 ], ) -@@ -4213,6 +4216,8 @@ v8_library( +@@ -4239,6 +4242,8 @@ v8_library( name = "v8", srcs = [ ":v8_inspector_files", diff --git a/patches/v8/0009-Randomize-the-initial-ExecutionContextId-used-by-the.patch b/patches/v8/0009-Randomize-the-initial-ExecutionContextId-used-by-the.patch index b1f098f4d68..ca36e2cd766 100644 --- a/patches/v8/0009-Randomize-the-initial-ExecutionContextId-used-by-the.patch +++ b/patches/v8/0009-Randomize-the-initial-ExecutionContextId-used-by-the.patch @@ -1,4 +1,4 @@ -From eecddb628a5c43b5cc5f19a3311c378dcece1627 Mon Sep 17 00:00:00 2001 +From deccc5595b446d97f5210ef36eafc5388e84c03a Mon Sep 17 00:00:00 2001 From: Orion Hodson Date: Wed, 13 Sep 2023 15:38:15 +0100 Subject: Randomize the initial ExecutionContextId used by the inspector @@ -8,10 +8,10 @@ by miniflare. This happens because workerd does not support re-loading live workers (https://chat.google.com/room/AAAAnS2bXT4/GX5-pa8O0ts). diff --git a/src/inspector/v8-inspector-impl.cc b/src/inspector/v8-inspector-impl.cc -index 9b2ea79f6397f6d60bfe2ea17deb05343a02228f..9ff65a0932211711dc2659276579dc80240967d1 100644 +index 8837c6403274152bd36c9c72a76b98093641ae53..b5f400d12f1bd36dfa9077bf076355a3df8fd015 100644 --- a/src/inspector/v8-inspector-impl.cc +++ b/src/inspector/v8-inspector-impl.cc -@@ -66,7 +66,7 @@ V8InspectorImpl::V8InspectorImpl(v8::Isolate* isolate, +@@ -75,7 +75,7 @@ V8InspectorImpl::V8InspectorImpl(v8::Isolate* isolate, m_client(client), m_debugger(new V8Debugger(isolate, this)), m_lastExceptionId(0), diff --git a/patches/v8/0010-Always-enable-continuation-preserved-data-in-the-bui.patch b/patches/v8/0010-Always-enable-continuation-preserved-data-in-the-bui.patch deleted file mode 100644 index c08d059bd82..00000000000 --- a/patches/v8/0010-Always-enable-continuation-preserved-data-in-the-bui.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 3088caad9c85b24f245b47ada63cb56ed6b78b0f Mon Sep 17 00:00:00 2001 -From: James M Snell -Date: Thu, 18 Jan 2024 10:19:14 -0800 -Subject: Always enable continuation preserved data in the build - - -diff --git a/BUILD.bazel b/BUILD.bazel -index bdf7568ff0ac11d2393fc398b9f4fb84b936bd07..30aa9d84aa27863446c05aea01479c5da4f28626 100644 ---- a/BUILD.bazel -+++ b/BUILD.bazel -@@ -418,6 +418,7 @@ v8_config( - "V8_ADVANCED_BIGINT_ALGORITHMS", - "V8_CONCURRENT_MARKING", - "V8_ENABLE_SPARKPLUG", -+ "V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA", - "V8_ENABLE_EXTENSIBLE_RO_SNAPSHOT", - ] + select({ - "@v8//bazel/config:is_debug": [ diff --git a/patches/v8/0011-increase-visibility-of-virtual-method.patch b/patches/v8/0010-increase-visibility-of-virtual-method.patch similarity index 91% rename from patches/v8/0011-increase-visibility-of-virtual-method.patch rename to patches/v8/0010-increase-visibility-of-virtual-method.patch index d9218b6c37a..830ca38a9fb 100644 --- a/patches/v8/0011-increase-visibility-of-virtual-method.patch +++ b/patches/v8/0010-increase-visibility-of-virtual-method.patch @@ -1,4 +1,4 @@ -From 650cb04c30fd0707f7443988cd2c97c778bec7d8 Mon Sep 17 00:00:00 2001 +From ffd7ab81f19f035d54621806aa68371604ab5f17 Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Tue, 6 Feb 2024 12:55:07 -0800 Subject: increase visibility of virtual method diff --git a/patches/v8/0012-Add-ValueSerializer-SetTreatFunctionsAsHostObjects.patch b/patches/v8/0011-Add-ValueSerializer-SetTreatFunctionsAsHostObjects.patch similarity index 89% rename from patches/v8/0012-Add-ValueSerializer-SetTreatFunctionsAsHostObjects.patch rename to patches/v8/0011-Add-ValueSerializer-SetTreatFunctionsAsHostObjects.patch index ebf25c9f53a..e8a39e30cb6 100644 --- a/patches/v8/0012-Add-ValueSerializer-SetTreatFunctionsAsHostObjects.patch +++ b/patches/v8/0011-Add-ValueSerializer-SetTreatFunctionsAsHostObjects.patch @@ -1,4 +1,4 @@ -From b413a9f57e487688c37ef3e92632292571a59596 Mon Sep 17 00:00:00 2001 +From 06de20cf51080e17afe7984ca98458a3653e18c9 Mon Sep 17 00:00:00 2001 From: Kenton Varda Date: Sat, 2 Mar 2024 09:00:18 -0600 Subject: Add ValueSerializer::SetTreatFunctionsAsHostObjects(). @@ -28,10 +28,10 @@ index 596be18adeb3a5a81794aaa44b1d347dec6c0c7d..141f138e08de849e3e02b3b2b346e643 * Write raw data in various common formats to the buffer. * Note that integer types are written in base-128 varint format, not with a diff --git a/src/api/api.cc b/src/api/api.cc -index a0988b509630a854c167cb634dde5b059ec9c0c1..9954e6a9182d1908b2e92150fba14c31dc23455f 100644 +index 8b8633b5e35ddc1a3c6eab202116c68bdf4cb56b..dc1044ba427c5bd2bd7ac995adccd2472afbcfe2 100644 --- a/src/api/api.cc +++ b/src/api/api.cc -@@ -3448,6 +3448,10 @@ void ValueSerializer::SetTreatArrayBufferViewsAsHostObjects(bool mode) { +@@ -3477,6 +3477,10 @@ void ValueSerializer::SetTreatArrayBufferViewsAsHostObjects(bool mode) { private_->serializer.SetTreatArrayBufferViewsAsHostObjects(mode); } @@ -43,7 +43,7 @@ index a0988b509630a854c167cb634dde5b059ec9c0c1..9954e6a9182d1908b2e92150fba14c31 Local value) { auto i_isolate = reinterpret_cast(context->GetIsolate()); diff --git a/src/objects/value-serializer.cc b/src/objects/value-serializer.cc -index 2e574704650c3b5d860fc21d083e9e6fed9ddfcf..0c82ae8299f2f45bee34177c3d1b663cede0c02e 100644 +index 96ad656a42173b66974539472467c497b89dc587..95ba1aa83f71dd34c63230899840081cf555042d 100644 --- a/src/objects/value-serializer.cc +++ b/src/objects/value-serializer.cc @@ -328,6 +328,10 @@ void ValueSerializer::SetTreatArrayBufferViewsAsHostObjects(bool mode) { @@ -65,7 +65,7 @@ index 2e574704650c3b5d860fc21d083e9e6fed9ddfcf..0c82ae8299f2f45bee34177c3d1b663c - instance_type != JS_SPECIAL_API_OBJECT_TYPE)) { + if (IsCallable(*receiver)) { + if (treat_functions_as_host_objects_) { -+ return WriteHostObject(Handle::cast(receiver)); ++ return WriteHostObject(Cast(receiver)); + } + return ThrowDataCloneError(MessageTemplate::kDataCloneError, receiver); + } else if (IsSpecialReceiverInstanceType(instance_type) && @@ -74,7 +74,7 @@ index 2e574704650c3b5d860fc21d083e9e6fed9ddfcf..0c82ae8299f2f45bee34177c3d1b663c } diff --git a/src/objects/value-serializer.h b/src/objects/value-serializer.h -index c3a44e9f64f944641eea417584429a0b147ef654..fcf6e66d44508c2c29889354f3794d37cc22b52d 100644 +index 27d5d03518e7bfecde240b658f63456c899f378c..faeb7879130b3d32feeb3a0435b3c21e9be44a14 100644 --- a/src/objects/value-serializer.h +++ b/src/objects/value-serializer.h @@ -102,6 +102,15 @@ class ValueSerializer { diff --git a/patches/v8/0013-Set-torque-generator-path-to-external-v8.-This-allow.patch b/patches/v8/0012-Set-torque-generator-path-to-external-v8.-This-allow.patch similarity index 92% rename from patches/v8/0013-Set-torque-generator-path-to-external-v8.-This-allow.patch rename to patches/v8/0012-Set-torque-generator-path-to-external-v8.-This-allow.patch index 19b25aaedb2..a3ec87a022f 100644 --- a/patches/v8/0013-Set-torque-generator-path-to-external-v8.-This-allow.patch +++ b/patches/v8/0012-Set-torque-generator-path-to-external-v8.-This-allow.patch @@ -1,4 +1,4 @@ -From 7e7ea0724d97fe80eb39b3a46708cebfe3a517b9 Mon Sep 17 00:00:00 2001 +From 541e832ea27e547eb7a648f07153dcd9a9e92357 Mon Sep 17 00:00:00 2001 From: Garrett Gu Date: Wed, 10 Apr 2024 14:31:33 -0500 Subject: Set torque generator path to external/v8. This allows bazel to find diff --git a/patches/v8/0014-Modify-where-to-look-for-fp16-dependency.-This-depen.patch b/patches/v8/0013-Modify-where-to-look-for-fp16-dependency.-This-depen.patch similarity index 83% rename from patches/v8/0014-Modify-where-to-look-for-fp16-dependency.-This-depen.patch rename to patches/v8/0013-Modify-where-to-look-for-fp16-dependency.-This-depen.patch index 79e73f57731..6aee0dee451 100644 --- a/patches/v8/0014-Modify-where-to-look-for-fp16-dependency.-This-depen.patch +++ b/patches/v8/0013-Modify-where-to-look-for-fp16-dependency.-This-depen.patch @@ -1,4 +1,4 @@ -From 9bec243b8da206665490e5fcd8dc8059339dc039 Mon Sep 17 00:00:00 2001 +From e001dbb4984d73158ddd152cb757cdde432a33e9 Mon Sep 17 00:00:00 2001 From: Garrett Gu Date: Mon, 22 Apr 2024 10:10:21 -0500 Subject: Modify where to look for fp16 dependency. This dependency is normally @@ -7,10 +7,10 @@ Subject: Modify where to look for fp16 dependency. This dependency is normally diff --git a/BUILD.bazel b/BUILD.bazel -index 30aa9d84aa27863446c05aea01479c5da4f28626..e23ebdfb033cf4d4211333e27a78a9e53ad0d5d7 100644 +index 3f1a94c7bd2c31a1581ff3aaa215fb5a682c51b3..629966b565e2a3b1018cf09b64dd5d969ad075a7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel -@@ -3700,16 +3700,22 @@ filegroup( +@@ -3723,16 +3723,22 @@ filegroup( }), ) diff --git a/patches/v8/0015-Expose-v8-Symbol-GetDispose.patch b/patches/v8/0014-Expose-v8-Symbol-GetDispose.patch similarity index 78% rename from patches/v8/0015-Expose-v8-Symbol-GetDispose.patch rename to patches/v8/0014-Expose-v8-Symbol-GetDispose.patch index 91f7ae9dfb6..4a5981ede5f 100644 --- a/patches/v8/0015-Expose-v8-Symbol-GetDispose.patch +++ b/patches/v8/0014-Expose-v8-Symbol-GetDispose.patch @@ -1,4 +1,4 @@ -From 5563f8c04c3cdf380f92312873bc487c39e28d7b Mon Sep 17 00:00:00 2001 +From de001edd8a331a3bc3a53c27d5e425ff493078d9 Mon Sep 17 00:00:00 2001 From: Jon Phillips Date: Tue, 30 Apr 2024 00:06:33 +0100 Subject: Expose v8::Symbol::GetDispose(). @@ -8,10 +8,10 @@ management spec. Since `Symbol.dispose` has been exposed to JS we need to be able to access the native v8::Symbol too. diff --git a/include/v8-primitive.h b/include/v8-primitive.h -index eb0a791cf73946c0955f6ccadbb36f0c4999cbab..a2726084a905173ec4f6179160ce5bd581f9c2df 100644 +index 1adb9cbcb22515d100eb4bf1160eb5bfb7cac409..f7507eccad97d1d7a8f7e717d73065203849e00d 100644 --- a/include/v8-primitive.h +++ b/include/v8-primitive.h -@@ -625,6 +625,8 @@ class V8_EXPORT Symbol : public Name { +@@ -692,6 +692,8 @@ class V8_EXPORT Symbol : public Name { static Local GetToPrimitive(Isolate* isolate); static Local GetToStringTag(Isolate* isolate); static Local GetUnscopables(Isolate* isolate); @@ -21,10 +21,10 @@ index eb0a791cf73946c0955f6ccadbb36f0c4999cbab..a2726084a905173ec4f6179160ce5bd5 V8_INLINE static Symbol* Cast(Data* data) { #ifdef V8_ENABLE_CHECKS diff --git a/src/api/api.cc b/src/api/api.cc -index 9954e6a9182d1908b2e92150fba14c31dc23455f..246c3fb5568fafb64f861079566ab35487bdb8ce 100644 +index dc1044ba427c5bd2bd7ac995adccd2472afbcfe2..908c23b1e451a2106581fe21224b0ce12a707b96 100644 --- a/src/api/api.cc +++ b/src/api/api.cc -@@ -9388,7 +9388,9 @@ Local v8::Symbol::ForApi(Isolate* v8_isolate, Local name) { +@@ -9463,7 +9463,9 @@ Local v8::Symbol::ForApi(Isolate* v8_isolate, Local name) { V(Split, split) \ V(ToPrimitive, to_primitive) \ V(ToStringTag, to_string_tag) \ diff --git a/patches/v8/0016-Rename-V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE-V8_COMPR.patch b/patches/v8/0015-Rename-V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE-V8_COMPR.patch similarity index 84% rename from patches/v8/0016-Rename-V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE-V8_COMPR.patch rename to patches/v8/0015-Rename-V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE-V8_COMPR.patch index 737747ddfb3..38160ad880c 100644 --- a/patches/v8/0016-Rename-V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE-V8_COMPR.patch +++ b/patches/v8/0015-Rename-V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE-V8_COMPR.patch @@ -1,4 +1,4 @@ -From abd3b18a0feac502ac3724818483e222767b83e0 Mon Sep 17 00:00:00 2001 +From bd2d06301b076672d9041e4d2c3dc88084bb6759 Mon Sep 17 00:00:00 2001 From: Jon Phillips Date: Thu, 9 May 2024 23:36:43 +0100 Subject: Rename V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE -> @@ -9,10 +9,10 @@ this rename elsewhere: https://chromium-review.googlesource.com/c/v8/v8/+/5279595. diff --git a/BUILD.bazel b/BUILD.bazel -index e23ebdfb033cf4d4211333e27a78a9e53ad0d5d7..02456453d2a57c7b13d5e843c6e6655f33a37f3a 100644 +index 629966b565e2a3b1018cf09b64dd5d969ad075a7..4deec252e0f8c4ec140f0d16e571a0329f695144 100644 --- a/BUILD.bazel +++ b/BUILD.bazel -@@ -285,10 +285,10 @@ selects.config_setting_group( +@@ -287,10 +287,10 @@ selects.config_setting_group( ], ) @@ -25,7 +25,7 @@ index e23ebdfb033cf4d4211333e27a78a9e53ad0d5d7..02456453d2a57c7b13d5e843c6e6655f match_all = [ ":is_v8_enable_pointer_compression", ":is_not_v8_enable_pointer_compression_shared_cage", -@@ -483,8 +483,8 @@ v8_config( +@@ -485,8 +485,8 @@ v8_config( ":enable_pointer_compression_shared_cage": [ "V8_COMPRESS_POINTERS_IN_SHARED_CAGE", ], diff --git a/patches/v8/0017-Revert-TracedReference-deref-API-removal.patch b/patches/v8/0016-Revert-TracedReference-deref-API-removal.patch similarity index 94% rename from patches/v8/0017-Revert-TracedReference-deref-API-removal.patch rename to patches/v8/0016-Revert-TracedReference-deref-API-removal.patch index 4621869c336..61d171d1c09 100644 --- a/patches/v8/0017-Revert-TracedReference-deref-API-removal.patch +++ b/patches/v8/0016-Revert-TracedReference-deref-API-removal.patch @@ -1,4 +1,4 @@ -From 97f6fcebc3b908c0cbc918bcf47591fd18e2cba0 Mon Sep 17 00:00:00 2001 +From 40286c19da2ce5f426b9e9f3f98dee211158017c Mon Sep 17 00:00:00 2001 From: Harris Hancock Date: Fri, 28 Jun 2024 14:19:25 +0100 Subject: Revert TracedReference deref API removal diff --git a/patches/v8/0018-Revert-heap-Add-masm-specific-unwinding-annotations-.patch b/patches/v8/0017-Revert-heap-Add-masm-specific-unwinding-annotations-.patch similarity index 96% rename from patches/v8/0018-Revert-heap-Add-masm-specific-unwinding-annotations-.patch rename to patches/v8/0017-Revert-heap-Add-masm-specific-unwinding-annotations-.patch index f9a5ccea488..cc04200cab7 100644 --- a/patches/v8/0018-Revert-heap-Add-masm-specific-unwinding-annotations-.patch +++ b/patches/v8/0017-Revert-heap-Add-masm-specific-unwinding-annotations-.patch @@ -1,4 +1,4 @@ -From 2241358ba2085c5a5f9d8c74ba41171d4dc0d4da Mon Sep 17 00:00:00 2001 +From 21c4be174097013e55cd6ac6213f79e19a9c35a8 Mon Sep 17 00:00:00 2001 From: Harris Hancock Date: Wed, 3 Jul 2024 15:46:43 +0100 Subject: Revert "heap: Add masm-specific unwinding annotations to GC @@ -9,10 +9,10 @@ This reverts commit 42bc7bfdf56cc7a8cd7757d96aa70b83ce82d9ff. This commit broke our build, because we patch V8 to build push_registers_asm.cc with clang-cl on Windows, and this commit makes it an error to compile that file on Windows with any compiler. Maybe clang-cl and masm can be used together? I'm not sure. In the meantime, I'm reverting this commit in the hope of getting our V8 upgrade unblocked. diff --git a/BUILD.gn b/BUILD.gn -index a4faf8e7a87de572555122088798ae2bc5108592..1810ec29e5fd049823d23d24fc3c023cd0bab41a 100644 +index 92e8541951384f3eba02be02162978fa57b63798..3051f560dff3f9d0a3a9916bd57527240f67acf5 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -4135,8 +4135,8 @@ v8_header_set("v8_internal_headers") { +@@ -4183,8 +4183,8 @@ v8_header_set("v8_internal_headers") { "src/third_party/siphash/halfsiphash.h", "src/third_party/utf8-decoder/utf8-decoder.h", "src/torque/runtime-macro-shims.h", @@ -22,7 +22,7 @@ index a4faf8e7a87de572555122088798ae2bc5108592..1810ec29e5fd049823d23d24fc3c023c "src/tracing/traced-value.h", "src/tracing/tracing-category-observer.h", "src/utils/address-map.h", -@@ -6783,12 +6783,7 @@ v8_source_set("v8_heap_base") { +@@ -6858,12 +6858,7 @@ v8_source_set("v8_heap_base") { if (is_clang || !is_win) { if (current_cpu == "x64") { diff --git a/patches/v8/0019-Update-illegal-invocation-error-message-in-v8.patch b/patches/v8/0018-Update-illegal-invocation-error-message-in-v8.patch similarity index 88% rename from patches/v8/0019-Update-illegal-invocation-error-message-in-v8.patch rename to patches/v8/0018-Update-illegal-invocation-error-message-in-v8.patch index 9c9287e8fd3..8cef4288c53 100644 --- a/patches/v8/0019-Update-illegal-invocation-error-message-in-v8.patch +++ b/patches/v8/0018-Update-illegal-invocation-error-message-in-v8.patch @@ -1,11 +1,11 @@ -From bd3333d53de62140f33b4b8ba8656f2162da2c47 Mon Sep 17 00:00:00 2001 +From 16b1c354fde124590e4f3c1dc95495bd49f9c6ec Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 9 Jul 2024 08:37:05 -0700 Subject: Update illegal invocation error message in v8 diff --git a/src/common/message-template.h b/src/common/message-template.h -index 5c7ffea18f6dd9976735213fff2e117225350f26..22e3f17402390dcdc723e2a9d4a56e048567f20b 100644 +index 1eeef77dc9e88089a8608a7650997d5f748b7137..2d82d8a0012ec32c2002e273a648336a901f2540 100644 --- a/src/common/message-template.h +++ b/src/common/message-template.h @@ -112,7 +112,9 @@ namespace internal { diff --git a/patches/v8/0019-wasm-Fix-more-code-logging-races.patch b/patches/v8/0019-wasm-Fix-more-code-logging-races.patch new file mode 100644 index 00000000000..2ffd4f10c7c --- /dev/null +++ b/patches/v8/0019-wasm-Fix-more-code-logging-races.patch @@ -0,0 +1,72 @@ +From 7681014c831ca1002d0c654f0744d4cd065d50ef Mon Sep 17 00:00:00 2001 +From: Clemens Backes +Date: Mon, 22 Jul 2024 18:26:42 +0200 +Subject: [wasm] Fix more code logging races + +Fix more causes for failures during shutdown or unlucky timing. + +R=mliedtke@chromium.org + +Bug: 42204620 +Change-Id: I056b197042d77ee652aedddf15579e90f60bcc61 +Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_dbg +Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_isolates_rel +Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5725360 +Reviewed-by: Matthias Liedtke +Commit-Queue: Clemens Backes +Cr-Commit-Position: refs/heads/main@{#95170} + +diff --git a/src/wasm/wasm-engine.cc b/src/wasm/wasm-engine.cc +index 117f33e8fc46dc64b790f9dd42a42eb75643cbb4..c8f3a971bebb123259b6fd78b9c55e10d5b1d5aa 100644 +--- a/src/wasm/wasm-engine.cc ++++ b/src/wasm/wasm-engine.cc +@@ -142,7 +142,8 @@ class WasmEngine::LogCodesTask : public CancelableTask { + friend class WasmEngine; + + public: +- LogCodesTask(Isolate* isolate) : CancelableTask(isolate), isolate_(isolate) {} ++ explicit LogCodesTask(Isolate* isolate) ++ : CancelableTask(isolate), isolate_(isolate) {} + + ~LogCodesTask() override { GetWasmEngine()->DeregisterCodeLoggingTask(this); } + +@@ -1272,6 +1273,10 @@ void WasmEngine::RemoveIsolate(Isolate* isolate) { + + // Keep a WasmCodeRefScope which dies after the {mutex_} is released, to avoid + // deadlock when code actually dies, as that requires taking the {mutex_}. ++ // Also, keep the NativeModules themselves alive. The isolate is shutting ++ // down, so the heap will not do that any more. ++ std::map> ++ native_modules_with_code_to_log; + WasmCodeRefScope code_ref_scope_for_dead_code; + + base::MutexGuard guard(&mutex_); +@@ -1318,6 +1323,17 @@ void WasmEngine::RemoveIsolate(Isolate* isolate) { + // Clear the {code_to_log} vector. + for (auto& [script_id, code_to_log] : isolate_info->code_to_log) { + for (WasmCode* code : code_to_log.code) { ++ if (!native_modules_with_code_to_log.count(code->native_module())) { ++ std::shared_ptr shared_native_module = ++ native_modules_[code->native_module()]->weak_ptr.lock(); ++ if (!shared_native_module) { ++ // The module is dying already; there's no need to decrement the ref ++ // count and add the code to the WasmCodeRefScope. ++ continue; ++ } ++ native_modules_with_code_to_log.insert(std::make_pair( ++ code->native_module(), std::move(shared_native_module))); ++ } + // Keep a reference in the {code_ref_scope_for_dead_code} such that the + // code cannot become dead immediately. + WasmCodeRefScope::AddRef(code); +@@ -1441,7 +1457,8 @@ void WasmEngine::DeregisterCodeLoggingTask(LogCodesTask* task) { + // If the isolate died already, the IsolateInfo can not be found. + if (it == isolates_.end()) return; + IsolateInfo* info = it->second.get(); +- DCHECK(info->log_codes_task == nullptr || info->log_codes_task == task); ++ // If another task is already scheduled (or we already deregistered), return. ++ if (info->log_codes_task != task) return; + info->log_codes_task = nullptr; + } + diff --git a/patches/v8/0020-wasm-Remove-destructor-of-LogCodesTask.patch b/patches/v8/0020-wasm-Remove-destructor-of-LogCodesTask.patch new file mode 100644 index 00000000000..75263189ed9 --- /dev/null +++ b/patches/v8/0020-wasm-Remove-destructor-of-LogCodesTask.patch @@ -0,0 +1,130 @@ +From 58a36ca22df3470497f59b2492e302f157ed69d2 Mon Sep 17 00:00:00 2001 +From: Clemens Backes +Date: Tue, 23 Jul 2024 10:51:51 +0200 +Subject: [wasm] Remove destructor of LogCodesTask + +This is a follow-up to https://crrev.com/c/5718451. The destructor is +still sometimes called very late by the platform, after global teardown. +In this case, the WasmEngine was already deallocated. + +It turns out we do not need the destructor at all. We can just schedule +a task when the first code to log is put into the queue, similar to how +we request the interrupt. + +R=mliedtke@chromium.org + +Bug: 42204620 +Change-Id: I4daf644bc157f68ac0b53290cc411109c5a6a5c9 +Fixed: 354251542 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5729763 +Reviewed-by: Matthias Liedtke +Commit-Queue: Clemens Backes +Cr-Commit-Position: refs/heads/main@{#95184} + +diff --git a/src/wasm/wasm-engine.cc b/src/wasm/wasm-engine.cc +index c8f3a971bebb123259b6fd78b9c55e10d5b1d5aa..e1f0b899286a61dd4a71b603a8e8fe4b20605b6f 100644 +--- a/src/wasm/wasm-engine.cc ++++ b/src/wasm/wasm-engine.cc +@@ -145,10 +145,7 @@ class WasmEngine::LogCodesTask : public CancelableTask { + explicit LogCodesTask(Isolate* isolate) + : CancelableTask(isolate), isolate_(isolate) {} + +- ~LogCodesTask() override { GetWasmEngine()->DeregisterCodeLoggingTask(this); } +- + void RunInternal() override { +- GetWasmEngine()->DeregisterCodeLoggingTask(this); + GetWasmEngine()->LogOutstandingCodesForIsolate(isolate_); + } + +@@ -483,9 +480,6 @@ struct WasmEngine::IsolateInfo { + // Caches whether code needs to be logged on this isolate. + bool log_codes; + +- // The currently scheduled LogCodesTask. +- LogCodesTask* log_codes_task = nullptr; +- + // Maps script ID to vector of code objects that still need to be logged, and + // the respective source URL. + struct CodeToLogPerScript { +@@ -1368,10 +1362,13 @@ void WasmEngine::LogCode(base::Vector code_vec) { + // weak handle is cleared already, we also don't need to log any more. + if (script_it == info->scripts.end()) continue; + +- // If this is the first code to log in that isolate, request an interrupt +- // to log the newly added code as soon as possible. ++ // If there is no code scheduled to be logged already in that isolate, ++ // then schedule a new task and also set an interrupt to log the newly ++ // added code as soon as possible. + if (info->code_to_log.empty()) { + isolate->stack_guard()->RequestLogWasmCode(); ++ to_schedule.emplace_back(info->foreground_task_runner, ++ std::make_unique(isolate)); + } + + WeakScriptHandle& weak_script_handle = script_it->second; +@@ -1387,22 +1384,6 @@ void WasmEngine::LogCode(base::Vector code_vec) { + DCHECK_EQ(native_module, code->native_module()); + code->IncRef(); + } +- +- if (info->log_codes_task == nullptr) { +- auto new_task = std::make_unique(isolate); +- info->log_codes_task = new_task.get(); +- // Store the LogCodeTasks to post them outside the WasmEngine::mutex_. +- // Posting the task in the mutex can cause the following deadlock (only +- // in d8): When d8 shuts down, it sets a terminate to the task runner. +- // When the terminate flag in the taskrunner is set, all newly posted +- // tasks get destroyed immediately. When the LogCodesTask gets +- // destroyed, it takes the WasmEngine::mutex_ lock to deregister itself +- // from the IsolateInfo. Therefore, as the LogCodesTask may get +- // destroyed immediately when it gets posted, it cannot get posted when +- // the WasmEngine::mutex_ lock is held. +- to_schedule.emplace_back(info->foreground_task_runner, +- std::move(new_task)); +- } + } + } + for (auto& [runner, task] : to_schedule) { +@@ -1450,18 +1431,6 @@ void WasmEngine::LogOutstandingCodesForIsolate(Isolate* isolate) { + } + } + +-void WasmEngine::DeregisterCodeLoggingTask(LogCodesTask* task) { +- base::MutexGuard engine_mutex_guard(&mutex_); +- Isolate* isolate = task->isolate_; +- auto it = isolates_.find(isolate); +- // If the isolate died already, the IsolateInfo can not be found. +- if (it == isolates_.end()) return; +- IsolateInfo* info = it->second.get(); +- // If another task is already scheduled (or we already deregistered), return. +- if (info->log_codes_task != task) return; +- info->log_codes_task = nullptr; +-} +- + std::shared_ptr WasmEngine::NewNativeModule( + Isolate* isolate, WasmEnabledFeatures enabled, + CompileTimeImports compile_imports, +@@ -1909,7 +1878,7 @@ void WasmEngine::PotentiallyFinishCurrentGC() { + + size_t WasmEngine::EstimateCurrentMemoryConsumption() const { + UPDATE_WHEN_CLASS_CHANGES(WasmEngine, 760); +- UPDATE_WHEN_CLASS_CHANGES(IsolateInfo, 192); ++ UPDATE_WHEN_CLASS_CHANGES(IsolateInfo, 184); + UPDATE_WHEN_CLASS_CHANGES(NativeModuleInfo, 144); + UPDATE_WHEN_CLASS_CHANGES(CurrentGCInfo, 96); + size_t result = sizeof(WasmEngine); +diff --git a/src/wasm/wasm-engine.h b/src/wasm/wasm-engine.h +index 4d9fce22e05b24ce1345d3df19257aa39e85c70b..5e353b8474859b03711a85400d913b5ade2efda9 100644 +--- a/src/wasm/wasm-engine.h ++++ b/src/wasm/wasm-engine.h +@@ -298,10 +298,6 @@ class V8_EXPORT_PRIVATE WasmEngine { + // outstanding code objects (added via {LogCode}). + void LogOutstandingCodesForIsolate(Isolate*); + +- // Code logging is done via a separate task per isolate. This deregisters a +- // task after execution (or destruction because of isolate shutdown). +- void DeregisterCodeLoggingTask(LogCodesTask*); +- + // Create a new NativeModule. The caller is responsible for its + // lifetime. The native module will be given some memory for code, + // which will be page size aligned. The size of the initial memory diff --git a/src/workerd/jsg/setup.c++ b/src/workerd/jsg/setup.c++ index 7c5ba7068ac..e7db355d894 100644 --- a/src/workerd/jsg/setup.c++ +++ b/src/workerd/jsg/setup.c++ @@ -206,14 +206,12 @@ void IsolateBase::clearDestructionQueue() { } HeapTracer::HeapTracer(v8::Isolate* isolate) - : v8::EmbedderRootsHandler( - // Historically V8 would call IsRoot() to scan references, and then call ResetRoot() - // on those where IsRoot() returned false. But later, V8 added the ability to mark a - // reference "droppable", and it assumes droppable references are not roots. We only - // want V8 to call ResetRoot() on droppable references, so we can tell it not to bother - // even calling `IsRoot()` on anything else. See comment about droppable references - // in Wrappable::attachWrapper() for details. - v8::EmbedderRootsHandler::RootHandling::kDontQueryEmbedderForAnyReference), + // Historically V8 would call IsRoot() to scan references, and then call ResetRoot() on those + // where IsRoot() returned false. Currently, V8 allows marking a reference as "droppable", and + // assumes droppable references are not roots. This way V8 only calls ResetRoot() on droppable + // references, and doesn't even call `IsRoot()` on anything else. See comment about droppable + // references in Wrappable::attachWrapper() for details. + : v8::EmbedderRootsHandler(), isolate(isolate) { isolate->AddGCPrologueCallback( [](v8::Isolate* isolate, v8::GCType type, v8::GCCallbackFlags flags, void* data) { @@ -253,9 +251,8 @@ HeapTracer& HeapTracer::getTracer(v8::Isolate* isolate) { } bool HeapTracer::IsRoot(const v8::TracedReference& handle) { - // V8 doesn't actually call this because we passed kDontQueryEmbedderForAnyReference to the - // EmbedderRootsHandler constructor. V8 will potentially use ResetRoot() only on references that - // were marked droppable. + // V8 doesn't actually call this anymore unless a deprecated EmbedderRootsHandler option is used. + // V8 will potentially use ResetRoot() only on references that were marked droppable. KJ_UNREACHABLE; } diff --git a/src/workerd/jsg/util.c++ b/src/workerd/jsg/util.c++ index 6057cc1b9f1..c16a958f941 100644 --- a/src/workerd/jsg/util.c++ +++ b/src/workerd/jsg/util.c++ @@ -614,14 +614,14 @@ void returnRejectedPromise( const v8::FunctionCallbackInfo& info, v8::Local exception, v8::TryCatch& tryCatch) { - return returnRejectedPromiseImpl(info, exception, tryCatch); + return returnRejectedPromiseImpl&>(info, exception, tryCatch); } void returnRejectedPromise( const v8::PropertyCallbackInfo& info, v8::Local exception, v8::TryCatch& tryCatch) { - return returnRejectedPromiseImpl(info, exception, tryCatch); + return returnRejectedPromiseImpl&>(info, exception, tryCatch); } // ======================================================================================