Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r66787:c99baebdd2f2
Date: 2013-09-05 10:28 +0200
http://bitbucket.org/pypy/pypy/changeset/c99baebdd2f2/

Log:    merge heads

diff --git a/pypy/module/pypyjit/policy.py b/pypy/module/pypyjit/policy.py
--- a/pypy/module/pypyjit/policy.py
+++ b/pypy/module/pypyjit/policy.py
@@ -109,7 +109,8 @@
                        'posix', '_socket', '_sre', '_lsprof', '_weakref',
                        '__pypy__', 'cStringIO', '_collections', 'struct',
                        'mmap', 'marshal', '_codecs', 'rctime', 'cppyy',
-                       '_cffi_backend', 'pyexpat', '_continuation', '_io']:
+                       '_cffi_backend', 'pyexpat', '_continuation', '_io',
+                       'thread']:
             if modname == 'pypyjit' and 'interp_resop' in rest:
                 return False
             return True
diff --git a/pypy/module/pypyjit/test/test_policy.py 
b/pypy/module/pypyjit/test/test_policy.py
--- a/pypy/module/pypyjit/test/test_policy.py
+++ b/pypy/module/pypyjit/test/test_policy.py
@@ -45,6 +45,10 @@
     from pypy.module._io.interp_bytesio import W_BytesIO
     assert pypypolicy.look_inside_function(W_BytesIO.seek_w.im_func)
 
+def test_thread():
+    from pypy.module.thread.os_lock import Lock
+    assert pypypolicy.look_inside_function(Lock.descr_lock_acquire.im_func)
+
 def test_pypy_module():
     from pypy.module._collections.interp_deque import W_Deque
     from pypy.module._random.interp_random import W_Random
diff --git a/pypy/module/pypyjit/test_pypy_c/test_thread.py 
b/pypy/module/pypyjit/test_pypy_c/test_thread.py
--- a/pypy/module/pypyjit/test_pypy_c/test_thread.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_thread.py
@@ -48,3 +48,47 @@
             i58 = arraylen_gc(p43, descr=...)
             jump(..., descr=...)
         """)
+
+    def test_lock_acquire_release(self):
+        def main(n):
+            import threading
+            lock = threading.Lock()
+            while n > 0:
+                with lock:
+                    n -= 1
+        log = self.run(main, [500])
+        assert log.result == main(500)
+        loop, = log.loops_by_filename(self.filepath)
+        assert loop.match("""
+        i58 = int_gt(i43, 0)
+        guard_true(i58, descr=<Guard0x10483adb8>)
+        p59 = getfield_gc(p15, descr=<FieldP 
pypy.module.thread.os_lock.Lock.inst_lock 8>)
+        i60 = getfield_gc(p59, descr=<FieldU 
rpython.rlib.rthread.Lock.inst__lock 8>)
+        p61 = force_token()
+        setfield_gc(p0, p61, descr=<FieldP 
pypy.interpreter.pyframe.PyFrame.vable_token 24>)
+        i62 = call_release_gil(4312440032, i60, 1, descr=<Calli 4 ii EF=6>)
+        guard_not_forced(descr=<Guard0x103f3cca0>)
+        guard_no_exception(descr=<Guard0x10483ad40>)
+        i63 = int_is_true(i62)
+        guard_true(i63, descr=<Guard0x10483acc8>)
+        i64 = int_sub(i43, 1)
+        guard_not_invalidated(descr=<Guard0x10483ac50>)
+        p66 = getfield_gc(p15, descr=<FieldP 
pypy.module.thread.os_lock.Lock.inst_lock 8>)
+        i67 = getfield_gc(p66, descr=<FieldU 
rpython.rlib.rthread.Lock.inst__lock 8>)
+        p68 = force_token()
+        setfield_gc(p0, p68, descr=<FieldP 
pypy.interpreter.pyframe.PyFrame.vable_token 24>)
+        i69 = call_release_gil(4312440032, i67, 0, descr=<Calli 4 ii EF=6>)
+        guard_not_forced(descr=<Guard0x103f3cc20>)
+        guard_no_exception(descr=<Guard0x10483aae8>)
+        i70 = int_is_true(i69)
+        guard_false(i70, descr=<Guard0x10483aa70>)
+        i71 = getfield_gc(p66, descr=<FieldU 
rpython.rlib.rthread.Lock.inst__lock 8>)
+        p72 = force_token()
+        setfield_gc(p0, p72, descr=<FieldP 
pypy.interpreter.pyframe.PyFrame.vable_token 24>)
+        call_release_gil(4312441056, i71, descr=<Callv 0 i EF=6>)
+        guard_not_forced(descr=<Guard0x103f3cba0>)
+        guard_no_exception(descr=<Guard0x10483a9f8>)
+        guard_not_invalidated(descr=<Guard0x10483a980>)
+        --TICK--
+        jump(..., descr=TargetToken(4361239720))
+        """)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to