support coroutine

A few questions

- How about a variance of `emscripten_coroutine_create` that allows customized stack size?
- Do we need `emscriptens_coroutine_destroy`, for those coroutine we don't need anymore, but still running?
- Do we need to save and restore STACK_MAX?
- The code is not actually asm.js validated, not sure how to make _malloc and _free work.
Is `STACK_BASE` relevant?


On Thu, Aug 7, 2014 at 3:41 PM, Alon Zakai <notifications@github.com> wrote:

> In src/library_async.js:
>
> > + *  4 callee's STACKTOP
> > + *  8 my async ctx
> > + * 12 my STACKTOP
> > + * 16 coroutine function
> > + * 20 coroutine arg
> > + * 24 my stack:
> > + *    ...
> > + */
> > +  emscripten_coroutine_create__sig: 'iii',
> > +  emscripten_coroutine_create__asm: true,
> > +  emscripten_coroutine_create__deps: ['malloc'],
> > +  emscripten_coroutine_create: function(f, arg) {
> > +    f = f|0;
> > +    arg = arg|0;
> > +    var coroutine = 0;
> > +    coroutine = _malloc(4096);
>
> This is the effective stack size, correct? You should also adjust
> STACK_MAX so in ASSERTIONS builds we will check for stack overflows. I
> actually see the code currently ignores STACK_MAX, even though it is in
> the asm module, fixing that now.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/kripken/emscripten/pull/2612/files#r15969127>.
>