From be1631d28be840f030dca0a0ad4855314bbd8d43 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 19 Dec 2024 05:07:18 -0800 Subject: [PATCH] Fix more errors --- .../BunReadableStreamDefaultController.cpp | 17 ++++++++++++++--- .../BunReadableStreamDefaultController.h | 11 ++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/bun.js/bindings/BunReadableStreamDefaultController.cpp b/src/bun.js/bindings/BunReadableStreamDefaultController.cpp index 81d0754b5f..8ecfd52a13 100644 --- a/src/bun.js/bindings/BunReadableStreamDefaultController.cpp +++ b/src/bun.js/bindings/BunReadableStreamDefaultController.cpp @@ -10,7 +10,12 @@ #include "BunReadableStreamDefaultReader.h" #include "DOMIsoSubspaces.h" #include "BunClientData.h" +#include "BunStreamStructures.h" +#include "DOMClientIsoSubspaces.h" +#include +#include +#include "BunStreamInlines.h" namespace Bun { using namespace JSC; @@ -167,7 +172,7 @@ private: } }; -JSReadableStreamDefaultController* JSReadableStreamDefaultController::create(VM& vm, Structure* structure, JSReadableStream* stream) +JSReadableStreamDefaultController* JSReadableStreamDefaultController::create(VM& vm, JSGlobalObject* globalObject, Structure* structure, JSReadableStream* stream) { JSReadableStreamDefaultController* controller = new (NotNull, JSC::allocateCell(vm)) JSReadableStreamDefaultController(vm, structure); controller->finishCreation(vm, stream); @@ -241,7 +246,7 @@ JSValue JSReadableStreamDefaultController::enqueue(JSGlobalObject* globalObject, } // Enqueue the chunk - JSArray* queue = m_queue.get(this); + JSArray* queue = m_queue.getInitializedOnMainThread(globalObject); scope.release(); queue->push(globalObject, chunk); @@ -369,7 +374,7 @@ void JSReadableStreamDefaultController::callPullIfNeeded(JSGlobalObject* globalO // Handle the promise returned by pull if (JSPromise* promise = jsDynamicCast(result)) { - Bun::performPromiseThen(globalObject, promise, jsReadableStreamDefaultControllerFullfillPull, jsReadableStreamDefaultControllerRejectPull, this); + Bun::then(globalObject, promise, jsReadableStreamDefaultControllerFullfillPull, jsReadableStreamDefaultControllerRejectPull, this); } else { // Not a promise, just mark pulling as done m_pulling = false; @@ -405,6 +410,12 @@ bool JSReadableStreamDefaultController::shouldCallPull() const return true; } +void JSReadableStreamDefaultController::finishCreation(VM& vm, JSReadableStream* stream) +{ + Base::finishCreation(vm); + m_stream.set(vm, this, stream); +} + const ClassInfo JSReadableStreamDefaultControllerConstructor::s_info = { "ReadableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultControllerConstructor) }; const ClassInfo JSReadableStreamDefaultControllerPrototype::s_info = { "ReadableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultControllerPrototype) }; const ClassInfo JSReadableStreamDefaultController::s_info = { "ReadableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultController) }; diff --git a/src/bun.js/bindings/BunReadableStreamDefaultController.h b/src/bun.js/bindings/BunReadableStreamDefaultController.h index 185f0f5072..c52fa8ea9d 100644 --- a/src/bun.js/bindings/BunReadableStreamDefaultController.h +++ b/src/bun.js/bindings/BunReadableStreamDefaultController.h @@ -15,12 +15,17 @@ public: using Base = JSC::JSDestructibleObject; static constexpr bool needsDestruction = true; - static JSReadableStreamDefaultController* create(JSC::VM&, JSC::JSGlobalObject*, JSC::Structure*); + static JSReadableStreamDefaultController* create(JSC::VM&, JSC::JSGlobalObject*, JSC::Structure*, JSReadableStream*); static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); } + static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject*); + + template + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm); + DECLARE_INFO; void attach(JSReadableStream* stream); @@ -58,11 +63,11 @@ public: private: JSReadableStreamDefaultController(JSC::VM&, JSC::Structure*); ~JSReadableStreamDefaultController(); - void finishCreation(JSC::VM&); + void finishCreation(JSC::VM&, JSReadableStream*); // Internal slots JSC::WriteBarrier m_stream; - JSC::WriteBarrier m_queue; + JSC::LazyProperty m_queue; JSC::WriteBarrier m_pullAlgorithm; JSC::WriteBarrier m_cancelAlgorithm; JSC::WriteBarrier m_strategySizeAlgorithm;