[pypy-commit] stmgc cl-collector-thread: move some commit log things to separate files
Raemi
noreply at buildbot.pypy.org
Mon Mar 9 15:56:27 CET 2015
Author: Remi Meier <remi.meier at gmail.com>
Branch: cl-collector-thread
Changeset: r1707:6f9eed8aeaa2
Date: 2015-03-09 13:35 +0100
http://bitbucket.org/pypy/stmgc/changeset/6f9eed8aeaa2/
Log: move some commit log things to separate files
diff --git a/c8/stm/commitlog.c b/c8/stm/commitlog.c
new file mode 100644
--- /dev/null
+++ b/c8/stm/commitlog.c
@@ -0,0 +1,55 @@
+#ifndef _STM_CORE_H_
+# error "must be compiled via stmgc.c"
+#endif
+
+
+static void free_bk(struct stm_undo_s *undo)
+{
+ free(undo->backup);
+ assert(undo->backup = (char*)-88);
+ increment_total_allocated(-SLICE_SIZE(undo->slice));
+}
+
+static struct stm_commit_log_entry_s *malloc_cle(long entries)
+{
+ size_t byte_len = sizeof(struct stm_commit_log_entry_s) +
+ entries * sizeof(struct stm_undo_s);
+ struct stm_commit_log_entry_s *result = malloc(byte_len);
+ increment_total_allocated(byte_len);
+ return result;
+}
+
+static void free_cle(struct stm_commit_log_entry_s *e)
+{
+ size_t byte_len = sizeof(struct stm_commit_log_entry_s) +
+ e->written_count * sizeof(struct stm_undo_s);
+ increment_total_allocated(-byte_len);
+ free(e);
+}
+
+
+void _dbg_print_commit_log()
+{
+ struct stm_commit_log_entry_s *cl = &commit_log_root;
+
+ fprintf(stderr, "commit log:\n");
+ while (cl) {
+ fprintf(stderr, " entry at %p: seg %d, rev %lu\n", cl, cl->segment_num, cl->rev_num);
+ struct stm_undo_s *undo = cl->written;
+ struct stm_undo_s *end = undo + cl->written_count;
+ for (; undo < end; undo++) {
+ fprintf(stderr, " obj %p, size %d, ofs %lu: ", undo->object,
+ SLICE_SIZE(undo->slice), SLICE_OFFSET(undo->slice));
+ /* long i; */
+ /* for (i=0; i<SLICE_SIZE(undo->slice); i += 8) */
+ /* fprintf(stderr, " 0x%016lx", *(long *)(undo->backup + i)); */
+ fprintf(stderr, "\n");
+ }
+
+ cl = cl->next;
+ if (cl == INEV_RUNNING) {
+ fprintf(stderr, " INEVITABLE\n");
+ return;
+ }
+ }
+}
diff --git a/c8/stm/commitlog.h b/c8/stm/commitlog.h
new file mode 100644
--- /dev/null
+++ b/c8/stm/commitlog.h
@@ -0,0 +1,40 @@
+
+
+/* Commit Log things */
+struct stm_undo_s {
+ object_t *object; /* the object that is modified */
+ char *backup; /* some backup data (a slice of the original obj) */
+ uint64_t slice; /* location and size of this slice (cannot cross
+ pages). The size is in the lower 2 bytes, and
+ the offset in the remaining 6 bytes. */
+};
+#define SLICE_OFFSET(slice) ((slice) >> 16)
+#define SLICE_SIZE(slice) ((int)((slice) & 0xFFFF))
+#define NEW_SLICE(offset, size) (((uint64_t)(offset)) << 16 | (size))
+
+
+
+/* The model is: we have a global chained list, from 'commit_log_root',
+ of 'struct stm_commit_log_entry_s' entries. Every one is fully
+ read-only apart from the 'next' field. Every one stands for one
+ commit that occurred. It lists the old objects that were modified
+ in this commit, and their attached "undo logs" --- that is, the
+ data from 'written[n].backup' is the content of (slices of) the
+ object as they were *before* that commit occurred.
+*/
+#define INEV_RUNNING ((void*)-1)
+struct stm_commit_log_entry_s {
+ struct stm_commit_log_entry_s *volatile next;
+ int segment_num;
+ uint64_t rev_num;
+ size_t written_count;
+ struct stm_undo_s written[];
+};
+static struct stm_commit_log_entry_s commit_log_root;
+
+
+static void free_bk(struct stm_undo_s *undo);
+static struct stm_commit_log_entry_s *malloc_cle(long entries);
+static void free_cle(struct stm_commit_log_entry_s *e);
+
+void _dbg_print_commit_log();
diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -2,31 +2,6 @@
# error "must be compiled via stmgc.c"
#endif
-/* *** MISC *** */
-static void free_bk(struct stm_undo_s *undo)
-{
- free(undo->backup);
- assert(undo->backup = (char*)-88);
- increment_total_allocated(-SLICE_SIZE(undo->slice));
-}
-
-static struct stm_commit_log_entry_s *malloc_cle(long entries)
-{
- size_t byte_len = sizeof(struct stm_commit_log_entry_s) +
- entries * sizeof(struct stm_undo_s);
- struct stm_commit_log_entry_s *result = malloc(byte_len);
- increment_total_allocated(byte_len);
- return result;
-}
-
-static void free_cle(struct stm_commit_log_entry_s *e)
-{
- size_t byte_len = sizeof(struct stm_commit_log_entry_s) +
- e->written_count * sizeof(struct stm_undo_s);
- increment_total_allocated(-byte_len);
- free(e);
-}
-/* *** MISC *** */
/* General helper: copies objects into our own segment, from some
@@ -259,31 +234,6 @@
/* ############# commit log ############# */
-void _dbg_print_commit_log()
-{
- struct stm_commit_log_entry_s *cl = &commit_log_root;
-
- fprintf(stderr, "commit log:\n");
- while (cl) {
- fprintf(stderr, " entry at %p: seg %d, rev %lu\n", cl, cl->segment_num, cl->rev_num);
- struct stm_undo_s *undo = cl->written;
- struct stm_undo_s *end = undo + cl->written_count;
- for (; undo < end; undo++) {
- fprintf(stderr, " obj %p, size %d, ofs %lu: ", undo->object,
- SLICE_SIZE(undo->slice), SLICE_OFFSET(undo->slice));
- /* long i; */
- /* for (i=0; i<SLICE_SIZE(undo->slice); i += 8) */
- /* fprintf(stderr, " 0x%016lx", *(long *)(undo->backup + i)); */
- fprintf(stderr, "\n");
- }
-
- cl = cl->next;
- if (cl == INEV_RUNNING) {
- fprintf(stderr, " INEVITABLE\n");
- return;
- }
- }
-}
static void reset_modified_from_backup_copies(int segment_num); /* forward */
diff --git a/c8/stm/core.h b/c8/stm/core.h
--- a/c8/stm/core.h
+++ b/c8/stm/core.h
@@ -172,43 +172,9 @@
TS_INEVITABLE,
};
-/* Commit Log things */
-struct stm_undo_s {
- object_t *object; /* the object that is modified */
- char *backup; /* some backup data (a slice of the original obj) */
- uint64_t slice; /* location and size of this slice (cannot cross
- pages). The size is in the lower 2 bytes, and
- the offset in the remaining 6 bytes. */
-};
-#define SLICE_OFFSET(slice) ((slice) >> 16)
-#define SLICE_SIZE(slice) ((int)((slice) & 0xFFFF))
-#define NEW_SLICE(offset, size) (((uint64_t)(offset)) << 16 | (size))
-/* The model is: we have a global chained list, from 'commit_log_root',
- of 'struct stm_commit_log_entry_s' entries. Every one is fully
- read-only apart from the 'next' field. Every one stands for one
- commit that occurred. It lists the old objects that were modified
- in this commit, and their attached "undo logs" --- that is, the
- data from 'written[n].backup' is the content of (slices of) the
- object as they were *before* that commit occurred.
-*/
-#define INEV_RUNNING ((void*)-1)
-struct stm_commit_log_entry_s {
- struct stm_commit_log_entry_s *volatile next;
- int segment_num;
- uint64_t rev_num;
- size_t written_count;
- struct stm_undo_s written[];
-};
-static struct stm_commit_log_entry_s commit_log_root;
-
-
-static void free_bk(struct stm_undo_s *undo);
-static struct stm_commit_log_entry_s *malloc_cle(long entries);
-static void free_cle(struct stm_commit_log_entry_s *e);
-
#ifndef STM_TESTS
static char *stm_object_pages;
diff --git a/c8/stmgc.c b/c8/stmgc.c
--- a/c8/stmgc.c
+++ b/c8/stmgc.c
@@ -3,6 +3,7 @@
#include "stm/atomic.h"
#include "stm/list.h"
#include "stm/smallmalloc.h"
+#include "stm/commitlog.h"
#include "stm/core.h"
#include "stm/pagecopy.h"
#include "stm/pages.h"
@@ -20,6 +21,7 @@
#include "stm/misc.c"
#include "stm/list.c"
#include "stm/smallmalloc.c"
+#include "stm/commitlog.c"
#include "stm/pagecopy.c"
#include "stm/pages.c"
#include "stm/prebuilt.c"
More information about the pypy-commit
mailing list