Skip to content

[interop] Use the object for offsets through virtual bases - #145

Open
jmcarcell wants to merge 3 commits into
compiler-research:mainfrom
jmcarcell:vbase-offset
Open

jmcarcell wants to merge 3 commits into
compiler-research:mainfrom
jmcarcell:vbase-offset

Conversation

@jmcarcell

@jmcarcell jmcarcell commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Fix crashes in Gaudi when an interface has a virtual base and the complete dynamic type is unknown to the interpreter. A static offset for the interface's complete-object layout can point to the wrong subobject.

GetBaseOffset now forwards the live derived-subobject address to Cpp::GetBaseClassOffset for upcasts. Downcasts use static layout offsets because callers obtain the complete type through GetActualClass. Remove the generated cast helpers and their cache.

Strengthen the hidden-type regression with a nonzero offset after the virtual edge, and add coverage for downcasts from virtual bases to a known complete type.

Depends on compiler-research/CppInterOp#1145. CPPINTEROP_GIT_TAG needs updating after that PR merges; builds against the current default pin remain blocked by the API dependency.

Validated against the updated local CppInterOp source with LLVM 22: 83 tests passed and 2 expected failures across advanced C++, basic API, cross-inheritance, and conversions. Ruff and formatting checks passed.

jmcarcell and others added 3 commits October 17, 2026 08:43
Use the new GetBaseClassOffset(derived, base, address) API for up-casts,
which reads virtual base offsets from the object's vtable/vbtable when
needed. This eliminates the need for IsBaseReachedVirtually checks and
the per-pair JIT-compiled helper for up-casts.

Down-casts still use the generated helper as they require dynamic_cast
semantics that GetBaseClassOffset does not provide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant