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

Consider a pointer size integer type #50

Open
Serentty opened this issue Dec 15, 2019 · 2 comments
Open

Consider a pointer size integer type #50

Serentty opened this issue Dec 15, 2019 · 2 comments

Comments

@Serentty
Copy link

Right now, lengths and sizes seem to be stored using a u32. At the moment, this is fine for all existing WebAssembly code. However, given that there will be 64-bit linear memories in the future, I think it would make sense to abstract this detail away to allow the same code to be recompiled for such larger linear memories.

@menduz
Copy link
Member

menduz commented Dec 16, 2019

Hi there, thanks for commenting.

I didn't think much about sizes and lengths >32bit so far. What you say makes a lot of sense.

Did you think about a way to do it already? I can think about a couple of ways but those either generate a ton of wasm code to cast back and forth 32<>64bit numbers when interacting with lengths and sizes or are specialized "big strings" "big lists" which are unpleasant to think about..

Regarding pointers, even though Lys is wasm32, the memory layout of pointers is ready for wasm64.
To get the memory address of a reference (64bit) we take the first 32bits

fun addressFromRef(pointer: ref): u32 = %wasm {
(i32.wrap_i64 (get_local $pointer))
}

@Serentty
Copy link
Author

Well, I expect that even after multiple memories, WebAssembly modules will still generally have a “home” address space, and I would expect usize to the be same number of bits as that address space.

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

No branches or pull requests

2 participants