Virtual Calls: Make the ABI match the implementations
Christophe de Dinechin
ddd at cup.hp.com
Fri Sep 15 22:18:39 UTC 2000
Folks,
Mark and Christophe discussed the various existing implementations regarding the
virtual call mechanism. The implementation of vcall offset thunks is additional
work relative to existing practice. With a minor tweak, we can leave room for
the proposed optimization while not implementing it right away.
The proposal is that thunks are implemented as weak symbols (as they are
generally today.) If an implementation decides to emit fall-through thunks, then
it emits these thunks along with the function, as strong symbols. In that case,
they will take precedence at link time.
To allow for the "full" fall through optimization even in the case of virtual
bases, vcall offsets are preserved. They will not be used in most
implementations today, that emit weak thunks at call site, rather than strong
thunks at callee site.
This proposal is in-line with the current priority, which is to get the ABI to
reflect what actual compilers will implement.
The specific proposal is to rephrase the paragraph in 5.2.6:
From:
In such cases, where the need for a thunk is identified after the base function
is declared, the thunk is emitted in a COMDAT group, identified by the (mangled)
thunk name. It must be emitted in the object containing the key function
definition for any class that causes it to be needed (D in the above example),
or in all objects referencing it if there is no key function. Observe that
different class hierarchies with the same virtual base may require override
thunks for the same base function, which will coincide iff the adjustment
offsets do.
To:
All thunks must be emitted in COMDAT groups in all object files which reference
them. As an optimization, thunks may be emitted as strong (non-COMDAT) symbols
in the same object file as the function to which they ultimately transfer
control. This optimization permits the fall-through implementation of thunks
described in the ABI Examples document.
References to vcall offsets or vbase offsets at other places in the document are
unchanged. Vcall offsets in particular are still needed to allow a complete
fall-through optimization to happen in all cases.
Mark and Christophe
More information about the cxx-abi-dev
mailing list