aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-04 16:38:45 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-04 16:38:45 -0700
commit48f64bc6e5fade5410413d31d0f17e9802a3917b (patch)
tree94c00737824119970f741eda92c96f71a16f9232
parent667303fc861afaa33ceb273a1e1652c7cd706879 (diff)
downloadbun-48f64bc6e5fade5410413d31d0f17e9802a3917b.tar.gz
bun-48f64bc6e5fade5410413d31d0f17e9802a3917b.tar.zst
bun-48f64bc6e5fade5410413d31d0f17e9802a3917b.zip
[itnernal] Cleanup some of the streams code
-rw-r--r--src/bun.js/bindings/JSSink.cpp515
-rw-r--r--src/bun.js/bindings/JSSink.h863
-rw-r--r--src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp71
-rw-r--r--src/bun.js/builtins/js/ReadableStreamInternals.js72
-rw-r--r--src/bun.js/generate-jssink.js30
-rw-r--r--src/bun.js/webcore/streams.zig1
-rw-r--r--test/bun.js/react-dom.test.tsx86
7 files changed, 846 insertions, 792 deletions
diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp
index 21b807c7f..84cb0bf1f 100644
--- a/src/bun.js/bindings/JSSink.cpp
+++ b/src/bun.js/bindings/JSSink.cpp
@@ -1,6 +1,6 @@
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at 2022-07-02T06:06:00.513Z
+// Generated by 'make generate-sink' at 2022-07-02T10:45:03.309Z
// To regenerate this file, run:
//
// make generate-sink
@@ -54,18 +54,12 @@
#include "JavaScriptCore/Weak.h"
#include "JavaScriptCore/WeakInlines.h"
-
-
namespace WebCore {
using namespace JSC;
-
-
-
-
-JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
-
+
auto& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
@@ -86,12 +80,10 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic
onClose = JSC::jsUndefined();
}
- JSC::JSFunction *onPullFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onPull);
- JSC::JSFunction *onCloseFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onClose);
+ JSC::JSFunction* onPullFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onPull);
+ JSC::JSFunction* onCloseFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onClose);
-
-
- if (WebCore::JSReadableArrayBufferSinkController* ArrayBufferSinkController = JSC::jsDynamicCast<WebCore::JSReadableArrayBufferSinkController*>(callFrame->thisValue())) {
+ if (WebCore::JSReadableArrayBufferSinkController* ArrayBufferSinkController = JSC::jsDynamicCast<WebCore::JSReadableArrayBufferSinkController*>(callFrame->thisValue())) {
if (ArrayBufferSinkController->wrapped() == nullptr) {
scope.throwException(globalObject, JSC::createTypeError(globalObject, "Cannot start stream with closed controller"_s));
return JSC::JSValue::encode(JSC::jsUndefined());
@@ -100,7 +92,6 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic
ArrayBufferSinkController->start(globalObject, readableStream, onPullFunction, onCloseFunction);
}
-
else if (WebCore::JSReadableHTTPResponseSinkController* HTTPResponseSinkController = JSC::jsDynamicCast<WebCore::JSReadableHTTPResponseSinkController*>(callFrame->thisValue())) {
if (HTTPResponseSinkController->wrapped() == nullptr) {
scope.throwException(globalObject, JSC::createTypeError(globalObject, "Cannot start stream with closed controller"_s));
@@ -110,7 +101,6 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic
HTTPResponseSinkController->start(globalObject, readableStream, onPullFunction, onCloseFunction);
}
-
else if (WebCore::JSReadableHTTPSResponseSinkController* HTTPSResponseSinkController = JSC::jsDynamicCast<WebCore::JSReadableHTTPSResponseSinkController*>(callFrame->thisValue())) {
if (HTTPSResponseSinkController->wrapped() == nullptr) {
scope.throwException(globalObject, JSC::createTypeError(globalObject, "Cannot start stream with closed controller"_s));
@@ -136,11 +126,10 @@ JSC_DEFINE_CUSTOM_GETTER(functionArrayBufferSink__getter, (JSC::JSGlobalObject *
return JSC::JSValue::encode(globalObject->ArrayBufferSink());
}
-
JSC_DECLARE_HOST_FUNCTION(JSReadableArrayBufferSinkController__close);
-JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
-
+
auto& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
@@ -150,7 +139,7 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__close, (JSC::JSGlo
return JSC::JSValue::encode(JSC::jsUndefined());
}
- void *ptr = controller->wrapped();
+ void* ptr = controller->wrapped();
if (ptr == nullptr) {
return JSC::JSValue::encode(JSC::jsUndefined());
}
@@ -161,9 +150,9 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__close, (JSC::JSGlo
}
JSC_DECLARE_HOST_FUNCTION(JSReadableArrayBufferSinkController__end);
-JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
-
+
auto& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
@@ -173,7 +162,7 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__end, (JSC::JSGloba
return JSC::JSValue::encode(JSC::jsUndefined());
}
- void *ptr = controller->wrapped();
+ void* ptr = controller->wrapped();
if (ptr == nullptr) {
return JSC::JSValue::encode(JSC::jsUndefined());
}
@@ -182,11 +171,10 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableArrayBufferSinkController__end, (JSC::JSGloba
return ArrayBufferSink__endWithSink(ptr, lexicalGlobalObject);
}
-
JSC_DECLARE_HOST_FUNCTION(ArrayBufferSink__doClose);
-JSC_DEFINE_HOST_FUNCTION(ArrayBufferSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+JSC_DEFINE_HOST_FUNCTION(ArrayBufferSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
-
+
auto& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
@@ -196,7 +184,7 @@ JSC_DEFINE_HOST_FUNCTION(ArrayBufferSink__doClose, (JSC::JSGlobalObject * lexica
return JSC::JSValue::encode(JSC::jsUndefined());
}
- void *ptr = sink->wrapped();
+ void* ptr = sink->wrapped();
if (ptr == nullptr) {
return JSC::JSValue::encode(JSC::jsUndefined());
}
@@ -206,8 +194,6 @@ JSC_DEFINE_HOST_FUNCTION(ArrayBufferSink__doClose, (JSC::JSGlobalObject * lexica
return JSC::JSValue::encode(JSC::jsUndefined());
}
-
-
JSC_DEFINE_CUSTOM_GETTER(functionHTTPResponseSink__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName))
{
auto& vm = lexicalGlobalObject->vm();
@@ -216,11 +202,10 @@ JSC_DEFINE_CUSTOM_GETTER(functionHTTPResponseSink__getter, (JSC::JSGlobalObject
return JSC::JSValue::encode(globalObject->HTTPResponseSink());
}
-
JSC_DECLARE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__close);
-JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
-
+
auto& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
@@ -230,7 +215,7 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__close, (JSC::JSGl
return JSC::JSValue::encode(JSC::jsUndefined());
}
- void *ptr = controller->wrapped();
+ void* ptr = controller->wrapped();
if (ptr == nullptr) {
return JSC::JSValue::encode(JSC::jsUndefined());
}
@@ -241,9 +226,9 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__close, (JSC::JSGl
}
JSC_DECLARE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__end);
-JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
-
+
auto& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
@@ -253,7 +238,7 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__end, (JSC::JSGlob
return JSC::JSValue::encode(JSC::jsUndefined());
}
- void *ptr = controller->wrapped();
+ void* ptr = controller->wrapped();
if (ptr == nullptr) {
return JSC::JSValue::encode(JSC::jsUndefined());
}
@@ -262,11 +247,10 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPResponseSinkController__end, (JSC::JSGlob
return HTTPResponseSink__endWithSink(ptr, lexicalGlobalObject);
}
-
JSC_DECLARE_HOST_FUNCTION(HTTPResponseSink__doClose);
-JSC_DEFINE_HOST_FUNCTION(HTTPResponseSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+JSC_DEFINE_HOST_FUNCTION(HTTPResponseSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
-
+
auto& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
@@ -276,7 +260,7 @@ JSC_DEFINE_HOST_FUNCTION(HTTPResponseSink__doClose, (JSC::JSGlobalObject * lexic
return JSC::JSValue::encode(JSC::jsUndefined());
}
- void *ptr = sink->wrapped();
+ void* ptr = sink->wrapped();
if (ptr == nullptr) {
return JSC::JSValue::encode(JSC::jsUndefined());
}
@@ -286,8 +270,6 @@ JSC_DEFINE_HOST_FUNCTION(HTTPResponseSink__doClose, (JSC::JSGlobalObject * lexic
return JSC::JSValue::encode(JSC::jsUndefined());
}
-
-
JSC_DEFINE_CUSTOM_GETTER(functionHTTPSResponseSink__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName))
{
auto& vm = lexicalGlobalObject->vm();
@@ -296,11 +278,10 @@ JSC_DEFINE_CUSTOM_GETTER(functionHTTPSResponseSink__getter, (JSC::JSGlobalObject
return JSC::JSValue::encode(globalObject->HTTPSResponseSink());
}
-
JSC_DECLARE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__close);
-JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__close, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
-
+
auto& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
@@ -310,7 +291,7 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__close, (JSC::JSG
return JSC::JSValue::encode(JSC::jsUndefined());
}
- void *ptr = controller->wrapped();
+ void* ptr = controller->wrapped();
if (ptr == nullptr) {
return JSC::JSValue::encode(JSC::jsUndefined());
}
@@ -321,9 +302,9 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__close, (JSC::JSG
}
JSC_DECLARE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__end);
-JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__end, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
-
+
auto& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
@@ -333,7 +314,7 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__end, (JSC::JSGlo
return JSC::JSValue::encode(JSC::jsUndefined());
}
- void *ptr = controller->wrapped();
+ void* ptr = controller->wrapped();
if (ptr == nullptr) {
return JSC::JSValue::encode(JSC::jsUndefined());
}
@@ -342,11 +323,10 @@ JSC_DEFINE_HOST_FUNCTION(JSReadableHTTPSResponseSinkController__end, (JSC::JSGlo
return HTTPSResponseSink__endWithSink(ptr, lexicalGlobalObject);
}
-
JSC_DECLARE_HOST_FUNCTION(HTTPSResponseSink__doClose);
-JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame *callFrame))
+JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
-
+
auto& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
@@ -356,7 +336,7 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi
return JSC::JSValue::encode(JSC::jsUndefined());
}
- void *ptr = sink->wrapped();
+ void* ptr = sink->wrapped();
if (ptr == nullptr) {
return JSC::JSValue::encode(JSC::jsUndefined());
}
@@ -366,10 +346,8 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi
return JSC::JSValue::encode(JSC::jsUndefined());
}
-
-
#include "JSSinkLookupTable.h"
-
+
/* Source for JSArrayBufferSinkPrototypeTableValues.lut.h
@begin JSArrayBufferSinkPrototypeTable
close ArrayBufferSink__doClose ReadOnly|DontDelete|Function 0
@@ -377,11 +355,10 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi
end ArrayBufferSink__end ReadOnly|DontDelete|Function 0
start ArrayBufferSink__start ReadOnly|DontDelete|Function 1
write ArrayBufferSink__write ReadOnly|DontDelete|Function 1
-
+
@end
*/
-
/* Source for JSReadableArrayBufferSinkControllerPrototypeTableValues.lut.h
@begin JSReadableArrayBufferSinkControllerPrototypeTable
close JSReadableArrayBufferSinkController__close ReadOnly|DontDelete|Function 0
@@ -392,7 +369,6 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi
@end
*/
-
/* Source for JSHTTPResponseSinkPrototypeTableValues.lut.h
@begin JSHTTPResponseSinkPrototypeTable
close HTTPResponseSink__doClose ReadOnly|DontDelete|Function 0
@@ -400,11 +376,10 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi
end HTTPResponseSink__end ReadOnly|DontDelete|Function 0
start HTTPResponseSink__start ReadOnly|DontDelete|Function 1
write HTTPResponseSink__write ReadOnly|DontDelete|Function 1
-
+
@end
*/
-
/* Source for JSReadableHTTPResponseSinkControllerPrototypeTableValues.lut.h
@begin JSReadableHTTPResponseSinkControllerPrototypeTable
close JSReadableHTTPResponseSinkController__close ReadOnly|DontDelete|Function 0
@@ -415,7 +390,6 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi
@end
*/
-
/* Source for JSHTTPSResponseSinkPrototypeTableValues.lut.h
@begin JSHTTPSResponseSinkPrototypeTable
close HTTPSResponseSink__doClose ReadOnly|DontDelete|Function 0
@@ -423,11 +397,10 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi
end HTTPSResponseSink__end ReadOnly|DontDelete|Function 0
start HTTPSResponseSink__start ReadOnly|DontDelete|Function 1
write HTTPSResponseSink__write ReadOnly|DontDelete|Function 1
-
+
@end
*/
-
/* Source for JSReadableHTTPSResponseSinkControllerPrototypeTableValues.lut.h
@begin JSReadableHTTPSResponseSinkControllerPrototypeTable
close JSReadableHTTPSResponseSinkController__close ReadOnly|DontDelete|Function 0
@@ -438,9 +411,6 @@ JSC_DEFINE_HOST_FUNCTION(HTTPSResponseSink__doClose, (JSC::JSGlobalObject * lexi
@end
*/
-
-
-
#pragma mark - ArrayBufferSink
class JSArrayBufferSinkPrototype final : public JSC::JSNonFinalObject {
@@ -476,42 +446,41 @@ private:
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSArrayBufferSinkPrototype, JSArrayBufferSinkPrototype::Base);
class JSReadableArrayBufferSinkControllerPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSReadableArrayBufferSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSReadableArrayBufferSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableArrayBufferSinkControllerPrototype>(vm)) JSReadableArrayBufferSinkControllerPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- 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());
- }
-
- private:
- JSReadableArrayBufferSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
- STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableArrayBufferSinkControllerPrototype, JSReadableArrayBufferSinkControllerPrototype::Base);
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSReadableArrayBufferSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableArrayBufferSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableArrayBufferSinkControllerPrototype>(vm)) JSReadableArrayBufferSinkControllerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ 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());
+ }
+
+private:
+ JSReadableArrayBufferSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableArrayBufferSinkControllerPrototype, JSReadableArrayBufferSinkControllerPrototype::Base);
const ClassInfo JSArrayBufferSinkPrototype::s_info = { "ArrayBufferSink"_s, &Base::s_info, &JSArrayBufferSinkPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSArrayBufferSinkPrototype) };
const ClassInfo JSArrayBufferSink::s_info = { "ArrayBufferSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSArrayBufferSink) };
const ClassInfo JSArrayBufferSinkConstructor::s_info = { "ArrayBufferSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSArrayBufferSinkConstructor) };
-
const ClassInfo JSReadableArrayBufferSinkControllerPrototype::s_info = { "ReadableArrayBufferSinkController"_s, &Base::s_info, &JSReadableArrayBufferSinkControllerPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSReadableArrayBufferSinkControllerPrototype) };
const ClassInfo JSReadableArrayBufferSinkController::s_info = { "ReadableArrayBufferSinkController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableArrayBufferSinkController) };
@@ -522,7 +491,6 @@ JSArrayBufferSink::~JSArrayBufferSink()
}
}
-
JSReadableArrayBufferSinkController::~JSReadableArrayBufferSinkController()
{
if (m_sinkPtr) {
@@ -540,7 +508,26 @@ JSObject* JSReadableArrayBufferSinkController::createPrototype(VM& vm, JSDOMGlob
return JSReadableArrayBufferSinkControllerPrototype::create(vm, &globalObject, JSReadableArrayBufferSinkControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
}
+void JSReadableArrayBufferSinkController::detach()
+{
+ m_sinkPtr = nullptr;
+ m_onPull.clear();
+
+ auto readableStream = m_weakReadableStream.get();
+ auto onClose = m_onClose.get();
+ m_onClose.clear();
+ if (readableStream && onClose) {
+ JSC::JSGlobalObject* globalObject = this->globalObject();
+ auto callData = JSC::getCallData(onClose);
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(readableStream);
+ arguments.append(jsUndefined());
+ JSC::call(globalObject, onClose, callData, JSC::jsUndefined(), arguments);
+ }
+
+ m_weakReadableStream.clear();
+}
JSArrayBufferSinkConstructor* JSArrayBufferSinkConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSObject* prototype)
{
@@ -570,11 +557,11 @@ void JSArrayBufferSinkConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* g
initializeProperties(vm, globalObject, prototype);
}
-JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSArrayBufferSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) {
+JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSArrayBufferSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame)
+{
return ArrayBufferSink__construct(globalObject, callFrame);
}
-
void JSArrayBufferSinkConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSObject* prototype)
{
putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
@@ -611,12 +598,10 @@ void JSReadableArrayBufferSinkController::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
void JSArrayBufferSink::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
{
auto* thisObject = jsCast<JSArrayBufferSink*>(cell);
if (void* wrapped = thisObject->wrapped()) {
- analyzer.setWrappedObjectForCell(cell, wrapped);
// if (thisObject->scriptExecutionContext())
// analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
}
@@ -627,14 +612,12 @@ void JSReadableArrayBufferSinkController::analyzeHeap(JSCell* cell, HeapAnalyzer
{
auto* thisObject = jsCast<JSReadableArrayBufferSinkController*>(cell);
if (void* wrapped = thisObject->wrapped()) {
- analyzer.setWrappedObjectForCell(cell, wrapped);
// if (thisObject->scriptExecutionContext())
// analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
}
Base::analyzeHeap(cell, analyzer);
}
-
template<typename Visitor>
void JSReadableArrayBufferSinkController::visitChildrenImpl(JSCell* cell, Visitor& visitor)
{
@@ -648,8 +631,8 @@ void JSReadableArrayBufferSinkController::visitChildrenImpl(JSCell* cell, Visito
DEFINE_VISIT_CHILDREN(JSReadableArrayBufferSinkController);
-
-void JSReadableArrayBufferSinkController::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose) {
+void JSReadableArrayBufferSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose)
+{
this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject());
this->m_onPull.set(globalObject->vm(), this, onPull);
this->m_onClose.set(globalObject->vm(), this, onClose);
@@ -660,14 +643,11 @@ void JSArrayBufferSink::destroy(JSCell* cell)
static_cast<JSArrayBufferSink*>(cell)->JSArrayBufferSink::~JSArrayBufferSink();
}
-
void JSReadableArrayBufferSinkController::destroy(JSCell* cell)
{
static_cast<JSReadableArrayBufferSinkController*>(cell)->JSReadableArrayBufferSinkController::~JSReadableArrayBufferSinkController();
}
-
-
#pragma mark - HTTPResponseSink
class JSHTTPResponseSinkPrototype final : public JSC::JSNonFinalObject {
@@ -703,42 +683,41 @@ private:
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTTPResponseSinkPrototype, JSHTTPResponseSinkPrototype::Base);
class JSReadableHTTPResponseSinkControllerPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSReadableHTTPResponseSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSReadableHTTPResponseSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableHTTPResponseSinkControllerPrototype>(vm)) JSReadableHTTPResponseSinkControllerPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- 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());
- }
-
- private:
- JSReadableHTTPResponseSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
- STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPResponseSinkControllerPrototype, JSReadableHTTPResponseSinkControllerPrototype::Base);
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSReadableHTTPResponseSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableHTTPResponseSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableHTTPResponseSinkControllerPrototype>(vm)) JSReadableHTTPResponseSinkControllerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ 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());
+ }
+
+private:
+ JSReadableHTTPResponseSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPResponseSinkControllerPrototype, JSReadableHTTPResponseSinkControllerPrototype::Base);
const ClassInfo JSHTTPResponseSinkPrototype::s_info = { "HTTPResponseSink"_s, &Base::s_info, &JSHTTPResponseSinkPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSHTTPResponseSinkPrototype) };
const ClassInfo JSHTTPResponseSink::s_info = { "HTTPResponseSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPResponseSink) };
const ClassInfo JSHTTPResponseSinkConstructor::s_info = { "HTTPResponseSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPResponseSinkConstructor) };
-
const ClassInfo JSReadableHTTPResponseSinkControllerPrototype::s_info = { "ReadableHTTPResponseSinkController"_s, &Base::s_info, &JSReadableHTTPResponseSinkControllerPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSReadableHTTPResponseSinkControllerPrototype) };
const ClassInfo JSReadableHTTPResponseSinkController::s_info = { "ReadableHTTPResponseSinkController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableHTTPResponseSinkController) };
@@ -749,7 +728,6 @@ JSHTTPResponseSink::~JSHTTPResponseSink()
}
}
-
JSReadableHTTPResponseSinkController::~JSReadableHTTPResponseSinkController()
{
if (m_sinkPtr) {
@@ -767,7 +745,26 @@ JSObject* JSReadableHTTPResponseSinkController::createPrototype(VM& vm, JSDOMGlo
return JSReadableHTTPResponseSinkControllerPrototype::create(vm, &globalObject, JSReadableHTTPResponseSinkControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
}
+void JSReadableHTTPResponseSinkController::detach()
+{
+ m_sinkPtr = nullptr;
+ m_onPull.clear();
+
+ auto readableStream = m_weakReadableStream.get();
+ auto onClose = m_onClose.get();
+ m_onClose.clear();
+ if (readableStream && onClose) {
+ JSC::JSGlobalObject* globalObject = this->globalObject();
+ auto callData = JSC::getCallData(onClose);
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(readableStream);
+ arguments.append(jsUndefined());
+ JSC::call(globalObject, onClose, callData, JSC::jsUndefined(), arguments);
+ }
+
+ m_weakReadableStream.clear();
+}
JSHTTPResponseSinkConstructor* JSHTTPResponseSinkConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSObject* prototype)
{
@@ -797,11 +794,11 @@ void JSHTTPResponseSinkConstructor::finishCreation(VM& vm, JSC::JSGlobalObject*
initializeProperties(vm, globalObject, prototype);
}
-JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSHTTPResponseSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) {
+JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSHTTPResponseSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame)
+{
return HTTPResponseSink__construct(globalObject, callFrame);
}
-
void JSHTTPResponseSinkConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSObject* prototype)
{
putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
@@ -838,12 +835,10 @@ void JSReadableHTTPResponseSinkController::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
void JSHTTPResponseSink::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
{
auto* thisObject = jsCast<JSHTTPResponseSink*>(cell);
if (void* wrapped = thisObject->wrapped()) {
- analyzer.setWrappedObjectForCell(cell, wrapped);
// if (thisObject->scriptExecutionContext())
// analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
}
@@ -854,14 +849,12 @@ void JSReadableHTTPResponseSinkController::analyzeHeap(JSCell* cell, HeapAnalyze
{
auto* thisObject = jsCast<JSReadableHTTPResponseSinkController*>(cell);
if (void* wrapped = thisObject->wrapped()) {
- analyzer.setWrappedObjectForCell(cell, wrapped);
// if (thisObject->scriptExecutionContext())
// analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
}
Base::analyzeHeap(cell, analyzer);
}
-
template<typename Visitor>
void JSReadableHTTPResponseSinkController::visitChildrenImpl(JSCell* cell, Visitor& visitor)
{
@@ -875,8 +868,8 @@ void JSReadableHTTPResponseSinkController::visitChildrenImpl(JSCell* cell, Visit
DEFINE_VISIT_CHILDREN(JSReadableHTTPResponseSinkController);
-
-void JSReadableHTTPResponseSinkController::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose) {
+void JSReadableHTTPResponseSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose)
+{
this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject());
this->m_onPull.set(globalObject->vm(), this, onPull);
this->m_onClose.set(globalObject->vm(), this, onClose);
@@ -887,14 +880,11 @@ void JSHTTPResponseSink::destroy(JSCell* cell)
static_cast<JSHTTPResponseSink*>(cell)->JSHTTPResponseSink::~JSHTTPResponseSink();
}
-
void JSReadableHTTPResponseSinkController::destroy(JSCell* cell)
{
static_cast<JSReadableHTTPResponseSinkController*>(cell)->JSReadableHTTPResponseSinkController::~JSReadableHTTPResponseSinkController();
}
-
-
#pragma mark - HTTPSResponseSink
class JSHTTPSResponseSinkPrototype final : public JSC::JSNonFinalObject {
@@ -930,42 +920,41 @@ private:
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSHTTPSResponseSinkPrototype, JSHTTPSResponseSinkPrototype::Base);
class JSReadableHTTPSResponseSinkControllerPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSReadableHTTPSResponseSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSReadableHTTPSResponseSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableHTTPSResponseSinkControllerPrototype>(vm)) JSReadableHTTPSResponseSinkControllerPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- 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());
- }
-
- private:
- JSReadableHTTPSResponseSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
- STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPSResponseSinkControllerPrototype, JSReadableHTTPSResponseSinkControllerPrototype::Base);
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSReadableHTTPSResponseSinkControllerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableHTTPSResponseSinkControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableHTTPSResponseSinkControllerPrototype>(vm)) JSReadableHTTPSResponseSinkControllerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ 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());
+ }
+
+private:
+ JSReadableHTTPSResponseSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableHTTPSResponseSinkControllerPrototype, JSReadableHTTPSResponseSinkControllerPrototype::Base);
const ClassInfo JSHTTPSResponseSinkPrototype::s_info = { "HTTPSResponseSink"_s, &Base::s_info, &JSHTTPSResponseSinkPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSHTTPSResponseSinkPrototype) };
const ClassInfo JSHTTPSResponseSink::s_info = { "HTTPSResponseSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPSResponseSink) };
const ClassInfo JSHTTPSResponseSinkConstructor::s_info = { "HTTPSResponseSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTTPSResponseSinkConstructor) };
-
const ClassInfo JSReadableHTTPSResponseSinkControllerPrototype::s_info = { "ReadableHTTPSResponseSinkController"_s, &Base::s_info, &JSReadableHTTPSResponseSinkControllerPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSReadableHTTPSResponseSinkControllerPrototype) };
const ClassInfo JSReadableHTTPSResponseSinkController::s_info = { "ReadableHTTPSResponseSinkController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableHTTPSResponseSinkController) };
@@ -976,7 +965,6 @@ JSHTTPSResponseSink::~JSHTTPSResponseSink()
}
}
-
JSReadableHTTPSResponseSinkController::~JSReadableHTTPSResponseSinkController()
{
if (m_sinkPtr) {
@@ -994,7 +982,26 @@ JSObject* JSReadableHTTPSResponseSinkController::createPrototype(VM& vm, JSDOMGl
return JSReadableHTTPSResponseSinkControllerPrototype::create(vm, &globalObject, JSReadableHTTPSResponseSinkControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
}
+void JSReadableHTTPSResponseSinkController::detach()
+{
+ m_sinkPtr = nullptr;
+ m_onPull.clear();
+
+ auto readableStream = m_weakReadableStream.get();
+ auto onClose = m_onClose.get();
+ m_onClose.clear();
+
+ if (readableStream && onClose) {
+ JSC::JSGlobalObject* globalObject = this->globalObject();
+ auto callData = JSC::getCallData(onClose);
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(readableStream);
+ arguments.append(jsUndefined());
+ JSC::call(globalObject, onClose, callData, JSC::jsUndefined(), arguments);
+ }
+ m_weakReadableStream.clear();
+}
JSHTTPSResponseSinkConstructor* JSHTTPSResponseSinkConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSObject* prototype)
{
@@ -1024,11 +1031,11 @@ void JSHTTPSResponseSinkConstructor::finishCreation(VM& vm, JSC::JSGlobalObject*
initializeProperties(vm, globalObject, prototype);
}
-JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSHTTPSResponseSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) {
+JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSHTTPSResponseSinkConstructor::construct(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame)
+{
return HTTPSResponseSink__construct(globalObject, callFrame);
}
-
void JSHTTPSResponseSinkConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSObject* prototype)
{
putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
@@ -1065,12 +1072,10 @@ void JSReadableHTTPSResponseSinkController::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
void JSHTTPSResponseSink::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
{
auto* thisObject = jsCast<JSHTTPSResponseSink*>(cell);
if (void* wrapped = thisObject->wrapped()) {
- analyzer.setWrappedObjectForCell(cell, wrapped);
// if (thisObject->scriptExecutionContext())
// analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
}
@@ -1081,14 +1086,12 @@ void JSReadableHTTPSResponseSinkController::analyzeHeap(JSCell* cell, HeapAnalyz
{
auto* thisObject = jsCast<JSReadableHTTPSResponseSinkController*>(cell);
if (void* wrapped = thisObject->wrapped()) {
- analyzer.setWrappedObjectForCell(cell, wrapped);
// if (thisObject->scriptExecutionContext())
// analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
}
Base::analyzeHeap(cell, analyzer);
}
-
template<typename Visitor>
void JSReadableHTTPSResponseSinkController::visitChildrenImpl(JSCell* cell, Visitor& visitor)
{
@@ -1102,8 +1105,8 @@ void JSReadableHTTPSResponseSinkController::visitChildrenImpl(JSCell* cell, Visi
DEFINE_VISIT_CHILDREN(JSReadableHTTPSResponseSinkController);
-
-void JSReadableHTTPSResponseSinkController::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose) {
+void JSReadableHTTPSResponseSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose)
+{
this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject());
this->m_onPull.set(globalObject->vm(), this, onPull);
this->m_onClose.set(globalObject->vm(), this, onClose);
@@ -1114,18 +1117,15 @@ void JSHTTPSResponseSink::destroy(JSCell* cell)
static_cast<JSHTTPSResponseSink*>(cell)->JSHTTPSResponseSink::~JSHTTPSResponseSink();
}
-
void JSReadableHTTPSResponseSinkController::destroy(JSCell* cell)
{
static_cast<JSReadableHTTPSResponseSinkController*>(cell)->JSReadableHTTPSResponseSinkController::~JSReadableHTTPSResponseSinkController();
}
+JSObject* createJSSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, SinkID sinkID)
+{
+ switch (sinkID) {
-
- JSObject* createJSSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, SinkID sinkID)
- {
- switch (sinkID) {
-
case ArrayBufferSink:
return JSArrayBufferSinkPrototype::create(vm, globalObject, JSArrayBufferSinkPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
@@ -1135,29 +1135,49 @@ void JSReadableHTTPSResponseSinkController::destroy(JSCell* cell)
case HTTPSResponseSink:
return JSHTTPSResponseSinkPrototype::create(vm, globalObject, JSHTTPSResponseSinkPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
-default:
- RELEASE_ASSERT_NOT_REACHED();
+ default:
+ RELEASE_ASSERT_NOT_REACHED();
}
}
JSObject* createJSSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, SinkID sinkID)
{
switch (sinkID) {
-
- case ArrayBufferSink:
- return JSReadableArrayBufferSinkControllerPrototype::create(vm, globalObject, JSReadableArrayBufferSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
- case HTTPResponseSink:
- return JSReadableHTTPResponseSinkControllerPrototype::create(vm, globalObject, JSReadableHTTPResponseSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+ case ArrayBufferSink:
+ return JSReadableArrayBufferSinkControllerPrototype::create(vm, globalObject, JSReadableArrayBufferSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
- case HTTPSResponseSink:
- return JSReadableHTTPSResponseSinkControllerPrototype::create(vm, globalObject, JSReadableHTTPSResponseSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+ case HTTPResponseSink:
+ return JSReadableHTTPResponseSinkControllerPrototype::create(vm, globalObject, JSReadableHTTPResponseSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
-default:
- RELEASE_ASSERT_NOT_REACHED();
- }
+ case HTTPSResponseSink:
+ return JSReadableHTTPSResponseSinkControllerPrototype::create(vm, globalObject, JSReadableHTTPSResponseSinkControllerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+
+ default:
+ RELEASE_ASSERT_NOT_REACHED();
+ }
}
-} // namespace WebCore
+Structure* createJSSinkControllerStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, SinkID sinkID)
+{
+ switch (sinkID) {
+
+ case ArrayBufferSink: {
+ auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID);
+ return JSReadableArrayBufferSinkController::createStructure(vm, globalObject, prototype);
+ }
+ case HTTPResponseSink: {
+ auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID);
+ return JSReadableHTTPResponseSinkController::createStructure(vm, globalObject, prototype);
+ }
+ case HTTPSResponseSink: {
+ auto* prototype = createJSSinkControllerPrototype(vm, globalObject, sinkID);
+ return JSReadableHTTPSResponseSinkController::createStructure(vm, globalObject, prototype);
+ }
+ default:
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+}
+} // namespace WebCore
extern "C" JSC__JSValue ArrayBufferSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr)
{
@@ -1186,7 +1206,6 @@ extern "C" void ArrayBufferSink__detachPtr(JSC__JSValue JSValue0)
sink->detach();
return;
}
-
if (auto* controller = JSC::jsDynamicCast<WebCore::JSReadableArrayBufferSinkController*>(JSC::JSValue::decode(JSValue0))) {
controller->detach();
@@ -1194,18 +1213,18 @@ extern "C" void ArrayBufferSink__detachPtr(JSC__JSValue JSValue0)
}
}
-extern "C" JSC__JSValue ArrayBufferSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void **controllerValue)
+extern "C" JSC__JSValue ArrayBufferSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void** controllerValue)
{
auto& vm = arg0->vm();
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0);
auto clientData = WebCore::clientData(vm);
- JSC::JSObject *readableStream = JSC::JSValue::decode(stream).getObject();
+ JSC::JSObject* readableStream = JSC::JSValue::decode(stream).getObject();
auto scope = DECLARE_CATCH_SCOPE(vm);
JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableArrayBufferSinkController>(vm, *globalObject);
- WebCore::JSReadableArrayBufferSinkController *controller = WebCore::JSReadableArrayBufferSinkController::create(vm, globalObject, structure, sinkPtr);
+ WebCore::JSReadableArrayBufferSinkController* controller = WebCore::JSReadableArrayBufferSinkController::create(vm, globalObject, structure, sinkPtr);
*controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller));
- JSC::JSObject *function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject();
+ JSC::JSObject* function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject();
auto callData = JSC::getCallData(function);
JSC::MarkedArgumentBuffer arguments;
arguments.append(JSC::JSValue::decode(stream));
@@ -1222,10 +1241,10 @@ extern "C" void ArrayBufferSink__onReady(JSC__JSValue controllerValue, JSC__JSVa
{
WebCore::JSReadableArrayBufferSinkController* controller = JSC::jsCast<WebCore::JSReadableArrayBufferSinkController*>(JSC::JSValue::decode(controllerValue).getObject());
- JSC::JSFunction *function = controller->m_onPull.get();
+ JSC::JSFunction* function = controller->m_onPull.get();
if (function == nullptr)
return;
- JSC::JSGlobalObject *globalObject = controller->globalObject();
+ JSC::JSGlobalObject* globalObject = controller->globalObject();
auto callData = JSC::getCallData(function);
JSC::MarkedArgumentBuffer arguments;
@@ -1238,28 +1257,28 @@ extern "C" void ArrayBufferSink__onReady(JSC__JSValue controllerValue, JSC__JSVa
extern "C" void ArrayBufferSink__onStart(JSC__JSValue controllerValue)
{
-
}
extern "C" void ArrayBufferSink__onClose(JSC__JSValue controllerValue, JSC__JSValue reason)
{
WebCore::JSReadableArrayBufferSinkController* controller = JSC::jsCast<WebCore::JSReadableArrayBufferSinkController*>(JSC::JSValue::decode(controllerValue).getObject());
- JSC::JSFunction *function = controller->m_onClose.get();
+ JSC::JSFunction* function = controller->m_onClose.get();
if (function == nullptr)
return;
// only call close once
controller->m_onClose.clear();
- JSC::JSGlobalObject *globalObject = controller->globalObject();
+ JSC::JSGlobalObject* globalObject = controller->globalObject();
auto callData = JSC::getCallData(function);
JSC::MarkedArgumentBuffer arguments;
- arguments.append(controller);
+ auto readableStream = controller->m_weakReadableStream.get();
+ arguments.append(readableStream ? readableStream : JSC::jsUndefined());
+
arguments.append(JSC::JSValue::decode(reason));
JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments);
}
-
extern "C" JSC__JSValue HTTPResponseSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr)
{
auto& vm = arg0->vm();
@@ -1287,7 +1306,6 @@ extern "C" void HTTPResponseSink__detachPtr(JSC__JSValue JSValue0)
sink->detach();
return;
}
-
if (auto* controller = JSC::jsDynamicCast<WebCore::JSReadableHTTPResponseSinkController*>(JSC::JSValue::decode(JSValue0))) {
controller->detach();
@@ -1295,18 +1313,18 @@ extern "C" void HTTPResponseSink__detachPtr(JSC__JSValue JSValue0)
}
}
-extern "C" JSC__JSValue HTTPResponseSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void **controllerValue)
+extern "C" JSC__JSValue HTTPResponseSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void** controllerValue)
{
auto& vm = arg0->vm();
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0);
auto clientData = WebCore::clientData(vm);
- JSC::JSObject *readableStream = JSC::JSValue::decode(stream).getObject();
+ JSC::JSObject* readableStream = JSC::JSValue::decode(stream).getObject();
auto scope = DECLARE_CATCH_SCOPE(vm);
- JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableHTTPResponseSinkController>(vm, *globalObject);
- WebCore::JSReadableHTTPResponseSinkController *controller = WebCore::JSReadableHTTPResponseSinkController::create(vm, globalObject, structure, sinkPtr);
+ JSC::Structure* structure = globalObject->JSReadableHTTPResponseSinkController();
+ WebCore::JSReadableHTTPResponseSinkController* controller = WebCore::JSReadableHTTPResponseSinkController::create(vm, globalObject, structure, sinkPtr);
*controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller));
- JSC::JSObject *function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject();
+ JSC::JSObject* function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject();
auto callData = JSC::getCallData(function);
JSC::MarkedArgumentBuffer arguments;
arguments.append(JSC::JSValue::decode(stream));
@@ -1323,10 +1341,10 @@ extern "C" void HTTPResponseSink__onReady(JSC__JSValue controllerValue, JSC__JSV
{
WebCore::JSReadableHTTPResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject());
- JSC::JSFunction *function = controller->m_onPull.get();
+ JSC::JSFunction* function = controller->m_onPull.get();
if (function == nullptr)
return;
- JSC::JSGlobalObject *globalObject = controller->globalObject();
+ JSC::JSGlobalObject* globalObject = controller->globalObject();
auto callData = JSC::getCallData(function);
JSC::MarkedArgumentBuffer arguments;
@@ -1339,28 +1357,28 @@ extern "C" void HTTPResponseSink__onReady(JSC__JSValue controllerValue, JSC__JSV
extern "C" void HTTPResponseSink__onStart(JSC__JSValue controllerValue)
{
-
}
extern "C" void HTTPResponseSink__onClose(JSC__JSValue controllerValue, JSC__JSValue reason)
{
WebCore::JSReadableHTTPResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject());
- JSC::JSFunction *function = controller->m_onClose.get();
+ JSC::JSFunction* function = controller->m_onClose.get();
if (function == nullptr)
return;
// only call close once
controller->m_onClose.clear();
- JSC::JSGlobalObject *globalObject = controller->globalObject();
+ JSC::JSGlobalObject* globalObject = controller->globalObject();
auto callData = JSC::getCallData(function);
JSC::MarkedArgumentBuffer arguments;
- arguments.append(controller);
+ auto readableStream = controller->m_weakReadableStream.get();
+ arguments.append(readableStream ? readableStream : JSC::jsUndefined());
+
arguments.append(JSC::JSValue::decode(reason));
JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments);
}
-
extern "C" JSC__JSValue HTTPSResponseSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr)
{
auto& vm = arg0->vm();
@@ -1388,7 +1406,6 @@ extern "C" void HTTPSResponseSink__detachPtr(JSC__JSValue JSValue0)
sink->detach();
return;
}
-
if (auto* controller = JSC::jsDynamicCast<WebCore::JSReadableHTTPSResponseSinkController*>(JSC::JSValue::decode(JSValue0))) {
controller->detach();
@@ -1396,18 +1413,18 @@ extern "C" void HTTPSResponseSink__detachPtr(JSC__JSValue JSValue0)
}
}
-extern "C" JSC__JSValue HTTPSResponseSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void **controllerValue)
+extern "C" JSC__JSValue HTTPSResponseSink__assignToStream(JSC__JSGlobalObject* arg0, JSC__JSValue stream, void* sinkPtr, void** controllerValue)
{
auto& vm = arg0->vm();
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0);
auto clientData = WebCore::clientData(vm);
- JSC::JSObject *readableStream = JSC::JSValue::decode(stream).getObject();
+ JSC::JSObject* readableStream = JSC::JSValue::decode(stream).getObject();
auto scope = DECLARE_CATCH_SCOPE(vm);
JSC::Structure* structure = WebCore::getDOMStructure<WebCore::JSReadableHTTPSResponseSinkController>(vm, *globalObject);
- WebCore::JSReadableHTTPSResponseSinkController *controller = WebCore::JSReadableHTTPSResponseSinkController::create(vm, globalObject, structure, sinkPtr);
+ WebCore::JSReadableHTTPSResponseSinkController* controller = WebCore::JSReadableHTTPSResponseSinkController::create(vm, globalObject, structure, sinkPtr);
*controllerValue = reinterpret_cast<void*>(JSC::JSValue::encode(controller));
- JSC::JSObject *function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject();
+ JSC::JSObject* function = globalObject->getDirect(vm, clientData->builtinNames().assignToStreamPrivateName()).getObject();
auto callData = JSC::getCallData(function);
JSC::MarkedArgumentBuffer arguments;
arguments.append(JSC::JSValue::decode(stream));
@@ -1424,10 +1441,10 @@ extern "C" void HTTPSResponseSink__onReady(JSC__JSValue controllerValue, JSC__JS
{
WebCore::JSReadableHTTPSResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPSResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject());
- JSC::JSFunction *function = controller->m_onPull.get();
+ JSC::JSFunction* function = controller->m_onPull.get();
if (function == nullptr)
return;
- JSC::JSGlobalObject *globalObject = controller->globalObject();
+ JSC::JSGlobalObject* globalObject = controller->globalObject();
auto callData = JSC::getCallData(function);
JSC::MarkedArgumentBuffer arguments;
@@ -1440,24 +1457,24 @@ extern "C" void HTTPSResponseSink__onReady(JSC__JSValue controllerValue, JSC__JS
extern "C" void HTTPSResponseSink__onStart(JSC__JSValue controllerValue)
{
-
}
extern "C" void HTTPSResponseSink__onClose(JSC__JSValue controllerValue, JSC__JSValue reason)
{
WebCore::JSReadableHTTPSResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPSResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject());
- JSC::JSFunction *function = controller->m_onClose.get();
+ JSC::JSFunction* function = controller->m_onClose.get();
if (function == nullptr)
return;
// only call close once
controller->m_onClose.clear();
- JSC::JSGlobalObject *globalObject = controller->globalObject();
+ JSC::JSGlobalObject* globalObject = controller->globalObject();
auto callData = JSC::getCallData(function);
JSC::MarkedArgumentBuffer arguments;
- arguments.append(controller);
+ auto readableStream = controller->m_weakReadableStream.get();
+ arguments.append(readableStream ? readableStream : JSC::jsUndefined());
+
arguments.append(JSC::JSValue::decode(reason));
JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments);
}
-
diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h
index 1a69db9c6..88954fd5a 100644
--- a/src/bun.js/bindings/JSSink.h
+++ b/src/bun.js/bindings/JSSink.h
@@ -1,6 +1,6 @@
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at 2022-07-02T06:06:00.509Z
+// Generated by 'make generate-sink' at 2022-07-02T10:45:03.308Z
//
#pragma once
@@ -17,458 +17,433 @@ namespace WebCore {
using namespace JSC;
JSC_DECLARE_HOST_FUNCTION(functionStartDirectStream);
-class JSArrayBufferSinkConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSArrayBufferSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype);
- static constexpr SinkID Sink = SinkID::ArrayBufferSink;
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSArrayBufferSinkConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); });
- }
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
-
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- private:
- JSArrayBufferSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction)
- : Base(vm, structure, nativeFunction, nativeFunction)
-
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
- };
-
- class JSArrayBufferSink final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSArrayBufferSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
- static constexpr SinkID Sink = SinkID::ArrayBufferSink;
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSArrayBufferSink, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); });
- }
-
- static void destroy(JSC::JSCell*);
- 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
-
- ~JSArrayBufferSink();
-
- void* wrapped() const { return m_sinkPtr; }
-
- void detach() {
- m_sinkPtr = nullptr;
-
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
-
- void* m_sinkPtr;
-
- JSArrayBufferSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_sinkPtr = sinkPtr;
- }
-
- void finishCreation(JSC::VM&);
- };
-
- class JSReadableArrayBufferSinkController final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSReadableArrayBufferSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
- static constexpr SinkID Sink = SinkID::ArrayBufferSink;
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSReadableArrayBufferSinkController, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); });
- }
-
- static void destroy(JSC::JSCell*);
- 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
-
- ~JSReadableArrayBufferSinkController();
-
-
- void* wrapped() const { return m_sinkPtr; }
- void detach() {
- m_sinkPtr = nullptr;
- m_onPull.clear();
- m_onClose.clear();
- m_weakReadableStream.clear();
- }
-
- void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose);
- DECLARE_VISIT_CHILDREN;
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
-
- void* m_sinkPtr;
- mutable WriteBarrier<JSC::JSFunction> m_onPull;
- mutable WriteBarrier<JSC::JSFunction> m_onClose;
- mutable JSC::Weak<JSObject> m_weakReadableStream;
-
- JSReadableArrayBufferSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_sinkPtr = sinkPtr;
- }
-
- void finishCreation(JSC::VM&);
- };
+class JSArrayBufferSinkConstructor final : public JSC::InternalFunction {
+public:
+ using Base = JSC::InternalFunction;
+ static JSArrayBufferSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype);
+ static constexpr SinkID Sink = SinkID::ArrayBufferSink;
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSArrayBufferSinkConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); });
+ }
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+private:
+ JSArrayBufferSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction)
+ : Base(vm, structure, nativeFunction, nativeFunction)
+
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
+};
+
+class JSArrayBufferSink final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSArrayBufferSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
+ static constexpr SinkID Sink = SinkID::ArrayBufferSink;
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSArrayBufferSink, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
+
+ ~JSArrayBufferSink();
+
+ void* wrapped() const { return m_sinkPtr; }
+
+ void detach()
+ {
+ m_sinkPtr = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+
+ void* m_sinkPtr;
+
+ JSArrayBufferSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_sinkPtr = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
+
+class JSReadableArrayBufferSinkController final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSReadableArrayBufferSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
+ static constexpr SinkID Sink = SinkID::ArrayBufferSink;
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSReadableArrayBufferSinkController, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
+
+ ~JSReadableArrayBufferSinkController();
+
+ void* wrapped() const { return m_sinkPtr; }
+ void detach();
+
+ void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose);
+ DECLARE_VISIT_CHILDREN;
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+
+ void* m_sinkPtr;
+ mutable WriteBarrier<JSC::JSFunction> m_onPull;
+ mutable WriteBarrier<JSC::JSFunction> m_onClose;
+ mutable JSC::Weak<JSObject> m_weakReadableStream;
+
+ JSReadableArrayBufferSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_sinkPtr = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
JSC_DECLARE_CUSTOM_GETTER(functionArrayBufferSink__getter);
-
-class JSHTTPResponseSinkConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSHTTPResponseSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype);
- static constexpr SinkID Sink = SinkID::HTTPResponseSink;
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSHTTPResponseSinkConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); });
- }
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
-
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- private:
- JSHTTPResponseSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction)
- : Base(vm, structure, nativeFunction, nativeFunction)
-
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
- };
-
- class JSHTTPResponseSink final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSHTTPResponseSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
- static constexpr SinkID Sink = SinkID::HTTPResponseSink;
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSHTTPResponseSink, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); });
- }
-
- static void destroy(JSC::JSCell*);
- 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
-
- ~JSHTTPResponseSink();
-
- void* wrapped() const { return m_sinkPtr; }
-
- void detach() {
- m_sinkPtr = nullptr;
-
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
-
- void* m_sinkPtr;
-
- JSHTTPResponseSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_sinkPtr = sinkPtr;
- }
-
- void finishCreation(JSC::VM&);
- };
-
- class JSReadableHTTPResponseSinkController final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSReadableHTTPResponseSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
- static constexpr SinkID Sink = SinkID::HTTPResponseSink;
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSReadableHTTPResponseSinkController, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); });
- }
-
- static void destroy(JSC::JSCell*);
- 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
-
- ~JSReadableHTTPResponseSinkController();
-
-
- void* wrapped() const { return m_sinkPtr; }
- void detach() {
- m_sinkPtr = nullptr;
- m_onPull.clear();
- m_onClose.clear();
- m_weakReadableStream.clear();
- }
-
- void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose);
- DECLARE_VISIT_CHILDREN;
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
-
- void* m_sinkPtr;
- mutable WriteBarrier<JSC::JSFunction> m_onPull;
- mutable WriteBarrier<JSC::JSFunction> m_onClose;
- mutable JSC::Weak<JSObject> m_weakReadableStream;
-
- JSReadableHTTPResponseSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_sinkPtr = sinkPtr;
- }
-
- void finishCreation(JSC::VM&);
- };
+class JSHTTPResponseSinkConstructor final : public JSC::InternalFunction {
+public:
+ using Base = JSC::InternalFunction;
+ static JSHTTPResponseSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype);
+ static constexpr SinkID Sink = SinkID::HTTPResponseSink;
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSHTTPResponseSinkConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); });
+ }
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+private:
+ JSHTTPResponseSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction)
+ : Base(vm, structure, nativeFunction, nativeFunction)
+
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
+};
+
+class JSHTTPResponseSink final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSHTTPResponseSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
+ static constexpr SinkID Sink = SinkID::HTTPResponseSink;
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSHTTPResponseSink, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
+
+ ~JSHTTPResponseSink();
+
+ void* wrapped() const { return m_sinkPtr; }
+
+ void detach()
+ {
+ m_sinkPtr = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+
+ void* m_sinkPtr;
+
+ JSHTTPResponseSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_sinkPtr = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
+
+class JSReadableHTTPResponseSinkController final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSReadableHTTPResponseSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
+ static constexpr SinkID Sink = SinkID::HTTPResponseSink;
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSReadableHTTPResponseSinkController, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
+
+ ~JSReadableHTTPResponseSinkController();
+
+ void* wrapped() const { return m_sinkPtr; }
+ void detach();
+
+ void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose);
+ DECLARE_VISIT_CHILDREN;
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+
+ void* m_sinkPtr;
+ mutable WriteBarrier<JSC::JSFunction> m_onPull;
+ mutable WriteBarrier<JSC::JSFunction> m_onClose;
+ mutable JSC::Weak<JSObject> m_weakReadableStream;
+
+ JSReadableHTTPResponseSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_sinkPtr = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
JSC_DECLARE_CUSTOM_GETTER(functionHTTPResponseSink__getter);
-
-class JSHTTPSResponseSinkConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSHTTPSResponseSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype);
- static constexpr SinkID Sink = SinkID::HTTPSResponseSink;
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSHTTPSResponseSinkConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); });
- }
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
-
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- private:
- JSHTTPSResponseSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction)
- : Base(vm, structure, nativeFunction, nativeFunction)
-
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
- };
-
- class JSHTTPSResponseSink final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSHTTPSResponseSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
- static constexpr SinkID Sink = SinkID::HTTPSResponseSink;
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSHTTPSResponseSink, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); });
- }
-
- static void destroy(JSC::JSCell*);
- 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
-
- ~JSHTTPSResponseSink();
-
- void* wrapped() const { return m_sinkPtr; }
-
- void detach() {
- m_sinkPtr = nullptr;
-
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
-
- void* m_sinkPtr;
-
- JSHTTPSResponseSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_sinkPtr = sinkPtr;
- }
-
- void finishCreation(JSC::VM&);
- };
-
- class JSReadableHTTPSResponseSinkController final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSReadableHTTPSResponseSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
- static constexpr SinkID Sink = SinkID::HTTPSResponseSink;
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSReadableHTTPSResponseSinkController, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); });
- }
-
- static void destroy(JSC::JSCell*);
- 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
-
- ~JSReadableHTTPSResponseSinkController();
-
-
- void* wrapped() const { return m_sinkPtr; }
- void detach() {
- m_sinkPtr = nullptr;
- m_onPull.clear();
- m_onClose.clear();
- m_weakReadableStream.clear();
- }
-
- void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose);
- DECLARE_VISIT_CHILDREN;
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
-
- void* m_sinkPtr;
- mutable WriteBarrier<JSC::JSFunction> m_onPull;
- mutable WriteBarrier<JSC::JSFunction> m_onClose;
- mutable JSC::Weak<JSObject> m_weakReadableStream;
-
- JSReadableHTTPSResponseSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_sinkPtr = sinkPtr;
- }
-
- void finishCreation(JSC::VM&);
- };
+class JSHTTPSResponseSinkConstructor final : public JSC::InternalFunction {
+public:
+ using Base = JSC::InternalFunction;
+ static JSHTTPSResponseSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype);
+ static constexpr SinkID Sink = SinkID::HTTPSResponseSink;
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSHTTPSResponseSinkConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = WTFMove(space); });
+ }
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+private:
+ JSHTTPSResponseSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction)
+ : Base(vm, structure, nativeFunction, nativeFunction)
+
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
+};
+
+class JSHTTPSResponseSink final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSHTTPSResponseSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
+ static constexpr SinkID Sink = SinkID::HTTPSResponseSink;
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSHTTPSResponseSink, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForJSSink.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = WTFMove(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
+
+ ~JSHTTPSResponseSink();
+
+ void* wrapped() const { return m_sinkPtr; }
+
+ void detach()
+ {
+ m_sinkPtr = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+
+ void* m_sinkPtr;
+
+ JSHTTPSResponseSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_sinkPtr = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
+
+class JSReadableHTTPSResponseSinkController final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSReadableHTTPSResponseSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
+ static constexpr SinkID Sink = SinkID::HTTPSResponseSink;
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSReadableHTTPSResponseSinkController, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = WTFMove(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ 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 JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
+
+ ~JSReadableHTTPSResponseSinkController();
+
+ void* wrapped() const { return m_sinkPtr; }
+ void detach();
+
+ void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose);
+ DECLARE_VISIT_CHILDREN;
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+
+ void* m_sinkPtr;
+ mutable WriteBarrier<JSC::JSFunction> m_onPull;
+ mutable WriteBarrier<JSC::JSFunction> m_onClose;
+ mutable JSC::Weak<JSObject> m_weakReadableStream;
+
+ JSReadableHTTPSResponseSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_sinkPtr = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
JSC_DECLARE_CUSTOM_GETTER(functionHTTPSResponseSink__getter);
-
-
JSObject* createJSSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID);
JSObject* createJSSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID);
-
+Structure* createJSSinkControllerStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID);
} // namespace WebCore
diff --git a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp
index fd6010f17..ee6dc21b3 100644
--- a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp
+++ b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp
@@ -949,33 +949,47 @@ const char* const s_readableStreamInternalsIsReadableStreamDefaultControllerCode
const JSC::ConstructAbility s_readableStreamInternalsReadDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamInternalsReadDirectStreamCodeConstructorKind = JSC::ConstructorKind::None;
-const int s_readableStreamInternalsReadDirectStreamCodeLength = 1208;
+const int s_readableStreamInternalsReadDirectStreamCodeLength = 1496;
static const JSC::Intrinsic s_readableStreamInternalsReadDirectStreamCodeIntrinsic = JSC::NoIntrinsic;
const char* const s_readableStreamInternalsReadDirectStreamCode =
"(function (stream, sink, underlyingSource) {\n" \
" \"use strict\";\n" \
" \n" \
" @putByIdDirectPrivate(stream, \"underlyingSource\", @undefined);\n" \
+ " @putByIdDirectPrivate(stream, \"start\", @undefined);\n" \
"\n" \
- " var {close: originalClose, pull} = underlyingSource;\n" \
+ " var {cancel, pull} = underlyingSource;\n" \
" underlyingSource = @undefined;\n" \
"\n" \
"\n" \
- " var fakeReader = {\n" \
- " };\n" \
- " var close = (reason) => {\n" \
- " try {\n" \
- " originalClose && originalClose(reason);\n" \
- " } catch (e) {\n" \
+ " var capturedStream = stream;\n" \
+ " var reader;\n" \
"\n" \
+ " function close(stream, reason) {\n" \
+ " if (reason && cancel) {\n" \
+ " try {\n" \
+ " cancel(reason);\n" \
+ " } catch (e) {\n" \
+ " }\n" \
+ "\n" \
+ " cancel = @undefined;\n" \
" }\n" \
- " originalClose = @undefined;\n" \
- " @putByIdDirectPrivate(stream, \"reader\", @undefined);\n" \
- " @putByIdDirectPrivate(stream, \"readableStreamController\", null);\n" \
- " @putByIdDirectPrivate(stream, \"state\", @streamClosed);\n" \
- " stream = @undefined;\n" \
- " fakeReader = @undefined;\n" \
- " };\n" \
+ "\n" \
+ " if (stream) {\n" \
+ " @putByIdDirectPrivate(stream, \"readableStreamController\", @undefined);\n" \
+ " @putByIdDirectPrivate(stream, \"reader\", @undefined);\n" \
+ " if (reason) {\n" \
+ " @putByIdDirectPrivate(stream, \"state\", @streamErrored);\n" \
+ " @putByIdDirectPrivate(stream, \"storedError\", reason);\n" \
+ " } else {\n" \
+ " @putByIdDirectPrivate(stream, \"state\", @streamClosed);\n" \
+ " }\n" \
+ " \n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ "\n" \
+ "\n" \
"\n" \
"\n" \
" if (!pull) {\n" \
@@ -990,8 +1004,6 @@ const char* const s_readableStreamInternalsReadDirectStreamCode =
" }\n" \
"\n" \
" @putByIdDirectPrivate(stream, \"readableStreamController\", sink);\n" \
- " @putByIdDirectPrivate(stream, \"start\", @undefined);\n" \
- "\n" \
" const highWaterMark = @getByIdDirectPrivate(stream, \"highWaterMark\");\n" \
"\n" \
" if (highWaterMark) {\n" \
@@ -1001,28 +1013,41 @@ const char* const s_readableStreamInternalsReadDirectStreamCode =
" }\n" \
"\n" \
" @startDirectStream.@call(sink, stream, pull, close);\n" \
+ " @putByIdDirectPrivate(stream, \"reader\", {});\n" \
"\n" \
- " //\n" \
- " @putByIdDirectPrivate(stream, \"reader\", fakeReader);\n" \
- " pull(sink);\n" \
+ " var maybePromise = pull(sink);\n" \
" sink = @undefined;\n" \
+ " if (maybePromise && @isPromise(maybePromise)) {\n" \
+ " return maybePromise.@then(() => {});\n" \
+ " }\n" \
+ "\n" \
"})\n" \
;
const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamInternalsAssignToStreamCodeConstructorKind = JSC::ConstructorKind::None;
-const int s_readableStreamInternalsAssignToStreamCodeLength = 279;
+const int s_readableStreamInternalsAssignToStreamCodeLength = 438;
static const JSC::Intrinsic s_readableStreamInternalsAssignToStreamCodeIntrinsic = JSC::NoIntrinsic;
const char* const s_readableStreamInternalsAssignToStreamCode =
"(function (stream, sink) {\n" \
" \"use strict\";\n" \
"\n" \
" //\n" \
- " const underlyingSource = @getByIdDirectPrivate(stream, \"underlyingSource\");\n" \
+ " var underlyingSource = @getByIdDirectPrivate(stream, \"underlyingSource\");\n" \
"\n" \
" //\n" \
" if (underlyingSource) {\n" \
- " return @readDirectStream(stream, sink, underlyingSource);\n" \
+ " try {\n" \
+ " return @readDirectStream(stream, sink, underlyingSource);\n" \
+ " } catch(e) {\n" \
+ " throw e;\n" \
+ " } finally {\n" \
+ " underlyingSource = @undefined;\n" \
+ " stream = @undefined;\n" \
+ " sink = @undefined;\n" \
+ " }\n" \
+ " \n" \
+ "\n" \
" }\n" \
"\n" \
" return @readStreamIntoSink(stream, sink, true);\n" \
diff --git a/src/bun.js/builtins/js/ReadableStreamInternals.js b/src/bun.js/builtins/js/ReadableStreamInternals.js
index 353e3f9e9..0f5871fa1 100644
--- a/src/bun.js/builtins/js/ReadableStreamInternals.js
+++ b/src/bun.js/builtins/js/ReadableStreamInternals.js
@@ -784,42 +784,51 @@ function readDirectStream(stream, sink, underlyingSource) {
"use strict";
@putByIdDirectPrivate(stream, "underlyingSource", @undefined);
+ @putByIdDirectPrivate(stream, "start", @undefined);
- var {close: originalClose, pull} = underlyingSource;
- underlyingSource = @undefined;
+ var capturedStream = stream;
+ var reader;
- var fakeReader = {
- };
- var close = (reason) => {
- try {
- originalClose && originalClose(reason);
- } catch (e) {
+ function close(stream, reason) {
+ if (reason && underlyingSource?.cancel) {
+ try {
+ underlyingSource.cancel(reason);
+ } catch (e) {
+ }
+ underlyingSource = @undefined;
}
- originalClose = @undefined;
- @putByIdDirectPrivate(stream, "reader", @undefined);
- @putByIdDirectPrivate(stream, "readableStreamController", null);
- @putByIdDirectPrivate(stream, "state", @streamClosed);
- stream = @undefined;
- fakeReader = @undefined;
- };
+
+ if (stream) {
+ @putByIdDirectPrivate(stream, "readableStreamController", @undefined);
+ @putByIdDirectPrivate(stream, "reader", @undefined);
+ if (reason) {
+ @putByIdDirectPrivate(stream, "state", @streamErrored);
+ @putByIdDirectPrivate(stream, "storedError", reason);
+ } else {
+ @putByIdDirectPrivate(stream, "state", @streamClosed);
+ }
+
+ }
+ }
- if (!pull) {
+
+
+
+ if (!underlyingSource.pull) {
close();
return;
}
- if (!@isCallable(pull)) {
+ if (!@isCallable(underlyingSource.pull)) {
close();
@throwTypeError("pull is not a function");
return;
}
@putByIdDirectPrivate(stream, "readableStreamController", sink);
- @putByIdDirectPrivate(stream, "start", @undefined);
-
const highWaterMark = @getByIdDirectPrivate(stream, "highWaterMark");
if (highWaterMark) {
@@ -828,12 +837,15 @@ function readDirectStream(stream, sink, underlyingSource) {
});
}
- @startDirectStream.@call(sink, stream, pull, close);
+ @startDirectStream.@call(sink, stream, underlyingSource.pull, close);
+ @putByIdDirectPrivate(stream, "reader", {});
- // isReadableStreamLocked() checks for truthiness of "reader"
- @putByIdDirectPrivate(stream, "reader", fakeReader);
- pull(sink);
+ var maybePromise = underlyingSource.pull(sink);
sink = @undefined;
+ if (maybePromise && @isPromise(maybePromise)) {
+ return maybePromise.@then(() => {});
+ }
+
}
@globalPrivate;
@@ -841,11 +853,21 @@ function assignToStream(stream, sink) {
"use strict";
// The stream is either a direct stream or a "default" JS stream
- const underlyingSource = @getByIdDirectPrivate(stream, "underlyingSource");
+ var underlyingSource = @getByIdDirectPrivate(stream, "underlyingSource");
// we know it's a direct stream when @underlyingSource is set
if (underlyingSource) {
- return @readDirectStream(stream, sink, underlyingSource);
+ try {
+ return @readDirectStream(stream, sink, underlyingSource);
+ } catch(e) {
+ throw e;
+ } finally {
+ underlyingSource = @undefined;
+ stream = @undefined;
+ sink = @undefined;
+ }
+
+
}
return @readStreamIntoSink(stream, sink, true);
diff --git a/src/bun.js/generate-jssink.js b/src/bun.js/generate-jssink.js
index 255bfe613..56ffcfb06 100644
--- a/src/bun.js/generate-jssink.js
+++ b/src/bun.js/generate-jssink.js
@@ -136,12 +136,7 @@ function header() {
void* wrapped() const { return m_sinkPtr; }
- void detach() {
- m_sinkPtr = nullptr;
- m_onPull.clear();
- m_onClose.clear();
- m_weakReadableStream.clear();
- }
+ void detach();
void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose);
DECLARE_VISIT_CHILDREN;
@@ -597,6 +592,25 @@ JSObject* JS${controllerName}::createPrototype(VM& vm, JSDOMGlobalObject& global
return ${controllerPrototypeName}::create(vm, &globalObject, ${controllerPrototypeName}::createStructure(vm, &globalObject, globalObject.objectPrototype()));
}
+void JS${controllerName}::detach() {
+ m_sinkPtr = nullptr;
+ m_onPull.clear();
+
+ auto readableStream = m_weakReadableStream.get();
+ auto onClose = m_onClose.get();
+ m_onClose.clear();
+
+ if (readableStream && onClose) {
+ JSC::JSGlobalObject *globalObject = this->globalObject();
+ auto callData = JSC::getCallData(onClose);
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(readableStream);
+ arguments.append(jsUndefined());
+ JSC::call(globalObject, onClose, callData, JSC::jsUndefined(), arguments);
+ }
+
+ m_weakReadableStream.clear();
+}
`;
templ += `
@@ -871,7 +885,9 @@ extern "C" void ${name}__onClose(JSC__JSValue controllerValue, JSC__JSValue reas
auto callData = JSC::getCallData(function);
JSC::MarkedArgumentBuffer arguments;
- arguments.append(controller);
+ auto readableStream = controller->m_weakReadableStream.get();
+ arguments.append(readableStream ? readableStream : JSC::jsUndefined());
+
arguments.append(JSC::JSValue::decode(reason));
JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments);
}
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig
index 4a10b1062..de9115666 100644
--- a/src/bun.js/webcore/streams.zig
+++ b/src/bun.js/webcore/streams.zig
@@ -1110,7 +1110,6 @@ pub fn NewJSSink(comptime SinkType: type, comptime name_: []const u8) type {
var this = @ptrCast(*ThisSink, @alignCast(std.meta.alignment(ThisSink), ptr));
this.sink.finalize();
- this.detach();
}
pub fn detach(this: *ThisSink) void {
diff --git a/test/bun.js/react-dom.test.tsx b/test/bun.js/react-dom.test.tsx
index b02d17cad..6c7884073 100644
--- a/test/bun.js/react-dom.test.tsx
+++ b/test/bun.js/react-dom.test.tsx
@@ -6,10 +6,10 @@ import {
readableStreamToText,
serve,
} from "bun";
+import { heapStats } from "bun:jsc";
import { describe, expect, it } from "bun:test";
import { renderToReadableStream as renderToReadableStreamBrowser } from "react-dom/server.browser";
-// import { gc } from "./gc";
-function gc() {}
+import { gc } from "./gc";
import { renderToReadableStream as renderToReadableStreamBun } from "./reactdom-bun";
Object.defineProperty(renderToReadableStreamBrowser, "name", {
@@ -93,7 +93,7 @@ describe("ReactDOM", () => {
renderToReadableStreamBun,
renderToReadableStreamBrowser,
]) {
- for (let [inputString, reactElement] of fixtures)
+ for (let [inputString, reactElement] of fixtures) {
describe(`${renderToReadableStream.name}(${inputString})`, () => {
it("Response.text()", async () => {
const stream = await renderToReadableStream(reactElement);
@@ -110,7 +110,6 @@ describe("ReactDOM", () => {
throw e;
}
});
-
it("Response.arrayBuffer()", async () => {
const stream = await renderToReadableStream(reactElement);
gc();
@@ -121,7 +120,6 @@ describe("ReactDOM", () => {
expect(text.replaceAll("<!-- -->", "")).toBe(inputString);
gc();
});
-
it("Response.blob()", async () => {
const stream = await renderToReadableStream(reactElement);
gc();
@@ -132,7 +130,6 @@ describe("ReactDOM", () => {
expect(text.replaceAll("<!-- -->", "")).toBe(inputString);
gc();
});
-
it("readableStreamToText(stream)", async () => {
const stream = await renderToReadableStream(reactElement);
gc();
@@ -141,7 +138,6 @@ describe("ReactDOM", () => {
expect(text.replaceAll("<!-- -->", "")).toBe(inputString);
gc();
});
-
it("readableStreamToBlob(stream)", async () => {
try {
const stream = await renderToReadableStream(reactElement);
@@ -157,7 +153,6 @@ describe("ReactDOM", () => {
throw e;
}
});
-
it("readableStreamToArray(stream)", async () => {
const stream = await renderToReadableStream(reactElement);
gc();
@@ -170,7 +165,6 @@ describe("ReactDOM", () => {
expect(text.replaceAll("<!-- -->", "")).toBe(inputString);
gc();
});
-
it("readableStreamToArrayBuffer(stream)", async () => {
const stream = await renderToReadableStream(reactElement);
gc();
@@ -181,11 +175,14 @@ describe("ReactDOM", () => {
gc();
});
});
+ }
}
// for (let renderToReadableStream of [
// renderToReadableStreamBun,
- // renderToReadableStreamBrowser,
+ // // renderToReadableStreamBrowser,
// ]) {
+ // // there is an event loop bug that causes deadlocks
+ // // the bug is with `fetch`, not with the HTTP server
// for (let [inputString, reactElement] of fixtures) {
// describe(`${renderToReadableStream.name}(${inputString})`, () => {
// it("http server, 1 request", async () => {
@@ -208,41 +205,44 @@ describe("ReactDOM", () => {
// server?.stop();
// gc();
// }
+ // // expect(
+ // // heapStats().objectTypeCounts.ReadableHTTPResponseSinkController ?? 0
+ // // ).toBe(0);
// });
- // const count = 4;
- // it(`http server, ${count} requests`, async () => {
- // var server;
- // try {
- // server = serve({
- // port: port++,
- // async fetch(req) {
- // return new Response(await renderToReadableStream(reactElement));
- // },
- // });
- // var total = 0;
- // gc();
- // while (total++ < count) {
- // var attempt = total;
- // const response = await fetch(
- // "http://localhost:" + server.port + "/"
- // );
- // gc();
- // const result = await response.text();
- // try {
- // expect(result.replaceAll("<!-- -->", "")).toBe(inputString);
- // } catch (e) {
- // e.message += "\nAttempt: " + attempt;
- // throw e;
- // }
+ // // const count = 4;
+ // // it(`http server, ${count} requests`, async () => {
+ // // var server;
+ // // try {
+ // // server = serve({
+ // // port: port++,
+ // // async fetch(req) {
+ // // return new Response(await renderToReadableStream(reactElement));
+ // // },
+ // // });
+ // // var total = 0;
+ // // gc();
+ // // while (total++ < count) {
+ // // var attempt = total;
+ // // const response = await fetch(
+ // // "http://localhost:" + server.port + "/"
+ // // );
+ // // gc();
+ // // const result = await response.text();
+ // // try {
+ // // expect(result.replaceAll("<!-- -->", "")).toBe(inputString);
+ // // } catch (e) {
+ // // e.message += "\nAttempt: " + attempt;
+ // // throw e;
+ // // }
- // gc();
- // }
- // } catch (e) {
- // throw e;
- // } finally {
- // server.stop();
- // }
- // });
+ // // gc();
+ // // }
+ // // } catch (e) {
+ // // throw e;
+ // // } finally {
+ // // server.stop();
+ // // }
+ // // });
// });
// }
// }