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?