v8/test/cctest/wasm
Enrico Bacis 6cd7a5a73a [wasm] Introduce the WasmContext
The WasmContext struct introduced in this CL is used to store the
mem_size and mem_start address of the wasm memory. These variables can
be accessed at C++ level at graph build time (e.g., initialized during
instance building). When the GrowMemory runtime is invoked, the context
variables can be changed in the WasmContext at C++ level so that the
generated code will load the correct values.

This requires to insert a relocatable pointer only in the
JSToWasmWrapper (and in the other wasm entry points), the value is then
passed from function to function as an automatically added additional
parameter. The WasmContext is then dropped when creating an Interpreter
Entry or when invoking a JavaScript function. This removes the need of
patching the generated code at runtime (i.e., when the memory grows)
with respect to WASM_MEMORY_REFERENCE and WASM_MEMORY_SIZE_REFERENCE.
However, we still need to patch the code at instance build time to patch
the JSToWasmWrappers; in fact the address of the WasmContext is not
known during compilation, but only when the instance is built.

The WasmContext address is passed as the first parameter. This has the
advantage of not having to move the WasmContext around if the function
does not use many registers. This CL also changes the wasm calling
convention so that the first parameter register is different from the
return value register. The WasmContext is attached to every
WasmMemoryObject, to share the same context with multiple instances
sharing the same memory. Moreover, the nodes representing the
WasmContext variables are cached in the SSA environment, similarly to
other local variables that might change during execution.  The nodes are
created when initializing the SSA environment and refreshed every time a
grow_memory or a function call happens, so that we are sure that they
always represent the correct mem_size and mem_start variables.

This CL also removes the WasmMemorySize runtime (since it's now possible
to directly retrieve mem_size from the context) and simplifies the
GrowMemory runtime (since every instance now has a memory_object).

R=ahaas@chromium.org,clemensh@chromium.org
CC=gdeepti@chromium.org

Change-Id: I3f058e641284f5a1bbbfc35a64c88da6ff08e240
Reviewed-on: https://chromium-review.googlesource.com/671008
Commit-Queue: Enrico Bacis <enricobacis@google.com>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48209}
2017-09-28 16:14:03 +00:00
..
OWNERS Add eholk to Wasm-related OWNERS files 2017-08-10 18:58:00 +00:00
test-c-wasm-entry.cc Revert "Revert "[wasm] Rename TestingModule to TestingModuleBuilder."" 2017-08-19 16:34:27 +00:00
test-run-wasm-64.cc [wasm] Allow traps in tests with many parameters in cctests 2017-09-26 07:53:39 +00:00
test-run-wasm-asmjs.cc [wasm] Introduce the WasmContext 2017-09-28 16:14:03 +00:00
test-run-wasm-atomics.cc [wasm] Use the right access operand for atomic ops 2017-09-23 19:52:42 +00:00
test-run-wasm-interpreter.cc [jumbo] add test namespaces for cctest 2017-09-21 08:46:16 +00:00
test-run-wasm-js.cc [jumbo] drop duplicate BUILD macro from test-run-wasm-js.cc 2017-09-22 11:15:08 +00:00
test-run-wasm-module.cc [wasm] Introduce the WasmContext 2017-09-28 16:14:03 +00:00
test-run-wasm-relocation.cc [jumbo] add test namespaces for cctest 2017-09-21 08:46:16 +00:00
test-run-wasm-simd.cc [jumbo] add test namespaces for cctest 2017-09-21 08:46:16 +00:00
test-run-wasm.cc [jumbo] add test namespaces for cctest 2017-09-21 08:46:16 +00:00
test-streaming-compilation.cc [wasm] Streaming compilation for WebAssembly. 2017-09-15 06:36:25 +00:00
test-wasm-breakpoints.cc [iwyu] Extend inline include checking to tests. 2017-09-08 09:31:32 +00:00
test-wasm-interpreter-entry.cc [wasm] Remove 'using namespace' from cctest/wasm 2017-09-01 13:49:24 +00:00
test-wasm-stack.cc [wasm] remove movable objects from WasmToJsWrapper 2017-09-21 19:24:42 +00:00
test-wasm-trap-position.cc [jumbo] add test namespaces for cctest 2017-09-21 08:46:16 +00:00
wasm-run-utils.cc [wasm] Introduce the WasmContext 2017-09-28 16:14:03 +00:00
wasm-run-utils.h [wasm] Introduce the WasmContext 2017-09-28 16:14:03 +00:00