[pypy-svn] r23078 - in pypy/dist/pypy: interpreter objspace
ac at codespeak.net
ac at codespeak.net
Mon Feb 6 19:12:08 CET 2006
Author: ac
Date: Mon Feb 6 19:12:06 2006
New Revision: 23078
Modified:
pypy/dist/pypy/interpreter/pyframe.py
pypy/dist/pypy/objspace/trace.py
Log:
(Samuele, Arre)
Make PyFrame.next_instr unsigned and make sure the unsignedness
doesn't escape.
Modified: pypy/dist/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyframe.py (original)
+++ pypy/dist/pypy/interpreter/pyframe.py Mon Feb 6 19:12:06 2006
@@ -5,6 +5,7 @@
from pypy.interpreter.miscutils import Stack, FixedStack
from pypy.interpreter.error import OperationError
from pypy.interpreter import pytraceback
+from pypy.rpython.rarithmetic import r_uint, intmask
import opcode
# Define some opcodes used
@@ -48,7 +49,7 @@
self.valuestack = Stack()
self.blockstack = Stack()
self.last_exception = None
- self.next_instr = 0
+ self.next_instr = r_uint(0) # Force it unsigned for performace reasons.
self.builtin = space.builtin.pick_builtin(w_globals)
# regular functions always have CO_OPTIMIZED and CO_NEWLOCALS.
# class bodies only have CO_NEWLOCALS.
@@ -95,7 +96,7 @@
"Interpreter main loop!"
try:
executioncontext.call_trace(self)
- self.last_instr = -1
+ self.last_instr = 0
while True:
try:
try:
@@ -103,7 +104,7 @@
while True:
# fetch and dispatch the next opcode
# dispatch() is abstract, see pyopcode.
- self.last_instr = self.next_instr
+ self.last_instr = intmask(self.next_instr)
executioncontext.bytecode_trace(self)
self.next_instr = self.last_instr
self.dispatch()
@@ -281,11 +282,11 @@
def get_last_lineno(self):
"Returns the line number of the instruction currently being executed."
- return pytraceback.offset2lineno(self.pycode, self.next_instr-1)
+ return pytraceback.offset2lineno(self.pycode, intmask(self.next_instr)-1)
def get_next_lineno(self):
"Returns the line number of the next instruction to execute."
- return pytraceback.offset2lineno(self.pycode, self.next_instr)
+ return pytraceback.offset2lineno(self.pycode, intmask(self.next_instr))
def fget_f_builtins(space, self):
return self.builtin.getdict()
@@ -524,7 +525,7 @@
def state_unpack_variables(self, space):
return [space.wrap(self.jump_to)]
def state_pack_variables(self, space, w_jump_to):
- self.jump_to = space.int_w(w_jump_to)
+ self.jump_to = space.uint_w(w_jump_to)
class SReturnValue(ControlFlowException):
"""Signals a 'return' statement.
Modified: pypy/dist/pypy/objspace/trace.py
==============================================================================
--- pypy/dist/pypy/objspace/trace.py (original)
+++ pypy/dist/pypy/objspace/trace.py Mon Feb 6 19:12:06 2006
@@ -4,7 +4,7 @@
"""
from pypy.tool import pydis
-
+from pypy.rpython.rarithmetic import intmask
# __________________________________________________________________________
#
# Tracing Events
@@ -16,7 +16,7 @@
def __init__(self, frame):
self.frame = frame
self.code = frame.pycode
- self.index = frame.next_instr
+ self.index = intmask(frame.next_instr)
class EnterFrame(object):
def __init__(self, frame):
More information about the Pypy-commit
mailing list