bootstrap with serialized mach

This commit is contained in:
2026-02-09 22:54:42 -06:00
parent 930dcfba36
commit b8b110b616
17 changed files with 89 additions and 247144 deletions

View File

@@ -3525,6 +3525,22 @@ JSValue JS_RunMachTree(JSContext *ctx, cJSON *ast, JSValue env) {
return result;
}
JSValue JS_RunMachBin(JSContext *ctx, const uint8_t *data, size_t size, JSValue env) {
MachCode *mc = JS_DeserializeMachCode(data, size);
if (!mc)
return JS_ThrowSyntaxError(ctx, "failed to deserialize MACH bytecode");
JSGCRef env_ref;
JS_PushGCRef(ctx, &env_ref);
env_ref.val = env;
JSCodeRegister *code = JS_LoadMachCode(ctx, mc, env_ref.val);
JS_FreeMachCode(mc);
JSValue result = JS_CallRegisterVM(ctx, code, ctx->global_obj, 0, NULL, env_ref.val, JS_NULL);
JS_PopGCRef(ctx, &env_ref);
return result;
}
JSValue JS_RunMach(JSContext *ctx, const char *ast_json, JSValue env) {
cJSON *ast = cJSON_Parse(ast_json);
if (!ast) {