mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-17 08:31:09 -08:00
New unit
new format Copied from Perforce Change: 19217 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
9565bfdd1d
commit
9f7a702995
2 changed files with 156 additions and 0 deletions
121
mps/qa/test/testlib/epvmfmt.c
Normal file
121
mps/qa/test/testlib/epvmfmt.c
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/* epvmfmt.c
|
||||
*/
|
||||
|
||||
#include "mps.h"
|
||||
#include "testlib.h"
|
||||
#include "epvmfmt.h"
|
||||
#include <string.h>
|
||||
|
||||
int alloccomments = 0;
|
||||
|
||||
/* the scanning function doesn't try to fix null refs
|
||||
*/
|
||||
|
||||
static mps_res_t epvmscan(mps_ss_t ss, mps_addr_t base, mps_addr_t limit);
|
||||
|
||||
mps_addr_t epvmskip(mps_addr_t object) {
|
||||
error("skip called on EPVM object: %p", object);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void epvmfwd(mps_addr_t object, mps_addr_t to) {
|
||||
error("fwd called on EPVM object: %p -> %p", object, to);
|
||||
}
|
||||
|
||||
mps_addr_t epvmisfwd(mps_addr_t object) {
|
||||
error("isfwd called on EPVM object: %p", object);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void epvmcopy(mps_addr_t object, mps_addr_t to) {
|
||||
error("copy called on EPVM object: %p -> %p", object, to);
|
||||
}
|
||||
|
||||
void epvmpad(mps_addr_t base, size_t size) {
|
||||
error("pad called in EPVM: %p, %u", base, size);
|
||||
}
|
||||
|
||||
struct mps_fmt_A_s fmtepvm =
|
||||
{
|
||||
(mps_align_t) 8,
|
||||
&epvmscan,
|
||||
&epvmskip,
|
||||
&epvmcopy,
|
||||
&epvmfwd,
|
||||
&epvmisfwd,
|
||||
&epvmpad
|
||||
};
|
||||
|
||||
/* in the following, size is the number of words you want
|
||||
to allocate
|
||||
*/
|
||||
|
||||
psobj *allocepvm(mps_ap_t ap, int size) {
|
||||
mps_addr_t p;
|
||||
psobj *q;
|
||||
int i;
|
||||
size_t bytes;
|
||||
|
||||
asserts(sizeof(struct psobj) == 8, "Aaarg! How can EPVM pools possibly work");
|
||||
bytes = size*8;
|
||||
|
||||
asserts(size > 0, "allocepvm with zero size");
|
||||
|
||||
do
|
||||
{
|
||||
die(mps_reserve(&p, ap, bytes), "Reserve: ");
|
||||
q=p;
|
||||
|
||||
for(i=0; i<size; i+=1)
|
||||
{
|
||||
(q+i)->obj = NULL;
|
||||
(q+i)->size = 0;
|
||||
}
|
||||
}
|
||||
while (!mps_commit(ap, p, bytes));
|
||||
commentif(alloccomments, "allocated %p.", q);
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
void splatepvm(psobj *obj) {
|
||||
obj->size = 0;
|
||||
}
|
||||
|
||||
mps_bool_t issplatepvm(psobj *obj) {
|
||||
return (obj->size == 0);
|
||||
}
|
||||
|
||||
static mps_res_t epvmscan(mps_ss_t ss, mps_addr_t base, mps_addr_t limit)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
MPS_SCAN_BEGIN(ss)
|
||||
{
|
||||
while (base < limit)
|
||||
{
|
||||
psobj *obj = base;
|
||||
mps_res_t res;
|
||||
mps_addr_t p;
|
||||
|
||||
asserts(obj->size > 0, "scan on splatted object at %p", obj);
|
||||
|
||||
p = obj->obj;
|
||||
asserts(p != NULL, "NULL pointer in EPVM obj at %p", obj);
|
||||
res = MPS_FIX(ss, (mps_addr_t *) &p); /* A ghastly PUN! */
|
||||
if (res != MPS_RES_OK) return res;
|
||||
asserts(p != NULL, "reference in EPVM fixed to NULL at %p", obj);
|
||||
obj->obj = p;
|
||||
|
||||
for (i=1; i<obj->size; i++) {
|
||||
p = obj->obj + i;
|
||||
res = MPS_FIX(ss, (mps_addr_t *) &p);
|
||||
if (res != MPS_RES_OK) return res;
|
||||
asserts(p == obj->obj+i, "reference in EPVM changed at %p", obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
MPS_SCAN_END(ss);
|
||||
return MPS_RES_OK;
|
||||
}
|
||||
|
||||
35
mps/qa/test/testlib/epvmfmt.h
Normal file
35
mps/qa/test/testlib/epvmfmt.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* epvmfmt.h
|
||||
Format for objects in the EPVM pool.
|
||||
*/
|
||||
|
||||
#ifndef epvmfmt_h
|
||||
#define epvmfmt_h
|
||||
|
||||
#include "mps.h"
|
||||
|
||||
extern int alloccomments;
|
||||
|
||||
/* the counters are visible so that I can check whether things
|
||||
get moved etc
|
||||
*/
|
||||
|
||||
/* the object format is visible so tests that want to
|
||||
can hack around with it
|
||||
*/
|
||||
|
||||
|
||||
typedef struct psobj {
|
||||
mps_addr_t *obj;
|
||||
mps_word_t size;
|
||||
} psobj;
|
||||
|
||||
extern struct mps_fmt_A_s fmtepvm;
|
||||
|
||||
psobj *allocepvm(mps_ap_t ap, int words);
|
||||
|
||||
void splatepvm(psobj *obj);
|
||||
|
||||
mps_bool_t issplatepvm(psobj *obj);
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue