jitcraft/BytecodeCompiler.cpp
changeset 69 dfce0539a77d
parent 68 b40b0e18a918
child 70 1aec996cde2d
     1.1 --- a/jitcraft/BytecodeCompiler.cpp	Tue Jul 10 02:11:13 2012 -0700
     1.2 +++ b/jitcraft/BytecodeCompiler.cpp	Wed Jul 11 01:12:54 2012 -0700
     1.3 @@ -606,16 +606,17 @@
     1.4          // arguments, but arrays and references are already in the
     1.5          // appropriate form.
     1.6          Local<Type> given(zone_, arg->type());
     1.7 -        if (i >= funType->parameters()->length())
     1.8 +        bool mustPushReference = false;
     1.9 +        if (i >= funType->parameters()->length()) {
    1.10              assert(funType->isNative() && funType->isNativeVariadic());
    1.11 -        else
    1.12 -            assert(!given->isReference() || !funType->parameterAt(i)->isArray());
    1.13 +            mustPushReference = !given->isArray() && !given->isReference();
    1.14 +        } else if (funType->parameterAt(i)->isReference()) {
    1.15 +            mustPushReference = !given->isReference();
    1.16 +        }
    1.17  
    1.18          // If a native is passed to a native, it must only be one level deep.
    1.19          assert(!funType->isNative() || !given->isArray() || given->levels() == 1);
    1.20  
    1.21 -        bool mustPushReference = !given->isArray() && !given->isReference();
    1.22 -
    1.23          if (mustPushReference) {
    1.24              if (arg->isNameProxy()) {
    1.25                  // :TODO: test with functions and globals
    1.26 @@ -717,7 +718,7 @@
    1.27  
    1.28      __ stop();
    1.29  
    1.30 -    if (__ oom())
    1.31 +    if (__ oom() || zone_->hasPendingException())
    1.32          return NULL;
    1.33  
    1.34      Local<ByteArray> bytes(zone_, ByteArray::New(zone_, __ length() * sizeof(bytecode), Heap::Tenure_Old));
    1.35 @@ -819,6 +820,9 @@
    1.36          statement->accept(this);
    1.37      }
    1.38  
    1.39 +    if (zone_->hasPendingException())
    1.40 +        return NULL;
    1.41 +
    1.42  #ifndef NDEBUG
    1.43      for (size_t i = 0; i < tree_->scope()->numFunctions(); i++)
    1.44          assert(moduleData_->module->getFunction(i));