Commits

Maciej Fijalkowski  committed 6112dd6 Draft

slow progress

  • Participants
  • Parent commits 0235d65
  • Branches vref-copy

Comments (0)

Files changed (4)

File pypy/jit/metainterp/compile.py

 from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.ootypesystem import ootype
 from pypy.objspace.flow.model import Constant, Variable
-from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.objectmodel import we_are_translated, specialize
 from pypy.rlib.debug import debug_start, debug_stop, debug_print
 from pypy.rlib import rstack
 from pypy.rlib.jit import JitDebugInfo, Counters
         self.copy_all_attributes_into(res)
         return res
 
+@specialize.arg(2)
+def read_field_from_resume(cpu, token, fieldname):
+    faildescr = cpu.force(token)
+    assert isinstance(faildescr, ResumeGuardForcedDescr)
+    return faildescr.handle_async_field_read(token, fieldname)
+
 class ResumeGuardForcedDescr(ResumeGuardDescr):
 
     def __init__(self, metainterp_sd, jitdriver_sd):
         # future failure of the GUARD_NOT_FORCED
         self.save_data(force_token, all_virtuals)
 
+    @specialize.arg(2)
+    def handle_async_field_read(self, force_token, fieldname):
+        from pypy.jit.metainterp.resume import read_field_from_resumedata
+        metainterp_sd = self.metainterp_sd
+        ginfo = self.jitdriver_sd.greenfield_info
+        return read_field_from_resumedata(metainterp_sd, self, ginfo)
+
     def save_data(self, key, value):
         globaldata = self.metainterp_sd.globaldata
         if we_are_translated():

File pypy/jit/metainterp/resume.py

     resumereader.done()
     return resumereader.liveboxes, virtualizable_boxes, virtualref_boxes
 
+def read_field_from_resumedata(metainterp, storage, greenfield_info):
+    xxx
+
 class ResumeDataBoxReader(AbstractResumeDataReader):
     unique_id = lambda: None
 

File pypy/jit/metainterp/virtualref.py

     def _freeze_(self):
         return True
 
-    def _find_type_of_virtualref(self):
+    def _find_type_of_virtualref(self, graphs):
         # XXX limitation is that we can only have one type
+        T = None
         for graph in graphs:
             for block in graph.iterblocks():
                 for op in block.operations:
+                    if op.opname == 'jit_record_vref':
+                        new_T = op.args[0].concretetype
+                        if T is None:
+                            T = new_T
+                        else:
+                            assert T == new_T, "Different vref types %s and %s" % (T, new_T)
+        self._vref_T = T
 
     def replace_force_virtual_with_call(self, graphs):
         # similar to rvirtualizable2.replace_force_virtualizable_with_call().
         c_is_virtual_ptr = None
         c_getfield_ptrs = {} # fieldname -> function
         force_virtual_count = 0
-        self._find_type_of_virtualref()
+        self._find_type_of_virtualref(graphs)
         for graph in graphs:
             for block in graph.iterblocks():
                 for op in block.operations:
     def get_vref_getfield_fnptr(self, name, RES_TP):
         def read_virtual_field(inst):
             if inst.typeptr != self.jit_virtual_ref_vtable:
-                lltype.cast_ptr(
-                xxx
-            xxx
+                inst = lltype.cast_pointer(self._vref_T, inst)
+                return getattr(inst, 'inst_' + name)
+            vref = lltype.cast_pointer(lltype.Ptr(self.JIT_VIRTUAL_REF), inst)
+            token = vref.virtual_token
+            if token == self.TOKEN_TRACING_RESCALL or token == self.TOKEN_NONE:
+                # not a virtual at all, just pretending to be one
+                forced = lltype.cast_pointer(self._vref_T, vref.forced)
+                return getattr(forced, 'inst_' + name)
+            else: 
+                assert not vref.forced
+                from pypy.jit.metainterp.compile import read_field_from_resume
+                return read_field_from_resume(self.cpu, token, name)
+                
         FUNC = lltype.FuncType([rclass.OBJECTPTR], RES_TP)
         funcptr = self.warmrunnerdesc.helper_func(
             lltype.Ptr(FUNC),

File pypy/rpython/lltypesystem/opimpl.py

 def op_jit_record_known_class(x, y):
     pass
 
+def op_jit_record_vref(x):
+    pass
+
 def op_get_group_member(TYPE, grpptr, memberoffset):
     from pypy.rpython.lltypesystem import llgroup
     assert isinstance(memberoffset, llgroup.GroupMemberOffset)