Merge branch 'native_boot'

This commit is contained in:
2026-02-23 19:07:07 -06:00
20 changed files with 38708 additions and 38130 deletions

View File

@@ -321,7 +321,7 @@ void script_startup(JSContext *js)
JS_SetGCScanExternal(js, actor_gc_scan);
/* Set per-actor heap memory limit */
js->actor_label = js->name; /* may be NULL; updated when name is set */
JS_SetHeapMemoryLimit(js, ACTOR_MEMORY_LIMIT);
JS_FreeValue(js, js_core_blob_use(js));

View File

@@ -871,7 +871,7 @@ typedef struct letter {
#define ACTOR_FAST_TIMER_NS (10ULL * 1000000)
#define ACTOR_SLOW_TIMER_NS (60000ULL * 1000000)
#define ACTOR_SLOW_STRIKES_MAX 3
#define ACTOR_MEMORY_LIMIT (16ULL * 1024 * 1024)
#define ACTOR_MEMORY_LIMIT (1024ULL * 1024 * 1024)
struct JSContext {
JSRuntime *rt;
@@ -948,6 +948,7 @@ struct JSContext {
uint32_t suspended_pc; /* saved PC for resume */
int vm_call_depth; /* 0 = pure bytecode, >0 = C frames on stack */
size_t heap_memory_limit; /* 0 = no limit, else max heap bytes */
const char *actor_label; /* human-readable label for OOM diagnostics */
JSValue current_exception;

View File

@@ -84,6 +84,7 @@ JSC_CCALL(actor_disrupt,
JSC_SCALL(actor_setname,
js->name = strdup(str);
js->actor_label = js->name;
)
JSC_CCALL(actor_on_exception,

View File

@@ -2044,6 +2044,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;
@@ -3283,7 +3284,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;
}