Author: Armin Rigo <[email protected]>
Branch: fast-gil
Changeset: r72218:b9d854c5738e
Date: 2014-06-25 17:19 +0200
http://bitbucket.org/pypy/pypy/changeset/b9d854c5738e/

Log:    Revert some of the last checkins: figured out why some functions
        were not present at all in the testing .so --- that's because they
        were "static inline".

diff --git a/pypy/module/thread/gil.py b/pypy/module/thread/gil.py
--- a/pypy/module/thread/gil.py
+++ b/pypy/module/thread/gil.py
@@ -11,7 +11,7 @@
 from pypy.module.thread.error import wrap_thread_error
 from pypy.interpreter.executioncontext import PeriodicAsyncAction
 from pypy.module.thread.threadlocals import OSThreadLocals
-from rpython.rlib.objectmodel import invoke_around_extcall, we_are_translated
+from rpython.rlib.objectmodel import invoke_around_extcall
 from rpython.rlib.rposix import get_errno, set_errno
 
 class GILThreadLocals(OSThreadLocals):
@@ -70,15 +70,13 @@
 def before_external_call():
     # this function must not raise, in such a way that the exception
     # transformer knows that it cannot raise!
-    if we_are_translated():
-        rgil.gil_release()
+    rgil.gil_release()
 before_external_call._gctransformer_hint_cannot_collect_ = True
 before_external_call._dont_reach_me_in_del_ = True
 
 def after_external_call():
     e = get_errno()
-    if we_are_translated():
-        rgil.gil_acquire()
+    rgil.gil_acquire()
     rthread.gc_thread_run()
     after_thread_switch()
     set_errno(e)
@@ -96,10 +94,9 @@
     # explicitly release the gil, in a way that tries to give more
     # priority to other threads (as opposed to continuing to run in
     # the same thread).
-    if we_are_translated():
-        if rgil.gil_yield_thread():
-            rthread.gc_thread_run()
-            after_thread_switch()
+    if rgil.gil_yield_thread():
+        rthread.gc_thread_run()
+        after_thread_switch()
 do_yield_thread._gctransformer_hint_close_stack_ = True
 do_yield_thread._dont_reach_me_in_del_ = True
 do_yield_thread._dont_inline_ = True
diff --git a/rpython/jit/backend/llsupport/callbuilder.py 
b/rpython/jit/backend/llsupport/callbuilder.py
--- a/rpython/jit/backend/llsupport/callbuilder.py
+++ b/rpython/jit/backend/llsupport/callbuilder.py
@@ -1,5 +1,4 @@
 from rpython.rlib.clibffi import FFI_DEFAULT_ABI
-from rpython.rlib.objectmodel import we_are_translated
 from rpython.rlib import rgil
 from rpython.rtyper.lltypesystem import lltype, rffi
 
@@ -46,10 +45,7 @@
     def emit_call_release_gil(self):
         """Emit a CALL_RELEASE_GIL, including calls to releasegil_addr
         and reacqgil_addr."""
-        if we_are_translated():
-            fastgil = rffi.cast(lltype.Signed, rgil.gil_fetch_fastgil())
-        else:
-            fastgil = "NOT TRANSLATED"
+        fastgil = rffi.cast(lltype.Signed, rgil.gil_fetch_fastgil())
         self.select_call_release_gil_mode()
         self.prepare_arguments()
         self.push_gcmap_for_call_release_gil()
diff --git a/rpython/jit/backend/x86/callbuilder.py 
b/rpython/jit/backend/x86/callbuilder.py
--- a/rpython/jit/backend/x86/callbuilder.py
+++ b/rpython/jit/backend/x86/callbuilder.py
@@ -126,10 +126,10 @@
             self.asm.set_extra_stack_depth(self.mc, -delta * WORD)
             css_value = eax
         #
+        self.mc.MOV(heap(fastgil), css_value)
+        #
         if not we_are_translated():        # for testing: we should not access
             self.mc.ADD(ebp, imm(1))       # ebp any more; and ignore 'fastgil'
-        else:
-            self.mc.MOV(heap(fastgil), css_value)
 
     def move_real_result_and_call_reacqgil_addr(self, fastgil):
         from rpython.jit.backend.x86.assembler import heap
@@ -160,9 +160,7 @@
             mc.LEA_rs(css_value.value, css)
         #
         mc.MOV(old_value, imm(1))
-        if not we_are_translated():
-            mc.MOV(old_value, css_value)       # for testing: ignore 'fastgil'
-        elif rx86.fits_in_32bits(fastgil):
+        if rx86.fits_in_32bits(fastgil):
             mc.XCHG_rj(old_value.value, fastgil)
         else:
             mc.MOV_ri(X86_64_SCRATCH_REG.value, fastgil)
diff --git a/rpython/translator/c/src/thread.h 
b/rpython/translator/c/src/thread.h
--- a/rpython/translator/c/src/thread.h
+++ b/rpython/translator/c/src/thread.h
@@ -27,6 +27,8 @@
 void RPyGilAllocate(void);
 long RPyGilYieldThread(void);
 void RPyGilAcquire(void);
+#define RPyGilRelease _RPyGilRelease
+#define RPyFetchFastGil _RPyFetchFastGil
 
 #ifdef PYPY_USE_ASMGCC
 # define RPY_FASTGIL_LOCKED(x)   (x == 1)
@@ -36,11 +38,11 @@
 
 extern long rpy_fastgil;
 
-static inline void RPyGilRelease(void) {
+static inline void _RPyGilRelease(void) {
     assert(RPY_FASTGIL_LOCKED(rpy_fastgil));
     rpy_fastgil = 0;
 }
-static inline long *RPyFetchFastGil(void) {
+static inline long *_RPyFetchFastGil(void) {
     return &rpy_fastgil;
 }
 
diff --git a/rpython/translator/c/src/thread_gil.c 
b/rpython/translator/c/src/thread_gil.c
--- a/rpython/translator/c/src/thread_gil.c
+++ b/rpython/translator/c/src/thread_gil.c
@@ -122,17 +122,6 @@
 #endif
 }
 
-/*
-void RPyGilRelease(void)
-{
-    Releases the GIL in order to do an external function call.
-    We assume that the common case is that the function call is
-    actually very short, and optimize accordingly.
-
-    Note: this function is defined as a 'static inline' in thread.h.
-}
-*/
-
 long RPyGilYieldThread(void)
 {
     /* can be called even before RPyGilAllocate(), but in this case,
@@ -155,3 +144,26 @@
     RPyGilAcquire();
     return 1;
 }
+
+/********** for tests only **********/
+
+/* These functions are usually defined as a macros RPyXyz() in thread.h
+   which get translated into calls to _RpyXyz().  But for tests we need
+   the real functions to exists in the library as well.
+*/
+
+#undef RPyGilRelease
+void RPyGilRelease(void)
+{
+    /* Releases the GIL in order to do an external function call.
+       We assume that the common case is that the function call is
+       actually very short, and optimize accordingly.
+    */
+    _RPyGilRelease();
+}
+
+#undef RPyFetchFastGil
+long *RPyFetchFastGil(void)
+{
+    return _RPyFetchFastGil();
+}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to