This commit is contained in:
2026-02-22 20:48:17 -06:00
parent 012b507415
commit 62440d3ed6
8 changed files with 116 additions and 8 deletions

View File

@@ -1935,6 +1935,10 @@ int ctx_gc (JSContext *ctx, int allow_grow, size_t alloc_size) {
}
#endif
/* Fire GC hook if registered */
if (ctx->trace_hook && (ctx->trace_type & JS_HOOK_GC))
ctx->trace_hook(ctx, JS_HOOK_GC, NULL, ctx->trace_data);
/* Check memory limit — kill actor if heap exceeds cap */
if (ctx->heap_memory_limit > 0 && ctx->current_block_size > ctx->heap_memory_limit) {
#ifdef ACTOR_TRACE
@@ -11780,6 +11784,15 @@ void js_debug_sethook (JSContext *ctx, js_hook hook, int type, void *user) {
ctx->trace_data = user;
}
void js_debug_gethook (JSContext *ctx, js_hook *hook, int *type, void **user) {
if (hook) *hook = ctx->trace_hook;
if (type) *type = ctx->trace_type;
if (user) *user = ctx->trace_data;
}
size_t cell_ctx_heap_used (JSContext *ctx) {
return (size_t)(ctx->heap_free - ctx->heap_base);
}
/* Public API: get stack trace as JS array of {fn, file, line, col} objects.
Does NOT clear reg_current_frame — caller is responsible if needed.