[pypy-commit] pypy refactor-pycall: Clone desc.pycall() and inline its parameters for the get_call_parameters() call site.
rlamy
noreply at buildbot.pypy.org
Wed Apr 1 21:00:40 CEST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: refactor-pycall
Changeset: r76683:9de382ca4b9b
Date: 2015-04-01 19:58 +0100
http://bitbucket.org/pypy/pypy/changeset/9de382ca4b9b/
Log: Clone desc.pycall() and inline its parameters for the
get_call_parameters() call site.
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -91,22 +91,17 @@
def get_call_parameters(self, function, args_s, policy):
desc = self.bookkeeper.getdesc(function)
+ from rpython.annotator.description import FunctionDesc
+ assert isinstance(desc, FunctionDesc)
args = simple_args(args_s)
- result = []
- def schedule(graph, inputcells):
- result.append((graph, inputcells))
- return annmodel.s_ImpossibleValue
-
prevpolicy = self.policy
self.policy = policy
self.bookkeeper.enter(None)
try:
- desc.pycall(schedule, args, annmodel.s_ImpossibleValue)
+ return desc.pycall_2(args)
finally:
self.bookkeeper.leave()
self.policy = prevpolicy
- [(graph, inputcells)] = result
- return graph, inputcells
def annotate_helper(self, function, args_s, policy=None):
if policy is None:
diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py
--- a/rpython/annotator/description.py
+++ b/rpython/annotator/description.py
@@ -7,7 +7,8 @@
from rpython.annotator.argument import rawshape, ArgErr
from rpython.tool.sourcetools import valid_identifier, func_with_new_name
from rpython.tool.pairtype import extendabletype
-from rpython.annotator.model import AnnotatorError, SomeInteger, SomeString
+from rpython.annotator.model import (
+ AnnotatorError, SomeInteger, SomeString, s_ImpossibleValue)
class CallFamily(object):
"""A family of Desc objects that could be called from common call sites.
@@ -75,7 +76,6 @@
try:
return self.attrs[attrname]
except KeyError:
- from rpython.annotator.model import s_ImpossibleValue
return s_ImpossibleValue
def set_s_value(self, attrname, s_value):
@@ -97,7 +97,6 @@
# ClassAttrFamily is more precise: it is only about one attribut name.
def __init__(self, desc):
- from rpython.annotator.model import s_ImpossibleValue
self.descs = {desc: True}
self.read_locations = {} # set of position_keys
self.s_value = s_ImpossibleValue # union of possible values
@@ -321,6 +320,26 @@
result = unionof(result, s_previous_result)
return result
+ def pycall_2(self, args):
+ inputcells = self.parse_arguments(args)
+ graph = self.specialize(inputcells)
+ assert isinstance(graph, FunctionGraph)
+ # if that graph has a different signature, we need to re-parse
+ # the arguments.
+ # recreate the args object because inputcells may have been changed
+ new_args = args.unmatch_signature(self.signature, inputcells)
+ inputcells = self.parse_arguments(new_args, graph)
+ res = graph, inputcells
+ result = s_ImpossibleValue
+ signature = getattr(self.pyobj, '_signature_', None)
+ if signature:
+ sigresult = enforce_signature_return(self, signature[1], result)
+ if sigresult is not None:
+ self.bookkeeper.annotator.addpendingblock(
+ graph, graph.returnblock, [sigresult])
+ result = sigresult
+ return res
+
def bind_under(self, classdef, name):
# XXX static methods
return self.bookkeeper.getmethoddesc(self,
@@ -352,7 +371,6 @@
@staticmethod
def row_to_consider(descs, args, op):
# see comments in CallFamily
- from rpython.annotator.model import s_ImpossibleValue
row = {}
for desc in descs:
def enlist(graph, ignore):
@@ -685,7 +703,6 @@
# look up an attribute in the class
cdesc = self.lookup(name)
if cdesc is None:
- from rpython.annotator.model import s_ImpossibleValue
return s_ImpossibleValue
else:
# delegate to s_get_value to turn it into an annotation
@@ -999,7 +1016,6 @@
try:
value = self.read_attribute(attr)
except AttributeError:
- from rpython.annotator.model import s_ImpossibleValue
return s_ImpossibleValue
else:
return self.bookkeeper.immutablevalue(value)
More information about the pypy-commit
mailing list