[pypy-svn] r24473 - in pypy/dist/pypy: interpreter module/stackless
ac at codespeak.net
ac at codespeak.net
Thu Mar 16 16:04:12 CET 2006
Author: ac
Date: Thu Mar 16 16:04:11 2006
New Revision: 24473
Modified:
pypy/dist/pypy/interpreter/executioncontext.py
pypy/dist/pypy/module/stackless/coroutine.py
Log:
(pedronis, arre) Make a single point of creation for framestacks.
Fixed subcontext_switch.
Don't store initially a framestack in AppCoroutine for the main coroutine.
Modified: pypy/dist/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/dist/pypy/interpreter/executioncontext.py (original)
+++ pypy/dist/pypy/interpreter/executioncontext.py Thu Mar 16 16:04:11 2006
@@ -2,13 +2,16 @@
from pypy.interpreter.miscutils import Stack
from pypy.interpreter.error import OperationError
+def new_framestack():
+ return Stack()
+
class ExecutionContext:
"""An ExecutionContext holds the state of an execution thread
in the Python interpreter."""
def __init__(self, space):
self.space = space
- self.framestack = Stack()
+ self.framestack = new_framestack()
self.w_tracefunc = None
self.w_profilefunc = None
self.is_tracing = 0
@@ -36,17 +39,23 @@
# coroutine: subcontext support
def subcontext_new(coobj):
- coobj.framestack = Stack()
+ coobj.framestack = new_framestack()
coobj.w_tracefunc = None
coobj.w_profilefunc = None
coobj.is_tracing = 0
subcontext_new = staticmethod(subcontext_new)
- def subcontext_swap(self, coobj):
- self.framestack, coobj.framestack = coobj.framestack, self.framestack
- self.w_tracefunc, coobj.w_tracefunc = coobj.w_tracefunc, self.w_tracefunc
- self.w_profilefunc, coobj.w_profilefunc = coobj.w_profilefunc, self.w_profilefunc
- self.is_tracing, coobj.is_tracing = coobj.is_tracing, self.is_tracing
+ def subcontext_switch(self, current, next):
+ current.framestack = self.framestack
+ current.w_tracefunc = self.w_tracefunc
+ current.w_profilefunc = self.w_profilefunc
+ current.is_tracing = self.is_tracing
+
+ self.framestack = next.framestack
+ self.w_tracefunc = next.w_tracefunc
+ self.w_profilefunc = next.w_profilefunc
+ self.is_tracing = next.is_tracing
+
# coroutine: I think this is all, folks!
def get_builtin(self):
Modified: pypy/dist/pypy/module/stackless/coroutine.py
==============================================================================
--- pypy/dist/pypy/module/stackless/coroutine.py (original)
+++ pypy/dist/pypy/module/stackless/coroutine.py Thu Mar 16 16:04:11 2006
@@ -45,12 +45,13 @@
class AppCoroutine(Coroutine): # XXX, StacklessFlags):
- def __init__(self, space):
+ def __init__(self, space, is_main=False):
self.space = space
state = self._get_state(space)
Coroutine.__init__(self, state)
self.flags = 0
- space.getexecutioncontext().subcontext_new(self)
+ if not is_main:
+ space.getexecutioncontext().subcontext_new(self)
def descr_method__new__(space, w_subtype):
co = space.allocate_instance(AppCoroutine, w_subtype)
@@ -143,4 +144,4 @@
self.space = space
def post_install(self):
- self.current = self.main = self.last = AppCoroutine(self.space)
+ self.current = self.main = self.last = AppCoroutine(self.space, is_main=True)
More information about the Pypy-commit
mailing list