Bug 693393 - Make poor man's Maybe<AutoCompartment> in JSAutoEnterCompartment (slightly) less fragile. r=luke
authorJustin Lebar <justin.lebar@gmail.com>
Mon, 10 Oct 2011 15:51:59 -0400
changeset 79003 962683b9d15a5c83f352b2cfd414a9ba47253c2f
parent 79002 79e60c5bde683867ed7a9f12d0a64b5d4a4d8c10
child 79004 6d2612f175306c4fa7d0c45f2619207e85568ef1
push idunknown
push userunknown
push dateunknown
reviewersluke
bugs693393
milestone10.0a1
Bug 693393 - Make poor man's Maybe<AutoCompartment> in JSAutoEnterCompartment (slightly) less fragile. r=luke
js/src/jsapi.h
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2216,22 +2216,21 @@ js_GetCompartmentPrivate(JSCompartment *
 JS_END_EXTERN_C
 
 class JS_PUBLIC_API(JSAutoEnterCompartment)
 {
     /*
      * This is a poor man's Maybe<AutoCompartment>, because we don't have
      * access to the AutoCompartment definition here.  We statically assert in
      * jsapi.cpp that we have the right size here.
+     *
+     * In practice, 32-bit Windows and Android get 16-word |bytes|, while
+     * other platforms get 13-word |bytes|.
      */
-#if !defined(_MSC_VER) && !defined(__arm__)
-    void* bytes[13];
-#else
-    void* bytes[sizeof(void*) == 4 ? 16 : 13];
-#endif
+    void* bytes[sizeof(void*) == 4 && MOZ_ALIGNOF(JSUint64) == 8 ? 16 : 13];
 
     /*
      * This object may be in one of three states.  If enter() or
      * enterAndIgnoreErrors() hasn't been called, it's in STATE_UNENTERED.
      * Otherwise, if we were asked to enter into the current compartment, our
      * state is STATE_SAME_COMPARTMENT.  If we actually created an
      * AutoCompartment and entered another compartment, our state is
      * STATE_OTHER_COMPARTMENT.