aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/BunJSCModule.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-02 02:35:43 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-02 02:35:43 -0700
commit6f3a092564e25a62d04fc45555be6987c8d715e2 (patch)
tree0fa99542c8604398dd0cfe923cce7e3a3197998d /src/bun.js/bindings/BunJSCModule.cpp
parentd1ad1089bc6b01e8a63f654abf4197b81dee06d8 (diff)
downloadbun-6f3a092564e25a62d04fc45555be6987c8d715e2.tar.gz
bun-6f3a092564e25a62d04fc45555be6987c8d715e2.tar.zst
bun-6f3a092564e25a62d04fc45555be6987c8d715e2.zip
[bun:jsc] Add `protectedObjectTypeCounts`, disallow gc
Diffstat (limited to 'src/bun.js/bindings/BunJSCModule.cpp')
-rw-r--r--src/bun.js/bindings/BunJSCModule.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/bun.js/bindings/BunJSCModule.cpp b/src/bun.js/bindings/BunJSCModule.cpp
index b81f2db93..dd5c4b062 100644
--- a/src/bun.js/bindings/BunJSCModule.cpp
+++ b/src/bun.js/bindings/BunJSCModule.cpp
@@ -197,8 +197,21 @@ const ClassInfo JSCMemoryFootprint::s_info = { "MemoryFootprint"_s, &Base::s_inf
JSC_DECLARE_HOST_FUNCTION(functionMemoryUsageStatistics);
JSC_DEFINE_HOST_FUNCTION(functionMemoryUsageStatistics, (JSGlobalObject * globalObject, CallFrame*))
{
- auto contextRef = toRef(globalObject);
- return JSValue::encode(toJS(JSGetMemoryUsageStatistics(contextRef)));
+
+ auto& vm = globalObject->vm();
+ JSC::DisallowGC disallowGC;
+
+ // this is a C API function
+ auto* stats = toJS(JSGetMemoryUsageStatistics(toRef(globalObject)));
+
+ // This is missing from the C API
+ JSC::JSObject* protectedCounts = constructEmptyObject(globalObject);
+ auto typeCounts = *vm.heap.protectedObjectTypeCounts();
+ for (auto& it : typeCounts)
+ protectedCounts->putDirect(vm, Identifier::fromLatin1(vm, it.key), jsNumber(it.value));
+
+ stats->putDirect(vm, Identifier::fromLatin1(vm, "protectedObjectTypeCounts"_s), protectedCounts);
+ return JSValue::encode(stats);
}
JSC_DECLARE_HOST_FUNCTION(functionCreateMemoryFootprint);