Author: Armin Rigo <[email protected]>
Branch: sandbox-2
Changeset: r97086:18e96c1f9821
Date: 2019-08-07 17:53 +0200
http://bitbucket.org/pypy/pypy/changeset/18e96c1f9821/
Log: Avoid hacking by mutating the lltype function objects
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
@@ -885,11 +885,18 @@
if db.sandbox:
if (getattr(obj, 'external', None) is not None and
not obj._safe_not_sandboxed):
- from rpython.translator.sandbox import rsandbox
- obj.__dict__['graph'] = rsandbox.get_sandbox_stub(
- obj, db.translator.rtyper)
- obj.__dict__.pop('_safe_not_sandboxed', None)
- obj.__dict__.pop('external', None)
+ try:
+ sandbox_mapping = db.sandbox_mapping
+ except AttributeError:
+ sandbox_mapping = db.sandbox_mapping = {}
+ try:
+ obj = sandbox_mapping[obj]
+ except KeyError:
+ from rpython.translator.sandbox import rsandbox
+ llfunc = rsandbox.get_sandbox_stub(
+ obj, db.translator.rtyper)
+ sandbox_mapping[obj] = llfunc._obj
+ obj = llfunc._obj
if forcename:
name = forcename
else:
diff --git a/rpython/translator/sandbox/rsandbox.py
b/rpython/translator/sandbox/rsandbox.py
--- a/rpython/translator/sandbox/rsandbox.py
+++ b/rpython/translator/sandbox/rsandbox.py
@@ -116,7 +116,7 @@
def _annotate(rtyper, f, args_s, s_result):
ann = MixLevelHelperAnnotator(rtyper)
- graph = ann.getgraph(f, args_s, s_result)
+ llfunc = ann.delayedfunction(f, args_s, s_result, needtype=True)
ann.finish()
ann.backend_optimize()
- return graph
+ return llfunc
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit