def lowlevelspecialize(funcdesc, args_s, key_for_args): args_s, key1, ignored, builder = flatten_star_args(funcdesc, args_s) key = [] new_args_s = [] for i, s_obj in enumerate(args_s): if i in key_for_args: key.append(key_for_args[i]) new_args_s.append(s_obj) elif isinstance(s_obj, annmodel.SomePBC): assert s_obj.is_constant( ), "ambiguous low-level helper specialization" key.append(KeyComp(s_obj.const)) new_args_s.append(s_obj) else: new_args_s.append(annmodel.not_const(s_obj)) try: key.append(annmodel.annotation_to_lltype(s_obj)) except ValueError: # passing non-low-level types to a ll_* function is allowed # for module/ll_* key.append(s_obj.__class__) key = (tuple(key), ) if key1 is not None: key += (key1, ) flowgraph = funcdesc.cachedgraph(key, builder=builder) args_s[:] = new_args_s return flowgraph
def lowlevelspecialize(funcdesc, args_s, key_for_args): args_s, key1, ignored, builder = flatten_star_args(funcdesc, args_s) key = [] new_args_s = [] for i, s_obj in enumerate(args_s): if i in key_for_args: key.append(key_for_args[i]) new_args_s.append(s_obj) elif isinstance(s_obj, annmodel.SomePBC): assert s_obj.is_constant(), "ambiguous low-level helper specialization" key.append(KeyComp(s_obj.const)) new_args_s.append(s_obj) else: new_args_s.append(annmodel.not_const(s_obj)) try: key.append(annmodel.annotation_to_lltype(s_obj)) except ValueError: # passing non-low-level types to a ll_* function is allowed # for module/ll_* key.append(s_obj.__class__) key = (tuple(key),) if key1 is not None: key += (key1,) flowgraph = funcdesc.cachedgraph(key, builder=builder) args_s[:] = new_args_s return flowgraph
def compute_result_annotation(self, s_x, **kwds_s): from pypy.annotation import model as annmodel s_x = annmodel.not_const(s_x) if 's_access_directly' in kwds_s: if isinstance(s_x, annmodel.SomeInstance): from pypy.objspace.flow.model import Constant classdesc = s_x.classdef.classdesc virtualizable = classdesc.read_attribute( '_virtualizable_', Constant(False)).value if virtualizable: flags = s_x.flags.copy() flags['access_directly'] = True s_x = annmodel.SomeInstance(s_x.classdef, s_x.can_be_None, flags) return s_x
def default_specialize(funcdesc, args_s): key = [] new_args_s = [] for s_obj in args_s: if isinstance(s_obj, annmodel.SomePBC): assert s_obj.is_constant(), "ambiguous low-level helper specialization" key.append(KeyComp(s_obj.const)) new_args_s.append(s_obj) else: new_args_s.append(annmodel.not_const(s_obj)) try: key.append(annmodel.annotation_to_lltype(s_obj)) except ValueError: # passing non-low-level types to a ll_* function is allowed # for module/ll_* key.append(s_obj.__class__) flowgraph = funcdesc.cachedgraph(tuple(key)) args_s[:] = new_args_s return flowgraph
def compute_result_annotation(self, s_x, **kwds_s): from pypy.annotation import model as annmodel s_x = annmodel.not_const(s_x) access_directly = 's_access_directly' in kwds_s fresh_virtualizable = 's_fresh_virtualizable' in kwds_s if access_directly or fresh_virtualizable: assert access_directly, "lone fresh_virtualizable hint" if isinstance(s_x, annmodel.SomeInstance): from pypy.objspace.flow.model import Constant classdesc = s_x.classdef.classdesc virtualizable = classdesc.read_attribute( '_virtualizable2_', Constant(None)).value if virtualizable is not None: flags = s_x.flags.copy() flags['access_directly'] = True if fresh_virtualizable: flags['fresh_virtualizable'] = True s_x = annmodel.SomeInstance(s_x.classdef, s_x.can_be_None, flags) return s_x
def compute_result_annotation(self, s_x, **kwds_s): from pypy.annotation import model as annmodel s_x = annmodel.not_const(s_x) access_directly = "s_access_directly" in kwds_s fresh_virtualizable = "s_fresh_virtualizable" in kwds_s if access_directly or fresh_virtualizable: assert access_directly, "lone fresh_virtualizable hint" if isinstance(s_x, annmodel.SomeInstance): from pypy.objspace.flow.model import Constant classdesc = s_x.classdef.classdesc virtualizable = classdesc.read_attribute("_virtualizable2_", Constant(None)).value if virtualizable is not None: flags = s_x.flags.copy() flags["access_directly"] = True if fresh_virtualizable: flags["fresh_virtualizable"] = True s_x = annmodel.SomeInstance(s_x.classdef, s_x.can_be_None, flags) return s_x
def compute_result_annotation(self, s_x, **kwds_s): from pypy.annotation import model as annmodel s_x = annmodel.not_const(s_x) return s_x