-
Notifications
You must be signed in to change notification settings - Fork 779
[NFC] Make public type collection more efficient #7561
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
Conversation
Previously public type collection worked by collecting all types in the module, classifying their visibility, then picking out all the public types to return. However, visibility classification requires directly finding the public types from the imports and exports in the first place, so the initial step of collecting all the types was unnecessary. Refactor the code so `getPublicHeapTypes` calculates the public types directly from the imports and exports and `classifyTypes` uses those results to classify visibility only when collecting all types from the module anyway.
} | ||
} | ||
|
||
void setIndices(IndexedHeapTypes& indexedTypes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, the moved code was so large that it's a smaller diff to show everything else moving around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
src/ir/module-utils.cpp
Outdated
return types; | ||
} | ||
|
||
std::vector<HeapType> getPublicHeapTypes(Module& wasm) { | ||
// We will need to traverse the types used by public types and mark them | ||
// public as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"as well" seems odd in the first comment of a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's referring to the original public types also introduced in this sentence, so I think it makes sense. I will clarify in general, though.
Previously public type collection worked by collecting all types in the
module, classifying their visibility, then picking out all the public
types to return. However, visibility classification requires directly
finding the public types from the imports and exports in the first
place, so the initial step of collecting all the types was unnecessary.
Refactor the code so
getPublicHeapTypes
calculates the public typesdirectly from the imports and exports and
classifyTypes
uses thoseresults to classify visibility only when collecting all types from the
module anyway.