[pypy-commit] stmgc c7-refactor: Two days to convince myself that this version of stm_write() gives
arigo
noreply at buildbot.pypy.org
Fri Feb 14 14:22:25 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r727:3ddbe9c6d224
Date: 2014-02-13 13:48 +0100
http://bitbucket.org/pypy/stmgc/changeset/3ddbe9c6d224/
Log: Two days to convince myself that this version of stm_write() gives
the best trade-offs
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -24,20 +24,20 @@
enum {
- /* set if the write-barrier slowpath needs to trigger. set on all
- old objects if there was no write-barrier on it in the same
- transaction and no collection inbetween. */
- GCFLAG_WRITE_BARRIER = _STM_GCFLAG_WRITE_BARRIER,
- /* set on objects which are in pages visible to others (SHARED
- or PRIVATE), but not committed yet. So only visible from
- this transaction. */
- //GCFLAG_NOT_COMMITTED = _STM_GCFLAG_WRITE_BARRIER << 1,
+ /* this flag is not set on most objects. when stm_write() is called
+ on an object that is not from the current transaction, then
+ _stm_write_slowpath() is called, and then the flag is set to
+ say "called once already, no need to call again". */
+ GCFLAG_WRITE_BARRIER_CALLED = _STM_GCFLAG_WRITE_BARRIER_CALLED,
+ /* set if the object can be seen by all threads. If unset, we know
+ it is only visible from the current thread. */
+ //GCFLAG_ALL_THREADS = 0x04,
/* only used during collections to mark an obj as moved out of the
generation it was in */
- //GCFLAG_MOVED = _STM_GCFLAG_WRITE_BARRIER << 2,
+ //GCFLAG_MOVED = 0x01,
/* objects smaller than one page and even smaller than
LARGE_OBJECT_WORDS * 8 bytes */
- //GCFLAG_SMALL = _STM_GCFLAG_WRITE_BARRIER << 3,
+ //GCFLAG_SMALL = 0x02,
};
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -33,6 +33,7 @@
typedef TLPREFIX struct object_s object_t;
typedef TLPREFIX struct stm_segment_info_s stm_segment_info_t;
typedef TLPREFIX struct stm_read_marker_s stm_read_marker_t;
+typedef TLPREFIX struct stm_current_transaction_s stm_current_transaction_t;
typedef TLPREFIX char stm_char;
typedef void* stm_jmpbuf_t[5]; /* for use with __builtin_setjmp() */
@@ -40,6 +41,10 @@
uint8_t rm;
};
+struct stm_current_transaction_s {
+ uint8_t ct;
+};
+
struct stm_segment_info_s {
uint8_t transaction_read_version;
int segment_num;
@@ -77,8 +82,8 @@
void _stm_large_dump(void);
#endif
-#define _STM_GCFLAG_WRITE_BARRIER 0x01
-#define STM_FLAGS_PREBUILT _STM_GCFLAG_WRITE_BARRIER
+#define _STM_GCFLAG_WRITE_BARRIER_CALLED 0x80
+#define STM_FLAGS_PREBUILT 0
/* ==================== HELPERS ==================== */
@@ -118,7 +123,12 @@
static inline void stm_write(object_t *obj)
{
- if (UNLIKELY(obj->stm_flags & _STM_GCFLAG_WRITE_BARRIER))
+ /* this is:
+ 'if (ct == 0 && (stm_flags & WRITE_BARRIER_CALLED) == 0)'
+ assuming that 'ct' is either 0 (no, not current transaction)
+ or 0xff (yes) */
+ if (UNLIKELY(!(((stm_current_transaction_t *)(((uintptr_t)obj) >> 8)->ct |
+ obj->stm_flags) & _STM_GCFLAG_WRITE_BARRIER_CALLED)))
_stm_write_slowpath(obj);
}
More information about the pypy-commit
mailing list