Author: Armin Rigo <[email protected]>
Branch: marker
Changeset: r1163:9568cd489776
Date: 2014-04-18 12:06 +0200
http://bitbucket.org/pypy/stmgc/changeset/9568cd489776/
Log: Tweaks, and check with demo2.c that it's usable from C code
diff --git a/c7/demo/demo2.c b/c7/demo/demo2.c
--- a/c7/demo/demo2.c
+++ b/c7/demo/demo2.c
@@ -44,6 +44,14 @@
visit((object_t **)&n->next);
}
+static void expand_marker(uintptr_t odd_number,
+ object_t *following_object,
+ char *outputbuf, size_t outputbufsize)
+{
+ assert(following_object == NULL);
+ snprintf(outputbuf, outputbufsize, "<%lu>", odd_number);
+}
+
nodeptr_t global_chained_list;
@@ -198,8 +206,18 @@
STM_PUSH_ROOT(stm_thread_local, global_chained_list); /* remains forever
in the shadow stack */
+ int loops = 0;
+
while (check_sorted() == -1) {
+
+ STM_PUSH_ROOT(stm_thread_local, (uintptr_t)(2 * loops + 1));
+ STM_PUSH_ROOT(stm_thread_local, NULL);
+
bubble_run();
+
+ STM_POP_ROOT_RET(stm_thread_local);
+ STM_POP_ROOT_RET(stm_thread_local);
+ loops++;
}
STM_POP_ROOT(stm_thread_local, global_chained_list);
@@ -246,6 +264,7 @@
stm_setup();
stm_register_thread_local(&stm_thread_local);
+ stmcb_expand_marker = expand_marker;
setup_list();
diff --git a/c7/stm/marker.c b/c7/stm/marker.c
--- a/c7/stm/marker.c
+++ b/c7/stm/marker.c
@@ -10,7 +10,8 @@
static void marker_fetch_expand(struct stm_priv_segment_info_s *pseg)
{
- pseg->marker_self[0] = 0;
+ if (pseg->marker_self[0] != 0)
+ return; /* already collected an entry */
if (stmcb_expand_marker != NULL) {
stm_thread_local_t *tl = pseg->pub.running_thread;
@@ -22,6 +23,11 @@
/* the stack entry is an odd number */
stmcb_expand_marker(x, current[1].ss,
pseg->marker_self, _STM_MARKER_LEN);
+
+ if (pseg->marker_self[0] == 0) {
+ pseg->marker_self[0] = '?';
+ pseg->marker_self[1] = 0;
+ }
break;
}
}
@@ -40,7 +46,10 @@
earlier than now (some objects may be GCed), but we only know
here the total time it gets attributed.
*/
- tl->longest_marker_state = attribute_to;
- tl->longest_marker_time = time;
- memcpy(tl->longest_marker_self, pseg->marker_self, _STM_MARKER_LEN);
+ if (time * 0.99 > tl->longest_marker_time) {
+ tl->longest_marker_state = attribute_to;
+ tl->longest_marker_time = time;
+ memcpy(tl->longest_marker_self, pseg->marker_self, _STM_MARKER_LEN);
+ }
+ pseg->marker_self[0] = 0;
}
diff --git a/c7/stm/timing.c b/c7/stm/timing.c
--- a/c7/stm/timing.c
+++ b/c7/stm/timing.c
@@ -39,8 +39,7 @@
add_timing(tl, attribute_to, time_this_transaction);
tl->timing[STM_TIME_RUN_CURRENT] = 0.0f;
- if (attribute_to != STM_TIME_RUN_COMMITTED &&
- time_this_transaction * 0.99 > tl->longest_marker_time) {
+ if (attribute_to != STM_TIME_RUN_COMMITTED) {
struct stm_priv_segment_info_s *pseg =
get_priv_segment(STM_SEGMENT->segment_num);
marker_copy(tl, pseg, attribute_to, time_this_transaction);
@@ -81,6 +80,10 @@
fprintf(stderr, " %-24s %9u %8.3f s\n",
timer_names[i], tl->events[i], (double)tl->timing[i]);
}
+ fprintf(stderr, " %-24s %6s %11.6f s\n",
+ "longest recorded marker", "", tl->longest_marker_time);
+ fprintf(stderr, " \"%.*s\"\n",
+ (int)_STM_MARKER_LEN, tl->longest_marker_self);
s_mutex_unlock();
}
}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit