Changing the object layout of a base class is non-trivial, mainly because of the many different places that have hard-coded assumptions.
If you just need an additional pointer in certain objects, have you considered creating those objects via ObjectTemplates / FunctionTemplates and add "internal fields"? This gives you additional slots in the objects you can use for whatever you like. On Thu, Apr 28, 2016 at 1:13 AM <[email protected]> wrote: > Hi all! > > As we know V8 objects, despite having C++ class definitions, are *not* > created in the same way as normal C++ objects. Instead, a small object > header is used and object components are addressed by offsets relative to > the object's base address. For example, the offset of HeapObject's map is > given in the class definition as kMapOffset. To retrieve the map, an > accessor method is defined which ultimately calls READ_FIELD(). > > Has anyone here tried to extend object header? I currently find myself in > a situation where it would be convenient to add a pointer field into the > header of all objects derived from HeapObject. It's easy enough to add > another kXYZOffset and change HeapObject::kHeaderSize accordingly (and > fixing a handful of STATIC_ASSERT's). I'm wondering what else needs to be > taken into account to make it work. So far I've taken care to add this new > field after the map and initializing the new field to NULL whenever > AllocateRaw() is called, but Chromium crashes on startup. What else am I > missing? Or is V8 too optimized for this to be easily done? > > -- > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" 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. > -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" 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.
