Author: Maciej Fijalkowski <[email protected]>
Branch: kill-gen-store-back-in
Changeset: r62777:f323e4b070c5
Date: 2013-03-25 17:49 -0700
http://bitbucket.org/pypy/pypy/changeset/f323e4b070c5/

Log:    the dumbest possible fix for the backend

diff --git a/rpython/jit/backend/test/runner_test.py 
b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -3866,14 +3866,21 @@
     def test_force_virtualizable(self):
 
         class FakeVinfo(object):
-            # for llgraph
-            def clear_vable_token(self, token):
-                lltype.cast_opaque_ptr(lltype.Ptr(S), token).x = 18
+            pass
 
+        def clear_vable_token(token):
+            lltype.cast_opaque_ptr(lltype.Ptr(S), token).x = 18
+
+        FUNC = lltype.FuncType([llmemory.GCREF], lltype.Void)
+        clear_vable_ptr = llhelper(lltype.Ptr(FUNC), clear_vable_token)
         S = lltype.GcStruct('x', ('x', lltype.Signed))
 
         pdescr = self.cpu.fielddescrof(S, 'x')
         pdescr.vinfo = FakeVinfo()
+        pdescr.vinfo.clear_vable_token = clear_vable_token
+        pdescr.vinfo.clear_vable_ptr = clear_vable_ptr
+        pdescr.vinfo.clear_vable_descr = self.cpu.calldescrof(FUNC, FUNC.ARGS,
+          FUNC.RESULT, EffectInfo.LEAST_GENERAL)
         loop = parse("""
         [p0]
         force_virtualizable(p0, descr=pdescr)
diff --git a/rpython/jit/backend/x86/regalloc.py 
b/rpython/jit/backend/x86/regalloc.py
--- a/rpython/jit/backend/x86/regalloc.py
+++ b/rpython/jit/backend/x86/regalloc.py
@@ -16,7 +16,7 @@
 from rpython.jit.backend.x86.jump import remap_frame_layout_mixed
 from rpython.jit.codewriter import longlong
 from rpython.jit.codewriter.effectinfo import EffectInfo
-from rpython.jit.metainterp.resoperation import rop
+from rpython.jit.metainterp.resoperation import rop, ResOperation
 from rpython.jit.backend.llsupport.descr import ArrayDescr
 from rpython.jit.backend.llsupport.descr import CallDescr
 from rpython.jit.backend.llsupport.descr import unpack_arraydescr
@@ -54,7 +54,7 @@
 class X86_64_RegisterManager(X86RegisterManager):
     # r11 omitted because it's used as scratch
     all_regs = [ecx, eax, edx, ebx, esi, edi, r8, r9, r10, r12, r13, r14, r15]
-    
+
     no_lower_byte_regs = []
     save_around_call_regs = [eax, ecx, edx, esi, edi, r8, r9, r10]
 
@@ -103,7 +103,7 @@
     def __init__(self, base_ofs):
         FrameManager.__init__(self)
         self.base_ofs = base_ofs
-    
+
     def frame_pos(self, i, box_type):
         return FrameLoc(i, get_ebp_ofs(self.base_ofs, i), box_type)
 
@@ -338,7 +338,8 @@
             self.assembler.mc.mark_op(op)
             self.rm.position = i
             self.xrm.position = i
-            if op.has_no_side_effect() and op.result not in self.longevity:
+            if (op.has_no_side_effect() and op.result not in self.longevity
+                and op.opnum != rop.FORCE_VIRTUALIZABLE):
                 i += 1
                 self.possibly_free_vars_for_op(op)
                 continue
@@ -870,6 +871,16 @@
             gc_ll_descr.get_nursery_top_addr(),
             sizeloc, gcmap)
 
+    def consider_force_virtualizable(self, op):
+        # just do a call for now
+        vinfo = op.getdescr().vinfo
+        calldescr = vinfo.clear_vable_descr
+        assert isinstance(calldescr, CallDescr)
+        fval = rffi.cast(lltype.Signed, vinfo.clear_vable_ptr)
+        op = ResOperation(rop.CALL, [ConstInt(fval), op.getarg(0)], None,
+                          descr=calldescr)
+        self.consider_call(op)
+
     def get_gcmap(self, forbidden_regs=[], noregs=False):
         frame_depth = self.fm.get_frame_depth()
         gcmap = allocate_gcmap(self.assembler, frame_depth, 
JITFRAME_FIXED_SIZE)
@@ -1313,7 +1324,7 @@
         #jump_op = self.final_jump_op
         #if jump_op is not None and jump_op.getdescr() is descr:
         #    self._compute_hint_frame_locations_from_descr(descr)
-        
+
 
     def consider_keepalive(self, op):
         pass
diff --git a/rpython/jit/codewriter/effectinfo.py 
b/rpython/jit/codewriter/effectinfo.py
--- a/rpython/jit/codewriter/effectinfo.py
+++ b/rpython/jit/codewriter/effectinfo.py
@@ -160,6 +160,9 @@
 EffectInfo.MOST_GENERAL = EffectInfo(None, None, None, None,
                                      EffectInfo.EF_RANDOM_EFFECTS,
                                      can_invalidate=True)
+EffectInfo.LEAST_GENERAL = EffectInfo({}, {}, {}, {},
+                                      EffectInfo.EF_ELIDABLE_CANNOT_RAISE,
+                                      can_invalidate=False)
 
 
 def effectinfo_from_writeanalyze(effects, cpu,
diff --git a/rpython/jit/metainterp/resoperation.py 
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -495,6 +495,8 @@
     'READ_TIMESTAMP/0',
     'MARK_OPAQUE_PTR/1b',
     'FORCE_VIRTUALIZABLE/1d', # forces a non-standard virtualizable
+    # this one has no *visible* side effect, since the virtualizable
+    # must be forced, however we need to execute it anyway
     '_NOSIDEEFFECT_LAST', # ----- end of no_side_effect operations -----
 
     'SETARRAYITEM_GC/3d',
diff --git a/rpython/jit/metainterp/virtualizable.py 
b/rpython/jit/metainterp/virtualizable.py
--- a/rpython/jit/metainterp/virtualizable.py
+++ b/rpython/jit/metainterp/virtualizable.py
@@ -1,3 +1,4 @@
+from rpython.jit.codewriter.effectinfo import EffectInfo
 from rpython.jit.metainterp import history
 from rpython.jit.metainterp.typesystem import deref, fieldType, arrayItem
 from rpython.jit.metainterp.warmstate import wrap, unwrap
@@ -70,7 +71,7 @@
             descr.vinfo = self
         for descr in self.array_field_descrs:
             descr.vinfo = self
-        
+
         self.static_field_by_descrs = dict(
             [(descr, i) for (i, descr) in enumerate(self.static_field_descrs)])
         self.array_field_by_descrs = dict(
@@ -291,6 +292,13 @@
             FUNCPTR, force_virtualizable_if_necessary)
         rvirtualizable2.replace_force_virtualizable_with_call(
             all_graphs, self.VTYPEPTR, funcptr)
+        (_, FUNCPTR) = ts.get_FuncType([llmemory.GCREF], lltype.Void)
+        self.clear_vable_ptr = self.warmrunnerdesc.helper_func(
+            FUNCPTR, self.clear_vable_token)
+        FUNC = FUNCPTR.TO
+        self.clear_vable_descr = self.cpu.calldescrof(FUNC, FUNC.ARGS,
+                                                      FUNC.RESULT,
+                                                      EffectInfo.LEAST_GENERAL)
 
     def unwrap_virtualizable_box(self, virtualizable_box):
         return virtualizable_box.getref(llmemory.GCREF)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to