[pypy-commit] pypy vmprof2: Move _code_unique_id out of ExecutionContext into its own small
arigo
noreply at buildbot.pypy.org
Wed Apr 22 15:41:06 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: vmprof2
Changeset: r76888:cc4843b3d8b2
Date: 2015-04-22 15:41 +0200
http://bitbucket.org/pypy/pypy/changeset/cc4843b3d8b2/
Log: Move _code_unique_id out of ExecutionContext into its own small
singleton: it is a global counter, not a per-thread one.
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -11,7 +11,7 @@
INT_MIN, INT_MAX, UINT_MAX, USHRT_MAX
from pypy.interpreter.executioncontext import (ExecutionContext, ActionFlag,
- UserDelAction)
+ UserDelAction, CodeUniqueIds)
from pypy.interpreter.error import OperationError, new_exception_class, oefmt
from pypy.interpreter.argument import Arguments
from pypy.interpreter.miscutils import ThreadLocals, make_weak_value_dictionary
@@ -388,6 +388,7 @@
self.actionflag = ActionFlag() # changed by the signal module
self.check_signal_action = None # changed by the signal module
self.user_del_action = UserDelAction(self)
+ self.code_unique_ids = CodeUniqueIds()
self._code_of_sys_exc_info = None
# can be overridden to a subclass
@@ -667,15 +668,15 @@
return ec
def register_code_callback(self, callback):
- ec = self.getexecutioncontext()
- ec._code_callback = callback
+ cui = self.code_unique_ids
+ cui.code_callback = callback
def register_code_object(self, pycode):
- ec = self.getexecutioncontext()
- if ec._code_callback is None:
+ cui = self.code_unique_ids
+ if cui.code_callback is None:
return
- ec._code_callback(self, pycode)
-
+ cui.code_callback(self, pycode)
+
def _freeze_(self):
return True
diff --git a/pypy/interpreter/executioncontext.py b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -2,7 +2,6 @@
from pypy.interpreter.error import OperationError, get_cleared_operation_error
from rpython.rlib.unroll import unrolling_iterable
from rpython.rlib import jit
-from rpython.rlib.objectmodel import we_are_translated
TICK_COUNTER_STEP = 100
@@ -35,16 +34,6 @@
self.w_profilefuncarg = None
self.thread_disappeared = False # might be set to True after os.fork()
- if sys.maxint == 2147483647:
- self._code_unique_id = 0 # XXX this is wrong, it won't work on 32bit
- else:
- if we_are_translated():
- self._code_unique_id = 0x7000000000000000
- else:
- self._code_unique_id = 0x7700000000000000
- # should be enough code objects
- self._code_callback = None
-
@staticmethod
def _mark_thread_disappeared(space):
# Called in the child process after os.fork() by interp_posix.py.
@@ -590,3 +579,11 @@
# there is no list of length n: if n is large, then the GC
# will run several times while walking the list, but it will
# see lower and lower memory usage, with no lower bound of n.
+
+class CodeUniqueIds(object):
+ def __init__(self):
+ if sys.maxint == 2147483647:
+ self.code_unique_id = 0 # XXX this is wrong, it won't work on 32bit
+ else:
+ self.code_unique_id = 0x7000000000000000
+ self.code_callback = None
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -127,9 +127,9 @@
from pypy.objspace.std.mapdict import init_mapdict_cache
init_mapdict_cache(self)
- ec = self.space.getexecutioncontext()
- self._unique_id = ec._code_unique_id
- ec._code_unique_id += 4 # so we have two bits that we can mark stuff
+ cui = self.space.code_unique_ids
+ self._unique_id = cui.code_unique_id
+ cui.code_unique_id += 4 # so we have two bits that we can mark stuff
# with
def _get_full_name(self):
More information about the pypy-commit
mailing list