diff options
author | Adrian Thurston <thurston@complang.org> | 2015-03-28 17:33:05 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2015-03-28 17:33:05 -0400 |
commit | 49b347705e29596edb6e091b855e021601e854c5 (patch) | |
tree | d26e1c6338068505089dbda462227cf967165d03 | |
parent | 9be83dad1c830dc96801a672281578ffe5838668 (diff) | |
download | colm-49b347705e29596edb6e091b855e021601e854c5.tar.gz |
allocate space for args on the caller's stack
-rw-r--r-- | src/bytecode.c | 22 | ||||
-rw-r--r-- | src/synthesis.cc | 11 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index c2b0cb6c..9c2dc42f 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -3157,13 +3157,25 @@ again: } case IN_PREP_ARGS: { - debug( prg, REALM_BYTECODE, "IN_PREP_ARGS\n" ); + Half size; + read_half( size ); + + debug( prg, REALM_BYTECODE, "IN_PREP_ARGS %hd\n", size ); + vm_push_type( Tree**, exec->callArgs ); + exec->callArgs = vm_ptop(); + vm_pushn( size ); + memset( vm_ptop(), 0, sizeof(Word) * size ); break; } case IN_CLEAR_ARGS: { - debug( prg, REALM_BYTECODE, "IN_CLEAR_ARGS\n" ); + Half size; + read_half( size ); + + debug( prg, REALM_BYTECODE, "IN_CLEAR_ARGS %hd\n", size ); + + vm_popn( size ); exec->callArgs = vm_pop_type( Tree** ); break; } @@ -3993,6 +4005,9 @@ again: downrefLocals( prg, &sp, exec->framePtr, fi->locals, fi->localsLen ); + debug( prg, REALM_BYTECODE, " exit popping %s argSize %d\n", + ( fi->name != 0 ? fi->name : "<no-name>" ), fi->argSize ); + vm_popn( fi->frameSize ); /* This can help solve some crashes, but really need to move to @@ -4017,7 +4032,8 @@ again: /* The CONTIGUOS PUSH. */ vm_pop_tree(); - /* The callArgs push. */ + /* The IN_PREP_ARGS stack data. */ + vm_popn( fi->argSize ); vm_pop_value(); if ( fi->retTree ) { diff --git a/src/synthesis.cc b/src/synthesis.cc index 442ac8c0..d6337310 100644 --- a/src/synthesis.cc +++ b/src/synthesis.cc @@ -1097,8 +1097,12 @@ UniqueType *LangVarRef::evaluateCall( Compiler *pd, CodeVect &code, CallArgVect Function *func = lookup.objMethod->func; /* Prepare the contiguous call args space. */ - if ( func != 0 ) + int asLoc; + if ( func != 0 ) { code.append( IN_PREP_ARGS ); + asLoc = code.length(); + code.appendHalf( 0 ); + } bool resetContiguous = false; if ( func != 0 ) { @@ -1121,8 +1125,11 @@ UniqueType *LangVarRef::evaluateCall( Compiler *pd, CodeVect &code, CallArgVect pd->endContiguous( code, resetContiguous ); pd->clearContiguous( code, resetContiguous ); - if ( func != 0 ) + if ( func != 0 ) { code.append( IN_CLEAR_ARGS ); + code.appendHalf( func->paramListSize ); + code.setHalf( asLoc, func->paramListSize ); + } if ( func != 0 ) code.append( IN_LOAD_RETVAL ); |