From a19e129aabf40fcb3d66b7c0cbd5474479aebb10 Mon Sep 17 00:00:00 2001 From: norris Date: Tue, 16 Jun 1998 18:36:57 +0000 Subject: [PATCH] (Not part of Communicator build.) Fix 129824 monkey: evaling a function with many arguments fails --- js/ref/jsfun.c | 6 +++--- js/ref/jsfun.h | 6 +++--- js/ref/jsobj.c | 32 +++++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/js/ref/jsfun.c b/js/ref/jsfun.c index 92dbaf745d1..cce955d73ef 100644 --- a/js/ref/jsfun.c +++ b/js/ref/jsfun.c @@ -1035,10 +1035,10 @@ fun_xdrObject(JSXDRState *xdr, JSObject **objp) } if (!JS_XDRStringOrNull(xdr, &atomstr) || - !JS_XDRUint8(xdr, &fun->nargs) || - !JS_XDRUint8(xdr, &fun->flags) || + !JS_XDRUint16(xdr, &fun->nargs) || !JS_XDRUint16(xdr, &fun->extra) || - !JS_XDRUint16(xdr, &fun->nvars)) + !JS_XDRUint16(xdr, &fun->nvars) || + !JS_XDRUint8(xdr, &fun->flags)) return JS_FALSE; /* do arguments and local vars */ diff --git a/js/ref/jsfun.h b/js/ref/jsfun.h index 480a31347ed..790eb39ae6b 100644 --- a/js/ref/jsfun.h +++ b/js/ref/jsfun.h @@ -30,11 +30,11 @@ struct JSFunction { jsrefcount nrefs; /* number of referencing objects */ JSObject *object; /* back-pointer to GC'ed object header */ JSNative call; /* native method pointer or null */ - uint8 nargs; /* minimum number of actual arguments */ - uint8 flags; /* bound method and other flags, see jsapi.h */ + uint16 nargs; /* minimum number of actual arguments */ uint16 extra; /* number of arg slots for local GC roots */ uint16 nvars; /* number of local variables */ - uint16 spare; /* reserved for future use */ + uint8 flags; /* bound method and other flags, see jsapi.h */ + uint8 spare; /* reserved for future use */ JSAtom *atom; /* name for diagnostics and decompiling */ JSScript *script; /* interpreted bytecode descriptor or null */ }; diff --git a/js/ref/jsobj.c b/js/ref/jsobj.c index 8462881272f..54b22c207e0 100644 --- a/js/ref/jsobj.c +++ b/js/ref/jsobj.c @@ -2455,21 +2455,31 @@ out: /* Routines to print out values during debugging. */ -void printVal(jsval val) { - jsuint i; - JSString *str; +void printJschar(jschar *cp) { + fprintf(stderr, "jschar* (0x%x) \"", cp); + while (*cp) + fputc(*cp++, stderr); + fputc('"', stderr); + fputc('\n', stderr); +} +void printString(JSString *str) { + jsuint i; + fprintf(stderr, "string (0x%x) \"", str); + for (i=0; i < str->length; i++) + fputc(str->chars[i], stderr); + fputc('"', stderr); + fputc('\n', stderr); +} + +void printVal(jsval val) { fprintf(stderr, "val %d (0x%x) = ", val, val); if (JSVAL_IS_INT(val)) { fprintf(stderr, "(int) %d\n", JSVAL_TO_INT(val)); } else if (JSVAL_IS_STRING(val)) { - fprintf(stderr, "(string) \""); - str = JSVAL_TO_STRING(val); - for (i=0; i < str->length; i++) - fputc(str->chars[i], stderr); - fputc('"', stderr); - fputc('\n', stderr); + printString(JSVAL_TO_STRING(val)); } + /* XXX more cases */ fflush(stderr); } @@ -2478,5 +2488,9 @@ void printId(jsid id) { printVal(js_IdToValue(id)); } +void printAtom(JSAtom *atom) { + printString(ATOM_TO_STRING(atom)); +} + #endif