[pypy-commit] pypy callfamily: move these 2 methods to a more logical location
rlamy
noreply at buildbot.pypy.org
Mon Apr 20 21:36:34 CEST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: callfamily
Changeset: r76853:a3e80a13f169
Date: 2015-04-20 20:36 +0100
http://bitbucket.org/pypy/pypy/changeset/a3e80a13f169/
Log: move these 2 methods to a more logical location
diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py
--- a/rpython/annotator/description.py
+++ b/rpython/annotator/description.py
@@ -53,6 +53,22 @@
table.append(row)
self.total_calltable_size += 1
+ def find_row(self, bookkeeper, descs, args, op):
+ shape = rawshape(args)
+ with bookkeeper.at_position(None):
+ row = build_calltable_row(descs, args, op)
+ index = self.calltable_lookup_row(shape, row)
+ return shape, index
+
+def build_calltable_row(descs, args, op):
+ # see comments in CallFamily
+ row = {}
+ for desc in descs:
+ graph = desc.get_graph(args, op)
+ assert isinstance(graph, FunctionGraph)
+ row[desc.rowkey()] = graph
+ return row
+
class FrozenAttrFamily(object):
"""A family of FrozenDesc objects that have any common 'getattr' sites.
@@ -352,33 +368,15 @@
@staticmethod
def consider_call_site(descs, args, s_result, op):
+ family = descs[0].getcallfamily()
shape = rawshape(args)
- row = FunctionDesc.row_to_consider(descs, args, op)
- family = descs[0].getcallfamily()
+ row = build_calltable_row(descs, args, op)
family.calltable_add_row(shape, row)
descs[0].mergecallfamilies(*descs[1:])
- @staticmethod
- def variant_for_call_site(bookkeeper, family, descs, args, op):
- shape = rawshape(args)
- with bookkeeper.at_position(None):
- row = FunctionDesc.row_to_consider(descs, args, op)
- index = family.calltable_lookup_row(shape, row)
- return shape, index
-
def rowkey(self):
return self
- @staticmethod
- def row_to_consider(descs, args, op):
- # see comments in CallFamily
- row = {}
- for desc in descs:
- graph = desc.get_graph(args, op)
- assert isinstance(graph, FunctionGraph)
- row[desc.rowkey()] = graph
- return row
-
def get_s_signatures(self, shape):
family = self.getcallfamily()
table = family.calltables.get(shape)
@@ -923,7 +921,7 @@
def consider_call_site(descs, args, s_result, op):
cnt, keys, star = rawshape(args)
shape = cnt + 1, keys, star # account for the extra 'self'
- row = FunctionDesc.row_to_consider(descs, args, op)
+ row = build_calltable_row(descs, args, op)
family = descs[0].getcallfamily()
family.calltable_add_row(shape, row)
descs[0].mergecallfamilies(*descs[1:])
@@ -1093,7 +1091,7 @@
def consider_call_site(descs, args, s_result, op):
cnt, keys, star = rawshape(args)
shape = cnt + 1, keys, star # account for the extra 'self'
- row = FunctionDesc.row_to_consider(descs, args, op)
+ row = build_calltable_row(descs, args, op)
family = descs[0].getcallfamily()
family.calltable_add_row(shape, row)
descs[0].mergecallfamilies(*descs[1:])
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -321,9 +321,8 @@
def get_concrete_llfn(self, s_pbc, args_s, op):
bk = self.rtyper.annotator.bookkeeper
descs = list(s_pbc.descriptions)
- vfcs = FunctionDesc.variant_for_call_site
args = simple_args(args_s)
- shape, index = vfcs(bk, self.callfamily, descs, args, op)
+ shape, index = self.callfamily.find_row(bk, descs, args, op)
funcdesc, = descs
row_of_one_graph = self.callfamily.calltables[shape][index]
graph = row_of_one_graph[funcdesc]
@@ -341,8 +340,7 @@
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 = FunctionDesc.variant_for_call_site
- shape, index = vfcs(bk, self.callfamily, descs, args, hop.spaceop)
+ shape, index = self.callfamily.find_row(bk, descs, args, hop.spaceop)
row_of_graphs = self.callfamily.calltables[shape][index]
anygraph = row_of_graphs.itervalues().next() # pick any witness
vfn = hop.inputarg(self, arg=0)
@@ -475,8 +473,7 @@
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 = FunctionDesc.variant_for_call_site
- shape, index = vfcs(bk, self.callfamily, descs, args, hop.spaceop)
+ shape, index = self.callfamily.find_row(bk, descs, args, hop.spaceop)
row_of_graphs = self.callfamily.calltables[shape][index]
anygraph = row_of_graphs.itervalues().next() # pick any witness
vlist = [hop.inputarg(self, arg=0)]
More information about the pypy-commit
mailing list