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

Get JSPI working #1685

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 5 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,11 @@ http_archive(
"//: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-wasm-jspi-Simplify-JS-frames-detection.patch",
"//:patches/v8/0016-Refactor-flag-for-JSPI-to-allow-dynamic-setting.patch",
"//:patches/v8/0017-wasm-js-jspi-Set-up-wasm-experimental-jspi-as-a-flag.patch",
"//:patches/v8/0018-wasm-type-reflection-Implement-dynamic-flag-for-wasm.patch",
"//:patches/v8/0019-Move-InitJSPIFeature-into-InstallConditionalFeatures.patch",
],
sha256 = "45e0ba667fb1a86f834d6a92b513c43fcfdc672525c8a5a60bfdb56eec137d4a",
strip_prefix = "v8-12.1.285.26",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 025482cca7b65b7692d2905fdf8eb8844cd560c3 Mon Sep 17 00:00:00 2001
From 28f0788c64a98a4c5a805a14ea5c190ece87f24c 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
Subject: [PATCH 01/19] Allow manually setting ValueDeserializer format version

For many years, V8's serialization version didn't change. In the meantime,
we accidentally stored data that was missing a version header. This patch
Expand All @@ -22,7 +22,7 @@ like:
3 files changed, 18 insertions(+)

diff --git a/include/v8-value-serializer.h b/include/v8-value-serializer.h
index 0cb3e045bc46ec732956318b980e749d1847d06d..40ad805c7970cc9379e69f046205836dbd760373 100644
index 0cb3e045bc4..40ad805c797 100644
--- a/include/v8-value-serializer.h
+++ b/include/v8-value-serializer.h
@@ -293,6 +293,13 @@ class V8_EXPORT ValueDeserializer {
Expand All @@ -40,7 +40,7 @@ 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 84d7d170cd0..d5e17d0b992 100644
--- a/src/api/api.cc
+++ b/src/api/api.cc
@@ -3678,6 +3678,10 @@ uint32_t ValueDeserializer::GetWireFormatVersion() const {
Expand All @@ -55,7 +55,7 @@ index 84d7d170cd0a96ec4d9cf772b13f779a3bd5bbeb..d5e17d0b9927a89c12013c5b0d3075f4
PREPARE_FOR_EXECUTION(context, ValueDeserializer, ReadValue);
i::MaybeHandle<i::Object> result;
diff --git a/src/objects/value-serializer.h b/src/objects/value-serializer.h
index 9b2d97cf79a21ff6d352172efaf53fdca4ac8e7b..8d9602b129a6156f051690ed595ca699bb132af4 100644
index 9b2d97cf79a..8d9602b129a 100644
--- a/src/objects/value-serializer.h
+++ b/src/objects/value-serializer.h
@@ -217,6 +217,13 @@ class ValueDeserializer {
Expand All @@ -72,3 +72,6 @@ index 9b2d97cf79a21ff6d352172efaf53fdca4ac8e7b..8d9602b129a6156f051690ed595ca699
/*
* Deserializes a V8 object from the buffer.
*/
--
2.34.1

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 029d28b2a8470a26bb60c54781a0835910dcc583 Mon Sep 17 00:00:00 2001
From 8600761aa89ee3d84a0633635314cd1400b903d7 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
Subject: [PATCH 02/19] Allow manually setting ValueSerializer format version

Refs: https://bitbucket.cfdata.org/projects/MIRRORS/repos/v8/pull-requests/2/overview
---
Expand All @@ -12,7 +12,7 @@ Refs: https://bitbucket.cfdata.org/projects/MIRRORS/repos/v8/pull-requests/2/ove
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
index 40ad805c797..596be18adeb 100644
--- a/include/v8-value-serializer.h
+++ b/include/v8-value-serializer.h
@@ -154,6 +154,11 @@ class V8_EXPORT ValueSerializer {
Expand All @@ -28,7 +28,7 @@ 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 d5e17d0b992..f59eed43d78 100644
--- a/src/api/api.cc
+++ b/src/api/api.cc
@@ -3546,6 +3546,10 @@ ValueSerializer::ValueSerializer(Isolate* v8_isolate, Delegate* delegate)
Expand All @@ -43,7 +43,7 @@ index d5e17d0b9927a89c12013c5b0d3075f47751f48a..f59eed43d782fe434e4dcbcd7fb7cb4c

void ValueSerializer::SetTreatArrayBufferViewsAsHostObjects(bool mode) {
diff --git a/src/objects/value-serializer.cc b/src/objects/value-serializer.cc
index 1b2eefa1ea67e0ea9f03641bf2e454a1046cb267..f0b1956253fe603ad6da30a41fb923078ef6bd78 100644
index 1b2eefa1ea6..f0b1956253f 100644
--- a/src/objects/value-serializer.cc
+++ b/src/objects/value-serializer.cc
@@ -267,6 +267,7 @@ ValueSerializer::ValueSerializer(Isolate* isolate,
Expand Down Expand Up @@ -89,7 +89,7 @@ index 1b2eefa1ea67e0ea9f03641bf2e454a1046cb267..f0b1956253fe603ad6da30a41fb92307
}

diff --git a/src/objects/value-serializer.h b/src/objects/value-serializer.h
index 8d9602b129a6156f051690ed595ca699bb132af4..4747119155007e1fa0075440fefa1dfee036c48a 100644
index 8d9602b129a..47471191550 100644
--- a/src/objects/value-serializer.h
+++ b/src/objects/value-serializer.h
@@ -54,6 +54,11 @@ class ValueSerializer {
Expand All @@ -112,3 +112,6 @@ index 8d9602b129a6156f051690ed595ca699bb132af4..4747119155007e1fa0075440fefa1dfe

// To avoid extra lookups in the identity map, ID+1 is actually stored in the
// map (checking if the used identity is zero is the fast way of checking if
--
2.34.1

9 changes: 6 additions & 3 deletions patches/v8/0003-Make-icudata-target-public.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
From 727f8f091a86edfe8c006cff310f1def08cbed6b Mon Sep 17 00:00:00 2001
From 83d4dbe30820e50cbd96bacab1df4b7bc3b7164a Mon Sep 17 00:00:00 2001
From: Kenton Varda <[email protected]>
Date: Sat, 17 Sep 2022 11:11:15 -0500
Subject: Make `:icudata` target public.
Subject: [PATCH 03/19] Make `:icudata` target public.

Dependencies are required to load this file, so it ought to be exposed for them to use.
---
bazel/BUILD.icu | 1 +
1 file changed, 1 insertion(+)

diff --git a/bazel/BUILD.icu b/bazel/BUILD.icu
index 2ae79a5784f252ab69b58cd47d131aec65d34701..4843ea09f99fa1b45bf66af8fd971adfd89efe45 100644
index 2ae79a5784f..4843ea09f99 100644
--- a/bazel/BUILD.icu
+++ b/bazel/BUILD.icu
@@ -5,6 +5,7 @@
Expand All @@ -20,3 +20,6 @@ index 2ae79a5784f252ab69b58cd47d131aec65d34701..4843ea09f99fa1b45bf66af8fd971adf
)

cc_library(
--
2.34.1

9 changes: 6 additions & 3 deletions patches/v8/0004-Add-ArrayBuffer-MaybeNew.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From f8be71a7afa20ded149f594f7ac38e53d2c85fa0 Mon Sep 17 00:00:00 2001
From 643989a3af36a11c045b9ee66b875edef586b45f 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()`.
Subject: [PATCH 04/19] 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()`.

Expand All @@ -11,7 +11,7 @@ In Cloudflare's edge runtime, this is part of a larger patch that allows gracefu
1 file changed, 8 insertions(+)

diff --git a/include/v8-array-buffer.h b/include/v8-array-buffer.h
index 804fc42c4b56dd9b79f0fdc49e94c0e101e510e8..369e770351b80c60cae43866139e3a5396de08bd 100644
index 804fc42c4b5..369e770351b 100644
--- a/include/v8-array-buffer.h
+++ b/include/v8-array-buffer.h
@@ -210,6 +210,14 @@ class V8_EXPORT ArrayBuffer : public Object {
Expand All @@ -29,3 +29,6 @@ index 804fc42c4b56dd9b79f0fdc49e94c0e101e510e8..369e770351b80c60cae43866139e3a53
/**
* Create a new ArrayBuffer. Allocate |byte_length| bytes.
* Allocated memory will be owned by a created ArrayBuffer and
--
2.34.1

13 changes: 8 additions & 5 deletions patches/v8/0005-Allow-Windows-builds-under-Bazel.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 9e93f5c62780aac7bf8649f76ecd3181df1473dc Mon Sep 17 00:00:00 2001
From 23ee0a53b953720dc19b295ffd1e9f4007b59e37 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
Subject: [PATCH 05/19] Allow Windows builds under Bazel

---
BUILD.bazel | 29 +++++++++++++++++------------
Expand All @@ -10,7 +10,7 @@ Subject: Allow Windows builds under Bazel
3 files changed, 84 insertions(+), 12 deletions(-)

diff --git a/BUILD.bazel b/BUILD.bazel
index 20af81b002fc1aefc14abb27085a7480d2f440a7..14d0c35fd606afa89d870a4f0ecdb567c7b75cad 100644
index 20af81b002f..14d0c35fd60 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -703,6 +703,7 @@ filegroup(
Expand Down Expand Up @@ -114,7 +114,7 @@ index 20af81b002fc1aefc14abb27085a7480d2f440a7..14d0c35fd606afa89d870a4f0ecdb567
python_version = "PY3",
tags = [
diff --git a/bazel/config/BUILD.bazel b/bazel/config/BUILD.bazel
index 67454fa90eea460e70e286623fb1c99edd22c650..7efff1ab909dc7048a216e511c2e71c72ee8847a 100644
index 67454fa90ee..7efff1ab909 100644
--- a/bazel/config/BUILD.bazel
+++ b/bazel/config/BUILD.bazel
@@ -286,6 +286,7 @@ selects.config_setting_group(
Expand Down Expand Up @@ -183,7 +183,7 @@ index 67454fa90eea460e70e286623fb1c99edd22c650..7efff1ab909dc7048a216e511c2e71c7
name = "is_clang",
match_any = [
diff --git a/bazel/defs.bzl b/bazel/defs.bzl
index b0b5eab46219f2abd263221de12c07a5cc7b2b10..0c59518819cb685fe9f68080d6bdbeb0b7ff5033 100644
index b0b5eab4621..0c59518819c 100644
--- a/bazel/defs.bzl
+++ b/bazel/defs.bzl
@@ -117,6 +117,24 @@ def _default_args():
Expand Down Expand Up @@ -251,3 +251,6 @@ index b0b5eab46219f2abd263221de12c07a5cc7b2b10..0c59518819cb685fe9f68080d6bdbeb0
"//conditions:default": "",
}),
)
--
2.34.1

9 changes: 6 additions & 3 deletions patches/v8/0006-Disable-bazel-whole-archive-build.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 42ae0d533772f9aae98f0f17454802e2b2af3bc0 Mon Sep 17 00:00:00 2001
From 24866314f6731cc395d6b6199c0b764ca55fc022 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
Subject: [PATCH 06/19] Disable bazel whole-archive build

V8's bazel configuration system adds the alwayslink parameter (equivalent
to --Wl,-whole-archive on Linux) to all V8 libraries, causing all V8
Expand All @@ -14,7 +14,7 @@ allows the linker to eliminate unused symbols.
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bazel/BUILD.icu b/bazel/BUILD.icu
index 4843ea09f99fa1b45bf66af8fd971adfd89efe45..73a25df55abc380092a0177bb13364e6f216ce95 100644
index 4843ea09f99..73a25df55ab 100644
--- a/bazel/BUILD.icu
+++ b/bazel/BUILD.icu
@@ -56,7 +56,7 @@ cc_library(
Expand All @@ -35,3 +35,6 @@ index 4843ea09f99fa1b45bf66af8fd971adfd89efe45..73a25df55abc380092a0177bb13364e6
)

cc_library(
--
2.34.1

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 10c232c3282ceda1c144b4edf0d762a2289fa23f Mon Sep 17 00:00:00 2001
From 7c5cd22643b478d2b27d5aea31427b17744a4d6c 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().
Subject: [PATCH 07/19] Make v8::Locker automatically call isolate->Enter().

This makes it no longer necessary to create a v8::Isolate::Scope after taking the lock.

Expand All @@ -13,7 +13,7 @@ This is a major change in API semantics, however, which makes it unlikely to be
1 file changed, 2 insertions(+)

diff --git a/src/execution/v8threads.cc b/src/execution/v8threads.cc
index 4205817b73f3d954be4109d91721037b3aa2d4ee..91e1a43d305d06fdf07fccdf80eb07e86115619b 100644
index 4205817b73f..91e1a43d305 100644
--- a/src/execution/v8threads.cc
+++ b/src/execution/v8threads.cc
@@ -40,6 +40,7 @@ void Locker::Initialize(v8::Isolate* isolate) {
Expand All @@ -32,3 +32,6 @@ index 4205817b73f3d954be4109d91721037b3aa2d4ee..91e1a43d305d06fdf07fccdf80eb07e8
isolate_->thread_manager()->Unlock();
}
}
--
2.34.1

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
From 44878c36ee87d51dadd3815bf5de749d05cfe189 Mon Sep 17 00:00:00 2001
From e1f6d5b659a30c0aa6200c7522d222ad34817bf3 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.
Subject: [PATCH 08/19] 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.

Expand All @@ -12,7 +13,7 @@ This is not the right solution. Instead, each background task/job implementation
2 files changed, 62 insertions(+)

diff --git a/include/v8-locker.h b/include/v8-locker.h
index 22b7a8767a83a702a2601bdfd4c0f71206df0ad5..fee48faffe82400595dca17197c5bbee680a6137 100644
index 22b7a8767a8..fee48faffe8 100644
--- a/include/v8-locker.h
+++ b/include/v8-locker.h
@@ -6,6 +6,7 @@
Expand Down Expand Up @@ -60,7 +61,7 @@ index 22b7a8767a83a702a2601bdfd4c0f71206df0ad5..fee48faffe82400595dca17197c5bbee

#endif // INCLUDE_V8_LOCKER_H_
diff --git a/src/execution/v8threads.cc b/src/execution/v8threads.cc
index 91e1a43d305d06fdf07fccdf80eb07e86115619b..dfe5da8f6bdc5a30d65b7f31d0e3a42fbe49d22b 100644
index 91e1a43d305..dfe5da8f6bd 100644
--- a/src/execution/v8threads.cc
+++ b/src/execution/v8threads.cc
@@ -6,6 +6,7 @@
Expand Down Expand Up @@ -107,3 +108,6 @@ index 91e1a43d305d06fdf07fccdf80eb07e86115619b..dfe5da8f6bdc5a30d65b7f31d0e3a42f
+}
+
} // namespace v8
--
2.34.1

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 8316053ffc2767486f2722aecb0a4af623474a26 Mon Sep 17 00:00:00 2001
From ea78783b6fdbf53d19efcf5dadb9c4292218c8e4 Mon Sep 17 00:00:00 2001
From: Felix Hanau <[email protected]>
Date: Wed, 7 Jun 2023 21:40:54 -0400
Subject: Speed up V8 bazel build by always using target cfg
Subject: [PATCH 09/19] Speed up V8 bazel build by always using target cfg

See the workerd build cfg changes for rationale. This provides a significant
speedup for the build: Components like ICU were previously compiled in
Expand All @@ -16,7 +16,7 @@ this also improves build times.
2 files changed, 57 insertions(+), 16 deletions(-)

diff --git a/BUILD.bazel b/BUILD.bazel
index 14d0c35fd606afa89d870a4f0ecdb567c7b75cad..be82fc2e20a10ded7cd8a949af0533a74290d49d 100644
index 14d0c35fd60..be82fc2e20a 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -17,6 +17,7 @@ load(
Expand Down Expand Up @@ -74,7 +74,7 @@ index 14d0c35fd606afa89d870a4f0ecdb567c7b75cad..be82fc2e20a10ded7cd8a949af0533a7
],
)
diff --git a/bazel/defs.bzl b/bazel/defs.bzl
index 0c59518819cb685fe9f68080d6bdbeb0b7ff5033..7053ca31b999ae7423e7485ee6392a09f9de4aa9 100644
index 0c59518819c..7053ca31b99 100644
--- a/bazel/defs.bzl
+++ b/bazel/defs.bzl
@@ -336,6 +336,15 @@ def v8_library(
Expand Down Expand Up @@ -162,3 +162,6 @@ index 0c59518819cb685fe9f68080d6bdbeb0b7ff5033..7053ca31b999ae7423e7485ee6392a09
+ ),
+ },
+)
--
2.34.1

Loading
Loading