On 20/04/2012 19:44, Marvin Humphrey wrote:
On Fri, Apr 20, 2012 at 3:02 AM, Nick Wellnhofer<[email protected]>  wrote:
On 19/04/2012 23:55, Marvin Humphrey wrote:
Unfortunately, applying this patch would severely constrain the development
of the Lucy core.  Because it freezes the layout of our vtables by
hard-coding the offsets at which method pointers are located, we would not
be able to add new methods to Lucy (among other problems) without breaking
compiled extensions.

But that's exactly what we do right now. The offsets are never changed.

Heh.

The original concept was to have one OFFSET var per novel method.  However,
that design was flawed because it caused the ABI to break if the method's
novel declaration moved from one class to another, e.g. up into a parent
class: a compiled extension would be counting on the existence of
Parcel_OldClass_MethodName_OFFSET, but that var would go away with the new
release of the core, breaking ABI compat.

Creating OFFSET vars for every invocant/method-name combo solved that problem,
though at the cost of considerable DLL symbol proliferation.  However, as you
point out, a mechanism to propagate the offsets was never introduced.

OK, I see. Then I would propose the following solution: We go back to defining offsets only for novel methods. But we define the offset variables per-parcel even for included classes. Then we lookup the offsets of included methods by method name at run-time. We'll have to store a bit of method metadata to make this work. Patch 03 in LUCY-231 already goes in that direction.

So a compiled extension would have something like the following in parcel.c:

size_t ext_Hash_fetch_OFFSET;

...

void
ext_bootstrap_parcel() {
    ext_Hash_fetch_OFFSET
        = cfish_VTable_find_offset(LUCY_HASH, "Fetch");
    ...
}

Note that the offsets of included classes are also prefixed with "ext_", not "lucy_". Every extension will use its own private copy. This makes it possible to hide the offset variables in the DLL.

VTable_find_offset can then find the correct offset even if a novel method has moved to a parent class.

Nick

Reply via email to