[Python-checkins] python/dist/src/Python ceval.c,2.392,2.393

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Wed Apr 7 09:17:39 EDT 2004


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25910

Modified Files:
	ceval.c 
Log Message:
* Improve readability and remove data dependencies by converting
pre-increment forms to post-increment forms.  Post-incrementing
also eliminates the need for negative array indices for oparg fetches.

* In exception handling code, check for class based exceptions before
  the older string based exceptions.



Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.392
retrieving revision 2.393
diff -C2 -d -r2.392 -r2.393
*** ceval.c	7 Apr 2004 11:39:21 -0000	2.392
--- ceval.c	7 Apr 2004 13:17:27 -0000	2.393
***************
*** 626,630 ****
  #define INSTR_OFFSET()	(next_instr - first_instr)
  #define NEXTOP()	(*next_instr++)
! #define NEXTARG()	(next_instr += 2, (next_instr[-1]<<8) + next_instr[-2])
  #define JUMPTO(x)	(next_instr = first_instr + (x))
  #define JUMPBY(x)	(next_instr += (x))
--- 626,631 ----
  #define INSTR_OFFSET()	(next_instr - first_instr)
  #define NEXTOP()	(*next_instr++)
! #define OPARG()		(next_instr[0] + (next_instr[1]<<8))
! #define SKIPARG()	(next_instr += 2)
  #define JUMPTO(x)	(next_instr = first_instr + (x))
  #define JUMPBY(x)	(next_instr += (x))
***************
*** 862,867 ****
  
  		opcode = NEXTOP();
! 		if (HAS_ARG(opcode))
! 			oparg = NEXTARG();
  	  dispatch_opcode:
  #ifdef DYNAMIC_EXECUTION_PROFILE
--- 863,870 ----
  
  		opcode = NEXTOP();
! 		if (HAS_ARG(opcode)) {
! 			oparg = OPARG();
! 			SKIPARG();
! 		}
  	  dispatch_opcode:
  #ifdef DYNAMIC_EXECUTION_PROFILE
***************
*** 1654,1658 ****
  					retval = POP();
  			}
! 			else if (PyString_Check(v) || PyClass_Check(v)) {
  				w = POP();
  				u = POP();
--- 1657,1661 ----
  					retval = POP();
  			}
! 			else if (PyClass_Check(v) || PyString_Check(v)) {
  				w = POP();
  				u = POP();
***************
*** 1893,1897 ****
  			x = PyTuple_New(oparg);
  			if (x != NULL) {
! 				for (; --oparg >= 0;) {
  					w = POP();
  					PyTuple_SET_ITEM(x, oparg, w);
--- 1896,1900 ----
  			x = PyTuple_New(oparg);
  			if (x != NULL) {
! 				while (oparg--) {
  					w = POP();
  					PyTuple_SET_ITEM(x, oparg, w);
***************
*** 1905,1909 ****
  			x =  PyList_New(oparg);
  			if (x != NULL) {
! 				for (; --oparg >= 0;) {
  					w = POP();
  					PyList_SET_ITEM(x, oparg, w);
--- 1908,1912 ----
  			x =  PyList_New(oparg);
  			if (x != NULL) {
! 				while (oparg--) {
  					w = POP();
  					PyList_SET_ITEM(x, oparg, w);
***************
*** 2177,2181 ****
  					break;
  				}
! 				while (--oparg >= 0) {
  					w = POP();
  					PyTuple_SET_ITEM(v, oparg, w);
--- 2180,2184 ----
  					break;
  				}
! 				while (oparg--) {
  					w = POP();
  					PyTuple_SET_ITEM(v, oparg, w);
***************
*** 2202,2206 ****
  					break;
  				}
! 				while (--nfree >= 0) {
  					w = POP();
  					PyTuple_SET_ITEM(v, nfree, w);
--- 2205,2209 ----
  					break;
  				}
! 				while (nfree--) {
  					w = POP();
  					PyTuple_SET_ITEM(v, nfree, w);
***************
*** 2216,2220 ****
  					break;
  				}
! 				while (--oparg >= 0) {
  					w = POP();
  					PyTuple_SET_ITEM(v, oparg, w);
--- 2219,2223 ----
  					break;
  				}
! 				while (oparg--) {
  					w = POP();
  					PyTuple_SET_ITEM(v, oparg, w);
***************
*** 2244,2248 ****
  		case EXTENDED_ARG:
  			opcode = NEXTOP();
! 			oparg = oparg<<16 | NEXTARG();
  			goto dispatch_opcode;
  
--- 2247,2252 ----
  		case EXTENDED_ARG:
  			opcode = NEXTOP();
! 			oparg = oparg<<16 | OPARG();
! 			SKIPARG();
  			goto dispatch_opcode;
  
***************
*** 3193,3197 ****
  
  		if (size > 0) {
! 			while (--size >= 0) {
  				addr += *p++;
  				if (*p++)
--- 3197,3201 ----
  
  		if (size > 0) {
! 			while (size--) {
  				addr += *p++;
  				if (*p++)
***************
*** 3608,3612 ****
  	if (kwdict == NULL)
  		return NULL;
! 	while (--nk >= 0) {
  		int err;
  		PyObject *value = EXT_POP(*pp_stack);
--- 3612,3616 ----
  	if (kwdict == NULL)
  		return NULL;
! 	while (nk--) {
  		int err;
  		PyObject *value = EXT_POP(*pp_stack);
***************
*** 3653,3657 ****
  		}
  	}
! 	while (--nstack >= 0) {
  		w = EXT_POP(*pp_stack);
  		PyTuple_SET_ITEM(callargs, nstack, w);
--- 3657,3661 ----
  		}
  	}
! 	while (nstack--) {
  		w = EXT_POP(*pp_stack);
  		PyTuple_SET_ITEM(callargs, nstack, w);
***************
*** 3668,3672 ****
  	if (args == NULL)
  		return NULL;
! 	while (--na >= 0) {
  		w = EXT_POP(*pp_stack);
  		PyTuple_SET_ITEM(args, na, w);
--- 3672,3676 ----
  	if (args == NULL)
  		return NULL;
! 	while (na--) {
  		w = EXT_POP(*pp_stack);
  		PyTuple_SET_ITEM(args, na, w);




More information about the Python-checkins mailing list