[pypy-commit] stmgc default: port the recent changes to c8
Raemi
noreply at buildbot.pypy.org
Mon Mar 30 10:05:55 CEST 2015
Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch:
Changeset: r1743:f6788cf5fb73
Date: 2015-03-30 10:07 +0200
http://bitbucket.org/pypy/stmgc/changeset/f6788cf5fb73/
Log: port the recent changes to c8
diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -2,6 +2,11 @@
# error "must be compiled via stmgc.c"
#endif
+char *stm_object_pages;
+long _stm_segment_nb_pages = NB_PAGES;
+int _stm_nb_segments = NB_SEGMENTS;
+int _stm_psegment_ofs = (int)(uintptr_t)STM_PSEGMENT;
+
/* *** MISC *** */
static void free_bk(struct stm_undo_s *undo)
{
@@ -1127,6 +1132,14 @@
check_nursery_at_transaction_start();
+ /* Change read-version here, because if we do stm_validate in the
+ safe-point below, we should not see our old reads from the last
+ transaction. */
+ uint8_t rv = STM_SEGMENT->transaction_read_version;
+ if (rv < 0xff) /* else, rare (maybe impossible?) case: we did already */
+ rv++; /* incr it but enter_safe_point_if_requested() aborted */
+ STM_SEGMENT->transaction_read_version = rv;
+
/* Warning: this safe-point may run light finalizers and register
commit/abort callbacks if a major GC is triggered here */
enter_safe_point_if_requested();
@@ -1134,9 +1147,7 @@
s_mutex_unlock(); // XXX it's probably possible to not acquire this here
- uint8_t old_rv = STM_SEGMENT->transaction_read_version;
- STM_SEGMENT->transaction_read_version = old_rv + 1;
- if (UNLIKELY(old_rv == 0xff)) {
+ if (UNLIKELY(rv == 0xff)) {
reset_transaction_read_version();
}
diff --git a/c8/stm/core.h b/c8/stm/core.h
--- a/c8/stm/core.h
+++ b/c8/stm/core.h
@@ -222,11 +222,10 @@
static void free_cle(struct stm_commit_log_entry_s *e);
-#ifndef STM_TESTS
-static char *stm_object_pages;
-#else
-char *stm_object_pages;
-#endif
+extern char *stm_object_pages;
+extern long _stm_segment_nb_pages;
+extern int _stm_nb_segments;
+extern int _stm_psegment_ofs;
static stm_thread_local_t *stm_all_thread_locals = NULL;
diff --git a/c8/stm/sync.c b/c8/stm/sync.c
--- a/c8/stm/sync.c
+++ b/c8/stm/sync.c
@@ -103,6 +103,24 @@
/************************************************************/
+void stm_wait_for_current_inevitable_transaction(void)
+{
+ struct stm_commit_log_entry_s *current = STM_PSEGMENT->last_commit_log_entry;
+
+ /* XXX: don't do busy-waiting */
+ while (1) {
+ if (current->next == NULL) {
+ break;
+ } else if (current->next == INEV_RUNNING) {
+ usleep(10);
+ continue;
+ }
+ current = current->next;
+ }
+}
+
+
+
static bool acquire_thread_segment(stm_thread_local_t *tl)
{
/* This function acquires a segment for the currently running thread,
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -304,6 +304,11 @@
void stm_start_inevitable_transaction(stm_thread_local_t *tl);
void stm_commit_transaction(void);
+
+/* Temporary fix? Call this outside a transaction. If there is an
+ inevitable transaction running somewhere else, wait until it finishes. */
+void stm_wait_for_current_inevitable_transaction(void);
+
void stm_abort_transaction(void) __attribute__((noreturn));
void stm_collect(long level);
More information about the pypy-commit
mailing list