Author: Manuel Jacob
Branch: llimpl
Changeset: r82103:dbd0602d5f13
Date: 2014-01-27 21:58 +0100
http://bitbucket.org/pypy/pypy/changeset/dbd0602d5f13/
Log: Kill running_on_llinterp. Instead we attach the fakeimpl to the
function object and fish it in llinterp. (grafted from
39eb895a3a295c0a20a0fdd467e33dec0eb2fcfb)
diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -275,8 +275,6 @@
return lltype.Signed
malloc_zero_filled = CDefinedIntSymbolic('MALLOC_ZERO_FILLED', default=0)
-running_on_llinterp = CDefinedIntSymbolic('RUNNING_ON_LLINTERP', default=1)
-# running_on_llinterp is meant to have the value 0 in all backends
# ____________________________________________________________
diff --git a/rpython/rtyper/extfunc.py b/rpython/rtyper/extfunc.py
--- a/rpython/rtyper/extfunc.py
+++ b/rpython/rtyper/extfunc.py
@@ -52,38 +52,12 @@
make_sandbox_trampoline)
impl = make_sandbox_trampoline(
self.name, signature_args, s_result)
- if hasattr(self, 'lltypefakeimpl'):
- # If we have both an llimpl and an llfakeimpl,
- # we need a wrapper that selects the proper one and calls it
- from rpython.tool.sourcetools import func_with_new_name
- # 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,
- '__name__': __name__,
- }
- exec py.code.compile("""
- from rpython.rlib.objectmodel import running_on_llinterp
- from rpython.rlib.debug import llinterpcall
- from rpython.rlib.jit import dont_look_inside
- # note: we say 'dont_look_inside' mostly because the
- # JIT does not support 'running_on_llinterp', but in
- # theory it is probably right to stop jitting anyway.
- @dont_look_inside
- 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')
# store some attributes to the 'impl' function, where
# the eventual call to rtyper.getcallable() will find them
# and transfer them to the final lltype.functionptr().
impl._llfnobjattrs_ = {'_name': self.name}
+ if hasattr(self, 'lltypefakeimpl'):
+ impl._llfnobjattrs_['_fakeimpl'] = fakeimpl
obj = rtyper.getannmixlevel().delayedfunction(
impl, signature_args, hop.s_result)
else:
diff --git a/rpython/rtyper/llinterp.py b/rpython/rtyper/llinterp.py
--- a/rpython/rtyper/llinterp.py
+++ b/rpython/rtyper/llinterp.py
@@ -667,6 +667,14 @@
return frame.eval()
def op_direct_call(self, f, *args):
+ pythonfunction = getattr(f._obj, '_fakeimpl', None)
+ if pythonfunction is not None:
+ try:
+ return pythonfunction(*args)
+ except:
+ self.make_llexception()
+ return
+
FTYPE = lltype.typeOf(f).TO
return self.perform_call(f, FTYPE.ARGS, args)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit