[pypy-commit] pypy stm-thread-2: in-progress
arigo
noreply at buildbot.pypy.org
Thu Sep 6 12:43:54 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread-2
Changeset: r57171:3f20b859ae2f
Date: 2012-09-06 12:43 +0200
http://bitbucket.org/pypy/pypy/changeset/3f20b859ae2f/
Log: in-progress
diff --git a/pypy/rpython/memory/gctransform/boehm.py b/pypy/rpython/memory/gctransform/boehm.py
--- a/pypy/rpython/memory/gctransform/boehm.py
+++ b/pypy/rpython/memory/gctransform/boehm.py
@@ -57,6 +57,9 @@
self.mixlevelannotator.finish() # for now
self.mixlevelannotator.backend_optimize()
+ def gcheader_initdata(self, hdr):
+ pass
+
def push_alive_nopyobj(self, var, llops):
pass
diff --git a/pypy/rpython/memory/gctransform/boehmstm.py b/pypy/rpython/memory/gctransform/boehmstm.py
--- a/pypy/rpython/memory/gctransform/boehmstm.py
+++ b/pypy/rpython/memory/gctransform/boehmstm.py
@@ -1,8 +1,21 @@
from pypy.rpython.memory.gctransform.boehm import BoehmGCTransformer
from pypy.rpython.lltypesystem import lltype
+from pypy.rlib.rarithmetic import r_uint, LONG_BIT
+
+
+_first_gcflag = 1 << (LONG_BIT//2)
+GCFLAG_GLOBAL = _first_gcflag << 0
+GCFLAG_NOT_WRITTEN = _first_gcflag << 2
+
+GCFLAG_PREBUILT = GCFLAG_GLOBAL|GCFLAG_NOT_WRITTEN
+REV_INITIAL = r_uint(1)
class BoehmSTMGCTransformer(BoehmGCTransformer):
HDR = lltype.Struct("header", ("hash", lltype.Signed),
("tid", lltype.Signed), # for flags only
("revision", lltype.Unsigned))
+
+ def gcheader_initdata(self, hdr):
+ hdr.tid = GCFLAG_PREBUILT
+ hdr.revision = REV_INITIAL
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
@@ -209,6 +209,7 @@
if defnode.db.gctransformer is not None:
hdr = lltype.malloc(defnode.db.gctransformer.HDR, immortal=True)
hdr.hash = lltype.identityhash_nocache(defnode.obj._as_ptr())
+ defnode.db.gctransformer.gcheader_initdata(hdr)
return hdr._obj
return None
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,10 +178,15 @@
/* #define BOEHM_MALLOC_0_1 GC_MALLOC_IGNORE_OFF_PAGE */
/* #define BOEHM_MALLOC_1_1 GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE */
+#ifndef _BOEHM_ALLOCATED
+# define _BOEHM_ALLOCATED(r) /* nothing */
+#endif
+
#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); \
+ _BOEHM_ALLOCATED(r); \
}
#define OP_BOEHM_DISAPPEARING_LINK(link, obj, r) \
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
@@ -5,7 +5,7 @@
# only for Boehm. With stmgc, this operation should have been handled
# already by gctransform.
assert funcgen.db.translator.config.translation.gc == 'boehm'
- return '/* stm_boehm_start_transaction(); */'
+ return 'stm_boehm_start_transaction();'
def stm_stop_transaction(funcgen, op):
# only for Boehm. With stmgc, this operation should have been handled
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
@@ -17,7 +17,8 @@
#include <setjmp.h>
-/* These are partly the same flags as defined in stmgc.py. Keep in sync! */
+/* These are partly the same flags as defined in stmgc.py, as well as
+ boehmstm.py. Keep in sync! */
enum {
_first_gcflag = 1L << (PYPY_LONG_BIT / 2),
GCFLAG_GLOBAL = _first_gcflag << 0,
@@ -72,13 +73,12 @@
void BeginTransaction(jmp_buf *);
void BeginInevitableTransaction(void);
-//int _FakeReach(gcptr);
+int _FakeReach(gcptr);
void CommitTransaction(void);
void BecomeInevitable(const char *why);
//void BeginInevitableTransaction(void);
int DescriptorInit(void);
void DescriptorDone(void);
-int _FakeReach(gcptr P);
//gcptr Allocate(size_t size, int gctid);
_Bool stm_PtrEq(gcptr P1, gcptr P2);
@@ -111,7 +111,11 @@
#ifdef USING_BOEHM_GC
# define OP_GC_ADR_OF_ROOT_STACK_TOP(r) r = NULL
+void stm_boehm_start_transaction(void);
void stm_boehm_stop_transaction(void);
+void stm_boehm_allocated(gcptr);
+# undef _BOEHM_ALLOCATED
+# define _BOEHM_ALLOCATED(r) stm_boehm_allocated((gcptr)(r))
#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
@@ -176,3 +176,42 @@
{
AbortTransaction(4); /* manual abort */
}
+
+#ifdef USING_BOEHM_GC
+static __thread gcptr stm_boehm_chained_list;
+void stm_boehm_start_transaction(void)
+{
+ stm_boehm_chained_list = NULL;
+}
+void stm_boehm_allocated(gcptr W)
+{
+ W->h_revision = (revision_t)stm_boehm_chained_list;
+ stm_boehm_chained_list = W;
+}
+void stm_boehm_stop_transaction(void)
+{
+ gcptr W = stm_boehm_chained_list;
+ stm_boehm_chained_list = NULL;
+ while (W) {
+ gcptr W_next = (gcptr)W->h_revision;
+ assert(W->h_tid & (GCFLAG_GLOBAL |
+ GCFLAG_NOT_WRITTEN |
+ GCFLAG_LOCAL_COPY) == 0);
+ W->h_tid |= GCFLAG_GLOBAL | GCFLAG_NOT_WRITTEN;
+ W->h_revision = 1;
+ W = W_next;
+ }
+ FindRootsForLocalCollect();
+}
+void *pypy_g__stm_duplicate(void *src)
+{
+ size_t size = GC_size(src);
+ void *result = GC_MALLOC(size);
+ memcpy(result, src, size);
+ return result;
+}
+void pypy_g__stm_enum_callback(void *tlsaddr, void *R, void *L)
+{
+ abort();
+}
+#endif
More information about the pypy-commit
mailing list