[pypy-commit] pypy stmgc-c7: Print the thread-local stm statistics also for the main thread when

arigo noreply at buildbot.pypy.org
Tue May 27 18:14:09 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r71742:a4b2331aad16
Date: 2014-05-27 18:13 +0200
http://bitbucket.org/pypy/pypy/changeset/a4b2331aad16/

Log:	Print the thread-local stm statistics also for the main thread when
	it finishes.

diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -819,6 +819,12 @@
                 print >> f, '\t'+line
     print >> f, '\treturn error;'
     print >> f, '}'
+    print >> f
+    # also generate the tear-down code (empty except for stm statistics)
+    print >> f, 'void RPython_TeardownCode(void) {'
+    if database.with_stm:
+        print >> f, '\tpypy_stm_teardown();'
+    print >> f, '}'
 
 def gen_stm_prebuilt(f, database):
     from rpython.translator.c.primitive import name_signed
diff --git a/rpython/translator/c/src/entrypoint.c b/rpython/translator/c/src/entrypoint.c
--- a/rpython/translator/c/src/entrypoint.c
+++ b/rpython/translator/c/src/entrypoint.c
@@ -60,6 +60,7 @@
 
     pypy_malloc_counters_results();
 
+    RPython_TeardownCode();
     return exitcode;
 
  memory_out:
diff --git a/rpython/translator/c/src/entrypoint.h b/rpython/translator/c/src/entrypoint.h
--- a/rpython/translator/c/src/entrypoint.h
+++ b/rpython/translator/c/src/entrypoint.h
@@ -9,5 +9,6 @@
 #endif
 
 char *RPython_StartupCode(void);
+void RPython_TeardownCode(void);
 int PYPY_MAIN_FUNCTION(int argc, char *argv[]);
 #endif  /* PYPY_STANDALONE */
diff --git a/rpython/translator/stm/src_stm/stmgcintf.c b/rpython/translator/stm/src_stm/stmgcintf.c
--- a/rpython/translator/stm/src_stm/stmgcintf.c
+++ b/rpython/translator/stm/src_stm/stmgcintf.c
@@ -71,6 +71,12 @@
     pypy_stm_start_inevitable_if_not_atomic();
 }
 
+void pypy_stm_teardown(void)
+{
+    pypy_stm_unregister_thread_local();
+    /* stm_teardown() not called here for now; it's mostly for tests */
+}
+
 long pypy_stm_enter_callback_call(void)
 {
     if (pypy_stm_ready_atomic == 0) {
diff --git a/rpython/translator/stm/src_stm/stmgcintf.h b/rpython/translator/stm/src_stm/stmgcintf.h
--- a/rpython/translator/stm/src_stm/stmgcintf.h
+++ b/rpython/translator/stm/src_stm/stmgcintf.h
@@ -19,6 +19,7 @@
 */
 
 void pypy_stm_setup(void);
+void pypy_stm_teardown(void);
 void pypy_stm_setup_prebuilt(void);        /* generated into stm_prebuilt.c */
 void pypy_stm_register_thread_local(void); /* generated into stm_prebuilt.c */
 void pypy_stm_unregister_thread_local(void); /* generated into stm_prebuilt.c */


More information about the pypy-commit mailing list