No Bug - Assert that our Rooting ABI is correct; r=sfink
authorTerrence Cole <terrence@mozilla.com>
Thu, 13 Jun 2013 15:14:44 -0700
changeset 146490 8322d226a0219331c22b9d3fa9b13f6d909cffd4
parent 146489 56e47c35233e3aa3a2adb3928968d2142937bae3
child 146491 46a12d8fbf033f58a90ab8c0f0c77a6b9667ae11
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
milestone24.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
No Bug - Assert that our Rooting ABI is correct; r=sfink
js/public/RootingAPI.h
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -173,17 +173,21 @@ struct JS_PUBLIC_API(NullPtr)
  * Encapsulated pointer class for use on the heap.
  *
  * Implements post barriers for heap-based GC thing pointers outside the engine.
  */
 template <typename T>
 class Heap : public js::HeapBase<T>
 {
   public:
-    Heap() { set(js::RootMethods<T>::initial()); }
+    Heap() {
+        MOZ_STATIC_ASSERT(sizeof(T) == sizeof(Heap<T>),
+                          "Heap<T> must be binary compatible with T.");
+        set(js::RootMethods<T>::initial());
+    }
     explicit Heap(T p) { set(p); }
     explicit Heap(const Heap<T> &p) { set(p.ptr); }
 
     ~Heap() {
         if (js::RootMethods<T>::needsPostBarrier(ptr))
             relocate();
     }
 
@@ -246,16 +250,18 @@ class MOZ_NONHEAP_CLASS Handle : public 
     friend class MutableHandle<T>;
 
   public:
     /* Creates a handle from a handle of a type convertible to T. */
     template <typename S>
     Handle(Handle<S> handle,
            typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0)
     {
+        MOZ_STATIC_ASSERT(sizeof(Handle<T>) == sizeof(T *),
+                          "Handle must be binary compatible with T*.");
         ptr = reinterpret_cast<const T *>(handle.address());
     }
 
     /* Create a handle for a NULL pointer. */
     Handle(js::NullPtr) {
         MOZ_STATIC_ASSERT(mozilla::IsPointer<T>::value,
                           "js::NullPtr overload not valid for non-pointer types");
         ptr = reinterpret_cast<const T *>(&js::NullPtr::constNullValue);
@@ -875,16 +881,18 @@ Handle<T>::Handle(MutableHandle<S> &root
 {
     ptr = reinterpret_cast<const T *>(root.address());
 }
 
 template <typename T>
 inline
 MutableHandle<T>::MutableHandle(Rooted<T> *root)
 {
+    MOZ_STATIC_ASSERT(sizeof(MutableHandle<T>) == sizeof(T *),
+                      "MutableHandle must be binary compatible with T*.");
     ptr = root->address();
 }
 
 } /* namespace JS */
 
 namespace js {
 
 /*