Example #1
0
File: jit.py Project: charred/pypy
    def specialize_call(self, hop):
        from rpython.rtyper.lltypesystem import rclass, lltype

        classrepr = rclass.get_type_repr(hop.rtyper)

        hop.exception_cannot_occur()
        v_inst = hop.inputarg(hop.args_r[0], arg=0)
        v_cls = hop.inputarg(classrepr, arg=1)
        return hop.genop('jit_record_known_class', [v_inst, v_cls],
                         resulttype=lltype.Void)
Example #2
0
def rtype_instantiate(hop):
    hop.exception_cannot_occur()
    s_class = hop.args_s[0]
    assert isinstance(s_class, annmodel.SomePBC)
    if len(s_class.descriptions) != 1:
        # instantiate() on a variable class
        vtypeptr, = hop.inputargs(rclass.get_type_repr(hop.rtyper))
        r_class = hop.args_r[0]
        return r_class._instantiate_runtime_class(hop, vtypeptr,
                                                  hop.r_result.lowleveltype)
    classdef = s_class.any_description().getuniqueclassdef()
    return rclass.rtype_new_instance(hop.rtyper, classdef, hop.llops)
Example #3
0
def rtype_instantiate(hop):
    hop.exception_cannot_occur()
    s_class = hop.args_s[0]
    assert isinstance(s_class, annmodel.SomePBC)
    if len(s_class.descriptions) != 1:
        # instantiate() on a variable class
        vtypeptr, = hop.inputargs(rclass.get_type_repr(hop.rtyper))
        v_inst = hop.gendirectcall(ll_instantiate, vtypeptr)
        return hop.genop('cast_pointer', [v_inst],    # v_type implicit in r_result
                         resulttype = hop.r_result.lowleveltype)

    classdef = s_class.any_description().getuniqueclassdef()
    return rclass.rtype_new_instance(hop.rtyper, classdef, hop.llops)
Example #4
0
def rtype_instantiate(hop):
    hop.exception_cannot_occur()
    s_class = hop.args_s[0]
    assert isinstance(s_class, annmodel.SomePBC)
    if len(s_class.descriptions) != 1:
        # instantiate() on a variable class
        vtypeptr, = hop.inputargs(rclass.get_type_repr(hop.rtyper))
        v_inst = hop.gendirectcall(ll_instantiate, vtypeptr)
        return hop.genop(
            'cast_pointer',
            [v_inst],  # v_type implicit in r_result
            resulttype=hop.r_result.lowleveltype)

    classdef = s_class.any_description().getuniqueclassdef()
    return rclass.rtype_new_instance(hop.rtyper, classdef, hop.llops)