[pypy-svn] r66039 - in pypy/branch/pyjitpl5/pypy: interpreter objspace/std

arigo at codespeak.net arigo at codespeak.net
Tue Jun 30 15:58:33 CEST 2009


Author: arigo
Date: Tue Jun 30 15:58:32 2009
New Revision: 66039

Modified:
   pypy/branch/pyjitpl5/pypy/interpreter/executioncontext.py
   pypy/branch/pyjitpl5/pypy/interpreter/miscutils.py
   pypy/branch/pyjitpl5/pypy/objspace/std/typeobject.py
Log:
Revert r66021.  Fijal, I *told* you on irc to run the test
in pypy/interpreter/test and you pretended that you did.
This makes me a little bit angry.


Modified: pypy/branch/pyjitpl5/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/interpreter/executioncontext.py	(original)
+++ pypy/branch/pyjitpl5/pypy/interpreter/executioncontext.py	Tue Jun 30 15:58:32 2009
@@ -1,11 +1,11 @@
 import sys
-from pypy.interpreter.miscutils import PseudoFrameStack
+from pypy.interpreter.miscutils import Stack
 from pypy.interpreter.error import OperationError
 from pypy.rlib.rarithmetic import LONG_BIT
 from pypy.rlib.unroll import unrolling_iterable
 
 def new_framestack():
-    return PseudoFrameStack()
+    return Stack()
 
 def app_profile_call(space, w_callable, frame, event, w_arg):
     space.call_function(w_callable,
@@ -32,7 +32,10 @@
         if self.framestack.depth() > self.space.sys.recursionlimit:
             raise OperationError(self.space.w_RuntimeError,
                                  self.space.wrap("maximum recursion depth exceeded"))
-        frame.f_back = self.framestack.top()
+        try:
+            frame.f_back = self.framestack.top()
+        except IndexError:
+            frame.f_back = None
 
         if not frame.hide():
             self.framestack.push(frame)
@@ -75,14 +78,14 @@
         # the following interface is for pickling and unpickling
         def getstate(self, space):
             # we just save the framestack
-            items = [space.wrap(item) for item in self.framestack.getitems()]
+            items = [space.wrap(item) for item in self.framestack.items]
             return space.newtuple(items)
 
         def setstate(self, space, w_state):
             from pypy.interpreter.pyframe import PyFrame
-            topitem = space.getitem(w_state, space.wrap(-1))
-            self.framestack._top = topitem
-            self.framestack._depth = space.int_w(space.len(w_state))
+            items = [space.interp_w(PyFrame, w_item)
+                     for w_item in space.unpackiterable(w_state)]
+            self.framestack.items = items
         # coroutine: I think this is all, folks!
 
 
@@ -123,12 +126,13 @@
             self._trace(frame, 'c_exception', w_exc)
 
     def _llprofile(self, event, w_arg):
+        fr = self.framestack.items
         space = self.space
         w_callback = self.profilefunc
         if w_callback is not None:
             frame = None
-            if fr.bottom():
-                frame = fr.bottom()
+            if fr:
+                frame = fr[0]
             self.profilefunc(space, self.w_profilefuncarg, frame, event, w_arg)
 
     def call_trace(self, frame):
@@ -193,7 +197,7 @@
         if func is not None:
             if w_arg is None:
                 raise ValueError("Cannot call setllprofile with real None")
-            for frame in self.framestack.getitems():
+            for frame in self.framestack.items:
                 frame.is_being_profiled = True
         self.w_profilefuncarg = w_arg
 

Modified: pypy/branch/pyjitpl5/pypy/interpreter/miscutils.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/interpreter/miscutils.py	(original)
+++ pypy/branch/pyjitpl5/pypy/interpreter/miscutils.py	Tue Jun 30 15:58:32 2009
@@ -9,41 +9,6 @@
 class RootStack:
     pass
 
-class PseudoFrameStack(RootStack):
-
-    def __init__(self):
-        self._top = None
-        self._depth = 0
-
-    def top(self, position=0):
-        next = self._top
-        while position > 0:
-            next = next.f_back
-            position -= 1
-        return next
-
-    def push(self, next):
-        assert next.f_back is self._top
-        self._top = next
-        self._depth += 1
-
-    def pop(self):
-        next = self._top
-        self._top = next.f_back
-        self._depth -= 1
-        return next
-
-    def depth(self):
-        return self._depth
-
-    def getitems(self):
-        items = []
-        next = self._top
-        while next is not None:
-            items.append(next)
-            next = next.f_back
-        return items
-
 class Stack(RootStack):
     """Utility class implementing a stack."""
 

Modified: pypy/branch/pyjitpl5/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/objspace/std/typeobject.py	(original)
+++ pypy/branch/pyjitpl5/pypy/objspace/std/typeobject.py	Tue Jun 30 15:58:32 2009
@@ -534,13 +534,15 @@
     # initialize __module__ in the dict (user-defined types only)
     if '__module__' not in w_self.dict_w:
         space = w_self.space
-        caller = space.getexecutioncontext().framestack.top()
-        if caller is None:
-            return
-        w_globals = caller.w_globals
-        w_name = space.finditem(w_globals, space.wrap('__name__'))
-        if w_name is not None:
-            w_self.dict_w['__module__'] = w_name
+        try:
+            caller = space.getexecutioncontext().framestack.top()
+        except IndexError:
+            pass
+        else:
+            w_globals = caller.w_globals
+            w_name = space.finditem(w_globals, space.wrap('__name__'))
+            if w_name is not None:
+                w_self.dict_w['__module__'] = w_name
 
 def compute_mro(w_self):
     if w_self.is_heaptype():



More information about the Pypy-commit mailing list