[pypy-commit] stmgc marker: Another hook
arigo
noreply at buildbot.pypy.org
Sat Apr 19 21:55:50 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: marker
Changeset: r1170:7660960de054
Date: 2014-04-19 21:26 +0200
http://bitbucket.org/pypy/stmgc/changeset/7660960de054/
Log: Another hook
diff --git a/c7/stm/marker.c b/c7/stm/marker.c
--- a/c7/stm/marker.c
+++ b/c7/stm/marker.c
@@ -7,6 +7,9 @@
object_t *following_object,
char *outputbuf, size_t outputbufsize);
+void (*stmcb_debug_print)(const char *cause, double time,
+ const char *marker);
+
static void marker_fetch_expand(struct stm_priv_segment_info_s *pseg)
{
@@ -55,6 +58,9 @@
earlier than now (some objects may be GCed), but we only know
here the total time it gets attributed.
*/
+ if (stmcb_debug_print) {
+ stmcb_debug_print(timer_names[attribute_to], time, pseg->marker_self);
+ }
if (time * 0.99 > tl->longest_marker_time) {
tl->longest_marker_state = attribute_to;
tl->longest_marker_time = time;
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -381,6 +381,8 @@
extern void (*stmcb_expand_marker)(char *segment_base, uintptr_t odd_number,
object_t *following_object,
char *outputbuf, size_t outputbufsize);
+extern void (*stmcb_debug_print)(const char *cause, double time,
+ const char *marker);
/* Conventience macros to push the markers into the shadowstack */
#define STM_PUSH_MARKER(tl, odd_num, p) do { \
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -126,6 +126,8 @@
void (*stmcb_expand_marker)(char *segment_base, uintptr_t odd_number,
object_t *following_object,
char *outputbuf, size_t outputbufsize);
+void (*stmcb_debug_print)(const char *cause, double time,
+ const char *marker);
void stm_push_marker(stm_thread_local_t *, uintptr_t, object_t *);
void stm_update_marker_num(stm_thread_local_t *, uintptr_t);
@@ -464,6 +466,7 @@
def teardown_method(self, meth):
lib.stmcb_expand_marker = ffi.NULL
+ lib.stmcb_debug_print = ffi.NULL
tl = self.tls[self.current_thread]
if lib._stm_in_transaction(tl) and lib.stm_is_inevitable():
self.commit_transaction() # must succeed!
diff --git a/c7/test/test_marker.py b/c7/test/test_marker.py
--- a/c7/test/test_marker.py
+++ b/c7/test/test_marker.py
@@ -130,3 +130,26 @@
self.push_root(stm_allocate(16))
raw = lib._stm_expand_marker()
assert ffi.string(raw) == '29 %r' % (p,)
+
+ def test_stmcb_debug_print(self):
+ @ffi.callback("void(char *, uintptr_t, object_t *, char *, size_t)")
+ def expand_marker(base, number, ptr, outbuf, outbufsize):
+ s = '<<<%d>>>\x00' % (number,)
+ assert len(s) <= outbufsize
+ outbuf[0:len(s)] = s
+ @ffi.callback("void(char *, double, char *)")
+ def debug_print(cause, time, marker):
+ if 0.0 < time < 1.0:
+ time = "time_ok"
+ seen.append((ffi.string(cause), time, ffi.string(marker)))
+ seen = []
+ lib.stmcb_expand_marker = expand_marker
+ lib.stmcb_debug_print = debug_print
+ #
+ self.start_transaction()
+ p = stm_allocate(16)
+ self.push_root(ffi.cast("object_t *", 29))
+ self.push_root(p)
+ self.abort_transaction()
+ #
+ assert seen == [("run aborted other", "time_ok", "<<<29>>>")]
More information about the pypy-commit
mailing list