Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v8 12.2 update #1694

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ http_archive(
url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()

Expand Down Expand Up @@ -190,6 +190,11 @@ bind(
actual = "@com_google_absl//absl/container:flat_hash_map",
)

bind(
name = "absl_btree",
actual = "@com_google_absl//absl/container:btree",
)

# tcmalloc requires this "rules_fuzzing" package. Its build files fail analysis without it, even
# though it is unused for our purposes.
http_archive(
Expand Down Expand Up @@ -422,24 +427,24 @@ http_archive(
patches = [
"//:patches/v8/0001-Allow-manually-setting-ValueDeserializer-format-vers.patch",
"//:patches/v8/0002-Allow-manually-setting-ValueSerializer-format-versio.patch",
"//:patches/v8/0003-Make-icudata-target-public.patch",
"//:patches/v8/0004-Add-ArrayBuffer-MaybeNew.patch",
"//:patches/v8/0005-Allow-Windows-builds-under-Bazel.patch",
"//:patches/v8/0006-Disable-bazel-whole-archive-build.patch",
"//:patches/v8/0007-Make-v8-Locker-automatically-call-isolate-Enter.patch",
"//:patches/v8/0008-Add-an-API-to-capture-and-restore-the-cage-base-poin.patch",
"//:patches/v8/0009-Speed-up-V8-bazel-build-by-always-using-target-cfg.patch",
"//:patches/v8/0010-Implement-Promise-Context-Tagging.patch",
"//:patches/v8/0011-Enable-V8-shared-linkage.patch",
"//:patches/v8/0012-Fix-V8-ICU-build.patch",
"//:patches/v8/0013-Randomize-the-initial-ExecutionContextId-used-by-the.patch",
"//:patches/v8/0014-Always-enable-continuation-preserved-data-in-the-bui.patch",
"//:patches/v8/0015-Attach-continuation-context-to-Promise-thenable-task.patch",
"//:patches/v8/0003-Add-ArrayBuffer-MaybeNew.patch",
"//:patches/v8/0004-Allow-Windows-builds-under-Bazel.patch",
"//:patches/v8/0005-Disable-bazel-whole-archive-build.patch",
"//:patches/v8/0006-Make-v8-Locker-automatically-call-isolate-Enter.patch",
"//:patches/v8/0007-Add-an-API-to-capture-and-restore-the-cage-base-poin.patch",
"//:patches/v8/0008-Speed-up-V8-bazel-build-by-always-using-target-cfg.patch",
"//:patches/v8/0009-Implement-Promise-Context-Tagging.patch",
"//:patches/v8/0010-Enable-V8-shared-linkage.patch",
"//:patches/v8/0011-Fix-V8-ICU-build.patch",
"//:patches/v8/0012-Randomize-the-initial-ExecutionContextId-used-by-the.patch",
"//:patches/v8/0013-Always-enable-continuation-preserved-data-in-the-bui.patch",
"//:patches/v8/0014-Attach-continuation-context-to-Promise-thenable-task.patch",
"//:patches/v8/0015-increase-visibility-of-virtual-method.patch",
],
sha256 = "45e0ba667fb1a86f834d6a92b513c43fcfdc672525c8a5a60bfdb56eec137d4a",
strip_prefix = "v8-12.1.285.26",
integrity = "sha256-jcBk1hBhzrMHRL0EDTgHKBVrJPsP1SLZL6A5/l6arrs=",
strip_prefix = "v8-12.2.281.18",
type = "tgz",
url = "https://github.com/v8/v8/archive/refs/tags/12.1.285.26.tar.gz",
url = "https://github.com/v8/v8/archive/refs/tags/12.2.281.18.tar.gz",
)

git_repository(
Expand Down Expand Up @@ -488,9 +493,6 @@ git_repository(
remote = "https://chromium.googlesource.com/chromium/src/base/trace_event/common.git",
)

# This sets up a hermetic python3, rather than depending on what is installed.
load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
name = "python3_12",
ignore_root_user_error = True,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From d529886e9db66ef38cd317d417c23bb7bdc964c0 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alex Robinson <[email protected]>
Date: Wed, 2 Mar 2022 15:58:04 -0600
Subject: Allow manually setting ValueDeserializer format version
Expand All @@ -15,11 +15,6 @@ like:
deserializer.SetWireFormatVersion(13);
}
auto maybeValue = deserializer.ReadValue(isolate->GetCurrentContext());
---
include/v8-value-serializer.h | 7 +++++++
src/api/api.cc | 4 ++++
src/objects/value-serializer.h | 7 +++++++
3 files changed, 18 insertions(+)

diff --git a/include/v8-value-serializer.h b/include/v8-value-serializer.h
index 0cb3e045bc46ec732956318b980e749d1847d06d..40ad805c7970cc9379e69f046205836dbd760373 100644
Expand All @@ -40,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 84d7d170cd0a96ec4d9cf772b13f779a3bd5bbeb..d5e17d0b9927a89c12013c5b0d3075f47751f48a 100644
index 8b709703b5fb51fed49832992f6c1dbeab933442..b5294331fa631d810c8e3a073a3358fc4d9260d7 100644
--- a/src/api/api.cc
+++ b/src/api/api.cc
@@ -3678,6 +3678,10 @@ uint32_t ValueDeserializer::GetWireFormatVersion() const {
@@ -3677,6 +3677,10 @@ uint32_t ValueDeserializer::GetWireFormatVersion() const {
return private_->deserializer.GetWireFormatVersion();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
From b05b76fd24b4277a9d6fcf6d6462aa5f583582ab Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: James M Snell <[email protected]>
Date: Wed, 16 Mar 2022 08:59:21 -0700
Subject: Allow manually setting ValueSerializer format version

Refs: https://bitbucket.cfdata.org/projects/MIRRORS/repos/v8/pull-requests/2/overview
---
include/v8-value-serializer.h | 5 +++++
src/api/api.cc | 4 ++++
src/objects/value-serializer.cc | 17 ++++++++++++++---
src/objects/value-serializer.h | 6 ++++++
4 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/include/v8-value-serializer.h b/include/v8-value-serializer.h
index 40ad805c7970cc9379e69f046205836dbd760373..596be18adeb3a5a81794aaa44b1d347dec6c0c7d 100644
Expand All @@ -28,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 d5e17d0b9927a89c12013c5b0d3075f47751f48a..f59eed43d782fe434e4dcbcd7fb7cb4c5f2590b4 100644
index b5294331fa631d810c8e3a073a3358fc4d9260d7..70f922a1ee4a6ac8ca7c35fe1e758af6bed55e4e 100644
--- a/src/api/api.cc
+++ b/src/api/api.cc
@@ -3546,6 +3546,10 @@ ValueSerializer::ValueSerializer(Isolate* v8_isolate, Delegate* delegate)
@@ -3545,6 +3545,10 @@ ValueSerializer::ValueSerializer(Isolate* v8_isolate, Delegate* delegate)

ValueSerializer::~ValueSerializer() { delete private_; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
From bd257320c7a70ec3a330086b58f85b02d178d534 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kenton Varda <[email protected]>
Date: Fri, 16 Sep 2022 21:41:45 -0500
Subject: Add `ArrayBuffer::MaybeNew()`.

In Cloudflare's edge runtime, this is part of a larger patch that allows graceful handling of allocations that exceed memory limits. `workerd` currently doesn't enforce any limits, so to reduce complexity we just forward to `New()`.

(We would like to upstream our internal patch, just need to find the time...)
---
include/v8-array-buffer.h | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/include/v8-array-buffer.h b/include/v8-array-buffer.h
index 804fc42c4b56dd9b79f0fdc49e94c0e101e510e8..369e770351b80c60cae43866139e3a5396de08bd 100644
Expand Down
22 changes: 0 additions & 22 deletions patches/v8/0003-Make-icudata-target-public.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
From 5e8439c07e9f3a31591cb7c8bef6581293435255 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Brendan Coll <[email protected]>
Date: Thu, 16 Mar 2023 11:56:10 +0000
Subject: Allow Windows builds under Bazel

---
BUILD.bazel | 29 +++++++++++++++++------------
bazel/config/BUILD.bazel | 37 +++++++++++++++++++++++++++++++++++++
bazel/defs.bzl | 30 ++++++++++++++++++++++++++++++
3 files changed, 84 insertions(+), 12 deletions(-)

diff --git a/BUILD.bazel b/BUILD.bazel
index 20af81b002fc1aefc14abb27085a7480d2f440a7..14d0c35fd606afa89d870a4f0ecdb567c7b75cad 100644
index 03ff0d8b3b0aca28d87e9612d8c83d8e7614c1d6..47ceeacf9c5d34853f8d427b167381e396364656 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -703,6 +703,7 @@ filegroup(
@@ -777,6 +777,7 @@ filegroup(
"src/base/platform/mutex.h",
"src/base/platform/platform.cc",
"src/base/platform/platform.h",
+ "src/base/platform/platform-posix.h", # Always included by src/execution/isolate.h
"src/base/platform/semaphore.cc",
"src/base/platform/semaphore.h",
"src/base/platform/time.cc",
@@ -743,7 +744,6 @@ filegroup(
@@ -817,7 +818,6 @@ filegroup(
] + select({
"@v8//bazel/config:is_posix": [
"src/base/platform/platform-posix.cc",
- "src/base/platform/platform-posix.h",
"src/base/platform/platform-posix-time.cc",
"src/base/platform/platform-posix-time.h",
],
@@ -766,6 +766,7 @@ filegroup(
@@ -840,6 +840,7 @@ filegroup(
"@v8//bazel/config:is_windows": [
"src/base/debug/stack_trace_win.cc",
"src/base/platform/platform-win32.cc",
+ "src/base/platform/platform-win32.h",
"src/base/win32-headers.h",
],
}),
@@ -1154,6 +1155,7 @@ filegroup(
@@ -1229,6 +1230,7 @@ filegroup(
"include/v8-wasm-trap-handler-posix.h",
"src/api/api.cc",
"src/api/api.h",
+ "include/v8-wasm-trap-handler-win.h",
"src/api/api-arguments.cc",
"src/api/api-arguments.h",
"src/api/api-arguments-inl.h",
@@ -2596,6 +2598,11 @@ filegroup(
@@ -2669,6 +2671,11 @@ filegroup(
"src/trap-handler/handler-inside-posix.cc",
"src/trap-handler/handler-outside-posix.cc",
],
Expand All @@ -57,7 +52,7 @@ index 20af81b002fc1aefc14abb27085a7480d2f440a7..14d0c35fd606afa89d870a4f0ecdb567
"//conditions:default": [],
}) + select({
"@v8//bazel/config:v8_arm64_simulator": [
@@ -2603,13 +2610,6 @@ filegroup(
@@ -2676,13 +2683,6 @@ filegroup(
"src/trap-handler/trap-handler-simulator.h",
],
"//conditions:default": [],
Expand All @@ -71,7 +66,7 @@ index 20af81b002fc1aefc14abb27085a7480d2f440a7..14d0c35fd606afa89d870a4f0ecdb567
}) + select({
"@v8//bazel/config:is_windows_64bit": [
"src/diagnostics/unwinding-info-win64.cc",
@@ -3502,6 +3502,9 @@ filegroup(
@@ -3670,6 +3670,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"],
Expand All @@ -81,7 +76,7 @@ index 20af81b002fc1aefc14abb27085a7480d2f440a7..14d0c35fd606afa89d870a4f0ecdb567
}),
)

@@ -3865,9 +3868,11 @@ filegroup(
@@ -4033,9 +4036,11 @@ filegroup(
"src/d8/d8-js.cc",
"src/d8/d8-platforms.cc",
"src/d8/d8-platforms.h",
Expand All @@ -95,7 +90,7 @@ index 20af81b002fc1aefc14abb27085a7480d2f440a7..14d0c35fd606afa89d870a4f0ecdb567
)

genrule(
@@ -4202,7 +4207,7 @@ py_test(
@@ -4371,7 +4376,7 @@ py_test(
":noicu/d8",
":noicu/v8_build_config",
"//testing/pybase",
Expand All @@ -104,7 +99,7 @@ index 20af81b002fc1aefc14abb27085a7480d2f440a7..14d0c35fd606afa89d870a4f0ecdb567
main = "tools/run-tests.py",
python_version = "PY3",
tags = [
@@ -4232,7 +4237,7 @@ py_test(
@@ -4401,7 +4406,7 @@ py_test(
":icu/d8",
":icu/v8_build_config",
"//testing/pybase",
Expand Down Expand Up @@ -183,10 +178,10 @@ index 67454fa90eea460e70e286623fb1c99edd22c650..7efff1ab909dc7048a216e511c2e71c7
name = "is_clang",
match_any = [
diff --git a/bazel/defs.bzl b/bazel/defs.bzl
index b0b5eab46219f2abd263221de12c07a5cc7b2b10..0c59518819cb685fe9f68080d6bdbeb0b7ff5033 100644
index 1ea9bc0da8de0f3fe3d39cfac0c920d60ea763b9..f050b04f76b96fbc761671958126b62288f94fd5 100644
--- a/bazel/defs.bzl
+++ b/bazel/defs.bzl
@@ -117,6 +117,24 @@ def _default_args():
@@ -118,6 +118,24 @@ def _default_args():
"-Wno-non-virtual-dtor",
"-isystem .",
],
Expand All @@ -211,7 +206,7 @@ index b0b5eab46219f2abd263221de12c07a5cc7b2b10..0c59518819cb685fe9f68080d6bdbeb0
"//conditions:default": [],
}) + select({
"@v8//bazel/config:is_clang": [
@@ -163,13 +181,23 @@ def _default_args():
@@ -164,13 +182,23 @@ def _default_args():
],
"//conditions:default": [
],
Expand All @@ -235,15 +230,15 @@ index b0b5eab46219f2abd263221de12c07a5cc7b2b10..0c59518819cb685fe9f68080d6bdbeb0
],
"@v8//bazel/config:is_macos": ["-pthread"],
"//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"],
@@ -497,6 +525,7 @@ def v8_mksnapshot(name, args, suffix = ""):
@@ -498,6 +526,7 @@ def v8_mksnapshot(name, args, suffix = ""):
suffix = suffix,
target_os = select({
"@v8//bazel/config:is_macos": "mac",
+ "@v8//bazel/config:is_windows": "win",
"//conditions:default": "",
}),
)
@@ -508,6 +537,7 @@ def v8_mksnapshot(name, args, suffix = ""):
@@ -509,6 +538,7 @@ def v8_mksnapshot(name, args, suffix = ""):
suffix = suffix,
target_os = select({
"@v8//bazel/config:is_macos": "mac",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 7783257dadbc076574a7b0156a5f3c2b8d192956 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Felix Hanau <[email protected]>
Date: Tue, 11 Apr 2023 14:41:31 -0400
Subject: Disable bazel whole-archive build
Expand All @@ -9,26 +9,23 @@ object files to be included even if they are not referenced. This is more
aggressive than what's done in the GN build system and not needed for
workerd - disabling alwayslink improves the binary size by ~ 1MB as it
allows the linker to eliminate unused symbols.
---
bazel/BUILD.icu | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bazel/BUILD.icu b/bazel/BUILD.icu
index 4843ea09f99fa1b45bf66af8fd971adfd89efe45..73a25df55abc380092a0177bb13364e6f216ce95 100644
index 5fda2f468492a7a69266dba40c0862b0e31fa7a1..5127ceb7b783b11d5750c01977d7e34606c39667 100644
--- a/bazel/BUILD.icu
+++ b/bazel/BUILD.icu
@@ -56,7 +56,7 @@ cc_library(
"source/i18n",
@@ -54,7 +54,7 @@ cc_library(
"U_ICUDATAENTRY_IN_COMMON",
],
tags = ["requires-rtti"],
- alwayslink = 1,
+ alwayslink = 0,
)

cc_library(
@@ -85,7 +85,7 @@ cc_library(
"//conditions:default": [],
}),
@@ -78,7 +78,7 @@ cc_library(
"U_I18N_IMPLEMENTATION",
],
deps = [":icuuc"],
- alwayslink = 1,
+ alwayslink = 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 7ed177af0c5fa711cbd95e58e0161732ca601e6c Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kenton Varda <[email protected]>
Date: Tue, 23 May 2023 09:18:57 -0500
Subject: Make v8::Locker automatically call isolate->Enter().
Expand All @@ -8,9 +8,6 @@ This makes it no longer necessary to create a v8::Isolate::Scope after taking th
More importantly, without this change, the Locker consturctor will segfault when V8 is compiled with pointer compression enabled but shared pointer cages disabled, also known as multi-cage mode. This change ensures that the cage base pointers are set up immediately after taking the lock, before other code runs that depends on them.

This is a major change in API semantics, however, which makes it unlikely to be upstreamable.
---
src/execution/v8threads.cc | 2 ++
1 file changed, 2 insertions(+)

diff --git a/src/execution/v8threads.cc b/src/execution/v8threads.cc
index 4205817b73f3d954be4109d91721037b3aa2d4ee..91e1a43d305d06fdf07fccdf80eb07e86115619b 100644
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
From c793b007c8605fa8827ca80dac70aaef02908777 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kenton Varda <[email protected]>
Date: Tue, 23 May 2023 09:24:11 -0500
Subject: Add an API to capture and restore the cage base pointers.

This will be used in workerd to ensure that the cage pointers propagate to background thread tasks/jobs correctly.

This is not the right solution. Instead, each background task/job implementation should be updated to propagate the pointers itself. However, that seems to require searching all of V8 for such implementations, with a potential crash if one is missed. Under the current time pressure I'd rather take the catch-all approach.
---
include/v8-locker.h | 30 ++++++++++++++++++++++++++++++
src/execution/v8threads.cc | 32 ++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)

diff --git a/include/v8-locker.h b/include/v8-locker.h
index 22b7a8767a83a702a2601bdfd4c0f71206df0ad5..fee48faffe82400595dca17197c5bbee680a6137 100644
Expand Down
Loading
Loading