I've looked at optimizing dynamic_cast to final C++ class. In theory, it should be possible to load the vtable pointer, compare it to the expected value, and use the original pointer if it matches, or NULL otherwise (for pointers, references are similar but need the conditional throw).

But I remember a discussion on the cxxabi list that vtables are not deduplicated if they are contained in multiple libraries, so a simple pointer comparison won't do. Is there anything else that could be used as a reliable marker? If not, do you think it would be feasible to add a fast-path for final target classes to the __dynamic_cast implementation?

--
Florian Weimer / Red Hat Product Security Team

Reply via email to