[pypy-svn] r47612 - pypy/dist/pypy/rpython/memory/gc

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Oct 19 22:58:47 CEST 2007


Author: cfbolz
Date: Fri Oct 19 22:58:46 2007
New Revision: 47612

Modified:
   pypy/dist/pypy/rpython/memory/gc/generation.py
   pypy/dist/pypy/rpython/memory/gc/semispace.py
Log:
consistently use a method to get the type id. makes it possible to introduce
flag bits in the type it field later.


Modified: pypy/dist/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc/generation.py	(original)
+++ pypy/dist/pypy/rpython/memory/gc/generation.py	Fri Oct 19 22:58:46 2007
@@ -171,8 +171,7 @@
         """obj must not be in the nursery.  This copies all the
         young objects it references out of the nursery.
         """
-        gc_info = self.header(obj)
-        typeid = gc_info.typeid
+        typeid = self.get_type_id(obj)
         offsets = self.offsets_to_gc_pointers(typeid)
         i = 0
         while i < len(offsets):

Modified: pypy/dist/pypy/rpython/memory/gc/semispace.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc/semispace.py	(original)
+++ pypy/dist/pypy/rpython/memory/gc/semispace.py	Fri Oct 19 22:58:46 2007
@@ -227,8 +227,7 @@
             return newobj
 
     def trace_and_copy(self, obj):
-        gc_info = self.header(obj)
-        typeid = gc_info.typeid
+        typeid = self.get_type_id(obj)
         offsets = self.offsets_to_gc_pointers(typeid)
         i = 0
         while i < len(offsets):
@@ -264,7 +263,7 @@
         gc_info.forw = newobj
 
     def get_size(self, obj):
-        typeid = self.header(obj).typeid
+        typeid = self.get_type_id(obj)
         size = self.fixed_size(typeid)
         if self.is_varsize(typeid):
             lenaddr = obj + self.varsize_offset_to_length(typeid)
@@ -277,6 +276,9 @@
         addr -= self.gcheaderbuilder.size_gc_header
         return llmemory.cast_adr_to_ptr(addr, lltype.Ptr(self.HDR))
 
+    def get_type_id(self, addr):
+        return self.header(addr).typeid
+
     def init_gc_object(self, addr, typeid):
         hdr = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(self.HDR))
         #hdr.forw = NULL   -- unneeded, the space is initially filled with zero
@@ -340,6 +342,7 @@
         self.finalizer_lock_count = 1
         try:
             while self.run_finalizers.non_empty():
+                #print "finalizer"
                 obj = self.run_finalizers.pop()
                 hdr = self.header(obj)
                 finalizer = self.getfinalizer(hdr.typeid)



More information about the Pypy-commit mailing list