jitcraft/BytecodeCompiler.cpp
changeset 72 40746ab0a30b
parent 70 1aec996cde2d
child 73 ef5492aa8d8b
     1.1 --- a/jitcraft/BytecodeCompiler.cpp	Sat Jul 14 18:43:34 2012 -0700
     1.2 +++ b/jitcraft/BytecodeCompiler.cpp	Sat Jul 14 21:01:52 2012 -0700
     1.3 @@ -164,7 +164,8 @@
     1.4      // Expressions leave their value on the top of the stack, so we make sure
     1.5      // to balance the stack if they're used as a statement.
     1.6      node->expression()->accept(this);
     1.7 -    __ pop();
     1.8 +    if (!node->expression()->type()->isVoid())
     1.9 +        __ pop();
    1.10  }
    1.11  
    1.12  void
    1.13 @@ -402,12 +403,12 @@
    1.14  void
    1.15  BytecodeCompiler::visit(ReturnStatement *node)
    1.16  {
    1.17 -    if (node->expression())
    1.18 +    if (node->expression()) {
    1.19          node->expression()->accept(this);
    1.20 -    else
    1.21 -        __ int_(0);
    1.22 -
    1.23 -    __ return_();
    1.24 +        __ return_();
    1.25 +    } else {
    1.26 +        __ returnvoid();
    1.27 +    }
    1.28  }
    1.29  
    1.30  void
    1.31 @@ -662,7 +663,7 @@
    1.32      if (fun->isNative())
    1.33          __ callnative(fun->slot(), node->arguments()->length());
    1.34      else
    1.35 -        __ callglobal(fun->slot());
    1.36 +        __ callglobal(funType, fun->slot());
    1.37      __ drop(node->arguments()->length());
    1.38  }
    1.39  
    1.40 @@ -734,6 +735,7 @@
    1.41  
    1.42      node->body()->accept(this);
    1.43  
    1.44 +    // STOP doubles as RETURNVOID.
    1.45      __ stop();
    1.46  
    1.47      if (__ oom() || zone_->hasPendingException())