Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r234:87869a164209 Date: 2013-06-22 14:55 +0200 http://bitbucket.org/pypy/stmgc/changeset/87869a164209/
Log: Simplify the allocation of stubs, at the cost of ~9/10th of a pointer :-) For now it's good enough. We'll try later to compress one or two pointer fields off some objects. diff --git a/c4/steal.c b/c4/steal.c --- a/c4/steal.c +++ b/c4/steal.c @@ -1,50 +1,14 @@ #include "stmimpl.h" -#define STUB_PAGE (4096 - 2*WORD) -#define STUB_NB_OBJS ((STUB_BLOCK_SIZE - 2*WORD) / \ - sizeof(struct stm_object_s)) - -struct stub_block_s { - struct tx_public_descriptor *thread; - struct stub_block_s *next; - struct stm_object_s stubs[STUB_NB_OBJS]; -}; - inline void copy_to_old_id_copy(gcptr obj, gcptr id); gcptr stm_stub_malloc(struct tx_public_descriptor *pd) { assert(pd->collection_lock != 0); - gcptr p = pd->stub_free_list; - if (p == NULL) { - assert(sizeof(struct stub_block_s) == STUB_BLOCK_SIZE); - - /* XXX free! */ - char *page = stm_malloc(STUB_PAGE); - char *page_end = page + STUB_PAGE; - page += (-(revision_t)page) & (STUB_BLOCK_SIZE-1); /* round up */ - - struct stub_block_s *b = (struct stub_block_s *)page; - struct stub_block_s *nextb = NULL; - gcptr nextp = NULL; - int i; - - while (((char *)(b + 1)) <= page_end) { - b->thread = pd; - b->next = nextb; - for (i = 0; i < STUB_NB_OBJS; i++) { - b->stubs[i].h_revision = (revision_t)nextp; - nextp = &b->stubs[i]; - } - b++; - } - assert(nextp != NULL); - p = nextp; - } - pd->stub_free_list = (gcptr)p->h_revision; - assert(STUB_THREAD(p) == pd); + gcptr p = stmgcpage_malloc(sizeof(struct stm_stub_s)); + STUB_THREAD(p) = pd; return p; } diff --git a/c4/steal.h b/c4/steal.h --- a/c4/steal.h +++ b/c4/steal.h @@ -2,10 +2,12 @@ #define _SRCSTM_STEAL_H -#define STUB_BLOCK_SIZE (32 * WORD) /* power of two */ +struct stm_stub_s { + struct stm_object_s s_header; + struct tx_public_descriptor *s_thread; +}; -#define STUB_THREAD(h) (*(struct tx_public_descriptor **) \ - (((revision_t)(h)) & ~(STUB_BLOCK_SIZE-1))) +#define STUB_THREAD(h) (((struct stm_stub_s *)(h))->s_thread) gcptr stm_stub_malloc(struct tx_public_descriptor *); void stm_steal_stub(gcptr); diff --git a/c4/test/support.py b/c4/test/support.py --- a/c4/test/support.py +++ b/c4/test/support.py @@ -100,7 +100,6 @@ /* some constants normally private that are useful in the tests */ #define WORD ... #define GC_PAGE_SIZE ... - #define STUB_BLOCK_SIZE ... #define GCFLAG_OLD ... #define GCFLAG_VISITED ... #define GCFLAG_PUBLIC ... _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit