Author: Ronan Lamy <[email protected]>
Branch: exctrans
Changeset: r81826:7a2c1c67667b
Date: 2016-01-17 15:44 +0000
http://bitbucket.org/pypy/pypy/changeset/7a2c1c67667b/
Log: Do sandboxing of register_external() stuff at the rtyper level
diff --git a/rpython/rtyper/extfunc.py b/rpython/rtyper/extfunc.py
--- a/rpython/rtyper/extfunc.py
+++ b/rpython/rtyper/extfunc.py
@@ -46,6 +46,12 @@
impl = getattr(self, 'lltypeimpl', None)
fakeimpl = getattr(self, 'lltypefakeimpl', self.instance)
if impl:
+ if (rtyper.annotator.translator.config.translation.sandbox
+ and not self.safe_not_sandboxed):
+ from rpython.translator.sandbox.rsandbox import (
+ 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
@@ -74,15 +80,10 @@
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
# the eventual call to rtyper.getcallable() will find them
# and transfer them to the final lltype.functionptr().
- impl._llfnobjattrs_ = {
- '_name': self.name,
- '_safe_not_sandboxed': self.safe_not_sandboxed,
- }
+ impl._llfnobjattrs_ = {'_name': self.name}
obj = rtyper.getannmixlevel().delayedfunction(
impl, signature_args, hop.s_result)
else:
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -29,7 +29,7 @@
from rpython.rtyper.rclass import RootClassRepr
from rpython.tool.pairtype import pair
from rpython.translator.unsimplify import insert_empty_block
-from rpython.translator.sandbox.rsandbox import make_sandbox_trampoline,
_annotate
+from rpython.translator.sandbox.rsandbox import make_sandbox_trampoline
class RPythonTyper(object):
diff --git a/rpython/translator/c/node.py b/rpython/translator/c/node.py
--- a/rpython/translator/c/node.py
+++ b/rpython/translator/c/node.py
@@ -905,13 +905,7 @@
def new_funcnode(db, T, obj, forcename=None):
sandbox = db.sandbox and need_sandboxing(obj)
if sandbox:
- if hasattr(obj, 'graph') and sandbox != 'if_external':
- graph = rsandbox.get_external_function_sandbox_graph(
- obj, db.translator.rtyper)
- obj.__dict__['graph'] = graph
- obj.__dict__.pop('_safe_not_sandboxed', None)
- obj.__dict__.pop('external', None)
- elif getattr(obj, 'external', None) is not None:
+ if getattr(obj, 'external', None) is not None:
obj.__dict__['graph'] = rsandbox.get_sandbox_stub(
obj, db.translator.rtyper)
obj.__dict__.pop('_safe_not_sandboxed', None)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit