Skip to content
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

Optimize static constructor calls/checks #303

Open
drcjt opened this issue Jul 14, 2023 · 1 comment
Open

Optimize static constructor calls/checks #303

drcjt opened this issue Jul 14, 2023 · 1 comment
Labels
tenet-performance Performance related issue

Comments

@drcjt
Copy link
Owner

drcjt commented Jul 14, 2023

Currently any of the triggers listed in ECMA 335 I.8.9.5 will cause the compiler to insert a call to the static constructor.
The code for the static constructor will self modify when running to replace itself with a single return instruction so subsequent calls to it will do nothing.

There is definitely room for improvement in terms of reducing the number of calls to the static constructors.
A method that performs two static field accesses to the same class with a static constructor will end up calling the static constructor twice. Would be good to try and implement some of these unnecessary calls

Consider recording details of static constructors called in a basic block and only add new calls if there isn't already a call being made

@drcjt drcjt added the tenet-performance Performance related issue label Jul 14, 2023
@drcjt
Copy link
Owner Author

drcjt commented Jul 14, 2023

Maybe take inspiration from similar work in real dotnet runtime here -> dotnet/runtime#64242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tenet-performance Performance related issue
Projects
None yet
Development

No branches or pull requests

1 participant