Skip to content

Commit

Permalink
Add JS_DumpObjects support
Browse files Browse the repository at this point in the history
  • Loading branch information
HarlonWang committed Sep 18, 2024
1 parent 6e2e68f commit 0d6f3d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
24 changes: 13 additions & 11 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2295,17 +2295,7 @@ void JS_FreeContext(JSContext *ctx)
JS_DumpShapes(ctx->rt);
#endif
#ifdef DUMP_OBJECTS
{
struct list_head *el;
JSGCObjectHeader *p;
printf("JSObjects: {\n");
JS_DumpObjectHeader(ctx->rt);
list_for_each(el, &rt->gc_obj_list) {
p = list_entry(el, JSGCObjectHeader, link);
JS_DumpGCObject(rt, p);
}
printf("}\n");
}
JS_DumpObjects(ctx-rt);
#endif
#ifdef DUMP_MEM
{
Expand Down Expand Up @@ -6378,6 +6368,18 @@ void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt)
}
}

void JS_DumpObjects(JSRuntime *rt){
struct list_head *el;
JSGCObjectHeader *p;
printf("JSObjects: {\n");
JS_DumpObjectHeader(ctx->rt);
list_for_each(el, &rt->gc_obj_list) {
p = list_entry(el, JSGCObjectHeader, link);
JS_DumpGCObject(rt, p);
}
printf("}\n");
}

JSValue JS_GetGlobalObject(JSContext *ctx)
{
return JS_DupValue(ctx, ctx->global_obj);
Expand Down
1 change: 1 addition & 0 deletions quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ typedef struct JSMemoryUsage {

void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s);
void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt);
void JS_DumpObjects(JSRuntime *rt);

/* atom support */
#define JS_ATOM_NULL 0
Expand Down

0 comments on commit 0d6f3d8

Please sign in to comment.