Author: Manuel Jacob
Branch: kill-running_on_llinterp
Changeset: r68968:39eb895a3a29
Date: 2014-01-27 21:58 +0100
http://bitbucket.org/pypy/pypy/changeset/39eb895a3a29/
Log: Kill running_on_llinterp. Instead we attach the fakeimpl to the
function object and fish it in llinterp.
diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -266,8 +266,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
@@ -162,34 +162,6 @@
impl = getattr(self, method_name, None)
fakeimpl = getattr(self, fake_method_name, self.instance)
if impl:
- if hasattr(self, fake_method_name):
- # 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')
if rtyper.annotator.translator.config.translation.sandbox:
impl._dont_inline_ = True
# store some attributes to the 'impl' function, where
@@ -199,6 +171,8 @@
'_name': self.name,
'_safe_not_sandboxed': self.safe_not_sandboxed,
}
+ if hasattr(self, fake_method_name):
+ 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
@@ -643,6 +643,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 =
self.llinterpreter.typer.type_system.derefType(lltype.typeOf(f))
return self.perform_call(f, FTYPE.ARGS, args)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit