bootstrap with serialized mach
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user