mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
Eliminating type puns on scan states, location dependencies, and allocation points through the mps interface.
Now that we're recommending inlining with client code and optimising with -O2 or -O3, we can't afford any bug introduced by the strict aliasing rule. Copied from Perforce Change: 179322 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
e17fee98ea
commit
78d5f049f0
32 changed files with 379 additions and 477 deletions
|
|
@ -182,8 +182,8 @@ static void *test(void *arg, size_t s)
|
|||
die(mps_pool_create(&pool, arena, mps_class_amc(), format, chain),
|
||||
"pool_create(amc)");
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, MPS_RANK_EXACT), "BufferCreate 2");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, mps_rank_exact()), "BufferCreate 2");
|
||||
|
||||
for(i = 0; i < exactRootsCOUNT; ++i)
|
||||
exactRoots[i] = objNULL;
|
||||
|
|
@ -191,12 +191,12 @@ static void *test(void *arg, size_t s)
|
|||
ambigRoots[i] = rnd_addr();
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&exactRoots[0], exactRootsCOUNT,
|
||||
(mps_word_t)1),
|
||||
"root_create_table(exact)");
|
||||
die(mps_root_create_table(&ambigRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
&ambigRoots[0], ambigRootsCOUNT),
|
||||
"root_create_table(ambig)");
|
||||
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ static void *test(void *arg, size_t s)
|
|||
die(mps_pool_create(&pool, arena, mps_class_amc(), format, chain),
|
||||
"pool_create(amc)");
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, MPS_RANK_EXACT), "BufferCreate 2");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, mps_rank_exact()), "BufferCreate 2");
|
||||
|
||||
for(i = 0; i < exactRootsCOUNT; ++i)
|
||||
exactRoots[i] = objNULL;
|
||||
|
|
@ -136,16 +136,16 @@ static void *test(void *arg, size_t s)
|
|||
ambigRoots[i] = rnd_addr();
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&exactRoots[0], exactRootsCOUNT,
|
||||
(mps_word_t)1),
|
||||
"root_create_table(exact)");
|
||||
die(mps_root_create_table(&ambigRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
&ambigRoots[0], ambigRootsCOUNT),
|
||||
"root_create_table(ambig)");
|
||||
die(mps_root_create_table(&bogusRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
&bogusRoots[0], bogusRootsCOUNT),
|
||||
"root_create_table(bogus)");
|
||||
|
||||
|
|
|
|||
|
|
@ -133,12 +133,12 @@ static void init(void)
|
|||
ambigRoots[i] = rnd_addr();
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&exactRoots[0], exactRootsCOUNT,
|
||||
(mps_word_t)1),
|
||||
"root_create_table(exact)");
|
||||
die(mps_root_create_table(&ambigRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
&ambigRoots[0], ambigRootsCOUNT),
|
||||
"root_create_table(ambig)");
|
||||
}
|
||||
|
|
@ -196,8 +196,8 @@ static void *test(void *arg, size_t s)
|
|||
arena = (mps_arena_t)arg;
|
||||
(void)s; /* unused */
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, MPS_RANK_EXACT), "BufferCreate 2");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, mps_rank_exact()), "BufferCreate 2");
|
||||
|
||||
/* create an ap, and leave it busy */
|
||||
die(mps_reserve(&busy_init, busy_ap, 64), "mps_reserve busy");
|
||||
|
|
@ -281,7 +281,7 @@ static void *fooey2(void *arg, size_t s)
|
|||
mps_ap_t ap;
|
||||
|
||||
(void)arg; (void)s; /* unused */
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate(fooey)");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate(fooey)");
|
||||
while(mps_collections(arena) < collectionsCOUNT) {
|
||||
churn(ap);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ static void *test(void *arg, size_t haveAmbigous)
|
|||
|
||||
pool = (mps_pool_t)arg;
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, MPS_RANK_EXACT), "BufferCreate 2");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, mps_rank_exact()), "BufferCreate 2");
|
||||
|
||||
for(i = 0; i < exactRootsCOUNT; ++i)
|
||||
exactRoots[i] = objNULL;
|
||||
|
|
@ -136,13 +136,13 @@ static void *test(void *arg, size_t haveAmbigous)
|
|||
ambigRoots[i] = rnd_addr();
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&exactRoots[0], exactRootsCOUNT,
|
||||
(mps_word_t)1),
|
||||
"root_create_table(exact)");
|
||||
if (haveAmbigous)
|
||||
die(mps_root_create_table(&ambigRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
&ambigRoots[0], ambigRootsCOUNT),
|
||||
"root_create_table(ambig)");
|
||||
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ static void *test(void *arg, size_t s)
|
|||
die(mps_pool_create(&pool, arena, mps_class_ams(), format, chain,
|
||||
TRUE), "pool_create(ams)");
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, MPS_RANK_EXACT), "BufferCreate 2");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, mps_rank_exact()), "BufferCreate 2");
|
||||
|
||||
for(i = 0; i < exactRootsCOUNT; ++i)
|
||||
exactRoots[i] = objNULL;
|
||||
|
|
@ -92,12 +92,12 @@ static void *test(void *arg, size_t s)
|
|||
ambigRoots[i] = rnd_addr();
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&exactRoots[0], exactRootsCOUNT,
|
||||
(mps_word_t)1),
|
||||
"root_create_table(exact)");
|
||||
die(mps_root_create_table(&ambigRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
&ambigRoots[0], ambigRootsCOUNT),
|
||||
"root_create_table(ambig)");
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ static mps_res_t stress(mps_class_t class, size_t (*size)(int i),
|
|||
if (res != MPS_RES_OK)
|
||||
return res;
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
|
||||
|
||||
/* allocate a load of objects */
|
||||
for (i=0; i<testSetSIZE; ++i) {
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ static void *setup(void *v, size_t s)
|
|||
arena = guff->arena;
|
||||
thr = guff->thr;
|
||||
|
||||
die(mps_root_create_reg(&stack, arena, MPS_RANK_AMBIG, 0, thr,
|
||||
die(mps_root_create_reg(&stack, arena, mps_rank_ambig(), 0, thr,
|
||||
mps_stack_scan_ambig, v, 0),
|
||||
"Root Create\n");
|
||||
die(mps_fmt_create_A(&dylanfmt, arena, dylan_fmt_A()),
|
||||
|
|
@ -269,13 +269,13 @@ static void *setup(void *v, size_t s)
|
|||
die(mps_pool_create(&tablepool, arena, mps_class_awl(), dylanweakfmt,
|
||||
dylan_weak_dependent),
|
||||
"Table Pool Create\n");
|
||||
die(mps_ap_create(&leafap, leafpool, MPS_RANK_EXACT),
|
||||
die(mps_ap_create(&leafap, leafpool, mps_rank_exact()),
|
||||
"Leaf AP Create\n");
|
||||
die(mps_ap_create(&exactap, tablepool, MPS_RANK_EXACT),
|
||||
die(mps_ap_create(&exactap, tablepool, mps_rank_exact()),
|
||||
"Exact AP Create\n");
|
||||
die(mps_ap_create(&weakap, tablepool, MPS_RANK_WEAK),
|
||||
die(mps_ap_create(&weakap, tablepool, mps_rank_weak()),
|
||||
"Weak AP Create\n");
|
||||
die(mps_ap_create(&bogusap, tablepool, MPS_RANK_EXACT),
|
||||
die(mps_ap_create(&bogusap, tablepool, mps_rank_exact()),
|
||||
"Bogus AP Create\n");
|
||||
|
||||
test(leafap, exactap, weakap, bogusap);
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ static void *setup(void *v, size_t s)
|
|||
arena = guff->arena;
|
||||
thr = guff->thr;
|
||||
|
||||
die(mps_root_create_reg(&stack, arena, MPS_RANK_AMBIG, 0, thr,
|
||||
die(mps_root_create_reg(&stack, arena, mps_rank_ambig(), 0, thr,
|
||||
mps_stack_scan_ambig, v, 0),
|
||||
"Root Create\n");
|
||||
EnsureHeaderFormat(&dylanfmt, arena);
|
||||
|
|
@ -272,13 +272,13 @@ static void *setup(void *v, size_t s)
|
|||
die(mps_pool_create(&tablepool, arena, mps_class_awl(), dylanweakfmt,
|
||||
dylan_weak_dependent),
|
||||
"Table Pool Create\n");
|
||||
die(mps_ap_create(&leafap, leafpool, MPS_RANK_EXACT),
|
||||
die(mps_ap_create(&leafap, leafpool, mps_rank_exact()),
|
||||
"Leaf AP Create\n");
|
||||
die(mps_ap_create(&exactap, tablepool, MPS_RANK_EXACT),
|
||||
die(mps_ap_create(&exactap, tablepool, mps_rank_exact()),
|
||||
"Exact AP Create\n");
|
||||
die(mps_ap_create(&weakap, tablepool, MPS_RANK_WEAK),
|
||||
die(mps_ap_create(&weakap, tablepool, mps_rank_weak()),
|
||||
"Weak AP Create\n");
|
||||
die(mps_ap_create(&bogusap, tablepool, MPS_RANK_EXACT),
|
||||
die(mps_ap_create(&bogusap, tablepool, mps_rank_exact()),
|
||||
"Bogus AP Create\n");
|
||||
|
||||
test(leafap, exactap, weakap, bogusap);
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ static void *setup(void *v, size_t s)
|
|||
arena = guff->arena;
|
||||
thr = guff->thr;
|
||||
|
||||
die(mps_root_create_reg(&stack, arena, MPS_RANK_AMBIG, 0, thr,
|
||||
die(mps_root_create_reg(&stack, arena, mps_rank_ambig(), 0, thr,
|
||||
mps_stack_scan_ambig, v, 0),
|
||||
"Root Create\n");
|
||||
die(mps_fmt_create_A(&dylanfmt, arena, dylan_fmt_A()),
|
||||
|
|
@ -267,13 +267,13 @@ static void *setup(void *v, size_t s)
|
|||
die(mps_pool_create(&tablepool, arena, mps_class_awl(), dylanweakfmt,
|
||||
dylan_weak_dependent),
|
||||
"Table Pool Create\n");
|
||||
die(mps_ap_create(&leafap, leafpool, MPS_RANK_EXACT),
|
||||
die(mps_ap_create(&leafap, leafpool, mps_rank_exact()),
|
||||
"Leaf AP Create\n");
|
||||
die(mps_ap_create(&exactap, tablepool, MPS_RANK_EXACT),
|
||||
die(mps_ap_create(&exactap, tablepool, mps_rank_exact()),
|
||||
"Exact AP Create\n");
|
||||
die(mps_ap_create(&weakap, tablepool, MPS_RANK_WEAK),
|
||||
die(mps_ap_create(&weakap, tablepool, mps_rank_weak()),
|
||||
"Weak AP Create\n");
|
||||
die(mps_ap_create(&bogusap, tablepool, MPS_RANK_EXACT),
|
||||
die(mps_ap_create(&bogusap, tablepool, mps_rank_exact()),
|
||||
"Bogus AP Create\n");
|
||||
|
||||
test(leafap, exactap, weakap, bogusap);
|
||||
|
|
|
|||
|
|
@ -51,14 +51,14 @@ Bool BufferCheck(Buffer buffer)
|
|||
CHECKL(buffer->emptySize <= buffer->fillSize);
|
||||
CHECKL(buffer->alignment == buffer->pool->alignment);
|
||||
CHECKL(AlignCheck(buffer->alignment));
|
||||
CHECKL(BoolCheck(buffer->apStruct.enabled));
|
||||
CHECKL(BoolCheck(buffer->ap_s._enabled));
|
||||
|
||||
if (buffer->apStruct.enabled) {
|
||||
if (buffer->ap_s._enabled) {
|
||||
/* no useful check for frameptr - mutator may be updating it */
|
||||
CHECKL(BoolCheck(buffer->apStruct.lwPopPending));
|
||||
CHECKL(BoolCheck(buffer->ap_s._lwpoppending));
|
||||
} else {
|
||||
CHECKL(buffer->apStruct.lwPopPending == FALSE);
|
||||
CHECKL(buffer->apStruct.frameptr == NULL);
|
||||
CHECKL(buffer->ap_s._lwpoppending == FALSE);
|
||||
CHECKL(buffer->ap_s._frameptr == NULL);
|
||||
}
|
||||
|
||||
/* If any of the buffer's fields indicate that it is reset, make */
|
||||
|
|
@ -68,15 +68,15 @@ Bool BufferCheck(Buffer buffer)
|
|||
/* nothing to check */
|
||||
} else if ((buffer->mode & BufferModeATTACHED) == 0
|
||||
|| buffer->base == (Addr)0
|
||||
|| buffer->apStruct.init == (Addr)0
|
||||
|| buffer->apStruct.alloc == (Addr)0
|
||||
|| buffer->ap_s.init == (Addr)0
|
||||
|| buffer->ap_s.alloc == (Addr)0
|
||||
|| buffer->poolLimit == (Addr)0) {
|
||||
CHECKL((buffer->mode & BufferModeATTACHED) == 0);
|
||||
CHECKL(buffer->base == (Addr)0);
|
||||
CHECKL(buffer->initAtFlip == (Addr)0);
|
||||
CHECKL(buffer->apStruct.init == (Addr)0);
|
||||
CHECKL(buffer->apStruct.alloc == (Addr)0);
|
||||
CHECKL(buffer->apStruct.limit == (Addr)0);
|
||||
CHECKL(buffer->ap_s.init == (Addr)0);
|
||||
CHECKL(buffer->ap_s.alloc == (Addr)0);
|
||||
CHECKL(buffer->ap_s.limit == (Addr)0);
|
||||
/* Nothing reliable to check for lightweight frame state */
|
||||
CHECKL(buffer->poolLimit == (Addr)0);
|
||||
} else {
|
||||
|
|
@ -88,16 +88,16 @@ Bool BufferCheck(Buffer buffer)
|
|||
|
||||
/* These fields should obey the ordering */
|
||||
/* base <= init <= alloc <= poolLimit */
|
||||
CHECKL(buffer->base <= buffer->apStruct.init);
|
||||
CHECKL(buffer->apStruct.init <= buffer->apStruct.alloc);
|
||||
CHECKL(buffer->apStruct.alloc <= buffer->poolLimit);
|
||||
CHECKL((mps_addr_t)buffer->base <= buffer->ap_s.init);
|
||||
CHECKL(buffer->ap_s.init <= buffer->ap_s.alloc);
|
||||
CHECKL(buffer->ap_s.alloc <= (mps_addr_t)buffer->poolLimit);
|
||||
|
||||
/* Check that the fields are aligned to the buffer alignment. */
|
||||
CHECKL(AddrIsAligned(buffer->base, buffer->alignment));
|
||||
CHECKL(AddrIsAligned(buffer->initAtFlip, buffer->alignment));
|
||||
CHECKL(AddrIsAligned(buffer->apStruct.init, buffer->alignment));
|
||||
CHECKL(AddrIsAligned(buffer->apStruct.alloc, buffer->alignment));
|
||||
CHECKL(AddrIsAligned(buffer->apStruct.limit, buffer->alignment));
|
||||
CHECKL(AddrIsAligned(buffer->ap_s.init, buffer->alignment));
|
||||
CHECKL(AddrIsAligned(buffer->ap_s.alloc, buffer->alignment));
|
||||
CHECKL(AddrIsAligned(buffer->ap_s.limit, buffer->alignment));
|
||||
CHECKL(AddrIsAligned(buffer->poolLimit, buffer->alignment));
|
||||
|
||||
/* .lwcheck: If LW frames are enabled, the buffer may become */
|
||||
|
|
@ -106,7 +106,7 @@ Bool BufferCheck(Buffer buffer)
|
|||
/* Read a snapshot value of the limit field. Use this to determine */
|
||||
/* if we are trapped, and to permit more useful checking when not */
|
||||
/* yet trapped. */
|
||||
aplimit = buffer->apStruct.limit;
|
||||
aplimit = buffer->ap_s.limit;
|
||||
|
||||
/* If the buffer isn't trapped then "limit" should be the limit */
|
||||
/* set by the owning pool. Otherwise, "init" is either at the */
|
||||
|
|
@ -117,17 +117,17 @@ Bool BufferCheck(Buffer buffer)
|
|||
/* is kept at zero to avoid misuse (see */
|
||||
/* request.dylan.170429.sol.zero). */
|
||||
|
||||
if ((buffer->apStruct.enabled && aplimit == (Addr)0) /* see .lwcheck */
|
||||
|| (!buffer->apStruct.enabled && BufferIsTrapped(buffer))) {
|
||||
if ((buffer->ap_s._enabled && aplimit == (Addr)0) /* see .lwcheck */
|
||||
|| (!buffer->ap_s._enabled && BufferIsTrapped(buffer))) {
|
||||
/* .check.use-trapped: This checking function uses BufferIsTrapped, */
|
||||
/* So BufferIsTrapped can't do checking as that would cause an */
|
||||
/* infinite loop. */
|
||||
CHECKL(aplimit == (Addr)0);
|
||||
if (buffer->mode & BufferModeFLIPPED) {
|
||||
CHECKL(buffer->apStruct.init == buffer->initAtFlip
|
||||
|| buffer->apStruct.init == buffer->apStruct.alloc);
|
||||
CHECKL(buffer->ap_s.init == buffer->initAtFlip
|
||||
|| buffer->ap_s.init == buffer->ap_s.alloc);
|
||||
CHECKL(buffer->base <= buffer->initAtFlip);
|
||||
CHECKL(buffer->initAtFlip <= buffer->apStruct.init);
|
||||
CHECKL(buffer->initAtFlip <= (Addr)buffer->ap_s.init);
|
||||
}
|
||||
/* Nothing special to check in the logged mode. */
|
||||
} else {
|
||||
|
|
@ -174,9 +174,9 @@ Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream)
|
|||
" alignment $W\n", (WriteFW)buffer->alignment,
|
||||
" base $A\n", buffer->base,
|
||||
" initAtFlip $A\n", buffer->initAtFlip,
|
||||
" init $A\n", buffer->apStruct.init,
|
||||
" alloc $A\n", buffer->apStruct.alloc,
|
||||
" limit $A\n", buffer->apStruct.limit,
|
||||
" init $A\n", buffer->ap_s.init,
|
||||
" alloc $A\n", buffer->ap_s.alloc,
|
||||
" limit $A\n", buffer->ap_s.limit,
|
||||
" poolLimit $A\n", buffer->poolLimit,
|
||||
NULL);
|
||||
if (res != ResOK) return res;
|
||||
|
|
@ -223,12 +223,15 @@ static Res BufferInitV(Buffer buffer, BufferClass class,
|
|||
buffer->alignment = pool->alignment; /* .trans.mod */
|
||||
buffer->base = (Addr)0;
|
||||
buffer->initAtFlip = (Addr)0;
|
||||
buffer->apStruct.init = (Addr)0;
|
||||
buffer->apStruct.alloc = (Addr)0;
|
||||
buffer->apStruct.limit = (Addr)0;
|
||||
buffer->apStruct.frameptr = NULL;
|
||||
buffer->apStruct.enabled = FALSE;
|
||||
buffer->apStruct.lwPopPending = FALSE;
|
||||
/* In the next three assignements we really mean zero, not NULL, because
|
||||
the bit pattern is compared. It's pretty unlikely we'll encounter
|
||||
a platform where this makes a difference. */
|
||||
buffer->ap_s.init = (mps_addr_t)0;
|
||||
buffer->ap_s.alloc = (mps_addr_t)0;
|
||||
buffer->ap_s.limit = (mps_addr_t)0;
|
||||
buffer->ap_s._frameptr = NULL;
|
||||
buffer->ap_s._enabled = FALSE;
|
||||
buffer->ap_s._lwpoppending = FALSE;
|
||||
buffer->poolLimit = (Addr)0;
|
||||
buffer->rampCount = 0;
|
||||
|
||||
|
|
@ -327,7 +330,7 @@ void BufferDetach(Buffer buffer, Pool pool)
|
|||
Size spare;
|
||||
|
||||
buffer->mode |= BufferModeTRANSITION;
|
||||
init = buffer->apStruct.init;
|
||||
init = buffer->ap_s.init;
|
||||
limit = buffer->poolLimit;
|
||||
/* Ask the owning pool to do whatever it needs to before the */
|
||||
/* buffer is detached (e.g. copy buffer state into pool state). */
|
||||
|
|
@ -353,9 +356,9 @@ void BufferDetach(Buffer buffer, Pool pool)
|
|||
/* Reset the buffer. */
|
||||
buffer->base = (Addr)0;
|
||||
buffer->initAtFlip = (Addr)0;
|
||||
buffer->apStruct.init = (Addr)0;
|
||||
buffer->apStruct.alloc = (Addr)0;
|
||||
buffer->apStruct.limit = (Addr)0;
|
||||
buffer->ap_s.init = (mps_addr_t)0;
|
||||
buffer->ap_s.alloc = (mps_addr_t)0;
|
||||
buffer->ap_s.limit = (mps_addr_t)0;
|
||||
buffer->poolLimit = (Addr)0;
|
||||
buffer->mode &=
|
||||
~(BufferModeATTACHED|BufferModeFLIPPED|BufferModeTRANSITION);
|
||||
|
|
@ -445,7 +448,7 @@ Bool BufferIsReady(Buffer buffer)
|
|||
{
|
||||
AVERT(Buffer, buffer);
|
||||
|
||||
return buffer->apStruct.init == buffer->apStruct.alloc;
|
||||
return buffer->ap_s.init == buffer->ap_s.alloc;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -470,9 +473,9 @@ static void BufferSetUnflipped(Buffer buffer)
|
|||
AVERT(Buffer, buffer);
|
||||
AVER(buffer->mode & BufferModeFLIPPED);
|
||||
buffer->mode &= ~BufferModeFLIPPED;
|
||||
/* restore apStruct.limit if appropriate */
|
||||
/* restore ap_s.limit if appropriate */
|
||||
if (!BufferIsTrapped(buffer)) {
|
||||
buffer->apStruct.limit = buffer->poolLimit;
|
||||
buffer->ap_s.limit = buffer->poolLimit;
|
||||
}
|
||||
buffer->initAtFlip = (Addr)0;
|
||||
}
|
||||
|
|
@ -486,16 +489,16 @@ static void BufferSetUnflipped(Buffer buffer)
|
|||
FrameState BufferFrameState(Buffer buffer)
|
||||
{
|
||||
AVERT(Buffer, buffer);
|
||||
if (buffer->apStruct.enabled) {
|
||||
if (buffer->apStruct.lwPopPending) {
|
||||
if (buffer->ap_s._enabled) {
|
||||
if (buffer->ap_s._lwpoppending) {
|
||||
return BufferFramePOP_PENDING;
|
||||
} else {
|
||||
AVER(buffer->apStruct.frameptr == NULL);
|
||||
AVER(buffer->ap_s._frameptr == NULL);
|
||||
return BufferFrameVALID;
|
||||
}
|
||||
} else {
|
||||
AVER(buffer->apStruct.frameptr == NULL);
|
||||
AVER(buffer->apStruct.lwPopPending == FALSE);
|
||||
AVER(buffer->ap_s._frameptr == NULL);
|
||||
AVER(buffer->ap_s._lwpoppending == FALSE);
|
||||
return BufferFrameDISABLED;
|
||||
}
|
||||
}
|
||||
|
|
@ -510,9 +513,9 @@ void BufferFrameSetState(Buffer buffer, FrameState state)
|
|||
{
|
||||
AVERT(Buffer, buffer);
|
||||
AVER(state == BufferFrameVALID || state == BufferFrameDISABLED);
|
||||
buffer->apStruct.frameptr = NULL;
|
||||
buffer->apStruct.lwPopPending = FALSE;
|
||||
buffer->apStruct.enabled = (state == BufferFrameVALID);
|
||||
buffer->ap_s._frameptr = NULL;
|
||||
buffer->ap_s._lwpoppending = FALSE;
|
||||
buffer->ap_s._enabled = (state == BufferFrameVALID);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -528,8 +531,8 @@ void BufferSetAllocAddr(Buffer buffer, Addr addr)
|
|||
AVER(buffer->base <= addr);
|
||||
AVER(buffer->poolLimit >= addr);
|
||||
|
||||
buffer->apStruct.init = addr;
|
||||
buffer->apStruct.alloc = addr;
|
||||
buffer->ap_s.init = addr;
|
||||
buffer->ap_s.alloc = addr;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -545,13 +548,13 @@ static void BufferFrameNotifyPopPending(Buffer buffer)
|
|||
Pool pool;
|
||||
AVER(BufferIsTrappedByMutator(buffer));
|
||||
AVER(BufferFrameState(buffer) == BufferFramePOP_PENDING);
|
||||
frame = (AllocFrame)buffer->apStruct.frameptr;
|
||||
frame = (AllocFrame)buffer->ap_s._frameptr;
|
||||
/* Unset PopPending state & notify the pool */
|
||||
BufferFrameSetState(buffer, BufferFrameVALID);
|
||||
/* If the frame is no longer trapped, undo the trap by resetting */
|
||||
/* the AP limit pointer */
|
||||
if (!BufferIsTrapped(buffer)) {
|
||||
buffer->apStruct.limit = buffer->poolLimit;
|
||||
buffer->ap_s.limit = buffer->poolLimit;
|
||||
}
|
||||
pool = BufferPool(buffer);
|
||||
(*pool->class->framePopPending)(pool, buffer, frame);
|
||||
|
|
@ -571,7 +574,7 @@ Res BufferFramePush(AllocFrame *frameReturn, Buffer buffer)
|
|||
|
||||
|
||||
/* Process any flip or PopPending */
|
||||
if (!BufferIsReset(buffer) && buffer->apStruct.limit == (Addr)0) {
|
||||
if (!BufferIsReset(buffer) && buffer->ap_s.limit == (Addr)0) {
|
||||
/* .fill.unflip: If the buffer is flipped then we unflip the buffer. */
|
||||
if (buffer->mode & BufferModeFLIPPED) {
|
||||
BufferSetUnflipped(buffer);
|
||||
|
|
@ -622,10 +625,11 @@ Res BufferReserve(Addr *pReturn, Buffer buffer, Size size,
|
|||
/* Is there enough room in the unallocated portion of the buffer to */
|
||||
/* satisfy the request? If so, just increase the alloc marker and */
|
||||
/* return a pointer to the area below it. */
|
||||
next = AddrAdd(buffer->apStruct.alloc, size);
|
||||
if (next > buffer->apStruct.alloc && next <= buffer->apStruct.limit) {
|
||||
buffer->apStruct.alloc = next;
|
||||
*pReturn = buffer->apStruct.init;
|
||||
next = AddrAdd(buffer->ap_s.alloc, size);
|
||||
if (next > (Addr)buffer->ap_s.alloc &&
|
||||
next <= (Addr)buffer->ap_s.limit) {
|
||||
buffer->ap_s.alloc = next;
|
||||
*pReturn = buffer->ap_s.init;
|
||||
return ResOK;
|
||||
}
|
||||
|
||||
|
|
@ -653,13 +657,13 @@ void BufferAttach(Buffer buffer, Addr base, Addr limit,
|
|||
/* Set up the buffer to point at the supplied region */
|
||||
buffer->mode |= BufferModeATTACHED;
|
||||
buffer->base = base;
|
||||
buffer->apStruct.init = init;
|
||||
buffer->apStruct.alloc = AddrAdd(init, size);
|
||||
buffer->ap_s.init = init;
|
||||
buffer->ap_s.alloc = AddrAdd(init, size);
|
||||
/* only set limit if not logged */
|
||||
if ((buffer->mode & BufferModeLOGGED) == 0) {
|
||||
buffer->apStruct.limit = limit;
|
||||
buffer->ap_s.limit = limit;
|
||||
} else {
|
||||
AVER(buffer->apStruct.limit == (Addr)0);
|
||||
AVER(buffer->ap_s.limit == (Addr)0);
|
||||
}
|
||||
AVER(buffer->initAtFlip == (Addr)0);
|
||||
buffer->poolLimit = limit;
|
||||
|
|
@ -710,7 +714,7 @@ Res BufferFill(Addr *pReturn, Buffer buffer, Size size,
|
|||
|
||||
/* If we're here because the buffer was trapped, then we attempt */
|
||||
/* the allocation here. */
|
||||
if (!BufferIsReset(buffer) && buffer->apStruct.limit == (Addr)0) {
|
||||
if (!BufferIsReset(buffer) && buffer->ap_s.limit == (Addr)0) {
|
||||
/* .fill.unflip: If the buffer is flipped then we unflip the buffer. */
|
||||
if (buffer->mode & BufferModeFLIPPED) {
|
||||
BufferSetUnflipped(buffer);
|
||||
|
|
@ -722,21 +726,21 @@ Res BufferFill(Addr *pReturn, Buffer buffer, Size size,
|
|||
}
|
||||
|
||||
/* .fill.logged: If the buffer is logged then we leave it logged. */
|
||||
next = AddrAdd(buffer->apStruct.alloc, size);
|
||||
if (next > buffer->apStruct.alloc &&
|
||||
next <= buffer->poolLimit) {
|
||||
buffer->apStruct.alloc = next;
|
||||
next = AddrAdd(buffer->ap_s.alloc, size);
|
||||
if (next > (Addr)buffer->ap_s.alloc &&
|
||||
next <= (Addr)buffer->poolLimit) {
|
||||
buffer->ap_s.alloc = next;
|
||||
if (buffer->mode & BufferModeLOGGED) {
|
||||
EVENT3(BufferReserve, buffer, buffer->apStruct.init, size);
|
||||
EVENT3(BufferReserve, buffer, buffer->ap_s.init, size);
|
||||
}
|
||||
*pReturn = buffer->apStruct.init;
|
||||
*pReturn = buffer->ap_s.init;
|
||||
return ResOK;
|
||||
}
|
||||
}
|
||||
|
||||
/* There really isn't enough room for the allocation now. */
|
||||
AVER(AddrAdd(buffer->apStruct.alloc, size) > buffer->poolLimit
|
||||
|| AddrAdd(buffer->apStruct.alloc, size) < buffer->apStruct.alloc);
|
||||
AVER(AddrAdd(buffer->ap_s.alloc, size) > buffer->poolLimit ||
|
||||
AddrAdd(buffer->ap_s.alloc, size) < (Addr)buffer->ap_s.alloc);
|
||||
|
||||
BufferDetach(buffer, pool);
|
||||
|
||||
|
|
@ -752,7 +756,7 @@ Res BufferFill(Addr *pReturn, Buffer buffer, Size size,
|
|||
BufferAttach(buffer, base, limit, base, size);
|
||||
|
||||
if (buffer->mode & BufferModeLOGGED) {
|
||||
EVENT3(BufferReserve, buffer, buffer->apStruct.init, size);
|
||||
EVENT3(BufferReserve, buffer, buffer->ap_s.init, size);
|
||||
}
|
||||
|
||||
*pReturn = base;
|
||||
|
|
@ -776,13 +780,13 @@ Bool BufferCommit(Buffer buffer, Addr p, Size size)
|
|||
/* .commit.before: If a flip occurs before this point, when the */
|
||||
/* pool reads "initAtFlip" it will point below the object, so it */
|
||||
/* will be trashed and the commit must fail when trip is called. */
|
||||
AVER(p == buffer->apStruct.init);
|
||||
AVER(AddrAdd(buffer->apStruct.init, size) == buffer->apStruct.alloc);
|
||||
AVER(p == buffer->ap_s.init);
|
||||
AVER(AddrAdd(buffer->ap_s.init, size) == buffer->ap_s.alloc);
|
||||
|
||||
/* .commit.update: Atomically update the init pointer to declare */
|
||||
/* that the object is initialized (though it may be invalid if a */
|
||||
/* flip occurred). */
|
||||
buffer->apStruct.init = buffer->apStruct.alloc;
|
||||
buffer->ap_s.init = buffer->ap_s.alloc;
|
||||
|
||||
/* .improve.memory-barrier: Memory barrier here on the DEC Alpha */
|
||||
/* (and other relaxed memory order architectures). */
|
||||
|
|
@ -791,7 +795,7 @@ Bool BufferCommit(Buffer buffer, Addr p, Size size)
|
|||
/* be collected. The commit must succeed when trip is called. */
|
||||
/* The pointer "p" will have been fixed up. (@@@@ Will it?) */
|
||||
/* .commit.trip: Trip the buffer if a flip has occurred. */
|
||||
if (buffer->apStruct.limit == 0)
|
||||
if (buffer->ap_s.limit == 0)
|
||||
return BufferTrip(buffer, p, size);
|
||||
|
||||
/* No flip occurred, so succeed. */
|
||||
|
|
@ -817,7 +821,7 @@ Bool BufferTrip(Buffer buffer, Addr p, Size size)
|
|||
|
||||
/* The limit field should be zero, because that's how trip gets */
|
||||
/* called. See .commit.trip. */
|
||||
AVER(buffer->apStruct.limit == 0);
|
||||
AVER(buffer->ap_s.limit == 0);
|
||||
/* Of course we should be trapped. */
|
||||
AVER(BufferIsTrapped(buffer));
|
||||
/* But the mutator shouldn't have caused the trap */
|
||||
|
|
@ -825,7 +829,7 @@ Bool BufferTrip(Buffer buffer, Addr p, Size size)
|
|||
|
||||
/* The init and alloc fields should be equal at this point, because */
|
||||
/* the step .commit.update has happened. */
|
||||
AVER(buffer->apStruct.init == buffer->apStruct.alloc);
|
||||
AVER(buffer->ap_s.init == buffer->ap_s.alloc);
|
||||
|
||||
/* The p parameter points at the base address of the allocated */
|
||||
/* block, the end of which should now coincide with the init and */
|
||||
|
|
@ -835,7 +839,7 @@ Bool BufferTrip(Buffer buffer, Addr p, Size size)
|
|||
/* it seems like the algorithms could be modified to cope with the */
|
||||
/* case of the object having been copied between Commit updating i */
|
||||
/* and testing limit) */
|
||||
AVER(AddrAdd(p, size) == buffer->apStruct.init);
|
||||
AVER(AddrAdd(p, size) == buffer->ap_s.init);
|
||||
|
||||
pool = BufferPool(buffer);
|
||||
|
||||
|
|
@ -847,13 +851,13 @@ Bool BufferTrip(Buffer buffer, Addr p, Size size)
|
|||
/* Otherwise (see .commit.after) the object is valid (will've been */
|
||||
/* scanned) so commit can simply succeed. */
|
||||
if ((buffer->mode & BufferModeFLIPPED)
|
||||
&& buffer->apStruct.init != buffer->initAtFlip) {
|
||||
&& buffer->ap_s.init != buffer->initAtFlip) {
|
||||
/* Reset just enough state for Reserve/Fill to work. */
|
||||
/* The buffer is left trapped and we leave the untrapping */
|
||||
/* for the next reserve (which goes out of line to Fill */
|
||||
/* (.fill.unflip) because the buffer is still trapped) */
|
||||
buffer->apStruct.init = p;
|
||||
buffer->apStruct.alloc = p;
|
||||
buffer->ap_s.init = p;
|
||||
buffer->ap_s.alloc = p;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -901,9 +905,9 @@ void BufferFlip(Buffer buffer)
|
|||
&& (buffer->mode & BufferModeFLIPPED) == 0
|
||||
&& !BufferIsReset(buffer)) {
|
||||
AVER(buffer->initAtFlip == (Addr)0);
|
||||
buffer->initAtFlip = buffer->apStruct.init;
|
||||
buffer->initAtFlip = buffer->ap_s.init;
|
||||
/* Memory Barrier here? @@@@ */
|
||||
buffer->apStruct.limit = (Addr)0;
|
||||
buffer->ap_s.limit = (Addr)0;
|
||||
buffer->mode |= BufferModeFLIPPED;
|
||||
}
|
||||
}
|
||||
|
|
@ -922,7 +926,7 @@ Addr BufferScanLimit(Buffer buffer)
|
|||
if (buffer->mode & BufferModeFLIPPED) {
|
||||
return buffer->initAtFlip;
|
||||
} else {
|
||||
return buffer->apStruct.init;
|
||||
return buffer->ap_s.init;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -984,9 +988,9 @@ Bool BufferIsTrapped(Buffer buffer)
|
|||
|
||||
Bool BufferIsTrappedByMutator(Buffer buffer)
|
||||
{
|
||||
AVER(!buffer->apStruct.lwPopPending || buffer->apStruct.enabled);
|
||||
AVER(!buffer->ap_s._lwpoppending || buffer->ap_s._enabled);
|
||||
/* Can't check buffer, see .check.use-trapped */
|
||||
return buffer->apStruct.lwPopPending;
|
||||
return buffer->ap_s._lwpoppending;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -151,8 +151,8 @@ static void *test(void *arg, size_t s)
|
|||
die(mps_pool_create(&pool_g, arena, mps_class_amc(), format, chain),
|
||||
"pool_create(amc)");
|
||||
|
||||
die(mps_ap_create(&ap, pool_g, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool_g, MPS_RANK_EXACT), "BufferCreate 2");
|
||||
die(mps_ap_create(&ap, pool_g, mps_rank_exact()), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool_g, mps_rank_exact()), "BufferCreate 2");
|
||||
|
||||
for(i = 0; i < exactRootsCOUNT; ++i) {
|
||||
exactRoots[i] = objNULL;
|
||||
|
|
@ -162,12 +162,12 @@ static void *test(void *arg, size_t s)
|
|||
}
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&exactRoots[0], exactRootsCOUNT,
|
||||
(mps_word_t)1),
|
||||
"root_create_table(exact)");
|
||||
die(mps_root_create_table(&ambigRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
&ambigRoots[0], ambigRootsCOUNT),
|
||||
"root_create_table(ambig)");
|
||||
|
||||
|
|
|
|||
|
|
@ -152,10 +152,10 @@ static void *test(void *arg, size_t s)
|
|||
die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
|
||||
die(mps_pool_create(&amc, arena, mps_class_amc(), fmt, chain),
|
||||
"pool_create amc\n");
|
||||
die(mps_root_create_table(&mps_root, arena, MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
die(mps_root_create_table(&mps_root, arena, mps_rank_exact(), (mps_rm_t)0,
|
||||
root, (size_t)rootCOUNT),
|
||||
"root_create\n");
|
||||
die(mps_ap_create(&ap, amc, MPS_RANK_EXACT), "ap_create\n");
|
||||
die(mps_ap_create(&ap, amc, mps_rank_exact()), "ap_create\n");
|
||||
|
||||
mps_message_type_enable(arena, mps_message_type_finalization());
|
||||
|
||||
|
|
|
|||
|
|
@ -117,13 +117,13 @@ static void *test(void *arg, size_t s)
|
|||
die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
|
||||
die(mps_pool_create(&amc, arena, mps_class_amc(), fmt, chain),
|
||||
"pool_create amc\n");
|
||||
die(mps_root_create_table(&mps_root[0], arena, MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
die(mps_root_create_table(&mps_root[0], arena, mps_rank_exact(), (mps_rm_t)0,
|
||||
root, (size_t)rootCOUNT),
|
||||
"root_create\n");
|
||||
die(mps_root_create_table(&mps_root[1], arena, MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
die(mps_root_create_table(&mps_root[1], arena, mps_rank_exact(), (mps_rm_t)0,
|
||||
&p, (size_t)1),
|
||||
"root_create\n");
|
||||
die(mps_ap_create(&ap, amc, MPS_RANK_EXACT), "ap_create\n");
|
||||
die(mps_ap_create(&ap, amc, mps_rank_exact()), "ap_create\n");
|
||||
|
||||
/* Make registered-for-finalization objects. */
|
||||
/* <design/poolmrg/#test.promise.ut.alloc> */
|
||||
|
|
|
|||
|
|
@ -142,10 +142,10 @@ static void *test(void *arg, size_t s)
|
|||
die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
|
||||
die(mps_pool_create(&amc, arena, mps_class_amc(), fmt, chain),
|
||||
"pool_create amc\n");
|
||||
die(mps_root_create_table(&mps_root, arena, MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
die(mps_root_create_table(&mps_root, arena, mps_rank_exact(), (mps_rm_t)0,
|
||||
root, (size_t)rootCOUNT),
|
||||
"root_create\n");
|
||||
die(mps_ap_create(&ap, amc, MPS_RANK_EXACT), "ap_create\n");
|
||||
die(mps_ap_create(&ap, amc, mps_rank_exact()), "ap_create\n");
|
||||
|
||||
mps_message_type_enable(arena, mps_message_type_finalization());
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ SRCID(ld, "$Id$");
|
|||
* because if the epoch advances after it is read the dependency
|
||||
* will simply include movement for more time than necessary.
|
||||
*/
|
||||
void LDReset(LD ld, Arena arena)
|
||||
void LDReset(mps_ld_t ld, Arena arena)
|
||||
{
|
||||
Bool b;
|
||||
Seg seg;
|
||||
|
|
@ -68,8 +68,8 @@ void LDReset(LD ld, Arena arena)
|
|||
b = SegOfAddr(&seg, arena, (Addr)ld);
|
||||
if (b)
|
||||
ShieldExpose(arena, seg); /* .ld.access */
|
||||
ld->epoch = arena->epoch;
|
||||
ld->rs = RefSetEMPTY;
|
||||
ld->_epoch = arena->epoch;
|
||||
ld->_rs = RefSetEMPTY;
|
||||
if (b)
|
||||
ShieldCover(arena, seg);
|
||||
}
|
||||
|
|
@ -93,12 +93,12 @@ void LDReset(LD ld, Arena arena)
|
|||
* were used first only the new location of the reference would end up
|
||||
* in the set.
|
||||
*/
|
||||
void LDAdd(LD ld, Arena arena, Addr addr)
|
||||
void LDAdd(mps_ld_t ld, Arena arena, Addr addr)
|
||||
{
|
||||
AVER(ld->epoch <= arena->epoch);
|
||||
AVER(ld->_epoch <= arena->epoch);
|
||||
/* AVERT(Arena, arena) -- see .add.lock-free */
|
||||
|
||||
ld->rs = RefSetAdd(arena, ld->rs, addr);
|
||||
ld->_rs = RefSetAdd(arena, ld->_rs, addr);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -115,36 +115,36 @@ void LDAdd(LD ld, Arena arena, Addr addr)
|
|||
* with everything which has moved since it was initialized.
|
||||
*
|
||||
* .stale.recent.conservative: The refset from the history table is
|
||||
* loaded before we check whether ld->epoch is "recent" with respect to
|
||||
* loaded before we check whether ld->_epoch is "recent" with respect to
|
||||
* the current epoch. This means that we may (conservatively) decide
|
||||
* to use the prehistory instead.
|
||||
*
|
||||
* .stale.old: Otherwise, if the dependency is older than the length
|
||||
* of the history, check it against all movement that has ever occured.
|
||||
*/
|
||||
Bool LDIsStale(LD ld, Arena arena, Addr addr)
|
||||
Bool LDIsStale(mps_ld_t ld, Arena arena, Addr addr)
|
||||
{
|
||||
RefSet rs;
|
||||
|
||||
UNUSED(addr);
|
||||
|
||||
AVER(ld->epoch <= arena->epoch);
|
||||
AVER(ld->_epoch <= arena->epoch);
|
||||
/* AVERT(Arena, arena) -- .stale.thread-safe */
|
||||
|
||||
if (arena->epoch == ld->epoch) /* .stale.current */
|
||||
if (arena->epoch == ld->_epoch) /* .stale.current */
|
||||
return FALSE;
|
||||
|
||||
/* Load the history refset, _then_ check to see if it's recent.
|
||||
* This may in fact load an okay refset, which we decide to throw
|
||||
* away and use the pre-history instead. */
|
||||
rs = arena->history[ld->epoch % LDHistoryLENGTH];
|
||||
rs = arena->history[ld->_epoch % LDHistoryLENGTH];
|
||||
/* .stale.recent */
|
||||
/* .stale.recent.conservative */
|
||||
if (arena->epoch - ld->epoch > LDHistoryLENGTH) {
|
||||
if (arena->epoch - ld->_epoch > LDHistoryLENGTH) {
|
||||
rs = arena->prehistory; /* .stale.old */
|
||||
}
|
||||
|
||||
return RefSetInter(ld->rs, rs) != RefSetEMPTY;
|
||||
return RefSetInter(ld->_rs, rs) != RefSetEMPTY;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -191,22 +191,22 @@ void LDAge(Arena arena, RefSet rs)
|
|||
* (rest of the) MPS. It is unnecessary to claim locks before calling
|
||||
* this function.
|
||||
*/
|
||||
void LDMerge(LD ld, Arena arena, LD from)
|
||||
void LDMerge(mps_ld_t ld, Arena arena, mps_ld_t from)
|
||||
{
|
||||
/* AVERT(Arena, arena); -- .merge.lock-free */
|
||||
AVER(ld != NULL);
|
||||
AVER(ld->epoch <= arena->epoch);
|
||||
AVER(ld->_epoch <= arena->epoch);
|
||||
AVER(from != NULL);
|
||||
AVER(from->epoch <= arena->epoch);
|
||||
AVER(from->_epoch <= arena->epoch);
|
||||
|
||||
/* If a reference has been added since epoch e1 then I've */
|
||||
/* certainly added since epoch e0 where e0 < e1. Therefore */
|
||||
/* the epoch of the merged ld is the minimum. */
|
||||
if (from->epoch < ld->epoch)
|
||||
ld->epoch = from->epoch;
|
||||
if (from->_epoch < ld->_epoch)
|
||||
ld->_epoch = from->_epoch;
|
||||
|
||||
/* The set of references added is the union of the two. */
|
||||
ld->rs = RefSetUnion(ld->rs, from->rs);
|
||||
ld->_rs = RefSetUnion(ld->_rs, from->_rs);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ int main(void)
|
|||
|
||||
die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE),
|
||||
"mps_arena_create");
|
||||
die(mps_root_create_table(&root, arena, MPS_RANK_EXACT,
|
||||
die(mps_root_create_table(&root, arena, mps_rank_exact(),
|
||||
(mps_rm_t)0,
|
||||
roots, (sizeof(roots)/sizeof(*roots))),
|
||||
"RootCreate");
|
||||
|
|
@ -61,7 +61,7 @@ int main(void)
|
|||
|
||||
die(mps_pool_create(&pool, arena, mps_class_lo(), format), "LOCreate");
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "APCreate");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "APCreate");
|
||||
|
||||
die(mps_reserve(&p, ap, sizeof(void *)), "mps_reserve min");
|
||||
*(mps_word_t *)p = sizeof(void *);
|
||||
|
|
|
|||
|
|
@ -366,6 +366,14 @@ extern Bool ScanStateCheck(ScanState ss);
|
|||
extern void ScanStateSetSummary(ScanState ss, RefSet summary);
|
||||
extern RefSet ScanStateSummary(ScanState ss);
|
||||
|
||||
/* See impl.h.mpmst.ss */
|
||||
#define ScanStateZoneShift(ss) ((Shift)(ss)->ss_s._zs)
|
||||
#define ScanStateWhite(ss) ((ZoneSet)(ss)->ss_s._w)
|
||||
#define ScanStateUnfixedSummary(ss) ((RefSet)(ss)->ss_s._ufs)
|
||||
#define ScanStateSetZoneShift(ss, shift) ((void)((ss)->ss_s._zs = (shift)))
|
||||
#define ScanStateSetWhite(ss, zs) ((void)((ss)->ss_s._w = (zs)))
|
||||
#define ScanStateSetUnfixedSummary(ss, rs) ((void)((ss)->ss_s._ufs = (rs)))
|
||||
|
||||
extern Bool TraceIdCheck(TraceId id);
|
||||
extern Bool TraceSetCheck(TraceSet ts);
|
||||
extern Bool TraceCheck(Trace trace);
|
||||
|
|
@ -405,11 +413,11 @@ extern double TraceWorkFactor;
|
|||
#define TRACE_SCAN_BEGIN(ss) \
|
||||
BEGIN \
|
||||
/* Check range on zoneShift before casting to Shift. */ \
|
||||
AVER((ss)->zoneShift < MPS_WORD_WIDTH); \
|
||||
AVER(ScanStateZoneShift(ss) < MPS_WORD_WIDTH); \
|
||||
{ \
|
||||
Shift SCANzoneShift = (Shift)(ss)->zoneShift; \
|
||||
ZoneSet SCANwhite = (ss)->white; \
|
||||
RefSet SCANsummary = (ss)->unfixedSummary; \
|
||||
Shift SCANzoneShift = ScanStateZoneShift(ss); \
|
||||
ZoneSet SCANwhite = ScanStateWhite(ss); \
|
||||
RefSet SCANsummary = ScanStateUnfixedSummary(ss); \
|
||||
Word SCANt; \
|
||||
{
|
||||
|
||||
|
|
@ -422,7 +430,7 @@ extern double TraceWorkFactor;
|
|||
|
||||
/* Equivalent to <code/mps.h> MPS_FIX2 */
|
||||
|
||||
#define TRACE_FIX2(ss, refIO) mps_fix2((mps_ss_t)(ss), (mps_addr_t *)(refIO))
|
||||
#define TRACE_FIX2(ss, refIO) _mps_fix2((mps_ss_t)(ss), (mps_addr_t *)(refIO))
|
||||
|
||||
/* Equivalent to <code/mps.h> MPS_FIX */
|
||||
|
||||
|
|
@ -433,7 +441,7 @@ extern double TraceWorkFactor;
|
|||
|
||||
#define TRACE_SCAN_END(ss) \
|
||||
} \
|
||||
(ss)->unfixedSummary = SCANsummary; \
|
||||
ScanStateSetUnfixedSummary(ss, SCANsummary); \
|
||||
} \
|
||||
END
|
||||
|
||||
|
|
@ -693,9 +701,11 @@ extern Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream);
|
|||
extern Res BufferReserve(Addr *pReturn, Buffer buffer, Size size,
|
||||
Bool withReservoirPermit);
|
||||
/* macro equivalent for BufferReserve, keep in sync with <code/buffer.c> */
|
||||
/* TODO: Perhaps this isn't really necessary now that we build the MPS with
|
||||
more global optimisation and inlining. RB 2012-09-07 */
|
||||
#define BUFFER_RESERVE(pReturn, buffer, size, withReservoirPermit) \
|
||||
(AddrAdd(BufferAlloc(buffer), size) > BufferAlloc(buffer) && \
|
||||
AddrAdd(BufferAlloc(buffer), size) <= BufferAP(buffer)->limit ? \
|
||||
AddrAdd(BufferAlloc(buffer), size) <= (Addr)BufferAP(buffer)->limit ? \
|
||||
(*(pReturn) = BufferAlloc(buffer), \
|
||||
BufferAP(buffer)->alloc = AddrAdd(BufferAlloc(buffer), size), \
|
||||
ResOK) : \
|
||||
|
|
@ -706,6 +716,8 @@ extern Res BufferFill(Addr *pReturn, Buffer buffer, Size size,
|
|||
|
||||
extern Bool BufferCommit(Buffer buffer, Addr p, Size size);
|
||||
/* macro equivalent for BufferCommit, keep in sync with <code/buffer.c> */
|
||||
/* TODO: Perhaps this isn't really necessary now that we build the MPS with
|
||||
more global optimisation and inlining. RB 2012-09-07 */
|
||||
#define BUFFER_COMMIT(buffer, p, size) \
|
||||
(BufferAP(buffer)->init = BufferAlloc(buffer), \
|
||||
BufferAP(buffer)->limit != 0 || BufferTrip(buffer, p, size))
|
||||
|
|
@ -721,10 +733,10 @@ extern void BufferAttach(Buffer buffer,
|
|||
extern void BufferDetach(Buffer buffer, Pool pool);
|
||||
extern void BufferFlip(Buffer buffer);
|
||||
|
||||
extern AP (BufferAP)(Buffer buffer);
|
||||
#define BufferAP(buffer) (&(buffer)->apStruct)
|
||||
extern Buffer BufferOfAP(AP ap);
|
||||
#define BufferOfAP(ap) PARENT(BufferStruct, apStruct, ap)
|
||||
extern mps_ap_t (BufferAP)(Buffer buffer);
|
||||
#define BufferAP(buffer) (&(buffer)->ap_s)
|
||||
extern Buffer BufferOfAP(mps_ap_t ap);
|
||||
#define BufferOfAP(ap) PARENT(BufferStruct, ap_s, ap)
|
||||
|
||||
#define BufferArena(buffer) ((buffer)->arena)
|
||||
#define BufferPool(buffer) ((buffer)->pool)
|
||||
|
|
@ -736,8 +748,8 @@ extern void BufferSetRankSet(Buffer buffer, RankSet rankset);
|
|||
|
||||
#define BufferBase(buffer) ((buffer)->base)
|
||||
#define BufferGetInit(buffer) /* see .trans.bufferinit */ \
|
||||
(BufferAP(buffer)->init)
|
||||
#define BufferAlloc(buffer) (BufferAP(buffer)->alloc)
|
||||
((Addr)(BufferAP(buffer)->init))
|
||||
#define BufferAlloc(buffer) ((Addr)(BufferAP(buffer)->alloc))
|
||||
#define BufferLimit(buffer) ((buffer)->poolLimit)
|
||||
extern Addr BufferScanLimit(Buffer buffer);
|
||||
|
||||
|
|
@ -890,11 +902,11 @@ extern Res MutatorFaultContextScan(ScanState ss, MutatorFaultContext mfc);
|
|||
|
||||
/* Location Dependency -- see <code/ld.c> */
|
||||
|
||||
extern void LDReset(LD ld, Arena arena);
|
||||
extern void LDAdd(LD ld, Arena arena, Addr addr);
|
||||
extern Bool LDIsStale(LD ld, Arena arena, Addr addr);
|
||||
extern void LDReset(mps_ld_t ld, Arena arena);
|
||||
extern void LDAdd(mps_ld_t ld, Arena arena, Addr addr);
|
||||
extern Bool LDIsStale(mps_ld_t ld, Arena arena, Addr addr);
|
||||
extern void LDAge(Arena arena, RefSet moved);
|
||||
extern void LDMerge(LD ld, Arena arena, LD from);
|
||||
extern void LDMerge(mps_ld_t ld, Arena arena, mps_ld_t from);
|
||||
|
||||
|
||||
/* Root Interface -- see <code/root.c> */
|
||||
|
|
|
|||
|
|
@ -343,33 +343,15 @@ typedef struct BufferClassStruct {
|
|||
} BufferClassStruct;
|
||||
|
||||
|
||||
|
||||
|
||||
/* APStruct -- allocation point structure
|
||||
*
|
||||
* AP are part of the design of buffers see <design/buffer/>.
|
||||
*
|
||||
* The allocation point is exported to the client code so that it can
|
||||
* do in-line buffered allocation.
|
||||
*
|
||||
* .ap: This structure must match <code/mps.h#ap>. See also
|
||||
* <code/mpsi.c#check.ap>. */
|
||||
|
||||
typedef struct APStruct {
|
||||
Addr init; /* limit of initialized area */
|
||||
Addr alloc; /* limit of allocated area */
|
||||
Addr limit; /* limit of allocation buffer */
|
||||
Addr frameptr; /* lightweight frame pointer */
|
||||
Bool enabled; /* lightweight frame status */
|
||||
Bool lwPopPending; /* lightweight pop pending? */
|
||||
} APStruct;
|
||||
|
||||
|
||||
/* BufferStruct -- allocation buffer structure
|
||||
*
|
||||
* See <code/buffer.c>, <design/buffer/>.
|
||||
*
|
||||
* The buffer contains an AP which may be exported to the client. */
|
||||
* The buffer contains an AP which may be exported to the client.
|
||||
* AP are part of the design of buffers see <design/buffer/>.
|
||||
* The allocation point is exported to the client code so that it can
|
||||
* do in-line buffered allocation.
|
||||
*/
|
||||
|
||||
#define BufferSig ((Sig)0x519B0FFE) /* SIGnature BUFFEr */
|
||||
|
||||
|
|
@ -386,7 +368,7 @@ typedef struct BufferStruct {
|
|||
double emptySize; /* bytes emptied from this buffer */
|
||||
Addr base; /* base address of allocation buffer */
|
||||
Addr initAtFlip; /* limit of initialized data at flip */
|
||||
APStruct apStruct; /* the allocation point */
|
||||
mps_ap_s ap_s; /* the allocation point */
|
||||
Addr poolLimit; /* the pool's idea of the limit */
|
||||
Align alignment; /* allocation alignment */
|
||||
unsigned rampCount; /* see <code/buffer.c#ramp.hack> */
|
||||
|
|
@ -435,40 +417,32 @@ typedef struct FormatStruct {
|
|||
} FormatStruct;
|
||||
|
||||
|
||||
/* LDStruct -- location dependency structure
|
||||
*
|
||||
* See design.mps.ld, and <code/ld.c>.
|
||||
*
|
||||
* A version of this structure is exported to the client. .ld.struct:
|
||||
* This must be kept in sync with <code/mps.h#ld>. See also
|
||||
* <code/mpsi.c#check.ld>. */
|
||||
|
||||
typedef struct LDStruct {
|
||||
Epoch epoch; /* epoch when ld was last reset / init'ed */
|
||||
RefSet rs; /* RefSet of Add'ed references */
|
||||
} LDStruct;
|
||||
|
||||
|
||||
/* ScanState
|
||||
*
|
||||
* .ss: See <code/trace.c>.
|
||||
*
|
||||
* .ss: The first three fields of the trace structure must match the
|
||||
* external scan state structure (mps_ss_s) thus:
|
||||
* ss->zoneShift mps_ss->w0
|
||||
* ss->white mps_ss->w1
|
||||
* ss->unfixedSummary mps_ss->w2
|
||||
* See <code/mps.h#ss> and <code/mpsi.c#check.ss>. This is why the Sig
|
||||
* field is in the middle of this structure. .ss.zone: The zoneShift
|
||||
* field is therefore declared as Word rather than Shift. */
|
||||
* .ss: The mps_ss field of the scan state structure is exported
|
||||
* through the MPS interface to optimise the critical path scan loop.
|
||||
*
|
||||
* .ss.zone: For binary compatibility, the zone shift is exported as
|
||||
* a word rather than a shift, so that the external mps_ss_s is a uniform
|
||||
* three-word structure. See <code/mps.h#ss> and <design/interface-c>.
|
||||
*
|
||||
* zs Shift zoneShift copy of arena->zoneShift. See .ss.zone
|
||||
* w ZoneSet white white set, for inline fix test
|
||||
* ufs RefSet unfixedSummary accumulated summary of scanned references
|
||||
*
|
||||
* NOTE: The mps_ss structure used to be obfuscated to preserve Harlequin's
|
||||
* trade secrets in the MPS technology. These days they just seek to
|
||||
* emphasize the abstraction, and could maybe be given better names and
|
||||
* types. RB 2012-09-07
|
||||
*/
|
||||
|
||||
#define ScanStateSig ((Sig)0x5195CA45) /* SIGnature SCAN State */
|
||||
|
||||
typedef struct ScanStateStruct {
|
||||
Word zoneShift; /* copy of arena->zoneShift. See .ss.zone */
|
||||
ZoneSet white; /* white set, for inline fix test */
|
||||
RefSet unfixedSummary; /* accumulated summary of scanned references */
|
||||
Sig sig; /* <design/sig/> */
|
||||
struct mps_ss_s ss_s; /* .ss <http://bash.org/?400459> */
|
||||
Arena arena; /* owning arena */
|
||||
PoolFixMethod fix; /* third stage fix function */
|
||||
void *fixClosure; /* closure data for fix */
|
||||
|
|
@ -630,7 +604,7 @@ typedef struct GlobalsStruct {
|
|||
|
||||
#define ArenaSig ((Sig)0x519A6E4A) /* SIGnature ARENA */
|
||||
|
||||
typedef struct ArenaStruct {
|
||||
typedef struct mps_arena_s {
|
||||
GlobalsStruct globals; /* must be first, see <design/arena/#globals> */
|
||||
Serial serial;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,9 +67,7 @@ typedef BufferClass SegBufClass; /* <design/buffer/> */
|
|||
typedef BufferClass RankBufClass; /* <design/buffer/> */
|
||||
typedef unsigned BufferMode; /* <design/buffer/> */
|
||||
typedef unsigned FrameState; /* <design/alloc-frame/> */
|
||||
typedef struct APStruct *AP; /* <design/buffer/> */
|
||||
typedef struct FormatStruct *Format; /* design.mps.format */
|
||||
typedef struct LDStruct *LD; /* design.mps.ld */
|
||||
typedef struct LockStruct *Lock; /* <code/lock.c>* */
|
||||
typedef struct PoolStruct *Pool; /* <design/pool/> */
|
||||
typedef struct PoolClassStruct *PoolClass; /* <code/poolclas.c> */
|
||||
|
|
@ -94,7 +92,7 @@ typedef struct SegPrefStruct *SegPref; /* design.mps.pref, <code/locus.c> */
|
|||
typedef int SegPrefKind; /* design.mps.pref, <code/locus.c> */
|
||||
typedef struct ArenaClassStruct *ArenaClass; /* <design/arena/> */
|
||||
typedef ArenaClass AbstractArenaClass; /* <code/arena.c> */
|
||||
typedef struct ArenaStruct *Arena; /* <design/arena/> */
|
||||
typedef struct mps_arena_s *Arena; /* <design/arena/> */
|
||||
typedef struct GlobalsStruct *Globals; /* <design/arena/> */
|
||||
typedef struct VMStruct *VM; /* <code/vm.c>* */
|
||||
typedef struct RootStruct *Root; /* <code/root.c> */
|
||||
|
|
|
|||
|
|
@ -1,11 +1,25 @@
|
|||
/* mps.h: RAVENBROOK MEMORY POOL SYSTEM C INTERFACE
|
||||
*
|
||||
* $Id$
|
||||
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
|
||||
* Copyright (c) 2001-2012 Ravenbrook Limited. See end of file for license.
|
||||
* Portions copyright (c) 2002 Global Graphics Software.
|
||||
*
|
||||
* .readership: customers, MPS developers.
|
||||
* .sources: <design/interface-c/>.
|
||||
* THIS HEADER IS NOT DOCUMENTATION.
|
||||
* Please refer to the [MPS Manual](../manual/).
|
||||
*
|
||||
* But if you are a human reading this, please note:
|
||||
*
|
||||
* .naming: The MPS interface only uses identifiers beginning `mps_`,
|
||||
* `MPS_` or `_mps_` and may use any identifiers with these prefixes in
|
||||
* future.
|
||||
*
|
||||
* .naming.internal: Any idenfitier beginning with underscore is for
|
||||
* internal use within the interface and may change or be withdrawn without
|
||||
* warning.
|
||||
*
|
||||
* .readership: compilers, MPS developers.
|
||||
*
|
||||
* .sources: [The design of the MPS Interface to C](../design/interface-c).
|
||||
*/
|
||||
|
||||
#ifndef mps_h
|
||||
|
|
@ -85,16 +99,16 @@ enum {
|
|||
* <code/mpmtypes.h#message.types> */
|
||||
/* Not meant to be used by clients, they should use the macros below. */
|
||||
enum {
|
||||
MPS_MESSAGE_TYPE_FINALIZATION,
|
||||
MPS_MESSAGE_TYPE_GC,
|
||||
MPS_MESSAGE_TYPE_GC_START
|
||||
_mps_MESSAGE_TYPE_FINALIZATION,
|
||||
_mps_MESSAGE_TYPE_GC,
|
||||
_mps_MESSAGE_TYPE_GC_START
|
||||
};
|
||||
|
||||
/* Message Types
|
||||
* This is what clients should use. */
|
||||
#define mps_message_type_finalization() MPS_MESSAGE_TYPE_FINALIZATION
|
||||
#define mps_message_type_gc() MPS_MESSAGE_TYPE_GC
|
||||
#define mps_message_type_gc_start() MPS_MESSAGE_TYPE_GC_START
|
||||
#define mps_message_type_finalization() _mps_MESSAGE_TYPE_FINALIZATION
|
||||
#define mps_message_type_gc() _mps_MESSAGE_TYPE_GC
|
||||
#define mps_message_type_gc_start() _mps_MESSAGE_TYPE_GC_START
|
||||
|
||||
|
||||
/* Reference Ranks
|
||||
|
|
@ -105,11 +119,6 @@ extern mps_rank_t mps_rank_ambig(void);
|
|||
extern mps_rank_t mps_rank_exact(void);
|
||||
extern mps_rank_t mps_rank_weak(void);
|
||||
|
||||
/* These upper case symbolic forms are obsolescent. */
|
||||
/* Provided for source compatibility only. */
|
||||
#define MPS_RANK_AMBIG mps_rank_ambig()
|
||||
#define MPS_RANK_EXACT mps_rank_exact()
|
||||
#define MPS_RANK_WEAK mps_rank_weak()
|
||||
|
||||
/* Root Modes */
|
||||
/* .rm: Keep in sync with <code/mpmtypes.h#rm> */
|
||||
|
|
@ -125,9 +134,9 @@ typedef struct mps_ap_s { /* allocation point descriptor */
|
|||
mps_addr_t init; /* limit of initialized memory */
|
||||
mps_addr_t alloc; /* limit of allocated memory */
|
||||
mps_addr_t limit; /* limit of available memory */
|
||||
mps_addr_t frameptr; /* lightweight frame pointer */
|
||||
mps_bool_t enabled; /* lightweight frame status */
|
||||
mps_bool_t lwpoppending; /* lightweight pop pending? */
|
||||
mps_addr_t _frameptr; /* lightweight frame pointer */
|
||||
mps_bool_t _enabled; /* lightweight frame status */
|
||||
mps_bool_t _lwpoppending; /* lightweight pop pending? */
|
||||
} mps_ap_s;
|
||||
|
||||
|
||||
|
|
@ -165,7 +174,7 @@ typedef struct mps_sac_class_s {
|
|||
/* .ld: Keep in sync with <code/mpmst.h#ld.struct>. */
|
||||
|
||||
typedef struct mps_ld_s { /* location dependency descriptor */
|
||||
mps_word_t w0, w1;
|
||||
mps_word_t _epoch, _rs;
|
||||
} mps_ld_s;
|
||||
|
||||
|
||||
|
|
@ -186,10 +195,10 @@ typedef mps_addr_t (*mps_fmt_class_t)(mps_addr_t);
|
|||
|
||||
|
||||
/* Scan State */
|
||||
/* .ss: See also <code/mpsi.c#check.ss> and <code/mpmst.h#ss>. */
|
||||
/* .ss: See also <code/mpmst.h#ss>. */
|
||||
|
||||
typedef struct mps_ss_s {
|
||||
mps_word_t w0, w1, w2;
|
||||
mps_word_t _zs, _w, _ufs;
|
||||
} mps_ss_s;
|
||||
|
||||
|
||||
|
|
@ -629,20 +638,20 @@ extern mps_res_t mps_fix(mps_ss_t, mps_addr_t *);
|
|||
#define MPS_SCAN_BEGIN(ss) \
|
||||
MPS_BEGIN \
|
||||
mps_ss_t _ss = (ss); \
|
||||
mps_word_t _mps_w0 = (_ss)->w0; \
|
||||
mps_word_t _mps_w1 = (_ss)->w1; \
|
||||
mps_word_t _mps_w2 = (_ss)->w2; \
|
||||
mps_word_t _mps_zs = (_ss)->_zs; \
|
||||
mps_word_t _mps_w = (_ss)->_w; \
|
||||
mps_word_t _mps_ufs = (_ss)->_ufs; \
|
||||
mps_word_t _mps_wt; \
|
||||
{
|
||||
|
||||
#define MPS_FIX1(ss, ref) \
|
||||
(_mps_wt = (mps_word_t)1 << ((mps_word_t)(ref) >> _mps_w0 \
|
||||
(_mps_wt = (mps_word_t)1 << ((mps_word_t)(ref) >> _mps_zs \
|
||||
& (sizeof(mps_word_t) * CHAR_BIT - 1)), \
|
||||
_mps_w2 |= _mps_wt, \
|
||||
(_mps_w1 & _mps_wt) != 0)
|
||||
_mps_ufs |= _mps_wt, \
|
||||
(_mps_w & _mps_wt) != 0)
|
||||
|
||||
extern mps_res_t mps_fix2(mps_ss_t, mps_addr_t *);
|
||||
#define MPS_FIX2(ss, ref_io) mps_fix2(ss, ref_io)
|
||||
extern mps_res_t _mps_fix2(mps_ss_t, mps_addr_t *);
|
||||
#define MPS_FIX2(ss, ref_io) _mps_fix2(ss, ref_io)
|
||||
|
||||
#define MPS_FIX12(ss, ref_io) \
|
||||
(MPS_FIX1(ss, *(ref_io)) ? \
|
||||
|
|
@ -653,12 +662,12 @@ extern mps_res_t mps_fix2(mps_ss_t, mps_addr_t *);
|
|||
|
||||
#define MPS_FIX_CALL(ss, call) \
|
||||
MPS_BEGIN \
|
||||
(call); _mps_w2 |= (ss)->w2; \
|
||||
(call); _mps_ufs |= (ss)->_ufs; \
|
||||
MPS_END
|
||||
|
||||
#define MPS_SCAN_END(ss) \
|
||||
} \
|
||||
(ss)->w2 = _mps_w2; \
|
||||
(ss)->_ufs = _mps_ufs; \
|
||||
MPS_END
|
||||
|
||||
|
||||
|
|
|
|||
257
mps/code/mpsi.c
257
mps/code/mpsi.c
|
|
@ -83,25 +83,17 @@ static Bool mpsi_check(void)
|
|||
CHECKL((int)MPS_RES_IO == (int)ResIO);
|
||||
CHECKL((int)MPS_RES_COMMIT_LIMIT == (int)ResCOMMIT_LIMIT);
|
||||
|
||||
/* Check that external and internal rank numbers match. */
|
||||
/* See <code/mps.h#ranks> and <code/mpmtypes.h#ranks>. */
|
||||
/* Also see .check.enum.cast. */
|
||||
CHECKL(COMPATTYPE(mps_rank_t, Rank));
|
||||
CHECKL((int)MPS_RANK_AMBIG == (int)RankAMBIG);
|
||||
CHECKL((int)MPS_RANK_EXACT == (int)RankEXACT);
|
||||
CHECKL((int)MPS_RANK_WEAK == (int)RankWEAK);
|
||||
|
||||
/* Check that external and internal message types match. */
|
||||
/* See <code/mps.h#message.types> and */
|
||||
/* <code/mpmtypes.h#message.types>. */
|
||||
/* Also see .check.enum.cast. */
|
||||
CHECKL(COMPATTYPE(mps_message_type_t, MessageType));
|
||||
CHECKL((int)MessageTypeFINALIZATION
|
||||
== (int)MPS_MESSAGE_TYPE_FINALIZATION);
|
||||
== (int)_mps_MESSAGE_TYPE_FINALIZATION);
|
||||
CHECKL((int)MessageTypeGC
|
||||
== (int)MPS_MESSAGE_TYPE_GC);
|
||||
== (int)_mps_MESSAGE_TYPE_GC);
|
||||
CHECKL((int)MessageTypeGCSTART
|
||||
== (int)MPS_MESSAGE_TYPE_GC_START);
|
||||
== (int)_mps_MESSAGE_TYPE_GC_START);
|
||||
|
||||
/* The external idea of a word width and the internal one */
|
||||
/* had better match. See <design/interface-c/#cons>. */
|
||||
|
|
@ -121,13 +113,6 @@ static Bool mpsi_check(void)
|
|||
/* out to external. */
|
||||
CHECKL(COMPATTYPE(mps_clock_t, Clock));
|
||||
|
||||
/* Check ap_s/APStruct compatibility by hand */
|
||||
/* .check.ap: See <code/mps.h#ap> and <code/buffer.h#ap>. */
|
||||
CHECKL(sizeof(mps_ap_s) == sizeof(APStruct));
|
||||
CHECKL(COMPATFIELD(mps_ap_s, init, APStruct, init));
|
||||
CHECKL(COMPATFIELD(mps_ap_s, alloc, APStruct, alloc));
|
||||
CHECKL(COMPATFIELD(mps_ap_s, limit, APStruct, limit));
|
||||
|
||||
/* Check sac_s/ExternalSACStruct compatibility by hand */
|
||||
/* See <code/mps.h#sac> and <code/sac.h#sac>. */
|
||||
CHECKL(sizeof(mps_sac_s) == sizeof(ExternalSACStruct));
|
||||
|
|
@ -157,20 +142,6 @@ static Bool mpsi_check(void)
|
|||
CHECKL(COMPATFIELD(mps_sac_classes_s, mps_frequency,
|
||||
SACClassesStruct, frequency));
|
||||
|
||||
/* Check ss_s/ScanStateStruct compatibility by hand */
|
||||
/* .check.ss: See <code/mps.h#ss> and <code/mpmst.h#ss>. */
|
||||
/* Note that the size of the mps_ss_s and ScanStateStruct */
|
||||
/* are not equal. See <code/mpmst.h#ss>. */
|
||||
CHECKL(COMPATFIELD(mps_ss_s, w0, ScanStateStruct, zoneShift));
|
||||
CHECKL(COMPATFIELD(mps_ss_s, w1, ScanStateStruct, white));
|
||||
CHECKL(COMPATFIELD(mps_ss_s, w2, ScanStateStruct, unfixedSummary));
|
||||
|
||||
/* Check ld_s/LDStruct compatibility by hand */
|
||||
/* .check.ld: See also <code/mpmst.h#ld.struct> and <code/mps.h#ld> */
|
||||
CHECKL(sizeof(mps_ld_s) == sizeof(LDStruct));
|
||||
CHECKL(COMPATFIELD(mps_ld_s, w0, LDStruct, epoch));
|
||||
CHECKL(COMPATFIELD(mps_ld_s, w1, LDStruct, rs));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -199,10 +170,9 @@ mps_rank_t mps_rank_weak(void)
|
|||
}
|
||||
|
||||
|
||||
mps_res_t mps_arena_extend(mps_arena_t mps_arena,
|
||||
mps_res_t mps_arena_extend(mps_arena_t arena,
|
||||
mps_addr_t base, size_t size)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Res res;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -213,9 +183,8 @@ mps_res_t mps_arena_extend(mps_arena_t mps_arena,
|
|||
return (mps_res_t)res;
|
||||
}
|
||||
|
||||
size_t mps_arena_reserved(mps_arena_t mps_arena)
|
||||
size_t mps_arena_reserved(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Size size;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -231,9 +200,8 @@ size_t mps_space_reserved(mps_space_t mps_space)
|
|||
return mps_arena_reserved(mps_space);
|
||||
}
|
||||
|
||||
size_t mps_arena_committed(mps_arena_t mps_arena)
|
||||
size_t mps_arena_committed(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Size size;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -249,9 +217,8 @@ size_t mps_space_committed(mps_space_t mps_space)
|
|||
return mps_arena_committed(mps_space);
|
||||
}
|
||||
|
||||
size_t mps_arena_spare_committed(mps_arena_t mps_arena)
|
||||
size_t mps_arena_spare_committed(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Size size;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -261,9 +228,8 @@ size_t mps_arena_spare_committed(mps_arena_t mps_arena)
|
|||
return (size_t)size;
|
||||
}
|
||||
|
||||
size_t mps_arena_commit_limit(mps_arena_t mps_arena)
|
||||
size_t mps_arena_commit_limit(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Size size;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -273,10 +239,9 @@ size_t mps_arena_commit_limit(mps_arena_t mps_arena)
|
|||
return size;
|
||||
}
|
||||
|
||||
mps_res_t mps_arena_commit_limit_set(mps_arena_t mps_arena, size_t limit)
|
||||
mps_res_t mps_arena_commit_limit_set(mps_arena_t arena, size_t limit)
|
||||
{
|
||||
Res res;
|
||||
Arena arena = (Arena)mps_arena;
|
||||
|
||||
ArenaEnter(arena);
|
||||
res = ArenaSetCommitLimit(arena, limit);
|
||||
|
|
@ -285,10 +250,8 @@ mps_res_t mps_arena_commit_limit_set(mps_arena_t mps_arena, size_t limit)
|
|||
return res;
|
||||
}
|
||||
|
||||
void mps_arena_spare_commit_limit_set(mps_arena_t mps_arena, size_t limit)
|
||||
void mps_arena_spare_commit_limit_set(mps_arena_t arena, size_t limit)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
|
||||
ArenaEnter(arena);
|
||||
ArenaSetSpareCommitLimit(arena, limit);
|
||||
ArenaLeave(arena);
|
||||
|
|
@ -296,9 +259,8 @@ void mps_arena_spare_commit_limit_set(mps_arena_t mps_arena, size_t limit)
|
|||
return;
|
||||
}
|
||||
|
||||
size_t mps_arena_spare_commit_limit(mps_arena_t mps_arena)
|
||||
size_t mps_arena_spare_commit_limit(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
size_t limit;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -308,9 +270,8 @@ size_t mps_arena_spare_commit_limit(mps_arena_t mps_arena)
|
|||
return limit;
|
||||
}
|
||||
|
||||
void mps_arena_clamp(mps_arena_t mps_arena)
|
||||
void mps_arena_clamp(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
ArenaEnter(arena);
|
||||
ArenaClamp(ArenaGlobals(arena));
|
||||
ArenaLeave(arena);
|
||||
|
|
@ -323,9 +284,8 @@ void mps_space_clamp(mps_space_t mps_space)
|
|||
}
|
||||
|
||||
|
||||
void mps_arena_release(mps_arena_t mps_arena)
|
||||
void mps_arena_release(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
ArenaEnter(arena);
|
||||
ArenaRelease(ArenaGlobals(arena));
|
||||
ArenaLeave(arena);
|
||||
|
|
@ -352,26 +312,23 @@ void mps_space_park(mps_space_t mps_space)
|
|||
mps_arena_park(mps_space);
|
||||
}
|
||||
|
||||
void mps_arena_expose(mps_arena_t mps_arena)
|
||||
void mps_arena_expose(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
ArenaEnter(arena);
|
||||
ArenaExposeRemember(ArenaGlobals(arena), 0);
|
||||
ArenaLeave(arena);
|
||||
}
|
||||
|
||||
/* Null implementations of remember and restore */
|
||||
void mps_arena_unsafe_expose_remember_protection(mps_arena_t mps_arena)
|
||||
void mps_arena_unsafe_expose_remember_protection(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
ArenaEnter(arena);
|
||||
ArenaExposeRemember(ArenaGlobals(arena), 1);
|
||||
ArenaLeave(arena);
|
||||
}
|
||||
|
||||
void mps_arena_unsafe_restore_protection(mps_arena_t mps_arena)
|
||||
void mps_arena_unsafe_restore_protection(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
ArenaEnter(arena);
|
||||
ArenaRestoreProtection(ArenaGlobals(arena));
|
||||
ArenaLeave(arena);
|
||||
|
|
@ -398,12 +355,11 @@ mps_res_t mps_arena_collect(mps_space_t mps_space)
|
|||
return res;
|
||||
}
|
||||
|
||||
mps_bool_t mps_arena_step(mps_arena_t mps_arena,
|
||||
mps_bool_t mps_arena_step(mps_arena_t arena,
|
||||
double interval,
|
||||
double multiplier)
|
||||
{
|
||||
Bool b;
|
||||
Arena arena = (Arena)mps_arena;
|
||||
ArenaEnter(arena);
|
||||
b = ArenaStep(ArenaGlobals(arena), interval, multiplier);
|
||||
ArenaLeave(arena);
|
||||
|
|
@ -457,10 +413,8 @@ mps_res_t mps_arena_create_v(mps_arena_t *mps_arena_o,
|
|||
|
||||
/* mps_arena_destroy -- destroy an arena object */
|
||||
|
||||
void mps_arena_destroy(mps_arena_t mps_arena)
|
||||
void mps_arena_destroy(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
|
||||
ArenaEnter(arena);
|
||||
ArenaDestroy(arena);
|
||||
}
|
||||
|
|
@ -468,10 +422,9 @@ void mps_arena_destroy(mps_arena_t mps_arena)
|
|||
|
||||
/* mps_arena_has_addr -- is this address managed by this arena? */
|
||||
|
||||
mps_bool_t mps_arena_has_addr(mps_arena_t mps_arena, mps_addr_t p)
|
||||
mps_bool_t mps_arena_has_addr(mps_arena_t arena, mps_addr_t p)
|
||||
{
|
||||
Bool b;
|
||||
Arena arena = (Arena)mps_arena;
|
||||
|
||||
/* One of the few functions that can be called
|
||||
during the call to an MPS function. IE this function
|
||||
|
|
@ -490,12 +443,11 @@ mps_bool_t mps_arena_has_addr(mps_arena_t mps_arena, mps_addr_t p)
|
|||
*/
|
||||
|
||||
mps_bool_t mps_addr_pool(mps_pool_t *mps_pool_o,
|
||||
mps_arena_t mps_arena,
|
||||
mps_arena_t arena,
|
||||
mps_addr_t p)
|
||||
{
|
||||
Bool b;
|
||||
Pool pool;
|
||||
Arena arena = (Arena)mps_arena;
|
||||
|
||||
AVER(mps_pool_o != NULL);
|
||||
/* mps_arena -- will be checked by ArenaEnterRecursive */
|
||||
|
|
@ -528,13 +480,12 @@ mps_bool_t mps_addr_pool(mps_pool_t *mps_pool_o,
|
|||
* Note: may return an MPS-internal format.
|
||||
*/
|
||||
mps_bool_t mps_addr_fmt(mps_fmt_t *mps_fmt_o,
|
||||
mps_arena_t mps_arena,
|
||||
mps_arena_t arena,
|
||||
mps_addr_t p)
|
||||
{
|
||||
Bool b;
|
||||
Pool pool;
|
||||
Format format = 0;
|
||||
Arena arena = (Arena)mps_arena;
|
||||
|
||||
AVER(mps_fmt_o != NULL);
|
||||
/* mps_arena -- will be checked by ArenaEnterRecursive */
|
||||
|
|
@ -565,10 +516,9 @@ mps_bool_t mps_addr_fmt(mps_fmt_t *mps_fmt_o,
|
|||
* the format structure is declared as "mps_fmt_A". */
|
||||
|
||||
mps_res_t mps_fmt_create_A(mps_fmt_t *mps_fmt_o,
|
||||
mps_arena_t mps_arena,
|
||||
mps_arena_t arena,
|
||||
mps_fmt_A_s *mps_fmt_A)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Format format;
|
||||
Res res;
|
||||
|
||||
|
|
@ -600,10 +550,9 @@ mps_res_t mps_fmt_create_A(mps_fmt_t *mps_fmt_o,
|
|||
/* mps_fmt_create_B -- create an object format of variant B */
|
||||
|
||||
mps_res_t mps_fmt_create_B(mps_fmt_t *mps_fmt_o,
|
||||
mps_arena_t mps_arena,
|
||||
mps_arena_t arena,
|
||||
mps_fmt_B_s *mps_fmt_B)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Format format;
|
||||
Res res;
|
||||
|
||||
|
|
@ -635,10 +584,9 @@ mps_res_t mps_fmt_create_B(mps_fmt_t *mps_fmt_o,
|
|||
/* mps_fmt_create_auto_header -- create a format of variant auto_header */
|
||||
|
||||
mps_res_t mps_fmt_create_auto_header(mps_fmt_t *mps_fmt_o,
|
||||
mps_arena_t mps_arena,
|
||||
mps_arena_t arena,
|
||||
mps_fmt_auto_header_s *mps_fmt)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Format format;
|
||||
Res res;
|
||||
|
||||
|
|
@ -670,10 +618,9 @@ mps_res_t mps_fmt_create_auto_header(mps_fmt_t *mps_fmt_o,
|
|||
/* mps_fmt_create_fixed -- create an object format of variant fixed */
|
||||
|
||||
mps_res_t mps_fmt_create_fixed(mps_fmt_t *mps_fmt_o,
|
||||
mps_arena_t mps_arena,
|
||||
mps_arena_t arena,
|
||||
mps_fmt_fixed_s *mps_fmt_fixed)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Format format;
|
||||
Res res;
|
||||
|
||||
|
|
@ -720,21 +667,20 @@ void mps_fmt_destroy(mps_fmt_t mps_fmt)
|
|||
}
|
||||
|
||||
|
||||
mps_res_t mps_pool_create(mps_pool_t *mps_pool_o, mps_arena_t mps_arena,
|
||||
mps_res_t mps_pool_create(mps_pool_t *mps_pool_o, mps_arena_t arena,
|
||||
mps_class_t mps_class, ...)
|
||||
{
|
||||
mps_res_t res;
|
||||
va_list args;
|
||||
va_start(args, mps_class);
|
||||
res = mps_pool_create_v(mps_pool_o, mps_arena, mps_class, args);
|
||||
res = mps_pool_create_v(mps_pool_o, arena, mps_class, args);
|
||||
va_end(args);
|
||||
return res;
|
||||
}
|
||||
|
||||
mps_res_t mps_pool_create_v(mps_pool_t *mps_pool_o, mps_arena_t mps_arena,
|
||||
mps_res_t mps_pool_create_v(mps_pool_t *mps_pool_o, mps_arena_t arena,
|
||||
mps_class_t mps_class, va_list args)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Pool pool;
|
||||
PoolClass class = (PoolClass)mps_class;
|
||||
Res res;
|
||||
|
|
@ -863,7 +809,7 @@ mps_res_t mps_ap_create(mps_ap_t *mps_ap_o, mps_pool_t mps_pool, ...)
|
|||
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
*mps_ap_o = (mps_ap_t)BufferAP(buf);
|
||||
*mps_ap_o = BufferAP(buf);
|
||||
return MPS_RES_OK;
|
||||
}
|
||||
|
||||
|
|
@ -894,13 +840,13 @@ mps_res_t mps_ap_create_v(mps_ap_t *mps_ap_o, mps_pool_t mps_pool,
|
|||
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
*mps_ap_o = (mps_ap_t)BufferAP(buf);
|
||||
*mps_ap_o = BufferAP(buf);
|
||||
return MPS_RES_OK;
|
||||
}
|
||||
|
||||
void mps_ap_destroy(mps_ap_t mps_ap)
|
||||
{
|
||||
Buffer buf = BufferOfAP((AP)mps_ap);
|
||||
Buffer buf = BufferOfAP(mps_ap);
|
||||
Arena arena;
|
||||
|
||||
AVER(mps_ap != NULL);
|
||||
|
|
@ -928,7 +874,7 @@ mps_res_t (mps_reserve)(mps_addr_t *p_o, mps_ap_t mps_ap, size_t size)
|
|||
|
||||
AVER(p_o != NULL);
|
||||
AVER(mps_ap != NULL);
|
||||
AVER(TESTT(Buffer, BufferOfAP((AP)mps_ap)));
|
||||
AVER(TESTT(Buffer, BufferOfAP(mps_ap)));
|
||||
AVER(mps_ap->init == mps_ap->alloc);
|
||||
AVER(size > 0);
|
||||
|
||||
|
|
@ -947,7 +893,7 @@ mps_res_t mps_reserve_with_reservoir_permit(mps_addr_t *p_o,
|
|||
AVER(p_o != NULL);
|
||||
AVER(size > 0);
|
||||
AVER(mps_ap != NULL);
|
||||
AVER(TESTT(Buffer, BufferOfAP((AP)mps_ap)));
|
||||
AVER(TESTT(Buffer, BufferOfAP(mps_ap)));
|
||||
AVER(mps_ap->init == mps_ap->alloc);
|
||||
|
||||
MPS_RESERVE_WITH_RESERVOIR_PERMIT_BLOCK(res, *p_o, mps_ap, size);
|
||||
|
|
@ -968,7 +914,7 @@ mps_res_t mps_reserve_with_reservoir_permit(mps_addr_t *p_o,
|
|||
mps_bool_t (mps_commit)(mps_ap_t mps_ap, mps_addr_t p, size_t size)
|
||||
{
|
||||
AVER(mps_ap != NULL);
|
||||
AVER(TESTT(Buffer, BufferOfAP((AP)mps_ap)));
|
||||
AVER(TESTT(Buffer, BufferOfAP(mps_ap)));
|
||||
AVER(p != NULL);
|
||||
AVER(size > 0);
|
||||
AVER(p == mps_ap->init);
|
||||
|
|
@ -999,13 +945,13 @@ mps_res_t (mps_ap_frame_push)(mps_frame_t *frame_o, mps_ap_t mps_ap)
|
|||
return MPS_RES_FAIL;
|
||||
}
|
||||
|
||||
if (!mps_ap->lwpoppending) {
|
||||
if (!mps_ap->_lwpoppending) {
|
||||
/* Valid state for a lightweight push */
|
||||
*frame_o = (mps_frame_t)mps_ap->init;
|
||||
return MPS_RES_OK;
|
||||
} else {
|
||||
/* Need a heavyweight push */
|
||||
Buffer buf = BufferOfAP((AP)mps_ap);
|
||||
Buffer buf = BufferOfAP(mps_ap);
|
||||
Arena arena;
|
||||
AllocFrame frame;
|
||||
Res res;
|
||||
|
|
@ -1040,16 +986,16 @@ mps_res_t (mps_ap_frame_pop)(mps_ap_t mps_ap, mps_frame_t frame)
|
|||
return MPS_RES_FAIL;
|
||||
}
|
||||
|
||||
if (mps_ap->enabled) {
|
||||
if (mps_ap->_enabled) {
|
||||
/* Valid state for a lightweight pop */
|
||||
mps_ap->frameptr = (mps_addr_t)frame; /* record pending pop */
|
||||
mps_ap->lwpoppending = TRUE;
|
||||
mps_ap->_frameptr = (mps_addr_t)frame; /* record pending pop */
|
||||
mps_ap->_lwpoppending = TRUE;
|
||||
mps_ap->limit = (mps_addr_t)0; /* trap the buffer */
|
||||
return MPS_RES_OK;
|
||||
|
||||
} else {
|
||||
/* Need a heavyweight pop */
|
||||
Buffer buf = BufferOfAP((AP)mps_ap);
|
||||
Buffer buf = BufferOfAP(mps_ap);
|
||||
Arena arena;
|
||||
Res res;
|
||||
|
||||
|
|
@ -1074,7 +1020,7 @@ mps_res_t (mps_ap_frame_pop)(mps_ap_t mps_ap, mps_frame_t frame)
|
|||
|
||||
mps_res_t mps_ap_fill(mps_addr_t *p_o, mps_ap_t mps_ap, size_t size)
|
||||
{
|
||||
Buffer buf = BufferOfAP((AP)mps_ap);
|
||||
Buffer buf = BufferOfAP(mps_ap);
|
||||
Arena arena;
|
||||
Addr p;
|
||||
Res res;
|
||||
|
|
@ -1105,7 +1051,7 @@ mps_res_t mps_ap_fill(mps_addr_t *p_o, mps_ap_t mps_ap, size_t size)
|
|||
mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *p_o, mps_ap_t mps_ap,
|
||||
size_t size)
|
||||
{
|
||||
Buffer buf = BufferOfAP((AP)mps_ap);
|
||||
Buffer buf = BufferOfAP(mps_ap);
|
||||
Arena arena;
|
||||
Addr p;
|
||||
Res res;
|
||||
|
|
@ -1140,7 +1086,7 @@ mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *p_o, mps_ap_t mps_ap,
|
|||
|
||||
mps_bool_t mps_ap_trip(mps_ap_t mps_ap, mps_addr_t p, size_t size)
|
||||
{
|
||||
Buffer buf = BufferOfAP((AP)mps_ap);
|
||||
Buffer buf = BufferOfAP(mps_ap);
|
||||
Arena arena;
|
||||
Bool b;
|
||||
|
||||
|
|
@ -1301,11 +1247,10 @@ void mps_sac_free(mps_sac_t mps_sac, mps_addr_t p, size_t size)
|
|||
/* Roots */
|
||||
|
||||
|
||||
mps_res_t mps_root_create(mps_root_t *mps_root_o, mps_arena_t mps_arena,
|
||||
mps_res_t mps_root_create(mps_root_t *mps_root_o, mps_arena_t arena,
|
||||
mps_rank_t mps_rank, mps_rm_t mps_rm,
|
||||
mps_root_scan_t mps_root_scan, void *p, size_t s)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Rank rank = (Rank)mps_rank;
|
||||
Root root;
|
||||
Res res;
|
||||
|
|
@ -1326,11 +1271,10 @@ mps_res_t mps_root_create(mps_root_t *mps_root_o, mps_arena_t mps_arena,
|
|||
return MPS_RES_OK;
|
||||
}
|
||||
|
||||
mps_res_t mps_root_create_table(mps_root_t *mps_root_o, mps_arena_t mps_arena,
|
||||
mps_res_t mps_root_create_table(mps_root_t *mps_root_o, mps_arena_t arena,
|
||||
mps_rank_t mps_rank, mps_rm_t mps_rm,
|
||||
mps_addr_t *base, size_t size)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Rank rank = (Rank)mps_rank;
|
||||
Root root;
|
||||
RootMode mode = (RootMode)mps_rm;
|
||||
|
|
@ -1357,12 +1301,11 @@ mps_res_t mps_root_create_table(mps_root_t *mps_root_o, mps_arena_t mps_arena,
|
|||
}
|
||||
|
||||
mps_res_t mps_root_create_table_masked(mps_root_t *mps_root_o,
|
||||
mps_arena_t mps_arena,
|
||||
mps_arena_t arena,
|
||||
mps_rank_t mps_rank, mps_rm_t mps_rm,
|
||||
mps_addr_t *base, size_t size,
|
||||
mps_word_t mask)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Rank rank = (Rank)mps_rank;
|
||||
Root root;
|
||||
RootMode mode = (RootMode)mps_rm;
|
||||
|
|
@ -1388,12 +1331,11 @@ mps_res_t mps_root_create_table_masked(mps_root_t *mps_root_o,
|
|||
return MPS_RES_OK;
|
||||
}
|
||||
|
||||
mps_res_t mps_root_create_fmt(mps_root_t *mps_root_o, mps_arena_t mps_arena,
|
||||
mps_res_t mps_root_create_fmt(mps_root_t *mps_root_o, mps_arena_t arena,
|
||||
mps_rank_t mps_rank, mps_rm_t mps_rm,
|
||||
mps_fmt_scan_t mps_fmt_scan,
|
||||
mps_addr_t base, mps_addr_t limit)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Rank rank = (Rank)mps_rank;
|
||||
FormatScanMethod scan = (FormatScanMethod)mps_fmt_scan;
|
||||
Root root;
|
||||
|
|
@ -1412,12 +1354,11 @@ mps_res_t mps_root_create_fmt(mps_root_t *mps_root_o, mps_arena_t mps_arena,
|
|||
return MPS_RES_OK;
|
||||
}
|
||||
|
||||
mps_res_t mps_root_create_reg(mps_root_t *mps_root_o, mps_arena_t mps_arena,
|
||||
mps_res_t mps_root_create_reg(mps_root_t *mps_root_o, mps_arena_t arena,
|
||||
mps_rank_t mps_rank, mps_rm_t mps_rm,
|
||||
mps_thr_t mps_thr, mps_reg_scan_t mps_reg_scan,
|
||||
void *reg_scan_p, size_t mps_size)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Rank rank = (Rank)mps_rank;
|
||||
Thread thread = (Thread)mps_thr;
|
||||
Root root;
|
||||
|
|
@ -1429,7 +1370,7 @@ mps_res_t mps_root_create_reg(mps_root_t *mps_root_o, mps_arena_t mps_arena,
|
|||
AVER(mps_reg_scan != NULL);
|
||||
AVER(mps_reg_scan == mps_stack_scan_ambig); /* .reg.scan */
|
||||
AVER(reg_scan_p != NULL); /* stackBot */
|
||||
AVER(rank == MPS_RANK_AMBIG);
|
||||
AVER(rank == mps_rank_ambig());
|
||||
AVER(mps_rm == (mps_rm_t)0);
|
||||
|
||||
/* See .root-mode. */
|
||||
|
|
@ -1452,9 +1393,8 @@ mps_res_t mps_root_create_reg(mps_root_t *mps_root_o, mps_arena_t mps_arena,
|
|||
mps_res_t mps_stack_scan_ambig(mps_ss_t mps_ss,
|
||||
mps_thr_t mps_thr, void *p, size_t s)
|
||||
{
|
||||
ScanState ss = (ScanState)mps_ss;
|
||||
ScanState ss = PARENT(ScanStateStruct, ss_s, mps_ss);
|
||||
Thread thread = (Thread)mps_thr;
|
||||
|
||||
UNUSED(s);
|
||||
return ThreadScan(ss, thread, p);
|
||||
}
|
||||
|
|
@ -1487,9 +1427,8 @@ void (mps_tramp)(void **r_o,
|
|||
}
|
||||
|
||||
|
||||
mps_res_t mps_thread_reg(mps_thr_t *mps_thr_o, mps_arena_t mps_arena)
|
||||
mps_res_t mps_thread_reg(mps_thr_t *mps_thr_o, mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Thread thread;
|
||||
Res res;
|
||||
|
||||
|
|
@ -1522,15 +1461,10 @@ void mps_thread_dereg(mps_thr_t mps_thr)
|
|||
ArenaLeave(arena);
|
||||
}
|
||||
|
||||
void mps_ld_reset(mps_ld_t mps_ld, mps_arena_t mps_arena)
|
||||
void mps_ld_reset(mps_ld_t ld, mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
LD ld = (LD)mps_ld;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
||||
LDReset(ld, arena);
|
||||
|
||||
ArenaLeave(arena);
|
||||
}
|
||||
|
||||
|
|
@ -1539,11 +1473,8 @@ void mps_ld_reset(mps_ld_t mps_ld, mps_arena_t mps_arena)
|
|||
*
|
||||
* See <design/interface-c/#lock-free>. */
|
||||
|
||||
void mps_ld_add(mps_ld_t mps_ld, mps_arena_t mps_arena, mps_addr_t addr)
|
||||
void mps_ld_add(mps_ld_t ld, mps_arena_t arena, mps_addr_t addr)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
LD ld = (LD)mps_ld;
|
||||
|
||||
LDAdd(ld, arena, (Addr)addr);
|
||||
}
|
||||
|
||||
|
|
@ -1552,13 +1483,9 @@ void mps_ld_add(mps_ld_t mps_ld, mps_arena_t mps_arena, mps_addr_t addr)
|
|||
*
|
||||
* See <design/interface-c/#lock-free>. */
|
||||
|
||||
void mps_ld_merge(mps_ld_t mps_ld, mps_arena_t mps_arena,
|
||||
mps_ld_t mps_from)
|
||||
void mps_ld_merge(mps_ld_t ld, mps_arena_t arena,
|
||||
mps_ld_t from)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
LD ld = (LD)mps_ld;
|
||||
LD from = (LD)mps_from;
|
||||
|
||||
LDMerge(ld, arena, from);
|
||||
}
|
||||
|
||||
|
|
@ -1567,11 +1494,9 @@ void mps_ld_merge(mps_ld_t mps_ld, mps_arena_t mps_arena,
|
|||
*
|
||||
* See <design/interface-c/#lock-free>. */
|
||||
|
||||
mps_bool_t mps_ld_isstale(mps_ld_t mps_ld, mps_arena_t mps_arena,
|
||||
mps_bool_t mps_ld_isstale(mps_ld_t ld, mps_arena_t arena,
|
||||
mps_addr_t addr)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
LD ld = (LD)mps_ld;
|
||||
Bool b;
|
||||
|
||||
b = LDIsStale(ld, arena, (Addr)addr);
|
||||
|
|
@ -1590,20 +1515,18 @@ mps_res_t mps_fix(mps_ss_t mps_ss, mps_addr_t *ref_io)
|
|||
return res;
|
||||
}
|
||||
|
||||
mps_word_t mps_collections(mps_arena_t mps_arena)
|
||||
mps_word_t mps_collections(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
return ArenaEpoch(arena); /* thread safe: see <code/arena.h#epoch.ts> */
|
||||
}
|
||||
|
||||
|
||||
/* mps_finalize -- register for finalization */
|
||||
|
||||
mps_res_t mps_finalize(mps_arena_t mps_arena, mps_addr_t *refref)
|
||||
mps_res_t mps_finalize(mps_arena_t arena, mps_addr_t *refref)
|
||||
{
|
||||
Res res;
|
||||
Addr object;
|
||||
Arena arena = (Arena)mps_arena;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
||||
|
|
@ -1617,11 +1540,10 @@ mps_res_t mps_finalize(mps_arena_t mps_arena, mps_addr_t *refref)
|
|||
|
||||
/* mps_definalize -- deregister for finalization */
|
||||
|
||||
mps_res_t mps_definalize(mps_arena_t mps_arena, mps_addr_t *refref)
|
||||
mps_res_t mps_definalize(mps_arena_t arena, mps_addr_t *refref)
|
||||
{
|
||||
Res res;
|
||||
Addr object;
|
||||
Arena arena = (Arena)mps_arena;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
||||
|
|
@ -1636,10 +1558,9 @@ mps_res_t mps_definalize(mps_arena_t mps_arena, mps_addr_t *refref)
|
|||
/* Messages */
|
||||
|
||||
|
||||
void mps_message_type_enable(mps_arena_t mps_arena,
|
||||
void mps_message_type_enable(mps_arena_t arena,
|
||||
mps_message_type_t mps_type)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
MessageType type = (MessageType)mps_type;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -1649,10 +1570,9 @@ void mps_message_type_enable(mps_arena_t mps_arena,
|
|||
ArenaLeave(arena);
|
||||
}
|
||||
|
||||
void mps_message_type_disable(mps_arena_t mps_arena,
|
||||
void mps_message_type_disable(mps_arena_t arena,
|
||||
mps_message_type_t mps_type)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
MessageType type = (MessageType)mps_type;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -1662,10 +1582,9 @@ void mps_message_type_disable(mps_arena_t mps_arena,
|
|||
ArenaLeave(arena);
|
||||
}
|
||||
|
||||
mps_bool_t mps_message_poll(mps_arena_t mps_arena)
|
||||
mps_bool_t mps_message_poll(mps_arena_t arena)
|
||||
{
|
||||
Bool b;
|
||||
Arena arena = (Arena)mps_arena;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
||||
|
|
@ -1676,9 +1595,8 @@ mps_bool_t mps_message_poll(mps_arena_t mps_arena)
|
|||
}
|
||||
|
||||
mps_bool_t mps_message_queue_type(mps_message_type_t *mps_message_type_return,
|
||||
mps_arena_t mps_arena)
|
||||
mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
MessageType type;
|
||||
Bool b;
|
||||
|
||||
|
|
@ -1694,11 +1612,10 @@ mps_bool_t mps_message_queue_type(mps_message_type_t *mps_message_type_return,
|
|||
}
|
||||
|
||||
mps_bool_t mps_message_get(mps_message_t *mps_message_return,
|
||||
mps_arena_t mps_arena,
|
||||
mps_arena_t arena,
|
||||
mps_message_type_t mps_type)
|
||||
{
|
||||
Bool b;
|
||||
Arena arena = (Arena)mps_arena;
|
||||
MessageType type = (MessageType)mps_type;
|
||||
Message message;
|
||||
|
||||
|
|
@ -1713,10 +1630,9 @@ mps_bool_t mps_message_get(mps_message_t *mps_message_return,
|
|||
return b;
|
||||
}
|
||||
|
||||
void mps_message_discard(mps_arena_t mps_arena,
|
||||
void mps_message_discard(mps_arena_t arena,
|
||||
mps_message_t mps_message)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Message message = (Message)mps_message;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -1731,10 +1647,9 @@ void mps_message_discard(mps_arena_t mps_arena,
|
|||
|
||||
/* -- All Message Types */
|
||||
|
||||
mps_message_type_t mps_message_type(mps_arena_t mps_arena,
|
||||
mps_message_type_t mps_message_type(mps_arena_t arena,
|
||||
mps_message_t mps_message)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Message message = (Message)mps_message;
|
||||
MessageType type;
|
||||
|
||||
|
|
@ -1747,10 +1662,9 @@ mps_message_type_t mps_message_type(mps_arena_t mps_arena,
|
|||
return (mps_message_type_t)type;
|
||||
}
|
||||
|
||||
mps_clock_t mps_message_clock(mps_arena_t mps_arena,
|
||||
mps_clock_t mps_message_clock(mps_arena_t arena,
|
||||
mps_message_t mps_message)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Message message = (Message)mps_message;
|
||||
Clock postedClock;
|
||||
|
||||
|
|
@ -1767,10 +1681,9 @@ mps_clock_t mps_message_clock(mps_arena_t mps_arena,
|
|||
/* -- mps_message_type_finalization */
|
||||
|
||||
void mps_message_finalization_ref(mps_addr_t *mps_addr_return,
|
||||
mps_arena_t mps_arena,
|
||||
mps_arena_t arena,
|
||||
mps_message_t mps_message)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Message message = (Message)mps_message;
|
||||
Ref ref;
|
||||
|
||||
|
|
@ -1787,10 +1700,9 @@ void mps_message_finalization_ref(mps_addr_t *mps_addr_return,
|
|||
|
||||
/* -- mps_message_type_gc */
|
||||
|
||||
size_t mps_message_gc_live_size(mps_arena_t mps_arena,
|
||||
size_t mps_message_gc_live_size(mps_arena_t arena,
|
||||
mps_message_t mps_message)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Message message = (Message)mps_message;
|
||||
Size size;
|
||||
|
||||
|
|
@ -1803,10 +1715,9 @@ size_t mps_message_gc_live_size(mps_arena_t mps_arena,
|
|||
return (size_t)size;
|
||||
}
|
||||
|
||||
size_t mps_message_gc_condemned_size(mps_arena_t mps_arena,
|
||||
size_t mps_message_gc_condemned_size(mps_arena_t arena,
|
||||
mps_message_t mps_message)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Message message = (Message)mps_message;
|
||||
Size size;
|
||||
|
||||
|
|
@ -1819,10 +1730,9 @@ size_t mps_message_gc_condemned_size(mps_arena_t mps_arena,
|
|||
return (size_t)size;
|
||||
}
|
||||
|
||||
size_t mps_message_gc_not_condemned_size(mps_arena_t mps_arena,
|
||||
size_t mps_message_gc_not_condemned_size(mps_arena_t arena,
|
||||
mps_message_t mps_message)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Message message = (Message)mps_message;
|
||||
Size size;
|
||||
|
||||
|
|
@ -1837,11 +1747,10 @@ size_t mps_message_gc_not_condemned_size(mps_arena_t mps_arena,
|
|||
|
||||
/* -- mps_message_type_gc_start */
|
||||
|
||||
const char *mps_message_gc_start_why(mps_arena_t mps_arena,
|
||||
const char *mps_message_gc_start_why(mps_arena_t arena,
|
||||
mps_message_t mps_message)
|
||||
{
|
||||
const char *s;
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Message message = (Message)mps_message;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -1858,10 +1767,9 @@ const char *mps_message_gc_start_why(mps_arena_t mps_arena,
|
|||
|
||||
/* Alert */
|
||||
|
||||
mps_res_t mps_alert_collection_set(mps_arena_t mps_arena,
|
||||
mps_res_t mps_alert_collection_set(mps_arena_t arena,
|
||||
mps_alert_collection_fn_t fn)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
ArenaEnter(arena);
|
||||
arena->alertCollection = fn;
|
||||
ArenaLeave(arena);
|
||||
|
|
@ -1922,7 +1830,7 @@ mps_res_t mps_ap_alloc_pattern_begin(mps_ap_t mps_ap,
|
|||
Arena arena;
|
||||
|
||||
AVER(mps_ap != NULL);
|
||||
buf = BufferOfAP((AP)mps_ap);
|
||||
buf = BufferOfAP(mps_ap);
|
||||
AVER(TESTT(Buffer, buf));
|
||||
|
||||
arena = BufferArena(buf);
|
||||
|
|
@ -1943,7 +1851,7 @@ mps_res_t mps_ap_alloc_pattern_end(mps_ap_t mps_ap,
|
|||
Res res;
|
||||
|
||||
AVER(mps_ap != NULL);
|
||||
buf = BufferOfAP((AP)mps_ap);
|
||||
buf = BufferOfAP(mps_ap);
|
||||
AVER(TESTT(Buffer, buf));
|
||||
UNUSED(alloc_pattern); /* .ramp.hack */
|
||||
|
||||
|
|
@ -1964,7 +1872,7 @@ mps_res_t mps_ap_alloc_pattern_reset(mps_ap_t mps_ap)
|
|||
Arena arena;
|
||||
|
||||
AVER(mps_ap != NULL);
|
||||
buf = BufferOfAP((AP)mps_ap);
|
||||
buf = BufferOfAP(mps_ap);
|
||||
AVER(TESTT(Buffer, buf));
|
||||
|
||||
arena = BufferArena(buf);
|
||||
|
|
@ -1983,10 +1891,8 @@ mps_res_t mps_ap_alloc_pattern_reset(mps_ap_t mps_ap)
|
|||
|
||||
/* mps_reservoir_limit_set -- set the reservoir size */
|
||||
|
||||
void mps_reservoir_limit_set(mps_arena_t mps_arena, size_t size)
|
||||
void mps_reservoir_limit_set(mps_arena_t arena, size_t size)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
|
||||
ArenaEnter(arena);
|
||||
ReservoirSetLimit(ArenaReservoir(arena), size);
|
||||
ArenaLeave(arena);
|
||||
|
|
@ -1995,9 +1901,8 @@ void mps_reservoir_limit_set(mps_arena_t mps_arena, size_t size)
|
|||
|
||||
/* mps_reservoir_limit -- return the reservoir size */
|
||||
|
||||
size_t mps_reservoir_limit(mps_arena_t mps_arena)
|
||||
size_t mps_reservoir_limit(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Size size;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -2011,9 +1916,8 @@ size_t mps_reservoir_limit(mps_arena_t mps_arena)
|
|||
|
||||
/* mps_reservoir_available -- return memory available in the reservoir */
|
||||
|
||||
size_t mps_reservoir_available(mps_arena_t mps_arena)
|
||||
size_t mps_reservoir_available(mps_arena_t arena)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Size size;
|
||||
|
||||
ArenaEnter(arena);
|
||||
|
|
@ -2030,10 +1934,9 @@ size_t mps_reservoir_available(mps_arena_t mps_arena)
|
|||
|
||||
/* mps_chain_create -- create a chain */
|
||||
|
||||
mps_res_t mps_chain_create(mps_chain_t *chain_o, mps_arena_t mps_arena,
|
||||
mps_res_t mps_chain_create(mps_chain_t *chain_o, mps_arena_t arena,
|
||||
size_t gen_count, mps_gen_param_s *params)
|
||||
{
|
||||
Arena arena = (Arena)mps_arena;
|
||||
Chain chain;
|
||||
Res res;
|
||||
|
||||
|
|
|
|||
|
|
@ -431,19 +431,19 @@ static void *test(void *arg, size_t s)
|
|||
}
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&exactRoots[0], exactRootsCOUNT,
|
||||
MPS_WORD_CONST(1)),
|
||||
"root_create_table(exact)");
|
||||
die(mps_root_create_table(&ambigRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
&ambigRoots[0], ambigRootsCOUNT),
|
||||
"root_create_table(ambig)");
|
||||
|
||||
obj = objNULL;
|
||||
|
||||
die(mps_root_create(&singleRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&root_single, &obj, 0),
|
||||
"root_create(single)");
|
||||
|
||||
|
|
@ -457,7 +457,7 @@ static void *test(void *arg, size_t s)
|
|||
addr_pool_test(arena, alloced_obj, mv, make(), amcpool, format);
|
||||
|
||||
die(mps_root_create_fmt(&fmtRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
dylan_fmt_A()->scan,
|
||||
alloced_obj,
|
||||
(mps_addr_t)(((char*)alloced_obj)+asize)),
|
||||
|
|
@ -587,7 +587,7 @@ int main(int argc, char **argv)
|
|||
die(mps_thread_reg(&thread, arena), "thread_reg");
|
||||
|
||||
die(mps_root_create_reg(®_root, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
thread, &mps_stack_scan_ambig,
|
||||
marker, (size_t)0),
|
||||
"root_create_reg");
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
|
|||
va_end(arg);
|
||||
if(res != MPS_RES_OK) return res;
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
|
||||
|
||||
/* allocate a load of objects */
|
||||
for(i=0; i<TEST_SET_SIZE; ++i) {
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ static void AMCSegSketch(Seg seg, char *pbSketch, size_t cbSketch)
|
|||
Bool mut = BufferIsMutator(buffer);
|
||||
Bool flipped = ((buffer->mode & BufferModeFLIPPED) != 0);
|
||||
Bool trapped = BufferIsTrapped(buffer);
|
||||
Bool limitzeroed = (buffer->apStruct.limit == 0);
|
||||
Bool limitzeroed = (buffer->ap_s.limit == 0);
|
||||
|
||||
pbSketch[3] = 'X'; /* I don't know what's going on! */
|
||||
|
||||
|
|
@ -1540,10 +1540,10 @@ static Res amcScanNailed(Bool *totalReturn, ScanState ss, Pool pool,
|
|||
DIAG_SINGLEF(( "amcScanNailed_loop",
|
||||
"scan completed, but had to loop $U times:\n", (WriteFU)loops,
|
||||
" SegSummary: $B\n", (WriteFB)SegSummary(seg),
|
||||
" ss.white: $B\n", (WriteFB)ss->white,
|
||||
" ss.unfixedSummary: $B", (WriteFB)ss->unfixedSummary,
|
||||
" ss.white: $B\n", (WriteFB)ScanStateWhite(ss),
|
||||
" ss.unfixedSummary: $B", (WriteFB)ScanStateUnfixedSummary(ss),
|
||||
"$S\n", (WriteFS)(
|
||||
(RefSetSub(ss->unfixedSummary, SegSummary(seg)))
|
||||
(RefSetSub(ScanStateUnfixedSummary(ss), SegSummary(seg)))
|
||||
? ""
|
||||
: " <=== This would have failed .verify.segsummary!"
|
||||
),
|
||||
|
|
|
|||
|
|
@ -338,11 +338,11 @@ static void *go(void *p, size_t s)
|
|||
die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
|
||||
die(mps_pool_create(&pool, arena, mps_class_amc(), format, chain),
|
||||
"AMCCreate");
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "APCreate");
|
||||
die(mps_root_create_table(®root, arena, MPS_RANK_AMBIG, 0,
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "APCreate");
|
||||
die(mps_root_create_table(®root, arena, mps_rank_ambig(), 0,
|
||||
(mps_addr_t *)reg, NREGS),
|
||||
"RootCreateTable");
|
||||
die(mps_root_create_table(&actroot, arena, MPS_RANK_AMBIG, 0,
|
||||
die(mps_root_create_table(&actroot, arena, mps_rank_ambig(), 0,
|
||||
(mps_addr_t *)&activationStack, sizeof(QSCell)/sizeof(mps_addr_t)),
|
||||
"RootCreateTable");
|
||||
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@ static void mps_amst_ap_stress(mps_ap_t ap)
|
|||
Buffer buffer;
|
||||
Seg seg;
|
||||
|
||||
buffer = BufferOfAP((AP)ap);
|
||||
buffer = BufferOfAP(ap);
|
||||
AVERT(Buffer, buffer);
|
||||
seg = BufferSeg(buffer);
|
||||
AMSTStressBufferedSeg(seg, buffer);
|
||||
|
|
@ -764,8 +764,8 @@ static void *test(void *arg, size_t s)
|
|||
die(mps_pool_create(&pool, arena, mps_class_amst(), format),
|
||||
"pool_create(amst)");
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, MPS_RANK_EXACT), "BufferCreate 2");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, mps_rank_exact()), "BufferCreate 2");
|
||||
|
||||
for(i = 0; i < exactRootsCOUNT; ++i)
|
||||
exactRoots[i] = objNULL;
|
||||
|
|
@ -773,12 +773,12 @@ static void *test(void *arg, size_t s)
|
|||
ambigRoots[i] = rnd_addr();
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&exactRoots[0], exactRootsCOUNT,
|
||||
(mps_word_t)1),
|
||||
"root_create_table(exact)");
|
||||
die(mps_root_create_table(&ambigRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
&ambigRoots[0], ambigRootsCOUNT),
|
||||
"root_create_table(ambig)");
|
||||
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ static void *test(void *arg, size_t s)
|
|||
die(mps_pool_create(&pool, arena, mps_class_amc(), format, chain),
|
||||
"pool_create(amc)");
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
|
||||
|
||||
for(i = 0; i < exactRootsCOUNT; ++i)
|
||||
exactRoots[i] = objNULL;
|
||||
|
|
@ -326,12 +326,12 @@ static void *test(void *arg, size_t s)
|
|||
ambigRoots[i] = rnd_addr();
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&exactRoots[0], exactRootsCOUNT,
|
||||
(mps_word_t)1),
|
||||
"root_create_table(exact)");
|
||||
die(mps_root_create_table(&ambigRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
mps_rank_ambig(), (mps_rm_t)0,
|
||||
&ambigRoots[0], ambigRootsCOUNT),
|
||||
"root_create_table(ambig)");
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ typedef long longest_t;
|
|||
* argument on stderr and exits the program. Otherwise does nothing.
|
||||
*
|
||||
* Typical use:
|
||||
* die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "APCreate");
|
||||
* die(mps_ap_create(&ap, pool, mps_rank_exact()), "APCreate");
|
||||
*/
|
||||
|
||||
extern void die(mps_res_t res, const char *s);
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ Bool ScanStateCheck(ScanState ss)
|
|||
CHECKS(ScanState, ss);
|
||||
CHECKL(FUNCHECK(ss->fix));
|
||||
/* Can't check ss->fixClosure. */
|
||||
CHECKL(ss->zoneShift == ss->arena->zoneShift);
|
||||
CHECKL(ScanStateZoneShift(ss) == ss->arena->zoneShift);
|
||||
white = ZoneSetEMPTY;
|
||||
TRACE_SET_ITER(ti, trace, ss->traces, ss->arena)
|
||||
white = ZoneSetUnion(white, ss->arena->trace[ti].white);
|
||||
TRACE_SET_ITER_END(ti, trace, ss->traces, ss->arena);
|
||||
CHECKL(ss->white == white);
|
||||
CHECKL(ScanStateWhite(ss) == white);
|
||||
CHECKU(Arena, ss->arena);
|
||||
/* Summaries could be anything, and can't be checked. */
|
||||
CHECKL(TraceSetCheck(ss->traces));
|
||||
|
|
@ -94,12 +94,12 @@ void ScanStateInit(ScanState ss, TraceSet ts, Arena arena,
|
|||
|
||||
ss->rank = rank;
|
||||
ss->traces = ts;
|
||||
ss->zoneShift = arena->zoneShift;
|
||||
ss->unfixedSummary = RefSetEMPTY;
|
||||
ScanStateSetZoneShift(ss, arena->zoneShift);
|
||||
ScanStateSetUnfixedSummary(ss, RefSetEMPTY);
|
||||
ss->fixedSummary = RefSetEMPTY;
|
||||
ss->arena = arena;
|
||||
ss->wasMarked = TRUE;
|
||||
ss->white = white;
|
||||
ScanStateSetWhite(ss, white);
|
||||
STATISTIC(ss->fixRefCount = (Count)0);
|
||||
STATISTIC(ss->segRefCount = (Count)0);
|
||||
STATISTIC(ss->whiteSegRefCount = (Count)0);
|
||||
|
|
@ -1108,7 +1108,7 @@ void ScanStateSetSummary(ScanState ss, RefSet summary)
|
|||
AVERT(ScanState, ss);
|
||||
/* Can't check summary, as it can be anything. */
|
||||
|
||||
ss->unfixedSummary = RefSetEMPTY;
|
||||
ScanStateSetUnfixedSummary(ss, RefSetEMPTY);
|
||||
ss->fixedSummary = summary;
|
||||
AVER(ScanStateSummary(ss) == summary);
|
||||
}
|
||||
|
|
@ -1127,7 +1127,8 @@ RefSet ScanStateSummary(ScanState ss)
|
|||
AVERT(ScanState, ss);
|
||||
|
||||
return RefSetUnion(ss->fixedSummary,
|
||||
RefSetDiff(ss->unfixedSummary, ss->white));
|
||||
RefSetDiff(ScanStateUnfixedSummary(ss),
|
||||
ScanStateWhite(ss)));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1156,16 +1157,17 @@ static Res traceScanSegRes(TraceSet ts, Rank rank, Arena arena, Seg seg)
|
|||
/* Setup result code to return later. */
|
||||
res = ResOK;
|
||||
} else { /* scan it */
|
||||
ScanStateStruct ss;
|
||||
ScanStateInit(&ss, ts, arena, rank, white);
|
||||
ScanStateStruct ssStruct;
|
||||
ScanState ss = &ssStruct;
|
||||
ScanStateInit(ss, ts, arena, rank, white);
|
||||
|
||||
/* Expose the segment to make sure we can scan it. */
|
||||
ShieldExpose(arena, seg);
|
||||
res = PoolScan(&wasTotal, &ss, SegPool(seg), seg);
|
||||
res = PoolScan(&wasTotal, ss, SegPool(seg), seg);
|
||||
/* Cover, regardless of result */
|
||||
ShieldCover(arena, seg);
|
||||
|
||||
traceSetUpdateCounts(ts, arena, &ss, traceAccountingPhaseSegScan);
|
||||
traceSetUpdateCounts(ts, arena, ss, traceAccountingPhaseSegScan);
|
||||
/* Count segments scanned pointlessly */
|
||||
STATISTIC_STAT
|
||||
({
|
||||
|
|
@ -1186,19 +1188,19 @@ static Res traceScanSegRes(TraceSet ts, Rank rank, Arena arena, Seg seg)
|
|||
/* .verify.segsummary: were the seg contents, as found by this
|
||||
* scan, consistent with the recorded SegSummary?
|
||||
*/
|
||||
AVER(RefSetSub(ss.unfixedSummary, SegSummary(seg)));
|
||||
AVER(RefSetSub(ScanStateUnfixedSummary(ss), SegSummary(seg)));
|
||||
|
||||
if(res != ResOK || !wasTotal) {
|
||||
/* scan was partial, so... */
|
||||
/* scanned summary should be ORed into segment summary. */
|
||||
SegSetSummary(seg, RefSetUnion(SegSummary(seg), ScanStateSummary(&ss)));
|
||||
SegSetSummary(seg, RefSetUnion(SegSummary(seg), ScanStateSummary(ss)));
|
||||
} else {
|
||||
/* all objects on segment have been scanned, so... */
|
||||
/* scanned summary should replace the segment summary. */
|
||||
SegSetSummary(seg, ScanStateSummary(&ss));
|
||||
SegSetSummary(seg, ScanStateSummary(ss));
|
||||
}
|
||||
|
||||
ScanStateFinish(&ss);
|
||||
ScanStateFinish(ss);
|
||||
}
|
||||
|
||||
if(res == ResOK) {
|
||||
|
|
@ -1314,7 +1316,7 @@ static Res TraceFix2(ScanState ss, Ref *refIO)
|
|||
ref = *refIO;
|
||||
|
||||
/* The zone test should already have been passed by MPS_FIX1 in mps.h. */
|
||||
AVER_CRITICAL(ZoneSetInter(ss->white,
|
||||
AVER_CRITICAL(ZoneSetInter(ScanStateWhite(ss),
|
||||
ZoneSetAdd(ss->arena, ZoneSetEMPTY, ref)) !=
|
||||
ZoneSetEMPTY);
|
||||
|
||||
|
|
@ -1388,7 +1390,7 @@ static Res TraceFix2(ScanState ss, Ref *refIO)
|
|||
* function is in trace.c and not mpsi.c.
|
||||
*/
|
||||
|
||||
mps_res_t mps_fix2(mps_ss_t mps_ss, mps_addr_t *mps_ref_io)
|
||||
mps_res_t _mps_fix2(mps_ss_t mps_ss, mps_addr_t *mps_ref_io)
|
||||
{
|
||||
ScanState ss = (ScanState)mps_ss;
|
||||
Ref *refIO = (Ref *)mps_ref_io;
|
||||
|
|
|
|||
|
|
@ -147,13 +147,13 @@ static void *test(void *arg, size_t s)
|
|||
die(mps_pool_create(&pool, arena, mps_class_amc(), format, chain),
|
||||
"pool_create(amc)");
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "ap_create");
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "ap_create");
|
||||
|
||||
for(i = 0; i < exactRootsCOUNT; ++i)
|
||||
exactRoots[i] = objNULL;
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
mps_rank_exact(), (mps_rm_t)0,
|
||||
&exactRoots[0], exactRootsCOUNT,
|
||||
(mps_word_t)1),
|
||||
"root_create_table(exact)");
|
||||
|
|
|
|||
|
|
@ -754,18 +754,18 @@ static void *testscriptB(void *arg, size_t s)
|
|||
for(i = 0; i < myrootAmbigCOUNT; ++i) {
|
||||
myrootAmbig[i] = NULL;
|
||||
}
|
||||
die(mps_root_create_table(&root_table_Ambig, arena, MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
die(mps_root_create_table(&root_table_Ambig, arena, mps_rank_ambig(), (mps_rm_t)0,
|
||||
myrootAmbig, (size_t)myrootAmbigCOUNT),
|
||||
"root_create - ambig");
|
||||
|
||||
for(i = 0; i < myrootExactCOUNT; ++i) {
|
||||
myrootExact[i] = NULL;
|
||||
}
|
||||
die(mps_root_create_table(&root_table_Exact, arena, MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
die(mps_root_create_table(&root_table_Exact, arena, mps_rank_exact(), (mps_rm_t)0,
|
||||
myrootExact, (size_t)myrootExactCOUNT),
|
||||
"root_create - exact");
|
||||
|
||||
die(mps_ap_create(&ap, amc, MPS_RANK_EXACT), "ap_create");
|
||||
die(mps_ap_create(&ap, amc, mps_rank_exact()), "ap_create");
|
||||
|
||||
/* root_stackreg: stack & registers are ambiguous roots = mutator's workspace */
|
||||
stack_start = &stack_starts_here;
|
||||
|
|
|
|||
|
|
@ -326,10 +326,10 @@ static void *testscriptB(void *arg, size_t s)
|
|||
for(i = 0; i < myrootCOUNT; ++i) {
|
||||
myroot[i] = NULL;
|
||||
}
|
||||
die(mps_root_create_table(&root_table, arena, MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
die(mps_root_create_table(&root_table, arena, mps_rank_exact(), (mps_rm_t)0,
|
||||
myroot, (size_t)myrootCOUNT),
|
||||
"root_create");
|
||||
die(mps_ap_create(&ap, amc, MPS_RANK_EXACT), "ap_create");
|
||||
die(mps_ap_create(&ap, amc, mps_rank_exact()), "ap_create");
|
||||
|
||||
/* root_stackreg: stack & registers are ambiguous roots = mutator's workspace */
|
||||
die(mps_root_create_reg(&root_stackreg, arena,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue