[pypy-commit] pypy stm-gc: Fixes, enough to have 'targetdemo-c' pass.
arigo
noreply at buildbot.pypy.org
Mon Apr 16 16:21:23 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r54421:665a595261ba
Date: 2012-04-16 16:20 +0200
http://bitbucket.org/pypy/pypy/changeset/665a595261ba/
Log: Fixes, enough to have 'targetdemo-c' pass.
diff --git a/pypy/rpython/memory/gc/base.py b/pypy/rpython/memory/gc/base.py
--- a/pypy/rpython/memory/gc/base.py
+++ b/pypy/rpython/memory/gc/base.py
@@ -22,10 +22,10 @@
gcflag_extra = 0 # or a real GC flag that is always 0 when not collecting
def __init__(self, config, chunk_size=DEFAULT_CHUNK_SIZE,
- translated_to_c=True):
+ multithread=False, translated_to_c=True):
self.gcheaderbuilder = GCHeaderBuilder(self.HDR)
- self.AddressStack = get_address_stack(chunk_size)
- self.AddressDeque = get_address_deque(chunk_size)
+ self.AddressStack = get_address_stack(chunk_size, multithread)
+ self.AddressDeque = get_address_deque(chunk_size, multithread)
self.AddressDict = AddressDict
self.null_address_dict = null_address_dict
self.config = config
diff --git a/pypy/rpython/memory/gc/stmgc.py b/pypy/rpython/memory/gc/stmgc.py
--- a/pypy/rpython/memory/gc/stmgc.py
+++ b/pypy/rpython/memory/gc/stmgc.py
@@ -84,7 +84,7 @@
#small_request_threshold=5*WORD,
#ArenaCollectionClass=None,
**kwds):
- MovingGCBase.__init__(self, config, **kwds)
+ MovingGCBase.__init__(self, config, multithread=True, **kwds)
#
if isinstance(stm_operations, str):
assert stm_operations == 'use_real_one', (
diff --git a/pypy/rpython/memory/gc/stmtls.py b/pypy/rpython/memory/gc/stmtls.py
--- a/pypy/rpython/memory/gc/stmtls.py
+++ b/pypy/rpython/memory/gc/stmtls.py
@@ -200,7 +200,9 @@
#
# All live nursery objects are out, and the rest dies. Fill
# the whole nursery with zero and reset the current nursery pointer.
- llarena.arena_reset(self.nursery_start, self.nursery_size, 2)
+ ll_assert(bool(self.nursery_free), "nursery_free is NULL")
+ size_used = self.nursery_free - self.nursery_start
+ llarena.arena_reset(self.nursery_start, size_used, 2)
self.nursery_free = self.nursery_start
#
debug_stop("gc-local")
diff --git a/pypy/rpython/memory/support.py b/pypy/rpython/memory/support.py
--- a/pypy/rpython/memory/support.py
+++ b/pypy/rpython/memory/support.py
@@ -16,9 +16,10 @@
DEFAULT_CHUNK_SIZE = 1019
-def get_chunk_manager(chunk_size=DEFAULT_CHUNK_SIZE, cache={}):
+def get_chunk_manager(chunk_size=DEFAULT_CHUNK_SIZE, multithread=False,
+ cache={}):
try:
- return cache[chunk_size]
+ return cache[chunk_size, multithread]
except KeyError:
pass
@@ -33,10 +34,11 @@
_alloc_flavor_ = "raw"
def __init__(self):
- self.free_list = null_chunk
+ if not multithread:
+ self.free_list = null_chunk
def get(self):
- if not self.free_list:
+ if multithread or not self.free_list:
# we zero-initialize the chunks to make the translation
# backends happy, but we don't need to do it at run-time.
zero = not we_are_translated()
@@ -48,7 +50,7 @@
return result
def put(self, chunk):
- if we_are_translated():
+ if not multithread and we_are_translated():
chunk.next = self.free_list
self.free_list = chunk
else:
@@ -58,17 +60,18 @@
lltype.free(chunk, flavor="raw", track_allocation=False)
unused_chunks = FreeList()
- cache[chunk_size] = unused_chunks, null_chunk
+ cache[chunk_size, multithread] = unused_chunks, null_chunk
return unused_chunks, null_chunk
-def get_address_stack(chunk_size=DEFAULT_CHUNK_SIZE, cache={}):
+def get_address_stack(chunk_size=DEFAULT_CHUNK_SIZE, multithread=False,
+ cache={}):
try:
- return cache[chunk_size]
+ return cache[chunk_size, multithread]
except KeyError:
pass
- unused_chunks, null_chunk = get_chunk_manager(chunk_size)
+ unused_chunks, null_chunk = get_chunk_manager(chunk_size, multithread)
class AddressStack(object):
_alloc_flavor_ = "raw"
@@ -173,20 +176,21 @@
chunk.items[count] = got
got = next
- cache[chunk_size] = AddressStack
+ cache[chunk_size, multithread] = AddressStack
return AddressStack
def _add_in_dict(item, d):
d.add(item)
-def get_address_deque(chunk_size=DEFAULT_CHUNK_SIZE, cache={}):
+def get_address_deque(chunk_size=DEFAULT_CHUNK_SIZE, multithread=False,
+ cache={}):
try:
- return cache[chunk_size]
+ return cache[chunk_size, multithread]
except KeyError:
pass
- unused_chunks, null_chunk = get_chunk_manager(chunk_size)
+ unused_chunks, null_chunk = get_chunk_manager(chunk_size, multithread)
class AddressDeque(object):
_alloc_flavor_ = "raw"
@@ -261,7 +265,7 @@
cur = next
free_non_gc_object(self)
- cache[chunk_size] = AddressDeque
+ cache[chunk_size, multithread] = AddressDeque
return AddressDeque
# ____________________________________________________________
diff --git a/pypy/translator/c/src/debug_alloc.h b/pypy/translator/c/src/debug_alloc.h
--- a/pypy/translator/c/src/debug_alloc.h
+++ b/pypy/translator/c/src/debug_alloc.h
@@ -1,10 +1,11 @@
/**************************************************************/
/*** tracking raw mallocs and frees for debugging ***/
-#ifndef RPY_ASSERT
+#if !defined(RPY_ASSERT) || defined(RPY_STM) /* <= not thread-safe */
# define OP_TRACK_ALLOC_START(addr, r) /* nothing */
# define OP_TRACK_ALLOC_STOP(addr, r) /* nothing */
+# define pypy_debug_alloc_results() /* nothing */
#else /* ifdef RPY_ASSERT */
diff --git a/pypy/translator/c/src/main.h b/pypy/translator/c/src/main.h
--- a/pypy/translator/c/src/main.h
+++ b/pypy/translator/c/src/main.h
@@ -59,9 +59,7 @@
exitcode = STANDALONE_ENTRY_POINT(argc, argv);
-#ifdef RPY_ASSERT
pypy_debug_alloc_results();
-#endif
if (RPyExceptionOccurred()) {
/* print the RPython traceback */
More information about the pypy-commit
mailing list