On Thu, Sep 29, 2011 at 12:11 PM, Simon Fraser <simon.fra...@apple.com>wrote:
> > On Sep 29, 2011, at 11:40 AM, Andreas Kling wrote: > > > Dear WebKittens, > > > > I'd like to add some compile-time assertions for the sizes of various > objects. The motivation comes a patch fixing bloat in InlineBox[1]. > > > > There are two major problems with this: > > > > 1. The sizes will differ on 32- and 64-bit platforms. > > 2. The sizes will differ based on compiler flags. > > > > One idea is to add a file that would only be built on (for example) > 64-bit Mac and then at least that bot would break if an object changes size. > That's obviously not ideal though. > > > > Any suggestions? :) > > You could group the bits together into a struct: > > struct { > m_foo: 1; > m_bar: 1; > ... > } m_bits; > > COMPILE_ASSERT(sizeof(m_bits) <= sizeof(uint32_t), Too_many_bits); > > This wouldn't' be sensitive to architecture. > > Simon > Perhaps you'll find some inspiration in http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/SizeLimits.cppwhere this is done for a few structs in wtf. I tried to use sizeof(int*) where I needed to deal with 32 vs 64 pointer issues and I put in an ifdef for a debug related size thing. dave
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev