aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-28 14:36:44 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-28 14:36:44 -0700
commita1b4dc42cb863eedbbe6735cb29a3d6941e02e04 (patch)
tree65ce376ceeb0615df9b960384d6b67dea5f935fd /src/bun.js
parent5ae5125919894d5aa8011eccac5c627777136c0c (diff)
downloadbun-a1b4dc42cb863eedbbe6735cb29a3d6941e02e04.tar.gz
bun-a1b4dc42cb863eedbbe6735cb29a3d6941e02e04.tar.zst
bun-a1b4dc42cb863eedbbe6735cb29a3d6941e02e04.zip
Implement `reportExtraMemoryVisited` and `reportExtraMemoryAllocated` in bindings
Diffstat (limited to 'src/bun.js')
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.cpp55
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.h57
-rw-r--r--src/bun.js/bindings/generated_classes.zig10
-rw-r--r--src/bun.js/scripts/generate-classes.ts1
4 files changed, 89 insertions, 34 deletions
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp
index aefc1f43c..305387b12 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.cpp
+++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp
@@ -121,12 +121,19 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__exitedGetterWrap, (JSGlobalObject
Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSC::EncodedJSValue result = SubprocessPrototype__getExited(thisObject->wrapped(), globalObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_exited.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ SubprocessPrototype__getExited(thisObject->wrapped(), globalObject)
+ );
RETURN_IF_EXCEPTION(throwScope, {});
- RELEASE_AND_RETURN(throwScope, result);
+ thisObject->m_exited.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
-
+
JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__killCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
{
@@ -315,6 +322,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSubprocessConstructor::construct(
}
JSSubprocess* instance = JSSubprocess::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -323,6 +331,7 @@ extern "C" EncodedJSValue Subprocess__create(Zig::GlobalObject* globalObject, vo
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSSubprocessStructure();
JSSubprocess* instance = JSSubprocess::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -405,6 +414,8 @@ void JSSubprocess::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSSubprocess* thisObject = jsCast<JSSubprocess*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
+
+ visitor.append(thisObject->m_exited);
visitor.append(thisObject->m_stderr);
visitor.append(thisObject->m_stdin);
visitor.append(thisObject->m_stdout);
@@ -560,6 +571,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA1Constructor::construct(JSC::J
}
JSSHA1* instance = JSSHA1::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -568,6 +580,7 @@ extern "C" EncodedJSValue SHA1__create(Zig::GlobalObject* globalObject, void* pt
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSSHA1Structure();
JSSHA1* instance = JSSHA1::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -792,6 +805,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSMD5Constructor::construct(JSC::JS
}
JSMD5* instance = JSMD5::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -800,6 +814,7 @@ extern "C" EncodedJSValue MD5__create(Zig::GlobalObject* globalObject, void* ptr
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSMD5Structure();
JSMD5* instance = JSMD5::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -1024,6 +1039,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSMD4Constructor::construct(JSC::JS
}
JSMD4* instance = JSMD4::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -1032,6 +1048,7 @@ extern "C" EncodedJSValue MD4__create(Zig::GlobalObject* globalObject, void* ptr
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSMD4Structure();
JSMD4* instance = JSMD4::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -1256,6 +1273,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA224Constructor::construct(JSC:
}
JSSHA224* instance = JSSHA224::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -1264,6 +1282,7 @@ extern "C" EncodedJSValue SHA224__create(Zig::GlobalObject* globalObject, void*
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSSHA224Structure();
JSSHA224* instance = JSSHA224::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -1488,6 +1507,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA512Constructor::construct(JSC:
}
JSSHA512* instance = JSSHA512::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -1496,6 +1516,7 @@ extern "C" EncodedJSValue SHA512__create(Zig::GlobalObject* globalObject, void*
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSSHA512Structure();
JSSHA512* instance = JSSHA512::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -1720,6 +1741,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA384Constructor::construct(JSC:
}
JSSHA384* instance = JSSHA384::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -1728,6 +1750,7 @@ extern "C" EncodedJSValue SHA384__create(Zig::GlobalObject* globalObject, void*
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSSHA384Structure();
JSSHA384* instance = JSSHA384::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -1952,6 +1975,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA256Constructor::construct(JSC:
}
JSSHA256* instance = JSSHA256::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -1960,6 +1984,7 @@ extern "C" EncodedJSValue SHA256__create(Zig::GlobalObject* globalObject, void*
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSSHA256Structure();
JSSHA256* instance = JSSHA256::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -2184,6 +2209,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA512_256Constructor::construct(
}
JSSHA512_256* instance = JSSHA512_256::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -2192,6 +2218,7 @@ extern "C" EncodedJSValue SHA512_256__create(Zig::GlobalObject* globalObject, vo
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSSHA512_256Structure();
JSSHA512_256* instance = JSSHA512_256::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -2410,6 +2437,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSTextDecoderConstructor::construct
}
JSTextDecoder* instance = JSTextDecoder::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -2418,6 +2446,7 @@ extern "C" EncodedJSValue TextDecoder__create(Zig::GlobalObject* globalObject, v
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSTextDecoderStructure();
JSTextDecoder* instance = JSTextDecoder::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -2500,6 +2529,7 @@ void JSTextDecoder::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSTextDecoder* thisObject = jsCast<JSTextDecoder*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
+
visitor.append(thisObject->m_encoding);
}
@@ -2904,6 +2934,10 @@ void JSRequestPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* global
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
}
+extern "C" size_t Request__estimatedSize(void* ptr);
+
+
+
void JSRequestConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype)
{
Base::finishCreation(vm, 0, "Request"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -2947,6 +2981,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSRequestConstructor::construct(JSC
}
JSRequest* instance = JSRequest::create(vm, globalObject, structure, ptr);
+ vm.heap.reportExtraMemoryAllocated(Request__estimatedSize(instance->wrapped()));
return JSValue::encode(instance);
}
@@ -2955,6 +2990,7 @@ extern "C" EncodedJSValue Request__create(Zig::GlobalObject* globalObject, void*
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSRequestStructure();
JSRequest* instance = JSRequest::create(vm, globalObject, structure, ptr);
+ vm.heap.reportExtraMemoryAllocated(Request__estimatedSize(ptr));
return JSValue::encode(instance);
}
@@ -3037,6 +3073,9 @@ void JSRequest::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSRequest* thisObject = jsCast<JSRequest*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
+ if (auto* ptr = thisObject->wrapped()) {
+visitor.reportExtraMemoryVisited(Request__estimatedSize(ptr));
+}
visitor.append(thisObject->m_body);
visitor.append(thisObject->m_headers);
visitor.append(thisObject->m_url);
@@ -3360,6 +3399,7 @@ void JSResponsePrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globa
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
}
+extern "C" size_t Response__estimatedSize(void* ptr);
extern "C" JSC_DECLARE_HOST_FUNCTION(ResponseClass__constructError);
extern "C" JSC_DECLARE_HOST_FUNCTION(ResponseClass__constructJSON);
extern "C" JSC_DECLARE_HOST_FUNCTION(ResponseClass__constructRedirect);
@@ -3414,6 +3454,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSResponseConstructor::construct(JS
}
JSResponse* instance = JSResponse::create(vm, globalObject, structure, ptr);
+ vm.heap.reportExtraMemoryAllocated(Response__estimatedSize(instance->wrapped()));
return JSValue::encode(instance);
}
@@ -3422,6 +3463,7 @@ extern "C" EncodedJSValue Response__create(Zig::GlobalObject* globalObject, void
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSResponseStructure();
JSResponse* instance = JSResponse::create(vm, globalObject, structure, ptr);
+ vm.heap.reportExtraMemoryAllocated(Response__estimatedSize(ptr));
return JSValue::encode(instance);
}
@@ -3504,6 +3546,9 @@ void JSResponse::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSResponse* thisObject = jsCast<JSResponse*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
+ if (auto* ptr = thisObject->wrapped()) {
+visitor.reportExtraMemoryVisited(Response__estimatedSize(ptr));
+}
visitor.append(thisObject->m_body);
visitor.append(thisObject->m_headers);
visitor.append(thisObject->m_statusText);
@@ -3773,6 +3818,7 @@ JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSBlobConstructor::construct(JSC::J
}
JSBlob* instance = JSBlob::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
@@ -3781,6 +3827,7 @@ extern "C" EncodedJSValue Blob__create(Zig::GlobalObject* globalObject, void* pt
auto &vm = globalObject->vm();
JSC::Structure* structure = globalObject->JSBlobStructure();
JSBlob* instance = JSBlob::create(vm, globalObject, structure, ptr);
+
return JSValue::encode(instance);
}
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h
index 22ffe60d7..95ccf0b10 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses.h
@@ -5,8 +5,6 @@
#include "root.h"
-#include "JSEventEmitter.h"
-
namespace Zig {
}
@@ -17,9 +15,9 @@ namespace WebCore {
using namespace Zig;
using namespace JSC;
-class JSSubprocess final : public JSDestructibleObject {
+class JSSubprocess final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSSubprocess* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -68,7 +66,8 @@ class JSSubprocess final : public JSDestructibleObject {
DECLARE_VISIT_CHILDREN;
- mutable JSC::WriteBarrier<JSC::Unknown> m_stderr;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_exited;
+mutable JSC::WriteBarrier<JSC::Unknown> m_stderr;
mutable JSC::WriteBarrier<JSC::Unknown> m_stdin;
mutable JSC::WriteBarrier<JSC::Unknown> m_stdout;
};
@@ -143,9 +142,9 @@ class JSSubprocessPrototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSubprocessPrototype* prototype);
};
-class JSSHA1 final : public JSDestructibleObject {
+class JSSHA1 final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSSHA1* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -267,9 +266,9 @@ class JSSHA1Prototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype);
};
-class JSMD5 final : public JSDestructibleObject {
+class JSMD5 final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSMD5* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -391,9 +390,9 @@ class JSMD5Prototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype);
};
-class JSMD4 final : public JSDestructibleObject {
+class JSMD4 final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSMD4* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -515,9 +514,9 @@ class JSMD4Prototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype);
};
-class JSSHA224 final : public JSDestructibleObject {
+class JSSHA224 final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSSHA224* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -639,9 +638,9 @@ class JSSHA224Prototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype);
};
-class JSSHA512 final : public JSDestructibleObject {
+class JSSHA512 final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSSHA512* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -763,9 +762,9 @@ class JSSHA512Prototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype);
};
-class JSSHA384 final : public JSDestructibleObject {
+class JSSHA384 final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSSHA384* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -887,9 +886,9 @@ class JSSHA384Prototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype);
};
-class JSSHA256 final : public JSDestructibleObject {
+class JSSHA256 final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSSHA256* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -1011,9 +1010,9 @@ class JSSHA256Prototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype);
};
-class JSSHA512_256 final : public JSDestructibleObject {
+class JSSHA512_256 final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSSHA512_256* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -1135,9 +1134,9 @@ class JSSHA512_256Prototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype);
};
-class JSTextDecoder final : public JSDestructibleObject {
+class JSTextDecoder final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSTextDecoder* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -1259,9 +1258,9 @@ class JSTextDecoderPrototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype);
};
-class JSRequest final : public JSDestructibleObject {
+class JSRequest final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSRequest* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -1385,9 +1384,9 @@ class JSRequestPrototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype);
};
-class JSResponse final : public JSDestructibleObject {
+class JSResponse final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSResponse* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
@@ -1512,9 +1511,9 @@ class JSResponsePrototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype);
};
-class JSBlob final : public JSDestructibleObject {
+class JSBlob final : public JSC::JSDestructibleObject {
public:
- using Base = JSDestructibleObject;
+ using Base = JSC::JSDestructibleObject;
static JSBlob* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
DECLARE_EXPORT_INFO;
diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig
index a05d6a958..f26966de0 100644
--- a/src/bun.js/bindings/generated_classes.zig
+++ b/src/bun.js/bindings/generated_classes.zig
@@ -837,6 +837,10 @@ pub const JSRequest = struct {
extern fn Request__dangerouslySetPtr(JSC.JSValue, ?*Request) bool;
comptime {
+ if (@TypeOf(Request.estimatedSize) != (fn (*Request) callconv(.C) usize)) {
+ @compileLog("Request.estimatedSize is not a size function");
+ }
+
if (@TypeOf(Request.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Request)) {
@compileLog("Request.constructor is not a constructor");
}
@@ -897,6 +901,7 @@ pub const JSRequest = struct {
if (!JSC.is_bindgen) {
@export(Request.constructor, .{ .name = "RequestClass__construct" });
@export(Request.doClone, .{ .name = "RequestPrototype__doClone" });
+ @export(Request.estimatedSize, .{ .name = "Request__estimatedSize" });
@export(Request.finalize, .{ .name = "RequestClass__finalize" });
@export(Request.getArrayBuffer, .{ .name = "RequestPrototype__getArrayBuffer" });
@export(Request.getBlob, .{ .name = "RequestPrototype__getBlob" });
@@ -964,6 +969,10 @@ pub const JSResponse = struct {
extern fn Response__dangerouslySetPtr(JSC.JSValue, ?*Response) bool;
comptime {
+ if (@TypeOf(Response.estimatedSize) != (fn (*Response) callconv(.C) usize)) {
+ @compileLog("Response.estimatedSize is not a size function");
+ }
+
if (@TypeOf(Response.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Response)) {
@compileLog("Response.constructor is not a constructor");
}
@@ -1018,6 +1027,7 @@ pub const JSResponse = struct {
@export(Response.constructor, .{ .name = "ResponseClass__construct" });
@export(Response.constructRedirect, .{ .name = "ResponseClass__constructRedirect" });
@export(Response.doClone, .{ .name = "ResponsePrototype__doClone" });
+ @export(Response.estimatedSize, .{ .name = "Response__estimatedSize" });
@export(Response.finalize, .{ .name = "ResponseClass__finalize" });
@export(Response.getArrayBuffer, .{ .name = "ResponsePrototype__getArrayBuffer" });
@export(Response.getBlob, .{ .name = "ResponsePrototype__getBlob" });
diff --git a/src/bun.js/scripts/generate-classes.ts b/src/bun.js/scripts/generate-classes.ts
index e818c96e5..55627bcc4 100644
--- a/src/bun.js/scripts/generate-classes.ts
+++ b/src/bun.js/scripts/generate-classes.ts
@@ -773,7 +773,6 @@ function generateClassHeader(typeName, obj) {
function generateClassImpl(typeName, obj: ClassDefinition) {
const { klass: fields, finalize, proto, construct, estimatedSize } = obj;
const name = className(typeName);
- var symbolName = classSymbolName;
const DEFINE_VISIT_CHILDREN_LIST = [
...Object.entries(fields),