Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-19 Thread Immanuel Haffner
So far, programs consist only of one function, no recursion. I think local variables suffice to represent the state - together with the mmap'd memory. I don't think I need an explicit stack frame. I will perform more experiments and progress in small steps. I will let you know of progress and

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-17 Thread Clemens Backes
Great to hear that it works! The approach with a re-mapping callback sounds very reasonable. You would still have to be careful about memory requirements by the compiled programs. Would they not need any memory for modeling their own stack, or putting any other state? On Fri, Jan 17, 2020 at

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-17 Thread Immanuel Haffner
It worked! Thanks a million :) Here is the patch: diff --git a/include/v8.h b/include/v8.h index 199fc6ae09..01bc30b031 100644 --- a/include/v8.h +++ b/include/v8.h @@ -11776,6 +11776,7 @@ size_t SnapshotCreator::AddData(Local object) { * \example process.cc */ +void

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-16 Thread Clemens Backes
Ack, SetRawMemory does exactly the right thing. If you add an API method that takes a Local (holding the wasm instance), you can implement that in api.cc via something like: i::Handle obj = Utils::OpenHandle(this); i::WasmInstanceObject::cast(*obj)->SetRawMemory(...); On Thu, Jan 16, 2020

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-16 Thread Immanuel Haffner
@Clements Regarding point 2, WasmInstanceObject::SetRawMemory() seems to to exactly what I want, right? How can I access this, given a v8::Object of a WebAssembly.Instance ? -- -- v8-dev mailing

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-16 Thread Immanuel Haffner
@Clemens That sounds doable. I will try this! @Ben Thanks, I thought about that already but I don't know whether that would work so easily. If i remap the memory, would a WASM load at address 0 really load from the remapped memory at offset 0? I will keep this in mind as a last resort :D --

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-16 Thread Ben Noordhuis
On Wed, Jan 15, 2020 at 5:05 PM Immanuel Haffner wrote: > To make my scenario more concrete: > I habe data in main memory, easily tens or hundreds of gigabytes. Programs > fly in requiring to access the data. Some programs are short-lived, some will > take a long time to compute. Some programs

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-16 Thread Clemens Backes
One quick and dirty way to do this would be: 1. If you need to catch memory out-of-bounds errors, disable the --wasm-trap-handler flag (in flag-definitions.h ), because there will

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-16 Thread Immanuel Haffner
What I am working on is (a) a research project and (b) the programs are all trust-worthy and harmless. Patching V8 sounds like an option. I would highly appreciate some guidance where to start. I am only superficially familiar with the public API yet. -- -- v8-dev mailing list

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-15 Thread Clemens Backes
On Wed, Jan 15, 2020 at 5:05 PM Immanuel Haffner wrote: > Hi Clemens, > > Thanks for your answer. I already had that thought. But copying data is > just not an option. > > To make my scenario more concrete: > I habe data in main memory, easily tens or hundreds of gigabytes. Programs > fly in

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-15 Thread Immanuel Haffner
Hi Clemens, Thanks for your answer. I already had that thought. But copying data is just not an option. To make my scenario more concrete: I habe data in main memory, easily tens or hundreds of gigabytes. Programs fly in requiring to access the data. Some programs are short-lived, some will

Re: [v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-15 Thread Clemens Backes
Hi Immanuel, you cannot create WebAssembly.Memory from any ArrayBuffer, or replace the underlying ArrayBuffer later, since the allocation that is backing the wasm memory has special requirements (guard regions around it to catch out of bounds accesses from wasm). What you can do instead is

[v8-dev] Sharing Memory between Host and WebAssembly Module

2020-01-09 Thread Immanuel Haffner
Hi everyone, I am JIT compiling programs in a high level language to a WebAssembly module. I want to run them in embedded V8. I succeeded in embedding V8, creating an isolate, and with some JS glue code instantiate the WebAssembly module and invoke an exported function. Now I am facing the