Author: Ronan Lamy <[email protected]>
Branch: reflowing
Changeset: r88662:85bd42cecd01
Date: 2016-11-25 04:22 +0000
http://bitbucket.org/pypy/pypy/changeset/85bd42cecd01/
Log: hg merge desc-specialize
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -439,6 +439,7 @@
space.wrap(msg))
return OperationError(exc, w_error)
[email protected](3)
def wrap_oserror2(space, e, w_filename=None, exception_name='w_OSError',
w_exception_class=None):
assert isinstance(e, OSError)
@@ -466,8 +467,8 @@
w_error = space.call_function(exc, space.wrap(errno),
space.wrap(msg))
return OperationError(exc, w_error)
-wrap_oserror2._annspecialcase_ = 'specialize:arg(3)'
[email protected](3)
def wrap_oserror(space, e, filename=None, exception_name='w_OSError',
w_exception_class=None):
if filename is not None:
@@ -478,7 +479,6 @@
return wrap_oserror2(space, e, None,
exception_name=exception_name,
w_exception_class=w_exception_class)
-wrap_oserror._annspecialcase_ = 'specialize:arg(3)'
def exception_from_saved_errno(space, w_type):
from rpython.rlib.rposix import get_saved_errno
diff --git a/pypy/module/_collections/interp_deque.py
b/pypy/module/_collections/interp_deque.py
--- a/pypy/module/_collections/interp_deque.py
+++ b/pypy/module/_collections/interp_deque.py
@@ -1,4 +1,5 @@
import sys
+from rpython.rlib.objectmodel import specialize
from pypy.interpreter import gateway
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef, make_weakref_descr
diff --git a/pypy/module/_pypyjson/targetjson.py
b/pypy/module/_pypyjson/targetjson.py
--- a/pypy/module/_pypyjson/targetjson.py
+++ b/pypy/module/_pypyjson/targetjson.py
@@ -4,6 +4,7 @@
sys.path.insert(0, str(ROOT))
import time
+from rpython.rlib.objectmodel import specialize
from pypy.interpreter.error import OperationError
from pypy.module._pypyjson.interp_decoder import loads
from rpython.rlib.objectmodel import specialize, dont_inline
diff --git a/pypy/module/cppyy/test/test_zjit.py
b/pypy/module/cppyy/test/test_zjit.py
--- a/pypy/module/cppyy/test/test_zjit.py
+++ b/pypy/module/cppyy/test/test_zjit.py
@@ -124,13 +124,13 @@
assert isinstance(w_obj, FakeFloat)
return w_obj.val
+ @specialize.arg(1)
def interp_w(self, RequiredClass, w_obj, can_be_None=False):
if can_be_None and w_obj is None:
return None
if not isinstance(w_obj, RequiredClass):
raise TypeError
return w_obj
- interp_w._annspecialcase_ = 'specialize:arg(1)'
def getarg_w(self, code, w_obj): # for retrieving buffers
return FakeBuffer(w_obj)
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -1614,9 +1614,8 @@
miniglobals = {'__name__': __name__, # for module name propagation
}
exec source.compile() in miniglobals
- call_external_function = miniglobals['cpy_call_external']
+ call_external_function = specialize.ll()(miniglobals['cpy_call_external'])
call_external_function._dont_inline_ = True
- call_external_function._annspecialcase_ = 'specialize:ll'
call_external_function._gctransformer_hint_close_stack_ = True
# don't inline, as a hack to guarantee that no GC pointer is alive
# anywhere in call_external_function
diff --git a/pypy/module/pyexpat/interp_pyexpat.py
b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -3,6 +3,7 @@
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
from pypy.interpreter.error import OperationError, oefmt
from rpython.rlib import rgc, jit
+from rpython.rlib.objectmodel import specialize
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rtyper.tool import rffi_platform
from rpython.translator.tool.cbuild import ExternalCompilationInfo
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -202,6 +202,7 @@
def newunicode(self, x):
return w_some_obj()
+ @specialize.argtype(1)
def wrap(self, x):
if not we_are_translated():
if isinstance(x, gateway.interp2app):
@@ -215,7 +216,6 @@
return w_some_obj()
self._wrap_not_rpython(x)
return w_some_obj()
- wrap._annspecialcase_ = "specialize:argtype(1)"
def _wrap_not_rpython(self, x):
"NOT_RPYTHON"
@@ -305,10 +305,10 @@
is_root(w_complex)
return 1.1, 2.2
+ @specialize.arg(1)
def allocate_instance(self, cls, w_subtype):
is_root(w_subtype)
return instantiate(cls)
- allocate_instance._annspecialcase_ = "specialize:arg(1)"
def decode_index(self, w_index_or_slice, seqlength):
is_root(w_index_or_slice)
diff --git a/pypy/objspace/fake/test/test_checkmodule.py
b/pypy/objspace/fake/test/test_checkmodule.py
--- a/pypy/objspace/fake/test/test_checkmodule.py
+++ b/pypy/objspace/fake/test/test_checkmodule.py
@@ -9,9 +9,9 @@
def make_checker():
check = []
+ @specialize.memo()
def see():
check.append(True)
- see._annspecialcase_ = 'specialize:memo'
return see, check
def test_wrap_interp2app():
diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -2,6 +2,7 @@
import sys
from rpython.rlib import jit
+from rpython.rlib.objectmodel import specialize
from rpython.rlib.rarithmetic import INT_MAX
from rpython.rlib.rfloat import DTSF_ALT, formatd, isnan, isinf
from rpython.rlib.rstring import StringBuilder, UnicodeBuilder
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -2,6 +2,7 @@
import types
from collections import defaultdict
+from contextlib import contextmanager
from rpython.tool.ansi_print import AnsiLogger
from rpython.tool.pairtype import pair
@@ -84,22 +85,17 @@
annmodel.TLS.check_str_without_nul = (
self.translator.config.translation.check_str_without_nul)
- flowgraph, inputs_s = self.get_call_parameters(function, args_s,
policy)
+ with self.using_policy(policy):
+ flowgraph, inputs_s = self.get_call_parameters(function, args_s)
if main_entry_point:
self.translator.entry_point_graph = flowgraph
return self.build_graph_types(flowgraph, inputs_s,
complete_now=complete_now)
- def get_call_parameters(self, function, args_s, policy):
- desc = self.bookkeeper.getdesc(function)
- prevpolicy = self.policy
- self.policy = policy
- self.bookkeeper.enter(None)
- try:
+ def get_call_parameters(self, function, args_s):
+ with self.bookkeeper.at_position(None):
+ desc = self.bookkeeper.getdesc(function)
return desc.get_call_parameters(args_s)
- finally:
- self.bookkeeper.leave()
- self.policy = prevpolicy
def annotate_helper(self, function, args_s, policy=None):
if policy is None:
@@ -108,21 +104,29 @@
# XXX hack
annmodel.TLS.check_str_without_nul = (
self.translator.config.translation.check_str_without_nul)
- graph, inputcells = self.get_call_parameters(function, args_s, policy)
- self.build_graph_types(graph, inputcells, complete_now=False)
- self.complete_helpers(policy)
+ with self.using_policy(policy):
+ graph, inputcells = self.get_call_parameters(function, args_s)
+ self.build_graph_types(graph, inputcells, complete_now=False)
+ self.complete_helpers()
return graph
- def complete_helpers(self, policy):
- saved = self.policy, self.added_blocks
- self.policy = policy
+ def complete_helpers(self):
+ saved = self.added_blocks
+ self.added_blocks = {}
try:
- self.added_blocks = {}
self.complete()
# invoke annotation simplifications for the new blocks
self.simplify(block_subset=self.added_blocks)
finally:
- self.policy, self.added_blocks = saved
+ self.added_blocks = saved
+
+ @contextmanager
+ def using_policy(self, policy):
+ """A context manager that temporarily replaces the annotator policy"""
+ old_policy = self.policy
+ self.policy = policy
+ yield
+ self.policy = old_policy
def build_graph_types(self, flowgraph, inputcells, complete_now=True):
checkgraph(flowgraph)
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -9,6 +9,7 @@
from collections import OrderedDict
from rpython.flowspace.model import Constant
+from rpython.flowspace.bytecode import cpython_code_signature
from rpython.annotator.model import (
SomeOrderedDict, SomeString, SomeChar, SomeFloat, unionof, SomeInstance,
SomeDict, SomeBuiltin, SomePBC, SomeInteger, TLS, SomeUnicodeCodePoint,
@@ -21,6 +22,7 @@
from rpython.annotator import description
from rpython.annotator.signature import annotationoftype
from rpython.annotator.argument import simple_args
+from rpython.annotator.specialize import memo
from rpython.rlib.objectmodel import r_dict, r_ordereddict, Symbolic
from rpython.tool.algo.unionfind import UnionFind
from rpython.rtyper import extregistry
@@ -358,7 +360,7 @@
return self.descs[obj_key]
except KeyError:
if isinstance(pyobj, types.FunctionType):
- result = description.FunctionDesc(self, pyobj)
+ result = self.newfuncdesc(pyobj)
elif isinstance(pyobj, (type, types.ClassType)):
if pyobj is object:
raise Exception("ClassDesc for object not supported")
@@ -403,6 +405,23 @@
self.descs[obj_key] = result
return result
+ def newfuncdesc(self, pyfunc):
+ name = pyfunc.__name__
+ if hasattr(pyfunc, '_generator_next_method_of_'):
+ from rpython.flowspace.argument import Signature
+ signature = Signature(['entry']) # haaaaaack
+ defaults = ()
+ else:
+ signature = cpython_code_signature(pyfunc.func_code)
+ defaults = pyfunc.func_defaults
+ # get the specializer based on the tag of the 'pyobj'
+ # (if any), according to the current policy
+ tag = getattr(pyfunc, '_annspecialcase_', None)
+ specializer = self.annotator.policy.get_specializer(tag)
+ if specializer is memo:
+ return description.MemoDesc(self, pyfunc, name, signature,
defaults, specializer)
+ return description.FunctionDesc(self, pyfunc, name, signature,
defaults, specializer)
+
def getfrozen(self, pyobj):
return description.FrozenDesc(self, pyobj)
diff --git a/rpython/annotator/classdesc.py b/rpython/annotator/classdesc.py
--- a/rpython/annotator/classdesc.py
+++ b/rpython/annotator/classdesc.py
@@ -608,7 +608,7 @@
if mixin:
# make a new copy of the FunctionDesc for this class,
# but don't specialize further for all subclasses
- funcdesc = FunctionDesc(self.bookkeeper, value)
+ funcdesc = self.bookkeeper.newfuncdesc(value)
self.classdict[name] = funcdesc
return
# NB. if value is, say, AssertionError.__init__, then we
diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py
--- a/rpython/annotator/description.py
+++ b/rpython/annotator/description.py
@@ -3,11 +3,10 @@
from rpython.annotator.signature import (
enforce_signature_args, enforce_signature_return, finish_type)
from rpython.flowspace.model import FunctionGraph
-from rpython.flowspace.bytecode import cpython_code_signature
from rpython.annotator.argument import rawshape, ArgErr, simple_args
from rpython.tool.sourcetools import valid_identifier
from rpython.tool.pairtype import extendabletype
-from rpython.annotator.model import AnnotatorError, s_ImpossibleValue
+from rpython.annotator.model import AnnotatorError, s_ImpossibleValue, unionof
class CallFamily(object):
"""A family of Desc objects that could be called from common call sites.
@@ -117,7 +116,6 @@
self.s_value = s_ImpossibleValue # union of possible values
def update(self, other):
- from rpython.annotator.model import unionof
self.descs.update(other.descs)
self.read_locations.update(other.read_locations)
self.s_value = unionof(self.s_value, other.s_value)
@@ -192,24 +190,12 @@
class FunctionDesc(Desc):
knowntype = types.FunctionType
- def __init__(self, bookkeeper, pyobj=None,
- name=None, signature=None, defaults=None,
+ def __init__(self, bookkeeper, pyobj, name, signature, defaults,
specializer=None):
super(FunctionDesc, self).__init__(bookkeeper, pyobj)
- if name is None:
- name = pyobj.func_name
- if signature is None:
- if hasattr(pyobj, '_generator_next_method_of_'):
- from rpython.flowspace.argument import Signature
- signature = Signature(['entry']) # haaaaaack
- defaults = ()
- else:
- signature = cpython_code_signature(pyobj.func_code)
- if defaults is None:
- defaults = pyobj.func_defaults
self.name = name
self.signature = signature
- self.defaults = defaults or ()
+ self.defaults = defaults if defaults is not None else ()
# 'specializer' is a function with the following signature:
# specializer(funcdesc, args_s) => graph
# or => s_result (overridden/memo
cases)
@@ -288,12 +274,39 @@
getattr(self.bookkeeper, "position_key", None) is not None):
_, block, i = self.bookkeeper.position_key
op = block.operations[i]
- if self.specializer is None:
- # get the specializer based on the tag of the 'pyobj'
- # (if any), according to the current policy
- tag = getattr(self.pyobj, '_annspecialcase_', None)
- policy = self.bookkeeper.annotator.policy
- self.specializer = policy.get_specializer(tag)
+ self.normalize_args(inputcells)
+ if getattr(self.pyobj, '_annspecialcase_',
'').endswith("call_location"):
+ return self.specializer(self, inputcells, op)
+ else:
+ return self.specializer(self, inputcells)
+
+ def pycall(self, whence, args, v_result, op=None):
+ inputcells = self.parse_arguments(args)
+ graph = self.specialize(inputcells, op)
+ 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)
+ annotator = self.bookkeeper.annotator
+ result = annotator.recursivecall(graph, whence, inputcells, v_result)
+ signature = getattr(self.pyobj, '_signature_', None)
+ if signature:
+ sigresult = enforce_signature_return(self, signature[1], result)
+ if sigresult is not None:
+ annotator.addpendingblock(
+ graph, graph.returnblock, [sigresult])
+ result = sigresult
+ return result
+
+ def normalize_args(self, inputs_s):
+ """
+ Canonicalize argument annotations into the exact parameter
+ annotations of a specific specialized graph.
+
+ Note: this method has no return value but mutates its argument instead.
+ """
enforceargs = getattr(self.pyobj, '_annenforceargs_', None)
signature = getattr(self.pyobj, '_signature_', None)
if enforceargs and signature:
@@ -304,34 +317,9 @@
from rpython.annotator.signature import Sig
enforceargs = Sig(*enforceargs)
self.pyobj._annenforceargs_ = enforceargs
- enforceargs(self, inputcells) # can modify inputcells in-place
+ enforceargs(self, inputs_s) # can modify inputs_s in-place
if signature:
- enforce_signature_args(self, signature[0], inputcells) # mutates
inputcells
- if getattr(self.pyobj, '_annspecialcase_',
'').endswith("call_location"):
- return self.specializer(self, inputcells, op)
- else:
- return self.specializer(self, inputcells)
-
- def pycall(self, whence, args, v_result, op=None):
- inputcells = self.parse_arguments(args)
- result = self.specialize(inputcells, op)
- if isinstance(result, FunctionGraph):
- graph = result # common case
- annotator = self.bookkeeper.annotator
- # 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)
- result = annotator.recursivecall(graph, whence, inputcells,
v_result)
- signature = getattr(self.pyobj, '_signature_', None)
- if signature:
- sigresult = enforce_signature_return(self, signature[1],
result)
- if sigresult is not None:
- annotator.addpendingblock(
- graph, graph.returnblock, [sigresult])
- result = sigresult
- return result
+ enforce_signature_args(self, signature[0], inputs_s) # mutates
inputs_s
def get_graph(self, args, op):
inputs_s = self.parse_arguments(args)
@@ -400,6 +388,15 @@
return s_sigs
+class MemoDesc(FunctionDesc):
+ def pycall(self, whence, args, s_previous_result, op=None):
+ inputcells = self.parse_arguments(args)
+ s_result = self.specialize(inputcells, op)
+ if isinstance(s_result, FunctionGraph):
+ s_result = s_result.getreturnvar().annotation
+ return s_result
+
+
class MethodDesc(Desc):
knowntype = types.MethodType
diff --git a/rpython/annotator/specialize.py b/rpython/annotator/specialize.py
--- a/rpython/annotator/specialize.py
+++ b/rpython/annotator/specialize.py
@@ -3,11 +3,13 @@
from rpython.tool.sourcetools import func_with_new_name
from rpython.tool.algo.unionfind import UnionFind
-from rpython.flowspace.model import Block, Link, Variable, SpaceOperation
+from rpython.flowspace.model import Block, Link, Variable
from rpython.flowspace.model import checkgraph
from rpython.flowspace.operation import op
from rpython.annotator import model as annmodel
from rpython.flowspace.argument import Signature
+from rpython.annotator.model import SomePBC, SomeImpossibleValue, SomeBool
+from rpython.annotator.model import unionof
def flatten_star_args(funcdesc, args_s):
argnames, vararg, kwarg = funcdesc.signature
@@ -127,7 +129,6 @@
def finish(self):
if self.do_not_process:
return
- from rpython.annotator.model import unionof
assert self.graph is None, "MemoTable already finished"
# list of which argument positions can take more than one value
example_args, example_value = self.table.iteritems().next()
@@ -246,34 +247,36 @@
args_s.append(unionof(*values_s))
annotator.addpendinggraph(self.graph, args_s)
+def all_values(s):
+ """Return the exhaustive list of possible values matching annotation `s`.
-def memo(funcdesc, arglist_s):
- from rpython.annotator.model import SomePBC, SomeImpossibleValue, SomeBool
- from rpython.annotator.model import unionof
+ Raises `AnnotatorError` if no such (reasonably small) finite list exists.
+ """
+ if s.is_constant():
+ return [s.const]
+ elif isinstance(s, SomePBC):
+ values = []
+ assert not s.can_be_None, "memo call: cannot mix None and PBCs"
+ for desc in s.descriptions:
+ if desc.pyobj is None:
+ raise annmodel.AnnotatorError(
+ "memo call with a class or PBC that has no "
+ "corresponding Python object (%r)" % (desc,))
+ values.append(desc.pyobj)
+ return values
+ elif isinstance(s, SomeImpossibleValue):
+ return []
+ elif isinstance(s, SomeBool):
+ return [False, True]
+ else:
+ raise annmodel.AnnotatorError("memo call: argument must be a class "
+ "or a frozen PBC, got %r" % (s,))
+
+def memo(funcdesc, args_s):
# call the function now, and collect possible results
- argvalues = []
- for s in arglist_s:
- if s.is_constant():
- values = [s.const]
- elif isinstance(s, SomePBC):
- values = []
- assert not s.can_be_None, "memo call: cannot mix None and PBCs"
- for desc in s.descriptions:
- if desc.pyobj is None:
- raise annmodel.AnnotatorError(
- "memo call with a class or PBC that has no "
- "corresponding Python object (%r)" % (desc,))
- values.append(desc.pyobj)
- elif isinstance(s, SomeImpossibleValue):
- return s # we will probably get more possible args later
- elif isinstance(s, SomeBool):
- values = [False, True]
- else:
- raise annmodel.AnnotatorError("memo call: argument must be a class
"
- "or a frozen PBC, got %r" % (s,))
- argvalues.append(values)
+
# the list of all possible tuples of arguments to give to the memo function
- possiblevalues = cartesian_product(argvalues)
+ possiblevalues = cartesian_product([all_values(s_arg) for s_arg in args_s])
# a MemoTable factory -- one MemoTable per family of arguments that can
# be called together, merged via a UnionFind.
diff --git a/rpython/rtyper/annlowlevel.py b/rpython/rtyper/annlowlevel.py
--- a/rpython/rtyper/annlowlevel.py
+++ b/rpython/rtyper/annlowlevel.py
@@ -138,11 +138,12 @@
# get the graph of the mix-level helper ll_function and prepare it for
# being annotated. Annotation and RTyping should be done in a single
shot
# at the end with finish().
- graph, args_s = self.rtyper.annotator.get_call_parameters(
- ll_function, args_s, policy = self.policy)
+ ann = self.rtyper.annotator
+ with ann.using_policy(self.policy):
+ graph, args_s = ann.get_call_parameters(ll_function, args_s)
for v_arg, s_arg in zip(graph.getargs(), args_s):
- self.rtyper.annotator.setbinding(v_arg, s_arg)
- self.rtyper.annotator.setbinding(graph.getreturnvar(), s_result)
+ ann.setbinding(v_arg, s_arg)
+ ann.setbinding(graph.getreturnvar(), s_result)
#self.rtyper.annotator.annotated[graph.returnblock] = graph
self.pending.append((ll_function, graph, args_s, s_result))
return graph
@@ -224,16 +225,17 @@
bk = ann.bookkeeper
translator = ann.translator
original_graph_count = len(translator.graphs)
- for ll_function, graph, args_s, s_result in self.pending:
- # mark the return block as already annotated, because the return
var
- # annotation was forced in getgraph() above. This prevents
temporary
- # less general values reaching the return block from crashing the
- # annotator (on the assert-that-new-binding-is-not-less-general).
- ann.annotated[graph.returnblock] = graph
- s_function = bk.immutablevalue(ll_function)
- bk.emulate_pbc_call(graph, s_function, args_s)
- self.newgraphs.add(graph)
- ann.complete_helpers(self.policy)
+ with ann.using_policy(self.policy):
+ for ll_function, graph, args_s, s_result in self.pending:
+ # mark the return block as already annotated, because the
return var
+ # annotation was forced in getgraph() above. This prevents
temporary
+ # less general values reaching the return block from crashing
the
+ # annotator (on the
assert-that-new-binding-is-not-less-general).
+ ann.annotated[graph.returnblock] = graph
+ s_function = bk.immutablevalue(ll_function)
+ bk.emulate_pbc_call(graph, s_function, args_s)
+ self.newgraphs.add(graph)
+ ann.complete_helpers()
for ll_function, graph, args_s, s_result in self.pending:
s_real_result = ann.binding(graph.getreturnvar())
if s_real_result != s_result:
diff --git a/rpython/rtyper/lltypesystem/llmemory.py
b/rpython/rtyper/lltypesystem/llmemory.py
--- a/rpython/rtyper/lltypesystem/llmemory.py
+++ b/rpython/rtyper/lltypesystem/llmemory.py
@@ -384,7 +384,6 @@
def _sizeof_none(TYPE):
assert not TYPE._is_varsize()
return ItemOffset(TYPE)
-_sizeof_none._annspecialcase_ = 'specialize:memo'
@specialize.memo()
def _internal_array_field(TYPE):
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -362,9 +362,9 @@
def get_concrete_llfn(self, s_pbc, args_s, op):
bk = self.rtyper.annotator.bookkeeper
funcdesc, = s_pbc.descriptions
- args = simple_args(args_s)
with bk.at_position(None):
- graph = funcdesc.get_graph(args, op)
+ argspec = simple_args(args_s)
+ graph = funcdesc.get_graph(argspec, op)
llfn = self.rtyper.getcallable(graph)
return inputconst(typeOf(llfn), llfn)
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -846,28 +846,29 @@
rtyper = self.rtyper
args_s = []
newargs_v = []
- for v in args_v:
- if v.concretetype is Void:
- s_value = rtyper.annotation(v)
- if s_value is None:
- s_value = annmodel.s_None
- if not s_value.is_constant():
- raise TyperError("non-constant variable of type Void")
- if not isinstance(s_value, (annmodel.SomePBC,
annmodel.SomeNone)):
- raise TyperError("non-PBC Void argument: %r", (s_value,))
- args_s.append(s_value)
- else:
- args_s.append(lltype_to_annotation(v.concretetype))
- newargs_v.append(v)
+ with rtyper.annotator.using_policy(rtyper.lowlevel_ann_policy):
+ for v in args_v:
+ if v.concretetype is Void:
+ s_value = rtyper.annotation(v)
+ if s_value is None:
+ s_value = annmodel.s_None
+ if not s_value.is_constant():
+ raise TyperError("non-constant variable of type Void")
+ if not isinstance(s_value, (annmodel.SomePBC,
annmodel.SomeNone)):
+ raise TyperError("non-PBC Void argument: %r",
(s_value,))
+ args_s.append(s_value)
+ else:
+ args_s.append(lltype_to_annotation(v.concretetype))
+ newargs_v.append(v)
- self.rtyper.call_all_setups() # compute ForwardReferences now
+ self.rtyper.call_all_setups() # compute ForwardReferences now
- # hack for bound methods
- if hasattr(ll_function, 'im_func'):
- bk = rtyper.annotator.bookkeeper
- args_s.insert(0, bk.immutablevalue(ll_function.im_self))
- newargs_v.insert(0, inputconst(Void, ll_function.im_self))
- ll_function = ll_function.im_func
+ # hack for bound methods
+ if hasattr(ll_function, 'im_func'):
+ bk = rtyper.annotator.bookkeeper
+ args_s.insert(0, bk.immutablevalue(ll_function.im_self))
+ newargs_v.insert(0, inputconst(Void, ll_function.im_self))
+ ll_function = ll_function.im_func
graph = annotate_lowlevel_helper(rtyper.annotator, ll_function, args_s,
rtyper.lowlevel_ann_policy)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit