On Tue, Apr 15, 2014 at 7:47 PM, Joshua Litt <[email protected]> wrote:

> I would like to take advantage of the layout of member variables in my
> Javascript layer.  It would be nice to just return pointers to simple
> objects, and use dataviews / typed arrays and offsets to read the necessary
> data instead of copying or making a ton of calls into asm.js
>
> I am taking advantage of this already in my program, but is this behavior
> actually defined or am I getting lucky?
>

I don't know whether the standard defines any particular layout except
that, within a public:, protected: or private: region, elements are stored
in order and that elements have appropriate alignment.

In practice, for simple structs of data, I've never seen compilers differ,
because there's really only one way to preserve order, have alignment, and
not pad unnecessarily...

I think you're safe to rely on the layout for simple things.

You may want to add some static_asserts so there's a compile-time error if
the layout ever changes.


> If reordering is occurring, it would be really nice to disable it
> optionally.
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Chad Austin
Technical Director, IMVU
http://engineering.imvu.com <http://www.imvu.com/members/Chad/>
http://chadaustin.me

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to