This commit is contained in:
2026-02-19 01:37:54 -06:00
parent 85ef711229
commit ab43ab0d2c
5 changed files with 148 additions and 103 deletions

View File

@@ -85,9 +85,6 @@ static JSValue *mach_materialize_cpool(JSContext *ctx, MachCPoolEntry *entries,
static int mach_check_call_arity(JSContext *ctx, JSFunction *fn, int argc) {
if (unlikely(fn->length >= 0 && argc > fn->length)) {
char buf[KEY_GET_STR_BUF_SIZE];
fprintf(stderr, "[arity-mach] callee=%s expected=%d got=%d\n",
JS_KeyGetStr(ctx, buf, KEY_GET_STR_BUF_SIZE, fn->name),
fn->length, argc);
JS_RaiseDisrupt(ctx, "too many arguments for %s: expected %d, got %d",
JS_KeyGetStr(ctx, buf, KEY_GET_STR_BUF_SIZE, fn->name), fn->length, argc);
return 0;
@@ -2183,13 +2180,8 @@ vm_dispatch:
int c_argc = (nr >= 2) ? nr - 2 : 0;
JSValue fn_val = fr->function;
JSFunction *fn = JS_VALUE_GET_FUNCTION(fn_val);
if (!mach_check_call_arity(ctx, fn, c_argc)) {
fprintf(stderr, "[arity-mach] caller=%s file=%s pc=%u op=invoke argc=%d\n",
code->name_cstr ? code->name_cstr : "?",
code->filename_cstr ? code->filename_cstr : "?",
(unsigned)(pc > 0 ? pc - 1 : 0), c_argc);
if (!mach_check_call_arity(ctx, fn, c_argc))
goto disrupt;
}
if (fn->kind == JS_FUNC_KIND_REGISTER) {
/* Register function: switch frames inline (fast path) */
@@ -2261,13 +2253,8 @@ vm_dispatch:
int c_argc = (nr >= 2) ? nr - 2 : 0;
JSValue fn_val = fr->function;
JSFunction *fn = JS_VALUE_GET_FUNCTION(fn_val);
if (!mach_check_call_arity(ctx, fn, c_argc)) {
fprintf(stderr, "[arity-mach] caller=%s file=%s pc=%u op=goinvoke argc=%d\n",
code->name_cstr ? code->name_cstr : "?",
code->filename_cstr ? code->filename_cstr : "?",
(unsigned)(pc > 0 ? pc - 1 : 0), c_argc);
if (!mach_check_call_arity(ctx, fn, c_argc))
goto disrupt;
}
if (fn->kind == JS_FUNC_KIND_REGISTER) {
JSCodeRegister *fn_code = JS_VALUE_GET_CODE(fn->u.cell.code)->u.reg.code;