Commits

Alex Gaynor committed ff6ca9a

Mark two fields in locks as immutable

Comments (0)

Files changed (3)

pypy/module/pypyjit/test_pypy_c/test_thread.py

         assert log.result == main(500)
         loop, = log.loops_by_filename(self.filepath)
         assert loop.match("""
-        i58 = int_gt(i43, 0)
+        i55 = int_gt(i43, 0)
+        guard_true(i55, descr=...)
+        p56 = force_token()
+        setfield_gc(p0, p56, descr=<FieldP pypy.interpreter.pyframe.PyFrame.vable_token .*>)
+        i57 = call_release_gil(..., i36, 1, descr=<Calli 4 ii EF=6>)
+        guard_not_forced(descr=...)
+        guard_no_exception(descr=...)
+        i58 = int_is_true(i57)
         guard_true(i58, descr=...)
-        p59 = getfield_gc(p15, descr=<FieldP pypy.module.thread.os_lock.Lock.inst_lock .*>)
-        i60 = getfield_gc(p59, descr=<FieldU rpython.rlib.rthread.Lock.inst__lock .*>)
+        i59 = int_sub(i43, 1)
+        guard_not_invalidated(descr=...)
         p61 = force_token()
         setfield_gc(p0, p61, descr=<FieldP pypy.interpreter.pyframe.PyFrame.vable_token .*>)
-        i62 = call_release_gil(..., i60, 1, descr=<Calli 4 ii EF=6>)
+        i62 = call_release_gil(..., i36, 0, descr=<Calli 4 ii EF=6>)
         guard_not_forced(descr=...)
         guard_no_exception(descr=...)
         i63 = int_is_true(i62)
-        guard_true(i63, descr=...)
-        i64 = int_sub(i43, 1)
-        guard_not_invalidated(descr=...)
-        p66 = getfield_gc(p15, descr=<FieldP pypy.module.thread.os_lock.Lock.inst_lock .*>)
-        i67 = getfield_gc(p66, descr=<FieldU rpython.rlib.rthread.Lock.inst__lock .*>)
-        p68 = force_token()
-        setfield_gc(p0, p68, descr=<FieldP pypy.interpreter.pyframe.PyFrame.vable_token .*>)
-        i69 = call_release_gil(..., i67, 0, descr=<Calli 4 ii EF=6>)
-        guard_not_forced(descr=...)
-        guard_no_exception(descr=...)
-        i70 = int_is_true(i69)
-        guard_false(i70, descr=...)
-        i71 = getfield_gc(p66, descr=<FieldU rpython.rlib.rthread.Lock.inst__lock .*>)
-        p72 = force_token()
-        setfield_gc(p0, p72, descr=<FieldP pypy.interpreter.pyframe.PyFrame.vable_token .*>)
-        call_release_gil(..., i71, descr=<Callv 0 i EF=6>)
+        guard_false(i63, descr=...)
+        p64 = force_token()
+        setfield_gc(p0, p64, descr=<FieldP pypy.interpreter.pyframe.PyFrame.vable_token .*>)
+        call_release_gil(4312494624, i36, descr=<Callv 0 i EF=6>)
         guard_not_forced(descr=...)
         guard_no_exception(descr=...)
         guard_not_invalidated(descr=...)

pypy/module/thread/os_lock.py

 class Lock(W_Root):
     "A box around an interp-level lock object."
 
+    _immutable_fields_ = ["lock"]
+
     def __init__(self, space):
         self.space = space
         try:

rpython/rlib/rthread.py

     """ Container for low-level implementation
     of a lock object
     """
+    _immutable_fields_ = ["_lock"]
+
     def __init__(self, ll_lock):
         self._lock = ll_lock