If T is a final type, we do not need to traverse hierarchy. Consider a final type T, jsDynamicCast<T*>(vm, cell); in this case, if (cell->classInfo(vm) == T::info()) return static_cast<T*>(cell); return nullptr; is enough. We can this optimization in JSCast.h with std::is_final<T>.
Created attachment 335299 [details] Patch
Created attachment 335304 [details] Patch
Comment on attachment 335304 [details] Patch r=me
Thanks!
Committed r229413: <https://trac.webkit.org/changeset/229413>
<rdar://problem/38267844>