@@ -363,7 +363,7 @@ JSC_DEFINE_HOST_FUNCTION(functionHeapSpaceStatistics,
363363{
364364 VM& vm = globalObject->vm ();
365365 JSLockHolder lock (vm);
366-
366+ auto scope = DECLARE_THROW_SCOPE (vm);
367367 // In JSC, we don't have the same heap space segmentation as V8
368368 // V8 has: new_space, old_space, code_space, map_space, large_object_space, etc.
369369 // JSC has a simpler structure, so we'll create a compatible representation
@@ -374,10 +374,12 @@ JSC_DEFINE_HOST_FUNCTION(functionHeapSpaceStatistics,
374374 }
375375
376376 JSArray* result = constructEmptyArray (globalObject, nullptr );
377+ RETURN_IF_EXCEPTION (scope, encodedJSValue ());
377378
378379 // Create a single "heap" space that represents JSC's heap
379380 // This provides basic compatibility with V8's getHeapSpaceStatistics API
380381 JSObject* heapSpace = constructEmptyObject (globalObject, globalObject->objectPrototype ());
382+ RETURN_IF_EXCEPTION (scope, encodedJSValue ());
381383
382384 size_t heapCapacity = vm.heap .capacity ();
383385 size_t heapUsed = vm.heap .size ();
@@ -395,6 +397,7 @@ JSC_DEFINE_HOST_FUNCTION(functionHeapSpaceStatistics,
395397 jsNumber (heapCapacity));
396398
397399 result->putDirectIndex (globalObject, 0 , heapSpace);
400+ RETURN_IF_EXCEPTION (scope, encodedJSValue ());
398401
399402 // V8 compatibility: Add placeholder spaces that V8 has but JSC doesn't
400403 const char * v8SpaceNames[] = {
@@ -413,6 +416,7 @@ JSC_DEFINE_HOST_FUNCTION(functionHeapSpaceStatistics,
413416
414417 for (size_t i = 0 ; i < sizeof (v8SpaceNames) / sizeof (v8SpaceNames[0 ]); i++) {
415418 JSObject* space = constructEmptyObject (globalObject);
419+ RETURN_IF_EXCEPTION (scope, encodedJSValue ());
416420 space->putDirect (vm, Identifier::fromString (vm, " spaceName" _s),
417421 jsString (vm, String::fromUTF8 (v8SpaceNames[i])));
418422 space->putDirect (vm, Identifier::fromString (vm, " spaceSize" _s),
@@ -425,9 +429,10 @@ JSC_DEFINE_HOST_FUNCTION(functionHeapSpaceStatistics,
425429 jsNumber (0 ));
426430
427431 result->putDirectIndex (globalObject, i + 1 , space);
432+ RETURN_IF_EXCEPTION (scope, encodedJSValue ());
428433 }
429434
430- return JSValue::encode (result);
435+ RELEASE_AND_RETURN (scope, JSValue::encode (result) );
431436}
432437
433438
@@ -998,7 +1003,7 @@ JSC_DEFINE_HOST_FUNCTION(functionPercentAvailableMemoryInUse, (JSGlobalObject *
9981003 getRandomSeed functionGetRandomSeed Function 0
9991004 heapSize functionHeapSize Function 0
10001005 heapStats functionMemoryUsageStatistics Function 0
1001- heapSpaceStats functionHeapSpaceStatistic
1006+ heapSpaceStats functionHeapSpaceStatistics Function 0
10021007 startSamplingProfiler functionStartSamplingProfiler Function 0
10031008 samplingProfilerStackTraces functionSamplingProfilerStackTraces Function 0
10041009 noInline functionNeverInlineFunction Function 0
0 commit comments