Bug 979481 - Add a helpful assertion indicating that the caller probably needs a JSAutoCompartment. r=luke
authorBobby Holley <bobbyholley@gmail.com>
Thu, 06 Mar 2014 08:55:01 -0800
changeset 172343 77f4622e20002af05aa733573f09d2135747aecb
parent 172342 670fb9adcd29826b0ab35db2380121e6c99aa433
child 172344 28b40ecf634501f39753fc267ce5817775d09c04
push id26358
push usercbook@mozilla.com
push dateFri, 07 Mar 2014 11:48:31 +0000
treeherdermozilla-central@b9fc2eb18bd1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs979481
milestone30.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 979481 - Add a helpful assertion indicating that the caller probably needs a JSAutoCompartment. r=luke
js/src/jscompartment.h
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -528,16 +528,17 @@ inline js::Handle<js::GlobalObject*>
 ExclusiveContext::global() const
 {
     /*
      * It's safe to use |unsafeGet()| here because any compartment that is
      * on-stack will be marked automatically, so there's no need for a read
      * barrier on it. Once the compartment is popped, the handle is no longer
      * safe to use.
      */
+    MOZ_ASSERT(compartment_, "Caller needs to enter a compartment first");
     return Handle<GlobalObject*>::fromMarkedLocation(compartment_->global_.unsafeGet());
 }
 
 class AssertCompartmentUnchanged
 {
   public:
     AssertCompartmentUnchanged(JSContext *cx
                                 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)