Skip to content

Update J2CLItableMerging to consider custom descriptors #7729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mason-lgtm
Copy link

Update J2CLItableMerging to consider types whose vtables are custom descriptors

@kripken kripken requested a review from tlively July 16, 2025 00:08
continue;
}
vtabletype = descriptor;
itabletype = type.fields[0].type.getHeapType();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to reserve field 0 in the descriptor. Once we have JS interop, the JS prototype will (almost certainly) have to be stored in field 0.

Comment on lines +125 to +126
if (!typeNameInfo.fieldNames.count(1) ||
!typeNameInfo.fieldNames[1].equals("itable")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we should have a similar check before looking up the name of field 0. Also, we can avoid double lookup by doing this:

Suggested change
if (!typeNameInfo.fieldNames.count(1) ||
!typeNameInfo.fieldNames[1].equals("itable")) {
if (auto it = typeNameInfo.fieldNames.find(1);
it == typeNameInfo.fieldNames.end() || it->second.equals("itable")) {

Comment on lines +112 to +113
std::optional<HeapType> vtabletype;
std::optional<HeapType> itabletype;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these would be empty, then we'll just continue to the next loop iteration anyway, so I don't see a reason to make them optional.

Suggested change
std::optional<HeapType> vtabletype;
std::optional<HeapType> itabletype;
HeapType vtabletype;
HeapType itabletype;

.fields[0]
.type));

HeapType& javaClass = parent.structInfoByITableType[curr->type.getHeapType()]->javaClass;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A HeapType is represented as a single number, so no need to take a reference to it unless you're going to mutate it.

Suggested change
HeapType& javaClass = parent.structInfoByITableType[curr->type.getHeapType()]->javaClass;
HeapType javaClass = parent.structInfoByITableType[curr->type.getHeapType()]->javaClass;

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.

2 participants