Author: Ronan Lamy <[email protected]>
Branch: kill-ootype
Changeset: r65561:e05eac0b3ff9
Date: 2013-07-23 18:20 +0200
http://bitbucket.org/pypy/pypy/changeset/e05eac0b3ff9/
Log: Remove ootype support from rpython.translator.backendopt.inline
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
@@ -3,7 +3,6 @@
from rpython.flowspace.model import (Variable, Constant, Block, Link,
SpaceOperation, c_last_exception, FunctionGraph, mkentrymap)
from rpython.rtyper.lltypesystem.lltype import Bool, Signed, typeOf, Void,
Ptr, normalizeptr
-from rpython.rtyper.ootypesystem import ootype
from rpython.tool.algo import sparsemat
from rpython.translator.backendopt import removenoops
from rpython.translator.backendopt.canraise import RaiseAnalyzer
@@ -16,22 +15,12 @@
pass
-def get_meth_from_oosend(op):
- INSTANCE = op.args[1].concretetype
- _, meth = INSTANCE._lookup(op.args[0].value)
- virtual = getattr(meth, '_virtual', True)
- if virtual:
- return None
- else:
- return meth
-
-
class CanRaise(object):
def __init__(self, can_raise):
self.can_raise = can_raise
-def collect_called_graphs(graph, translator, include_oosend=True):
+def collect_called_graphs(graph, translator):
graphs_or_something = set()
for block in graph.iterblocks():
for op in block.operations:
@@ -48,15 +37,6 @@
else:
for graph in graphs:
graphs_or_something.add(graph)
- if op.opname == 'oosend' and include_oosend:
- meth = get_meth_from_oosend(op)
- if hasattr(meth, 'graph'):
- key = meth.graph
- elif hasattr(meth, '_can_raise'):
- key = CanRaise(meth._can_raise)
- else:
- key = op.args[0]
- graphs_or_something.add(key)
return graphs_or_something
def iter_callsites(graph, calling_what):
@@ -64,10 +44,6 @@
for i, op in enumerate(block.operations):
if op.opname == "direct_call":
funcobj = op.args[0].value._obj
- elif op.opname == "oosend":
- funcobj = get_meth_from_oosend(op)
- if funcobj is None:
- continue # cannot inline virtual methods
else:
continue
@@ -119,21 +95,16 @@
while True:
if isinstance(currvar, Constant):
value = currvar.value
- if isinstance(typeOf(value), ootype.Instance):
- TYPE = ootype.dynamicType(value)
- else:
- TYPE = typeOf(normalizeptr(value))
+ TYPE = typeOf(normalizeptr(value))
return TYPE, block.exits[0]
if i < 0:
return None, None
op = ops[i]
i -= 1
- if op.opname in ("same_as", "cast_pointer", "ooupcast", "oodowncast")
and op.result is currvar:
+ if op.opname in ("same_as", "cast_pointer") and op.result is currvar:
currvar = op.args[0]
elif op.opname == "malloc" and op.result is currvar:
return Ptr(op.args[0].value), block.exits[0]
- elif op.opname == "new" and op.result is currvar:
- return op.args[0].value, block.exits[0]
def does_raise_directly(graph, raise_analyzer):
""" this function checks, whether graph contains operations which can raise
@@ -216,11 +187,8 @@
return count
def get_graph_from_op(self, op):
- assert op.opname in ('direct_call', 'oosend')
- if op.opname == 'direct_call':
- return self.op.args[0].value._obj.graph
- else:
- return get_meth_from_oosend(op).graph
+ assert op.opname == 'direct_call'
+ return self.op.args[0].value._obj.graph
def inline_once(self, block, index_operation):
self.varmap = {}
@@ -247,10 +215,6 @@
for i, op in enumerate(block.operations):
if op.opname == "direct_call":
funcobj = op.args[0].value._obj
- elif op.opname == "oosend":
- funcobj = get_meth_from_oosend(op)
- if funcobj is None:
- continue
else:
continue
graph = getattr(funcobj, 'graph', None)
@@ -457,26 +421,6 @@
passon_args.append(linktoinlined.args[index])
passon_args += self.original_passon_vars
- if self.op.opname == 'oosend' and not isinstance(self.op.args[1],
Constant):
- # if we try to inline a graph defined in a superclass, the
- # type of 'self' on the graph differs from the current
- linkv = passon_args[0]
- inputv = copiedstartblock.inputargs[0]
- LINK_SELF = linkv.concretetype
- INPUT_SELF = inputv.concretetype
- if LINK_SELF != INPUT_SELF:
- # need to insert an upcast
- if ootype.isSubclass(LINK_SELF, INPUT_SELF):
- opname = 'ooupcast'
- else:
- assert ootype.isSubclass(INPUT_SELF, LINK_SELF)
- opname = 'oodowncast'
- v = Variable()
- v.concretetype = INPUT_SELF
- upcast = SpaceOperation(opname, [linkv], v)
- block.operations.append(upcast)
- passon_args[0] = v
-
#rewire blocks
linktoinlined.target = copiedstartblock
linktoinlined.args = passon_args
@@ -544,8 +488,6 @@
total += 1.5 + len(op.args) / 2
elif op.opname == "indirect_call":
total += 2 + len(op.args) / 2
- elif op.opname == "oosend":
- total += 2 + len(op.args) / 2
total += weights.get(op.opname, 1)
if block.exitswitch is not None:
total += 1
@@ -629,11 +571,6 @@
'_dont_inline_', False):
continue
add(parentgraph, block, op, graph)
- if op.opname == "oosend":
- meth = get_meth_from_oosend(op)
- graph = getattr(meth, 'graph', None)
- if graph is not None and graph in ok_to_call:
- add(parentgraph, block, op, graph)
return result
def instrument_inline_candidates(graphs, threshold):
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
@@ -550,7 +550,7 @@
eval_func, t = self.check_auto_inlining(f, [])
f_graph = graphof(t, f)
- called_graphs = collect_called_graphs(f_graph, t, include_oosend=False)
+ called_graphs = collect_called_graphs(f_graph, t)
assert len(called_graphs) == 0
result = eval_func([])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit