summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
Commit message (Collapse)AuthorAgeFilesLines
* SF patch #864059: optimize eval_frameRaymond Hettinger2004-02-061-5/+6
| | | | | | Simplified version of Neal Norwitz's patch which adds gotos for opcodes that set "why". This skips a number of tests where the outcome of the tests are known in advance.
* Getting rid of all the code inside #ifdef macintosh too.Jack Jansen2003-11-201-5/+1
|
* Make undetected error on stack unwind a fatal error.Jeremy Hylton2003-11-051-4/+4
|
* Deleting cyclic object comparison.Armin Rigo2003-10-281-20/+36
| | | | | SF patch 825639 http://mail.python.org/pipermail/python-dev/2003-October/039445.html
* oh dear. Wrong manipulation. Committed a version of ceval.c from myArmin Rigo2003-10-251-28/+20
| | | | | | no-cyclic-comparison patch at the same time as errors.c. Reverting ceval.c to the previous revision.
* Made function declaration a proper C prototypeArmin Rigo2003-10-251-20/+28
|
* Simplify and speedup uses of Py_BuildValue():Raymond Hettinger2003-10-121-3/+3
| | | | | | * Py_BuildValue("(OOO)",a,b,c) --> PyTuple_Pack(3,a,b,c) * Py_BuildValue("()",a) --> PyTuple_New(0) * Py_BuildValue("O", a) --> Py_INCREF(a)
* Fix SF #762455, segfault when sys.stdout is changed in getattrNeal Norwitz2003-06-291-0/+6
| | | | Will backport.
* Add PyThreadState_SetAsyncExc(long, PyObject *).Guido van Rossum2003-06-281-1/+17
| | | | | | | | | A new API (only accessible from C) to interrupt a thread by sending it an exception. This is not always effective, but might help some people. Requested by Just van Rossum and Alex Martelli. It is intentional that you have to write your own C extension to call it from Python. Docs will have to wait.
* Use fast_next_opcode shortcut for forward jump opcodes (it's safe andNeil Schemenauer2003-06-011-5/+5
| | | | gives a small speedup).
* SF bug #733667: kwargs handled incorrectlyRaymond Hettinger2003-05-311-1/+1
| | | | | The fast_function() inlining optimization only applies when there are zero keyword arguments.
* Don't use fast_next_opcode for JUMP_* opcodes. This fixes the problemNeil Schemenauer2003-05-301-6/+6
| | | | reported by Kurt B. Kaiser.
* Armin Rigo's fix & test forMichael W. Hudson2003-04-291-9/+10
| | | | | | [ 729622 ] line tracing hook errors with massaging from me to integrate test into test suite.
* Revert the previous enhancement to the bytecode optimizer.Raymond Hettinger2003-04-241-3/+0
| | | | The additional code complexity and new NOP opcode were not worth it.
* Improved the bytecode optimizer.Raymond Hettinger2003-04-221-0/+3
| | | | | | | | | | | | | | * Can now test for basic blocks. * Optimize inverted comparisions. * Optimize unary_not followed by a conditional jump. * Added a new opcode, NOP, to keep code size constant. * Applied NOP to previous transformations where appropriate. Note, the NOP would not be necessary if other functions were added to re-target jump addresses and update the co_lnotab mapping. That would yield slightly faster and cleaner bytecode at the expense of optimizer simplicity and of keeping it decoupled from the line-numbering structure.
* New PyGILState_ API - implements pep 311, from patch 684256.Mark Hammond2003-04-191-0/+2
|
* - New function sys.call_tracing() allows pdb to debug codeGuido van Rossum2003-04-091-0/+18
| | | | | | recursively. - pdb has a new command, "debug", which lets you step through arbitrary code from the debugger's (pdb) prompt.
* Eliminate data dependency in predict macro.Raymond Hettinger2003-03-161-2/+8
| | | | | | | | Added two predictions: GET_ITER --> FOR_ITER FOR_ITER --> STORE_FAST or UNPACK_SEQUENCE Improves timings on pybench and timeit.py. Pystone results are neutral.
* Fix comment and whitespace.Raymond Hettinger2003-03-161-3/+4
|
* Introduced macros for a simple opcode prediction protocol.Raymond Hettinger2003-03-161-6/+35
| | | | | | | | | | | | | | | | | | | Applied to common cases: COMPARE_OP is often followed by a JUMP_IF. JUMP_IF is usually followed by POP_TOP. Shows improved timings on PyStone, PyBench, and specific tests using timeit.py: python timeit.py -s "x=1" "if x==1: pass" python timeit.py -s "x=1" "if x==2: pass" python timeit.py -s "x=1" "if x: pass" python timeit.py -s "x=100" "while x!=1: x-=1" Potential future candidates: GET_ITER predicts FOR_ITER FOR_ITER predicts STORE_FAST or UNPACK_SEQUENCE Also, applied missing goto fast_next_opcode to DUP_TOPX.
* SF patch #701907: More use of fast_next_opcodeRaymond Hettinger2003-03-141-11/+11
| | | | | | | | My previous patches should have used fast_next_opcode in a few places instead of continue. Also, applied one PyInt_AS_LONG macro in a place where the type had already been checked.
* Added implementation notes for [re]set_exc_info().Guido van Rossum2003-03-011-0/+61
|
* In the process of adding all the extended slice support I attempted toMichael W. Hudson2003-02-271-4/+4
| | | | | | | change _PyEval_SliceIndex to round massively negative longs up to -INT_MAX, instead of 0 but botched it. Get it right. Thx to Armin for the report.
* Micro-optimizations.Raymond Hettinger2003-02-261-4/+18
| | | | | * List/Tuple checkexact is faster for the common case. * Testing for Py_True and Py_False can be inlined for faster looping.
* - PyEval_GetFrame() is now declared to return a PyFrameObject *Guido van Rossum2003-02-191-7/+7
| | | | instead of a plain PyObject *. (SF patch #686601 by Ben Laurie.)
* patch #683515: "Add unicode support to compile(), eval() and exec"Just van Rossum2003-02-101-2/+13
| | | | Incorporated nnorwitz's comment re. Py__USING_UNICODE.
* Small function call optimization and special build option for call stats.Jeremy Hylton2003-02-051-12/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | -DCALL_PROFILE: Count the number of function calls executed. When this symbol is defined, the ceval mainloop and helper functions count the number of function calls made. It keeps detailed statistics about what kind of object was called and whether the call hit any of the special fast paths in the code. Optimization: When we take the fast_function() path, which seems to be taken for most function calls, and there is minimal frame setup to do, avoid call PyEval_EvalCodeEx(). The eval code ex function does a lot of work to handle keywords args and star args, free variables, generators, etc. The inlined version simply allocates the frame and copies the arguments values into the frame. The optimization gets a little help from compile.c which adds a CO_NOFREE flag to code objects that don't have free variables or cell variables. This change allows fast_function() to get into the fast path with fewer tests. I measure a couple of percent speedup in pystone with this change, but there's surely more that can be done.
* SF patch #670367: Micro-optimizations for ceval.cRaymond Hettinger2003-01-191-18/+13
| | | | | | | | | | | | | | | | | | | | Make the code slightly shorter, faster, and easier to read. * Eliminate unused DUP_TOPX code for x==1. compile.c always generates DUP_TOP instead. * Since only two cases remain for DUP_TOPX, replace the switch-case with if-elseif. * The in-lined integer compare does a CheckExact on both arguments. Since the second is a little more likely to fail, test it first. * The switch-case for IS/IS_NOT and IN/NOT_IN can separate the regular and inverted cases with no additional work. For all four paths, saves a test and jump.
* Replaced POP() with STACKADJ(-1) on lines where the result wasn't used.Raymond Hettinger2003-01-141-2/+2
| | | | | | The two are semantically equivalent, but the first triggered a compiler warning about an unused variable. Note, the preceding steps had already accessed and decreffed the variable so the reference counts were fine.
* As discussed on python-dev, removed from DUP_TOPX support for theRaymond Hettinger2003-01-101-35/+0
| | | | | | | | parameter being either four or five. Currently, compile.c does not generate calls with a parameter higher than three. May have to be reverted if the second alpha or beta shakes out some other tool generating this op code with a parameter of four or five.
* As discussed briefly on python-dev, add Pending Deprecation WarningNeal Norwitz2003-01-101-3/+5
| | | | | when a string exception is raised. Note that raising string exceptions is deprecated in an exception message.
* SF patch #664320: Replace push/pop clusters in ceval.cRaymond Hettinger2003-01-091-150/+167
| | | | | | | | | | | 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.
* Make private functions static so we don't pollute the namespaceNeal Norwitz2002-11-101-1/+1
|
* This is Richie Hindle's patch:Michael W. Hudson2002-11-081-7/+16
| | | | | | | [ 631276 ] Exceptions raised by line trace function It conflicted with the patches from Armin I just checked it, so I had to so some bits by hand.
* Assorted patches from Armin Rigo:Michael W. Hudson2002-11-081-42/+48
| | | | | | | | [ 617309 ] getframe hook (Psyco #1) [ 617311 ] Tiny profiling info (Psyco #2) [ 617312 ] debugger-controlled jumps (Psyco #3) These are forward ports from 2.2.2.
* Handle really big steps in extended slices.Michael W. Hudson2002-11-061-1/+1
| | | | Fixes a test failure on 64 bit platforms (I hope).
* One last tweak to the tracing machinery: this actually computes what I intendedMichael W. Hudson2002-10-031-1/+3
| | | | | | | all along. Before instr_lb tended to be too high. I don't think this actually makes any difference, given what the compiler produces, but it makes me a bit happier.
* Fix for the recursion_level bug Armin Rigo reported in sfMichael W. Hudson2002-10-021-0/+4
| | | | | | | patch #617312, both on the trunk and the 22-maint branch. Also added a test case, and ported the test_trace I wrote for HEAD to 2.2.2 (with all those horrible extra 'line' events ;-).
* A slight change to SET_LINENO-less tracing.Michael W. Hudson2002-09-111-5/+18
| | | | | This makes things a touch more like 2.2. Read the comments in Python/ceval.c for more details.
* Bump default check interval to 100 instructions. Computers are much fasterSkip Montanaro2002-09-031-2/+2
| | | | | | than when this interval was first established. Checking too frequently just adds needless overhead because most of the time there is nothing to do and no other threads ready to run.
* replace thread state objects' ticker and checkinterval fields with twoSkip Montanaro2002-09-031-2/+8
| | | | | | | | | | globals, _Py_Ticker and _Py_CheckInterval. This also implements Jeremy's shortcut in Py_AddPendingCall that zeroes out _Py_Ticker. This allows the test in the main loop to only test a single value. The gory details are at http://python.org/sf/602191
* Further SET_LINENO reomval fixes. See comments in patch #587933.Michael W. Hudson2002-08-301-34/+20
| | | | | | | | | | Use a slightly different strategy to determine when not to call the line trace function. This removes the need for the RETURN_NONE opcode, so that's gone again. Update docs and comments to match. Thanks to Neal and Armin! Also add a test suite. This should have come with the original patch...
* The error messages in err_args() -- which is only called when theGuido van Rossum2002-08-231-2/+2
| | | | | | required number of args is 0 or 1 -- were reversed. Also change "1" into "exactly one", the same words as used elsewhere for this condition.
* Comment typo repair.Michael W. Hudson2002-08-201-1/+1
|
* My patch #597221. Use f_lasti more consistently.Michael W. Hudson2002-08-201-9/+9
|
* Add a warning comment to the LOAD_GLOBAL inline code.Guido van Rossum2002-08-191-1/+3
|
* Another ugly inlining hack, expanding the two PyDict_GetItem() callsGuido van Rossum2002-08-191-1/+25
| | | | | | | | | | | | | | | in LOAD_GLOBAL. Besides saving a C function call, it saves checks whether f_globals and f_builtins are dicts, and extracting and testing the string object's hash code is done only once. We bail out of the inlining if the name is not exactly a string, or when its hash is -1; because of interning, neither should ever happen. I believe interning guarantees that the hash code is set, and I believe that the 'names' tuple of a code object always contains interned strings, but I'm not assuming that -- I'm simply testing hash != -1. On my home machine, this makes a pystone variant with new-style classes and slots run at the same speed as classic pystone! (With new-style classes but without slots, it is still a lot slower.)
* Inline fast_cfunction() in new call_function().Jeremy Hylton2002-08-161-55/+33
| | | | | | | | | Also, don't handle METH_OLDARGS on the fast path. All the interesting builtins have been converted to use METH_NOARGS, METH_O, or METH_VARARGS. Result is another 1-2% speedup. If I can cobble together 10 of these, it might make a difference.
* Move body of CALL_FUNCTION opcode into helper function.Jeremy Hylton2002-08-161-54/+56
| | | | | | | This makes the code much easier to ready, because it is at a sane indentation level. On my box this shows a 1-2% speedup, which means nothing, except that I'm not going to worry about the performance effects of the change.
* Streamline the fast track for CFunction calls a bit more: there wasGuido van Rossum2002-08-161-5/+2
| | | | | | | nothing special done if keyword arguments were present, so test for that earlier and fall through to the normal case if there are any. This ought to slow down CFunction calls with keyword args, but I don't care; it's a tiny (1%) improvement for pystone.