[pypy-commit] pypy cffi-static-callback-embedding: hg merge ec-keepalive

arigo pypy.commits at gmail.com
Mon Jan 4 13:58:27 EST 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-static-callback-embedding
Changeset: r81560:6b1fefba1c93
Date: 2016-01-04 19:57 +0100
http://bitbucket.org/pypy/pypy/changeset/6b1fefba1c93/

Log:	hg merge ec-keepalive

diff --git a/rpython/rlib/entrypoint.py b/rpython/rlib/entrypoint.py
--- a/rpython/rlib/entrypoint.py
+++ b/rpython/rlib/entrypoint.py
@@ -1,4 +1,4 @@
-secondary_entrypoints = {}
+secondary_entrypoints = {"main": []}
 
 import py
 from rpython.rtyper.lltypesystem import lltype, rffi
@@ -109,17 +109,3 @@
                     "you.  Another difference is that entrypoint_highlevel() "
                     "returns the normal Python function, which can be safely "
                     "called from more Python code.")
-
-
-# the point of dance below is so the call to rpython_startup_code actually
-# does call asm_stack_bottom. It's here because there is no other good place.
-# This thing is imported by any target which has any API, so it'll get
-# registered
-
-RPython_StartupCode = rffi.llexternal('RPython_StartupCode', [], lltype.Void,
-                                      _nowrapper=True,
-                                      random_effects_on_gcobjs=True)
-
- at entrypoint_highlevel('main', [], c_name='rpython_startup_code')
-def rpython_startup_code():
-    RPython_StartupCode()
diff --git a/rpython/rlib/rshrinklist.py b/rpython/rlib/rshrinklist.py
--- a/rpython/rlib/rshrinklist.py
+++ b/rpython/rlib/rshrinklist.py
@@ -6,6 +6,8 @@
     The twist is that occasionally append() will throw away the
     items for which must_keep() returns False.  (It does so without
     changing the order.)
+
+    See also rpython.rlib.rweaklist.
     """
     _mixin_ = True
 
diff --git a/rpython/rlib/rweaklist.py b/rpython/rlib/rweaklist.py
--- a/rpython/rlib/rweaklist.py
+++ b/rpython/rlib/rweaklist.py
@@ -5,6 +5,13 @@
 
 
 class RWeakListMixin(object):
+    """A mixin base class.  A collection that weakly maps indexes to objects.
+    After an object goes away, its index is marked free and will be reused
+    by some following add_handle() call.  So add_handle() might not append
+    the object at the end of the list, but can put it anywhere.
+
+    See also rpython.rlib.rshrinklist.
+    """
     _mixin_ = True
 
     def initialize(self):
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
@@ -37,6 +37,24 @@
 # include <src/thread.h>
 #endif
 
+void rpython_startup_code(void)
+{
+#ifdef RPY_WITH_GIL
+    RPyGilAcquire();
+#endif
+#ifdef PYPY_USE_ASMGCC
+    pypy_g_rpython_rtyper_lltypesystem_rffi_StackCounter.sc_inst_stacks_counter++;
+#endif
+    pypy_asm_stack_bottom();
+    RPython_StartupCode();
+#ifdef PYPY_USE_ASMGCC
+    pypy_g_rpython_rtyper_lltypesystem_rffi_StackCounter.sc_inst_stacks_counter--;
+#endif
+#ifdef RPY_WITH_GIL
+    RPyGilRelease();
+#endif
+}
+
 
 RPY_EXTERN
 int pypy_main_function(int argc, char *argv[])
diff --git a/rpython/translator/c/src/threadlocal.h b/rpython/translator/c/src/threadlocal.h
--- a/rpython/translator/c/src/threadlocal.h
+++ b/rpython/translator/c/src/threadlocal.h
@@ -33,6 +33,8 @@
 
 /* Use the '__thread' specifier, so far only on Linux */
 
+#include <pthread.h>
+
 RPY_EXTERN __thread struct pypy_threadlocal_s pypy_threadlocal;
 
 #define OP_THREADLOCALREF_ADDR(r)               \
@@ -68,8 +70,6 @@
 #  define _RPy_ThreadLocals_Set(x)  pthread_setspecific(pypy_threadlocal_key, x)
 #endif
 
-RPY_EXTERN pthread_key_t pypy_threadlocal_key;
-
 
 #define OP_THREADLOCALREF_ADDR(r)               \
     do {                                        \
@@ -91,6 +91,9 @@
 /* ------------------------------------------------------------ */
 
 
+RPY_EXTERN pthread_key_t pypy_threadlocal_key;
+
+
 /* only for the fall-back path in the JIT */
 #define OP_THREADLOCALREF_GET_NONCONST(RESTYPE, offset, r)      \
     do {                                                        \
diff --git a/rpython/translator/c/test/test_standalone.py b/rpython/translator/c/test/test_standalone.py
--- a/rpython/translator/c/test/test_standalone.py
+++ b/rpython/translator/c/test/test_standalone.py
@@ -96,6 +96,8 @@
                     continue
                 if name == 'pypy_debug_file':     # ok to export this one
                     continue
+                if name == 'rpython_startup_code':  # ok for this one too
+                    continue
                 if 'pypy' in name.lower() or 'rpy' in name.lower():
                     raise Exception("Unexpected exported name %r.  "
                         "What is likely missing is RPY_EXTERN before the "
diff --git a/rpython/translator/driver.py b/rpython/translator/driver.py
--- a/rpython/translator/driver.py
+++ b/rpython/translator/driver.py
@@ -203,9 +203,8 @@
                 try:
                     points = secondary_entrypoints[key]
                 except KeyError:
-                    raise KeyError(
-                        "Entrypoints not found. I only know the keys %r." %
-                        (", ".join(secondary_entrypoints.keys()), ))
+                    raise KeyError("Entrypoint %r not found (not in %r)" %
+                                   (key, secondary_entrypoints.keys()))
                 self.secondary_entrypoints.extend(points)
 
         self.translator.driver_instrument_result = self.instrument_result


More information about the pypy-commit mailing list