Author: Remi Meier <[email protected]>
Branch:
Changeset: r1746:9ac6dfa3ca3b
Date: 2015-04-02 10:37 +0200
http://bitbucket.org/pypy/stmgc/changeset/9ac6dfa3ca3b/
Log: minor improvement by using allocate_old_small for small prebuilt
objs
diff --git a/c8/stm/gcpage.c b/c8/stm/gcpage.c
--- a/c8/stm/gcpage.c
+++ b/c8/stm/gcpage.c
@@ -106,6 +106,9 @@
object_t *_stm_allocate_old(ssize_t size_rounded_up)
{
/* only for tests xxx but stm_setup_prebuilt() uses this now too */
+ if (size_rounded_up <= GC_LAST_SMALL_SIZE)
+ return _stm_allocate_old_small(size_rounded_up);
+
stm_char *p = allocate_outside_nursery_large(size_rounded_up);
object_t *o = (object_t *)p;
diff --git a/c8/test/test_card_marking.py b/c8/test/test_card_marking.py
--- a/c8/test/test_card_marking.py
+++ b/c8/test/test_card_marking.py
@@ -374,3 +374,28 @@
self.start_transaction()
assert stm_get_char(o, HDR) == '\0'
+
+ def test_some_sizes(self):
+ sizes = range(16, GC_LAST_SMALL_SIZE*2, 16) + [FAST_ALLOC,
FAST_ALLOC+16]
+ old = stm_allocate_old_refs(1)
+ for size in sizes:
+ self.start_transaction()
+ p = stm_allocate(size)
+ stm_set_char(p, 'a', use_cards=True)
+ stm_set_ref(old, 0, p)
+ self.commit_transaction()
+
+ self.start_transaction()
+ p = stm_get_ref(old, 0)
+ assert stm_get_char(p) == 'a'
+ stm_set_char(p, 'b', use_cards=True)
+ self.commit_transaction()
+
+ self.switch(1)
+
+ self.start_transaction()
+ p = stm_get_ref(old, 0)
+ assert stm_get_char(p) == 'b'
+ self.commit_transaction()
+
+ self.switch(0)
diff --git a/c8/test/test_gcpage.py b/c8/test/test_gcpage.py
--- a/c8/test/test_gcpage.py
+++ b/c8/test/test_gcpage.py
@@ -318,10 +318,16 @@
def test_keepalive_prebuilt(self):
stm_allocate_old(64)
+ big = GC_LAST_SMALL_SIZE+64
+ stm_allocate_old(big)
+
+ # see allocate_outside_nursery_large:
+ actual_big = (big + 15 ) & ~15
+
self.start_transaction()
- assert lib._stm_total_allocated() == 64 + LMO # large malloc'd
+ assert lib._stm_total_allocated() == 64 + (actual_big + LMO) # large
malloc'd
stm_major_collect()
- assert lib._stm_total_allocated() == 64 + LMO # large malloc'd
+ assert lib._stm_total_allocated() == 64 + (actual_big + LMO) # large
malloc'd
self.commit_transaction()
def test_bug(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit