[pypy-commit] pypy stm-thread-2: Using gc=none instead of fighting Boehm. Now the test passes, slowly.
arigo
noreply at buildbot.pypy.org
Thu Sep 6 16:10:26 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread-2
Changeset: r57177:9b410b19726d
Date: 2012-09-06 16:10 +0200
http://bitbucket.org/pypy/pypy/changeset/9b410b19726d/
Log: Using gc=none instead of fighting Boehm. Now the test passes,
slowly.
diff --git a/pypy/rpython/memory/gctransform/boehmstm.py b/pypy/rpython/memory/gctransform/nogcstm.py
rename from pypy/rpython/memory/gctransform/boehmstm.py
rename to pypy/rpython/memory/gctransform/nogcstm.py
--- a/pypy/rpython/memory/gctransform/boehmstm.py
+++ b/pypy/rpython/memory/gctransform/nogcstm.py
@@ -11,7 +11,7 @@
REV_INITIAL = r_uint(1)
-class BoehmSTMGCTransformer(BoehmGCTransformer):
+class NoneSTMGCTransformer(BoehmGCTransformer):
HDR = lltype.Struct("header", ("hash", lltype.Signed),
("size", lltype.Signed),
("tid", lltype.Signed), # for flags only
diff --git a/pypy/translator/c/gc.py b/pypy/translator/c/gc.py
--- a/pypy/translator/c/gc.py
+++ b/pypy/translator/c/gc.py
@@ -199,9 +199,6 @@
class BoehmGcPolicy(BasicGcPolicy):
def gettransformer(self):
- if self.db.translator.config.translation.stm:
- from pypy.rpython.memory.gctransform import boehmstm
- return boehmstm.BoehmSTMGCTransformer(self.db.translator)
from pypy.rpython.memory.gctransform import boehm
return boehm.BoehmGCTransformer(self.db.translator)
@@ -232,7 +229,7 @@
from pypy.rpython.tool.rffi_platform import configure_boehm
eci = eci.merge(configure_boehm())
- pre_include_bits = ['#define USING_BOEHM_GC']
+ pre_include_bits = []
if sys.platform.startswith('linux'):
pre_include_bits += ["#define _REENTRANT 1",
"#define GC_LINUX_THREADS 1"]
@@ -242,6 +239,7 @@
eci = eci.merge(ExternalCompilationInfo(
pre_include_bits=pre_include_bits,
+ post_include_bits=['#define USING_BOEHM_GC'],
))
return eci
@@ -306,10 +304,16 @@
gc_startup_code = RefcountingGcPolicy.gc_startup_code.im_func
+ def gettransformer(self):
+ if self.db.translator.config.translation.stm:
+ from pypy.rpython.memory.gctransform import nogcstm
+ return nogcstm.NoneSTMGCTransformer(self.db.translator)
+ return BoehmGcPolicy.gettransformer(self)
+
def compilation_info(self):
eci = BasicGcPolicy.compilation_info(self)
eci = eci.merge(ExternalCompilationInfo(
- post_include_bits=['#define USING_NO_GC_AT_ALL'],
+ pre_include_bits=['#define USING_NO_GC_AT_ALL'],
))
return eci
diff --git a/pypy/translator/c/src/mem.h b/pypy/translator/c/src/mem.h
--- a/pypy/translator/c/src/mem.h
+++ b/pypy/translator/c/src/mem.h
@@ -178,14 +178,11 @@
/* #define BOEHM_MALLOC_0_1 GC_MALLOC_IGNORE_OFF_PAGE */
/* #define BOEHM_MALLOC_1_1 GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE */
-#ifndef OP_BOEHM_ZERO_MALLOC /* may be defined already by src_stm/et.h */
#define OP_BOEHM_ZERO_MALLOC(size, r, restype, is_atomic, is_varsize) { \
r = (restype) BOEHM_MALLOC_ ## is_atomic ## _ ## is_varsize (size); \
if (r && is_atomic) /* the non-atomic versions return cleared memory */ \
memset((void*) r, 0, size); \
}
-#endif
-
#define OP_BOEHM_DISAPPEARING_LINK(link, obj, r) \
if (GC_base(obj) == NULL) \
; /* 'obj' is probably a prebuilt object - it makes no */ \
@@ -236,8 +233,10 @@
#ifdef USING_NO_GC_AT_ALL
+#ifndef OP_BOEHM_ZERO_MALLOC /* may be defined already by src_stm/et.h */
#define OP_BOEHM_ZERO_MALLOC(size, r, restype, is_atomic, is_varsize) \
r = (restype) calloc(1, size);
+#endif
#define OP_BOEHM_DISAPPEARING_LINK(link, obj, r) /* nothing */
#define OP_GC__DISABLE_FINALIZERS(r) /* nothing */
#define OP_GC__ENABLE_FINALIZERS(r) /* nothing */
diff --git a/pypy/translator/stm/funcgen.py b/pypy/translator/stm/funcgen.py
--- a/pypy/translator/stm/funcgen.py
+++ b/pypy/translator/stm/funcgen.py
@@ -3,16 +3,16 @@
def stm_start_transaction(funcgen, op):
- # only for Boehm. With stmgc, this operation should have been handled
+ # only for testing. With stmgc, this operation should have been handled
# already by gctransform.
- assert funcgen.db.translator.config.translation.gc == 'boehm'
- return 'stm_boehm_start_transaction();'
+ assert funcgen.db.translator.config.translation.gc == 'none'
+ return 'stm_nogc_start_transaction();'
def stm_stop_transaction(funcgen, op):
- # only for Boehm. With stmgc, this operation should have been handled
+ # only for testing. With stmgc, this operation should have been handled
# already by gctransform.
- assert funcgen.db.translator.config.translation.gc == 'boehm'
- return 'stm_boehm_stop_transaction();'
+ assert funcgen.db.translator.config.translation.gc == 'none'
+ return 'stm_nogc_stop_transaction();'
def stm_barrier(funcgen, op):
level = op.args[0].value
diff --git a/pypy/translator/stm/src_stm/et.h b/pypy/translator/stm/src_stm/et.h
--- a/pypy/translator/stm/src_stm/et.h
+++ b/pypy/translator/stm/src_stm/et.h
@@ -14,11 +14,12 @@
#ifndef _ET_H
#define _ET_H
+#include <stddef.h>
#include <setjmp.h>
/* These are partly the same flags as defined in stmgc.py, as well as
- boehmstm.py. Keep in sync! */
+ nogcstm.py. Keep in sync! */
enum {
_first_gcflag = 1L << (PYPY_LONG_BIT / 2),
GCFLAG_GLOBAL = _first_gcflag << 0,
@@ -109,14 +110,14 @@
void *save_and_restore);
void stm_abort_and_retry(void);
-#ifdef USING_BOEHM_GC
+#ifdef USING_NO_GC_AT_ALL
# define OP_GC_ADR_OF_ROOT_STACK_TOP(r) r = NULL
-void stm_boehm_start_transaction(void);
-void stm_boehm_stop_transaction(void);
-gcptr stm_boehm_allocate(size_t);
+void stm_nogc_start_transaction(void);
+void stm_nogc_stop_transaction(void);
+gcptr stm_nogc_allocate(size_t);
# undef OP_BOEHM_ZERO_MALLOC
# define OP_BOEHM_ZERO_MALLOC(size, r, restype, is_atomic, is_varsize) \
- r = (restype) stm_boehm_allocate(size)
+ r = (restype) stm_nogc_allocate(size)
#endif
#endif /* _ET_H */
diff --git a/pypy/translator/stm/src_stm/rpyintf.c b/pypy/translator/stm/src_stm/rpyintf.c
--- a/pypy/translator/stm/src_stm/rpyintf.c
+++ b/pypy/translator/stm/src_stm/rpyintf.c
@@ -123,7 +123,7 @@
void **volatile v_saved_value;
long volatile v_atomic = thread_descriptor->atomic;
assert((!thread_descriptor->active) == (!v_atomic));
-#ifndef USING_BOEHM_GC
+#ifndef USING_NO_GC_AT_ALL
v_saved_value = *(void***)save_and_restore;
#endif
/***/
@@ -135,7 +135,7 @@
void **restore_value;
counter = v_counter;
d->atomic = v_atomic;
-#ifndef USING_BOEHM_GC
+#ifndef USING_NO_GC_AT_ALL
restore_value = v_saved_value;
if (!d->atomic)
{
@@ -173,7 +173,7 @@
if (d->atomic && d->setjmp_buf == &_jmpbuf)
BecomeInevitable("perform_transaction left with atomic");
-#ifndef USING_BOEHM_GC
+#ifndef USING_NO_GC_AT_ALL
*(void***)save_and_restore = v_saved_value;
#endif
}
@@ -183,27 +183,29 @@
AbortTransaction(4); /* manual abort */
}
-#ifdef USING_BOEHM_GC
-static __thread gcptr stm_boehm_chained_list;
-void stm_boehm_start_transaction(void)
+#ifdef USING_NO_GC_AT_ALL
+static __thread gcptr stm_nogc_chained_list;
+void stm_nogc_start_transaction(void)
{
- GC_init();
- stm_boehm_chained_list = NULL;
+ stm_nogc_chained_list = NULL;
}
-gcptr stm_boehm_allocate(size_t size)
+gcptr stm_nogc_allocate(size_t size)
{
- gcptr W = GC_local_malloc(size);
- memset((void*) W, 0, size);
+ gcptr W = calloc(1, size);
+ if (!W) {
+ fprintf(stderr, "out of memory!\n");
+ abort();
+ }
W->h_size = size;
- W->h_revision = (revision_t)stm_boehm_chained_list;
- stm_boehm_chained_list = W;
+ W->h_revision = (revision_t)stm_nogc_chained_list;
+ stm_nogc_chained_list = W;
return W;
}
-void stm_boehm_stop_transaction(void)
+void stm_nogc_stop_transaction(void)
{
struct gcroot_s *gcroots;
- gcptr W = stm_boehm_chained_list;
- stm_boehm_chained_list = NULL;
+ gcptr W = stm_nogc_chained_list;
+ stm_nogc_chained_list = NULL;
while (W) {
gcptr W_next = (gcptr)W->h_revision;
assert((W->h_tid & (GCFLAG_GLOBAL |
@@ -227,7 +229,11 @@
void *pypy_g__stm_duplicate(void *src)
{
size_t size = ((gcptr)src)->h_size;
- void *result = GC_local_malloc(size);
+ void *result = malloc(size);
+ if (!result) {
+ fprintf(stderr, "out of memory!\n");
+ abort();
+ }
memcpy(result, src, size);
return result;
}
diff --git a/pypy/translator/stm/test/support.py b/pypy/translator/stm/test/support.py
--- a/pypy/translator/stm/test/support.py
+++ b/pypy/translator/stm/test/support.py
@@ -24,5 +24,5 @@
return res
-class BoehmCompiledSTMTests(CompiledSTMTests):
- gc = "boehm"
+class NoGcCompiledSTMTests(CompiledSTMTests):
+ gc = "none"
diff --git a/pypy/translator/stm/test/test_ztranslated.py b/pypy/translator/stm/test/test_ztranslated.py
--- a/pypy/translator/stm/test/test_ztranslated.py
+++ b/pypy/translator/stm/test/test_ztranslated.py
@@ -1,15 +1,14 @@
import py
from pypy.rlib import rstm, rgc
-from pypy.translator.stm.test.support import BoehmCompiledSTMTests
+from pypy.translator.stm.test.support import NoGcCompiledSTMTests
from pypy.translator.stm.test.support import CompiledSTMTests
from pypy.translator.stm.test import targetdemo2
-class TestBoehmSTMTranslated(BoehmCompiledSTMTests):
+class TestNoGcSTMTranslated(NoGcCompiledSTMTests):
def test_targetdemo(self):
t, cbuilder = self.compile(targetdemo2.entry_point)
- data, dataerr = cbuilder.cmdexec('4 5000', err=True,
- env={'PYPY_GC_DEBUG': '1'})
+ data, dataerr = cbuilder.cmdexec('4 100', err=True)
assert 'check ok!' in data
More information about the pypy-commit
mailing list