⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 283286 in webkit


Ignore:
Timestamp:
Sep 29, 2021, 5:19:07 PM (5 years ago)
Author:
basuke.suzuki@sony.com
Message:

[JSC] Add objectTypeCounts to JSGetMemoryUsageStatistics
https://bugs.webkit.org/show_bug.cgi?id=230957

Reviewed by Yusuke Suzuki.

  • API/JSBase.cpp: Added objectTypeCounts property

(JSGetMemoryUsageStatistics):

  • API/JSBasePrivate.h: Added description of objectTypeCounts property
  • jsc.cpp: Added memoryUsageStatistics() function
Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSBase.cpp

    r272980 r283286  
    205205    JSLockHolder locker(vm);
    206206
     207    auto typeCounts = vm.heap.objectTypeCounts();
     208    JSObject* objectTypeCounts = constructEmptyObject(globalObject);
     209    for (auto& it : *typeCounts)
     210        objectTypeCounts->putDirect(vm, Identifier::fromString(vm, it.key), jsNumber(it.value));
     211
    207212    JSObject* object = constructEmptyObject(globalObject);
    208213    object->putDirect(vm, Identifier::fromString(vm, "heapSize"), jsNumber(vm.heap.size()));
     
    213218    object->putDirect(vm, Identifier::fromString(vm, "globalObjectCount"), jsNumber(vm.heap.globalObjectCount()));
    214219    object->putDirect(vm, Identifier::fromString(vm, "protectedGlobalObjectCount"), jsNumber(vm.heap.protectedGlobalObjectCount()));
     220    object->putDirect(vm, Identifier::fromString(vm, "objectTypeCounts"), objectTypeCounts);
    215221
    216222    return toRef(object);
  • trunk/Source/JavaScriptCore/API/JSBasePrivate.h

    r271560 r283286  
    7272 globalObjectCount: current count of global GC objects
    7373 protectedGlobalObjectCount: current count of protected global GC objects
     74 objectTypeCounts: object with GC object types as keys and their current counts as values
    7475*/
    7576JS_EXPORT JSObjectRef JSGetMemoryUsageStatistics(JSContextRef ctx);
  • trunk/Source/JavaScriptCore/ChangeLog

    r283236 r283286  
     12021-09-29  Basuke Suzuki  <basuke.suzuki@sony.com>
     2
     3        [JSC] Add objectTypeCounts to JSGetMemoryUsageStatistics
     4        https://bugs.webkit.org/show_bug.cgi?id=230957
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * API/JSBase.cpp: Added objectTypeCounts property
     9        (JSGetMemoryUsageStatistics):
     10        * API/JSBasePrivate.h: Added description of objectTypeCounts property
     11        * jsc.cpp: Added memoryUsageStatistics() function
     12
    1132021-09-29  Yusuke Suzuki  <ysuzuki@apple.com>
    214
  • trunk/Source/JavaScriptCore/jsc.cpp

    r283062 r283286  
    2323#include "config.h"
    2424
     25#include "APICast.h"
    2526#include "ArrayBuffer.h"
    2627#include "BigIntConstructor.h"
     
    4546#include "JSArray.h"
    4647#include "JSArrayBuffer.h"
     48#include "JSBasePrivate.h"
    4749#include "JSBigInt.h"
    4850#include "JSFinalizationRegistry.h"
     
    286288static JSC_DECLARE_HOST_FUNCTION(functionEdenGC);
    287289static JSC_DECLARE_HOST_FUNCTION(functionHeapSize);
     290static JSC_DECLARE_HOST_FUNCTION(functionMemoryUsageStatistics);
    288291static JSC_DECLARE_HOST_FUNCTION(functionCreateMemoryFootprint);
    289292static JSC_DECLARE_HOST_FUNCTION(functionResetMemoryPeak);
     
    530533        addFunction(vm, "edenGC", functionEdenGC, 0);
    531534        addFunction(vm, "gcHeapSize", functionHeapSize, 0);
     535        addFunction(vm, "memoryUsageStatistics", functionMemoryUsageStatistics, 0);
    532536        addFunction(vm, "MemoryFootprint", functionCreateMemoryFootprint, 0);
    533537        addFunction(vm, "resetMemoryPeak", functionResetMemoryPeak, 0);
     
    14621466const ClassInfo JSCMemoryFootprint::s_info = { "MemoryFootprint", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCMemoryFootprint) };
    14631467
     1468JSC_DEFINE_HOST_FUNCTION(functionMemoryUsageStatistics, (JSGlobalObject* globalObject, CallFrame*))
     1469{
     1470    auto contextRef = toRef(globalObject);
     1471    return JSValue::encode(toJS(JSGetMemoryUsageStatistics(contextRef)));
     1472}
     1473
    14641474JSC_DEFINE_HOST_FUNCTION(functionCreateMemoryFootprint, (JSGlobalObject* globalObject, CallFrame*))
    14651475{
Note: See TracChangeset for help on using the changeset viewer.