Bug 979481 - Add a helpful assertion indicating that the caller probably needs a JSAutoCompartment. r=luke
authorBobby Holley <bobbyholley@gmail.com>
Wed, 26 Mar 2014 10:59:03 -0300
changeset 175513 edc54a1c9a9be720a1061b400d7758493d4e30ab
parent 175512 ae9c10bf7be8766453352e0d4a497a2856aa027f
child 175514 15ceb48e2bf68611fe89d6efc3c4f8bfd5db6b6e
push id26492
push userryanvm@gmail.com
push dateThu, 27 Mar 2014 00:57:51 +0000
treeherdermozilla-central@441f5fd256e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs979481
milestone31.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
@@ -520,16 +520,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)