1. Pypy
  2. Untitled project
  3. pypy

Commits

Maciej Fijalkowski  committed eeef502

(fijal, arigo) general progress

  • Participants
  • Parent commits b2f02b8
  • Branches incremental-gc

Comments (0)

Files changed (2)

File rpython/memory/gc/incminimark.py

View file
  • Ignore whitespace
         self.max_heap_size_already_raised = False
         self.max_delta = float(r_uint(-1))
         #
+        if card_page_indices != 0:
+            import py
+            py.test.skip("cards unsupported")
         self.card_page_indices = card_page_indices
         if self.card_page_indices > 0:
             self.card_page_shift = 0
             self.move_nursery_top(totalsize)
             return prev_result
         self.minor_collection()
+        self.major_collection_step()
         #
-        if self.get_total_memory_used() > self.next_major_collection_threshold:
-            self.major_collection()
+
+        #
+        # The nursery might not be empty now, because of
+        # execute_finalizers().  If it is almost full again,
+        # we need to fix it with another call to minor_collection().
+        if self.nursery_free + totalsize > self.nursery_top:
             #
-            # The nursery might not be empty now, because of
-            # execute_finalizers().  If it is almost full again,
-            # we need to fix it with another call to minor_collection().
-            if self.nursery_free + totalsize > self.nursery_top:
-                #
-                if self.nursery_free + totalsize > self.nursery_real_top:
-                    self.minor_collection()
-                    # then the nursery is empty
-                else:
-                    # we just need to clean up a bit more of the nursery
-                    self.move_nursery_top(totalsize)
+            if self.nursery_free + totalsize > self.nursery_real_top:
+                self.minor_collection()
+                # then the nursery is empty
+            else:
+                # we just need to clean up a bit more of the nursery
+                self.move_nursery_top(totalsize)
         #
         result = self.nursery_free
         self.nursery_free = result + totalsize
                 self.write_to_visited_object_backward(addr_struct)
     write_barrier_slowpath._dont_inline_ = True
 
-    def write_barrier_from_array(self, newvalue, addr_array, index):
-
-        if self.header(addr_array).tid & GCFLAG_TRACK_YOUNG_PTRS:
-            if self.card_page_indices > 0:     # <- constant-folded
-                self.remember_young_pointer_from_array2(addr_array, index)
-            else:
-                self.remember_young_pointer(addr_array, newvalue)
-
-        if self.gc_state == STATE_MARKING:
-            if self.header(addr_struct).tid & GCFLAG_VISITED:
-                self.write_to_visited_object_backward(addr_struct,newvalue)
-
+    def write_barrier_from_array(self, addr_array, index):
+        if self.header(addr_array).tid & (GCFLAG_TRACK_YOUNG_PTRS |
+                                          GCFLAG_VISITED):
+            self.write_barrier_slowpath(addr_array)
 
     def _init_writebarrier_logic(self):
         DEBUG = self.DEBUG
             self.minor_collection()
             self.major_collection_step()
 
-    def debug_gc_step(self,n=1):
+    def debug_gc_step(self, n=1):
         while n > 0:
             self.minor_collection()
             self.major_collection_step()
 
         debug_stop("gc-collect-step")
 
-    def major_collection(self,reserving_size=0):
+    def major_collection(self, reserving_size=0):
         # For now keep things compatible with the existing GC
         # and do all steps in a loop
 

File rpython/memory/gc/test/test_direct.py

View file
  • Ignore whitespace
         # object shifted by minor collect
         oldhdr = self.gc.header(llmemory.cast_ptr_to_adr(oldobj))
         assert oldhdr.tid & incminimark.GCFLAG_VISITED == 0
-        #process one object
-        self.gc.debug_gc_step()
 
         self.gc.minor_collection()
-        # make sure minor collect doesnt interfere with visited flag on
-        # old object
+        self.gc.visit_all_objects_step(1)
+
         assert oldhdr.tid & incminimark.GCFLAG_VISITED
 
         #at this point the first object should have been processed
         self.write(oldobj,'next',newobj)
         #the barrier should have made the object gray
         newhdr = self.gc.header(llmemory.cast_ptr_to_adr(newobj))
-        assert newhdr.tid & incminimark.GCFLAG_GRAY
+        assert oldhdr.tid & incminimark.GCFLAG_GRAY
+        assert newhdr.tid & (incminimark.GCFLAG_VISITED | incminimark.GCFLAG_GRAY) == 0
         #checks gray object is in objects_to_trace
         self.gc.debug_check_consistency()
 
 
         self.gc.debug_gc_step_until(incminimark.STATE_MARKING)
 
-        #process one object
-        self.gc.debug_gc_step()
+        self.gc.minor_collection()
+        self.gc.visit_all_objects_step(1)
 
         oldobj = self.stackroots[-1]
 
         self.write(oldobj,'next',newobj)
         #the barrier should have made the object gray
         newhdr = self.gc.header(llmemory.cast_ptr_to_adr(newobj))
-        assert newhdr.tid & incminimark.GCFLAG_GRAY
+        assert newhdr.tid & incminimark.GCFLAG_GRAY == 0
+        assert (self.gc.header(llmemory.cast_ptr_to_adr(oldobj)).tid &
+                incminimark.GCFLAG_GRAY)
 
+        assert self.gc.gc_state == incminimark.STATE_MARKING
         # make newobj unreachable again
         self.write(oldobj,'next',oldobj)
 
         self.gc.debug_gc_step_until(incminimark.STATE_SCANNING)
         self.gc.debug_check_consistency()
 
-        # object cant be collected in this case, must be made old.
-        assert newobj.x == 5
-
-        self.gc.debug_gc_step_until(incminimark.STATE_SCANNING)
-
         # now object is collected
         assert py.test.raises(RuntimeError,"newobj.x")
 
             self.stackroots.append(curobj)
             assert self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(curobj))
 
-        reachableroot = curobj
-
         for i in range(5):
             curobj = self.malloc(VAR, largeobj_size)
             self.stackroots.append(curobj)
 
         assert self.gc.gc_state == incminimark.STATE_SCANNING
 
+        self.gc.debug_gc_step()   # this reads self.stackroots
+        reachableroot = self.stackroots[4]
 
         nallocated = {}