Commit 24606d5c authored by Ronan Lamy's avatar Ronan Lamy
Browse files

kill bookkeeper.build_args

--HG--
branch : unify-call-ops
parent 8ca76f81be34
......@@ -18,7 +18,7 @@ from rpython.annotator.listdef import ListDef, ListItem
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 @@ class Bookkeeper(object):
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 @@ class Bookkeeper(object):
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 @@ class Bookkeeper(object):
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)
......
......@@ -14,6 +14,7 @@ from rpython.flowspace.model import (Constant, WrapException, const, Variable,
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 @@ class SimpleCall(SingleDispatchMixin, CallOp):
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 @@ class CallArgs(SingleDispatchMixin, CallOp):
"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
......
......@@ -31,7 +31,7 @@ def getsig(rtyper, graph):
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 @@ def callparse(rtyper, graph, hop, opname, r_self=None):
else:
start = 0
rinputs[0] = r_self
opname = hop.spaceop.opname
if opname == "simple_call":
arguments = ArgumentsForRtype(args_h(start))
elif opname == "call_args":
......
......@@ -182,10 +182,10 @@ class SmallFunctionSetPBCRepr(Repr):
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
......@@ -223,9 +223,9 @@ class SmallFunctionSetPBCRepr(Repr):
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
......@@ -233,7 +233,7 @@ class SmallFunctionSetPBCRepr(Repr):
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)
......
......@@ -300,14 +300,14 @@ class AbstractFunctionsPBCRepr(CanBeNull, Repr):
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 @@ class AbstractFunctionsPBCRepr(CanBeNull, Repr):
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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment