1
1
From bc2a85e39fd55879b9baed51429c08b27d5514c8 Mon Sep 17 00:00:00 2001
2
2
From: Matt Leon <mattleon@google.com>
3
3
Date: Wed, 16 Jul 2025 16:55:02 -0400
4
- Subject: [PATCH 1/6 ] Disable pointer compression
4
+ Subject: [PATCH 1/7 ] Disable pointer compression
5
5
6
6
Pointer compression limits the maximum number of WasmVMs.
7
7
@@ -30,7 +30,7 @@ index 3f5a87d054e..0a693b7ee10 100644
30
30
From 61898e9a63ac89a37261c081b84714cfc400a4b1 Mon Sep 17 00:00:00 2001
31
31
From: Matt Leon <mattleon@google.com>
32
32
Date: Wed, 16 Jul 2025 16:56:31 -0400
33
- Subject: [PATCH 2/6 ] Restore _allowlist_function_transition
33
+ Subject: [PATCH 2/7 ] Restore _allowlist_function_transition
34
34
35
35
Reverts v8 commit b26554ec368e9553782012c96aa5e99b163eaff2, which removed use of
36
36
_allowlist_function_transition from v8 bazel/defs.bzl, since it is still required
@@ -85,7 +85,7 @@ index 8c929454840..57336154cf7 100644
85
85
From 4a6e7158fd4ca48c75c8e33ea15760c9beea1d2f Mon Sep 17 00:00:00 2001
86
86
From: Matt Leon <mattleon@google.com>
87
87
Date: Wed, 16 Jul 2025 16:56:52 -0400
88
- Subject: [PATCH 3/6 ] Don't expose Wasm C API (only Wasm C++ API).
88
+ Subject: [PATCH 3/7 ] Don't expose Wasm C API (only Wasm C++ API).
89
89
90
90
Signed-off-by: Matt Leon <mattleon@google.com>
91
91
---
@@ -118,7 +118,7 @@ index 05e4029f183..d705be96a16 100644
118
118
From 7b593eb8086dcfe9012d4fa694d622f21dadb731 Mon Sep 17 00:00:00 2001
119
119
From: Matt Leon <mattleon@google.com>
120
120
Date: Wed, 16 Jul 2025 16:58:02 -0400
121
- Subject: [PATCH 4/6 ] Stub out fast_float for bazel-supplied version
121
+ Subject: [PATCH 4/7 ] Stub out fast_float for bazel-supplied version
122
122
123
123
Signed-off-by: Matt Leon <mattleon@google.com>
124
124
---
@@ -145,7 +145,7 @@ index 0a693b7ee10..eafd9dad20c 100644
145
145
From b442d34b12dd513946f509d9db86839ce8aa4d7f Mon Sep 17 00:00:00 2001
146
146
From: Matt Leon <mattleon@google.com>
147
147
Date: Wed, 16 Jul 2025 20:04:05 -0400
148
- Subject: [PATCH 5/6 ] Stub out vendored dependencies for bazel-sourced versions
148
+ Subject: [PATCH 5/7 ] Stub out vendored dependencies for bazel-sourced versions
149
149
150
150
Signed-off-by: Matt Leon <mattleon@google.com>
151
151
---
@@ -177,7 +177,7 @@ index eafd9dad20c..ce36666e36e 100644
177
177
From e0b8f32cc057a3c0875437d5d54d012cabcab458 Mon Sep 17 00:00:00 2001
178
178
From: Matt Leon <mattleon@google.com>
179
179
Date: Wed, 16 Jul 2025 20:29:10 -0400
180
- Subject: [PATCH 6/6 ] Add build flags to make V8 compile with GCC
180
+ Subject: [PATCH 6/7 ] Add build flags to make V8 compile with GCC
181
181
182
182
Signed-off-by: Matt Leon <mattleon@google.com>
183
183
---
@@ -201,3 +201,146 @@ index 14d7ace5e59..c7a48d4e805 100644
201
201
- -
202
202
2.50.0.727.gbf7dc18ff4-goog
203
203
204
+
205
+ From 7ce2d6bd14b338ab91a8636a8694b9ef180b2f90 Mon Sep 17 00:00:00 2001
206
+ From: Matt Leon <mattleon@google.com>
207
+ Date: Fri, 18 Jul 2025 17:28:42 -0400
208
+ Subject: [PATCH 7/7] Hack out atomic simd support in V8.
209
+
210
+ Atomic simdutf requires __cpp_lib_atomic_ref >= 201806, which is only
211
+ supported in clang libc++ 19+. The version of LLVM used in Envoy as of
212
+ 2025-07-18 is libc++ 18, so this is not supported.
213
+
214
+ The simdutf documentation indicates this atomic form is not tested and
215
+ is not recommended for use:
216
+ https://github.com/simdutf/simdutf/blob/5d1b6248f29a8ed0eb90f79be268be41730e39f8/include/simdutf/implementation.h#L3066-L3068
217
+
218
+ In addition, this is in the implementation of a JS array buffer. Since
219
+ proxy-wasm-cpp-host does not make use of JS array buffers or shared
220
+ memory between web workers, we're stubbing it out.
221
+
222
+ Mostly reverts
223
+ https://github.com/v8/v8/commit/6d6c1e680c7b8ea5f62a76e9c3d88d3fb0a88df0.
224
+
225
+ Signed-off-by: Matt Leon <mattleon@google.com>
226
+ ---
227
+ bazel/defs.bzl | 2 +-
228
+ src/builtins/builtins-typed-array.cc | 8 ++++++++
229
+ src/objects/simd.cc | 10 ++++++++++
230
+ 3 files changed, 19 insertions(+), 1 deletion(-)
231
+
232
+ diff --git a/bazel/defs.bzl b/bazel/defs.bzl
233
+ index c7a48d4e805..a73b3812882 100644
234
+ --- a/bazel/defs.bzl
235
+ +++ b/bazel/defs.bzl
236
+ @@ -180,7 +180,7 @@ def _default_args():
237
+ "Advapi32.lib",
238
+ ],
239
+ "@v8//bazel/config:is_macos": ["-pthread"],
240
+ - "//conditions:default": ["-Wl,--no-as-needed -ldl -latomic -pthread"],
241
+ + "//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"],
242
+ }) + select({
243
+ ":should_add_rdynamic": ["-rdynamic"],
244
+ "//conditions:default": [],
245
+ diff --git a/src/builtins/builtins-typed-array.cc b/src/builtins/builtins-typed-array.cc
246
+ index 918cb873481..bc933e8dc1d 100644
247
+ --- a/src/builtins/builtins-typed-array.cc
248
+ +++ b/src/builtins/builtins-typed-array.cc
249
+ @@ -520,17 +520,21 @@ simdutf::result ArrayBufferSetFromBase64(
250
+ DirectHandle<JSTypedArray> typed_array, size_t& output_length) {
251
+ output_length = array_length;
252
+ simdutf::result simd_result;
253
+ + #ifdef WANT_ATOMIC_REF
254
+ if (typed_array->buffer()->is_shared()) {
255
+ simd_result = simdutf::atomic_base64_to_binary_safe(
256
+ reinterpret_cast<const T>(input_vector), input_length,
257
+ reinterpret_cast<char*>(typed_array->DataPtr()), output_length,
258
+ alphabet, last_chunk_handling, /*decode_up_to_bad_char*/ true);
259
+ } else {
260
+ + #endif
261
+ simd_result = simdutf::base64_to_binary_safe(
262
+ reinterpret_cast<const T>(input_vector), input_length,
263
+ reinterpret_cast<char*>(typed_array->DataPtr()), output_length,
264
+ alphabet, last_chunk_handling, /*decode_up_to_bad_char*/ true);
265
+ + #ifdef WANT_ATOMIC_REF
266
+ }
267
+ + #endif
268
+
269
+ return simd_result;
270
+ }
271
+ @@ -833,15 +837,19 @@ BUILTIN(Uint8ArrayPrototypeToBase64) {
272
+ // 11. Return CodePointsToString(outAscii).
273
+
274
+ size_t simd_result_size;
275
+ + #ifdef WANT_ATOMIC_REF
276
+ if (uint8array->buffer()->is_shared()) {
277
+ simd_result_size = simdutf::atomic_binary_to_base64(
278
+ std::bit_cast<const char*>(uint8array->DataPtr()), length,
279
+ reinterpret_cast<char*>(output->GetChars(no_gc)), alphabet);
280
+ } else {
281
+ + #endif
282
+ simd_result_size = simdutf::binary_to_base64(
283
+ std::bit_cast<const char*>(uint8array->DataPtr()), length,
284
+ reinterpret_cast<char*>(output->GetChars(no_gc)), alphabet);
285
+ + #ifdef WANT_ATOMIC_REF
286
+ }
287
+ + #endif
288
+ DCHECK_EQ(simd_result_size, output_length);
289
+ USE(simd_result_size);
290
+ }
291
+ diff --git a/src/objects/simd.cc b/src/objects/simd.cc
292
+ index 0ef570ceb7d..9217fa76072 100644
293
+ --- a/src/objects/simd.cc
294
+ +++ b/src/objects/simd.cc
295
+ @@ -477,6 +477,7 @@ void Uint8ArrayToHexSlow(const char* bytes, size_t length,
296
+ }
297
+ }
298
+
299
+ + #ifdef WANT_ATOMIC_REF
300
+ void AtomicUint8ArrayToHexSlow(const char* bytes, size_t length,
301
+ DirectHandle<SeqOneByteString> string_output) {
302
+ int index = 0;
303
+ @@ -492,6 +493,7 @@ void AtomicUint8ArrayToHexSlow(const char* bytes, size_t length,
304
+ index += 2;
305
+ }
306
+ }
307
+ + #endif
308
+
309
+ inline uint16_t ByteToHex(uint8_t byte) {
310
+ const uint16_t correction = (('a' - '0' - 10) << 8) + ('a' - '0' - 10);
311
+ @@ -645,11 +647,15 @@ Tagged<Object> Uint8ArrayToHex(const char* bytes, size_t length, bool is_shared,
312
+ }
313
+ #endif
314
+
315
+ + #ifdef WANT_ATOMIC_REF
316
+ if (is_shared) {
317
+ AtomicUint8ArrayToHexSlow(bytes, length, string_output);
318
+ } else {
319
+ + #endif
320
+ Uint8ArrayToHexSlow(bytes, length, string_output);
321
+ + #ifdef WANT_ATOMIC_REF
322
+ }
323
+ + #endif
324
+ return *string_output;
325
+ }
326
+
327
+ @@ -1082,12 +1088,16 @@ bool ArrayBufferFromHex(const base::Vector<T>& input_vector, bool is_shared,
328
+ for (uint32_t i = 0; i < output_length * 2; i += 2) {
329
+ result = HandleRemainingHexValues(input_vector, i);
330
+ if (result.has_value()) {
331
+ + #ifdef WANT_ATOMIC_REF
332
+ if (is_shared) {
333
+ std::atomic_ref<uint8_t>(buffer[index++])
334
+ .store(result.value(), std::memory_order_relaxed);
335
+ } else {
336
+ + #endif
337
+ buffer[index++] = result.value();
338
+ + #ifdef WANT_ATOMIC_REF
339
+ }
340
+ + #endif
341
+ } else {
342
+ return false;
343
+ }
344
+ - -
345
+ 2.50.0.727.gbf7dc18ff4-goog
346
+
0 commit comments