Skip to content

make functions frameless if they don't need a frame #43208

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
mraleph opened this issue Aug 27, 2020 · 3 comments
Open

make functions frameless if they don't need a frame #43208

mraleph opened this issue Aug 27, 2020 · 3 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size vm-aot-code-size Related to improvements in AOT code size

Comments

@mraleph
Copy link
Member

mraleph commented Aug 27, 2020

If a function is a leaf and does not contain any spills it does not need a frame.

POC mraleph@a70a694 reveals that a lot of functions in Flutter Gallery fit this definition - and dropping frame setup leads to a significant code size improvement (and potentially performance improvement as well).

Store barrier introduces a slight complication into this on ARM/ARM64 because of its outlined slow-path. This slow-path can only call leaf-runtime entry, but nevertheless calling the slow-path clobbers LR. We already support generating store barriers in intrinsics - which are also frameless and thus don't have LR saved - however this introduces explicit pushing and popping of LR which needs to be taken into account when deciding if it is worth to setup a frame (e.g. POC allows at most 1 instruction with a store barrier per frameless function). One dodgy part here is the lack of static guarantee: location summaries capture which instructions perform calls and which don't, with the exception of store barrier call. I suggest that turning POC into a real implementation requires at least adding an assertion that checks that branch-link instruction is only allows to be emitted when IL instruction is marked as clobbering LR.

part of go/dart-llvm-assessment

/cc @mkustermann for triage and assignment

@mraleph mraleph added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size vm-aot-code-size Related to improvements in AOT code size labels Aug 27, 2020
@mraleph
Copy link
Member Author

mraleph commented Aug 27, 2020

While discussing this with @mkustermann I have done a bit of digging into why this had such a drastic effect on Flutter Gallery size. Turns out that it disproportionally hits localisation related getters which are generated in large numbers on Flutter Gallery because it supports a lot of different locales. We have 83906 frameless functions and 21303 framefull functions - however out of 83906 frameless functions 80938 originate from localization related generated code.

This means on an average Flutter application this is not likely to have similar impact (unless of course it includes similar amount of localizations done in a similar way).

/cc @alexmarkov

@mkustermann
Copy link
Member

We already had a bug for this in #40195 . Due to more context here I'll close the other issue.

@sstrickl is going to work on this soon.

@mkustermann
Copy link
Member

@mraleph Since you made the PoC, maybe you can upstream them as well?

@mkustermann mkustermann assigned mraleph and unassigned sstrickl Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size vm-aot-code-size Related to improvements in AOT code size
Projects
None yet
Development

No branches or pull requests

3 participants