Author: Armin Rigo <[email protected]>
Branch: improve-vmprof-testing
Changeset: r86030:5af59f30c570
Date: 2016-08-05 16:06 +0200
http://bitbucket.org/pypy/pypy/changeset/5af59f30c570/

Log:    We need the vmprof stack updates to occur all untranslated, because
        the test is going to be checking that the metainterp/* updates it
        correctly, and metainterp/* is not translated here

diff --git a/rpython/jit/backend/test/test_rvmprof.py 
b/rpython/jit/backend/test/test_rvmprof.py
--- a/rpython/jit/backend/test/test_rvmprof.py
+++ b/rpython/jit/backend/test/test_rvmprof.py
@@ -37,7 +37,8 @@
 
         register_code_object_class(CodeObj, get_name)
 
-        @vmprof_execute_code("main", get_code_fn)
+        @vmprof_execute_code("main", get_code_fn,
+                             _hack_update_stack_untranslated=True)
         def f(code, n):
             i = 0
             while i < n:
@@ -46,7 +47,6 @@
                 llfn()
 
         def main(n):
-            cintf.vmprof_tl_stack.setraw(null)   # make it empty
             vmprof = _get_vmprof()
             code = CodeObj()
             register_code(code, get_name)
@@ -59,6 +59,7 @@
         hooks = Hooks()
 
         null = lltype.nullptr(cintf.VMPROFSTACK)
+        cintf.vmprof_tl_stack.setraw(null)
         self.meta_interp(main, [10], policy=JitPolicy(hooks))
         print visited
         #v = set(visited)
diff --git a/rpython/rlib/rvmprof/rvmprof.py b/rpython/rlib/rvmprof/rvmprof.py
--- a/rpython/rlib/rvmprof/rvmprof.py
+++ b/rpython/rlib/rvmprof/rvmprof.py
@@ -4,7 +4,7 @@
 from rpython.rlib.rvmprof import cintf
 from rpython.rtyper.annlowlevel import cast_instance_to_gcref
 from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance
-from rpython.rtyper.lltypesystem import rffi, llmemory
+from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.rlib.rweaklist import RWeakListMixin
 
@@ -140,7 +140,8 @@
         if self.cintf.vmprof_register_virtual_function(name, uid, 500000) < 0:
             raise VMProfError("vmprof buffers full!  disk full or too slow")
 
-def vmprof_execute_code(name, get_code_fn, result_class=None):
+def vmprof_execute_code(name, get_code_fn, result_class=None,
+                        _hack_update_stack_untranslated=False):
     """Decorator to be used on the function that interprets a code object.
 
     'name' must be a unique name.
@@ -150,6 +151,18 @@
 
     'result_class' is ignored (backward compatibility).
     """
+    if _hack_update_stack_untranslated:
+        from rpython.rtyper.annlowlevel import llhelper
+        enter_code = llhelper(lltype.Ptr(
+            lltype.FuncType([lltype.Signed], cintf.PVMPROFSTACK)),
+            cintf.enter_code)
+        leave_code = llhelper(lltype.Ptr(
+            lltype.FuncType([cintf.PVMPROFSTACK], lltype.Void)),
+            cintf.leave_code)
+    else:
+        enter_code = cintf.enter_code
+        leave_code = cintf.leave_code
+
     def decorate(func):
         try:
             _get_vmprof()
@@ -161,11 +174,11 @@
             # JIT cannot see through it.
             if not jit.we_are_jitted():
                 unique_id = get_code_fn(*args)._vmprof_unique_id
-                x = cintf.enter_code(unique_id)
+                x = enter_code(unique_id)
                 try:
                     return func(*args)
                 finally:
-                    cintf.leave_code(x)
+                    leave_code(x)
             else:
                 return func(*args)
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to