From fa77ae873c5b542e721bbbb0a9f6682eec229e6d Mon Sep 17 00:00:00 2001 From: Terrence Cole Date: Thu, 13 Jun 2013 15:14:44 -0700 Subject: [PATCH] No Bug - Assert that our Rooting ABI is correct; r=sfink --HG-- extra : rebase_source : 3247d6a22f73d278ae4e6904dff28a1b727e5169 --- js/public/RootingAPI.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h index 5f4fecb7b0e8..6ffe4597057f 100644 --- a/js/public/RootingAPI.h +++ b/js/public/RootingAPI.h @@ -178,7 +178,11 @@ template class Heap : public js::HeapBase { public: - Heap() { set(js::RootMethods::initial()); } + Heap() { + MOZ_STATIC_ASSERT(sizeof(T) == sizeof(Heap), + "Heap must be binary compatible with T."); + set(js::RootMethods::initial()); + } explicit Heap(T p) { set(p); } explicit Heap(const Heap &p) { set(p.ptr); } @@ -251,6 +255,8 @@ class MOZ_NONHEAP_CLASS Handle : public js::HandleBase Handle(Handle handle, typename mozilla::EnableIf::value, int>::Type dummy = 0) { + MOZ_STATIC_ASSERT(sizeof(Handle) == sizeof(T *), + "Handle must be binary compatible with T*."); ptr = reinterpret_cast(handle.address()); } @@ -880,6 +886,8 @@ template inline MutableHandle::MutableHandle(Rooted *root) { + MOZ_STATIC_ASSERT(sizeof(MutableHandle) == sizeof(T *), + "MutableHandle must be binary compatible with T*."); ptr = root->address(); }