[pypy-svn] r67355 - in pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llsupport: . test

arigo at codespeak.net arigo at codespeak.net
Mon Aug 31 14:28:21 CEST 2009


Author: arigo
Date: Mon Aug 31 14:28:19 2009
New Revision: 67355

Modified:
   pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llsupport/gc.py
   pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llsupport/test/test_gc.py
Log:
Don't need to pass the GcRefList from outside.
Keep it an internal implementation detail.


Modified: pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llsupport/gc.py
==============================================================================
--- pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llsupport/gc.py	(original)
+++ pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llsupport/gc.py	Mon Aug 31 14:28:19 2009
@@ -23,7 +23,7 @@
         return True
     def do_write_barrier(self, gcref_struct, gcref_newptr):
         pass
-    def rewrite_assembler(self, cpu, gcrefs, operations):
+    def rewrite_assembler(self, cpu, operations):
         pass
 
 # ____________________________________________________________
@@ -266,7 +266,6 @@
 
 
 class GcLLDescr_framework(GcLLDescription):
-    GcRefList = GcRefList
 
     def __init__(self, gcdescr, translator, llop1=llop):
         from pypy.rpython.memory.gc.base import choose_gc_from_config
@@ -276,6 +275,7 @@
         assert self.translate_support_code, "required with the framework GC"
         self.translator = translator
         self.llop1 = llop1
+        self.gcrefs = None
 
         # we need the hybrid GC for GcRefList.alloc_gcref_list() to work
         if gcdescr.config.translation.gc != 'hybrid':
@@ -429,7 +429,7 @@
             funcptr(llmemory.cast_ptr_to_adr(gcref_struct),
                     llmemory.cast_ptr_to_adr(gcref_newptr))
 
-    def rewrite_assembler(self, cpu, gcrefs, operations):
+    def rewrite_assembler(self, cpu, operations):
         # Perform two kinds of rewrites in parallel:
         #
         # - Add COND_CALLs to the write barrier before SETFIELD_GC and
@@ -443,6 +443,8 @@
         #   replace direct usage of ConstPtr with a BoxPtr loaded by a
         #   GETFIELD_RAW from the array 'gcrefs.list'.
         #
+        if self.gcrefs is None:
+            self.gcrefs = GcRefList()
         newops = []
         for op in operations:
             if op.opnum == rop.DEBUG_MERGE_POINT:
@@ -454,7 +456,7 @@
                 if (isinstance(v, ConstPtr) and bool(v.value)
                                             and rgc.can_move(v.value)):
                     box = BoxPtr(v.value)
-                    addr = gcrefs.get_address_of_gcref(v.value)
+                    addr = self.gcrefs.get_address_of_gcref(v.value)
                     addr = cpu.cast_adr_to_int(addr)
                     newops.append(ResOperation(rop.GETFIELD_RAW,
                                                [ConstInt(addr)], box,
@@ -478,7 +480,7 @@
                                       descr=op.descr)
             # ----------
             if op.is_guard():
-                self.rewrite_assembler(cpu, gcrefs, op.suboperations)
+                self.rewrite_assembler(cpu, op.suboperations)
             newops.append(op)
         del operations[:]
         operations.extend(newops)

Modified: pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llsupport/test/test_gc.py
==============================================================================
--- pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llsupport/test/test_gc.py	(original)
+++ pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llsupport/test/test_gc.py	Mon Aug 31 14:28:19 2009
@@ -250,9 +250,8 @@
             ResOperation(rop.OOIS, [v_random_box, ConstPtr(s_gcref)],
                          v_result),
             ]
-        gcrefs = GcRefList()
         gc_ll_descr = self.gc_ll_descr
-        gc_ll_descr.rewrite_assembler(MyFakeCPU(), gcrefs, operations)
+        gc_ll_descr.rewrite_assembler(MyFakeCPU(), operations)
         assert len(operations) == 2
         assert operations[0].opnum == rop.GETFIELD_RAW
         assert operations[0].args == [ConstInt(43)]
@@ -273,7 +272,7 @@
                          descr=field_descr),
             ]
         gc_ll_descr = self.gc_ll_descr
-        gc_ll_descr.rewrite_assembler(self.fake_cpu, None, operations)
+        gc_ll_descr.rewrite_assembler(self.fake_cpu, operations)
         assert len(operations) == 3
         #
         assert operations[0].opnum == rop.GETFIELD_RAW
@@ -306,7 +305,7 @@
                          descr=array_descr),
             ]
         gc_ll_descr = self.gc_ll_descr
-        gc_ll_descr.rewrite_assembler(self.fake_cpu, None, operations)
+        gc_ll_descr.rewrite_assembler(self.fake_cpu, operations)
         assert len(operations) == 3
         #
         assert operations[0].opnum == rop.GETFIELD_RAW



More information about the Pypy-commit mailing list