[pypy-svn] r20212 - in pypy/branch/somepbc-refactoring/pypy: annotation doc/discussion rpython/lltypesystem
arigo at codespeak.net
arigo at codespeak.net
Thu Nov 24 16:46:35 CET 2005
Author: arigo
Date: Thu Nov 24 16:46:33 2005
New Revision: 20212
Modified:
pypy/branch/somepbc-refactoring/pypy/annotation/description.py
pypy/branch/somepbc-refactoring/pypy/doc/discussion/somepbc-refactoring-plan.txt
pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rpbc.py
Log:
(mwh, pedronis, arigo)
some clean-ups (!) in description.py, to build call families of the
FunctionDescs only. Two more test_rpbc tests pass with just a don't-look
kind of hack.
Modified: pypy/branch/somepbc-refactoring/pypy/annotation/description.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/annotation/description.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/annotation/description.py Thu Nov 24 16:46:33 2005
@@ -18,10 +18,11 @@
self.total_calltable_size = 0
def update(self, other):
- assert not self.calltables and not other.calltables, (
- "too late for merging call families!")
self.descs.update(other.descs)
self.patterns.update(other.patterns)
+ for shape, table in other.calltables.items():
+ for row in table:
+ self.calltable_add_row(shape, row)
def calltable_lookup_row(self, callshape, row):
# this code looks up a table of which graph to
@@ -77,15 +78,15 @@
def getcallfamily(self):
"""Get the CallFamily object."""
call_families = self.bookkeeper.pbc_maximal_call_families
- _, _, callfamily = call_families.find(self)
+ _, _, callfamily = call_families.find(self.rowkey())
return callfamily
def mergecallfamilies(self, *others):
"""Merge the call families of the given Descs into one."""
call_families = self.bookkeeper.pbc_maximal_call_families
- changed, rep, callfamily = call_families.find(self)
+ changed, rep, callfamily = call_families.find(self.rowkey())
for desc in others:
- changed1, rep, callfamily = call_families.union(rep, desc)
+ changed1, rep, callfamily = call_families.union(rep, desc.rowkey())
changed = changed or changed1
return changed
@@ -107,10 +108,6 @@
def bind_under(self, classdef, name):
return self
- def consider_call_site(bookkeeper, family, descs, args):
- print "unimplemented consider_call_site for %r" % (descs,) # XXX
- consider_call_site = staticmethod(consider_call_site)
-
class FunctionDesc(Desc):
knowntype = types.FunctionType
@@ -196,13 +193,16 @@
return shape, index
variant_for_call_site = staticmethod(variant_for_call_site)
+ def rowkey(self):
+ return self
+
def row_to_consider(descs, args):
# see comments in CallFamily
from pypy.annotation.model import s_ImpossibleValue
row = {}
for desc in descs:
def enlist(graph, ignore):
- row[desc] = graph
+ row[desc.rowkey()] = graph
return s_ImpossibleValue # meaningless
desc.pycall(enlist, args, s_ImpossibleValue)
return row
@@ -378,6 +378,13 @@
return self
return None
+ def consider_call_site(bookkeeper, family, descs, args):
+ print "XXX not implemented"
+ consider_call_site = staticmethod(consider_call_site)
+
+ def rowkey(self):
+ return self
+
class MethodDesc(Desc):
knowntype = types.MethodType
@@ -401,6 +408,21 @@
def bind_under(self, classdef, name):
self.bookkeeper.warning("rebinding an already bound %r" % (self,))
return self.funcdesc.bind_under(classdef, name)
+
+ def consider_call_site(bookkeeper, family, descs, args):
+ funcdescs = [methoddesc.funcdesc for methoddesc in descs]
+ row = FunctionDesc.row_to_consider(descs, args)
+ shape = args.rawshape()
+ shape = (shape[0]+1,) + shape[1:] # account for the extra 'self'
+ family.calltable_add_row(shape, row)
+ consider_call_site = staticmethod(consider_call_site)
+
+ def rowkey(self):
+ # we are computing call families and call tables that always contain
+ # FunctionDescs, not MethodDescs. The present method returns the
+ # FunctionDesc to use as a key in that family.
+ return self.funcdesc
+
def new_or_old_class(c):
if hasattr(c, '__class__'):
@@ -445,3 +467,14 @@
s_self = SomePBC([self.frozendesc])
args = args.prepend(s_self)
return self.funcdesc.pycall(schedule, args, s_previous_result)
+
+ def consider_call_site(bookkeeper, family, descs, args):
+ funcdescs = [mofdesc.funcdesc for mofdesc in descs]
+ row = FunctionDesc.row_to_consider(descs, args)
+ shape = args.rawshape()
+ shape = (shape[0]+1,) + shape[1:] # account for the extra 'self'
+ family.calltable_add_row(shape, row)
+ consider_call_site = staticmethod(consider_call_site)
+
+ def rowkey(self):
+ return self.funcdesc
Modified: pypy/branch/somepbc-refactoring/pypy/doc/discussion/somepbc-refactoring-plan.txt
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/doc/discussion/somepbc-refactoring-plan.txt (original)
+++ pypy/branch/somepbc-refactoring/pypy/doc/discussion/somepbc-refactoring-plan.txt Thu Nov 24 16:46:33 2005
@@ -170,8 +170,7 @@
that's actually being called.
Neither is totally straightforward: the former is closer to what
-happens on the trunk but there is no obvious place to attach the
-information, unless maybe normalization can essentially remove all
-callables from FuncDescs from the graph? The latter is more of a
+happens on the trunk but new families of funcdescs need to be created
+at the end of annotation or by normalisation. The latter is more of a
change. The former is also perhaps a bit unnatural for ootyped
backends.
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rpbc.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rpbc.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rpbc.py Thu Nov 24 16:46:33 2005
@@ -153,7 +153,8 @@
return self.redispatch_call(hop, call_args=True)
def redispatch_call(self, hop, call_args):
- s_function = annmodel.SomePBC({self.funcdesc: True})
+ # XXX obscure, try to refactor...
+ s_function = annmodel.SomePBC([self.funcdesc])
hop2 = hop.copy()
hop2.args_s[0] = self.s_im_self # make the 1st arg stand for 'im_self'
hop2.args_r[0] = self.r_im_self # (same lowleveltype as 'self')
@@ -164,7 +165,8 @@
hop2.swap_fst_snd_args()
_, s_shape = hop2.r_s_popfirstarg() # temporarely remove shape
adjust_shape(hop2, s_shape)
- c = Constant(self.function)
+ # a marker that would crash if actually used...
+ c = Constant("obscure-don't-use-me")
hop2.v_s_insertfirstarg(c, s_function) # insert 'function'
# now hop2 looks like simple_call(function, self, args...)
return hop2.dispatch()
More information about the Pypy-commit
mailing list