Author: Armin Rigo <[email protected]>
Branch: object-dtype2
Changeset: r76647:99280110fed2
Date: 2015-03-30 20:06 +0200
http://bitbucket.org/pypy/pypy/changeset/99280110fed2/
Log: In-progress: define and use rgc.ll_writebarrier() where needed
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1649,14 +1649,18 @@
return boxes.W_ObjectBox(w_item)
def store(self, arr, i, offset, box):
- self._write(arr.storage, i, offset, self.unbox(box))
+ self._write(arr.storage, i, offset, self.unbox(box),
+ arr.gcstruct)
def read(self, arr, i, offset, dtype=None):
return self.box(self._read(arr.storage, i, offset))
@jit.dont_look_inside
- def _write(self, storage, i, offset, w_obj):
+ def _write(self, storage, i, offset, w_obj, gcstruct):
+ # no GC anywhere in this function!
if we_are_translated():
+ from rpython.rlib import rgc
+ rgc.ll_writebarrier(gcstruct)
value = rffi.cast(lltype.Signed, cast_instance_to_gcref(w_obj))
else:
value = len(_all_objs_for_tests)
@@ -1676,7 +1680,7 @@
def fill(self, storage, width, box, start, stop, offset):
value = self.unbox(box)
for i in xrange(start, stop, width):
- self._write(storage, i, offset, value)
+ self._write(storage, i, offset, value, XXX)
def unbox(self, box):
assert isinstance(box, self.BoxType)
diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -681,6 +681,14 @@
call, for internal reasons.
"""
[email protected]()
+def ll_writebarrier(gc_obj):
+ """Use together with custom tracers. When you update some object pointer
+ stored in raw memory, you must call this function on 'gc_obj', which must
+ be the object of type TP with the custom tracer (*not* the value stored!).
+ This makes sure that the custom hook will be called again."""
+ llop.gc_writebarrier(lltype.Void, gc_obj)
+
class RegisterGcTraceEntry(ExtRegistryEntry):
_about_ = register_custom_trace_hook
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit