[pypy-commit] stmgc c7-refactor: Rename "stm_current_transaction_t" into "stm_creation_marker_t".
arigo
noreply at buildbot.pypy.org
Fri Feb 14 14:22:28 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r729:508eed0d9371
Date: 2014-02-14 14:22 +0100
http://bitbucket.org/pypy/stmgc/changeset/508eed0d9371/
Log: Rename "stm_current_transaction_t" into "stm_creation_marker_t".
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -18,10 +18,13 @@
#define FIRST_OBJECT_PAGE ((READMARKER_END + 4095) / 4096UL)
#define FIRST_NURSERY_PAGE FIRST_OBJECT_PAGE
#define END_NURSERY_PAGE (FIRST_NURSERY_PAGE + NB_NURSERY_PAGES)
+
#define READMARKER_START ((FIRST_OBJECT_PAGE * 4096UL) >> 4)
#define FIRST_READMARKER_PAGE (READMARKER_START / 4096UL)
#define NB_READMARKER_PAGES (FIRST_OBJECT_PAGE - FIRST_READMARKER_PAGE)
+#define CURTRANS_START ((FIRST_OBJECT_PAGE * 4096UL) >> 8)
+
enum {
/* this flag is not set on most objects. when stm_write() is called
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -17,10 +17,10 @@
/* if objects are larger than this limit but smaller than LARGE_OBJECT,
then they might be allocted outside sections but still in the nursery. */
-#define MEDIUM_OBJECT (9*1024)
+#define MEDIUM_OBJECT (8*1024)
/* size in bytes of the alignment of any section requested */
-#define NURSERY_ALIGNMENT 64
+#define NURSERY_ALIGNMENT 256
/************************************************************/
diff --git a/c7/stm/setup.c b/c7/stm/setup.c
--- a/c7/stm/setup.c
+++ b/c7/stm/setup.c
@@ -21,6 +21,10 @@
assert(READMARKER_START < READMARKER_END);
assert(READMARKER_END <= 4096UL * FIRST_OBJECT_PAGE);
assert(FIRST_OBJECT_PAGE < NB_PAGES);
+ assert(CURTRANS_START >= 8192);
+ assert((NB_PAGES * 4096UL) >> 8 <= (FIRST_OBJECT_PAGE * 4096UL) >> 4);
+ assert((END_NURSERY_PAGE * 4096UL) >> 8 <=
+ (FIRST_READMARKER_PAGE * 4096UL));
stm_object_pages = mmap(NULL, TOTAL_MEMORY,
PROT_READ | PROT_WRITE,
@@ -59,13 +63,19 @@
long time for each page. */
pages_initialize_shared(FIRST_NURSERY_PAGE, NB_NURSERY_PAGES);
+ /* The read markers are initially zero, which is correct:
+ STM_SEGMENT->transaction_read_version never contains zero,
+ so a null read marker means "not read" whatever the
+ current transaction_read_version is.
+
+ The creation markers are initially zero, which is correct:
+ it means "objects of this group of 256 bytes have not been
+ allocated by the current transaction."
+ */
+
setup_sync();
setup_nursery();
setup_gcpage();
-
-#if 0
- stm_largemalloc_init(heap, HEAP_PAGES * 4096UL);
-#endif
}
void stm_teardown(void)
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -33,16 +33,27 @@
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 struct stm_creation_marker_s stm_creation_marker_t;
typedef TLPREFIX char stm_char;
typedef void* stm_jmpbuf_t[5]; /* for use with __builtin_setjmp() */
struct stm_read_marker_s {
+ /* In every segment, every object has a corresponding read marker.
+ We assume that objects are at least 16 bytes long, and use
+ their address divided by 16. The read marker is equal to
+ 'STM_SEGMENT->transaction_read_version' if and only if the
+ object was read in the current transaction. */
uint8_t rm;
};
-struct stm_current_transaction_s {
- uint8_t ct;
+struct stm_creation_marker_s {
+ /* In addition to read markers, every group of 256 bytes has one
+ extra byte, the creation marker, located at the address divided
+ by 256. The creation marker is either 0xff if all objects in
+ this group come have been allocated by the current transaction,
+ or 0x00 if none of them have been. Groups cannot contain a
+ mixture of both. */
+ uint8_t cm;
};
struct stm_segment_info_s {
@@ -125,9 +136,9 @@
{
/* 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 |
+ assuming that 'cm' is either 0 (not created in current transaction)
+ or 0xff (created in current transaction) */
+ if (UNLIKELY(!(((stm_creation_marker_t *)(((uintptr_t)obj) >> 8)->cm |
obj->stm_flags) & _STM_GCFLAG_WRITE_BARRIER_CALLED)))
_stm_write_slowpath(obj);
}
More information about the pypy-commit
mailing list