Regarding the specific questions:

 * Memory initialization: we actually just moved to doing this a few days
ago :) On emscripten incoming and binaryen master, asm2wasm will import the
memory initialization into the wasm module.

 * establishStackSpace() receives parameters, while start() does not, so we
can't use start().

Overall I think having an option for more standalone wasm output could be
useful. But some things currently need JS support:

 * Our libc does syscalls out into JS, so without the JS side you'd need to
implement those yourself.

 * The libc also reuses web platform things like data/time support, by
calling out (in a non-syscall manner) to JS.

 * If you want integration support for input/output, WebGL, Web Audio, etc.
then you definitely need JS.

However, for code that just does pure computation, with little or no
libc/OS support, it should be possible to emit a standalone wasm module.
But we'd need to figure out things like establishStackSpace, and I suspect
there is more I can't think of now, experimenting in this direction is
probably the best way to find out.


On Sat, Sep 10, 2016 at 12:29 PM, Joshua Warner <allpowerfu...@gmail.com>
wrote:

> Hi,
>
> I've been experimenting with implementing my own WebAssembly interpreter (
> https://github.com/joshuawarner32/rust-wasm), and I'm starting to throw
> some more complicated examples at it.  An emscripten/binaryen-compiled `int
> main() { return 42; }` works just fine, but once I graduate to `int main()
> { printf("Hello"); }`, I start running into some problems with
> initial-conditions that the WebAssembly module expects.
>
> Taking a step back, it looks like emscripten is generating a large
> javascript wrapper around the wasm module, and the wasm module is highly
> dependent on this external helper.  I'd like to avoid shipping a javascript
> engine next to my wasm interpreter, which means I'm left translating that
> wrapper code by hand.
>
> Some of the relevant things that the wrapper seems to contain:
> * Memory initialization - why can't this be done with standard `(memory
> ... (segment ...))` stuff, directly in the wasm module?
> * Calling some initialization routines - possibly including
> `establishStackSpace` - again, why can't this be done in the `start`
> function of the wasm module?
> * (Some other things that I'm clearly missing, since I have yet to get
> HelloWorld working on _any_ wasm interpreter (including v8), without the
> wrapping javascript)
>
> In short, I'd like to get emscripten to generate a wasm module that, to
> the extent possible, doesn't depend on any javascript wrapper.
>
> How small can I get the logic in that wrapper?
>
> Any pointers on places in the emscripten code that I can poke at to push
> things in this direction?  I'd love to upstream some improvements if
> possible.
>
> Thanks,
> Joshua
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to