[Patches] [Patch #101022] Removal of SET_LINENO (experimental)

noreply@sourceforge.net noreply@sourceforge.net
Mon, 31 Jul 2000 07:57:38 -0700


Patch #101022 has been updated. 

Project: 
Category: core (C code)
Status: Postponed
Summary: Removal of SET_LINENO (experimental)

Follow-Ups:

Date: 2000-Jul-30 16:12
By: marangoz

Comment:
For testing, as discussed on python-dev. For a gentle summary, see:
http://www.python.org/pipermail/python-dev/2000-July/014364.html

-------------------------------------------------------

Date: 2000-Jul-30 18:16
By: marangoz

Comment:
A nit: inline the argfetch in CALL_TRACE and goto the switch,
instead of jumping to get_oparg which splits the sequence
[fetch opcode, fetch oparg] -- this can slow things down.

-------------------------------------------------------

Date: 2000-Jul-31 06:40
By: gvanrossum

Comment:
Status set to postponed to indicate that this is still experimental.
-------------------------------------------------------

Date: 2000-Jul-31 07:57
By: marangoz

Comment:
Another rewrite, making this whole strategy b/w compatible according to
the 1st incompatibility point a) described in: http://www.python.org/pipermail/python-dev/2000-July/014364.html

Changes:

1. f.f_lineno is computed and updated on f_lineno attribute requests for
   f, given f.f_lasti. Correctness is ensured because f.f_lasti is updated
   on *all* attribute accesses (in LOAD_ATTR in the main loop).

2. The standard setup does not generate SET_LINENO, but uses
   co_lnotab for computing the source line number (e.g. tracebacks)
   This is equivalent to the actual "python -O".

3. With "python -d", we fall back to the current version of the
   interpreter (with SET_LINENO) thus making it easy to test whether
   this patch fully replaces SET_LINENO's behavior.
   (modulo f->f_lineno accesses from legacy C code, but this is insane).

IMO, this version already worths the pain to be truly tested and improved.

One improvement is to define a nicer public C API for breakpoints:
 - PyCode_SetBreakPointAtLine(line)
 - PyCode_SetBreakPointAtAddr(addr)
or similar, which would install a CALL_TRACE opcode in the appropriate
location of the copy of co_code.

Another idea is to avoid duplicating the entire co_code just for storing
the CALL_TRACE opcodes. We can store them in the original and keep
a table of breakpoints. Setting the breakpoints would occur whenever
the sys.settrace hook is set.
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=101022&group_id=5470