Exemple #1
0
def Py_EnterRecursiveCall(space, where):
    """Marks a point where a recursive C-level call is about to be performed.

    If USE_STACKCHECK is defined, this function checks if the the OS
    stack overflowed using PyOS_CheckStack().  In this is the case, it
    sets a MemoryError and returns a nonzero value.

    The function then checks if the recursion limit is reached.  If this is the
    case, a RuntimeError is set and a nonzero value is returned.
    Otherwise, zero is returned.

    where should be a string such as " in instance check" to be
    concatenated to the RuntimeError message caused by the recursion depth
    limit."""
    if not we_are_translated():
        # XXX hack since the stack checks only work translated
        global limit
        limit += 1
        if limit > 10:
            raise oefmt(space.w_RuntimeError,
                        "maximum recursion depth exceeded%s",
                        rffi.charp2str(where))
        return 0
    from rpython.rlib.rstack import stack_almost_full
    if stack_almost_full():
        raise oefmt(space.w_RuntimeError, "maximum recursion depth exceeded%s",
                    rffi.charp2str(where))
    return 0
Exemple #2
0
 def async(self, space):
     # also matches a RuntimeError("maximum rec.") if the stack is
     # still almost full, because in this case it might be a better
     # idea to propagate the exception than eat it
     if (self.w_type is space.w_RuntimeError and
         self._value == "maximum recursion depth exceeded" and
         rstack.stack_almost_full()):
         return True
     return OperationError.async(self, space)
Exemple #3
0
 def handle_fail(self, deadframe, metainterp_sd, jitdriver_sd):
     if (self.must_compile(deadframe, metainterp_sd, jitdriver_sd)
             and not rstack.stack_almost_full()):
         self.start_compiling()
         try:
             self._trace_and_compile_from_bridge(deadframe, metainterp_sd,
                                                 jitdriver_sd)
         finally:
             self.done_compiling()
     else:
         from rpython.jit.metainterp.blackhole import resume_in_blackhole
         if isinstance(self, ResumeGuardCopiedDescr):
             resume_in_blackhole(metainterp_sd, jitdriver_sd, self.prev, deadframe)    
         else:
             assert isinstance(self, ResumeGuardDescr)
             resume_in_blackhole(metainterp_sd, jitdriver_sd, self, deadframe)
     assert 0, "unreachable"
Exemple #4
0
 def bound_reached(hash, cell, *args):
     if not confirm_enter_jit(*args):
         return
     jitcounter.decay_all_counters()
     if rstack.stack_almost_full():
         return
     # start tracing
     from rpython.jit.metainterp.pyjitpl import MetaInterp
     metainterp = MetaInterp(metainterp_sd, jitdriver_sd)
     greenargs = args[:num_green_args]
     if cell is None:
         cell = JitCell(*greenargs)
         jitcounter.install_new_cell(hash, cell)
     cell.flags |= JC_TRACING | JC_TRACING_OCCURRED
     try:
         metainterp.compile_and_run_once(jitdriver_sd, *args)
     finally:
         cell.flags &= ~JC_TRACING
Exemple #5
0
def stack_almost_full(space):
    """Return True if the stack is more than 15/16th full."""
    return space.newbool(rstack.stack_almost_full())