[pypy-commit] pypy nogil-unsafe-2: small cleanup
Raemi
pypy.commits at gmail.com
Mon Mar 20 12:43:09 EDT 2017
Author: Remi Meier <remi.meier at gmail.com>
Branch: nogil-unsafe-2
Changeset: r90765:d29b5e7da8b0
Date: 2017-03-20 17:42 +0100
http://bitbucket.org/pypy/pypy/changeset/d29b5e7da8b0/
Log: small cleanup
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -439,10 +439,7 @@
self.updated_old_objects_pointing_to_pinned = False
#
# Allocate lock(s)
- wb_slowpath_lock = lltype.malloc(rthread.TLOCKP.TO, flavor='raw',
- track_allocation=False)
- rthread.c_thread_lock_init(wb_slowpath_lock)
- self.wb_slowpath_lock = wb_slowpath_lock
+ self.wb_slowpath_lock = rthread.allocate_ll_lock_NOAUTO()
#
# Allocate a nursery. In case of auto_nursery_size, start by
# allocating a very small nursery, enough to do things like look
diff --git a/rpython/memory/gc/test/test_thread.py b/rpython/memory/gc/test/test_thread.py
--- a/rpython/memory/gc/test/test_thread.py
+++ b/rpython/memory/gc/test/test_thread.py
@@ -11,7 +11,6 @@
class ThreadSwitcher:
all_threadlocals = [incminimark.NURSERY_FREE,
incminimark.NURSERY_TOP,
- incminimark.NEXT_NUBLOCK,
]
def __init__(self, gc):
diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -59,6 +59,9 @@
TLOCKP_SIZE = rffi_platform.sizeof('struct RPyOpaque_ThreadLock', eci)
c_thread_lock_init = llexternal('RPyThreadLockInit', [TLOCKP], rffi.INT,
releasegil=False) # may add in a global list
+c_thread_lock_init_NOAUTO = llexternal('RPyThreadLockInit', [TLOCKP], rffi.INT,
+ _nowrapper=True) # may add in a global list!
+
c_thread_lock_dealloc_NOAUTO = llexternal('RPyOpaqueDealloc_ThreadLock',
[TLOCKP], lltype.Void,
_nowrapper=True)
@@ -248,6 +251,13 @@
rgc.add_memory_pressure(TLOCKP_SIZE)
return ll_lock
+
+def allocate_ll_lock_NOAUTO():
+ ll_lock = lltype.malloc(TLOCKP.TO, flavor='raw', track_allocation=False)
+ c_thread_lock_init_NOAUTO(ll_lock)
+ return ll_lock
+
+
def free_ll_lock(ll_lock):
acquire_NOAUTO(ll_lock, False)
release_NOAUTO(ll_lock)
diff --git a/rpython/translator/c/test/test_nogil.py b/rpython/translator/c/test/test_nogil.py
--- a/rpython/translator/c/test/test_nogil.py
+++ b/rpython/translator/c/test/test_nogil.py
@@ -112,6 +112,7 @@
def worker():
rthread.gc_thread_start()
+ # these arrays should be old soon:
arrays = []
for _ in range(state.arrays):
arrays.append([None])
@@ -120,6 +121,7 @@
xi = 0
for i in range(1000):
xi = i
+ # put a young X() in each old array
for idx in range(state.arrays):
x = X(xi)
arrays[idx][0] = x
@@ -127,6 +129,7 @@
gc.collect(0)
+ # check that Xs are not lost
for idx in range(state.arrays):
assert arrays[idx][0].i == xi
More information about the pypy-commit
mailing list