From 19524b3a5358190b56e5a55a4815c1751edcdb16 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Thu, 12 Feb 2026 17:06:48 -0600 Subject: [PATCH] faster json decode --- source/mach.c | 2 +- source/quickjs-internal.h | 5 ----- source/runtime.c | 3 ++- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/source/mach.c b/source/mach.c index 36cda201..42c8c773 100644 --- a/source/mach.c +++ b/source/mach.c @@ -1804,7 +1804,7 @@ JSValue JS_CallRegisterVM(JSContext *ctx, JSCodeRegister *code, } default: - result = JS_ThrowInternalError(ctx, "unknown register VM opcode %d", op); + printf("unknown register VM opcode %d: %s\n", op, mach_opcode_names[op]); goto done; } continue; diff --git a/source/quickjs-internal.h b/source/quickjs-internal.h index 7d6ebc59..9758c297 100644 --- a/source/quickjs-internal.h +++ b/source/quickjs-internal.h @@ -469,7 +469,6 @@ typedef enum MachOpcode { MACH_JMPNULL, /* if R(A)==null: pc += sBx */ /* Function calls — Lua-style consecutive registers (legacy .mach) */ - MACH_CALL, /* (removed — placeholder to preserve opcode numbering) */ MACH_RETURN, /* Return R(A) */ MACH_RETNIL, /* Return null */ @@ -488,8 +487,6 @@ typedef enum MachOpcode { MACH_HASPROP, /* R(A) = R(C) in R(B) — has property check */ MACH_REGEXP, /* R(A) = regexp(K(B), K(C)) — regex literal */ - MACH_CALLMETHOD, /* (removed — placeholder to preserve opcode numbering) */ - MACH_EQ_TOL, /* R(A) = eq_tol(R(B), R(B+1), R(B+2)), C=3 */ MACH_NEQ_TOL, /* R(A) = ne_tol(R(B), R(B+1), R(B+2)), C=3 */ @@ -651,7 +648,6 @@ static const char *mach_opcode_names[MACH_OP_COUNT] = { [MACH_JMPTRUE] = "jmptrue", [MACH_JMPFALSE] = "jmpfalse", [MACH_JMPNULL] = "jmpnull", - [MACH_CALL] = "call", [MACH_RETURN] = "return", [MACH_RETNIL] = "retnil", [MACH_NEWOBJECT] = "newobject", @@ -664,7 +660,6 @@ static const char *mach_opcode_names[MACH_OP_COUNT] = { [MACH_DELETEINDEX] = "deleteindex", [MACH_HASPROP] = "hasprop", [MACH_REGEXP] = "regexp", - [MACH_CALLMETHOD] = "callmethod", [MACH_EQ_TOL] = "eq_tol", [MACH_NEQ_TOL] = "neq_tol", [MACH_NOP] = "nop", diff --git a/source/runtime.c b/source/runtime.c index 5b7d63de..44f55cb6 100644 --- a/source/runtime.c +++ b/source/runtime.c @@ -5221,7 +5221,8 @@ static JSValue cjson_to_jsvalue (JSContext *ctx, const cJSON *item) { if (cJSON_IsString (item)) return JS_NewString (ctx, item->valuestring); if (cJSON_IsArray (item)) { int n = cJSON_GetArraySize (item); - JSValue arr = JS_NewArray (ctx); + JSValue arr = JS_NewArrayLen (ctx,n); + printf("array size %d\n", n); for (int i = 0; i < n; i++) { cJSON *child = cJSON_GetArrayItem (item, i); JS_SetPropertyNumber (ctx, arr, i, cjson_to_jsvalue (ctx, child));