[pypy-commit] pypy default: merge branch unify-call-ops
rlamy
noreply at buildbot.pypy.org
Mon May 26 04:58:15 CEST 2014
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r71734:03667db26477
Date: 2014-05-26 03:57 +0100
http://bitbucket.org/pypy/pypy/changeset/03667db26477/
Log: merge branch unify-call-ops
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -11,3 +11,4 @@
.. branch: release-2.3.x
+.. branch: unify-call-ops
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -18,7 +18,7 @@
from rpython.annotator.dictdef import DictDef
from rpython.annotator import description
from rpython.annotator.signature import annotationoftype
-from rpython.annotator.argument import simple_args, complex_args
+from rpython.annotator.argument import simple_args
from rpython.rlib.objectmodel import r_dict, Symbolic
from rpython.tool.algo.unionfind import UnionFind
from rpython.rtyper import extregistry
@@ -103,8 +103,9 @@
self.consider_call_site(call_op)
for pbc, args_s in self.emulated_pbc_calls.itervalues():
- self.consider_call_site_for_pbc(pbc, 'simple_call',
- args_s, s_ImpossibleValue, None)
+ args = simple_args(args_s)
+ self.consider_call_site_for_pbc(pbc, args,
+ s_ImpossibleValue, None)
self.emulated_pbc_calls = {}
finally:
self.leave()
@@ -152,16 +153,16 @@
args_s = [lltype_to_annotation(adtmeth.ll_ptrtype)] + args_s
if isinstance(s_callable, SomePBC):
s_result = binding(call_op.result, s_ImpossibleValue)
- self.consider_call_site_for_pbc(s_callable, call_op.opname, args_s,
+ args = call_op.build_args(args_s)
+ self.consider_call_site_for_pbc(s_callable, args,
s_result, call_op)
- def consider_call_site_for_pbc(self, s_callable, opname, args_s, s_result,
+ def consider_call_site_for_pbc(self, s_callable, args, s_result,
call_op):
descs = list(s_callable.descriptions)
if not descs:
return
family = descs[0].getcallfamily()
- args = self.build_args(opname, args_s)
s_callable.getKind().consider_call_site(self, family, descs, args,
s_result, call_op)
@@ -562,12 +563,6 @@
assert self.annotator.binding(op.args[pos]) == s_type
return op
- def build_args(self, op, args_s):
- if op == "simple_call":
- return simple_args(args_s)
- elif op == "call_args":
- return complex_args(args_s)
-
def ondegenerated(self, what, s_value, where=None, called_from_graph=None):
self.annotator.ondegenerated(what, s_value, where=where,
called_from_graph=called_from_graph)
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -14,6 +14,7 @@
SpaceOperation)
from rpython.flowspace.specialcase import register_flow_sc
from rpython.annotator.model import SomeTuple
+from rpython.annotator.argument import ArgumentsForTranslation
from rpython.flowspace.specialcase import SPECIAL_CASES
@@ -511,6 +512,9 @@
return sc(ctx, *args_w)
return ctx.do_op(self)
+ def build_args(self, args_s):
+ return ArgumentsForTranslation(list(args_s))
+
class CallArgs(SingleDispatchMixin, CallOp):
opname = 'call_args'
@@ -529,6 +533,10 @@
"should not call %r with keyword arguments" % (fn,))
return ctx.do_op(self)
+ def build_args(self, args_s):
+ return ArgumentsForTranslation.fromshape(args_s[0].const,
+ list(args_s[1:]))
+
# Other functions that get directly translated to SpaceOperators
func2op[type] = op.type
diff --git a/rpython/rtyper/callparse.py b/rpython/rtyper/callparse.py
--- a/rpython/rtyper/callparse.py
+++ b/rpython/rtyper/callparse.py
@@ -31,7 +31,7 @@
getrinputs(rtyper, graph),
getrresult(rtyper, graph))
-def callparse(rtyper, graph, hop, opname, r_self=None):
+def callparse(rtyper, graph, hop, r_self=None):
"""Parse the arguments of 'hop' when calling the given 'graph'.
"""
rinputs = getrinputs(rtyper, graph)
@@ -43,6 +43,7 @@
else:
start = 0
rinputs[0] = r_self
+ opname = hop.spaceop.opname
if opname == "simple_call":
arguments = ArgumentsForRtype(args_h(start))
elif opname == "call_args":
diff --git a/rpython/rtyper/lltypesystem/rpbc.py b/rpython/rtyper/lltypesystem/rpbc.py
--- a/rpython/rtyper/lltypesystem/rpbc.py
+++ b/rpython/rtyper/lltypesystem/rpbc.py
@@ -183,10 +183,10 @@
return self.convert_desc(funcdesc)
def rtype_simple_call(self, hop):
- return self.call('simple_call', hop)
+ return self.call(hop)
def rtype_call_args(self, hop):
- return self.call('call_args', hop)
+ return self.call(hop)
def dispatcher(self, shape, index, argtypes, resulttype):
key = shape, index, tuple(argtypes), resulttype
@@ -224,9 +224,9 @@
c_ret = self._dispatch_cache[key] = inputconst(typeOf(ll_ret), ll_ret)
return c_ret
- def call(self, opname, hop):
+ def call(self, hop):
bk = self.rtyper.annotator.bookkeeper
- args = bk.build_args(opname, hop.args_s[1:])
+ args = hop.spaceop.build_args(hop.args_s[1:])
s_pbc = hop.args_s[0] # possibly more precise than self.s_pbc
descs = list(s_pbc.descriptions)
vfcs = description.FunctionDesc.variant_for_call_site
@@ -234,7 +234,7 @@
row_of_graphs = self.callfamily.calltables[shape][index]
anygraph = row_of_graphs.itervalues().next() # pick any witness
vlist = [hop.inputarg(self, arg=0)]
- vlist += callparse.callparse(self.rtyper, anygraph, hop, opname)
+ vlist += callparse.callparse(self.rtyper, anygraph, hop)
rresult = callparse.getrresult(self.rtyper, anygraph)
hop.exception_is_here()
v_dispatcher = self.dispatcher(shape, index, [v.concretetype for v in vlist[1:]], rresult.lowleveltype)
@@ -353,11 +353,6 @@
v_func = r_class.getclsfield(v_cls, self.methodname, hop.llops)
hop2 = self.add_instance_arg_to_hop(hop, call_args)
- opname = 'simple_call'
- if call_args:
- opname = 'call_args'
- hop2.forced_opname = opname
-
hop2.v_s_insertfirstarg(v_func, s_func) # insert 'function'
if type(hop2.args_r[0]) is SmallFunctionSetPBCRepr and type(r_func) is FunctionsPBCRepr:
diff --git a/rpython/rtyper/module/r_os_stat.py b/rpython/rtyper/module/r_os_stat.py
--- a/rpython/rtyper/module/r_os_stat.py
+++ b/rpython/rtyper/module/r_os_stat.py
@@ -10,6 +10,7 @@
from rpython.annotator import model as annmodel
from rpython.rtyper.llannotation import lltype_to_annotation
from rpython.flowspace.model import Constant
+from rpython.flowspace.operation import op
from rpython.tool.pairtype import pairtype
from rpython.rtyper.rmodel import Repr
from rpython.rtyper.rint import IntegerRepr
@@ -36,8 +37,10 @@
rtyper = self.rtyper
s_index = rtyper.annotator.bookkeeper.immutablevalue(index)
hop2 = hop.copy()
- hop2.forced_opname = 'getitem'
- hop2.args_v = [hop2.args_v[0], Constant(index)]
+ spaceop = op.getitem(hop.args_v[0], Constant(index))
+ spaceop.result = hop.spaceop.result
+ hop2.spaceop = spaceop
+ hop2.args_v = spaceop.args
hop2.args_s = [self.s_tuple, s_index]
hop2.args_r = [self.r_tuple, rtyper.getrepr(s_index)]
return hop2.dispatch()
@@ -87,8 +90,10 @@
rtyper = self.rtyper
s_index = rtyper.annotator.bookkeeper.immutablevalue(index)
hop2 = hop.copy()
- hop2.forced_opname = 'getitem'
- hop2.args_v = [hop2.args_v[0], Constant(index)]
+ spaceop = op.getitem(hop.args_v[0], Constant(index))
+ spaceop.result = hop.result
+ hop2.spaceop = spaceop
+ hop2.args_v = spaceop.args
hop2.args_s = [self.s_tuple, s_index]
hop2.args_r = [self.r_tuple, rtyper.getrepr(s_index)]
return hop2.dispatch()
diff --git a/rpython/rtyper/rcontrollerentry.py b/rpython/rtyper/rcontrollerentry.py
--- a/rpython/rtyper/rcontrollerentry.py
+++ b/rpython/rtyper/rcontrollerentry.py
@@ -1,4 +1,5 @@
from rpython.flowspace.model import Constant
+from rpython.flowspace.operation import op
from rpython.rtyper.error import TyperError
from rpython.rtyper.rmodel import Repr
from rpython.tool.pairtype import pairtype
@@ -71,5 +72,7 @@
s_new, r_new = r_controlled.s_real_obj, r_controlled.r_real_obj
hop2.s_result, hop2.r_result = s_new, r_new
hop2.v_s_insertfirstarg(c_meth, s_meth)
- hop2.forced_opname = 'simple_call'
+ spaceop = op.simple_call(*hop2.args_v)
+ spaceop.result = hop2.spaceop.result
+ hop2.spaceop = spaceop
return hop2.dispatch()
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -300,14 +300,14 @@
return inputconst(typeOf(llfn), llfn)
def rtype_simple_call(self, hop):
- return self.call('simple_call', hop)
+ return self.call(hop)
def rtype_call_args(self, hop):
- return self.call('call_args', hop)
+ return self.call(hop)
- def call(self, opname, hop):
+ def call(self, hop):
bk = self.rtyper.annotator.bookkeeper
- args = bk.build_args(opname, hop.args_s[1:])
+ args = hop.spaceop.build_args(hop.args_s[1:])
s_pbc = hop.args_s[0] # possibly more precise than self.s_pbc
descs = list(s_pbc.descriptions)
vfcs = description.FunctionDesc.variant_for_call_site
@@ -317,7 +317,7 @@
vfn = hop.inputarg(self, arg=0)
vlist = [self.convert_to_concrete_llfn(vfn, shape, index,
hop.llops)]
- vlist += callparse.callparse(self.rtyper, anygraph, hop, opname)
+ vlist += callparse.callparse(self.rtyper, anygraph, hop)
rresult = callparse.getrresult(self.rtyper, anygraph)
hop.exception_is_here()
if isinstance(vlist[0], Constant):
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -650,8 +650,6 @@
class HighLevelOp(object):
- forced_opname = None
-
def __init__(self, rtyper, spaceop, exceptionlinks, llops):
self.rtyper = rtyper
self.spaceop = spaceop
@@ -679,12 +677,11 @@
if type(value) is list: # grunt
value = value[:]
setattr(result, key, value)
- result.forced_opname = self.forced_opname
return result
def dispatch(self):
rtyper = self.rtyper
- opname = self.forced_opname or self.spaceop.opname
+ opname = self.spaceop.opname
translate_meth = getattr(rtyper, 'translate_op_' + opname,
rtyper.default_translate_operation)
return translate_meth(self)
More information about the pypy-commit
mailing list