Author: Armin Rigo <[email protected]>
Branch: sandbox-2
Changeset: r97293:322c4bfc9c42
Date: 2019-08-27 09:47 +0200
http://bitbucket.org/pypy/pypy/changeset/322c4bfc9c42/
Log: Revert the changes to backendopt done in 906b820ecdac; instead move
the review-checking before running backendopt. More small fixes.
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -3,7 +3,9 @@
import py
from rpython.rlib.nonconst import NonConstant
-from rpython.rlib.objectmodel import CDefinedIntSymbolic,
keepalive_until_here, specialize, not_rpython, we_are_translated
+from rpython.rlib.objectmodel import CDefinedIntSymbolic, keepalive_until_here
+from rpython.rlib.objectmodel import specialize, not_rpython, we_are_translated
+from rpython.rlib.objectmodel import sandbox_review
from rpython.rlib.unroll import unrolling_iterable
from rpython.rtyper.extregistry import ExtRegistryEntry
from rpython.tool.sourcetools import rpython_wrapper
@@ -1196,6 +1198,7 @@
def _jit_conditional_call(condition, function, *args):
pass # special-cased below
+@sandbox_review(reviewed=True) # for the llop.jit_conditional_call
@specialize.call_location()
def conditional_call(condition, function, *args):
"""Does the same as:
@@ -1217,6 +1220,7 @@
def _jit_conditional_call_value(value, function, *args):
return value # special-cased below
+@sandbox_review(reviewed=True) # for the llop.jit_conditional_call_value
@specialize.call_location()
def conditional_call_elidable(value, function, *args):
"""Does the same as:
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -1600,6 +1600,7 @@
lltype.Ptr(rwin32.FILETIME), lltype.Ptr(rwin32.FILETIME)],
rwin32.BOOL, calling_conv='win')
+@sandbox_review(reviewed=True)
@replace_os_function('times')
def times():
if not _WIN32:
diff --git a/rpython/translator/backendopt/all.py
b/rpython/translator/backendopt/all.py
--- a/rpython/translator/backendopt/all.py
+++ b/rpython/translator/backendopt/all.py
@@ -113,7 +113,7 @@
if config.profile_based_inline and not secondary:
threshold = config.profile_based_inline_threshold
heuristic = get_function(config.profile_based_inline_heuristic)
- inline.instrument_inline_candidates(translator, graphs, threshold)
+ inline.instrument_inline_candidates(graphs, threshold)
counters = translator.driver_instrument_result(
config.profile_based_inline)
n = len(counters)
diff --git a/rpython/translator/backendopt/inline.py
b/rpython/translator/backendopt/inline.py
--- a/rpython/translator/backendopt/inline.py
+++ b/rpython/translator/backendopt/inline.py
@@ -548,8 +548,7 @@
return (0.9999 * measure_median_execution_cost(graph) +
count), True # may be NaN
-def inlinable_static_callers(translator, graphs, store_calls=False,
- ok_to_call=None):
+def inlinable_static_callers(graphs, store_calls=False, ok_to_call=None):
if ok_to_call is None:
ok_to_call = set(graphs)
result = []
@@ -559,7 +558,6 @@
else:
result.append((parentgraph, graph))
#
- dont_inline = make_dont_inline_checker(translator)
for parentgraph in graphs:
for block in parentgraph.iterblocks():
for op in block.operations:
@@ -567,12 +565,13 @@
funcobj = op.args[0].value._obj
graph = getattr(funcobj, 'graph', None)
if graph is not None and graph in ok_to_call:
- if dont_inline(funcobj):
+ if getattr(getattr(funcobj, '_callable', None),
+ '_dont_inline_', False):
continue
add(parentgraph, block, op, graph)
return result
-def instrument_inline_candidates(translator, graphs, threshold):
+def instrument_inline_candidates(graphs, threshold):
cache = {None: False}
def candidate(graph):
try:
@@ -582,7 +581,6 @@
cache[graph] = res
return res
n = 0
- dont_inline = make_dont_inline_checker(translator)
for parentgraph in graphs:
for block in parentgraph.iterblocks():
ops = block.operations
@@ -594,7 +592,8 @@
funcobj = op.args[0].value._obj
graph = getattr(funcobj, 'graph', None)
if graph is not None:
- if dont_inline(funcobj):
+ if getattr(getattr(funcobj, '_callable', None),
+ '_dont_inline_', False):
continue
if candidate(graph):
tag = Constant('inline', Void)
@@ -611,17 +610,6 @@
return (hasattr(graph, 'func') and
getattr(graph.func, '_always_inline_', None))
-def make_dont_inline_checker(translator):
- sandbox = translator.config.translation.sandbox
-
- def dont_inline(funcobj):
- func = getattr(funcobj, '_callable', None)
- if sandbox:
- if hasattr(func, '_sandbox_review_'):
- return True
- return getattr(func, '_dont_inline_', False)
- return dont_inline
-
def auto_inlining(translator, threshold=None,
callgraph=None,
call_count_pred=None,
@@ -633,7 +621,7 @@
callers = {} # {graph: {graphs-that-call-it}}
callees = {} # {graph: {graphs-that-it-calls}}
if callgraph is None:
- callgraph = inlinable_static_callers(translator, translator.graphs)
+ callgraph = inlinable_static_callers(translator.graphs)
for graph1, graph2 in callgraph:
callers.setdefault(graph2, {})[graph1] = True
callees.setdefault(graph1, {})[graph2] = True
@@ -739,8 +727,7 @@
if not hasattr(graph, 'exceptiontransformed')])
else:
ok_to_call = None
- callgraph = inlinable_static_callers(translator, graphs,
- ok_to_call=ok_to_call)
+ callgraph = inlinable_static_callers(graphs, ok_to_call=ok_to_call)
count = auto_inlining(translator, threshold, callgraph=callgraph,
heuristic=heuristic,
call_count_pred=call_count_pred)
diff --git a/rpython/translator/backendopt/test/test_inline.py
b/rpython/translator/backendopt/test/test_inline.py
--- a/rpython/translator/backendopt/test/test_inline.py
+++ b/rpython/translator/backendopt/test/test_inline.py
@@ -100,7 +100,7 @@
call_count_pred = None
if call_count_check:
call_count_pred = lambda lbl: True
- instrument_inline_candidates(t, t.graphs, threshold)
+ instrument_inline_candidates(t.graphs, threshold)
if remove_same_as:
for graph in t.graphs:
diff --git a/rpython/translator/driver.py b/rpython/translator/driver.py
--- a/rpython/translator/driver.py
+++ b/rpython/translator/driver.py
@@ -344,6 +344,12 @@
rtyper = self.translator.buildrtyper()
rtyper.specialize(dont_simplify_again=True)
+ # we do the sandbox review checking here, before inlining graphs
+ # inside each other (and later generating extra graphs for the GC).
+ if self.config.translation.sandbox:
+ from rpython.translator.sandbox import graphchecker
+ graphchecker.check_all_graphs(self.translator)
+
@taskdef([RTYPE], "JIT compiler generation")
def task_pyjitpl_lltype(self):
""" Generate bytecodes for JIT and flow the JIT helper functions
@@ -412,10 +418,6 @@
if translator.annotator is not None:
translator.frozen = True
- if self.config.translation.sandbox:
- from rpython.translator.sandbox import graphchecker
- graphchecker.check_all_graphs(self.translator)
-
standalone = self.standalone
get_gchooks = self.extra.get('get_gchooks', lambda: None)
gchooks = get_gchooks()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit