Commits

Armin Rigo committed cb0037c

Fix

  • Participants
  • Parent commits cd50141

Comments (0)

Files changed (1)

pypy/jit/backend/test/test_random.py

 class OperationBuilder(object):
     def __init__(self, cpu, loop, vars):
         self.cpu = cpu
+        if not hasattr(cpu, '_faildescr_keepalive'):
+            cpu._faildescr_keepalive = []
         self.fakemetainterp = FakeMetaInterp()
         self.loop = loop
         self.intvars = [box for box in vars if isinstance(box, BoxInt)]
         if pytest.config.option.output:
             s.close()
 
+    def getfaildescr(self):
+        descr = BasicFailDescr()
+        self.cpu._faildescr_keepalive.append(descr)
+        return descr
+
 class CannotProduceOperation(Exception):
     pass
 
             builder.intvars[:] = original_intvars
         else:
             op = ResOperation(rop.GUARD_NO_OVERFLOW, [], None)
-        op.setdescr(BasicFailDescr())
+        op.setdescr(builder.getfaildescr())
         op.setfailargs(fail_subset)
         builder.loop.operations.append(op)
 
     def produce_into(self, builder, r):
         op, passing = self.gen_guard(builder, r)
         builder.loop.operations.append(op)
-        op.setdescr(BasicFailDescr())
+        op.setdescr(builder.getfaildescr())
         op.setfailargs(builder.subset_of_intvars(r))
         if not passing:
             builder.should_fail_by = op
         r.shuffle(endvars)
         endvars = endvars[:1]
         loop.operations.append(ResOperation(rop.FINISH, endvars, None,
-                                            descr=BasicFailDescr()))
+                                            descr=builder.getfaildescr()))
         if builder.should_fail_by:
             self.should_fail_by = builder.should_fail_by
             self.guard_op = builder.guard_op
             else:
                 op = ResOperation(rop.GUARD_EXCEPTION, [guard_op._exc_box],
                                   BoxPtr())
-            op.setdescr(BasicFailDescr())
+            op.setdescr(self.builder.getfaildescr())
             op.setfailargs([])
             return op