[pypy-svn] r49985 - in pypy/dist/pypy: rpython rpython/lltypesystem translator/llvm/test
arigo at codespeak.net
arigo at codespeak.net
Fri Dec 21 16:26:45 CET 2007
Author: arigo
Date: Fri Dec 21 16:26:43 2007
New Revision: 49985
Modified:
pypy/dist/pypy/rpython/extfunc.py
pypy/dist/pypy/rpython/lltypesystem/llarena.py
pypy/dist/pypy/translator/llvm/test/test_new_gc.py
Log:
Fighting the nice wrappers that get inserted in the middle
of GC code and that allocate stuff themselves.
Modified: pypy/dist/pypy/rpython/extfunc.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunc.py (original)
+++ pypy/dist/pypy/rpython/extfunc.py Fri Dec 21 16:26:43 2007
@@ -181,16 +181,25 @@
if hasattr(self, fake_method_name):
# If we have both an {ll,oo}impl and a {ll,oo}fakeimpl,
# we need a wrapper that selects the proper one and calls it
- from pypy.rlib.objectmodel import running_on_llinterp
- from pypy.rlib.debug import llinterpcall
from pypy.tool.sourcetools import func_with_new_name
- original_impl = impl
- def ll_wrapper(*args):
- if running_on_llinterp:
- return llinterpcall(s_result, fakeimpl, *args)
- else:
- return original_impl(*args)
- impl = func_with_new_name(ll_wrapper, name + '_wrapper')
+ # Using '*args' is delicate because this wrapper is also
+ # created for init-time functions like llarena.arena_malloc
+ # which are called before the GC is fully initialized
+ args = ', '.join(['arg%d' % i for i in range(len(args_ll))])
+ d = {'original_impl': impl,
+ 's_result': s_result,
+ 'fakeimpl': fakeimpl,
+ }
+ exec py.code.compile("""
+ from pypy.rlib.objectmodel import running_on_llinterp
+ from pypy.rlib.debug import llinterpcall
+ def ll_wrapper(%s):
+ if running_on_llinterp:
+ return llinterpcall(s_result, fakeimpl, %s)
+ else:
+ return original_impl(%s)
+ """ % (args, args, args)) in d
+ impl = func_with_new_name(d['ll_wrapper'], name + '_wrapper')
if rtyper.annotator.translator.config.translation.sandbox:
impl._dont_inline_ = True
# store some attributes to the 'impl' function, where
Modified: pypy/dist/pypy/rpython/lltypesystem/llarena.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/llarena.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/llarena.py Fri Dec 21 16:26:43 2007
@@ -360,7 +360,8 @@
llimpl_round_up_for_allocation = rffi.llexternal('ROUND_UP_FOR_ALLOCATION',
[rffi.INT], rffi.INT,
- sandboxsafe=True)
+ sandboxsafe=True,
+ _nowrapper=True)
register_external(round_up_for_allocation, [int], int,
'll_arena.round_up_for_allocation',
llimpl=llimpl_round_up_for_allocation,
Modified: pypy/dist/pypy/translator/llvm/test/test_new_gc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_new_gc.py (original)
+++ pypy/dist/pypy/translator/llvm/test/test_new_gc.py Fri Dec 21 16:26:43 2007
@@ -5,7 +5,6 @@
from pypy.rpython.lltypesystem import lltype, llmemory, llarena
def test_gc_offsets():
- py.test.skip("in-progress")
STRUCT = lltype.GcStruct('S1', ('x', lltype.Signed))
ARRAY = lltype.GcArray(lltype.Signed)
s1 = llarena.round_up_for_allocation(llmemory.sizeof(STRUCT))
@@ -34,12 +33,11 @@
assert i3 + 4 <= i5
def test_1():
- py.test.skip("in-progress")
def fn(n):
d = {}
for i in range(n):
d[i] = str(i)
- return d[n//2]
+ return int(d[n//2])
mod, f = compile_test(fn, [int], gcpolicy="semispace")
assert f(5000) == fn(5000)
More information about the Pypy-commit
mailing list