Author: Richard Plangger <[email protected]>
Branch: jitlog-exact-source-lines
Changeset: r85956:7467ad8d230f
Date: 2016-08-01 16:41 +0200
http://bitbucket.org/pypy/pypy/changeset/7467ad8d230f/
Log: use offset2lineno as proposed by cfbolz
diff --git a/pypy/module/pypyjit/interp_jit.py
b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -42,6 +42,22 @@
from rpython.rlib import rvmprof
return rvmprof.get_unique_id(bytecode)
[email protected]
+def offset2lineno(bytecode, stopat):
+ # see dis.findlinestarts for an explanation. This function is copied from
+ # rpython/tool/error.py
+ # lnotab is a list of [byte inc, line inc, ...]
+ # even position denote byte increments, odd line increments...
+ tab = bytecode.co_lnotab
+ line = bytecode.co_firstlineno
+ addr = 0
+ for i in range(0, len(tab), 2):
+ addr = addr + ord(tab[i])
+ if addr > stopat:
+ break
+ line = line + ord(tab[i+1])
+ return line
+
@jl.returns(jl.MP_FILENAME, jl.MP_LINENO,
jl.MP_SCOPE, jl.MP_INDEX, jl.MP_OPCODE)
def get_location(next_instr, is_being_profiled, bytecode):
@@ -53,7 +69,8 @@
name = bytecode.co_name
if not name:
name = ""
- return (bytecode.co_filename, bytecode.co_firstlineno,
+ line = offset2lineno(bytecode, next_instr)
+ return (bytecode.co_filename, line,
name, intmask(next_instr), opname)
def should_unroll_one_iteration(next_instr, is_being_profiled, bytecode):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit