Bug 752578 - Remove the JS guard object implementation. r=Ms2ger
authorJeff Walden <jwalden@mit.edu>
Thu, 27 Dec 2012 11:20:22 -0600
changeset 126571 01efd933f60b4376289c1174bd3d45aef096ad0f
parent 126570 7f628cbf1073dda524db9c1d71ceb04e4d9616cc
child 126572 3e3f356726b5e6cc146ff2db1dd36b30c1205228
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs752578
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 752578 - Remove the JS guard object implementation. r=Ms2ger
js/public/Utility.h
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -552,115 +552,16 @@ template <typename T>
 struct ScopedDeletePtrTraits : public ScopedFreePtrTraits<T>
 {
     static void release(T *ptr) { js_delete(ptr); }
 };
 SCOPED_TEMPLATE(ScopedDeletePtr, ScopedDeletePtrTraits)
 
 } /* namespace js */
 
-/*
- * The following classes are designed to cause assertions to detect
- * inadvertent use of guard objects as temporaries.  In other words,
- * when we have a guard object whose only purpose is its constructor and
- * destructor (and is never otherwise referenced), the intended use
- * might be:
- *     JSAutoTempValueRooter tvr(cx, 1, &val);
- * but is is easy to accidentally write:
- *     JSAutoTempValueRooter(cx, 1, &val);
- * which compiles just fine, but runs the destructor well before the
- * intended time.
- *
- * They work by adding (#ifdef DEBUG) an additional parameter to the
- * guard object's constructor, with a default value, so that users of
- * the guard object's API do not need to do anything.  The default value
- * of this parameter is a temporary object.  C++ (ISO/IEC 14882:1998),
- * section 12.2 [class.temporary], clauses 4 and 5 seem to assume a
- * guarantee that temporaries are destroyed in the reverse of their
- * construction order, but I actually can't find a statement that that
- * is true in the general case (beyond the two specific cases mentioned
- * there).  However, it seems to be true.
- *
- * These classes are intended to be used only via the macros immediately
- * below them:
- *   JS_DECL_USE_GUARD_OBJECT_NOTIFIER declares (ifdef DEBUG) a member
- *     variable, and should be put where a declaration of a private
- *     member variable would be placed.
- *   JS_GUARD_OBJECT_NOTIFIER_PARAM should be placed at the end of the
- *     parameters to each constructor of the guard object; it declares
- *     (ifdef DEBUG) an additional parameter.
- *   JS_GUARD_OBJECT_NOTIFIER_INIT is a statement that belongs in each
- *     constructor.  It uses the parameter declared by
- *     JS_GUARD_OBJECT_NOTIFIER_PARAM.
- */
-#ifdef DEBUG
-class JS_FRIEND_API(JSGuardObjectNotifier)
-{
-private:
-    bool* mStatementDone;
-public:
-    JSGuardObjectNotifier() : mStatementDone(NULL) {}
-
-    ~JSGuardObjectNotifier() {
-        *mStatementDone = true;
-    }
-
-    void setStatementDone(bool *aStatementDone) {
-        mStatementDone = aStatementDone;
-    }
-};
-
-class JS_FRIEND_API(JSGuardObjectNotificationReceiver)
-{
-private:
-    bool mStatementDone;
-public:
-    JSGuardObjectNotificationReceiver() : mStatementDone(false) {}
-
-    ~JSGuardObjectNotificationReceiver() {
-        /*
-         * Assert that the guard object was not used as a temporary.
-         * (Note that this assert might also fire if Init is not called
-         * because the guard object's implementation is not using the
-         * above macros correctly.)
-         */
-        JS_ASSERT(mStatementDone);
-    }
-
-    void Init(const JSGuardObjectNotifier &aNotifier) {
-        /*
-         * aNotifier is passed as a const reference so that we can pass a
-         * temporary, but we really intend it as non-const
-         */
-        const_cast<JSGuardObjectNotifier&>(aNotifier).
-            setStatementDone(&mStatementDone);
-    }
-};
-
-#define JS_DECL_USE_GUARD_OBJECT_NOTIFIER \
-    JSGuardObjectNotificationReceiver _mCheckNotUsedAsTemporary;
-#define JS_GUARD_OBJECT_NOTIFIER_PARAM \
-    , const JSGuardObjectNotifier& _notifier = JSGuardObjectNotifier()
-#define JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT \
-    , const JSGuardObjectNotifier& _notifier
-#define JS_GUARD_OBJECT_NOTIFIER_PARAM0 \
-    const JSGuardObjectNotifier& _notifier = JSGuardObjectNotifier()
-#define JS_GUARD_OBJECT_NOTIFIER_INIT \
-    JS_BEGIN_MACRO _mCheckNotUsedAsTemporary.Init(_notifier); JS_END_MACRO
-
-#else /* defined(DEBUG) */
-
-#define JS_DECL_USE_GUARD_OBJECT_NOTIFIER
-#define JS_GUARD_OBJECT_NOTIFIER_PARAM
-#define JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT
-#define JS_GUARD_OBJECT_NOTIFIER_PARAM0
-#define JS_GUARD_OBJECT_NOTIFIER_INIT JS_BEGIN_MACRO JS_END_MACRO
-
-#endif /* !defined(DEBUG) */
-
 namespace js {
 
 /*
  * "Move" References
  *
  * Some types can be copied much more efficiently if we know the original's
  * value need not be preserved --- that is, if we are doing a "move", not a
  * "copy". For example, if we have: