[pypy-commit] pypy default: don't require a bookkeeper to create an ArgumentsForTranslation object
rlamy
noreply at buildbot.pypy.org
Wed May 21 05:08:41 CEST 2014
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r71626:48e079c6da38
Date: 2014-05-21 04:07 +0100
http://bitbucket.org/pypy/pypy/changeset/48e079c6da38/
Log: don't require a bookkeeper to create an ArgumentsForTranslation
object
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -10,6 +10,7 @@
c_last_exception, checkgraph)
from rpython.translator import simplify, transform
from rpython.annotator import model as annmodel, signature
+from rpython.annotator.argument import simple_args
from rpython.annotator.bookkeeper import Bookkeeper
import py
@@ -91,7 +92,7 @@
def get_call_parameters(self, function, args_s, policy):
desc = self.bookkeeper.getdesc(function)
- args = self.bookkeeper.build_args("simple_call", args_s[:])
+ args = simple_args(args_s)
result = []
def schedule(graph, inputcells):
result.append((graph, inputcells))
diff --git a/rpython/annotator/argument.py b/rpython/annotator/argument.py
--- a/rpython/annotator/argument.py
+++ b/rpython/annotator/argument.py
@@ -171,6 +171,12 @@
def rawshape(args):
return args._rawshape()
+def simple_args(args_s):
+ return ArgumentsForTranslation(list(args_s))
+
+def complex_args(args_s):
+ return ArgumentsForTranslation.fromshape(args_s[0].const,
+ list(args_s[1:]))
#
# ArgErr family of exceptions raised in case of argument mismatch.
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 ArgumentsForTranslation
+from rpython.annotator.argument import simple_args, complex_args
from rpython.rlib.objectmodel import r_dict, Symbolic
from rpython.tool.algo.unionfind import UnionFind
from rpython.rtyper import extregistry
@@ -538,7 +538,7 @@
del emulated_pbc_calls[other_key]
emulated_pbc_calls[unique_key] = pbc, args_s
- args = self.build_args("simple_call", args_s)
+ args = simple_args(args_s)
if callback is None:
emulated = True
else:
@@ -564,11 +564,9 @@
def build_args(self, op, args_s):
if op == "simple_call":
- return ArgumentsForTranslation(list(args_s))
+ return simple_args(args_s)
elif op == "call_args":
- return ArgumentsForTranslation.fromshape(
- args_s[0].const, # shape
- list(args_s[1:]))
+ 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,
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -15,6 +15,7 @@
from rpython.annotator import builtin
from rpython.annotator.binaryop import _clone ## XXX where to put this?
from rpython.annotator.model import AnnotatorError
+from rpython.annotator.argument import simple_args, complex_args
UNARY_OPERATIONS = set([oper.opname for oper in op.__dict__.values()
if oper.dispatch == 1])
@@ -133,10 +134,10 @@
return self # default unbound __get__ implementation
def simple_call(self, *args_s):
- return self.call(getbookkeeper().build_args("simple_call", args_s))
+ return self.call(simple_args(args_s))
def call_args(self, *args_s):
- return self.call(getbookkeeper().build_args("call_args", args_s))
+ return self.call(complex_args(args_s))
def call(self, args, implicit_init=False):
raise AnnotatorError("Cannot prove that the object is callable")
@@ -687,14 +688,14 @@
bk = getbookkeeper()
# record for calltables
bk.emulate_pbc_call(bk.position_key, s_iterable, [])
- return s_iterable.call(bk.build_args("simple_call", []))
+ return s_iterable.call(simple_args([]))
def next(self):
s_next = self._true_getattr('next')
bk = getbookkeeper()
# record for calltables
bk.emulate_pbc_call(bk.position_key, s_next, [])
- return s_next.call(bk.build_args("simple_call", []))
+ return s_next.call(simple_args([]))
class __extend__(SomeBuiltin):
def simple_call(self, *args):
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -2,6 +2,7 @@
from rpython.annotator import model as annmodel, description
from rpython.flowspace.model import Constant
+from rpython.annotator.argument import simple_args
from rpython.rtyper import rclass, callparse
from rpython.rtyper.annlowlevel import llstr
from rpython.rtyper.error import TyperError
@@ -290,7 +291,7 @@
bk = self.rtyper.annotator.bookkeeper
descs = list(s_pbc.descriptions)
vfcs = description.FunctionDesc.variant_for_call_site
- args = bk.build_args("simple_call", args_s)
+ args = simple_args(args_s)
shape, index = vfcs(bk, self.callfamily, descs, args, op)
funcdesc, = descs
row_of_one_graph = self.callfamily.calltables[shape][index]
More information about the pypy-commit
mailing list