From 69b032d3dc0a23462e828788b5a22b0f12cc5421 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Mon, 2 Feb 2026 23:02:50 -0600 Subject: [PATCH] rm gc --- debug/js.c | 2 -- source/quickjs.c | 35 ----------------------------------- source/quickjs.h | 1 - 3 files changed, 38 deletions(-) diff --git a/debug/js.c b/debug/js.c index 8e092509..3d991c02 100644 --- a/debug/js.c +++ b/debug/js.c @@ -1,6 +1,5 @@ #include "cell.h" -JSC_CCALL(os_gc, JS_RunGC(JS_GetRuntime(js)) ) JSC_CCALL(os_mem_limit, JS_SetMemoryLimit(JS_GetRuntime(js), js2number(js,argv[0]))) JSC_CCALL(os_max_stacksize, JS_SetMaxStackSize(JS_GetRuntime(js), js2number(js,argv[0]))) @@ -91,7 +90,6 @@ static const JSCFunctionListEntry js_js_funcs[] = { MIST_FUNC_DEF(os, calc_mem, 0), MIST_FUNC_DEF(os, mem_limit, 1), MIST_FUNC_DEF(os, max_stacksize, 1), - MIST_FUNC_DEF(os, gc, 0), MIST_FUNC_DEF(os, eval, 2), MIST_FUNC_DEF(js, compile, 2), MIST_FUNC_DEF(js, eval_compile, 1), diff --git a/source/quickjs.c b/source/quickjs.c index 11bd778e..7f117039 100644 --- a/source/quickjs.c +++ b/source/quickjs.c @@ -85,8 +85,6 @@ // #define DUMP_GC /* dump objects freed by the garbage collector */ // #define DUMP_GC_FREE -/* dump objects leaking when freeing the runtime */ -// #define DUMP_LEAKS 1 /* dump memory usage before running the garbage collector */ // #define DUMP_MEM // #define DUMP_OBJECTS /* dump objects in JS_FreeContext */ @@ -367,13 +365,6 @@ struct JSRuntime { /* Interrupt handler for checking execution limits */ JSInterruptHandler *interrupt_handler; void *interrupt_opaque; - - /* Primary context (for single-context runtimes) */ - JSContext *js; - -#ifdef DUMP_LEAKS - struct list_head string_list; -#endif }; struct JSClass { @@ -1028,14 +1019,6 @@ void *js_realloc (JSContext *ctx, void *ptr, size_t size) { /* Forward declaration for ctx_gc */ static int ctx_gc (JSContext *ctx); -/* Run GC on a specific context */ -void JS_RunGC (JSRuntime *rt) { - JSContext *ctx = rt->js; - if (ctx) { - ctx_gc (ctx); - } -} - /* JS_MarkValue - mark a value during GC traversal. With copying GC, this is a no-op as we discover live objects by tracing. */ void JS_MarkValue (JSRuntime *rt, JSValue val, JS_MarkFunc *mark_func) { @@ -2320,10 +2303,6 @@ JSRuntime *JS_NewRuntime (void) { if (!rt) return NULL; memset (rt, 0, sizeof (*rt)); -#ifdef DUMP_LEAKS - init_list_head (&rt->string_list); -#endif - /* create the object, array and function classes */ if (init_class_range (rt, js_std_class_def, JS_CLASS_OBJECT, countof (js_std_class_def)) < 0) @@ -2399,7 +2378,6 @@ void JS_FreeRuntime (JSRuntime *rt) { } JSContext *JS_NewContextRaw (JSRuntime *rt) { - assert (!rt->js); JSContext *ctx; int i; @@ -2475,7 +2453,6 @@ JSContext *JS_NewContextRaw (JSRuntime *rt) { ctx->heap_end = ctx->heap_base + ctx->current_block_size; JS_AddIntrinsicBasicObjects (ctx); - rt->js = ctx; return ctx; } @@ -2902,16 +2879,6 @@ static JSValue pretext_end (JSContext *ctx, JSText *s) { js_free (ctx, s); return JS_KEY_empty; } - int cap = (int)objhdr_cap56 (s->hdr); - if (len < cap) { - /* Try to shrink, but OK if realloc fails */ - size_t new_size = sizeof (JSText) + ((len + 1) / 2) * sizeof (uint64_t); - JSText *new_str = js_realloc_rt (s, new_size); - if (new_str) s = new_str; - } -#ifdef DUMP_LEAKS - list_add_tail (&s->link, &ctx->rt->string_list); -#endif /* Set final length in capacity field and clear length for hash storage */ s->hdr = objhdr_set_cap56 (s->hdr, len); s->length = 0; @@ -25768,5 +25735,3 @@ JSValue js_math_cycles_use (JSContext *ctx) { JS_SetPropertyFunctionList (ctx, obj, js_math_cycles_funcs, countof (js_math_cycles_funcs)); return obj; } - -JSContext *JS_GetContext (JSRuntime *rt) { return rt->js; } diff --git a/source/quickjs.h b/source/quickjs.h index acf44228..23becdd5 100644 --- a/source/quickjs.h +++ b/source/quickjs.h @@ -388,7 +388,6 @@ void JS_SetRuntimeOpaque (JSRuntime *rt, void *opaque); typedef void JS_MarkFunc (JSRuntime *rt, JSGCObjectHeader *gp); /* JS_MarkValue is a no-op with copying GC (values are traced from roots) */ void JS_MarkValue (JSRuntime *rt, JSValue val, JS_MarkFunc *mark_func); -void JS_RunGC (JSRuntime *rt); JS_BOOL JS_IsLiveObject (JSRuntime *rt, JSValue obj); JSContext *JS_NewContext (JSRuntime *rt);