[Python-checkins] python/dist/src/Python ceval.c,2.342,2.343

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Thu, 09 Jan 2003 07:24:40 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv9854

Modified Files:
	ceval.c 
Log Message:
SF patch #664320: Replace push/pop clusters in ceval.c

Replaced groups of pushes and pops with indexed access to the stack and
a single adjustment (if needed) to the stacklevel.  

Avoids scores of unnecessary increments and decrements to the stackpointer.
Removes unnecessary sequential dependencies so that the compiler has more
freedom for optimizations.  Frees the processor for more parallel and
pipelined execution by using mostly read-only access and having few pointer
adjustments just prior to a read or write.



Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.342
retrieving revision 2.343
diff -C2 -d -r2.342 -r2.343
*** ceval.c	10 Nov 2002 14:33:26 -0000	2.342
--- ceval.c	9 Jan 2003 15:24:30 -0000	2.343
***************
*** 551,554 ****
--- 551,564 ----
  #define EMPTY()		(STACK_LEVEL() == 0)
  #define TOP()		(stack_pointer[-1])
+ #define SECOND()	(stack_pointer[-2])
+ #define THIRD() 	(stack_pointer[-3])
+ #define FOURTH()	(stack_pointer[-4])
+ #define FIFTH() 	(stack_pointer[-5])
+ #define SET_TOP(v)	(stack_pointer[-1] = (v))
+ #define SET_SECOND(v)	(stack_pointer[-2] = (v))
+ #define SET_THIRD(v)	(stack_pointer[-3] = (v))
[...1127 lines suppressed...]
  			v = POP();
! 			u = POP();
  			x = PySlice_New(u, v, w);
  			Py_DECREF(u);
  			Py_DECREF(v);
  			Py_XDECREF(w);
! 			PUSH(x);
  			if (x != NULL) continue;
  			break;
--- 2139,2148 ----
  				w = NULL;
  			v = POP();
! 			u = TOP();
  			x = PySlice_New(u, v, w);
  			Py_DECREF(u);
  			Py_DECREF(v);
  			Py_XDECREF(w);
! 			SET_TOP(x);
  			if (x != NULL) continue;
  			break;