[Scummvm-cvs-logs] SF.net SVN: scummvm:[50275] scummvm/trunk/engines/sci/engine

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Jun 25 18:54:04 CEST 2010


Revision: 50275
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50275&view=rev
Author:   thebluegr
Date:     2010-06-25 16:54:03 +0000 (Fri, 25 Jun 2010)

Log Message:
-----------
Removed all of the non-validating code - there's no real point in removing script validations

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/vm.cpp

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2010-06-25 16:43:09 UTC (rev 50274)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2010-06-25 16:54:03 UTC (rev 50275)
@@ -94,7 +94,6 @@
 //@{
 
 //#define DEBUG_PARSER	// enable for parser debugging
-//#define DISABLE_VALIDATIONS	// enable to stop validation checks
 
 // ---- Kernel signatures -----------------------------------------------------
 

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2010-06-25 16:43:09 UTC (rev 50274)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2010-06-25 16:54:03 UTC (rev 50275)
@@ -95,8 +95,6 @@
 
 // validation functionality
 
-#ifndef DISABLE_VALIDATIONS
-
 static reg_t &validate_property(Object *obj, int index) {
 	// A static dummy reg_t, which we return if obj or index turn out to be
 	// invalid. Note that we cannot just return NULL_REG, because client code
@@ -286,19 +284,6 @@
 	}
 }
 
-#else
-// Non-validating alternatives
-
-#  define validate_stack_addr(s, sp) sp
-#  define validate_arithmetic(r) ((r).offset)
-#  define signed_validate_arithmetic(r) ((int16)(r).offset)
-#  define validate_variable(r, sb, t, m, i, l)
-#  define validate_read_var(r, sb, t, m, i, l, dv) ((r)[i])
-#  define validate_write_var(r, sb, t, m, i, l, v, sm, k) ((r)[i] = (v))
-#  define validate_property(o, p) ((o)->_variables[p])
-
-#endif
-
 #define READ_VAR(type, index, def) validate_read_var(s->variables[type], s->stack_base, type, s->variablesMax[type], index, __LINE__, def)
 #define WRITE_VAR(type, index, value) validate_write_var(s->variables[type], s->stack_base, type, s->variablesMax[type], index, __LINE__, value, s->_segMan, g_sci->getKernel())
 #define WRITE_VAR16(type, index, value) WRITE_VAR(type, index, make_reg(0, value));
@@ -607,10 +592,6 @@
 	return &(execStack.back());
 }
 
-#ifdef DISABLE_VALIDATIONS
-#  define kernel_matches_signature(a, b, c, d) 1
-#endif
-
 static reg_t pointer_add(EngineState *s, reg_t base, int offset) {
 	SegmentObj *mobj = s->_segMan->getSegmentObj(base.segment);
 
@@ -804,9 +785,7 @@
 void run_vm(EngineState *s, bool restoring) {
 	assert(s);
 
-#ifndef DISABLE_VALIDATIONS
 	unsigned int code_buf_size = 0 ; // (Avoid spurious warning)
-#endif
 	int temp;
 	int16 aux_acc; // Auxiliary 16 bit accumulator
 	reg_t r_temp; // Temporary register
@@ -857,9 +836,7 @@
 				// FIXME: Why does this happen? Are there leftover calls in the call stack?
 				warning("Running on non-existant script in segment %x", s->xs->addr.pc.segment);
 				code_buf = _fake_return_buffer;
-#ifndef DISABLE_VALIDATIONS
 				code_buf_size = 2;
-#endif
 				s->xs->addr.pc.offset = 1;
 
 				scr = NULL;
@@ -867,18 +844,14 @@
 			} else {
 				obj = s->_segMan->getObject(s->xs->objp);
 				code_buf = scr->_buf;
-#ifndef DISABLE_VALIDATIONS
 				code_buf_size = scr->getBufSize();
-#endif
 				local_script = s->_segMan->getScriptIfLoaded(s->xs->local_segment);
 				if (!local_script) {
 					// FIXME: Why does this happen? Is the script not loaded yet at this point?
 					warning("Could not find local script from segment %x", s->xs->local_segment);
 					local_script = NULL;
 					s->variablesBase[VAR_LOCAL] = s->variables[VAR_LOCAL] = NULL;
-#ifndef DISABLE_VALIDATIONS
 					s->variablesMax[VAR_LOCAL] = 0;
-#endif
 				} else {
 
 					s->variablesSegment[VAR_LOCAL] = local_script->_localsSegment;
@@ -886,14 +859,12 @@
 						s->variablesBase[VAR_LOCAL] = s->variables[VAR_LOCAL] = local_script->_localsBlock->_locals.begin();
 					else
 						s->variablesBase[VAR_LOCAL] = s->variables[VAR_LOCAL] = NULL;
-#ifndef DISABLE_VALIDATIONS
 					if (local_script->_localsBlock)
 						s->variablesMax[VAR_LOCAL] = local_script->_localsBlock->_locals.size();
 					else
 						s->variablesMax[VAR_LOCAL] = 0;
 					s->variablesMax[VAR_TEMP] = s->xs->sp - s->xs->fp;
 					s->variablesMax[VAR_PARAM] = s->xs->argc + 1;
-#endif
 				}
 				s->variables[VAR_TEMP] = s->xs->fp;
 				s->variables[VAR_PARAM] = s->xs->variables_argp;
@@ -915,7 +886,6 @@
 			con->onFrame();
 		}
 
-#ifndef DISABLE_VALIDATIONS
 		if (s->xs->sp < s->xs->fp)
 			error("run_vm(): stack underflow, sp: %04x:%04x, fp: %04x:%04x", 
 			PRINT_REG(*s->xs->sp), PRINT_REG(*s->xs->fp));
@@ -925,7 +895,6 @@
 		if (s->xs->addr.pc.offset >= code_buf_size)
 			error("run_vm(): program counter gone astray, addr: %d, code buffer size: %d", 
 			s->xs->addr.pc.offset, code_buf_size);
-#endif
 
 		// Get opcode
 		byte extOpcode;
@@ -1517,12 +1486,10 @@
 				s->r_acc.offset = s->xs->addr.pc.offset + opparams[0];
 			}
 
-#ifndef DISABLE_VALIDATIONS
 			if (s->r_acc.offset >= code_buf_size) {
 				error("VM: lofsa operation overflowed: %04x:%04x beyond end"
 				          " of script (at %04x)\n", PRINT_REG(s->r_acc), code_buf_size);
 			}
-#endif
 			break;
 
 		case op_lofss: // 0x3a (58)
@@ -1539,12 +1506,10 @@
 				r_temp.offset = s->xs->addr.pc.offset + opparams[0];
 			}
 
-#ifndef DISABLE_VALIDATIONS
 			if (r_temp.offset >= code_buf_size) {
 				error("VM: lofss operation overflowed: %04x:%04x beyond end"
 				          " of script (at %04x)", PRINT_REG(r_temp), code_buf_size);
 			}
-#endif
 			PUSH32(r_temp);
 			break;
 
@@ -1781,13 +1746,11 @@
 		if (s->_executionStackPosChanged) // Force initialization
 			s->xs = xs_new;
 
-//#ifndef DISABLE_VALIDATIONS
 		if (s->xs != &(s->_executionStack.back())) {
 			error("xs is stale (%p vs %p); last command was %02x",
 					(void *)s->xs, (void *)&(s->_executionStack.back()),
 					opcode);
 		}
-//#endif
 		++s->scriptStepCounter;
 	}
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list