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

Fix arrays to store their primitive elements contiguously. #737

Open
otrho opened this issue Feb 3, 2022 · 3 comments
Open

Fix arrays to store their primitive elements contiguously. #737

otrho opened this issue Feb 3, 2022 · 3 comments
Labels
compiler: codegen Everything to do with IR->ASM, register allocation, etc. compiler General compiler. Should eventually become more specific as the issue is triaged enhancement New feature or request

Comments

@otrho
Copy link
Contributor

otrho commented Feb 3, 2022

At the moment all types smaller than 64 bits are cast up to 64 bit values in the ASM generation, so they fit in a register nicely, and work easily with lw and sw. This is also true for arrays, so an array of bytes is actually converted to an array of u64. This is both wasteful and unexpected, from a developer point of view.

@otrho otrho added enhancement New feature or request compiler General compiler. Should eventually become more specific as the issue is triaged labels Feb 3, 2022
@otrho
Copy link
Contributor Author

otrho commented Feb 3, 2022

Having [byte] actually mean a stream of bytes would already be useful for the B512 type in the Sway std library.

@adlerjohn
Copy link
Contributor

Something to consider: the internal memory representation is currently identical to the ABI representation. This allows no-copy, direct use of parameters passed in from userspace (with an optional safety check that's either constant-time or linear in the number of fields rather than linear in the number of bytes, as a serialize/deserialize pass would be).

Changing anything about the internal representation of things also requires a change to the ABI specification to preserve this property.

@otrho
Copy link
Contributor Author

otrho commented Feb 3, 2022

This talks specifically about padding smaller values. https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/abi.md#unsigned-integers

And here for arrays https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/abi.md#array

@otrho otrho self-assigned this Jun 23, 2022
@otrho otrho removed their assignment Oct 25, 2022
@anton-trunov anton-trunov added the compiler: codegen Everything to do with IR->ASM, register allocation, etc. label Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: codegen Everything to do with IR->ASM, register allocation, etc. compiler General compiler. Should eventually become more specific as the issue is triaged enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

3 participants