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

feat(interface-types) New numbers and strings instructions #1329

Conversation

Hywan
Copy link
Contributor

@Hywan Hywan commented Mar 24, 2020

This PR does 3 things:

  • Transforms the x-to-y number lowerings and liftings instructions to the new set of instructions y.from_x. It's just the opposite. It's more logical, but the diff is dense due to that. The lowering_lifting module is renamed numbers.
  • Renames memory-to-string to string.lift_memory, and string-to-memory to string.lower_memory. It's also more logical, but the diff is dense due to that too. The memory_to_string and string_to_module modules are merged into the strings module.
  • Introduce the new string.size instruction (in the strings module).

I think commits are clean and atomic enough, so it might be better to review it like that.

For binary encoding/decoding, the binary representation is absolutely entirely arbitrary (since the working notes define nothing, obviously).

Cf https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/working-notes/Instructions.md

Hywan added 3 commits March 24, 2020 12:43
Basically the `x-to-y` instructions have been renamed `y.from_x`. This
patch updates the instruction. The binary representation isn't
specified yet, so it's just arbitrary values.
@Hywan Hywan changed the title feat(interface-types) New types and instructions feat(interface-types) New numbers and strings instructions Mar 24, 2020
@Hywan Hywan marked this pull request as ready for review March 24, 2020 14:42
Copy link
Contributor

@MarkMcCaskey MarkMcCaskey left a comment

Choose a reason for hiding this comment

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

Looks good to me!

)
})?;

let pointer = to_native::<i32>(&inputs[0], instruction)? as usize;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the fact this is an i32 cause a problem? It seems that we can't access the upper 2gb of memory by casting from i32 to usize because -1i32 as usize is 18446744073709551615; -1i32 as u32 as usize is 4294967295 which seems closer to what we'd want here.

If this is a mistake, perhaps we should add some tests using the upper 2gb of memory to make sure everything is working as expected as this issue will likely be in a lot of places!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. The pointer is of kind i32 in the spec. It is regular a Wasm core type i32. Our API needs a usize, hence the casting.

You're right we need to check it is positive. I'm opening an issue to focus on that.

@Hywan
Copy link
Contributor Author

Hywan commented Mar 26, 2020

bors r+

bors bot added a commit that referenced this pull request Mar 26, 2020
1329: feat(interface-types) New numbers and strings instructions r=Hywan a=Hywan

This PR does 3 things:

* Transforms the `x-to-y` number lowerings and liftings instructions to the new set of instructions `y.from_x`. It's just the opposite. It's more logical, but the diff is dense due to that. The `lowering_lifting` module is renamed `numbers`.
* Renames `memory-to-string` to `string.lift_memory`, and `string-to-memory` to `string.lower_memory`. It's also more logical, but the diff is dense due to that too. The `memory_to_string` and `string_to_module` modules are merged into the `strings` module.
* Introduce the new `string.size` instruction (in the `strings` module).

I think commits are clean and atomic enough, so it might be better to review it like that.

For binary encoding/decoding, the binary representation is absolutely entirely arbitrary (since the working notes define nothing, obviously).

Cf https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/working-notes/Instructions.md

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
Co-authored-by: Ivan Enderlin <ivan.enderlin@wanadoo.fr>
@syrusakbary syrusakbary merged commit 531ec45 into wasmerio:master Mar 26, 2020
@bors
Copy link
Contributor

bors bot commented Mar 26, 2020

Timed out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation Do you like to read? 🎉 enhancement New feature! 🧪 tests I love tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants