示例#1
0
def _new_runfn(h, _):
    # Here, we are in a fresh new stacklet.
    llop.gc_stack_bottom(lltype.Void)  # marker for trackgcroot.py
    #
    # There is a fresh suspstack object waiting on the gcrootfinder,
    # so populate it with data that represents the parent suspended
    # stacklet and detach the suspstack object from gcrootfinder.
    suspstack = gcrootfinder.attach_handle_on_suspstack(h)
    #
    # Call the main function provided by the (RPython) user.
    suspstack = gcrootfinder.runfn(suspstack, gcrootfinder.arg)
    #
    # Here, suspstack points to the target stacklet to which we want
    # to jump to next.  Read the 'handle' and forget about the
    # suspstack object.
    return _consume_suspstack(suspstack)
示例#2
0
def _new_runfn(h, _):
    # Here, we are in a fresh new stacklet.
    llop.gc_stack_bottom(lltype.Void)   # marker for trackgcroot.py
    #
    # There is a fresh suspstack object waiting on the gcrootfinder,
    # so populate it with data that represents the parent suspended
    # stacklet and detach the suspstack object from gcrootfinder.
    suspstack = gcrootfinder.attach_handle_on_suspstack(h)
    #
    # Call the main function provided by the (RPython) user.
    suspstack = gcrootfinder.runfn(suspstack, gcrootfinder.arg)
    #
    # Here, suspstack points to the target stacklet to which we want
    # to jump to next.  Read the 'handle' and forget about the
    # suspstack object.
    return _consume_suspstack(suspstack)
示例#3
0
    def wrapper(*args):
        from pypy.module.cpyext.pyobject import make_ref, from_ref
        from pypy.module.cpyext.pyobject import Reference

        # we hope that malloc removal removes the newtuple() that is
        # inserted exactly here by the varargs specializer
        llop.gc_stack_bottom(lltype.Void)  # marker for trackgcroot.py
        rffi.stackcounter.stacks_counter += 1
        retval = fatal_value
        boxed_args = ()
        try:
            if not we_are_translated() and DEBUG_WRAPPER:
                print >> sys.stderr, callable,
            assert len(args) == len(callable.api_func.argtypes)
            for i, (typ, is_wrapped) in argtypes_enum_ui:
                arg = args[i]
                if is_PyObject(typ) and is_wrapped:
                    if arg:
                        arg_conv = from_ref(space, rffi.cast(PyObject, arg))
                    else:
                        arg_conv = None
                else:
                    arg_conv = arg
                boxed_args += (arg_conv,)
            state = space.fromcache(State)
            try:
                result = callable(space, *boxed_args)
                if not we_are_translated() and DEBUG_WRAPPER:
                    print >> sys.stderr, " DONE"
            except OperationError, e:
                failed = True
                state.set_exception(e)
            except BaseException, e:
                failed = True
                if not we_are_translated():
                    message = repr(e)
                    import traceback

                    traceback.print_exc()
                else:
                    message = str(e)
                state.set_exception(OperationError(space.w_SystemError, space.wrap(message)))
示例#4
0
 def wrapper(*args):
     from pypy.module.cpyext.pyobject import make_ref, from_ref
     from pypy.module.cpyext.pyobject import Reference
     # we hope that malloc removal removes the newtuple() that is
     # inserted exactly here by the varargs specializer
     llop.gc_stack_bottom(lltype.Void)  # marker for trackgcroot.py
     rffi.stackcounter.stacks_counter += 1
     retval = fatal_value
     boxed_args = ()
     try:
         if not we_are_translated() and DEBUG_WRAPPER:
             print >> sys.stderr, callable,
         assert len(args) == len(callable.api_func.argtypes)
         for i, (typ, is_wrapped) in argtypes_enum_ui:
             arg = args[i]
             if is_PyObject(typ) and is_wrapped:
                 if arg:
                     arg_conv = from_ref(space, rffi.cast(PyObject, arg))
                 else:
                     arg_conv = None
             else:
                 arg_conv = arg
             boxed_args += (arg_conv, )
         state = space.fromcache(State)
         try:
             result = callable(space, *boxed_args)
             if not we_are_translated() and DEBUG_WRAPPER:
                 print >> sys.stderr, " DONE"
         except OperationError, e:
             failed = True
             state.set_exception(e)
         except BaseException, e:
             failed = True
             if not we_are_translated():
                 message = repr(e)
                 import traceback
                 traceback.print_exc()
             else:
                 message = str(e)
             state.set_exception(
                 OperationError(space.w_SystemError, space.wrap(message)))
示例#5
0
 def mycallback(a, b):
     llop.gc_stack_bottom(lltype.Void)
     rffi.stackcounter.stacks_counter += 1
     gc.collect()
     rffi.stackcounter.stacks_counter -= 1
     return a + b
示例#6
0
 def mycallback(a, b):
     llop.gc_stack_bottom(lltype.Void)
     rffi.stackcounter.stacks_counter += 1
     gc.collect()
     rffi.stackcounter.stacks_counter -= 1
     return a + b