[pypy-svn] r80041 - in pypy/branch/out-of-line-guards/pypy: jit/backend/llgraph jit/codewriter jit/metainterp rpython/lltypesystem

fijal at codespeak.net fijal at codespeak.net
Mon Dec 13 18:15:27 CET 2010


Author: fijal
Date: Mon Dec 13 18:15:25 2010
New Revision: 80041

Modified:
   pypy/branch/out-of-line-guards/pypy/jit/backend/llgraph/runner.py
   pypy/branch/out-of-line-guards/pypy/jit/codewriter/jtransform.py
   pypy/branch/out-of-line-guards/pypy/jit/metainterp/history.py
   pypy/branch/out-of-line-guards/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/out-of-line-guards/pypy/rpython/lltypesystem/rclass.py
Log:
Progress on out-of-line guards. Use weakref for storing affected codes
and cheat (horribly) to pretend that LoopToken is a low-level pointer


Modified: pypy/branch/out-of-line-guards/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/out-of-line-guards/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/out-of-line-guards/pypy/jit/backend/llgraph/runner.py	Mon Dec 13 18:15:25 2010
@@ -490,6 +490,13 @@
 
     def get_invalidate_asm(self, TP, fieldname):
         def invalidate_asm(arg, fieldname):
+            prev = getattr(arg, fieldname)
+            next = prev
+            while next:
+                prev = next
+                x = llmemory.weakref_deref(history.LoopToken._TYPE,
+                                           prev.address)
+                next = next.next
             XXX # write me
         return invalidate_asm
 

Modified: pypy/branch/out-of-line-guards/pypy/jit/codewriter/jtransform.py
==============================================================================
--- pypy/branch/out-of-line-guards/pypy/jit/codewriter/jtransform.py	(original)
+++ pypy/branch/out-of-line-guards/pypy/jit/codewriter/jtransform.py	Mon Dec 13 18:15:25 2010
@@ -605,7 +605,8 @@
                         next = next.next
                     prev.next = new_asmcode
 
-            args_s = [lltype_to_annotation(llmemory.GCREF)] * 2
+            args_s = [lltype_to_annotation(llmemory.GCREF),
+                      lltype_to_annotation(llmemory.WeakRefPtr)]
             s_result = lltype_to_annotation(lltype.Void)
             mixlevelann = MixLevelHelperAnnotator(self.cpu.rtyper)
             c_appender = mixlevelann.constfunc(appender, args_s, s_result)

Modified: pypy/branch/out-of-line-guards/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/out-of-line-guards/pypy/jit/metainterp/history.py	(original)
+++ pypy/branch/out-of-line-guards/pypy/jit/metainterp/history.py	Mon Dec 13 18:15:25 2010
@@ -725,6 +725,20 @@
     was compiled; but the LoopDescr remains alive and points to the
     generated assembler.
     """
+
+    _TYPE = lltype.Ptr(lltype.GcStruct('dummy struct for tests'))
+
+    def _normalizedcontainer(self):
+        return self
+
+    def _getobj(self, check=True):
+        return self
+    _as_ptr = _getobj
+    _obj0 = None
+    _obj = property(_getobj)
+    def _was_freed(self):
+        return False
+    
     terminating = False # see TerminatingLoopToken in compile.py
     outermost_jitdriver_sd = None
     # specnodes = ...

Modified: pypy/branch/out-of-line-guards/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/out-of-line-guards/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/out-of-line-guards/pypy/jit/metainterp/pyjitpl.py	Mon Dec 13 18:15:25 2010
@@ -1,6 +1,5 @@
 import py, os, sys
 from pypy.rpython.lltypesystem import lltype, llmemory, rclass
-from pypy.rpython.lltypesystem.rclass import ASMCODE
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rlib.debug import debug_start, debug_stop, debug_print
@@ -2238,13 +2237,14 @@
         op = op.copy_and_change(rop.CALL_ASSEMBLER, args=args, descr=token)
         self.history.operations.append(op)
 
-    def remember_jit_invariants(self, token):
-        lltoken = lltype.cast_opaque_ptr(llmemory.GCREF, token)
+    def remember_jit_invariants(self, loop):
+        lltoken_weakref = llmemory.weakref_create(loop.token)
         seen = {}
         for b_struct, c_appender in self.invariant_structs:
             if (b_struct, c_appender) not in seen:
-                heaptracker.int2adr(c_func.value).ptr(b_struct.value, lltoken)
-                seend[(b_struct, c_appender)] = None
+                heaptracker.int2adr(c_appender.value).ptr(b_struct.value,
+                                                          lltoken_weakref)
+                seen[(b_struct, c_appender)] = None
 
 # ____________________________________________________________
 

Modified: pypy/branch/out-of-line-guards/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/branch/out-of-line-guards/pypy/rpython/lltypesystem/rclass.py	(original)
+++ pypy/branch/out-of-line-guards/pypy/rpython/lltypesystem/rclass.py	Mon Dec 13 18:15:25 2010
@@ -87,7 +87,7 @@
 # a linked-list of assembler codes to invalidate in case jit_invariant_fields
 # are modified
 ASMCODE = lltype.GcForwardReference()
-ASMCODE.become(GcStruct('asmcode', ('address', llmemory.GCREF),
+ASMCODE.become(GcStruct('asmcode', ('address', llmemory.WeakRefPtr),
                         ('next', lltype.Ptr(ASMCODE))))
 
 def cast_vtable_to_typeptr(vtable):



More information about the Pypy-commit mailing list