[pypy-commit] pypy vmprof: Implement the correct handling of get_virtual_ip in the presence of
fijal
noreply at buildbot.pypy.org
Sun Dec 14 18:05:11 CET 2014
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: vmprof
Changeset: r74914:3c0a8b430ed5
Date: 2014-12-14 19:04 +0200
http://bitbucket.org/pypy/pypy/changeset/3c0a8b430ed5/
Log: Implement the correct handling of get_virtual_ip in the presence of
virtualizables. Added a hack that will give you the vable_token with
a very minimal test
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
@@ -104,6 +104,8 @@
def get_virtual_ip(gc_frame):
frame = cast_base_ptr_to_instance(PyFrame, gc_frame)
+ if jit._is_virtualizable_token_set(frame):
+ return rffi.cast(rffi.VOIDP, 0)
virtual_ip = do_get_virtual_ip(frame)
return rffi.cast(rffi.VOIDP, virtual_ip)
get_virtual_ip.c_name = 'pypy_vmprof_get_virtual_ip'
diff --git a/rpython/jit/backend/llsupport/test/ztranslation_test.py b/rpython/jit/backend/llsupport/test/ztranslation_test.py
--- a/rpython/jit/backend/llsupport/test/ztranslation_test.py
+++ b/rpython/jit/backend/llsupport/test/ztranslation_test.py
@@ -2,7 +2,7 @@
from rpython.tool.udir import udir
from rpython.rlib.jit import JitDriver, unroll_parameters, set_param
from rpython.rlib.jit import PARAMETERS, dont_look_inside
-from rpython.rlib.jit import promote
+from rpython.rlib.jit import promote, _get_virtualizable_token
from rpython.rlib import jit_hooks, rposix
from rpython.rlib.objectmodel import keepalive_until_here
from rpython.rlib.rthread import ThreadLocalReference
@@ -28,12 +28,15 @@
# - floats neg and abs
# - llexternal with macro=True
- class Frame(object):
+ class BasicFrame(object):
_virtualizable_ = ['i']
def __init__(self, i):
self.i = i
+ class Frame(BasicFrame):
+ pass
+
eci = ExternalCompilationInfo(post_include_bits=['''
#define pypy_my_fabs(x) fabs(x)
'''])
@@ -59,6 +62,7 @@
while frame.i > 3:
jitdriver.can_enter_jit(frame=frame, total=total, j=j)
jitdriver.jit_merge_point(frame=frame, total=total, j=j)
+ _get_virtualizable_token(frame)
total += frame.i
if frame.i >= 20:
frame.i -= 2
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -280,6 +280,36 @@
_we_are_jitted = CDefinedIntSymbolic('0 /* we are not jitted here */',
default=0)
+def _get_virtualizable_token(frame):
+ """ An obscure API to get vable token.
+ Used by _vmprof
+ """
+ from rpython.rtyper.lltypesystem import lltype, llmemory
+
+ return lltype.nullptr(llmemory.GCREF.TO)
+
+class GetVirtualizableTokenEntry(ExtRegistryEntry):
+ _about_ = _get_virtualizable_token
+
+ def compute_result_annotation(self, s_arg):
+ from rpython.rtyper.llannotation import SomePtr
+ from rpython.rtyper.lltypesystem import llmemory
+ return SomePtr(llmemory.GCREF)
+
+ def specialize_call(self, hop):
+ from rpython.rtyper.lltypesystem import lltype, llmemory
+
+ hop.exception_cannot_occur()
+ T = hop.args_r[0].lowleveltype.TO
+ v = hop.inputarg(hop.args_r[0], arg=0)
+ c_super = hop.inputconst(lltype.Void, 'super')
+ while not hasattr(T, 'vable_token'):
+ v = hop.genop('getfield', [v, c_super], resulttype=T.super)
+ T = T.super
+ c_vable_token = hop.inputconst(lltype.Void, 'vable_token')
+ return hop.genop('getfield', [v, c_vable_token],
+ resulttype=llmemory.GCREF)
+
class Entry(ExtRegistryEntry):
_about_ = we_are_jitted
More information about the pypy-commit
mailing list