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

Rename grow_memory and memory_size? #627

Closed
binji opened this issue Dec 18, 2017 · 24 comments
Closed

Rename grow_memory and memory_size? #627

binji opened this issue Dec 18, 2017 · 24 comments

Comments

@binji
Copy link
Member

binji commented Dec 18, 2017

--bikeshed warning--

As discussed here, we will likely add a suite of new memory operations, mem.init, mem.clear, mem.copy, etc.

We could follow the current naming scheme and call these init_memory, clear_memory, copy_memory (or move_memory), but the mem. syntax is kind of nice, and mimics the style of other instructions. But then we have a bit of a naming wart with grow_memory and memory_size. Should we rename these to mem.grow and mem.size?

@eholk
Copy link

eholk commented Dec 18, 2017

I like mem.grow and mem.size better, and I think it's more consistent with our other names, like i32.add.

Will many things break if we change it?

@binji
Copy link
Member Author

binji commented Dec 18, 2017

The names are referenced in the spec, and exposed to users in the text format. Browser's debuggers display these names too.

But I'm guessing most things won't break because most users and tools don't consume or produce the text format.

@eholk
Copy link

eholk commented Dec 18, 2017 via email

@jfbastien
Copy link
Member

While we're here: mem versus memory?

@binji
Copy link
Member Author

binji commented Dec 18, 2017

I prefer mem, but memory is fine too.

@rossberg
Copy link
Member

+1. If we do this before 1.0 is official we can get away with it.

FWIW, I also prefer mem.

@jfbastien
Copy link
Member

What have we shortened in the spec, versus spelled out fully? I think we should be consistent and choose mem versus memory accordingly.

@rossberg
Copy link
Member

@jfbastien, at least the core spec abbreviates to "mem" everywhere else.

@jfbastien
Copy link
Member

In long names we have Memory, Table, Global, reinterpret, call_indirect, etc.

In shortened names we have varuint32, i32.const, eq / ne / lt / etc, clz, mul, div, rem, trunc.

So we've been quite inconsistent! I don't care which way we go, but we should be consistent. We spell it "Memory" in the current spec, I'd expect memory operations to be spelled the same, but we could decide that all ops need to be abbreviated while object need to be spelled out fully?

This is the tiniest of bikeshed anyways, I don't really care which way we go, but consistency seems missing and that's kind of embarrassing for a Standard (granted, we just accreted things over time and are just stamping them into the standard!).

@eholk
Copy link

eholk commented Dec 19, 2017 via email

@jfbastien
Copy link
Member

In the context of assembly instructions, mem should be perfectly
recognizable, so it seems like going with mem over memory follows the
general rule of using abbreviations where they are well known.

Sure, but the text format already uses memory. Granted it's not an instruction. I think we shouldn't be inconsistent.

@eholk
Copy link

eholk commented Dec 19, 2017 via email

@sunfishcode
Copy link
Member

These names are also exposed to users in various tools; clang has an intrinsic function named __builtin_wasm_grow_memory, LLVM has @llvm.wasm.grow.memory, and Rust and others will likely expose them as well. These tools don't have to reflect the official names, but it's advantageous if they do. So there is value in resolving this sooner rather than later.

The only outstanding issue here is memory vs mem, with most people preferring mem. The arguments against mem are:

As a way to move forward, I propose observing:

  • the text format already has func, a short name, in a similar role as mem (both have corresponding module index spaces), so there's consistency to be had there
  • the rename is a text format change, so other text format changes may be considered at the same time
  • the original names are being replaced, so they're not great examples for new names :-)

So the changes can be:

  • mem.grow and mem.size.
  • rename (memory ...) to (mem ...) in the text format to match
  • tools may continue to accept the old names, as needed, for compatibility

How does this sound?

binji added a commit to WebAssembly/bulk-memory-operations that referenced this issue Jan 18, 2018
This aligns with current interest in using `mem.` prefix for memory
operations, see WebAssembly/spec#627 and
WebAssembly/threads#62 (comment).
@rossberg
Copy link
Member

PR #649 implements this suggestion for spec, interpreter, and tests.

@xtuc
Copy link
Contributor

xtuc commented Jan 26, 2018

I just have a question from the point of view of an implementer; unlike WASM, WATF has no version or header. Wouldn't it be worth adding something like (version 1.0) (module) to allow future breaking changes?

@sunfishcode
Copy link
Member

@xtuc Implementations may continue to accept the old names as long as they wish. #649 doesn't currently preserve support for the old names in the spec repo, but if you think that's worth doing, I encourage you to raise the concern there.

@rossberg
Copy link
Member

During the last meeting some participants did not like the shortening in the memory declaration form. After having converted the entire test suite in #649, I tend to agree, for both aesthetics and minimality of change. I created #720 as an alternative PR that picks the longer names memory.size and memory.grow. We should decide at the next CG meeting.

@littledan
Copy link
Collaborator

I thought the concern was more about the memory section being too short if we switched it to mem; weren't we discussing the possibility of instructions going by mem.grow, etc, and the section staying memory?

@rossberg
Copy link
Member

@littledan, there was a strong sentiment in the above discussion that both should be consistent, and I agree.

@NWilson
Copy link

NWilson commented Feb 27, 2018

As a random aside - if memory.grow is preferable to grow_memory, surely also global.get and local.tee are preferable to get_global and tee_local? They operate on global/local objects, in the same way that the memory opcodes operate on a memory object.

@rossberg
Copy link
Member

@NWilson, funny you bring that up, because I was just editing a comment to the same effect. Right now, it is not really clear what our overarching naming scheme for instructions is. With the proposed change, we have X. prefixes where X can be one of two things: (1) a value type, (2) an entity (one of the things that has either its own namespace or can be ex/imported). If we wanted to be more consistent, then we may also want to rename the *global and *local instructions. One could even argue that call_indirect should be renamed table.call, which seems in line with the table.get/set instructions proposed elsewhere.

I don't have a good answer. It becomes even less clear when considering various future extensions.

@RyanLamansky
Copy link

This seems like the best possible time to go over the MVP spec and all the upcoming extensions that have proposed their own new opcodes to come up with some kind of harmony and consistency.

@binji
Copy link
Member Author

binji commented Mar 21, 2018

At the March 21st CG meeting, we discussed whether to choose memory or mem. There weren't any strong opinions about it w.r.t. the instruction names, but some preferred that the section name not be shortened to mem, and there was an additional desire to be consistent between the instruction and section names. As a result, the group decided to go with memory.

@rossberg
Copy link
Member

rossberg commented May 3, 2018

This has landed.

@rossberg rossberg closed this as completed May 3, 2018
binji added a commit to WebAssembly/bulk-memory-operations that referenced this issue May 7, 2018
This follows the naming discussed in issue
WebAssembly/spec#627.
patrick-east added a commit to patrick-east/opa that referenced this issue Jul 9, 2020
As part of this update we needed to change the memory grow builtins.
The version we used were removed in https://reviews.llvm.org/D56645
after (apparently) having been deprecated for some time. The newer
versions match up with more recent versions of the WASM spec (see
WebAssembly/spec#627 for more context).

The WebAssembly/wabt version is also updated to the latest release to
correct build issues with the older one and llvm 10.

Upgrading should prevent a deadlock we saw periodically in the CI
while building the OPA wasm binaries.

Signed-off-by: Patrick East <[email protected]>
patrick-east added a commit to open-policy-agent/opa that referenced this issue Jul 10, 2020
As part of this update we needed to change the memory grow builtins.
The version we used were removed in https://reviews.llvm.org/D56645
after (apparently) having been deprecated for some time. The newer
versions match up with more recent versions of the WASM spec (see
WebAssembly/spec#627 for more context).

The WebAssembly/wabt version is also updated to the latest release to
correct build issues with the older one and llvm 10.

Upgrading should prevent a deadlock we saw periodically in the CI
while building the OPA wasm binaries.

Signed-off-by: Patrick East <[email protected]>
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

9 participants