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

Local definition clarification #499

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions AstSemantics.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ instead expected release unused physical pages from the working set using the

Each function has a fixed, pre-declared number of local variables which occupy a single
index space local to the function. Parameters are addressed as local variables. Local
variables do not have addresses and are not aliased by linear memory. Local
variables have value types and are initialized to the appropriate zero value for their
type at the beginning of the function, except parameters which are initialized to the values
of the arguments passed to the function.
variables do not have addresses and are not aliased by linear memory. By doing so, local
variables become in essence virtual registers that may or not require a stack slot when
lowering to machine code. Local variables have value types and are initialized to the
appropriate zero value for their type at the beginning of the function, except parameters
which are initialized to the values of the arguments passed to the function.

* `get_local`: read the current value of a local variable
* `set_local`: set the current value of a local variable
Expand All @@ -225,6 +226,9 @@ The details of index space for local variables and their types will be further c
e.g. whether locals with type `i32` and `i64` must be contiguous and separate from
others, etc.

Finally, because local variables can be seen as virtual registers, `get_local` and
Copy link

Choose a reason for hiding this comment

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

This is a lot of low-level detail that is probably only interesting to engine implementors and compiler people, so I don't think that it is necessary here.

`set_local` are not automatically going to be translated into load/store instructions.

## Control flow structures

WebAssembly offers basic structured control flow with the following constructs.
Expand Down
6 changes: 6 additions & 0 deletions Rationale.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ producers can use to pre-color variables and give hints to a WebAssembly VM's
register allocation algorithms, offloading some of the optimization work from
the WebAssembly VM.

Finally, because it is not possible to take the address of the local variables,
one can see local variables as virtual registers that do not automatically
have a designated memory location for storing the temporary calculations.
WebAssembly locals therefore become whatever the code generator requires to generate
the code. In some cases, they might become a physical register. In other cases,
they might become a stack slot.

## Variable-Length Argument Lists

Expand Down