mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Move Bun__JSRequest__calculateEstimatedByteSize earlier (#22993)
### What does this PR do? ### How did you verify your code works?
This commit is contained in:
@@ -21,6 +21,8 @@ static JSC_DECLARE_CUSTOM_GETTER(jsJSBunRequestGetCookies);
|
||||
|
||||
static JSC_DECLARE_HOST_FUNCTION(jsJSBunRequestClone);
|
||||
|
||||
extern "C" void Bun__JSRequest__calculateEstimatedByteSize(void* requestPtr);
|
||||
|
||||
static const HashTableValue JSBunRequestPrototypeValues[] = {
|
||||
{ "params"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, jsJSBunRequestGetParams, nullptr } },
|
||||
{ "cookies"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, jsJSBunRequestGetCookies, nullptr } },
|
||||
@@ -29,6 +31,10 @@ static const HashTableValue JSBunRequestPrototypeValues[] = {
|
||||
|
||||
JSBunRequest* JSBunRequest::create(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr, JSObject* params)
|
||||
{
|
||||
// Do this **extremely** early, before we create the JSValue.
|
||||
// We do not want to risk the GC running before this function is called.
|
||||
Bun__JSRequest__calculateEstimatedByteSize(sinkPtr);
|
||||
|
||||
JSBunRequest* ptr = new (NotNull, JSC::allocateCell<JSBunRequest>(vm)) JSBunRequest(vm, structure, sinkPtr);
|
||||
ptr->finishCreation(vm, params);
|
||||
return ptr;
|
||||
@@ -124,13 +130,12 @@ JSBunRequest::JSBunRequest(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr
|
||||
{
|
||||
}
|
||||
extern "C" size_t Request__estimatedSize(void* requestPtr);
|
||||
extern "C" void Bun__JSRequest__calculateEstimatedByteSize(void* requestPtr);
|
||||
|
||||
void JSBunRequest::finishCreation(JSC::VM& vm, JSObject* params)
|
||||
{
|
||||
Base::finishCreation(vm);
|
||||
m_params.setMayBeNull(vm, this, params);
|
||||
m_cookies.clear();
|
||||
Bun__JSRequest__calculateEstimatedByteSize(this->wrapped());
|
||||
|
||||
auto size = Request__estimatedSize(this->wrapped());
|
||||
vm.heap.reportExtraMemoryAllocated(this, size);
|
||||
|
||||
Reference in New Issue
Block a user