Author: Remi Meier <[email protected]>
Branch: stmgc-c8
Changeset: r76347:06bd5b7e134d
Date: 2015-03-12 09:30 +0100
http://bitbucket.org/pypy/pypy/changeset/06bd5b7e134d/
Log: import stmgc w/o nursery zeroing
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 @@
-a4e4d3ad014a
+b548b42c978e+
diff --git a/rpython/translator/stm/src_stm/stm/core.c
b/rpython/translator/stm/src_stm/stm/core.c
--- a/rpython/translator/stm/src_stm/stm/core.c
+++ b/rpython/translator/stm/src_stm/stm/core.c
@@ -862,6 +862,31 @@
}
+static void touch_all_pages_of_obj(object_t *obj, size_t obj_size)
+{
+ int my_segnum = STM_SEGMENT->segment_num;
+ uintptr_t end_page, first_page = ((uintptr_t)obj) / 4096UL;
+
+ /* get the last page containing data from the object */
+ if (LIKELY(is_small_uniform(obj))) {
+ end_page = first_page;
+ } else {
+ end_page = (((uintptr_t)obj) + obj_size - 1) / 4096UL;
+ }
+
+ acquire_privatization_lock(STM_SEGMENT->segment_num);
+ uintptr_t page;
+ for (page = first_page; page <= end_page; page++) {
+ if (get_page_status_in(my_segnum, page) == PAGE_NO_ACCESS) {
+ release_privatization_lock(STM_SEGMENT->segment_num);
+ volatile char *dummy = REAL_ADDRESS(STM_SEGMENT->segment_base,
page * 4096UL);
+ *dummy; /* force segfault */
+ acquire_privatization_lock(STM_SEGMENT->segment_num);
+ }
+ }
+ release_privatization_lock(STM_SEGMENT->segment_num);
+}
+
__attribute__((always_inline))
static void write_slowpath_common(object_t *obj, bool mark_card)
{
@@ -888,29 +913,10 @@
the full obj in this segment (XXX) */
char *realobj;
size_t obj_size;
- int my_segnum = STM_SEGMENT->segment_num;
- uintptr_t end_page, first_page = ((uintptr_t)obj) / 4096UL;
-
realobj = REAL_ADDRESS(STM_SEGMENT->segment_base, obj);
obj_size = stmcb_size_rounded_up((struct object_s *)realobj);
- /* get the last page containing data from the object */
- if (LIKELY(is_small_uniform(obj))) {
- end_page = first_page;
- } else {
- end_page = (((uintptr_t)obj) + obj_size - 1) / 4096UL;
- }
- acquire_privatization_lock(STM_SEGMENT->segment_num);
- uintptr_t page;
- for (page = first_page; page <= end_page; page++) {
- if (get_page_status_in(my_segnum, page) == PAGE_NO_ACCESS) {
- release_privatization_lock(STM_SEGMENT->segment_num);
- volatile char *dummy = REAL_ADDRESS(STM_SEGMENT->segment_base,
page * 4096UL);
- *dummy; /* force segfault */
- acquire_privatization_lock(STM_SEGMENT->segment_num);
- }
- }
- release_privatization_lock(STM_SEGMENT->segment_num);
+ touch_all_pages_of_obj(obj, obj_size);
}
if (mark_card) {
diff --git a/rpython/translator/stm/src_stm/stm/core.h
b/rpython/translator/stm/src_stm/stm/core.h
--- a/rpython/translator/stm/src_stm/stm/core.h
+++ b/rpython/translator/stm/src_stm/stm/core.h
@@ -278,6 +278,8 @@
static stm_thread_local_t *abort_with_mutex_no_longjmp(void);
static void abort_data_structures_from_segment_num(int segment_num);
+static void touch_all_pages_of_obj(object_t *obj, size_t obj_size);
+
static void synchronize_object_enqueue(object_t *obj);
static void synchronize_objects_flush(void);
diff --git a/rpython/translator/stm/src_stm/stm/nursery.c
b/rpython/translator/stm/src_stm/stm/nursery.c
--- a/rpython/translator/stm/src_stm/stm/nursery.c
+++ b/rpython/translator/stm/src_stm/stm/nursery.c
@@ -451,11 +451,8 @@
#undef STM_PSEGMENT
#undef STM_SEGMENT
dprintf(("throw_away_nursery\n"));
- /* reset the nursery by zeroing it */
+
size_t nursery_used;
- char *realnursery;
-
- realnursery = REAL_ADDRESS(pseg->pub.segment_base, _stm_nursery_start);
nursery_used = pseg->pub.nursery_current - (stm_char *)_stm_nursery_start;
if (nursery_used > NB_NURSERY_PAGES * 4096) {
/* possible in rare cases when the program artificially advances
@@ -463,11 +460,18 @@
nursery_used = NB_NURSERY_PAGES * 4096;
}
OPT_ASSERT((nursery_used & 7) == 0);
+
+
+#if _STM_NURSERY_ZEROED
+ /* reset the nursery by zeroing it */
+ char *realnursery;
+ realnursery = REAL_ADDRESS(pseg->pub.segment_base, _stm_nursery_start);
memset(realnursery, 0, nursery_used);
/* assert that the rest of the nursery still contains only zeroes */
assert_memset_zero(realnursery + nursery_used,
(NURSERY_END - _stm_nursery_start) - nursery_used);
+#endif
pseg->pub.nursery_current = (stm_char *)_stm_nursery_start;
@@ -601,6 +605,9 @@
stm_char *end = p + size_rounded_up;
if ((uintptr_t)end <= NURSERY_END) {
STM_SEGMENT->nursery_current = end;
+#if !_STM_NURSERY_ZEROED
+ ((object_t *)p)->stm_flags = 0;
+#endif
return (object_t *)p;
}
@@ -626,7 +633,14 @@
tree_insert(STM_PSEGMENT->young_outside_nursery, (uintptr_t)o, 0);
+#if _STM_NURSERY_ZEROED
memset(REAL_ADDRESS(STM_SEGMENT->segment_base, o), 0, size_rounded_up);
+#else
+ o->stm_flags = 0;
+ /* make all pages of 'o' accessible as synchronize_obj_flush() in minor
+ collections assumes all young objs are fully accessible. */
+ touch_all_pages_of_obj(o, size_rounded_up);
+#endif
return o;
}
@@ -646,6 +660,7 @@
}
#endif
+__attribute__((unused))
static void assert_memset_zero(void *s, size_t n)
{
#ifndef NDEBUG
@@ -662,9 +677,12 @@
static void check_nursery_at_transaction_start(void)
{
assert((uintptr_t)STM_SEGMENT->nursery_current == _stm_nursery_start);
+
+#if _STM_NURSERY_ZEROED
assert_memset_zero(REAL_ADDRESS(STM_SEGMENT->segment_base,
STM_SEGMENT->nursery_current),
NURSERY_END - _stm_nursery_start);
+#endif
}
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
@@ -73,6 +73,10 @@
void *creating_pthread[2];
} stm_thread_local_t;
+#ifndef _STM_NURSERY_ZEROED
+#define _STM_NURSERY_ZEROED 0
+#endif
+
#define _STM_GCFLAG_WRITE_BARRIER 0x01
#define _STM_FAST_ALLOC (66*1024)
#define _STM_NSE_SIGNAL_ABORT 1
@@ -254,6 +258,9 @@
if (UNLIKELY((uintptr_t)end > STM_SEGMENT->nursery_end))
return _stm_allocate_slowpath(size_rounded_up);
+#if !_STM_NURSERY_ZEROED
+ ((object_t *)p)->stm_flags = 0;
+#endif
return (object_t *)p;
}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit