From 27898e866f6ba46d84e82c7d8e130931fc9f0a18 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Mon, 26 Jul 2010 16:11:37 -0700 Subject: [PATCH] Bug 581744 - Deprecate JSFUN_GETTER and JSFUN_SETTER; they never did much, and they're very nearly dead code already. r=brendan --- js/src/jsapi.h | 7 ----- js/src/jsinterp.cpp | 67 ++++++++++----------------------------------- js/src/jsobj.cpp | 13 --------- js/src/jsopcode.cpp | 4 --- js/src/shell/js.cpp | 2 -- 5 files changed, 14 insertions(+), 79 deletions(-) diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 39cacc64707..d37d12ce037 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -472,21 +472,14 @@ extern JS_PUBLIC_DATA(jsid) JSID_VOID; /* Function flags, set in JSFunctionSpec and passed to JS_NewFunction etc. */ #define JSFUN_LAMBDA 0x08 /* expressed, not declared, function */ -#define JSFUN_GETTER JSPROP_GETTER -#define JSFUN_SETTER JSPROP_SETTER #define JSFUN_BOUND_METHOD 0x40 /* bind this to fun->object's parent */ #define JSFUN_HEAVYWEIGHT 0x80 /* activation requires a Call object */ #define JSFUN_DISJOINT_FLAGS(f) ((f) & 0x0f) -#define JSFUN_GSFLAGS(f) ((f) & (JSFUN_GETTER | JSFUN_SETTER)) -#define JSFUN_GETTER_TEST(f) ((f) & JSFUN_GETTER) -#define JSFUN_SETTER_TEST(f) ((f) & JSFUN_SETTER) #define JSFUN_BOUND_METHOD_TEST(f) ((f) & JSFUN_BOUND_METHOD) #define JSFUN_HEAVYWEIGHT_TEST(f) ((f) & JSFUN_HEAVYWEIGHT) -#define JSFUN_GSFLAG2ATTR(f) JSFUN_GSFLAGS(f) - #define JSFUN_THISP_FLAGS(f) (f) #define JSFUN_THISP_TEST(f,t) ((f) & t) diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index ca8fd600034..aefdd244b67 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -5421,12 +5421,6 @@ END_CASE(JSOP_DEFVAR) BEGIN_CASE(JSOP_DEFFUN) { - PropertyOp getter, setter; - bool doSet; - JSObject *pobj; - JSProperty *prop; - uint32 old; - /* * A top-level function defined in Global or Eval code (see ECMA-262 * Ed. 3), or else a SpiderMonkey extension: a named function statement in @@ -5494,24 +5488,6 @@ BEGIN_CASE(JSOP_DEFFUN) ? JSPROP_ENUMERATE : JSPROP_ENUMERATE | JSPROP_PERMANENT; - /* - * Load function flags that are also property attributes. Getters and - * setters do not need a slot, their value is stored elsewhere in the - * property itself, not in obj slots. - */ - getter = setter = PropertyStub; - uintN flags = JSFUN_GSFLAG2ATTR(fun->flags); - if (flags) { - /* Function cannot be both getter a setter. */ - JS_ASSERT(flags == JSPROP_GETTER || flags == JSPROP_SETTER); - attrs |= flags | JSPROP_SHARED; - rval.setUndefined(); - if (flags == JSPROP_GETTER) - getter = CastAsPropertyOp(obj); - else - setter = CastAsPropertyOp(obj); - } - /* * We define the function as a property of the variable object and not the * current scope chain even for the case of function expression statements @@ -5520,13 +5496,17 @@ BEGIN_CASE(JSOP_DEFFUN) JSObject *parent = fp->varobj(cx); JS_ASSERT(parent); + uint32 old; + bool doSet; + /* * Check for a const property of the same name -- or any kind of property * if executing with the strict option. We check here at runtime as well * as at compile-time, to handle eval as well as multiple HTML script tags. */ jsid id = ATOM_TO_JSID(fun->atom); - prop = NULL; + JSProperty *prop = NULL; + JSObject *pobj; JSBool ok = CheckRedeclaration(cx, parent, id, attrs, &pobj, &prop); if (!ok) goto restore_scope; @@ -5556,13 +5536,13 @@ BEGIN_CASE(JSOP_DEFFUN) */ JS_ASSERT(!(attrs & ~(JSPROP_ENUMERATE|JSPROP_PERMANENT))); JS_ASSERT(!(old & JSPROP_READONLY)); - doSet = JS_TRUE; + doSet = true; } pobj->dropProperty(cx, prop); } ok = doSet ? parent->setProperty(cx, id, &rval) - : parent->defineProperty(cx, id, rval, getter, setter, attrs); + : parent->defineProperty(cx, id, rval, PropertyStub, PropertyStub, attrs); restore_scope: /* Restore fp->scopeChain now that obj is defined in fp->callobj. */ @@ -5590,37 +5570,18 @@ BEGIN_CASE(JSOP_DEFFUN_DBGFC) ? JSPROP_ENUMERATE : JSPROP_ENUMERATE | JSPROP_PERMANENT; - uintN flags = JSFUN_GSFLAG2ATTR(fun->flags); - if (flags) { - attrs |= flags | JSPROP_SHARED; - rval.setUndefined(); - } - JSObject *parent = fp->varobj(cx); JS_ASSERT(parent); jsid id = ATOM_TO_JSID(fun->atom); - JSBool ok = CheckRedeclaration(cx, parent, id, attrs, NULL, NULL); - if (ok) { - if (attrs == JSPROP_ENUMERATE) { - JS_ASSERT(fp->flags & JSFRAME_EVAL); - ok = parent->setProperty(cx, id, &rval); - } else { - JS_ASSERT(attrs & JSPROP_PERMANENT); - - ok = parent->defineProperty(cx, id, rval, - (flags & JSPROP_GETTER) - ? CastAsPropertyOp(obj) - : PropertyStub, - (flags & JSPROP_SETTER) - ? CastAsPropertyOp(obj) - : PropertyStub, - attrs); - } - } - - if (!ok) + if (!CheckRedeclaration(cx, parent, id, attrs, NULL, NULL)) goto error; + + if ((attrs == JSPROP_ENUMERATE) + ? !parent->setProperty(cx, id, &rval) + : !parent->defineProperty(cx, id, rval, PropertyStub, PropertyStub, attrs)) { + goto error; + } } END_CASE(JSOP_DEFFUN_FC) diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 8f66df81168..366ccd5d08d 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -668,7 +668,6 @@ obj_toSource(JSContext *cx, uintN argc, Value *vp) * end so that we can put "get" in front of the function definition. */ if (gsop[j] && IsFunctionObject(val[j])) { - JSFunction *fun = js_ValueToFunction(cx, &val[j], JSV2F_SEARCH_STACK); const jschar *start = vchars; const jschar *end = vchars + vlength; @@ -678,18 +677,6 @@ obj_toSource(JSContext *cx, uintN argc, Value *vp) parenChomp = 1; } - /* - * Try to jump "getter" or "setter" keywords, if we suspect - * they might appear here. This code can be confused by people - * defining Function.prototype.toString, so let's be cautious. - */ - if (JSFUN_GETTER_TEST(fun->flags) || JSFUN_SETTER_TEST(fun->flags)) { - /* skip "getter/setter" */ - const jschar *tmp = js_strchr_limit(vchars, ' ', end); - if (tmp) - vchars = tmp + 1; - } - /* Try to jump "function" keyword. */ if (vchars) vchars = js_strchr_limit(vchars, ' ', end); diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp index af60f81d779..153be1dcb95 100644 --- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -4977,10 +4977,6 @@ js_DecompileFunction(JSPrinter *jp) if (!jp->grouped && (fun->flags & JSFUN_LAMBDA)) js_puts(jp, "("); } - if (JSFUN_GETTER_TEST(fun->flags)) - js_printf(jp, "%s ", js_getter_str); - else if (JSFUN_SETTER_TEST(fun->flags)) - js_printf(jp, "%s ", js_setter_str); js_printf(jp, "%s ", js_function_str); if (fun->atom && !QuoteString(&jp->sprinter, ATOM_TO_STRING(fun->atom), 0)) diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index d634f94b520..80e95593dd3 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -1746,8 +1746,6 @@ DisassembleValue(JSContext *cx, jsval v, bool lines, bool recursive) #define SHOW_FLAG(flag) if (flags & JSFUN_##flag) fputs(" " #flag, stdout); SHOW_FLAG(LAMBDA); - SHOW_FLAG(SETTER); - SHOW_FLAG(GETTER); SHOW_FLAG(BOUND_METHOD); SHOW_FLAG(HEAVYWEIGHT); SHOW_FLAG(THISP_STRING);