Define stack sizes at central place

also reverts bug 4282 as stack is included in bss already so nothing that needs fixing
This commit is contained in:
Ludwig Nussel 2009-11-01 19:58:03 +00:00
parent 698127ad32
commit cc9a74a218
3 changed files with 12 additions and 11 deletions

View File

@ -357,8 +357,6 @@ intptr_t QDECL VM_DllSyscall( intptr_t arg, ... ) {
}
#define STACK_SIZE 0x20000
/*
=================
VM_LoadQVM
@ -427,7 +425,7 @@ vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc ) {
// round up to next power of 2 so all data operations can
// be mask protected
dataLength = header.h->dataLength + header.h->litLength +
header.h->bssLength + STACK_SIZE;
header.h->bssLength;
for ( i = 0 ; dataLength > ( 1 << i ) ; i++ ) {
}
dataLength = 1 << i;
@ -606,7 +604,7 @@ vm_t *VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *),
// the stack is implicitly at the end of the image
vm->programStack = vm->dataMask + 1;
vm->stackBottom = vm->programStack - STACK_SIZE;
vm->stackBottom = vm->programStack - PROGRAM_STACK_SIZE;
Com_Printf("%s loaded in %d bytes on the hunk\n", module, remaining - Hunk_MemoryRemaining());
@ -730,8 +728,6 @@ an OP_ENTER instruction, which will subtract space for
locals from sp
==============
*/
#define MAX_STACK 256
#define STACK_MASK (MAX_STACK-1)
intptr_t QDECL VM_Call( vm_t *vm, int callnum, ... ) {
vm_t *oldVM;

View File

@ -311,13 +311,11 @@ an OP_ENTER instruction, which will subtract space for
locals from sp
==============
*/
#define MAX_STACK 256
#define STACK_MASK (MAX_STACK-1)
#define DEBUGSTR va("%s%i", VM_Indent(vm), opStack-stack )
int VM_CallInterpreted( vm_t *vm, int *args ) {
int stack[MAX_STACK];
int stack[OPSTACK_SIZE];
int *opStack;
int programCounter;
int programStack;
@ -392,7 +390,7 @@ nextInstruction2:
if ( opStack < stack ) {
Com_Error( ERR_DROP, "VM opStack underflow" );
}
if ( opStack >= stack+MAX_STACK ) {
if ( opStack >= stack+OPSTACK_SIZE ) {
Com_Error( ERR_DROP, "VM opStack overflow" );
}

View File

@ -22,6 +22,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "q_shared.h"
#include "qcommon.h"
#define OPSTACK_SIZE 256
#define OPSTACK_MASK (OPSTACK_SIZE-1)
// don't change
// Hardcoded in q3asm an reserved at end of bss
#define PROGRAM_STACK_SIZE 0x10000
#define PROGRAM_STACK_MASK (PROGRAM_STACK_SIZE-1)
typedef enum {
OP_UNDEF,
@ -180,4 +188,3 @@ vmSymbol_t *VM_ValueToFunctionSymbol( vm_t *vm, int value );
int VM_SymbolToValue( vm_t *vm, const char *symbol );
const char *VM_ValueToSymbol( vm_t *vm, int value );
void VM_LogSyscalls( int *args );