diff options
| author | Nick Barnes | 2002-05-14 13:06:13 +0100 |
|---|---|---|
| committer | Nick Barnes | 2002-05-14 13:06:13 +0100 |
| commit | 833f5bf257e3acff6162176efc70f25ef005b037 (patch) | |
| tree | e41f7ed1e545bf2d69dd28431c149b424ea252f5 /mps/code/amcsshe.c | |
| parent | c5e9dc4c8402721d8ed29a368ea7604136c00341 (diff) | |
| download | emacs-833f5bf257e3acff6162176efc70f25ef005b037.tar.gz emacs-833f5bf257e3acff6162176efc70f25ef005b037.zip | |
Improve treatment of dylan formats: keep common code in fmtdy.c, header-specific code in fmthe.c, the null format in fmtno.[ch], and split out the prototypes for the test functions into fmtdytst.h.
Copied from Perforce
Change: 29145
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code/amcsshe.c')
| -rw-r--r-- | mps/code/amcsshe.c | 97 |
1 files changed, 2 insertions, 95 deletions
diff --git a/mps/code/amcsshe.c b/mps/code/amcsshe.c index 2be9e32be89..bc5de2f184c 100644 --- a/mps/code/amcsshe.c +++ b/mps/code/amcsshe.c | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include "fmthe.h" | 7 | #include "fmthe.h" |
| 8 | #include "fmtdytst.h" | ||
| 8 | #include "testlib.h" | 9 | #include "testlib.h" |
| 9 | #include "mpscamc.h" | 10 | #include "mpscamc.h" |
| 10 | #include "mpsavm.h" | 11 | #include "mpsavm.h" |
| @@ -44,100 +45,6 @@ static mps_addr_t exactRoots[exactRootsCOUNT]; | |||
| 44 | static mps_addr_t ambigRoots[ambigRootsCOUNT]; | 45 | static mps_addr_t ambigRoots[ambigRootsCOUNT]; |
| 45 | static mps_addr_t bogusRoots[bogusRootsCOUNT]; | 46 | static mps_addr_t bogusRoots[bogusRootsCOUNT]; |
| 46 | 47 | ||
| 47 | |||
| 48 | |||
| 49 | static mps_word_t *ww = NULL; | ||
| 50 | static mps_word_t *tvw; | ||
| 51 | |||
| 52 | |||
| 53 | static mps_word_t dylan_make_WV(mps_word_t version, mps_word_t vb, | ||
| 54 | mps_word_t es, mps_word_t vf) | ||
| 55 | { | ||
| 56 | /* VERSION- ... VB------ reserved ES---VF- */ | ||
| 57 | return((version << (MPS_WORD_WIDTH - 8)) | | ||
| 58 | (vb << 16) | | ||
| 59 | (es << 3) | | ||
| 60 | vf); | ||
| 61 | } | ||
| 62 | |||
| 63 | |||
| 64 | static mps_res_t init(mps_addr_t addr, size_t size, | ||
| 65 | mps_addr_t *refs, size_t nr_refs) | ||
| 66 | { | ||
| 67 | |||
| 68 | /* Make sure the size is aligned. */ | ||
| 69 | if ((size & (ALIGN-1)) != 0) return MPS_RES_PARAM; | ||
| 70 | |||
| 71 | if (ww == NULL) { | ||
| 72 | ww = malloc(sizeof(mps_word_t) * (BASIC_WRAPPER_SIZE + 1)); | ||
| 73 | if (ww == NULL) return MPS_RES_MEMORY; | ||
| 74 | tvw = malloc(sizeof(mps_word_t) * BASIC_WRAPPER_SIZE); | ||
| 75 | if (tvw == NULL) { | ||
| 76 | free(ww); | ||
| 77 | return MPS_RES_MEMORY; | ||
| 78 | } | ||
| 79 | |||
| 80 | /* Build a wrapper wrapper. */ | ||
| 81 | ww[WW] = (mps_word_t)ww; | ||
| 82 | ww[WC] = (mps_word_t)ww; /* dummy class */ | ||
| 83 | ww[WM] = (1 << 2) | 1; /* dummy subtype_mask */ | ||
| 84 | ww[WF] = ((WS - 1) << 2) | 2; | ||
| 85 | ww[WV] = dylan_make_WV(2, 0, 0, 0); | ||
| 86 | ww[WS] = (1 << 2) | 1; | ||
| 87 | ww[WP] = 1; | ||
| 88 | |||
| 89 | /* Build a wrapper for traceable vectors. */ | ||
| 90 | tvw[WW] = (mps_word_t)ww; | ||
| 91 | tvw[WC] = (mps_word_t)ww; /* dummy class */ | ||
| 92 | tvw[WM] = (1 << 2) | 1; /* dummy subtype_mask */ | ||
| 93 | tvw[WF] = 0; /* no fixed part */ | ||
| 94 | tvw[WV] = dylan_make_WV(2, 0, 0, 2); /* traceable variable part */ | ||
| 95 | tvw[WS] = 1; /* no patterns */ | ||
| 96 | } | ||
| 97 | |||
| 98 | /* If there is enough room, make a vector, otherwise just */ | ||
| 99 | /* make a padding object. */ | ||
| 100 | |||
| 101 | if (size >= sizeof(mps_word_t) * 2) { | ||
| 102 | mps_word_t *p = (mps_word_t *)addr; | ||
| 103 | mps_word_t i, t = (size / sizeof(mps_word_t)) - 2; | ||
| 104 | |||
| 105 | p[0] = (mps_word_t)tvw; /* install vector wrapper */ | ||
| 106 | p[1] = (t << 2) | 1; /* tag the vector length */ | ||
| 107 | for(i = 0; i < t; ++i) { | ||
| 108 | mps_word_t r = rnd(); | ||
| 109 | |||
| 110 | if (r & 1) | ||
| 111 | p[2+i] = ((r & ~(mps_word_t)3) | 1); /* random int */ | ||
| 112 | else | ||
| 113 | p[2+i] = (mps_word_t)refs[(r >> 1) % nr_refs]; /* random ptr */ | ||
| 114 | } | ||
| 115 | } else { | ||
| 116 | die(MPS_RES_FAIL, "small object"); | ||
| 117 | } | ||
| 118 | |||
| 119 | return MPS_RES_OK; | ||
| 120 | } | ||
| 121 | |||
| 122 | |||
| 123 | static void dylan_write(mps_addr_t addr, mps_addr_t *refs, size_t nr_refs) | ||
| 124 | { | ||
| 125 | mps_word_t *p = (mps_word_t *)addr; | ||
| 126 | mps_word_t t = p[1] >> 2; | ||
| 127 | |||
| 128 | /* If the object is a vector, update a random entry. */ | ||
| 129 | if (p[0] == (mps_word_t)tvw && t > 0) { | ||
| 130 | mps_word_t r = rnd(); | ||
| 131 | size_t i = 2 + (rnd() % t); | ||
| 132 | |||
| 133 | if (r & 1) | ||
| 134 | p[i] = ((r & ~(mps_word_t)3) | 1); /* random int */ | ||
| 135 | else | ||
| 136 | p[i] = (mps_word_t)refs[(r >> 1) % nr_refs]; /* random ptr */ | ||
| 137 | } | ||
| 138 | } | ||
| 139 | |||
| 140 | |||
| 141 | static mps_addr_t make(void) | 48 | static mps_addr_t make(void) |
| 142 | { | 49 | { |
| 143 | size_t length = rnd() % (2*avLEN); | 50 | size_t length = rnd() % (2*avLEN); |
| @@ -150,7 +57,7 @@ static mps_addr_t make(void) | |||
| 150 | if (res) | 57 | if (res) |
| 151 | die(res, "MPS_RESERVE_BLOCK"); | 58 | die(res, "MPS_RESERVE_BLOCK"); |
| 152 | userP = (mps_addr_t)((char*)p + headerSIZE); | 59 | userP = (mps_addr_t)((char*)p + headerSIZE); |
| 153 | res = init(userP, size, exactRoots, exactRootsCOUNT); | 60 | res = dylan_init(userP, size, exactRoots, exactRootsCOUNT); |
| 154 | if (res) | 61 | if (res) |
| 155 | die(res, "dylan_init"); | 62 | die(res, "dylan_init"); |
| 156 | ((int*)p)[0] = realHeader; | 63 | ((int*)p)[0] = realHeader; |