r1274 - trunk/code/qcommon
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Mar 24 17:20:55 EDT 2008
Author: ludwig
Date: 2008-03-24 17:20:55 -0400 (Mon, 24 Mar 2008)
New Revision: 1274
Modified:
trunk/code/qcommon/vm.c
trunk/code/qcommon/vm_interpreted.c
trunk/code/qcommon/vm_local.h
trunk/code/qcommon/vm_x86_64.c
Log:
use vm->callLevel to count recursive calls to VM_Call
Throw an error if vm->callLevel is set and VM_Free is called.
Modified: trunk/code/qcommon/vm.c
===================================================================
--- trunk/code/qcommon/vm.c 2008-03-24 21:20:49 UTC (rev 1273)
+++ trunk/code/qcommon/vm.c 2008-03-24 21:20:55 UTC (rev 1274)
@@ -608,6 +608,15 @@
*/
void VM_Free( vm_t *vm ) {
+ if(!vm) {
+ return;
+ }
+
+ if(vm->callLevel) {
+ Com_Error( ERR_FATAL, "VM_Free(%s) on running vm", vm->name );
+ return;
+ }
+
if(vm->destroy)
vm->destroy(vm);
@@ -635,13 +644,8 @@
void VM_Clear(void) {
int i;
for (i=0;i<MAX_VM; i++) {
- if ( vmTable[i].dllHandle ) {
- Sys_UnloadDll( vmTable[i].dllHandle );
- }
- Com_Memset( &vmTable[i], 0, sizeof( vm_t ) );
+ VM_Free(&vmTable[i]);
}
- currentVM = NULL;
- lastVM = NULL;
}
void *VM_ArgPtr( intptr_t intValue ) {
@@ -722,6 +726,7 @@
Com_Printf( "VM_Call( %d )\n", callnum );
}
+ ++vm->callLevel;
// if we have a dll loaded, call it directly
if ( vm->entryPoint ) {
//rcg010207 - see dissertation at top of VM_DllSyscall() in this file.
@@ -765,6 +770,7 @@
r = VM_CallInterpreted( vm, &a.callnum );
#endif
}
+ --vm->callLevel;
if ( oldVM != NULL )
currentVM = oldVM;
Modified: trunk/code/qcommon/vm_interpreted.c
===================================================================
--- trunk/code/qcommon/vm_interpreted.c 2008-03-24 21:20:49 UTC (rev 1273)
+++ trunk/code/qcommon/vm_interpreted.c 2008-03-24 21:20:55 UTC (rev 1274)
@@ -376,8 +376,6 @@
*(int *)&image[ programStack + 4 ] = 0; // return stack
*(int *)&image[ programStack ] = -1; // will terminate the loop on return
- vm->callLevel = 0;
-
VM_Debug(0);
// vm_debugLevel=2;
@@ -516,7 +514,7 @@
if ( programCounter < 0 ) {
// system call
int r;
- int temp;
+// int temp;
#ifdef DEBUG_VM
int stomped;
@@ -525,7 +523,7 @@
}
#endif
// save the stack to allow recursive VM entry
- temp = vm->callLevel;
+// temp = vm->callLevel;
vm->programStack = programStack - 4;
#ifdef DEBUG_VM
stomped = *(int *)&image[ programStack + 4 ];
@@ -558,7 +556,7 @@
opStack++;
*opStack = r;
programCounter = *(int *)&image[ programStack ];
- vm->callLevel = temp;
+// vm->callLevel = temp;
#ifdef DEBUG_VM
if ( vm_debugLevel ) {
Com_Printf( "%s<--- %s\n", DEBUGSTR, VM_ValueToSymbol( vm, programCounter ) );
@@ -599,7 +597,7 @@
// vm_debugLevel = 2;
// VM_StackTrace( vm, programCounter, programStack );
}
- vm->callLevel++;
+// vm->callLevel++;
}
#endif
goto nextInstruction;
@@ -614,7 +612,7 @@
#ifdef DEBUG_VM
profileSymbol = VM_ValueToFunctionSymbol( vm, programCounter );
if ( vm_debugLevel ) {
- vm->callLevel--;
+// vm->callLevel--;
Com_Printf( "%s<--- %s\n", DEBUGSTR, VM_ValueToSymbol( vm, programCounter ) );
}
#endif
Modified: trunk/code/qcommon/vm_local.h
===================================================================
--- trunk/code/qcommon/vm_local.h 2008-03-24 21:20:49 UTC (rev 1273)
+++ trunk/code/qcommon/vm_local.h 2008-03-24 21:20:55 UTC (rev 1274)
@@ -156,7 +156,7 @@
int numSymbols;
struct vmSymbol_s *symbols;
- int callLevel; // for debug indenting
+ int callLevel; // counts recursive VM_Call
int breakFunction; // increment breakCount on function entry to this
int breakCount;
Modified: trunk/code/qcommon/vm_x86_64.c
===================================================================
--- trunk/code/qcommon/vm_x86_64.c 2008-03-24 21:20:49 UTC (rev 1273)
+++ trunk/code/qcommon/vm_x86_64.c 2008-03-24 21:20:55 UTC (rev 1274)
@@ -1069,7 +1069,6 @@
currentVM = vm;
- ++vm->callLevel;
// Com_Printf("entering %s level %d, call %d, arg1 = 0x%x\n", vm->name, vm->callLevel, args[0], args[1]);
// interpret the code
@@ -1131,7 +1130,6 @@
}
// Com_Printf("exiting %s level %d\n", vm->name, vm->callLevel);
- --vm->callLevel;
vm->programStack = stackOnEntry;
return *(int *)opStack;
More information about the quake3-commits
mailing list