Thanks for clarifying this for me - can’t wait to try it out. That’s definitely 
one of the most exciting new features in Emscripten!

In terms of saving and restoring local variables quickly: to avoid iterating 
over all variables, can you make them properties of an object at compile time 
(instead of atomic variables in the function scope)?  I other words, make the 
function scope explicitly accessible as an object? For example, for two the 
functions below:

void foo(int a) {
        float b;
        char * c;
        …
        bar(b);
        ...
}

void bar(float c) {
        int d;
        …
        emscripten_sleep(1);
        …
}

You could generate two explicit scope objects:

fooScope = {
        parentScope: ...
        a: ...
        b: …
        c: …
}

and 

barScope = {
        parentScope: …
        c: …
        d: ...
}

When saving the local variables when calling emscripten_sleep, you merely had 
to store barScope. If bar was called from foo, its parentScope property was set 
to fooScope (this had to happen at runtime at a small cost). Restoring the 
scope is again, a single operation only. In return, the affected functions 
would need to access their variables as properties of the funcScope object. Not 
sure if asm.js allows for that. You would probably have to represent the scope 
structures on the heap and turn accesses to the local variables into heap 
accesses at some offset of the scope struct location. Also, the 
funcScope.parentScope property had to be populated when entering a function. So 
there was a trade-off, not sure how it would pan out. 

Soeren


On 27 Jul 2014, at 22:29, 王璐 <[email protected]> wrote:

> Hi,
> 
> There are definitely overhead for this transformation, mainly saving and 
> restoring local variables. Usually this kind of overhead is acceptable, as 
> async functions are usually supposed to be slow.
> 
> On the other hand, how would you define 'performance degration', as probably 
> we don't have other options. 
> 
> asm.js does support function pointers, although you need to know the 
> signature, and asyncify is asm.js compliant. In fact asm.js is required for 
> this feature.
> 
> 
> regards,
> - Lu
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "emscripten-discuss" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/emscripten-discuss/kSMH2N0CoLg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to