1. Tobias Pape
  2. pypy

Commits

Carl Friedrich Bolz  committed 366c6b1

try to print the class of the virtual that is being promoted

  • Participants
  • Parent commits 931f918
  • Branches default

Comments (0)

Files changed (4)

File rpython/jit/metainterp/optimizeopt/rewrite.py

View file
  • Ignore whitespace
     def optimize_GUARD_VALUE(self, op):
         value = self.getvalue(op.getarg(0))
         if value.is_virtual():
-            raise InvalidLoop('A promote of a virtual (a recently allocated object) never makes sense!')
+            arg = value.get_constant_class(self.optimizer.cpu)
+            if arg:
+                addr = arg.getaddr()
+                name = self.optimizer.metainterp_sd.get_name_from_address(addr)
+            else:
+                name = "<unknown>"
+            raise InvalidLoop('A promote of a virtual %s (a recently allocated object) never makes sense!' % name)
         if value.last_guard:
             # there already has been a guard_nonnull or guard_class or
             # guard_nonnull_class on this value, which is rather silly.

File rpython/jit/metainterp/optimizeopt/test/test_disable_optimizations.py

View file
  • Ignore whitespace
         def raises(self, e, fn, *args):
             try:
                 fn(*args)
-            except e:
-                pass
+            except Exception, e:
+                return e
 
     opt = allopts[optnum]
     exec "TestNo%sLLtype = TestLLtype" % (opt[0].upper() + opt[1:])

File rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py

View file
  • Ignore whitespace
         return loop
 
     def raises(self, e, fn, *args):
-        py.test.raises(e, fn, *args)
+        return py.test.raises(e, fn, *args).value
 
 class OptimizeOptTest(BaseTestWithUnroll):
 
         guard_value(p2, ConstPtr(myptr)) []
         jump(p2)
         """
-        self.raises(InvalidLoop, self.optimize_loop,
-                       ops, "crash!")
+        exc = self.raises(InvalidLoop, self.optimize_loop,
+                          ops, "crash!")
+        if exc:
+            assert "node" in exc.msg
 
     def test_merge_guard_class_guard_value(self):
         ops = """

File rpython/jit/metainterp/optimizeopt/test/test_util.py

View file
  • Ignore whitespace
             max_retrace_guards = 15
         jitcounter = DeterministicJitCounter()
 
+    def get_name_from_address(self, addr):
+        # hack
+        try:
+            return "".join(addr.ptr.name)[:-1] # remove \x00
+        except AttributeError:
+            return ""
+
 class Storage(compile.ResumeGuardDescr):
     "for tests."
     def __init__(self, metainterp_sd=None, original_greenkey=None):