Author: Armin Rigo <[email protected]>
Branch:
Changeset: r168:37c581d1aab8
Date: 2013-06-17 14:01 +0200
http://bitbucket.org/pypy/stmgc/changeset/37c581d1aab8/
Log: Next test
diff --git a/c4/et.c b/c4/et.c
--- a/c4/et.c
+++ b/c4/et.c
@@ -1347,10 +1347,12 @@
void _stm_test_forget_previous_state(void)
{
+ /* debug: reset all global states, between tests */
fprintf(stderr, "=======================================================\n");
assert(thread_descriptor == NULL);
memset(stm_descriptor_array, 0, sizeof(stm_descriptor_array));
descriptor_array_free_list = 0;
+ stmgcpage_count(2);
}
int DescriptorInit(void)
diff --git a/c4/gcpage.c b/c4/gcpage.c
--- a/c4/gcpage.c
+++ b/c4/gcpage.c
@@ -12,7 +12,7 @@
static revision_t countdown_next_major_coll = GC_MIN;
/* For statistics */
-static uintptr_t count_global_pages;
+static revision_t count_global_pages;
/* For tests */
long stmgcpage_count(int quantity)
@@ -20,6 +20,7 @@
switch (quantity) {
case 0: return count_global_pages;
case 1: return LOCAL_GCPAGES()->count_pages;
+ case 2: count_global_pages = 0; return 0;
default: return -1;
}
}
@@ -62,13 +63,8 @@
/* Send to the shared area all my pages. For now we don't extract
the information about which locations are free or not; we just
leave it to the next major GC to figure them out. */
-#if 0
struct tx_public_descriptor *gcp = LOCAL_GCPAGES();
-
- gcp->gcp_next = finished_thread_gcpages;
- finished_thread_gcpages = gcp;
- count_global_pages += gcp->count_pages;*/
-#endif
+ count_global_pages += gcp->count_pages;
}
diff --git a/c4/gcpage.h b/c4/gcpage.h
--- a/c4/gcpage.h
+++ b/c4/gcpage.h
@@ -60,7 +60,7 @@
gcptr free_loc_for_size[GC_SMALL_REQUESTS]; \
\
/* For statistics */ \
- uintptr_t count_pages;
+ revision_t count_pages;
#define LOCAL_GCPAGES() (thread_descriptor->public_descriptor)
diff --git a/c4/test/support.py b/c4/test/support.py
--- a/c4/test/support.py
+++ b/c4/test/support.py
@@ -115,8 +115,6 @@
#include "stmgc.h"
#include "stmimpl.h"
- //extern gcptr stmgcpage_malloc(size_t size);
- //extern void stmgcpage_free(gcptr obj);
//extern void stmgcpage_possibly_major_collect(int);
extern revision_t stm_global_cur_time(void);
//extern void stmgcpage_add_prebuilt_root(gcptr);
@@ -408,7 +406,7 @@
def oalloc(size):
"Allocate an 'old' protected object, outside any nursery"
- p = ffi.cast("gcptr", lib.stm_malloc(size))
+ p = lib.stmgcpage_malloc(size)
p.h_tid = GCFLAG_OLD | GCFLAG_WRITE_BARRIER
p.h_revision = -sys.maxint
lib.settid(p, 42 + size)
@@ -417,7 +415,7 @@
def oalloc_refs(nrefs):
"""Allocate an 'old' protected object, outside any nursery,
with nrefs pointers"""
- p = ffi.cast("gcptr", lib.stm_malloc(HDR + WORD * nrefs))
+ p = lib.stmgcpage_malloc(HDR + WORD * nrefs)
p.h_tid = GCFLAG_OLD | GCFLAG_WRITE_BARRIER
p.h_revision = -sys.maxint
lib.settid(p, 421 + nrefs)
diff --git a/c4/test/test_gcpage.py b/c4/test/test_gcpage.py
--- a/c4/test/test_gcpage.py
+++ b/c4/test/test_gcpage.py
@@ -43,3 +43,16 @@
p = lib.stmgcpage_malloc(HDR)
assert distance(plist[-1], p) != HDR
assert count_pages() == 2
+
+def test_thread_local_malloc():
+ assert count_global_pages() == 0
+ where = []
+ def f1(r):
+ where.append(oalloc(HDR))
+ def f2(r):
+ where.append(oalloc(HDR))
+ run_parallel(f1, f2)
+ assert count_pages() == 0
+ assert count_global_pages() == 2
+ p3, p4 = where
+ assert abs(distance(p3, p4)) > PAGE_ROOM / 2
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit