diff --git a/js/src/jsobj.c b/js/src/jsobj.c index 9d765ef8989..ed610b691d5 100644 --- a/js/src/jsobj.c +++ b/js/src/jsobj.c @@ -955,6 +955,34 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, if (needOldStyleGetterSetter) gsop[j] = gsopold[j]; + /* If val[j] is a non-sharp object, consider sharpening it. */ + vsharp = NULL; + vsharplength = 0; +#if JS_HAS_SHARP_VARS + if (!JSVAL_IS_PRIMITIVE(val[j]) && vchars[0] != '#') { + he = js_EnterSharpObject(cx, JSVAL_TO_OBJECT(val[j]), NULL, + &vsharp); + if (!he) { + ok = JS_FALSE; + goto error; + } + if (IS_SHARP(he)) { + vchars = vsharp; + vlength = js_strlen(vchars); + needOldStyleGetterSetter = JS_TRUE; + gsop[j] = gsopold[j]; + } else { + if (vsharp) { + vsharplength = js_strlen(vsharp); + MAKE_SHARP(he); + needOldStyleGetterSetter = JS_TRUE; + gsop[j] = gsopold[j]; + } + js_LeaveSharpObject(cx, NULL); + } + } +#endif + #ifndef OLD_GETTER_SETTER /* * Remove '(function ' from the beginning of valstr and ')' from the @@ -1000,34 +1028,6 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, gsop[j] = gsopold[j]; #endif - /* If val[j] is a non-sharp object, consider sharpening it. */ - vsharp = NULL; - vsharplength = 0; -#if JS_HAS_SHARP_VARS - if (!JSVAL_IS_PRIMITIVE(val[j]) && vchars[0] != '#') { - he = js_EnterSharpObject(cx, JSVAL_TO_OBJECT(val[j]), NULL, - &vsharp); - if (!he) { - ok = JS_FALSE; - goto error; - } - if (IS_SHARP(he)) { - vchars = vsharp; - vlength = js_strlen(vchars); - needOldStyleGetterSetter = JS_TRUE; - gsop[j] = gsopold[j]; - } else { - if (vsharp) { - vsharplength = js_strlen(vsharp); - MAKE_SHARP(he); - needOldStyleGetterSetter = JS_TRUE; - gsop[j] = gsopold[j]; - } - js_LeaveSharpObject(cx, NULL); - } - } -#endif - #define SAFE_ADD(n) \ JS_BEGIN_MACRO \ size_t n_ = (n); \