[Stackless-checkins] CVS: slpdev/src/2.3/dev/Python ceval.c, 1.90, 1.91
Christian Tismer
tismer at centera.de
Mon Jul 12 20:56:58 CEST 2004
Update of /home/cvs/slpdev/src/2.3/dev/Python
In directory centera.de:/tmp/cvs-serv18053/Python
Modified Files:
ceval.c
Log Message:
A tiny optimization of oparg fetching for X86.
Mainly I started optimizing by keeping interpreters on the stack.
This is just a cache-like optimization and gives a few percent.
But I think it will really count for generator/iterator situations.
Index: ceval.c
===================================================================
RCS file: /home/cvs/slpdev/src/2.3/dev/Python/ceval.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -C2 -d -r1.90 -r1.91
*** ceval.c 10 Jul 2004 01:07:10 -0000 1.90
--- ceval.c 12 Jul 2004 18:56:52 -0000 1.91
***************
*** 667,670 ****
--- 667,681 ----
next_instr[1]; next_instr += 3
+ #ifdef STACKLESS
+ #ifdef STACKLESS_USE_ENDIAN
+
+ #undef NEXTARG
+ #define NEXTARG() (next_instr += 2, ((short *)next_instr)[-1])
+ #undef PREDICTED_WITH_ARG
+ #define PREDICTED_WITH_ARG(op) PRED_##op: next_instr += 3; \
+ oparg = ((short *)next_instr)[-1]
+ #endif
+ #endif
+
/* Stack manipulation macros */
***************
*** 848,853 ****
#endif
- fast_reentry:
-
#endif /* STACKLESS */
--- 859,862 ----
***************
*** 898,901 ****
--- 907,911 ----
}
assert(opcode == FOR_ITER);
+
if (retval != NULL) {
PUSH(retval);
***************
*** 909,918 ****
}
else if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
! /* this can happen from external re-entry */
PyErr_Clear();
- /* iterator ended normally */
retval = POP();
Py_DECREF(retval);
- /* perform the delayed block jump */
JUMPBY(oparg);
}
--- 919,929 ----
}
else if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
! /* we need to check for stopiteration because
! * somebody might inject this as a real
! * exception.
! */
PyErr_Clear();
retval = POP();
Py_DECREF(retval);
JUMPBY(oparg);
}
***************
*** 2290,2293 ****
--- 2301,2305 ----
if (STACKLESS_UNWINDING(x))
goto stackless_iter;
+ stackless_iter_return:
#else
x = PyIter_Next(v);
***************
*** 2322,2325 ****
--- 2334,2338 ----
goto stackless_call;
}
+ stackless_call_return:
#endif
PUSH(x);
***************
*** 2667,2689 ****
(look for the word 'Promise' above) */
f->f_lasti = INSTR_OFFSET() - 1;
! f = tstate->frame;
! /*
! * make a fast jump, if the new frame's f_execute is
! * eval_frame, the recursion limit does not impose a problem,
! * and if we don't have to cope with a trace function.
! * Otherwise, it is better to go through the full sequence
! * instead of repeating code, here.
! */
! if (f && f->f_execute == PyEval_EvalFrame &&
! tstate->recursion_depth < recursion_limit &&
! ! tstate->use_tracing) {
! ++tstate->recursion_depth;
! f->f_execute = PyEval_EvalFrame_noval;
! STACKLESS_UNPACK(retval);
! goto fast_reentry;
}
! return retval;
stackless_interrupt_call:
--- 2680,2701 ----
(look for the word 'Promise' above) */
f->f_lasti = INSTR_OFFSET() - 1;
! if (tstate->frame->f_back != f)
! return retval;
! STACKLESS_UNPACK(retval);
! retval = tstate->frame->f_execute(tstate->frame, retval);
! if (tstate->frame != f)
! return retval;
! if (STACKLESS_UNWINDING(retval))
! STACKLESS_UNPACK(retval);
! x = retval;
! f->f_stacktop = NULL;
! if (f->f_execute == PyEval_EvalFrame_iter) {
! next_instr += (oparg >> 16) ? 6 : 3;
! f->f_execute = PyEval_EvalFrame_value;
! goto stackless_iter_return;
}
! goto stackless_call_return;
stackless_interrupt_call:
_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins
More information about the Stackless-checkins
mailing list