Author: Remi Meier <[email protected]>
Branch: stmgc-c4
Changeset: r65811:200e28316921
Date: 2013-07-30 09:42 +0200
http://bitbucket.org/pypy/pypy/changeset/200e28316921/
Log: fix problem in zrpy_gc_test.py (we need to break the transaction in
order to free all possible weakref'ed objects)
diff --git a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
--- a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
+++ b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
@@ -38,12 +38,23 @@
name = args[1]
if argc > 2:
n = int(args[2])
+
r_list = []
for i in range(20):
r = g(name, n)
r_list.append(r)
rgc.collect()
+
+ if rgc.stm_is_enabled():
+ from rpython.rlib import rstm
+ # this breaks the transaction. necessary to make possible
+ # weak-reffed private_from_protected objects non-private
+ # and thereby non-reffed (remove them from some list)
+ rstm.before_external_call()
+ rstm.after_external_call()
+
rgc.collect(); rgc.collect()
+
freed = 0
for i, r in enumerate(r_list):
if r() is None:
@@ -51,6 +62,7 @@
else:
print "not freed:", r(), "pos:", i
print freed
+
return 0
return entrypoint
diff --git a/rpython/translator/stm/src_stm/revision
b/rpython/translator/stm/src_stm/revision
--- a/rpython/translator/stm/src_stm/revision
+++ b/rpython/translator/stm/src_stm/revision
@@ -1,1 +1,1 @@
-c528da482152
+0ebfd6dd4f46
diff --git a/rpython/translator/stm/src_stm/stmgc.h
b/rpython/translator/stm/src_stm/stmgc.h
--- a/rpython/translator/stm/src_stm/stmgc.h
+++ b/rpython/translator/stm/src_stm/stmgc.h
@@ -70,8 +70,10 @@
do stm_write_barrier() again if we ended the transaction, or
if we did a potential collection (e.g. stm_allocate()).
*/
-static inline gcptr stm_read_barrier(gcptr);
-static inline gcptr stm_write_barrier(gcptr);
+#if 0 // (optimized version below)
+gcptr stm_read_barrier(gcptr);
+gcptr stm_write_barrier(gcptr);
+#endif
/* start a new transaction, calls callback(), and when it returns
finish that transaction. callback() is called with the 'arg'
@@ -140,16 +142,12 @@
/************************************************************/
-/* macro-like functionality */
+/* macro functionality */
extern __thread gcptr *stm_shadowstack;
-static inline void stm_push_root(gcptr obj) {
- *stm_shadowstack++ = obj;
-}
-static inline gcptr stm_pop_root(void) {
- return *--stm_shadowstack;
-}
+#define stm_push_root(obj) (*stm_shadowstack++ = (obj))
+#define stm_pop_root() (*--stm_shadowstack)
extern __thread revision_t stm_private_rev_num;
gcptr stm_DirectReadBarrier(gcptr);
@@ -161,21 +159,18 @@
(*(gcptr *)(stm_read_barrier_cache + ((revision_t)(obj) & FX_MASK)))
#define UNLIKELY(test) __builtin_expect(test, 0)
-static inline gcptr stm_read_barrier(gcptr obj) {
- /* XXX optimize to get the smallest code */
- if (UNLIKELY((obj->h_revision != stm_private_rev_num) &&
- (FXCACHE_AT(obj) != obj)))
- obj = stm_DirectReadBarrier(obj);
- return obj;
-}
-static inline gcptr stm_write_barrier(gcptr obj) {
- if (UNLIKELY((obj->h_revision != stm_private_rev_num) |
- ((obj->h_tid & GCFLAG_WRITE_BARRIER) != 0)))
- obj = stm_WriteBarrier(obj);
- return obj;
-}
-#undef UNLIKELY
+#define stm_read_barrier(obj) \
+ (UNLIKELY(((obj)->h_revision != stm_private_rev_num) && \
+ (FXCACHE_AT(obj) != (obj))) ? \
+ stm_DirectReadBarrier(obj) \
+ : (obj))
+
+#define stm_write_barrier(obj) \
+ (UNLIKELY(((obj)->h_revision != stm_private_rev_num) || \
+ (((obj)->h_tid & GCFLAG_WRITE_BARRIER) != 0)) ? \
+ stm_WriteBarrier(obj) \
+ : (obj))
#endif
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit