Bug 752578 - Use mfbt's guard object implementation rather than using our own in the trickier cases. r=Ms2ger
authorJeff Walden <jwalden@mit.edu>
Thu, 27 Dec 2012 11:20:22 -0600
changeset 126569 0d6c5f87f08bb687cf3e0148f8d8b48940becc3e
parent 126568 e024dfa5a77431f5bd48a4898face9042f9b3055
child 126570 7f628cbf1073dda524db9c1d71ceb04e4d9616cc
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 - Use mfbt's guard object implementation rather than using our own in the trickier cases. r=Ms2ger
js/src/jsapi.h
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/src/vm/SPSProfiler.cpp
js/src/vm/SPSProfiler.h
js/src/vm/ScopeObject.cpp
js/src/vm/ScopeObject.h
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -5540,29 +5540,31 @@ JS_GetStringEncodingLength(JSContext *cx
  * encoded into bytes with no error reported. Otherwise it returns the number
  * of bytes that are necessary to encode the string. If that exceeds the
  * length parameter, the string will be cut and only length bytes will be
  * written into the buffer.
  */
 JS_PUBLIC_API(size_t)
 JS_EncodeStringToBuffer(JSString *str, char *buffer, size_t length);
 
-class JSAutoByteString {
+class JSAutoByteString
+{
   public:
     JSAutoByteString(JSContext *cx, JSString *str
-                     JS_GUARD_OBJECT_NOTIFIER_PARAM)
+                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : mBytes(JS_EncodeString(cx, str))
     {
         JS_ASSERT(cx);
-        JS_GUARD_OBJECT_NOTIFIER_INIT;
-    }
-
-    JSAutoByteString(JS_GUARD_OBJECT_NOTIFIER_PARAM0)
-      : mBytes(NULL) {
-        JS_GUARD_OBJECT_NOTIFIER_INIT;
+        MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+    }
+
+    JSAutoByteString(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
+      : mBytes(NULL)
+    {
+        MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
 
     ~JSAutoByteString() {
         js_free(mBytes);
     }
 
     /* Take ownership of the given byte array. */
     void initBytes(char *bytes) {
@@ -5587,17 +5589,17 @@ class JSAutoByteString {
     }
 
     bool operator!() const {
         return !mBytes;
     }
 
   private:
     char        *mBytes;
-    JS_DECL_USE_GUARD_OBJECT_NOTIFIER
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
     /* Copy and assignment are not supported. */
     JSAutoByteString(const JSAutoByteString &another);
     JSAutoByteString &operator=(const JSAutoByteString &another);
 };
 
 /************************************************************************/
 /*
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -299,28 +299,28 @@ JS_DefineFunctionsWithHelp(JSContext *cx
                 return false;
         }
     }
 
     return true;
 }
 
 AutoSwitchCompartment::AutoSwitchCompartment(JSContext *cx, JSCompartment *newCompartment
-                                             JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
+                                             MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
   : cx(cx), oldCompartment(cx->compartment)
 {
-    JS_GUARD_OBJECT_NOTIFIER_INIT;
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     cx->setCompartment(newCompartment);
 }
 
 AutoSwitchCompartment::AutoSwitchCompartment(JSContext *cx, JSHandleObject target
-                                             JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
+                                             MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
   : cx(cx), oldCompartment(cx->compartment)
 {
-    JS_GUARD_OBJECT_NOTIFIER_INIT;
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     cx->setCompartment(target->compartment());
 }
 
 AutoSwitchCompartment::~AutoSwitchCompartment()
 {
     /* The old compartment may have been destroyed, so we can't use cx->setCompartment. */
     cx->compartment = oldCompartment;
 }
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -2,23 +2,23 @@
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jsfriendapi_h___
 #define jsfriendapi_h___
 
+#include "mozilla/GuardObjects.h"
+
 #include "jsclass.h"
 #include "jscpucfg.h"
 #include "jspubtd.h"
 #include "jsprvtd.h"
 
-#include "mozilla/GuardObjects.h"
-
 /*
  * This macro checks if the stack pointer has exceeded a given limit. If
  * |tolerance| is non-zero, it returns true only if the stack pointer has
  * exceeded the limit by more than |tolerance| bytes.
  */
 #if JS_STACK_GROWTH_DIRECTION > 0
 # define JS_CHECK_STACK_SIZE_WITH_TOLERANCE(limit, sp, tolerance)  \
     ((uintptr_t)(sp) < (limit)+(tolerance))
@@ -215,20 +215,21 @@ extern JS_FRIEND_API(void)
 DumpHeapComplete(JSRuntime *rt, FILE *fp);
 
 class JS_FRIEND_API(AutoSwitchCompartment) {
   private:
     JSContext *cx;
     JSCompartment *oldCompartment;
   public:
     AutoSwitchCompartment(JSContext *cx, JSCompartment *newCompartment
-                          JS_GUARD_OBJECT_NOTIFIER_PARAM);
-    AutoSwitchCompartment(JSContext *cx, JSHandleObject target JS_GUARD_OBJECT_NOTIFIER_PARAM);
+                          MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
+    AutoSwitchCompartment(JSContext *cx, JSHandleObject target
+                          MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     ~AutoSwitchCompartment();
-    JS_DECL_USE_GUARD_OBJECT_NOTIFIER
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 #ifdef OLD_GETTER_SETTER_METHODS
 JS_FRIEND_API(JSBool) obj_defineGetter(JSContext *cx, unsigned argc, js::Value *vp);
 JS_FRIEND_API(JSBool) obj_defineSetter(JSContext *cx, unsigned argc, js::Value *vp);
 #endif
 
 extern JS_FRIEND_API(bool)
--- a/js/src/vm/SPSProfiler.cpp
+++ b/js/src/vm/SPSProfiler.cpp
@@ -389,20 +389,21 @@ SPSProfiler::unregisterScript(UnrootedSc
     }
     if (info->chunks.length() == 0) {
         jminfo.remove(ptr);
         js_delete(info);
     }
 }
 #endif
 
-SPSEntryMarker::SPSEntryMarker(JSRuntime *rt JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
+SPSEntryMarker::SPSEntryMarker(JSRuntime *rt
+                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
     : profiler(&rt->spsProfiler)
 {
-    JS_GUARD_OBJECT_NOTIFIER_INIT;
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     if (!profiler->enabled()) {
         profiler = NULL;
         return;
     }
     size_before = *profiler->size_;
     profiler->push("js::RunScript", this, NULL, NULL);
 }
 
--- a/js/src/vm/SPSProfiler.h
+++ b/js/src/vm/SPSProfiler.h
@@ -6,16 +6,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef SPSProfiler_h__
 #define SPSProfiler_h__
 
 #include <stddef.h>
 
 #include "mozilla/DebugOnly.h"
+#include "mozilla/GuardObjects.h"
 #include "mozilla/HashFunctions.h"
 
 #include "js/Utility.h"
 #include "jsscript.h"
 
 /*
  * SPS Profiler integration with the JS Engine
  * https://developer.mozilla.org/en/Performance/Profiling_with_the_Built-in_Profiler
@@ -257,22 +258,25 @@ class SPSProfiler
 
 /*
  * This class is used in RunScript() to push the marker onto the sampling stack
  * that we're about to enter JS function calls. This is the only time in which a
  * valid stack pointer is pushed to the sampling stack.
  */
 class SPSEntryMarker
 {
+  public:
+    SPSEntryMarker(JSRuntime *rt
+                   MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
+    ~SPSEntryMarker();
+
+  private:
     SPSProfiler *profiler;
     mozilla::DebugOnly<uint32_t> size_before;
-    JS_DECL_USE_GUARD_OBJECT_NOTIFIER
-  public:
-    SPSEntryMarker(JSRuntime *rt JS_GUARD_OBJECT_NOTIFIER_PARAM);
-    ~SPSEntryMarker();
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 /*
  * SPS is the profiling backend used by the JS engine to enable time profiling.
  * More information can be found in vm/SPSProfiler.{h,cpp}. This class manages
  * the instrumentation portion of the profiling for JIT code.
  *
  * The instrumentation tracks entry into functions, leaving those functions via
--- a/js/src/vm/ScopeObject.cpp
+++ b/js/src/vm/ScopeObject.cpp
@@ -875,70 +875,70 @@ js::CloneStaticBlockObject(JSContext *cx
     }
 
     return clone;
 }
 
 /*****************************************************************************/
 
 ScopeIter::ScopeIter(JSContext *cx
-                     JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
+                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
   : fp_(NULL),
     cur_(cx, reinterpret_cast<JSObject *>(-1)),
     block_(cx, reinterpret_cast<StaticBlockObject *>(-1)),
     type_(Type(-1))
 {
-    JS_GUARD_OBJECT_NOTIFIER_INIT;
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 }
 
 ScopeIter::ScopeIter(const ScopeIter &si, JSContext *cx
-                     JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
+                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
   : fp_(si.fp_),
     cur_(cx, si.cur_),
     block_(cx, si.block_),
     type_(si.type_),
     hasScopeObject_(si.hasScopeObject_)
 {
-    JS_GUARD_OBJECT_NOTIFIER_INIT;
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 }
 
 ScopeIter::ScopeIter(JSObject &enclosingScope, JSContext *cx
-                     JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
+                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
   : fp_(NULL),
     cur_(cx, &enclosingScope),
     block_(cx, reinterpret_cast<StaticBlockObject *>(-1)),
     type_(Type(-1))
 {
-    JS_GUARD_OBJECT_NOTIFIER_INIT;
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 }
 
 ScopeIter::ScopeIter(StackFrame *fp, JSContext *cx
-                     JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
+                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
   : fp_(fp),
     cur_(cx, fp->scopeChain()),
     block_(cx, fp->maybeBlockChain())
 {
     assertSameCompartment(cx, fp);
     settle();
-    JS_GUARD_OBJECT_NOTIFIER_INIT;
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 }
 
 ScopeIter::ScopeIter(const ScopeIter &si, StackFrame *fp, JSContext *cx
-                     JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
+                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
   : fp_(fp),
     cur_(cx, si.cur_),
     block_(cx, si.block_),
     type_(si.type_),
     hasScopeObject_(si.hasScopeObject_)
 {
-    JS_GUARD_OBJECT_NOTIFIER_INIT;
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 }
 
 ScopeIter::ScopeIter(StackFrame *fp, ScopeObject &scope, JSContext *cx
-                     JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
+                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
   : fp_(fp),
     cur_(cx, &scope),
     block_(cx)
 {
     /*
      * Find the appropriate static block for this iterator, given 'scope'. We
      * know that 'scope' is a (non-optimized) scope on fp's scope chain. We do
      * not, however, know whether fp->maybeScopeChain() encloses 'scope'. E.g.:
@@ -960,17 +960,17 @@ ScopeIter::ScopeIter(StackFrame *fp, Sco
                 break;
             block_ = block_->enclosingBlock();
         }
         JS_ASSERT_IF(cur_->isClonedBlock(), cur_->asClonedBlock().staticBlock() == *block_);
     } else {
         block_ = NULL;
     }
     settle();
-    JS_GUARD_OBJECT_NOTIFIER_INIT;
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 }
 
 ScopeObject &
 ScopeIter::scope() const
 {
     JS_ASSERT(hasScopeObject());
     return cur_->asScope();
 }
--- a/js/src/vm/ScopeObject.h
+++ b/js/src/vm/ScopeObject.h
@@ -3,16 +3,18 @@
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef ScopeObject_h___
 #define ScopeObject_h___
 
+#include "mozilla/GuardObjects.h"
+
 #include "jscntxt.h"
 #include "jsobj.h"
 #include "jsweakmap.h"
 
 #include "gc/Barrier.h"
 
 namespace js {
 
@@ -409,43 +411,43 @@ class ScopeIter
     void settle();
 
     /* ScopeIter does not have value semantics. */
     ScopeIter(const ScopeIter &si) MOZ_DELETE;
 
   public:
     /* The default constructor leaves ScopeIter totally invalid */
     explicit ScopeIter(JSContext *cx
-                       JS_GUARD_OBJECT_NOTIFIER_PARAM);
+                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
 
     /* Constructing from a copy of an existing ScopeIter. */
     explicit ScopeIter(const ScopeIter &si, JSContext *cx
-                       JS_GUARD_OBJECT_NOTIFIER_PARAM);
+                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
 
     /* Constructing from StackFrame places ScopeIter on the innermost scope. */
     explicit ScopeIter(StackFrame *fp, JSContext *cx
-                       JS_GUARD_OBJECT_NOTIFIER_PARAM);
+                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
 
     /*
      * Without a StackFrame, the resulting ScopeIter is done() with
      * enclosingScope() as given.
      */
     explicit ScopeIter(JSObject &enclosingScope, JSContext *cx
-                       JS_GUARD_OBJECT_NOTIFIER_PARAM);
+                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
 
     /*
      * For the special case of generators, copy the given ScopeIter, with 'fp'
      * as the StackFrame instead of si.fp(). Not for general use.
      */
     ScopeIter(const ScopeIter &si, StackFrame *fp, JSContext *cx
-              JS_GUARD_OBJECT_NOTIFIER_PARAM);
+              MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
 
     /* Like ScopeIter(StackFrame *) except start at 'scope'. */
     ScopeIter(StackFrame *fp, ScopeObject &scope, JSContext *cx
-              JS_GUARD_OBJECT_NOTIFIER_PARAM);
+              MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
 
     bool done() const { return !fp_; }
 
     /* If done(): */
 
     JSObject &enclosingScope() const { JS_ASSERT(done()); return *cur_; }
 
     /* If !done(): */
@@ -454,17 +456,17 @@ class ScopeIter
 
     StackFrame *fp() const { JS_ASSERT(!done()); return fp_; }
     Type type() const { JS_ASSERT(!done()); return type_; }
     bool hasScopeObject() const { JS_ASSERT(!done()); return hasScopeObject_; }
     ScopeObject &scope() const;
 
     StaticBlockObject &staticBlock() const { JS_ASSERT(type() == Block); return *block_; }
 
-    JS_DECL_USE_GUARD_OBJECT_NOTIFIER
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 class ScopeIterKey
 {
     StackFrame *fp_;
     JSObject *cur_;
     StaticBlockObject *block_;
     ScopeIter::Type type_;