RPython should support multiple frame vref types?

Issue #1817 resolved
Edd Barrett
created an issue


In the pypy bridge, I've had to disable vrefs in at least one of the two interpreters to avoid the following error:

[translation:ERROR] UnionError:
[translation:ERROR] RPython cannot unify instances with no common base class
[translation:ERROR] Offending annotations:
[translation:ERROR]   SomeInstance(can_be_None=False, classdef=pypy.objspace.std
[translation:ERROR]   SomeInstance(can_be_None=False, classdef=hippy.frame.Frame
[translation:ERROR] Occurred processing the following simple_call:
[translation:ERROR]       (KeyError getting at the binding!)
[translation:ERROR]     v1101 = simple_call((function virtual_ref), frame_0)
[translation:ERROR] In <FunctionGraph of (hippy.interpreter:899)Interpreter.ente
r at 0x69844758>:
[translation:ERROR] Happened at file hippy/interpreter.py line 901
[translation:ERROR]             frame.f_backref = self.topframeref
[translation:ERROR] ==>         self.topframeref = jit.virtual_ref(frame)
[translation:ERROR]             #self.topframeref = jit.non_virtual_ref(frame)
[translation:ERROR]             if self.debugger is not None:
[translation:ERROR] Known variable annotations:
[translation:ERROR]  frame_0 = SomeInstance(can_be_None=False, classdef=hippy.fr
[translation:ERROR] Processing block:
[translation:ERROR]  block@3 is a <class 'rpython.flowspace.flowcontext.SpamBloc
[translation:ERROR]  in (hippy.interpreter:899)Interpreter.enter
[translation:ERROR]  containing the following operations:
[translation:ERROR]        v1102 = getattr(self_139, ('topframeref'))
[translation:ERROR]        v1103 = setattr(frame_0, ('f_backref'), v1102)
[translation:ERROR]        v1101 = simple_call((function virtual_ref), frame_0)
[translation:ERROR]        v1104 = setattr(self_139, ('topframeref'), v1101)
[translation:ERROR]        v1105 = getattr(self_139, ('debugger'))
[translation:ERROR]        v1106 = is_(v1105, (None))
[translation:ERROR]        v1107 = bool(v1106)
[translation:ERROR]  --end--

So basically, a hippy frame and a pypy frame cannot be unioned. There are two possible fixes:

  • Provide some base abstract frame type and force VM implementers to use it.
  • Allow RPython to support multiple frame types for vrefs.

I don't feel qualified to comment further. What do the pypy devs think?

Comments (6)

  1. Edd Barrett reporter

    Works. OK to apply the following?

    diff -r 24db6697b691 rpython/rlib/jit.py
    --- a/rpython/rlib/jit.py   Wed Jul 16 14:51:39 2014 -0700
    +++ b/rpython/rlib/jit.py   Wed Jul 23 11:55:00 2014 +0100
    @@ -340,6 +340,7 @@
     # ____________________________________________________________
     # VRefs
     def virtual_ref(x):
         """Creates a 'vref' object that contains a reference to 'x'.  Calls
         to virtual_ref/virtual_ref_finish must be properly nested.  The idea
    @@ -351,6 +352,7 @@
         return DirectJitVRef(x)
     virtual_ref.oopspec = 'virtual_ref(x)'
     def virtual_ref_finish(vref, x):
         """See docstring in virtual_ref(x)"""
         keepalive_until_here(x)   # otherwise the whole function call is removed
  2. Log in to comment