correct caching

This commit is contained in:
2026-02-23 13:37:11 -06:00
parent 99fb575c9c
commit d066ab03cd
7 changed files with 184 additions and 95 deletions

View File

@@ -2071,6 +2071,7 @@ JSContext *JS_NewContextRawWithHeapSize (JSRuntime *rt, size_t heap_size) {
ctx->suspended_pc = 0;
ctx->vm_call_depth = 0;
ctx->heap_memory_limit = 0;
ctx->actor_label = NULL;
JS_AddGCRef(ctx, &ctx->suspended_frame_ref);
ctx->suspended_frame_ref.val = JS_NULL;
@@ -3297,7 +3298,20 @@ JS_RaiseDisrupt (JSContext *ctx, const char *fmt, ...) {
/* Log to "memory" channel + disrupt. Skips JS callback (can't allocate). */
JSValue JS_RaiseOOM (JSContext *ctx) {
fprintf (stderr, "out of memory\n");
size_t used = (size_t)((uint8_t *)ctx->heap_free - (uint8_t *)ctx->heap_base);
size_t block = ctx->current_block_size;
size_t limit = ctx->heap_memory_limit;
const char *label = ctx->actor_label;
if (limit > 0) {
fprintf(stderr, "out of memory: heap %zuKB / %zuKB block, limit %zuMB",
used / 1024, block / 1024, limit / (1024 * 1024));
} else {
fprintf(stderr, "out of memory: heap %zuKB / %zuKB block, no limit",
used / 1024, block / 1024);
}
if (label)
fprintf(stderr, " [%s]", label);
fprintf(stderr, "\n");
ctx->current_exception = JS_TRUE;
return JS_EXCEPTION;
}