-
Notifications
You must be signed in to change notification settings - Fork 74
Improve finding edges to data segments #45
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
Comments
This should help us get useful information about data segments: https://reviews.llvm.org/D46417 |
🔍 From sprinkling if let I32Const(base) = code[i - 1] {
if let Some(data_id) = items.get_data(base as u32 + off) {
items.add_edge(body_id, data_id);
}
} However, I'm just beginning to wrap my mind around what's happening there... currently, I fail to understand the meaning (and necessity) of Also, am I right assuming that optimizing data segments isn't all that simple -- we cannot drop something without changing all existing offsets. I suppose it could be overwritten with zeros, and thus be end up being better to compress? (And additionally, it's hard to determine when the default data segment content from the wasm file is used, or when it is overwritten (using the |
Update -- I've found a reference for my 💭 points above: https://github.com/rust-lang-nursery/rust-wasm/issues/21 ✅ |
Accessing
The The thing is, this will only work for static indices, where the offset is embedded in the instruction. Any kind of dynamic indexing into the array won't be seen by this (very simple, conservative) analysis. I suspect that this is what is happening in practice.
The only way to safely remove them is by having and parsing relocations from the linker. Twiggy is just performing (or at least attempting to perform) a conservative analysis for informative purposes. It can't be complete unless both (1) relocations are present, and (2) we teach twiggy how to understand them. That said, it would be cool to add that feature, and it would also be cool to extend our conservative analysis to understand more cases. In general, I think a full abstract interpreter for wasm would be super useful here, although that definitely belongs in a project of its own :) |
@fitzgen thanks for shedding some light on this 😃 |
Ok, clearly this wasm's size has a lot going on in the data section:
Which functions are using this data?
No edges to the data segments found. I don't believe that is accurate.
The text was updated successfully, but these errors were encountered: