• Philip Chimento's avatar
    jsapi-util-root: Use a union for mutually exclusive members · 4e7f4a53
    Philip Chimento authored
    In GjsMaybeOwned<T> the JS::Heap<T> and JS::PersistentRooted<T>* members
    are mutually exclusive. The m_rooted flag determines which one we are
    using. Therefore, we can put the two in a union to save space.
    
    The only thing we have to do is watch out when switching from one mode to
    the other. When switching to rooted, we have to be careful to call the
    destructor of JS::Heap, and when switching to unrooted we have to use
    placement-new to construct a JS::Heap in the location of the union.
    
    This reduces the size of ObjectInstance to 88 bytes on x86_64 (although
    when the GjsMaybeOwned is in rooted mode, that is, the ObjectInstance is
    in toggle ref mode and a GObject owns a reference to it, there are 32
    "hidden" bytes allocated for the PersistentRooted.)
    4e7f4a53
Name
Last commit
Last update
..
byteArray.cpp Loading commit data...
byteArray.h Loading commit data...
console.cpp Loading commit data...
context-private.h Loading commit data...
context.cpp Loading commit data...
context.h Loading commit data...
coverage.cpp Loading commit data...
coverage.h Loading commit data...
engine.cpp Loading commit data...
engine.h Loading commit data...
gjs.h Loading commit data...
gjs.stp.in Loading commit data...
global.cpp Loading commit data...
global.h Loading commit data...
importer.cpp Loading commit data...
importer.h Loading commit data...
jsapi-class.h Loading commit data...
jsapi-dynamic-class.cpp Loading commit data...
jsapi-util-args.h Loading commit data...
jsapi-util-error.cpp Loading commit data...
jsapi-util-root.h Loading commit data...
jsapi-util-string.cpp Loading commit data...
jsapi-util.cpp Loading commit data...
jsapi-util.h Loading commit data...
jsapi-wrapper.h Loading commit data...
macros.h Loading commit data...
mem.cpp Loading commit data...
mem.h Loading commit data...
module.cpp Loading commit data...
module.h Loading commit data...
native.cpp Loading commit data...
native.h Loading commit data...
profiler-private.h Loading commit data...
profiler.cpp Loading commit data...
profiler.h Loading commit data...
stack.cpp Loading commit data...