[pypy-commit] pypy ffistruct: delay the lookup of to_free until it's needed. This should save a getfield_gc in the trace in the common case
antocuni
noreply at buildbot.pypy.org
Thu May 17 11:45:41 CEST 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: ffistruct
Changeset: r55123:b7e461c340c7
Date: 2012-05-17 11:45 +0200
http://bitbucket.org/pypy/pypy/changeset/b7e461c340c7/
Log: delay the lookup of to_free until it's needed. This should save a
getfield_gc in the trace in the common case
diff --git a/pypy/module/_ffi/interp_funcptr.py b/pypy/module/_ffi/interp_funcptr.py
--- a/pypy/module/_ffi/interp_funcptr.py
+++ b/pypy/module/_ffi/interp_funcptr.py
@@ -48,7 +48,7 @@
self.func.name, expected, arg, given)
#
argchain = libffi.ArgChain()
- argpusher = PushArgumentConverter(space, argchain, self.to_free)
+ argpusher = PushArgumentConverter(space, argchain, self)
for i in range(expected):
w_argtype = self.argtypes_w[i]
w_arg = args_w[i]
@@ -83,10 +83,10 @@
low-level types and push them to the argchain.
"""
- def __init__(self, space, argchain, to_free):
+ def __init__(self, space, argchain, w_func):
FromAppLevelConverter.__init__(self, space)
self.argchain = argchain
- self.to_free = to_free
+ self.w_func = w_func
def handle_signed(self, w_ffitype, w_obj, intval):
self.argchain.arg(intval)
@@ -108,13 +108,13 @@
def handle_char_p(self, w_ffitype, w_obj, strval):
buf = rffi.str2charp(strval)
- self.to_free.append(rffi.cast(rffi.VOIDP, buf))
+ self.w_func.to_free.append(rffi.cast(rffi.VOIDP, buf))
addr = rffi.cast(rffi.ULONG, buf)
self.argchain.arg(addr)
def handle_unichar_p(self, w_ffitype, w_obj, unicodeval):
buf = rffi.unicode2wcharp(unicodeval)
- self.to_free.append(rffi.cast(rffi.VOIDP, buf))
+ self.w_func.to_free.append(rffi.cast(rffi.VOIDP, buf))
addr = rffi.cast(rffi.ULONG, buf)
self.argchain.arg(addr)
More information about the pypy-commit
mailing list