예제 #1
0
파일: warmspot.py 프로젝트: charred/pypy
 def handle_jitexception(e):
     # XXX the bulk of this function is mostly a copy-paste from above
     try:
         raise e
     except jitexc.ContinueRunningNormally, e:
         args = ()
         for ARGTYPE, attrname, count in portalfunc_ARGS:
             x = getattr(e, attrname)[count]
             x = specialize_value(ARGTYPE, x)
             args = args + (x,)
         result = ll_portal_runner(*args)
         if result_kind != 'void':
             result = unspecialize_value(result)
         return result
예제 #2
0
 def handle_jitexception(e):
     # XXX the bulk of this function is mostly a copy-paste from above
     try:
         raise e
     except jitexc.ContinueRunningNormally, e:
         args = ()
         for ARGTYPE, attrname, count in portalfunc_ARGS:
             x = getattr(e, attrname)[count]
             x = specialize_value(ARGTYPE, x)
             args = args + (x, )
         result = ll_portal_runner(*args)
         if result_kind != 'void':
             result = unspecialize_value(result)
         return result
예제 #3
0
 def handle_jitexception(e):
     # XXX there are too many exceptions all around...
     while True:
         if isinstance(e, EnterJitAssembler):
             try:
                 return e.execute()
             except jitexc.JitException as e:
                 continue
         #
         if isinstance(e, jitexc.ContinueRunningNormally):
             args = ()
             for ARGTYPE, attrname, count in portalfunc_ARGS:
                 x = getattr(e, attrname)[count]
                 x = specialize_value(ARGTYPE, x)
                 args = args + (x, )
             try:
                 result = support.maybe_on_top_of_llinterp(
                     rtyper, portal_ptr)(*args)
             except jitexc.JitException as e:
                 continue
             if result_kind != 'void':
                 result = unspecialize_value(result)
             return result
         #
         if result_kind == 'void':
             if isinstance(e, jitexc.DoneWithThisFrameVoid):
                 return None
         if result_kind == 'int':
             if isinstance(e, jitexc.DoneWithThisFrameInt):
                 return e.result
         if result_kind == 'ref':
             if isinstance(e, jitexc.DoneWithThisFrameRef):
                 return e.result
         if result_kind == 'float':
             if isinstance(e, jitexc.DoneWithThisFrameFloat):
                 return e.result
         #
         if isinstance(e, jitexc.ExitFrameWithExceptionRef):
             value = ts.cast_to_baseclass(e.value)
             if not we_are_translated():
                 raise LLException(ts.get_typeptr(value), value)
             else:
                 value = cast_base_ptr_to_instance(Exception, value)
                 assert value is not None
                 raise value
         #
         raise AssertionError("all cases should have been handled")
예제 #4
0
파일: warmspot.py 프로젝트: mozillazg/pypy
 def handle_jitexception(e):
     # XXX there are too many exceptions all around...
     while True:
         if isinstance(e, EnterJitAssembler):
             try:
                 return e.execute()
             except jitexc.JitException as e:
                 continue
         #
         if isinstance(e, jitexc.ContinueRunningNormally):
             args = ()
             for ARGTYPE, attrname, count in portalfunc_ARGS:
                 x = getattr(e, attrname)[count]
                 x = specialize_value(ARGTYPE, x)
                 args = args + (x,)
             try:
                 result = support.maybe_on_top_of_llinterp(rtyper,
                                                     portal_ptr)(*args)
             except jitexc.JitException as e:
                 continue
             if result_kind != 'void':
                 result = unspecialize_value(result)
             return result
         #
         if result_kind == 'void':
             if isinstance(e, jitexc.DoneWithThisFrameVoid):
                 return None
         if result_kind == 'int':
             if isinstance(e, jitexc.DoneWithThisFrameInt):
                 return e.result
         if result_kind == 'ref':
             if isinstance(e, jitexc.DoneWithThisFrameRef):
                 return e.result
         if result_kind == 'float':
             if isinstance(e, jitexc.DoneWithThisFrameFloat):
                 return e.result
         #
         if isinstance(e, jitexc.ExitFrameWithExceptionRef):
             value = ts.cast_to_baseclass(e.value)
             if not we_are_translated():
                 raise LLException(ts.get_typeptr(value), value)
             else:
                 value = cast_base_ptr_to_instance(Exception, value)
                 assert value is not None
                 raise value
         #
         raise AssertionError("all cases should have been handled")
예제 #5
0
def _run_with_machine_code(testself, args):
    metainterp = testself.metainterp
    num_green_args = metainterp.jitdriver_sd.num_green_args
    procedure_token = metainterp.get_procedure_token(args[:num_green_args])
    # a loop was successfully created by _run_with_pyjitpl(); call it
    cpu = metainterp.cpu
    args1 = []
    for i in range(len(args) - num_green_args):
        x = args[num_green_args + i]
        args1.append(unspecialize_value(x))
    deadframe = cpu.execute_token(procedure_token, *args1)
    faildescr = cpu.get_latest_descr(deadframe)
    assert faildescr.__class__.__name__.startswith('DoneWithThisFrameDescr')
    if metainterp.jitdriver_sd.result_type == history.INT:
        return deadframe, cpu.get_int_value(deadframe, 0)
    elif metainterp.jitdriver_sd.result_type == history.REF:
        return deadframe, cpu.get_ref_value(deadframe, 0)
    elif metainterp.jitdriver_sd.result_type == history.FLOAT:
        return deadframe, cpu.get_float_value(deadframe, 0)
    else:
        return deadframe, None
예제 #6
0
파일: support.py 프로젝트: mozillazg/pypy
def _run_with_machine_code(testself, args):
    metainterp = testself.metainterp
    num_green_args = metainterp.jitdriver_sd.num_green_args
    procedure_token = metainterp.get_procedure_token(args[:num_green_args])
    # a loop was successfully created by _run_with_pyjitpl(); call it
    cpu = metainterp.cpu
    args1 = []
    for i in range(len(args) - num_green_args):
        x = args[num_green_args + i]
        args1.append(unspecialize_value(x))
    deadframe = cpu.execute_token(procedure_token, *args1)
    faildescr = cpu.get_latest_descr(deadframe)
    assert faildescr.__class__.__name__.startswith('DoneWithThisFrameDescr')
    if metainterp.jitdriver_sd.result_type == history.INT:
        return deadframe, cpu.get_int_value(deadframe, 0)
    elif metainterp.jitdriver_sd.result_type == history.REF:
        return deadframe, cpu.get_ref_value(deadframe, 0)
    elif metainterp.jitdriver_sd.result_type == history.FLOAT:
        return deadframe, cpu.get_float_value(deadframe, 0)
    else:
        return deadframe, None