Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion cmake/tools/SetupWebKit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option(WEBKIT_LOCAL "If a local version of WebKit should be used instead of down
option(WEBKIT_BUILD_TYPE "The build type for local WebKit (defaults to CMAKE_BUILD_TYPE)")

if(NOT WEBKIT_VERSION)
set(WEBKIT_VERSION b55703a58c8e57ac3479b9ba5cd434386a298965)
set(WEBKIT_VERSION fc9f2fa7272fec64905df6a9c78e15d7912f14ca)
endif()
Comment on lines 8 to 10

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

TAG="autobuild-fc9f2fa7272fec64905df6a9c78e15d7912f14ca"
REPO="oven-sh/WebKit"

echo "== Checking if release tag ${TAG} exists =="
if gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then
  echo "OK: Release tag exists"
else
  echo "FAIL: Release tag ${TAG} not found in ${REPO}"
  exit 1
fi

echo
echo "== Listing release assets =="
gh release view "$TAG" --repo "$REPO" --json assets --jq '.assets[].name' | sort

echo
echo "== Checking for expected platform artifacts =="
expected_assets=(
  "bun-webkit-linux-amd64-lto.tar.gz"
  "bun-webkit-linux-arm64-lto.tar.gz"
  "bun-webkit-macos-amd64-lto.tar.gz"
  "bun-webkit-macos-arm64-lto.tar.gz"
  "bun-webkit-windows-amd64-lto.tar.gz"
)

ASSETS_JSON="$(gh release view "$TAG" --repo "$REPO" --json assets)"
missing=0
for name in "${expected_assets[@]}"; do
  if echo "$ASSETS_JSON" | jq -e --arg n "$name" '.assets[] | select(.name == $n)' >/dev/null; then
    echo "OK   $name"
  else
    echo "MISS $name"
    missing=1
  fi
done

if [[ "$missing" -ne 0 ]]; then
  echo
  echo "WARN: Some expected artifacts may be missing"
fi

Repository: oven-sh/bun

Length of output: 239


Do not merge until the WebKit release is published.

The WEBKIT_VERSION is updated to fc9f2fa7272fec64905df6a9c78e15d7912f14ca, but the corresponding release tag autobuild-fc9f2fa7272fec64905df6a9c78e15d7912f14ca does not exist in oven-sh/WebKit. The build will fail when attempting to download prebuilt artifacts. The WebKit prebuilts must be built and published to the release page before this change can merge.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmake/tools/SetupWebKit.cmake` around lines 8 - 10, The WEBKIT_VERSION
variable was bumped to fc9f2fa7272fec64905df6a9c78e15d7912f14ca but the
corresponding release tag autobuild-fc9f2fa7272fec64905df6a9c78e15d7912f14ca is
not published yet; revert the WEBKIT_VERSION change in SetupWebKit.cmake
(restore the prior commit hash) or gate this change until the prebuilts are
published by removing the new hash from the set(WEBKIT_VERSION ...) assignment
and/or adding a pre-check that validates the existence of the release tag before
attempting to download prebuilts (use the WEBKIT_VERSION symbol and the expected
autobuild-<WEBKIT_VERSION> tag name in the check).



Expand Down
2 changes: 1 addition & 1 deletion scripts/build/deps/webkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* for local mode. Override via `--webkit-version=<hash>` to test a branch.
* From https://github.com/oven-sh/WebKit releases.
*/
export const WEBKIT_VERSION = "b55703a58c8e57ac3479b9ba5cd434386a298965";
export const WEBKIT_VERSION = "fc9f2fa7272fec64905df6a9c78e15d7912f14ca";

/**
* WebKit (JavaScriptCore) — the JS engine.
Expand Down
4 changes: 3 additions & 1 deletion scripts/verify-baseline-static/allowlist-x64-windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ _RNvNvNtNtNt<rust-hash>6memchr4arch6x86_646memchr11memchr3_raw6detect [AVX, AVX

# ----------------------------------------------------------------------------
# MSVC STL vectorized algorithms. Gate: __isa_available.
# (11 symbols)
# (13 symbols)
# ----------------------------------------------------------------------------
__std_reverse_copy_trivially_copyable_1 [AVX, AVX2]
__std_reverse_trivially_swappable_1 [AVX, AVX2]
Expand All @@ -596,6 +596,8 @@ __std_reverse_trivially_swappable_8
`anonymous namespace'::__std_find_trivial_impl<`anonymous namespace'::_Find_traits_4,unsigned int> [AVX, AVX2]
`anonymous namespace'::__std_find_trivial_impl<`anonymous namespace'::_Find_traits_8,unsigned __int64> [AVX, AVX2]
`anonymous namespace'::__std_minmax_impl<3,`anonymous namespace'::_Minmax_traits_8_avx,1> [AVX, AVX2]
`anonymous namespace'::__std_minmax_disp<1,`anonymous namespace'::_Minmax_traits_8,0> [AVX512F, AVX512VL]
`anonymous namespace'::__std_minmax_impl<1,`anonymous namespace'::_Minmax_traits_8_avx,0> [AVX, AVX2, AVX512F, AVX512VL]


# ----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion src/bake/BakeGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ const JSC::GlobalObjectMethodTable& GlobalObject::globalObjectMethodTable()
INHERIT_HOOK_METHOD(supportsRichSourceInfo),
INHERIT_HOOK_METHOD(shouldInterruptScript),
INHERIT_HOOK_METHOD(javaScriptRuntimeFlags),
INHERIT_HOOK_METHOD(queueMicrotaskToEventLoop),
INHERIT_HOOK_METHOD(shouldInterruptScriptBeforeTimeout),
bakeModuleLoaderImportModule,
bakeModuleLoaderResolve,
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/bindings/BunAnalyzeTranspiledModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ extern "C" EncodedJSValue Bun__analyzeTranspiledModule(JSGlobalObject* globalObj
#if BUN_DEBUG
RELEASE_AND_RETURN(scope, fallbackParse(globalObject, moduleKey, sourceCode, promise, moduleRecord));
#else
promise->resolve(globalObject, moduleRecord);
promise->resolve(globalObject, vm, moduleRecord);
RELEASE_AND_RETURN(scope, JSValue::encode(promise));
#endif
}
Expand Down Expand Up @@ -219,7 +219,7 @@ static EncodedJSValue fallbackParse(JSGlobalObject* globalObject, const Identifi
}

scope.release();
promise->resolve(globalObject, resultValue == nullptr ? moduleRecord : resultValue);
promise->resolve(globalObject, vm, resultValue == nullptr ? moduleRecord : resultValue);
return JSValue::encode(promise);
}

Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/bindings/BunGCOutputConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*
* How does it work?
* -----------------
* 1. During GC, objects are marked through their visitChildren/visitAdditionalChildren methods
* 1. During GC, objects are marked through their visitChildren/visitAdditionalChildrenInGCThread methods
* 2. JavaScript execution resumes (mutator runs)
* 3. New references may be created or changed during JS execution
* 4. DOMGCOutputConstraint runs and calls visitOutputConstraints on relevant objects
Expand All @@ -66,7 +66,7 @@
* Relevant WebKit files for reference:
* ------------------------------------
* - Source/WebCore/bindings/js/DOMGCOutputConstraint.cpp (original implementation)
* - Source/WebCore/bindings/js/JSEventTargetCustom.cpp (visitAdditionalChildren example)
* - Source/WebCore/bindings/js/JSEventTargetCustom.cpp (visitAdditionalChildrenInGCThread example)
* - Source/WebCore/bindings/js/JSDocumentCustom.cpp (complex marking example)
* - Source/WebCore/bindings/js/JSMessagePortCustom.cpp (cross-context references)
* - Source/WebCore/dom/EventTarget.idl (JSCustomMarkFunction attribute)
Expand Down
10 changes: 5 additions & 5 deletions src/bun.js/bindings/JSBundlerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class JSBundlerPlugin final : public JSC::JSDestructibleObject {
DECLARE_VISIT_CHILDREN;
DECLARE_VISIT_OUTPUT_CONSTRAINTS;

template<typename Visitor> void visitAdditionalChildren(Visitor&);
template<typename Visitor> void visitAdditionalChildrenInGCThread(Visitor&);

Bun::BundlerPlugin plugin;
/// These are defined in BundlerPlugin.ts
Expand Down Expand Up @@ -188,7 +188,7 @@ class JSBundlerPlugin final : public JSC::JSDestructibleObject {
};

template<typename Visitor>
void JSBundlerPlugin::visitAdditionalChildren(Visitor& visitor)
void JSBundlerPlugin::visitAdditionalChildrenInGCThread(Visitor& visitor)
{
this->onLoadFunction.visit(visitor);
this->onResolveFunction.visit(visitor);
Expand All @@ -202,7 +202,7 @@ void JSBundlerPlugin::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSBundlerPlugin* thisObject = jsCast<JSBundlerPlugin*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
thisObject->visitAdditionalChildren(visitor);
thisObject->visitAdditionalChildrenInGCThread(visitor);
}
DEFINE_VISIT_CHILDREN(JSBundlerPlugin);

Expand All @@ -211,7 +211,7 @@ void JSBundlerPlugin::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSBundlerPlugin* thisObject = jsCast<JSBundlerPlugin*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
thisObject->visitAdditionalChildren(visitor);
thisObject->visitAdditionalChildrenInGCThread(visitor);
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSBundlerPlugin);

Expand Down Expand Up @@ -676,7 +676,7 @@ extern "C" void JSBundlerPlugin__drainDeferred(Bun::JSBundlerPlugin* pluginObjec
if (rejected) {
promise->reject(vm, globalObject, JSC::jsUndefined());
} else {
promise->resolve(globalObject, JSC::jsUndefined());
promise->resolve(globalObject, vm, JSC::jsUndefined());
}
RETURN_IF_EXCEPTION(scope, );
}
Expand Down
10 changes: 5 additions & 5 deletions src/bun.js/bindings/JSMockFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class JSMockFunction : public JSC::InternalFunction {
DECLARE_INFO;

DECLARE_VISIT_CHILDREN;
template<typename Visitor> void visitAdditionalChildren(Visitor&);
template<typename Visitor> void visitAdditionalChildrenInGCThread(Visitor&);
DECLARE_VISIT_OUTPUT_CONSTRAINTS;

JSC::LazyProperty<JSMockFunction, JSObject> mock;
Expand Down Expand Up @@ -469,7 +469,7 @@ class JSMockFunction : public JSC::InternalFunction {
};

template<typename Visitor>
void JSMockFunction::visitAdditionalChildren(Visitor& visitor)
void JSMockFunction::visitAdditionalChildrenInGCThread(Visitor& visitor)
{
JSMockFunction* fn = this;
ASSERT_GC_OBJECT_INHERITS(fn, info());
Expand All @@ -492,19 +492,19 @@ void JSMockFunction::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSMockFunction* fn = jsCast<JSMockFunction*>(cell);
ASSERT_GC_OBJECT_INHERITS(fn, info());
Base::visitChildren(fn, visitor);
fn->visitAdditionalChildren<Visitor>(visitor);
fn->visitAdditionalChildrenInGCThread<Visitor>(visitor);
}

template<typename Visitor>
void JSMockFunction::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSMockFunction* thisObject = jsCast<JSMockFunction*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
thisObject->visitAdditionalChildren<Visitor>(visitor);
thisObject->visitAdditionalChildrenInGCThread<Visitor>(visitor);
}

DEFINE_VISIT_CHILDREN(JSMockFunction);
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSMockFunction);
DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSMockFunction);
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSMockFunction);

static void pushImpl(JSMockFunction* fn, JSGlobalObject* jsGlobalObject, JSMockImplementation::Kind kind, JSValue value)
Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/bindings/JSSecrets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ void Bun__SecretsJobOptions__runFromJS(SecretsJobOptions* opts, JSGlobalObject*
if (opts->error.type == Secrets::ErrorType::NotFound) {
if (opts->op == SecretsJobOptions::GET) {
// For GET operations, NotFound resolves with null
RELEASE_AND_RETURN(scope, promise->resolve(global, jsNull()));
RELEASE_AND_RETURN(scope, promise->resolve(global, vm, jsNull()));
} else if (opts->op == SecretsJobOptions::DELETE_OP) {
// For DELETE_OP operations, NotFound means we return false
RELEASE_AND_RETURN(scope, promise->resolve(global, jsBoolean(false)));
RELEASE_AND_RETURN(scope, promise->resolve(global, vm, jsBoolean(false)));
}
}
JSValue error = opts->error.toJS(vm, global);
Comment on lines 273 to 282

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟣 Pre-existing bug: Bun.secrets.delete(service, name) fails silently when called with two positional string arguments because case DELETE_OP: falls through to case SET: which requires 3 positional args instead of 2. This is a pre-existing issue unrelated to this PR's WebKit upgrade changes.

Extended reasoning...

What the bug is

In SecretsJobOptions::fromJS() (JSSecrets.cpp), the case DELETE_OP: label has no body and falls through to case SET:. The shared positional-argument path inside that combined block checks args.size() > 2, requiring three string arguments (service, name, value). But DELETE_OP only needs two arguments (service + name) — there is no value to delete. So any call like Bun.secrets.delete("myService", "myKey") with two positional strings skips the fast path entirely and falls into fromOptionsObject(), which throws "Expected options to be an object" because the second argument is a string, not an options object.

The specific code path

0 ""

0 ""

0 ""

1 "/usr/include/stdc-predef.h" 1 3 4

0 "" 2

1 ""

By contrast, case GET: correctly uses args.size() > 1 in its own branch, requiring only 2 string args.

Why existing code does not prevent it

The fall-through is intentional for the options-object form (both SET and DELETE can accept {service, name, value} / {service, name} objects), but the positional-argument guard was written with only SET in mind (which genuinely needs 3 args: service, name, value). Nobody added a separate positional check for DELETE_OP that needs only 2.

Impact

Any caller using the convenient Bun.secrets.delete('service', 'name') positional form receives a runtime error instead of a successful deletion. The options-object form Bun.secrets.delete({ service: 'x', name: 'y' }) works correctly. This is a silent behavioral regression for users who follow the documented positional API.

Step-by-step proof

  1. User calls: await Bun.secrets.delete('com.example', 'API_KEY')
  2. JS glue marshals this as callWithThisValueAndArguments -> fromJS(globalObject, args) where args = ['com.example', 'API_KEY'], args.size() == 2, op == DELETE_OP
  3. Switch hits case DELETE_OP: — no body — falls to case SET:
  4. Guard args.size() > 2 -> 2 > 2 -> false — positional path skipped
  5. fromOptionsObject() is called; it looks at args.at(0) expecting an object, finds a string -> throws "Expected options to be an object"
  6. Promise rejects with that error instead of deleting the secret

How to fix it

Give DELETE_OP its own case block before SET:, mirroring the GET: pattern but checking args.size() > 1:

0 ""

0 ""

0 ""

1 "/usr/include/stdc-predef.h" 1 3 4

0 "" 2

1 ""

Pre-existing classification

This PR's only change to JSSecrets.cpp is updating promise->resolve(global, value) to promise->resolve(global, vm, value) to match the new WebKit JSPromise API. The argument-parsing logic in fromJS() was not touched by this PR.

Expand Down Expand Up @@ -306,7 +306,7 @@ void Bun__SecretsJobOptions__runFromJS(SecretsJobOptions* opts, JSGlobalObject*
break;
}
RETURN_IF_EXCEPTION(scope, );
RELEASE_AND_RETURN(scope, promise->resolve(global, result));
RELEASE_AND_RETURN(scope, promise->resolve(global, vm, result));
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/bindings/ModuleLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ extern "C" void Bun__onFulfillAsyncModule(
EXCEPTION_ASSERT(created.has_value() == !scope.exception());
if (created.has_value()) {
JSSourceCode* code = JSSourceCode::create(vm, WTF::move(created.value()));
promise->resolve(globalObject, code);
promise->resolve(globalObject, vm, code);
scope.assertNoExceptionExceptTermination();
} else {
auto* exception = scope.exception();
Expand All @@ -511,7 +511,7 @@ extern "C" void Bun__onFulfillAsyncModule(
}
} else {
auto&& provider = Zig::SourceProvider::create(jsDynamicCast<Zig::GlobalObject*>(globalObject), res->result.value);
promise->resolve(globalObject, JSC::JSSourceCode::create(vm, JSC::SourceCode(provider)));
promise->resolve(globalObject, vm, JSC::JSSourceCode::create(vm, JSC::SourceCode(provider)));
scope.assertNoExceptionExceptTermination();
}
} else {
Expand Down Expand Up @@ -1163,7 +1163,7 @@ BUN_DEFINE_HOST_FUNCTION(jsFunctionOnLoadObjectResultResolve, (JSC::JSGlobalObje
return retValue;
}
scope.release();
promise->resolve(globalObject, result);
promise->resolve(globalObject, vm, result);
pendingModule->internalField(2).set(vm, pendingModule, JSC::jsUndefined());
return JSValue::encode(jsUndefined());
}
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/bindings/NodeTimerObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static bool call(JSGlobalObject* globalObject, JSValue timerObject, JSValue call

if (auto* promise = jsDynamicCast<JSPromise*>(callbackValue)) {
// This was a Bun.sleep() call
promise->resolve(globalObject, jsUndefined());
promise->resolve(globalObject, vm, jsUndefined());
} else {
auto callData = JSC::getCallData(callbackValue);
if (callData.type == CallData::Type::None) {
Expand Down
1 change: 0 additions & 1 deletion src/bun.js/bindings/NodeVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,6 @@ const JSC::GlobalObjectMethodTable& NodeVMGlobalObject::globalObjectMethodTable(
&supportsRichSourceInfo,
&shouldInterruptScript,
&javaScriptRuntimeFlags,
nullptr, // queueTaskToEventLoop
nullptr, // shouldInterruptScriptBeforeTimeout,
&moduleLoaderImportModule,
nullptr, // moduleLoaderResolve
Expand Down
23 changes: 8 additions & 15 deletions src/bun.js/bindings/ZigGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,18 +730,12 @@ JSC::ScriptExecutionStatus Zig::GlobalObject::scriptExecutionStatus(JSC::JSGloba

void unsafeEvalNoop(JSGlobalObject*, const WTF::String&) {}

static void queueMicrotaskToEventLoop(JSGlobalObject& globalObject, QueuedTask&& task)
{
globalObject.vm().queueMicrotask(WTF::move(task));
}

const JSC::GlobalObjectMethodTable& GlobalObject::globalObjectMethodTable()
{
static const JSC::GlobalObjectMethodTable table = {
&supportsRichSourceInfo,
&shouldInterruptScript,
&javaScriptRuntimeFlags,
&queueMicrotaskToEventLoop,
nullptr, // &shouldInterruptScriptBeforeTimeout,
&moduleLoaderImportModule, // moduleLoaderImportModule
&moduleLoaderResolve, // moduleLoaderResolve
Expand Down Expand Up @@ -770,7 +764,6 @@ const JSC::GlobalObjectMethodTable& EvalGlobalObject::globalObjectMethodTable()
&supportsRichSourceInfo,
&shouldInterruptScript,
&javaScriptRuntimeFlags,
&queueMicrotaskToEventLoop,
nullptr, // &shouldInterruptScriptBeforeTimeout,
&moduleLoaderImportModule, // moduleLoaderImportModule
&moduleLoaderResolve, // moduleLoaderResolve
Expand Down Expand Up @@ -2713,7 +2706,7 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
GlobalPropertyInfo(builtinNames.makeAbortErrorPrivateName(), JSFunction::create(vm, this, 1, String(), jsFunctionMakeAbortError, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
GlobalPropertyInfo(builtinNames.checkBufferReadPrivateName(), JSFunction::create(vm, this, 1, String(), jsFunctionCheckBufferRead, ImplementationVisibility::Public), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
};
addStaticGlobals(staticGlobals, std::size(staticGlobals));
addStaticGlobals(staticGlobals);

// TODO: most/all of these private properties can be made as static globals.
// i've noticed doing it as is will work somewhat but getDirect() wont be able to find them
Expand Down Expand Up @@ -2929,7 +2922,7 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
WebCore::clientData(thisObject->vm())->httpHeaderIdentifiers().visit<Visitor>(visitor);

thisObject->visitGeneratedLazyClasses<Visitor>(thisObject, visitor);
thisObject->visitAdditionalChildren<Visitor>(visitor);
thisObject->visitAdditionalChildrenInGCThread<Visitor>(visitor);
}

extern "C" bool JSGlobalObject__setTimeZone(JSC::JSGlobalObject* globalObject, const ZigString* timeZone)
Expand Down Expand Up @@ -3013,7 +3006,7 @@ void GlobalObject::handleRejectedPromises()
DEFINE_VISIT_CHILDREN(GlobalObject);

template<typename Visitor>
void GlobalObject::visitAdditionalChildren(Visitor& visitor)
void GlobalObject::visitAdditionalChildrenInGCThread(Visitor& visitor)
{
GlobalObject* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Expand All @@ -3026,15 +3019,15 @@ void GlobalObject::visitAdditionalChildren(Visitor& visitor)
visitor.addOpaqueRoot(context);
}

DEFINE_VISIT_ADDITIONAL_CHILDREN(GlobalObject);
DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(GlobalObject);

template<typename Visitor>
void GlobalObject::visitOutputConstraints(JSCell* cell, Visitor& visitor)
{
auto* thisObject = jsCast<GlobalObject*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitOutputConstraints(thisObject, visitor);
thisObject->visitAdditionalChildren(visitor);
thisObject->visitAdditionalChildrenInGCThread(visitor);
}

template void GlobalObject::visitOutputConstraints(JSCell*, AbstractSlotVisitor&);
Expand Down Expand Up @@ -3436,7 +3429,7 @@ static JSC::JSPromise* handleResponseOnStreamingAction(JSGlobalObject* lexicalGl

auto promise = JSC::JSPromise::create(vm, globalObject->promiseStructure());
auto sourceCode = makeSource("[wasm code]"_s, SourceOrigin(), SourceTaintedOrigin::Untainted);
auto compiler = JSC::Wasm::StreamingCompiler::create(vm, mode, globalObject, promise, importObject, sourceCode);
auto compiler = JSC::Wasm::StreamingCompiler::create(vm, mode, globalObject, promise, importObject, std::nullopt, sourceCode);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

// getBodyStreamOrBytesForWasmStreaming throws the proper exception. Since this is being
// executed in a .then(...) callback, throwing is perfectly fine.
Expand Down Expand Up @@ -3466,12 +3459,12 @@ static JSC::JSPromise* handleResponseOnStreamingAction(JSGlobalObject* lexicalGl
return promise;
}

JSC::JSPromise* GlobalObject::compileStreaming(JSGlobalObject* globalObject, JSC::JSValue source)
JSC::JSPromise* GlobalObject::compileStreaming(JSGlobalObject* globalObject, JSC::JSValue source, std::optional<JSC::WebAssemblyCompileOptions>&&)
{
return handleResponseOnStreamingAction(globalObject, source, JSC::Wasm::CompilerMode::Validation, nullptr);
}

JSC::JSPromise* GlobalObject::instantiateStreaming(JSGlobalObject* globalObject, JSC::JSValue source, JSC::JSObject* importObject)
JSC::JSPromise* GlobalObject::instantiateStreaming(JSGlobalObject* globalObject, JSC::JSValue source, JSC::JSObject* importObject, std::optional<JSC::WebAssemblyCompileOptions>&&)
{
return handleResponseOnStreamingAction(globalObject, source, JSC::Wasm::CompilerMode::FullCompile, importObject);
}
Comment thread
claude[bot] marked this conversation as resolved.
Resolved
Expand Down
7 changes: 4 additions & 3 deletions src/bun.js/bindings/ZigGlobalObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace JSC {
class Structure;
class Identifier;
class LazyClassStructure;
class WebAssemblyCompileOptions;
enum class JSPromiseRejectionOperation : unsigned;
} // namespace JSC

Expand Down Expand Up @@ -166,7 +167,7 @@ class GlobalObject : public Bun::GlobalScope {
WebCore::DOMWrapperWorld& world() { return m_world.get(); }

DECLARE_VISIT_CHILDREN;
template<typename Visitor> void visitAdditionalChildren(Visitor&);
template<typename Visitor> void visitAdditionalChildrenInGCThread(Visitor&);
template<typename Visitor> static void visitOutputConstraints(JSCell*, Visitor&);

bool worldIsNormal() const { return m_worldIsNormal; }
Expand Down Expand Up @@ -197,8 +198,8 @@ class GlobalObject : public Bun::GlobalScope {
static JSC::JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue key, JSC::JSValue parameters, JSC::JSValue script);
static JSC::JSObject* moduleLoaderCreateImportMetaProperties(JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue key, JSC::JSModuleRecord*, JSC::JSValue val);
static JSC::JSValue moduleLoaderEvaluate(JSGlobalObject*, JSC::JSModuleLoader*, JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher, JSValue sentValue, JSValue resumeMode);
static JSC::JSPromise* compileStreaming(JSGlobalObject*, JSC::JSValue source);
static JSC::JSPromise* instantiateStreaming(JSGlobalObject*, JSC::JSValue source, JSC::JSObject* importObject);
static JSC::JSPromise* compileStreaming(JSGlobalObject*, JSC::JSValue source, std::optional<JSC::WebAssemblyCompileOptions>&&);
static JSC::JSPromise* instantiateStreaming(JSGlobalObject*, JSC::JSValue source, JSC::JSObject* importObject, std::optional<JSC::WebAssemblyCompileOptions>&&);

static ScriptExecutionStatus scriptExecutionStatus(JSGlobalObject*, JSObject*);
static void promiseRejectionTracker(JSGlobalObject*, JSC::JSPromise*, JSC::JSPromiseRejectionOperation);
Expand Down
8 changes: 4 additions & 4 deletions src/bun.js/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3424,12 +3424,12 @@ void JSC__AnyPromise__wrap(JSC::JSGlobalObject* globalObject, EncodedJSValue enc
}

if (auto* promise = jsDynamicCast<JSC::JSPromise*>(promiseValue)) {
promise->resolve(globalObject, result);
promise->resolve(globalObject, vm, result);
RETURN_IF_EXCEPTION(scope, );
return;
}
if (auto* promise = jsDynamicCast<JSC::JSInternalPromise*>(promiseValue)) {
promise->resolve(globalObject, result);
promise->resolve(globalObject, vm, result);
RETURN_IF_EXCEPTION(scope, );
return;
}
Expand Down Expand Up @@ -3509,7 +3509,7 @@ JSC::JSPromise* JSC__JSPromise__rejectedPromise(JSC::JSGlobalObject* arg0, JSC::
ASSERT_WITH_MESSAGE(arg0 != target, "Promise cannot be resolved to itself");

// Note: the Promise can be another promise. Since we go through the generic promise resolve codepath.
arg0->resolve(arg1, JSC::JSValue::decode(JSValue2));
arg0->resolve(arg1, arg1->vm(), JSC::JSValue::decode(JSValue2));
}

// This implementation closely mimics the one in JSC::JSPromise::resolve
Expand Down Expand Up @@ -3671,7 +3671,7 @@ JSC::JSInternalPromise* JSC__JSInternalPromise__rejectedPromise(JSC::JSGlobalObj
[[ZIG_EXPORT(check_slow)]]
void JSC__JSInternalPromise__resolve(JSC::JSInternalPromise* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2)
{
arg0->resolve(arg1, JSC::JSValue::decode(JSValue2));
arg0->resolve(arg1, arg1->vm(), JSC::JSValue::decode(JSValue2));
}

JSC::JSInternalPromise* JSC__JSInternalPromise__resolvedPromise(JSC::JSGlobalObject* arg0,
Expand Down
Loading
Loading