Commits

Armin Rigo  committed 5820e4a Merge

Merge exception-cannot-occur: now we have to say either
hop.exception_cannot_occur() or hop.exception_is_here() in all
specialize_call() methods we write. Previously, it "kind of worked"
for a while until someone tried to call the special function within
a try: block.

  • Participants
  • Parent commits 4b68bb8, cbe26c9

Comments (0)

Files changed (30)

File pypy/jit/backend/llgraph/llimpl.py

         if specialize_as_constant:
             def specialize_call(self, hop):
                 llvalue = func(hop.args_s[0].const)
+                hop.exception_cannot_occur()
                 return hop.inputconst(lltype.typeOf(llvalue), llvalue)
         else:
             # specialize as direct_call
                     sm = ootype._static_meth(FUNCTYPE, _name=func.__name__, _callable=func)
                     cfunc = hop.inputconst(FUNCTYPE, sm)
                 args_v = hop.inputargs(*hop.args_r)
+                hop.exception_is_here()
                 return hop.genop('direct_call', [cfunc] + args_v, hop.r_result)
 
 

File pypy/module/thread/test/test_ll_thread.py

     def test_gc_locking(self):
         import time
         from pypy.rlib.objectmodel import invoke_around_extcall
-        from pypy.rlib.objectmodel import we_are_translated
         from pypy.rlib.debug import ll_assert
 
         class State:
             state.finished = 0
             # the next line installs before_extcall() and after_extcall()
             # to be called automatically around external function calls.
-            # When not translated it does not work around time.sleep(),
-            # so we have to call them manually for this test.
             invoke_around_extcall(before_extcall, after_extcall)
 
             g(10, 1)
                 willing_to_wait_more -= 1
                 done = len(state.answers) == expected
 
-                if not we_are_translated(): before_extcall()
                 time.sleep(0.01)
-                if not we_are_translated(): after_extcall()
 
-            if not we_are_translated(): before_extcall()
             time.sleep(0.1)
-            if not we_are_translated(): after_extcall()
 
             return len(state.answers)
 
         answers = fn()
         assert answers == expected
 
-class TestRunDirectly(AbstractThreadTests):
-    def getcompiled(self, f, argtypes):
-        return f
-
-    def test_start_new_thread(self):
-        py.test.skip("deadlocks occasionally -- why???")
+#class TestRunDirectly(AbstractThreadTests):
+#    def getcompiled(self, f, argtypes):
+#        return f
+# These are disabled because they crash occasionally for bad reasons
+# related to the fact that ll2ctypes is not at all thread-safe
 
 class TestUsingBoehm(AbstractThreadTests):
     gcpolicy = 'boehm'

File pypy/objspace/fake/objspace.py

         return s_None
 
     def specialize_call(self, hop):
+        hop.exception_cannot_occur()
         return hop.inputconst(lltype.Void, None)
 
 # ____________________________________________________________

File pypy/rlib/jit.py

         pass
 
     def specialize_call(self, hop):
-        pass
+        hop.exception_cannot_occur()
 
 vref_None = non_virtual_ref(None)
 

File pypy/rlib/jit_hooks.py

                 c_name = hop.inputconst(lltype.Void, 'access_helper')
                 args_v = [hop.inputarg(arg, arg=i)
                           for i, arg in enumerate(hop.args_r)]
+                hop.exception_cannot_occur()
                 return hop.genop('jit_marker', [c_name, c_func] + args_v,
                                  resulttype=hop.r_result)
         return helper

File pypy/rlib/objectmodel.py

 
     def specialize_call(self, hop):
         from pypy.rpython.lltypesystem import lltype
+        hop.exception_cannot_occur()
         return hop.inputconst(lltype.Bool, hop.s_result.const)
 
 # ____________________________________________________________
         r_obj, = hop.args_r
         v_obj, = hop.inputargs(r_obj)
         ll_fn = r_obj.get_ll_hash_function()
+        hop.exception_is_here()
         return hop.gendirectcall(ll_fn, v_obj)
 
 class Entry(ExtRegistryEntry):
             from pypy.rpython.error import TyperError
             raise TyperError("compute_identity_hash() cannot be applied to"
                              " %r" % (vobj.concretetype,))
+        hop.exception_cannot_occur()
         return hop.genop('gc_identityhash', [vobj], resulttype=lltype.Signed)
 
 class Entry(ExtRegistryEntry):
             from pypy.rpython.error import TyperError
             raise TyperError("compute_unique_id() cannot be applied to"
                              " %r" % (vobj.concretetype,))
+        hop.exception_cannot_occur()
         return hop.genop('gc_id', [vobj], resulttype=lltype.Signed)
 
 class Entry(ExtRegistryEntry):
 
     def specialize_call(self, hop):
         vobj, = hop.inputargs(hop.args_r[0])
+        hop.exception_cannot_occur()
         if hop.rtyper.type_system.name == 'lltypesystem':
             from pypy.rpython.lltypesystem import lltype
             if isinstance(vobj.concretetype, lltype.Ptr):

File pypy/rlib/rbigint.py

         s_DIGIT = self.bookkeeper.valueoftype(type(NULLDIGIT))
         assert s_DIGIT.contains(s_list.listdef.listitem.s_value)
     def specialize_call(self, hop):
-        pass
+        hop.exception_cannot_occur()
 
 
 class rbigint(object):

File pypy/rlib/rerased.py

             return identity.leave_tunnel(self.bookkeeper)
 
         def specialize_call(self, hop):
+            hop.exception_cannot_occur()
             if hop.r_result.lowleveltype is lltype.Void:
                 return hop.inputconst(lltype.Void, None)
             [v] = hop.inputargs(hop.args_r[0])
-            hop.exception_cannot_occur()
             return hop.args_r[0].rtype_unerase(hop, v)
 
     return erase, unerase
         return hop.genop('cast_opaque_ptr', [v], resulttype=hop.r_result)
 
     def rtype_unerase_int(self, hop, v):
+        hop.exception_cannot_occur()
         return hop.gendirectcall(ll_unerase_int, v)
 
     def rtype_erase_int(self, hop):
 
     def rtype_unerase_int(self, hop, v):
         c_one = hop.inputconst(lltype.Signed, 1)
+        hop.exception_cannot_occur()
         v2 = hop.genop('oounbox_int', [v], resulttype=hop.r_result)
         return hop.genop('int_rshift', [v2, c_one], resulttype=lltype.Signed)
 

File pypy/rlib/rgc.py

     def compute_result_annotation(self):
         return s_list_of_gcrefs()
     def specialize_call(self, hop):
+        hop.exception_cannot_occur()
         return hop.genop('gc_get_rpy_roots', [], resulttype = hop.r_result)
 
 class Entry(ExtRegistryEntry):
         return s_list_of_gcrefs()
     def specialize_call(self, hop):
         vlist = hop.inputargs(hop.args_r[0])
+        hop.exception_cannot_occur()
         return hop.genop('gc_get_rpy_referents', vlist,
                          resulttype = hop.r_result)
 
         return annmodel.SomeInteger()
     def specialize_call(self, hop):
         vlist = hop.inputargs(hop.args_r[0])
+        hop.exception_cannot_occur()
         return hop.genop('gc_get_rpy_memory_usage', vlist,
                          resulttype = hop.r_result)
 
         return annmodel.SomeInteger()
     def specialize_call(self, hop):
         vlist = hop.inputargs(hop.args_r[0])
+        hop.exception_cannot_occur()
         return hop.genop('gc_get_rpy_type_index', vlist,
                          resulttype = hop.r_result)
 
         return annmodel.SomeBool()
     def specialize_call(self, hop):
         vlist = hop.inputargs(hop.args_r[0])
+        hop.exception_cannot_occur()
         return hop.genop('gc_is_rpy_instance', vlist,
                          resulttype = hop.r_result)
 
         classrepr = getclassrepr(hop.rtyper, classdef)
         vtable = classrepr.getvtable()
         assert lltype.typeOf(vtable) == rclass.CLASSTYPE
+        hop.exception_cannot_occur()
         return Constant(vtable, concretetype=rclass.CLASSTYPE)
 
 class Entry(ExtRegistryEntry):

File pypy/rlib/rstring.py

             raise ValueError("Value is not no_nul")
 
     def specialize_call(self, hop):
-        pass
+        hop.exception_cannot_occur()
 

File pypy/rpython/controllerentry.py

     def specialize_call(self, hop):
         from pypy.rpython.lltypesystem import lltype
         assert hop.s_result.is_constant()
+        hop.exception_cannot_occur()
         return hop.inputconst(lltype.Bool, hop.s_result.const)
 
 # ____________________________________________________________

File pypy/rpython/lltypesystem/lloperation.py

 
     def specialize_call(self, hop):
         from pypy.rpython.lltypesystem import lltype
+        hop.exception_cannot_occur()
         return hop.inputconst(lltype.Void, None)
 
 def enum_ops_without_sideeffects(raising_is_ok=False):

File pypy/rpython/lltypesystem/rbuiltin.py

 from pypy.rpython.rbool import bool_repr
 
 def rtype_builtin_isinstance(hop):
+    hop.exception_cannot_occur()
     if hop.s_result.is_constant():
         return hop.inputconst(lltype.Bool, hop.s_result.const)
     if hop.args_r[0] == pyobj_repr or hop.args_r[1] == pyobj_repr:
     return my_instantiate()
 
 def rtype_instantiate(hop):
+    hop.exception_cannot_occur()
     s_class = hop.args_s[0]
     assert isinstance(s_class, annmodel.SomePBC)
     if len(s_class.descriptions) != 1:
     return rclass.rtype_new_instance(hop.rtyper, classdef, hop.llops)
 
 def rtype_builtin_hasattr(hop):
+    hop.exception_cannot_occur()
     if hop.s_result.is_constant():
         return hop.inputconst(lltype.Bool, hop.s_result.const)
     if hop.args_r[0] == pyobj_repr:
     raise TyperError("hasattr is only suported on a constant or on PyObject")
 
 def rtype_builtin___import__(hop):
+    xxx    # should not be used any more
     args_v = hop.inputargs(*[pyobj_repr for ign in hop.args_r])
     c = hop.inputconst(pyobj_repr, __import__)
     return hop.genop('simple_call', [c] + args_v, resulttype = pyobj_repr)

File pypy/rpython/lltypesystem/rclass.py

         assert isinstance(TYPE, GcStruct)
         assert lltype._castdepth(TYPE, OBJECT) > 0
         hop.rtyper.set_type_for_typeptr(vtable, TYPE)
+        hop.exception_cannot_occur()
         return hop.inputconst(lltype.Void, None)

File pypy/rpython/lltypesystem/rtuple.py

         vtup = hop.inputarg(self, 0)
         LIST = hop.r_result.lowleveltype.TO
         cno = inputconst(Signed, nitems)
+        hop.exception_is_here()
         vlist = hop.gendirectcall(LIST.ll_newlist, cno)
         v_func = hop.inputconst(Void, rlist.dum_nocheck)
         for index in range(nitems):

File pypy/rpython/module/r_os_stat.py

     r_StatResult = hop.rtyper.getrepr(ll_os_stat.s_StatResult)
     [v_result] = hop.inputargs(r_StatResult.r_tuple)
     # no-op conversion from r_StatResult.r_tuple to r_StatResult
+    hop.exception_cannot_occur()
     return v_result

File pypy/rpython/ootypesystem/ooregistry.py

                                          annmodel.SomeOOInstance,
                                          annmodel.SomeString))
         vlist = hop.inputargs(hop.args_r[0], ootype.Signed)
+        hop.exception_cannot_occur()
         return hop.genop('oostring', vlist, resulttype = ootype.String)
 
 class Entry_oounicode(ExtRegistryEntry):
         assert isinstance(hop.args_s[0], (annmodel.SomeUnicodeCodePoint,
                                           annmodel.SomeOOInstance))
         vlist = hop.inputargs(hop.args_r[0], ootype.Signed)
+        hop.exception_cannot_occur()
         return hop.genop('oounicode', vlist, resulttype = ootype.Unicode)
     
 

File pypy/rpython/ootypesystem/rbuiltin.py

 from pypy.rpython.error import TyperError
 
 def rtype_new(hop):
+    hop.exception_cannot_occur()
     assert hop.args_s[0].is_constant()
     vlist = hop.inputargs(ootype.Void)
     return hop.genop('new', vlist,
                      resulttype = hop.r_result.lowleveltype)
 
 def rtype_oonewarray(hop):
+    hop.exception_cannot_occur()
     assert hop.args_s[0].is_constant()
     vlist = hop.inputarg(ootype.Void, arg=0)
     vlength = hop.inputarg(ootype.Signed, arg=1)
                      resulttype = hop.r_result.lowleveltype)
 
 def rtype_null(hop):
+    hop.exception_cannot_occur()
     assert hop.args_s[0].is_constant()
     TYPE = hop.args_s[0].const
     nullvalue = ootype.null(TYPE)
     return hop.inputconst(TYPE, nullvalue)
 
 def rtype_classof(hop):
+    hop.exception_cannot_occur()
     assert isinstance(hop.args_s[0], annmodel.SomeOOInstance)
     vlist = hop.inputargs(hop.args_r[0])
     return hop.genop('classof', vlist,
                      resulttype = ootype.Class)
 
 def rtype_subclassof(hop):
+    hop.exception_cannot_occur()
     vlist = hop.inputargs(rootype.ooclass_repr, rootype.ooclass_repr)
     return hop.genop('subclassof', vlist,
                      resulttype = ootype.Bool)
 
 def rtype_instanceof(hop):
+    hop.exception_cannot_occur()
     INSTANCE = hop.args_v[1].value
     v_inst = hop.inputarg(hop.args_r[0], arg=0)
     c_cls = hop.inputconst(ootype.Void, INSTANCE)
                      resulttype=ootype.Bool)
 
 def rtype_runtimenew(hop):
+    hop.exception_cannot_occur()
     vlist = hop.inputargs(rootype.ooclass_repr)
     return hop.genop('runtimenew', vlist,
                      resulttype = hop.r_result.lowleveltype)
 
 def rtype_ooupcast(hop):
+    hop.exception_cannot_occur()
     assert isinstance(hop.args_s[0].const, ootype.Instance)
     assert isinstance(hop.args_s[1], annmodel.SomeOOInstance)
     v_inst = hop.inputarg(hop.args_r[1], arg=1)
     return hop.genop('ooupcast', [v_inst], resulttype = hop.r_result.lowleveltype)
 
 def rtype_oodowncast(hop):
+    hop.exception_cannot_occur()
     assert isinstance(hop.args_s[0].const, ootype.Instance)
     assert isinstance(hop.args_s[1], annmodel.SomeOOInstance)
     v_inst = hop.inputarg(hop.args_r[1], arg=1)
     return hop.genop('oodowncast', [v_inst], resulttype = hop.r_result.lowleveltype)
 
 def rtype_cast_to_object(hop):
+    hop.exception_cannot_occur()
     assert isinstance(hop.args_s[0], annmodel.SomeOOStaticMeth) or \
            isinstance(hop.args_s[0], annmodel.SomeOOClass) or \
            isinstance(hop.args_s[0].ootype, ootype.OOType)
     return hop.genop('cast_to_object', [v_inst], resulttype = hop.r_result.lowleveltype)
 
 def rtype_cast_from_object(hop):
+    hop.exception_cannot_occur()
     assert isinstance(hop.args_s[0].const, ootype.OOType)
     assert isinstance(hop.args_s[1], annmodel.SomeOOObject)
     v_inst = hop.inputarg(hop.args_r[1], arg=1)
     return hop.genop('cast_from_object', [v_inst], resulttype = hop.r_result.lowleveltype)
 
 def rtype_builtin_isinstance(hop):
+    hop.exception_cannot_occur()
     if hop.s_result.is_constant():
         return hop.inputconst(ootype.Bool, hop.s_result.const)
 
     return ootype.subclassof(c1, class_)
 
 def rtype_instantiate(hop):
+    hop.exception_cannot_occur()
     if hop.args_s[0].is_constant():
 ##        INSTANCE = hop.s_result.rtyper_makerepr(hop.rtyper).lowleveltype
 ##        v_instance = hop.inputconst(ootype.Void, INSTANCE)

File pypy/rpython/ootypesystem/rtuple.py

         RESULT = hop.r_result.lowleveltype
         c_resulttype = inputconst(ootype.Void, RESULT)
         c_length = inputconst(ootype.Signed, len(self.items_r))
+        hop.exception_is_here()
         if isinstance(RESULT, ootype.Array):
             v_list = hop.genop('oonewarray', [c_resulttype, c_length], resulttype=RESULT)
         else:

File pypy/rpython/rbool.py

 
     def rtype_float(_, hop):
         vlist = hop.inputargs(Float)
+        hop.exception_cannot_occur()
         return vlist[0]
 
 #

File pypy/rpython/rbuiltin.py

         raise TyperError("don't know about built-in function %r" % (
             self.builtinfunc,))
 
+    def _call(self, hop2, **kwds_i):
+        bltintyper = self.findbltintyper(hop2.rtyper)
+        hop2.llops._called_exception_is_here_or_cannot_occur = False
+        v_result = bltintyper(hop2, **kwds_i)
+        if not hop2.llops._called_exception_is_here_or_cannot_occur:
+            raise TyperError("missing hop.exception_cannot_occur() or "
+                             "hop.exception_is_here() in %s" % bltintyper)
+        return v_result
+
     def rtype_simple_call(self, hop):
-        bltintyper = self.findbltintyper(hop.rtyper)
         hop2 = hop.copy()
         hop2.r_s_popfirstarg()
-        return bltintyper(hop2)
+        return self._call(hop2)
 
     def rtype_call_args(self, hop):
         # calling a built-in function with keyword arguments:
         # mostly for rpython.objectmodel.hint()
         hop, kwds_i = call_args_expand(hop)
 
-        bltintyper = self.findbltintyper(hop.rtyper)
         hop2 = hop.copy()
         hop2.r_s_popfirstarg()
         hop2.r_s_popfirstarg()
         # the RPython-level keyword args are passed with an 'i_' prefix and
         # the corresponding value is an *index* in the hop2 arguments,
         # to be used with hop.inputarg(arg=..)
-        return bltintyper(hop2, **kwds_i)
+        return self._call(hop2, **kwds_i)
 
 
 class BuiltinMethodRepr(Repr):
 # ____________________________________________________________
 
 def rtype_builtin_bool(hop):
+    # not called any more?
     assert hop.nb_args == 1
     return hop.args_r[0].rtype_is_true(hop)
 
 
 def rtype_builtin_min(hop):
     v1, v2 = hop.inputargs(hop.r_result, hop.r_result)
+    hop.exception_cannot_occur()
     return hop.gendirectcall(ll_min, v1, v2)
 
 def ll_min(i1, i2):
 
 def rtype_builtin_max(hop):
     v1, v2 = hop.inputargs(hop.r_result, hop.r_result)
+    hop.exception_cannot_occur()
     return hop.gendirectcall(ll_max, v1, v2)
 
 def ll_max(i1, i2):
     pass
 
 def rtype_OSError__init__(hop):
+    hop.exception_cannot_occur()
     if hop.nb_args == 2:
         raise TyperError("OSError() should not be called with "
                          "a single argument")
         r_self.setfield(v_self, 'errno', v_errno, hop.llops)
 
 def rtype_WindowsError__init__(hop):
+    hop.exception_cannot_occur()
     if hop.nb_args == 2:
         raise TyperError("WindowsError() should not be called with "
                          "a single argument")
     assert hop.args_s[0].is_constant()
     TGT = hop.args_s[0].const
     v_type, v_value = hop.inputargs(lltype.Void, hop.args_r[1])
+    hop.exception_cannot_occur()
     return gen_cast(hop.llops, TGT, v_value)
 
 _cast_to_Signed = {
 
 def rtype_identity_hash(hop):
     vlist = hop.inputargs(hop.args_r[0])
+    hop.exception_cannot_occur()
     return hop.genop('gc_identityhash', vlist, resulttype=lltype.Signed)
 
 def rtype_runtime_type_info(hop):
     assert isinstance(hop.args_r[0], rptr.PtrRepr)
     vlist = hop.inputargs(hop.args_r[0])
+    hop.exception_cannot_occur()
     return hop.genop('runtime_type_info', vlist,
                      resulttype = hop.r_result.lowleveltype)
 
 
 def rtype_raw_malloc(hop):
     v_size, = hop.inputargs(lltype.Signed)
+    hop.exception_cannot_occur()
     return hop.genop('raw_malloc', [v_size], resulttype=llmemory.Address)
 
 def rtype_raw_malloc_usage(hop):
     if s_addr.is_null_address():
         raise TyperError("raw_memclear(x, n) where x is the constant NULL")
     v_list = hop.inputargs(llmemory.Address, lltype.Signed)
+    hop.exception_cannot_occur()
     return hop.genop('raw_memclear', v_list)
 
 BUILTIN_TYPER[llmemory.raw_malloc] = rtype_raw_malloc
 
 def rtype_offsetof(hop):
     TYPE, field = hop.inputargs(lltype.Void, lltype.Void)
+    hop.exception_cannot_occur()
     return hop.inputconst(lltype.Signed,
                           llmemory.offsetof(TYPE.value, field.value))
 
 # non-gc objects
 
 def rtype_free_non_gc_object(hop):
+    hop.exception_cannot_occur()
     vinst, = hop.inputargs(hop.args_r[0])
     flavor = hop.args_r[0].gcflavor
     assert flavor != 'gc'
 # keepalive_until_here
 
 def rtype_keepalive_until_here(hop):
+    hop.exception_cannot_occur()
     for v in hop.args_v:
         hop.genop('keepalive', [v], resulttype=lltype.Void)
     return hop.inputconst(lltype.Void, None)

File pypy/rpython/rfloat.py

         hop.exception_cannot_occur()
         return hop.genop('cast_float_to_int', vlist, resulttype=Signed)
 
-    rtype_float = rtype_pos
+    def rtype_float(_, hop):
+        vlist = hop.inputargs(Float)
+        hop.exception_cannot_occur()
+        return vlist[0]
 
     # version picked by specialisation based on which
     # type system rtyping is using, from <type_system>.ll_str module

File pypy/rpython/rint.py

         if hop.has_implicit_exception(ValueError):
             hop.exception_is_here()
             hop.gendirectcall(ll_check_chr, vlist[0])
+        else:
+            hop.exception_cannot_occur()
         return hop.genop('cast_int_to_char', vlist, resulttype=Char)
 
     def rtype_unichr(_, hop):
         if hop.has_implicit_exception(ValueError):
             hop.exception_is_here()
             hop.gendirectcall(ll_check_unichr, vlist[0])
+        else:
+            hop.exception_cannot_occur()
         return hop.genop('cast_int_to_unichar', vlist, resulttype=UniChar)
 
     def rtype_is_true(self, hop):

File pypy/rpython/rlist.py

     def rtype_bltn_list(self, hop):
         v_lst = hop.inputarg(self, 0)
         cRESLIST = hop.inputconst(Void, hop.r_result.LIST)
+        hop.exception_is_here()
         return hop.gendirectcall(ll_copy, cRESLIST, v_lst)
 
     def rtype_len(self, hop):

File pypy/rpython/rrange.py

     if isinstance(hop.r_result, AbstractRangeRepr):
         if hop.r_result.step != 0:
             c_rng = hop.inputconst(Void, hop.r_result.RANGE)
+            hop.exception_is_here()
             return hop.gendirectcall(hop.r_result.ll_newrange, c_rng, vstart, vstop)
         else:
+            hop.exception_is_here()
             return hop.gendirectcall(hop.r_result.ll_newrangest, vstart, vstop, vstep)
     else:
         # cannot build a RANGE object, needs a real list
         if isinstance(ITEMTYPE, Ptr):
             ITEMTYPE = ITEMTYPE.TO
         cLIST = hop.inputconst(Void, ITEMTYPE)
+        hop.exception_is_here()
         return hop.gendirectcall(ll_range2list, cLIST, vstart, vstop, vstep)
 
 rtype_builtin_xrange = rtype_builtin_range
                                      [v_index, v_item])
 
 def rtype_builtin_enumerate(hop):
+    hop.exception_cannot_occur()
     return hop.r_result.r_baseiter.newiter(hop)

File pypy/rpython/rstr.py

 
     def rtype_unicode(self, hop):
         if hop.args_s[0].is_constant():
+            # convertion errors occur during annotation, so cannot any more:
+            hop.exception_cannot_occur()
             return hop.inputconst(hop.r_result, hop.s_result.const)
         repr = hop.args_r[0].repr
         v_str = hop.inputarg(repr, 0)

File pypy/rpython/rtyper.py

         return result
 
     def exception_is_here(self):
+        self.llops._called_exception_is_here_or_cannot_occur = True
         if self.llops.llop_raising_exceptions is not None:
             raise TyperError("cannot catch an exception at more than one llop")
         if not self.exceptionlinks:
         self.llops.llop_raising_exceptions = len(self.llops)
 
     def exception_cannot_occur(self):
+        self.llops._called_exception_is_here_or_cannot_occur = True
         if self.llops.llop_raising_exceptions is not None:
             raise TyperError("cannot catch an exception at more than one llop")
         if not self.exceptionlinks:

File pypy/rpython/test/test_extregistry.py

         _about_ = dummy_func
         s_result_annotation = annmodel.SomeInteger()
         def specialize_call(self, hop):
+            hop.exception_cannot_occur()
             return hop.inputconst(lltype.Signed, 42)
 
     def func():

File pypy/rpython/test/test_rclass.py

                 return annmodel.SomeInteger()
             def specialize_call(self, hop):
                 [v_instance] = hop.inputargs(*hop.args_r)
+                hop.exception_is_here()
                 return hop.gendirectcall(ll_my_gethash, v_instance)
 
         def f(n):

File pypy/translator/cli/dotnet.py

             
 
     def specialize_call(self, hop):
+        hop.exception_cannot_occur()
         assert hop.args_s[1].is_constant()
         TYPE = hop.args_s[1].const
         v_obj = hop.inputarg(hop.args_r[0], arg=0)
 
     def specialize_call(self, hop):
         v_obj, = hop.inputargs(*hop.args_r)
+        hop.exception_cannot_occur()
         return hop.genop('same_as', [v_obj], hop.r_result.lowleveltype)
 
 def new_array(type, length):
 
     def specialize_call(self, hop):
         v_type, = hop.inputargs(*hop.args_r)
+        hop.exception_cannot_occur()
         return hop.genop('cli_typeof', [v_type], hop.r_result.lowleveltype)
 
 
         v_obj, = hop.inputargs(*hop.args_r)
         methodname = hop.args_r[0].methodname
         c_methodname = hop.inputconst(ootype.Void, methodname)
+        hop.exception_cannot_occur()
         return hop.genop('cli_eventhandler', [v_obj, c_methodname], hop.r_result.lowleveltype)
 
 
     def specialize_call(self, hop):
         assert isinstance(hop.args_s[0], annmodel.SomeOOInstance)
         v_inst = hop.inputarg(hop.args_r[0], arg=0)
+        hop.exception_cannot_occur()
         return hop.genop('oodowncast', [v_inst], resulttype = hop.r_result.lowleveltype)
 
 
     def specialize_call(self, hop):
         assert isinstance(hop.args_s[0], annmodel.SomeOOInstance)
         v_inst = hop.inputarg(hop.args_r[0], arg=0)
+        hop.exception_cannot_occur()
         return hop.genop('ooupcast', [v_inst], resulttype = hop.r_result.lowleveltype)
 
 
 
     def specialize_call(self, hop):
         v_obj = hop.inputarg(hop.args_r[0], arg=0)
+        hop.exception_cannot_occur()
         return hop.genop('oodowncast', [v_obj], hop.r_result.lowleveltype)