[pypy-commit] pypy gc-del-3: fix

2016-05-04 Thread arigo
Author: Armin Rigo 
Branch: gc-del-3
Changeset: r84195:a495ce740059
Date: 2016-05-04 18:50 +0200
http://bitbucket.org/pypy/pypy/changeset/a495ce740059/

Log:fix

diff --git a/rpython/memory/gc/minimark.py b/rpython/memory/gc/minimark.py
--- a/rpython/memory/gc/minimark.py
+++ b/rpython/memory/gc/minimark.py
@@ -561,8 +561,6 @@
 # Build the object.
 llarena.arena_reserve(result, totalsize)
 obj = result + size_gc_header
-if is_finalizer_light:
-self.young_objects_with_light_finalizers.append(obj)
 self.init_gc_object(result, typeid, flags=0)
 #
 # If it is a weakref or has a lightweight destructor, record it
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy gc-del-3: fix the XXXXXX

2016-05-03 Thread arigo
Author: Armin Rigo 
Branch: gc-del-3
Changeset: r84178:3502aa349b77
Date: 2016-05-03 21:50 +0200
http://bitbucket.org/pypy/pypy/changeset/3502aa349b77/

Log:fix the XX

diff --git a/rpython/memory/gc/base.py b/rpython/memory/gc/base.py
--- a/rpython/memory/gc/base.py
+++ b/rpython/memory/gc/base.py
@@ -33,30 +33,26 @@
 self.config = config
 assert isinstance(translated_to_c, bool)
 self.translated_to_c = translated_to_c
+self._finalizer_queue_objects = []
 
 def setup(self):
 # all runtime mutable values' setup should happen here
 # and in its overriden versions! for the benefit of test_transformed_gc
 self.finalizer_lock = False
-if we_are_translated():
-XX
-else:
-self._finalizer_queue_objects = []# XXX FIX ME
 
 def register_finalizer_index(self, fq, index):
+"NOT_RPYTHON"
 while len(self._finalizer_queue_objects) <= index:
 self._finalizer_queue_objects.append(None)
 if self._finalizer_queue_objects[index] is None:
 fq._reset()
+fq._gc_deque = self.AddressDeque()
 self._finalizer_queue_objects[index] = fq
 else:
 assert self._finalizer_queue_objects[index] is fq
 
-def add_finalizer_to_run(self, fq_index, obj):
-if we_are_translated():
-XX
-else:
-self._finalizer_queue_objects[fq_index]._queue.append(obj)
+def mark_finalizer_to_run(self, fq_index, obj):
+self._finalizer_queue_objects[fq_index]._gc_deque.append(obj)
 
 def post_setup(self):
 # More stuff that needs to be initialized when the GC is already
@@ -65,7 +61,7 @@
 self.DEBUG = env.read_from_env('PYPY_GC_DEBUG')
 
 def _teardown(self):
-pass
+self._finalizer_queue_objects = [] # for tests
 
 def can_optimize_clean_setarrayitems(self):
 return True # False in case of card marking
@@ -345,11 +341,12 @@
 enumerate_all_roots._annspecialcase_ = 'specialize:arg(1)'
 
 def enum_pending_finalizers(self, callback, arg):
-if we_are_translated():
-XX#. foreach(callback, arg)
-for fq in self._finalizer_queue_objects:
-for obj in fq._queue:
-callback(obj, arg)
+i = 0
+while i < len(self._finalizer_queue_objects):
+fq = self._finalizer_queue_objects[i]
+if fq is not None:
+fq._gc_deque.foreach(callback, arg)
+i += 1
 enum_pending_finalizers._annspecialcase_ = 'specialize:arg(1)'
 
 def debug_check_consistency(self):
@@ -395,11 +392,12 @@
 return  # the outer invocation of execute_finalizers() will do it
 self.finalizer_lock = True
 try:
-if we_are_translated():
-XX
-for i, fq in enumerate(self._finalizer_queue_objects):
-if len(fq._queue) > 0:
+i = 0
+while i < len(self._finalizer_queue_objects):
+fq = self._finalizer_queue_objects[i]
+if fq is not None and fq._gc_deque.non_empty():
 self.finalizer_trigger(i)
+i += 1
 finally:
 self.finalizer_lock = False
 
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -2679,7 +2679,7 @@
 if state == 2:
 from rpython.rtyper.lltypesystem import rffi
 fq_index = rffi.cast(lltype.Signed, fq_nr)
-self.add_finalizer_to_run(fq_index, x)
+self.mark_finalizer_to_run(fq_index, x)
 # we must also fix the state from 2 to 3 here, otherwise
 # we leave the GCFLAG_FINALIZATION_ORDERING bit behind
 # which will confuse the next collection
diff --git a/rpython/memory/gcwrapper.py b/rpython/memory/gcwrapper.py
--- a/rpython/memory/gcwrapper.py
+++ b/rpython/memory/gcwrapper.py
@@ -215,8 +215,9 @@
 
 def gc_fq_next_dead(self, fq_tag):
 fq, _ = self.get_finalizer_queue_index(fq_tag)
-addr = fq.next_dead()
-if addr is None:
+if fq._gc_deque.non_empty():
+addr = fq._gc_deque.popleft()
+else:
 addr = llmemory.NULL
 return llmemory.cast_adr_to_ptr(addr, rclass.OBJECTPTR)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy gc-del-3: fix

2016-05-03 Thread arigo
Author: Armin Rigo 
Branch: gc-del-3
Changeset: r84180:83a6a474a555
Date: 2016-05-03 22:51 +0200
http://bitbucket.org/pypy/pypy/changeset/83a6a474a555/

Log:fix

diff --git a/rpython/memory/gcwrapper.py b/rpython/memory/gcwrapper.py
--- a/rpython/memory/gcwrapper.py
+++ b/rpython/memory/gcwrapper.py
@@ -211,17 +211,17 @@
 assert index == len(self.finalizer_queues)
 self.finalizer_queue_indexes[fq] = index
 self.finalizer_queues.append(fq)
-return (fq, index)
+self.gc.register_finalizer_index(fq, index)
+return index
 
 def gc_fq_next_dead(self, fq_tag):
-fq, index = self.get_finalizer_queue_index(fq_tag)
+index = self.get_finalizer_queue_index(fq_tag)
 return lltype.cast_opaque_ptr(rclass.OBJECTPTR,
   self.gc.finalizer_next_dead(index))
 
 def gc_fq_register(self, fq_tag, ptr):
-fq, index = self.get_finalizer_queue_index(fq_tag)
+index = self.get_finalizer_queue_index(fq_tag)
 ptr = lltype.cast_opaque_ptr(llmemory.GCREF, ptr)
-self.gc.register_finalizer_index(fq, index)
 self.gc.register_finalizer(index, ptr)
 
 # 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit