Exemple #1
0
def do_getfield_raw(cpu, _, structbox, fielddescr):
    check_descr(fielddescr)
    struct = structbox.getint()
    if fielddescr.is_pointer_field():
        return BoxPtr(cpu.bh_getfield_raw_r(struct, fielddescr))
    elif fielddescr.is_float_field():
        return BoxFloat(cpu.bh_getfield_raw_f(struct, fielddescr))
    else:
        return BoxInt(cpu.bh_getfield_raw_i(struct, fielddescr))
Exemple #2
0
def do_getfield_raw(cpu, _, structbox, fielddescr):
    check_descr(fielddescr)
    struct = structbox.getint()
    if fielddescr.is_pointer_field():
        return BoxPtr(cpu.bh_getfield_raw_r(struct, fielddescr))
    elif fielddescr.is_float_field():
        return BoxFloat(cpu.bh_getfield_raw_f(struct, fielddescr))
    else:
        return BoxInt(cpu.bh_getfield_raw_i(struct, fielddescr))
Exemple #3
0
def execute(cpu, metainterp, opnum, descr, *argboxes):
    # only for opnums with a fixed arity
    num_args = len(argboxes)
    withdescr = has_descr(opnum)
    if withdescr:
        check_descr(descr)
        argboxes = argboxes + (descr, )
    else:
        assert descr is None
    func = get_execute_function(opnum, num_args, withdescr)
    return func(cpu, metainterp, *argboxes)  # note that the 'argboxes' tuple
Exemple #4
0
def execute(cpu, metainterp, opnum, descr, *argboxes):
    # only for opnums with a fixed arity
    num_args = len(argboxes)
    withdescr = has_descr(opnum)
    if withdescr:
        check_descr(descr)
        argboxes = argboxes + (descr,)
    else:
        assert descr is None
    func = get_execute_function(opnum, num_args, withdescr)
    return func(cpu, metainterp, *argboxes)  # note that the 'argboxes' tuple
Exemple #5
0
def _execute_arglist(cpu, metainterp, opnum, argboxes, descr=None):
    arity = resoperation.oparity[opnum]
    assert arity == -1 or len(argboxes) == arity
    if resoperation.opwithdescr[opnum]:
        check_descr(descr)
        if arity == -1:
            func = get_execute_function(opnum, -1, True)
            if func:
                return func(cpu, metainterp, argboxes, descr)
        if arity == 0:
            func = get_execute_function(opnum, 0, True)
            if func:
                return func(cpu, metainterp, descr)
        if arity == 1:
            func = get_execute_function(opnum, 1, True)
            if func:
                return func(cpu, metainterp, argboxes[0], descr)
        if arity == 2:
            func = get_execute_function(opnum, 2, True)
            if func:
                return func(cpu, metainterp, argboxes[0], argboxes[1], descr)
        if arity == 3:
            func = get_execute_function(opnum, 3, True)
            if func:
                return func(cpu, metainterp, argboxes[0], argboxes[1],
                            argboxes[2], descr)
    else:
        assert descr is None
        if arity == 1:
            func = get_execute_function(opnum, 1, False)
            if func:
                return func(cpu, metainterp, argboxes[0])
        if arity == 2:
            func = get_execute_function(opnum, 2, False)
            if func:
                return func(cpu, metainterp, argboxes[0], argboxes[1])
        if arity == 3:
            func = get_execute_function(opnum, 3, False)
            if func:
                return func(cpu, metainterp, argboxes[0], argboxes[1],
                            argboxes[2])
        if arity == 5:  # copystrcontent, copyunicodecontent
            func = get_execute_function(opnum, 5, False)
            if func:
                return func(cpu, metainterp, argboxes[0], argboxes[1],
                            argboxes[2], argboxes[3], argboxes[4])
    raise NotImplementedError
Exemple #6
0
def _execute_arglist(cpu, metainterp, opnum, argboxes, descr=None):
    arity = resoperation.oparity[opnum]    
    assert arity == -1 or len(argboxes) == arity
    if resoperation.opwithdescr[opnum]:
        check_descr(descr)
        if arity == -1:
            func = get_execute_function(opnum, -1, True)
            if func:
                return func(cpu, metainterp, argboxes, descr)
        if arity == 0:
            func = get_execute_function(opnum, 0, True)
            if func:
                return func(cpu, metainterp, descr)
        if arity == 1:
            func = get_execute_function(opnum, 1, True)
            if func:
                return func(cpu, metainterp, argboxes[0], descr)
        if arity == 2:
            func = get_execute_function(opnum, 2, True)
            if func:
                return func(cpu, metainterp, argboxes[0], argboxes[1], descr)
        if arity == 3:
            func = get_execute_function(opnum, 3, True)
            if func:
                return func(cpu, metainterp, argboxes[0], argboxes[1],
                            argboxes[2], descr)
    else:
        assert descr is None
        if arity == 1:
            func = get_execute_function(opnum, 1, False)
            if func:
                return func(cpu, metainterp, argboxes[0])
        if arity == 2:
            func = get_execute_function(opnum, 2, False)
            if func:
                return func(cpu, metainterp, argboxes[0], argboxes[1])
        if arity == 3:
            func = get_execute_function(opnum, 3, False)
            if func:
                return func(cpu, metainterp, argboxes[0], argboxes[1],
                            argboxes[2])
        if arity == 5:    # copystrcontent, copyunicodecontent
            func = get_execute_function(opnum, 5, False)
            if func:
                return func(cpu, metainterp, argboxes[0], argboxes[1],
                        argboxes[2], argboxes[3], argboxes[4])
    raise NotImplementedError
Exemple #7
0
def execute_varargs(cpu, metainterp, opnum, argboxes, descr):
    # only for opnums with a variable arity (calls, typically)
    check_descr(descr)
    func = get_execute_function(opnum, -1, True)
    return func(cpu, metainterp, argboxes, descr)
Exemple #8
0
def do_getfield_raw_r(cpu, _, structbox, fielddescr):
    check_descr(fielddescr)
    struct = structbox.getint()
    return cpu.bh_getfield_raw_r(struct, fielddescr)
Exemple #9
0
 def _check_descr(self, descr):
     if not we_are_translated() and getattr(descr, 'I_am_a_descr', False):
         return  # needed for the mock case in oparser_model
     from rpython.jit.metainterp.history import check_descr
     check_descr(descr)
Exemple #10
0
def execute_varargs(cpu, metainterp, opnum, argboxes, descr):
    # only for opnums with a variable arity (calls, typically)
    check_descr(descr)
    func = get_execute_function(opnum, -1, True)
    return func(cpu, metainterp, argboxes, descr)
Exemple #11
0
def do_getfield_raw_r(cpu, _, structbox, fielddescr):
    check_descr(fielddescr)
    struct = structbox.getint()
    return cpu.bh_getfield_raw_r(struct, fielddescr)
Exemple #12
0
 def _check_descr(self, descr):
     if not we_are_translated() and getattr(descr, 'I_am_a_descr', False):
         return # needed for the mock case in oparser_model
     from rpython.jit.metainterp.history import check_descr
     check_descr(descr)