From 26c9a577bb6eead72f79c15546e4ae01da63a7ea Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Thu, 1 May 2025 11:53:49 -0500 Subject: [PATCH] clean up --- quickjs.c | 21 ++++++--------------- quickjs.h | 4 +--- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/quickjs.c b/quickjs.c index 143c07c..5a75542 100644 --- a/quickjs.c +++ b/quickjs.c @@ -1275,7 +1275,7 @@ static void js_trigger_gc(JSRuntime *rt, size_t size) fprintf(dumpout, "GC: size=%" PRIu64 "\n", (uint64_t)rt->malloc_state.malloc_size); #endif - JS_RunGC(rt, NULL); + JS_RunGC(rt); rt->malloc_gc_threshold = rt->malloc_state.malloc_size + (rt->malloc_state.malloc_size >> 1); } @@ -5060,7 +5060,7 @@ static __maybe_unused void JS_DumpShapes(JSRuntime *rt) fprintf(dumpout, "}\n"); } -JSShape *JS_ObjectShape(JSContext *js, JSValue v) +JSShape *JS_ObjectShape(JSContext *js, JSValueConst v) { JSObject *p = JS_VALUE_GET_OBJ(v); if (!p || !p->shape) return NULL; @@ -6282,9 +6282,6 @@ static void JS_RunGCInternal(JSRuntime *rt, BOOL remove_weak_objects) gc_remove_weak_objects(rt); } - double n = stm_now(); - double size = rt->malloc_state.malloc_size; - /* decrement the reference of the children of each object. mark = 1 after this pass. */ gc_decref(rt); @@ -6307,8 +6304,6 @@ static void JS_RunGCInternal(JSRuntime *rt, BOOL remove_weak_objects) }*/ /* free the GC objects in a cycle */ gc_free_cycles(rt); - - return ret; } void JS_RunGC(JSRuntime *rt) @@ -7005,11 +7000,6 @@ const char *get_func_name(JSContext *ctx, JSValueConst func) return JS_ToCString(ctx, val); } -int js_fn_linenum(JSContext *js, JSValueConst fn) -{ - return JS_VALUE_GET_OBJ(fn)->u.func.function_bytecode->debug.line_num; -} - JSAtom js_fn_filename(JSContext *js, JSValueConst fn) { return JS_VALUE_GET_OBJ(fn)->u.func.function_bytecode->debug.filename; @@ -55014,7 +55004,7 @@ void js_debug_info(JSContext *js, JSValue fn, js_debug *dbg) dbg->closure_n = b->closure_var_count; dbg->param_n = b->arg_count; dbg->vararg = 1; - dbg->line = b->debug.line_num; +// dbg->line = b->debug.line_num; dbg->source = b->debug.source; dbg->srclen = b->debug.source_len; break; @@ -55066,7 +55056,8 @@ JSValue js_debugger_build_backtrace(JSContext *ctx, const uint8_t *cur_pc) b = p->u.func.function_bytecode; if (b->has_debug) { const uint8_t *pc = sf != ctx->rt->current_stack_frame || !cur_pc ? sf->cur_pc : cur_pc; - line_num1 = find_line_num(ctx, b, pc - b->byte_code_buf - 1); + int col_num; + line_num1 = find_line_num(ctx, b, pc - b->byte_code_buf - 1, &col_num); JS_SetPropertyStr(ctx, current_frame, "filename", JS_AtomToString(ctx, b->debug.filename)); if (line_num1 != -1) JS_SetPropertyStr(ctx, current_frame, "line", JS_NewUint32(ctx, line_num1)); @@ -55089,7 +55080,7 @@ JSValue js_debugger_fn_info(JSContext *ctx, JSValue fn) JSFunctionBytecode *b = f->u.func.function_bytecode; if (b->has_debug) { JS_SetPropertyStr(ctx, ret, "filename", JS_AtomToString(ctx, b->debug.filename)); - JS_SetPropertyStr(ctx, ret, "line", JS_NewInt32(ctx,b->debug.line_num)); +// JS_SetPropertyStr(ctx, ret, "line", JS_NewInt32(ctx,b->debug.line_num)); } done: return ret; diff --git a/quickjs.h b/quickjs.h index 48a00ee..a250c67 100644 --- a/quickjs.h +++ b/quickjs.h @@ -323,7 +323,6 @@ typedef struct JSValue { #define JS_NAN (JSValue){ .u.float64 = JS_FLOAT64_NAN, JS_TAG_FLOAT64 } -int js_fn_linenum(JSContext *js, JSValueConst fn); JSAtom js_fn_filename(JSContext *js, JSValueConst fn); const char *get_func_name(JSContext *js, JSValueConst fn); @@ -460,7 +459,7 @@ void *JS_GetRuntimeOpaque(JSRuntime *rt); void JS_SetRuntimeOpaque(JSRuntime *rt, void *opaque); typedef void JS_MarkFunc(JSRuntime *rt, JSGCObjectHeader *gp); void JS_MarkValue(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); -JSValue JS_RunGC(JSRuntime *rt, JSContext *ctx); +void JS_RunGC(JSRuntime *rt); JS_BOOL JS_IsLiveObject(JSRuntime *rt, JSValueConst obj); JSValue JS_NewSymbol(JSContext *ctx, const char *description, int is_global); @@ -1226,7 +1225,6 @@ JSValue js_debugger_fn_info(JSContext *ctx, JSValue fn); JSValue js_debugger_backtrace_fns(JSContext *ctx, const uint8_t *cur_pc); uint32_t js_debugger_stack_depth(JSContext *ctx); JSValue js_dump_value(JSContext *ctx, JSValue v); -JSValue js_dump_object(JSContext *ctx, JSGCObjectHeader *p); JSValue js_dump_leaks(JSContext *ctx); JSValue js_dump_stack_info(JSContext *ctx);