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

Optimization: use unions for representing RuntimeValue #99

Closed
pepyakin opened this issue Jun 20, 2018 · 2 comments · Fixed by #133
Closed

Optimization: use unions for representing RuntimeValue #99

pepyakin opened this issue Jun 20, 2018 · 2 comments · Fixed by #133
Labels
help wanted Extra attention is needed

Comments

@pepyakin
Copy link
Collaborator

pepyakin commented Jun 20, 2018

Depends on #98

Currently, a RuntimeValue is represented by a rust enum.

As a refresher: A rust enum requires space for the variant tag plus the size of a payload of the largest variant, which also requires to be properly aligned. Thus, a RuntimeValue takes 8 bytes for the payload (for 64-bit wide values) and 8 bytes for the alignment (on x86_64).

We can shelve 8 bytes by removing a tag. We can achieve it by using C-like unions for representing runtime values internally. It is possible because after validation it is statically guaranteed that each operation will be used with operands of appropriate types (i.e., f32.* operators will always be used with f32 operands).

Shrinking RuntimeValue may potentially improve cache efficiency for the operand stack and remove branching to check operand types.

@pepyakin pepyakin added the help wanted Extra attention is needed label Jun 21, 2018
@leoyvens

This comment has been minimized.

@pepyakin

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants