Bug 784300 - Make self-hosted non-constructor functions not have a prototype. r=tschneidereit
authorNorbert Lindenberg <mozilladev@lindenbergsoftware.com>
Thu, 13 Sep 2012 11:33:00 +0200
changeset 110688 9e68f92a96b62613704a095cebf75c77549c50f5
parent 110687 440f587c464a401c2c6dd56636ddfb5ef8b04a16
child 110689 35c8685ee065bf19cff0b3f049b63048223476e0
push idunknown
push userunknown
push dateunknown
reviewerstschneidereit
bugs784300
milestone18.0a1
Bug 784300 - Make self-hosted non-constructor functions not have a prototype. r=tschneidereit
js/src/jsfun.cpp
js/src/jsfun.h
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -282,28 +282,28 @@ fun_resolve(JSContext *cx, HandleObject 
 {
     if (!JSID_IS_ATOM(id))
         return true;
 
     RootedFunction fun(cx, obj->toFunction());
 
     if (JSID_IS_ATOM(id, cx->runtime->atomState.classPrototypeAtom)) {
         /*
-         * Native or "built-in" functions do not have a .prototype property per
-         * ECMA-262, or (Object.prototype, Function.prototype, etc.) have that
-         * property created eagerly.
+         * Built-in functions do not have a .prototype property per ECMA-262,
+         * or (Object.prototype, Function.prototype, etc.) have that property
+         * created eagerly.
          *
          * ES5 15.3.4: the non-native function object named Function.prototype
          * does not have a .prototype property.
          *
          * ES5 15.3.4.5: bound functions don't have a prototype property. The
-         * isNative() test covers this case because bound functions are native
-         * functions by definition/construction.
+         * isBuiltin() test covers this case because bound functions are native
+         * (and thus built-in) functions by definition/construction.
          */
-        if (fun->isNative() || fun->isFunctionPrototype())
+        if (fun->isBuiltin() || fun->isFunctionPrototype())
             return true;
 
         if (!ResolveInterpretedFunctionPrototype(cx, fun))
             return false;
         objp.set(fun);
         return true;
     }
 
--- a/js/src/jsfun.h
+++ b/js/src/jsfun.h
@@ -76,16 +76,17 @@ struct JSFunction : public JSObject
   public:
 
     bool hasDefaults()       const { return flags & JSFUN_HAS_DEFAULTS; }
     bool hasRest()           const { return flags & JSFUN_HAS_REST; }
     bool hasGuessedAtom()    const { return flags & JSFUN_HAS_GUESSED_ATOM; }
     bool isInterpreted()     const { return flags & JSFUN_INTERPRETED; }
     bool isNative()          const { return !isInterpreted(); }
     bool isSelfHostedBuiltin() const { return flags & JSFUN_SELF_HOSTED; }
+    bool isBuiltin()         const { return isNative() || isSelfHostedBuiltin(); }
     bool isSelfHostedConstructor() const { return flags & JSFUN_SELF_HOSTED_CTOR; }
     bool isNativeConstructor() const { return flags & JSFUN_CONSTRUCTOR; }
     bool isHeavyweight()     const { return JSFUN_HEAVYWEIGHT_TEST(flags); }
     bool isFunctionPrototype() const { return flags & JSFUN_PROTOTYPE; }
     bool isInterpretedConstructor() const {
         return isInterpreted() && !isFunctionPrototype() &&
                (!isSelfHostedBuiltin() || isSelfHostedConstructor());
     }