[pypy-commit] pypy vmprof: shuffle stuff around to make it more RPython

fijal noreply at buildbot.pypy.org
Sat Jan 24 14:01:48 CET 2015


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: vmprof
Changeset: r75509:b57dabe367b1
Date: 2015-01-24 15:01 +0200
http://bitbucket.org/pypy/pypy/changeset/b57dabe367b1/

Log:	shuffle stuff around to make it more RPython

diff --git a/pypy/interpreter/executioncontext.py b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -34,6 +34,10 @@
         self.w_profilefuncarg = None
         self.thread_disappeared = False   # might be set to True after os.fork()
         self.register_code_callback = None
+        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
 
     @staticmethod
     def _mark_thread_disappeared(space):
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -55,13 +55,9 @@
     "CPython-style code objects."
     _immutable_ = True
     _immutable_fields_ = ["co_consts_w[*]", "co_names_w[*]", "co_varnames[*]",
-                          "co_freevars[*]", "co_cellvars[*]", "_args_as_cellvars[*]"]
-
-    if sys.maxint == 2147483647:
-        _unique_id = 0 # XXX this is wrong, it won't work on 32bit
-    else:
-        _unique_id = 0x7000000000000000
-
+                          "co_freevars[*]", "co_cellvars[*]",
+                          "_args_as_cellvars[*]"]
+    
     def __init__(self, space,  argcount, nlocals, stacksize, flags,
                      code, consts, names, varnames, filename,
                      name, firstlineno, lnotab, freevars, cellvars,
@@ -131,8 +127,10 @@
             from pypy.objspace.std.mapdict import init_mapdict_cache
             init_mapdict_cache(self)
 
-        self._unique_id = PyCode._unique_id
-        PyCode._unique_id += 1
+        ec = self.space.getexecutioncontext()
+        self._unique_id = ec._code_unique_id
+        ec._code_unique_id += 2 # so we have one bit that we can mark stuff
+        # with
 
     def _get_full_name(self):
         return "py:%s:%d:%s" % (self.co_name, self.co_firstlineno,
diff --git a/pypy/module/_vmprof/interp_vmprof.py b/pypy/module/_vmprof/interp_vmprof.py
--- a/pypy/module/_vmprof/interp_vmprof.py
+++ b/pypy/module/_vmprof/interp_vmprof.py
@@ -170,8 +170,14 @@
 
 @unwrap_spec(fileno=int, period=int)
 def enable(space, fileno, period=-1):
-    space.getbuiltinmodule('_vmprof').vmprof.enable(space, fileno, period)
+    from pypy.module._vmprof import Module
+    mod_vmprof = space.getbuiltinmodule('_vmprof')
+    assert isinstance(mod_vmprof, Module)
+    mod_vmprof.vmprof.enable(space, fileno, period)
 
 def disable(space):
-    space.getbuiltinmodule('_vmprof').vmprof.disable(space)
+    from pypy.module._vmprof import Module
+    mod_vmprof = space.getbuiltinmodule('_vmprof')
+    assert isinstance(mod_vmprof, Module)
+    mod_vmprof.vmprof.disable(space)
 


More information about the pypy-commit mailing list