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 9:36 AM Immanuel Haffner <haffner.imman...@gmail.com> wrote: > 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<T> object) { > * \example process.cc > */ > > +void SetWasmInstanceRawMemory(Local<Object> wasmInstance, uint8_t > *mem_start, size_t mem_size); > > } // namespace v8 > > diff --git a/src/api/api.cc b/src/api/api.cc > index ffc89d7dc8..795cc110b8 100644 > --- a/src/api/api.cc > +++ b/src/api/api.cc > @@ -340,6 +340,11 @@ class CallDepthScope { > > } // namespace > > +void SetWasmInstanceRawMemory(Local<Object> wasmInstance, uint8_t > *mem_start, size_t mem_size) { > + i::Handle<i::Object> obj = Utils::OpenHandle(*wasmInstance); > + i::WasmInstanceObject::cast(*obj).SetRawMemory(mem_start, mem_size); > +} > + > static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate, > i::Handle<i::Script> script) > { > i::Handle<i::Object> scriptName(script->GetNameOrSourceURL(), isolate); > diff --git a/src/flags/flag-definitions.h b/src/flags/flag-definitions.h > index 2b68204af5..e10a583f63 100644 > --- a/src/flags/flag-definitions.h > +++ b/src/flags/flag-definitions.h > @@ -746,7 +746,7 @@ DEFINE_BOOL(wasm_no_stack_checks, false, > DEFINE_BOOL(wasm_math_intrinsics, true, > "intrinsify some Math imports into wasm") > > -DEFINE_BOOL(wasm_trap_handler, true, > +DEFINE_BOOL(wasm_trap_handler, false, > "use signal handlers to catch out of bounds memory access in > wasm" > " (currently Linux x86_64 only)") > DEFINE_BOOL(wasm_fuzzer_gen_test, false, > > Now I can do the following in the host: > /* Create host memory. */ > auto host_memory = new int32_t[1024]; > for (int32_t i = 0; i != 1024; ++i) > host_memory[i] = i; > > v8::SetWasmInstanceRawMemory(instance, > reinterpret_cast<uint8_t*>(host_memory), 4096); > > And from within the module I can issue a load and retrieve a value from > the array. I yet have to experiment with overflows or grows... > > As I already said, I want to work with really large allocations, maybe > tens or hundreds of gigabytes. Because WebAssembly currently only has 2GiB > address space, I need some mechanism to feed the host allocations to the > WASM module in chunks. I think of installing a callback from the WASM > module to the host, via a WASM module import, that allows the WASM module > to signal to the host, that the current chunk was processed and the next > chunk is requested. So roughly every 2GiB of processed data, the WASM > module issues a callback to the host. When that callback returns, the > module can assume the next chunk is mapped into the linear memory and > proceed. > Does this sound like a good approach? Any concerns here (regarding > correctness or performance)? > > -- > -- > v8-dev mailing list > v8-dev@googlegroups.com > http://groups.google.com/group/v8-dev > --- > You received this message because you are subscribed to the Google Groups > "v8-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-dev+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-dev/edc41107-3a61-4e1d-99de-56b95084183c%40googlegroups.com > <https://groups.google.com/d/msgid/v8-dev/edc41107-3a61-4e1d-99de-56b95084183c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Clemens Backes Software Engineer cleme...@google.com Google Germany GmbH Erika-Mann-Straße 33 80636 München Geschäftsführer: Paul Manicle, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde. This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person. -- Clemens Backes Software Engineer cleme...@google.com Google Germany GmbH Erika-Mann-Straße 33 80636 München Geschäftsführer: Paul Manicle, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde. This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person. -- -- v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAGO%3DqhBGLC3-pzhFV5g2pdaKV64wBsdt_Tw66ZQRV7MyQWg1RA%40mail.gmail.com.