Add a debug assertion

This commit is contained in:
Jarred Sumner
2024-05-16 20:35:57 -07:00
parent 5caca9cd48
commit ffeaa77370

View File

@@ -2213,6 +2213,11 @@ extern "C" JSC__JSValue JSObjectCallAsFunctionReturnValue(JSContextRef ctx, JSC_
JSC::JSGlobalObject* globalObject = toJS(ctx);
JSC::VM& vm = globalObject->vm();
#if BUN_DEBUG
// This is a redundant check, but we add it to make the error message clearer.
ASSERT_WITH_MESSAGE(!vm.isCollectorBusyOnCurrentThread(), "Cannot call function inside a finalizer or while GC is running on same thread.");
#endif
if (UNLIKELY(!object))
return JSC::JSValue::encode(JSC::JSValue());
@@ -2263,6 +2268,11 @@ JSC__JSValue JSObjectCallAsFunctionReturnValueHoldingAPILock(JSContextRef ctx, J
JSC::JSLockHolder lock(vm);
#if BUN_DEBUG
// This is a redundant check, but we add it to make the error message clearer.
ASSERT_WITH_MESSAGE(!vm.isCollectorBusyOnCurrentThread(), "Cannot call function inside a finalizer or while GC is running on same thread.");
#endif
if (!object)
return JSC::JSValue::encode(JSC::JSValue());