Exemplo n.º 1
0
 def f(n):
     if n <= 0:
         return 42
     try:
         return f(n+1)
     except StackOverflow:
         if glob.caught:
             print 'Oups! already caught!'
         glob.caught = True
         _stack_criticalcode_start()
         critical(100)   # recurse another 100 times here
         _stack_criticalcode_stop()
         return 789
Exemplo n.º 2
0
 def f(n):
     if n <= 0:
         return 42
     try:
         return f(n+1)
     except StackOverflow:
         if glob.caught:
             print 'Oups! already caught!'
         glob.caught = True
         _stack_criticalcode_start()
         critical(100)   # recurse another 100 times here
         _stack_criticalcode_stop()
         return 789
Exemplo n.º 3
0
    def force_now(cpu, token):
        # Called during a residual call from the assembler, if the code
        # actually needs to force one of the virtualrefs or the virtualizable.
        # Implemented by forcing *all* virtualrefs and the virtualizable.

        # don't interrupt me! If the stack runs out in force_from_resumedata()
        # then we have seen cpu.force() but not self.save_data(), leaving in
        # an inconsistent state
        rstack._stack_criticalcode_start()
        try:
            faildescr = cpu.force(token)
            assert isinstance(faildescr, ResumeGuardForcedDescr)
            faildescr.handle_async_forcing(token)
        finally:
            rstack._stack_criticalcode_stop()
Exemplo n.º 4
0
    def force_now(cpu, token):
        # Called during a residual call from the assembler, if the code
        # actually needs to force one of the virtualrefs or the virtualizable.
        # Implemented by forcing *all* virtualrefs and the virtualizable.

        # don't interrupt me! If the stack runs out in force_from_resumedata()
        # then we have seen cpu.force() but not self.save_data(), leaving in
        # an inconsistent state
        rstack._stack_criticalcode_start()
        try:
            faildescr = cpu.force(token)
            assert isinstance(faildescr, ResumeGuardForcedDescr)
            faildescr.handle_async_forcing(token)
        finally:
            rstack._stack_criticalcode_stop()
Exemplo n.º 5
0
def blackhole_from_resumedata(blackholeinterpbuilder, jitdriver_sd, storage,
                              all_virtuals=None):
    # The initialization is stack-critical code: it must not be interrupted by
    # StackOverflow, otherwise the jit_virtual_refs are left in a dangling state.
    rstack._stack_criticalcode_start()
    try:
        resumereader = ResumeDataDirectReader(blackholeinterpbuilder.metainterp_sd,
                                              storage, all_virtuals)
        vinfo = jitdriver_sd.virtualizable_info
        ginfo = jitdriver_sd.greenfield_info
        vrefinfo = blackholeinterpbuilder.metainterp_sd.virtualref_info
        resumereader.consume_vref_and_vable(vrefinfo, vinfo, ginfo)
    finally:
        rstack._stack_criticalcode_stop()
    #
    # First get a chain of blackhole interpreters whose length is given
    # by the depth of rd_frame_info_list.  The first one we get must be
    # the bottom one, i.e. the last one in the chain, in order to make
    # the comment in BlackholeInterpreter.setposition() valid.
    nextbh = None
    frameinfo = storage.rd_frame_info_list
    while True:
        curbh = blackholeinterpbuilder.acquire_interp()
        curbh.nextblackholeinterp = nextbh
        nextbh = curbh
        frameinfo = frameinfo.prev
        if frameinfo is None:
            break
    firstbh = nextbh
    #
    # Now fill the blackhole interpreters with resume data.
    curbh = firstbh
    frameinfo = storage.rd_frame_info_list
    while True:
        curbh.setposition(frameinfo.jitcode, frameinfo.pc)
        resumereader.consume_one_section(curbh)
        curbh = curbh.nextblackholeinterp
        frameinfo = frameinfo.prev
        if frameinfo is None:
            break
    resumereader.done()
    return firstbh