Providing some context based on offline discussions.
Description
The main focus of this effort is to enable optimizations on Mono fullAOT platforms, mainly WASM and iOS.
The plan is to initially conduct experiments on both platforms WASM (first) and iOS (in a later stage) to estimate potential improvements (size savings and better performance) before proceeding with the concrete implementation. This is especially true for requirement 2. (listed in Prerequisites section) as it requires changes in an external tool.
Limitation
For every compiled method MonoAOT compiler generates an implicit reference to a method, by adding an entry into method_id->method tables which are used by the runtime to perform the method lookup/dispatch during its invocation.
This prevents optimization passes to better optimize the generated code.
Prerequisites
In order to remove the limitation, several tasks have to be done:
Identify for which methods types the optimization can be applied - example: private and/or internal members
Provide MonoAOT compiler with additional information about a method usage - method_id->method entries cannot be removed for methods accessed via reflection or referenced from other assemblies.
This information could come from ILLinker as it has a global view of the program and performs reflection analysis. It would be required to implement an ILLinker pass which would decorate:
private members with a custom attribute that ensures a member is not accessed via reflection (similar to DisablePrivateReflectionAttribute)
internal members with a custom attribute that ensures a member is not accessed via reflection or from a different assembly InternalsVisibleToAttribute
Providing some context based on offline discussions.
Description
The main focus of this effort is to enable optimizations on Mono fullAOT platforms, mainly
WASM
andiOS
.The plan is to initially conduct experiments on both platforms
WASM
(first) andiOS
(in a later stage) to estimate potential improvements (size savings and better performance) before proceeding with the concrete implementation. This is especially true for requirement2.
(listed inPrerequisites
section) as it requires changes in an external tool.Limitation
For every compiled method MonoAOT compiler generates an implicit reference to a method, by adding an entry into
method_id->method
tables which are used by the runtime to perform the method lookup/dispatch during its invocation. This prevents optimization passes to better optimize the generated code.Prerequisites
In order to remove the limitation, several tasks have to be done:
method_id->method
entries cannot be removed for methods accessed via reflection or referenced from other assemblies. This information could come from ILLinker as it has a global view of the program and performs reflection analysis. It would be required to implement an ILLinker pass which would decorate:DisablePrivateReflectionAttribute
)InternalsVisibleToAttribute
no_method_table_lmethods
(add entry) - WASMmethod_addresses
(remove entry) - iOSllvm.used
Additional notes
opt
:--attributor-enable=all