Supporting async functions

This is only an early version. 
My hand-written tests as well as some PDCurses demos are working, but there are still some not working.

This PR is mainly for code review, because I think that the approach has been determined.

A library is necessary to support manipulating async stack frames. asm.js is not supported yet, but it won't be difficult, as there are only number operations (no references to functions)

kripken/emscripten#2482

Function pointers are not supported yet.


OK. Fixed.


On Tue, Jul 8, 2014 at 4:36 PM, Dan Gohman <notifications@github.com> wrote:

> In lib/Transforms/NaCl/LowerEmAsyncFunctions.cpp:
>
> > +  BasicBlock *EntryBlock = BasicBlock::Create(TheModule->getContext(), "", &F, &F.getEntryBlock());
> > +  BranchInst::Create(AfterCallBlock, EntryBlock);
> > +
> > +  DominatorTree DT;
> > +  DT.runOnFunction(F);
> > +
> > +  // These blocks may be using some values defined at or before AsyncCallBlock
> > +  BasicBlockSet Ramifications = FindReachableBlocksFrom(AfterCallBlock);
> > +
> > +  SmallPtrSet<Value*, 256> ContextVariables;
> > +  Values Pending;
> > +
> > +  // Examine the instructions, find all variables that we need to store in the context
> > +  for(BasicBlockSet::iterator RI = Ramifications.begin(), RE = Ramifications.end(); RI != RE; ++RI) {
> > +    for(BasicBlock::iterator I = (*RI)->begin(), E = (*RI)->end(); I != E; ++I) {
> > +      for(unsigned i = 0, NumOperands = I->getNumOperands(); i < NumOperands; ++i) {
>
> Functions don't have a space there. if/for/while/etc. do.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/kripken/emscripten-fastcomp/pull/39/files#r14686788>.
>