Skip to content

Conversation

@pettyjamesm
Copy link
Contributor

@pettyjamesm pettyjamesm commented May 16, 2024

Allows temp variables to be reused within the same Scope instance after being released. This allows relatively smaller method bytecode sizes by using relatively fewer variable slots- which becomes significant since:

  • accessing variable slots 0 - 3 is a single bytecode operation: aload_0, aload_1, aload_2, aload_3
  • accessing variable slots 3 - 255 takes two bytes: aload <index>
  • accessing variable slots 256+ takes 4 bytes: wide aload <two byte index>

Similar overheads are incurred when storing values into a variable, and for other non-reference type load/store bytecode operations.

@pettyjamesm
Copy link
Contributor Author

@electrum / @dain PTAL

Copy link
Member

@dain dain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I was going to add this years ago and never got to it :)

@dain dain merged commit 8d0a634 into airlift:master May 16, 2024
@pettyjamesm pettyjamesm deleted the reusable-temp-variables branch May 16, 2024 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants