Skip to content

Commit c97b321

Browse files
committed
reproduce v8 fast api bug
1 parent a9a9829 commit c97b321

File tree

6 files changed

+205
-179
lines changed

6 files changed

+205
-179
lines changed

githooks/pre-commit

100755100644
File mode changed.

src/workerd/jsg/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ wd_cc_library(
282282
src = f,
283283
local_defines = ["JSG_IMPLEMENTATION"],
284284
deps = [":jsg"],
285+
size = "enormous",
285286
) for f in glob(
286287
["*-test.c++"],
287288
exclude = [

src/workerd/jsg/fast-api-test.c++

Lines changed: 198 additions & 177 deletions
Large diffs are not rendered by default.

src/workerd/jsg/fast-api.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ concept FastApiPrimitive = kj::isSameType<T, void>() || kj::isSameType<T, bool>(
6363

6464
// Helper to determine if a type can be used as a parameter in V8 Fast API
6565
template <typename T>
66-
concept FastApiParam = !isFunctionCallbackInfo<kj::RemoveConst<kj::Decay<T>>> &&
67-
!isKjPromise<kj::RemoveConst<kj::Decay<T>>> && !isJsgPromise<kj::RemoveConst<kj::Decay<T>>>;
66+
concept FastApiParam = !isFunctionCallbackInfo<kj::RemoveConst<kj::Decay<T>>>;
6867

6968
// Helper to determine if a type can be used as a return value in a V8 Fast API
7069
template <typename T>
@@ -106,6 +105,8 @@ struct FastApiJSGToV8 {
106105
using value = v8::Local<v8::Value>;
107106
};
108107

108+
// TODO(soon): Address this.
109+
// Removing v8::FastOneByteString will fix GC related issues.
109110
template <typename T>
110111
requires StringLike<kj::RemoveConst<kj::Decay<T>>>
111112
struct FastApiJSGToV8<T> {

src/workerd/jsg/promise.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ class PromiseWrapper {
618618
if (handle->IsPromise()) {
619619
auto promise = handle.As<v8::Promise>();
620620
if constexpr (!isVoid<T>() && !isV8Ref<T>()) {
621+
js.v8Isolate->RequestGarbageCollectionForTesting(v8::Isolate::kFullGarbageCollection);
621622
// Add a .then() to unwrap the promise's resolution (i.e. convert it from JS to C++).
622623
// Note that we don't need to handle the rejection case here as there is no wrapping
623624
// applied to exception values, so we just let it propagate through.

src/workerd/jsg/value.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@ class StringWrapper {
516516
template <StringLike T>
517517
kj::Maybe<T> tryUnwrap(
518518
Lock& js, v8::Local<v8::Context> context, const v8::FastOneByteString& handle, T*) {
519+
KJ_DBG("Converting FAST ONE BYTE STRING");
520+
// js.v8Isolate->RequestGarbageCollectionForTesting(v8::Isolate::kFullGarbageCollection);
519521
size_t utf8_length = simdutf::utf8_length_from_latin1(handle.data, handle.length);
520522
kj::Array<char> buf = kj::heapArray<char>(utf8_length + 1);
521523
buf[utf8_length] = '\0';

0 commit comments

Comments
 (0)