aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorDavid Lovemore2012-06-28 15:39:07 +0100
committerDavid Lovemore2012-06-28 15:39:07 +0100
commita553fb00533d2ac3b932d7a94b8178d56cf678e9 (patch)
tree595f34eeae0c2a9ee11dc43135512dab17ae0808 /mps/code
parent8f87261a136c91d4cd00d5ccc08b86ac864037ec (diff)
parent1e6a42e2cf06fae86773dc12ffa2e249b85d1a17 (diff)
downloademacs-a553fb00533d2ac3b932d7a94b8178d56cf678e9.tar.gz
emacs-a553fb00533d2ac3b932d7a94b8178d56cf678e9.zip
Merged from branch/2012-03-26/build-w3i6/... to bring over all the work to get windows 64-bit build running.
Copied from Perforce Change: 178525 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/amcss.c12
-rw-r--r--mps/code/amcsshe.c2
-rw-r--r--mps/code/amcssth.c2
-rw-r--r--mps/code/amsss.c2
-rw-r--r--mps/code/amssshe.c4
-rw-r--r--mps/code/apss.c45
-rw-r--r--mps/code/arenavm.c26
-rw-r--r--mps/code/commpost.nmk12
-rw-r--r--mps/code/commpre.nmk3
-rw-r--r--mps/code/dbgpool.h2
-rw-r--r--mps/code/eventcnv.c4
-rw-r--r--mps/code/eventpro.c4
-rw-r--r--mps/code/exposet0.c2
-rw-r--r--mps/code/fmtdytst.h4
-rw-r--r--mps/code/fmthe.c2
-rw-r--r--mps/code/fmthe.h2
-rw-r--r--mps/code/locv.c22
-rw-r--r--mps/code/mpm.h16
-rw-r--r--mps/code/mpmss.c34
-rw-r--r--mps/code/mps.h14
-rw-r--r--mps/code/mpsicv.c12
-rw-r--r--mps/code/mpstd.h27
-rw-r--r--mps/code/mv2test.c4
-rw-r--r--mps/code/prmci6.h65
-rw-r--r--mps/code/prmci6w3.c126
-rw-r--r--mps/code/proti6.c124
-rw-r--r--mps/code/protw3.c7
-rw-r--r--mps/code/sacss.c30
-rw-r--r--mps/code/segsmss.c4
-rw-r--r--mps/code/ssw3i6.asm113
-rw-r--r--mps/code/steptest.c6
-rw-r--r--mps/code/table.c2
-rw-r--r--mps/code/testlib.h13
-rw-r--r--mps/code/thw3.c273
-rw-r--r--mps/code/thw3.h70
-rw-r--r--mps/code/thw3i3.c216
-rw-r--r--mps/code/thw3i6.c168
-rw-r--r--mps/code/trace.c15
-rw-r--r--mps/code/vmw3.c22
-rw-r--r--mps/code/w3i3mv.nmk4
-rw-r--r--mps/code/w3i6mv.nmk363
-rw-r--r--mps/code/walkt0.c2
-rw-r--r--mps/code/zcoll.c46
43 files changed, 1578 insertions, 348 deletions
diff --git a/mps/code/amcss.c b/mps/code/amcss.c
index 7055bf94b70..a6b47bf1914 100644
--- a/mps/code/amcss.c
+++ b/mps/code/amcss.c
@@ -38,7 +38,7 @@ static mps_gen_param_s testChain[genCOUNT] = {
38 38
39 39
40/* objNULL needs to be odd so that it's ignored in exactRoots. */ 40/* objNULL needs to be odd so that it's ignored in exactRoots. */
41#define objNULL ((mps_addr_t)0xDECEA5ED) 41#define objNULL ((mps_addr_t)MPS_WORD_CONST(0xDECEA5ED))
42 42
43 43
44static mps_pool_t pool; 44static mps_pool_t pool;
@@ -210,7 +210,7 @@ static void *test(void *arg, size_t s)
210 ramping = 1; 210 ramping = 1;
211 objs = 0; 211 objs = 0;
212 while (collections < collectionsCOUNT) { 212 while (collections < collectionsCOUNT) {
213 unsigned long c; 213 mps_word_t c;
214 size_t r; 214 size_t r;
215 215
216 c = mps_collections(arena); 216 c = mps_collections(arena);
@@ -230,9 +230,13 @@ static void *test(void *arg, size_t s)
230 */ 230 */
231 231
232 /* how many random addrs must we try, to hit the arena once? */ 232 /* how many random addrs must we try, to hit the arena once? */
233 hitRatio = ((size_t)-1 / mps_arena_committed(arena)); 233 hitRatio = (0xfffffffful / mps_arena_committed(arena));
234 for (i = 0; i < hitsWanted * hitRatio ; i++) { 234 for (i = 0; i < hitsWanted * hitRatio ; i++) {
235 mps_addr_t p = rnd_addr(); 235 /* An exact root maybe in the arena, so add a random 32-bit
236 * offset to it. We may get no hits if it is objNULL.
237 */
238 mps_addr_t p = (char *)exactRoots[rnd() % exactRootsCOUNT]
239 + rnd()-0x80000000ul;
236 if (mps_arena_has_addr(arena, p)) { 240 if (mps_arena_has_addr(arena, p)) {
237 printf("%p is in the arena\n", p); 241 printf("%p is in the arena\n", p);
238 } 242 }
diff --git a/mps/code/amcsshe.c b/mps/code/amcsshe.c
index edc76a16deb..646f6c4f90b 100644
--- a/mps/code/amcsshe.c
+++ b/mps/code/amcsshe.c
@@ -41,7 +41,7 @@ static mps_gen_param_s testChain[genCOUNT] = {
41 41
42 42
43/* objNULL needs to be odd so that it's ignored in exactRoots. */ 43/* objNULL needs to be odd so that it's ignored in exactRoots. */
44#define objNULL ((mps_addr_t)0xDECEA5ED) 44#define objNULL ((mps_addr_t)MPS_WORD_CONST(0xDECEA5ED))
45 45
46 46
47static mps_pool_t pool; 47static mps_pool_t pool;
diff --git a/mps/code/amcssth.c b/mps/code/amcssth.c
index e71849d72fa..08597be51a4 100644
--- a/mps/code/amcssth.c
+++ b/mps/code/amcssth.c
@@ -38,7 +38,7 @@ static mps_gen_param_s testChain[genCOUNT] = {
38 38
39 39
40/* objNULL needs to be odd so that it's ignored in exactRoots. */ 40/* objNULL needs to be odd so that it's ignored in exactRoots. */
41#define objNULL ((mps_addr_t)0xDECEA5ED) 41#define objNULL ((mps_addr_t)MPS_WORD_CONST(0xDECEA5ED))
42 42
43 43
44static mps_pool_t pool; 44static mps_pool_t pool;
diff --git a/mps/code/amsss.c b/mps/code/amsss.c
index efe8c173731..956bd4f58a0 100644
--- a/mps/code/amsss.c
+++ b/mps/code/amsss.c
@@ -30,7 +30,7 @@
30#define totalSizeMAX 800 * (size_t)1024 30#define totalSizeMAX 800 * (size_t)1024
31#define totalSizeSTEP 200 * (size_t)1024 31#define totalSizeSTEP 200 * (size_t)1024
32/* objNULL needs to be odd so that it's ignored in exactRoots. */ 32/* objNULL needs to be odd so that it's ignored in exactRoots. */
33#define objNULL ((mps_addr_t)0xDECEA5ED) 33#define objNULL ((mps_addr_t)MPS_WORD_CONST(0xDECEA5ED))
34#define testArenaSIZE ((size_t)16<<20) 34#define testArenaSIZE ((size_t)16<<20)
35#define initTestFREQ 3000 35#define initTestFREQ 3000
36#define splatTestFREQ 6000 36#define splatTestFREQ 6000
diff --git a/mps/code/amssshe.c b/mps/code/amssshe.c
index a042a06d3ed..cc37010fe20 100644
--- a/mps/code/amssshe.c
+++ b/mps/code/amssshe.c
@@ -28,7 +28,7 @@
28#define totalSizeMAX 800 * (size_t)1024 28#define totalSizeMAX 800 * (size_t)1024
29#define totalSizeSTEP 200 * (size_t)1024 29#define totalSizeSTEP 200 * (size_t)1024
30/* objNULL needs to be odd so that it's ignored in exactRoots. */ 30/* objNULL needs to be odd so that it's ignored in exactRoots. */
31#define objNULL ((mps_addr_t)0xDECEA5ED) 31#define objNULL ((mps_addr_t)MPS_WORD_CONST(0xDECEA5ED))
32#define testArenaSIZE ((size_t)16<<20) 32#define testArenaSIZE ((size_t)16<<20)
33#define initTestFREQ 6000 33#define initTestFREQ 6000
34static mps_gen_param_s testChain[1] = { { 160, 0.90 } }; 34static mps_gen_param_s testChain[1] = { { 160, 0.90 } };
@@ -89,7 +89,7 @@ static void *test(void *arg, size_t s)
89 for(i = 0; i < exactRootsCOUNT; ++i) 89 for(i = 0; i < exactRootsCOUNT; ++i)
90 exactRoots[i] = objNULL; 90 exactRoots[i] = objNULL;
91 for(i = 0; i < ambigRootsCOUNT; ++i) 91 for(i = 0; i < ambigRootsCOUNT; ++i)
92 ambigRoots[i] = (mps_addr_t)rnd(); 92 ambigRoots[i] = rnd_addr();
93 93
94 die(mps_root_create_table_masked(&exactRoot, arena, 94 die(mps_root_create_table_masked(&exactRoot, arena,
95 MPS_RANK_EXACT, (mps_rm_t)0, 95 MPS_RANK_EXACT, (mps_rm_t)0,
diff --git a/mps/code/apss.c b/mps/code/apss.c
index 942b371d223..7b6472a5099 100644
--- a/mps/code/apss.c
+++ b/mps/code/apss.c
@@ -113,23 +113,39 @@ allocFail:
113#define alignUp(w, a) (((w) + (a) - 1) & ~((size_t)(a) - 1)) 113#define alignUp(w, a) (((w) + (a) - 1) & ~((size_t)(a) - 1))
114 114
115 115
116/* randomSize8 -- produce sizes both latge and small, 8-byte aligned */ 116/* randomSizeAligned -- produce sizes both large and small,
117 * aligned by platform alignment */
117 118
118static size_t randomSize8(int i) 119static size_t randomSizeAligned(int i)
119{ 120{
120 size_t maxSize = 2 * 160 * 0x2000; 121 size_t maxSize = 2 * 160 * 0x2000;
121 /* Reduce by a factor of 2 every 10 cycles. Total allocation about 40 MB. */ 122 /* Reduce by a factor of 2 every 10 cycles. Total allocation about 40 MB. */
122 return alignUp(rnd() % max((maxSize >> (i / 10)), 2) + 1, 8); 123 return alignUp(rnd() % max((maxSize >> (i / 10)), 2) + 1, MPS_PF_ALIGN);
123} 124}
124 125
125 126
126/* testInArena -- test all the pool classes in the given arena */ 127static mps_pool_debug_option_s bothOptions8 = {
128 /* .fence_template = */ (void *)"postpost",
129 /* .fence_size = */ 8,
130 /* .free_template = */ (void *)"DEAD",
131 /* .free_size = */ 4
132};
133
134static mps_pool_debug_option_s bothOptions16 = {
135 /* .fence_template = */ (void *)"postpostpostpost",
136 /* .fence_size = */ 16,
137 /* .free_template = */ (void *)"DEAD",
138 /* .free_size = */ 4
139};
127 140
128static mps_pool_debug_option_s bothOptions = 141static mps_pool_debug_option_s fenceOptions = {
129 { (void *)"postpost", 8, (void *)"DEAD", 4 }; 142 /* .fence_template = */ (void *)"\0XXX ''\"\"'' XXX\0",
143 /* .fence_size = */ 16,
144 /* .free_template = */ NULL,
145 /* .free_size = */ 0
146};
130 147
131static mps_pool_debug_option_s fenceOptions = 148/* testInArena -- test all the pool classes in the given arena */
132 { (void *)"\0XXX ''\"\"'' XXX\0", 16, NULL, 0 };
133 149
134static void testInArena(mps_arena_t arena, mps_pool_debug_option_s *options) 150static void testInArena(mps_arena_t arena, mps_pool_debug_option_s *options)
135{ 151{
@@ -138,17 +154,17 @@ static void testInArena(mps_arena_t arena, mps_pool_debug_option_s *options)
138 /* IWBN to test MVFFDebug, but the MPS doesn't support debugging APs, */ 154 /* IWBN to test MVFFDebug, but the MPS doesn't support debugging APs, */
139 /* yet (MV Debug works here, because it fakes it through PoolAlloc). */ 155 /* yet (MV Debug works here, because it fakes it through PoolAlloc). */
140 printf("MVFF\n\n"); 156 printf("MVFF\n\n");
141 res = stress(mps_class_mvff(), randomSize8, arena, 157 res = stress(mps_class_mvff(), randomSizeAligned, arena,
142 (size_t)65536, (size_t)32, (size_t)4, TRUE, TRUE, TRUE); 158 (size_t)65536, (size_t)32, sizeof(void *), TRUE, TRUE, TRUE);
143 if (res == MPS_RES_COMMIT_LIMIT) return; 159 if (res == MPS_RES_COMMIT_LIMIT) return;
144 die(res, "stress MVFF"); 160 die(res, "stress MVFF");
145 printf("MV debug\n\n"); 161 printf("MV debug\n\n");
146 res = stress(mps_class_mv_debug(), randomSize8, arena, 162 res = stress(mps_class_mv_debug(), randomSizeAligned, arena,
147 options, (size_t)65536, (size_t)32, (size_t)65536); 163 options, (size_t)65536, (size_t)32, (size_t)65536);
148 if (res == MPS_RES_COMMIT_LIMIT) return; 164 if (res == MPS_RES_COMMIT_LIMIT) return;
149 die(res, "stress MV debug"); 165 die(res, "stress MV debug");
150 printf("MV\n\n"); 166 printf("MV\n\n");
151 res = stress(mps_class_mv(), randomSize8, arena, 167 res = stress(mps_class_mv(), randomSizeAligned, arena,
152 (size_t)65536, (size_t)32, (size_t)65536); 168 (size_t)65536, (size_t)32, (size_t)65536);
153 if (res == MPS_RES_COMMIT_LIMIT) return; 169 if (res == MPS_RES_COMMIT_LIMIT) return;
154 die(res, "stress MV"); 170 die(res, "stress MV");
@@ -158,6 +174,9 @@ static void testInArena(mps_arena_t arena, mps_pool_debug_option_s *options)
158int main(int argc, char **argv) 174int main(int argc, char **argv)
159{ 175{
160 mps_arena_t arena; 176 mps_arena_t arena;
177 mps_pool_debug_option_s *bothOptions;
178
179 bothOptions = MPS_PF_ALIGN == 8 ? &bothOptions8 : &bothOptions16;
161 180
162 randomize(argc, argv); 181 randomize(argc, argv);
163 182
@@ -169,7 +188,7 @@ int main(int argc, char **argv)
169 188
170 die(mps_arena_create(&arena, mps_arena_class_vmnz(), 2*testArenaSIZE), 189 die(mps_arena_create(&arena, mps_arena_class_vmnz(), 2*testArenaSIZE),
171 "mps_arena_create"); 190 "mps_arena_create");
172 testInArena(arena, &bothOptions); 191 testInArena(arena, bothOptions);
173 mps_arena_destroy(arena); 192 mps_arena_destroy(arena);
174 193
175 fflush(stdout); /* synchronize */ 194 fflush(stdout); /* synchronize */
diff --git a/mps/code/arenavm.c b/mps/code/arenavm.c
index 2b8a473d6bd..1b1a15b50bb 100644
--- a/mps/code/arenavm.c
+++ b/mps/code/arenavm.c
@@ -482,10 +482,28 @@ static Res VMArenaInit(Arena *arenaReturn, ArenaClass class, va_list args)
482 vmArena->vm = arenaVM; 482 vmArena->vm = arenaVM;
483 vmArena->spareSize = 0; 483 vmArena->spareSize = 0;
484 484
485 /* .blacklist: We blacklist the zones corresponding to small integers. */ 485 /* .blacklist: We blacklist the zones that could be referenced by small
486 vmArena->blacklist = 486 integers misinterpreted as references. This isn't a perfect simulation,
487 ZoneSetAdd(arena, ZoneSetAdd(arena, ZoneSetEMPTY, (Addr)1), (Addr)-1); 487 but it should catch the common cases. */
488 488 {
489 union {
490 mps_word_t word;
491 mps_addr_t addr;
492 int i;
493 long l;
494 } nono;
495 vmArena->blacklist = ZoneSetEMPTY;
496 nono.word = 0;
497 nono.i = 1;
498 vmArena->blacklist = ZoneSetAdd(arena, vmArena->blacklist, nono.addr);
499 nono.i = -1;
500 vmArena->blacklist = ZoneSetAdd(arena, vmArena->blacklist, nono.addr);
501 nono.l = 1;
502 vmArena->blacklist = ZoneSetAdd(arena, vmArena->blacklist, nono.addr);
503 nono.l = -1;
504 vmArena->blacklist = ZoneSetAdd(arena, vmArena->blacklist, nono.addr);
505 }
506
489 for(gen = (Index)0; gen < VMArenaGenCount; gen++) { 507 for(gen = (Index)0; gen < VMArenaGenCount; gen++) {
490 vmArena->genZoneSet[gen] = ZoneSetEMPTY; 508 vmArena->genZoneSet[gen] = ZoneSetEMPTY;
491 } 509 }
diff --git a/mps/code/commpost.nmk b/mps/code/commpost.nmk
index 8898f9435b6..3a855d81d88 100644
--- a/mps/code/commpost.nmk
+++ b/mps/code/commpost.nmk
@@ -16,7 +16,7 @@
16 16
17all: mpmss.exe amcss.exe amsss.exe amssshe.exe segsmss.exe awlut.exe awluthe.exe\ 17all: mpmss.exe amcss.exe amsss.exe amssshe.exe segsmss.exe awlut.exe awluthe.exe\
18 mpsicv.exe lockutw3.exe lockcov.exe poolncv.exe locv.exe qs.exe apss.exe \ 18 mpsicv.exe lockutw3.exe lockcov.exe poolncv.exe locv.exe qs.exe apss.exe \
19 finalcv.exe finaltest.exe \ 19 sacss.exe finalcv.exe finaltest.exe \
20 arenacv.exe bttest.exe teletest.exe \ 20 arenacv.exe bttest.exe teletest.exe \
21 abqtest.exe cbstest.exe btcv.exe mv2test.exe messtest.exe steptest.exe \ 21 abqtest.exe cbstest.exe btcv.exe mv2test.exe messtest.exe steptest.exe \
22 locbwcss.exe locusss.exe zcoll.exe zmess.exe \ 22 locbwcss.exe locusss.exe zcoll.exe zmess.exe \
@@ -33,7 +33,7 @@ swall: mmsw.lib replaysw.exe
33 33
34mpmss.exe amcss.exe amcsshe.exe amsss.exe amssshe.exe segsmss.exe awlut.exe awluthe.exe dwstress.exe \ 34mpmss.exe amcss.exe amcsshe.exe amsss.exe amssshe.exe segsmss.exe awlut.exe awluthe.exe dwstress.exe \
35 mpsicv.exe lockutw3.exe lockcov.exe poolncv.exe locv.exe qs.exe apss.exe \ 35 mpsicv.exe lockutw3.exe lockcov.exe poolncv.exe locv.exe qs.exe apss.exe \
36 finalcv.exe finaltest.exe \ 36 sacss.exe finalcv.exe finaltest.exe \
37 arenacv.exe bttest.exe teletest.exe \ 37 arenacv.exe bttest.exe teletest.exe \
38 expt825.exe \ 38 expt825.exe \
39 abqtest.exe cbstest.exe btcv.exe mv2test.exe messtest.exe steptest.exe \ 39 abqtest.exe cbstest.exe btcv.exe mv2test.exe messtest.exe steptest.exe \
@@ -132,6 +132,10 @@ $(PFM)\$(VARIETY)\apss.exe: $(PFM)\$(VARIETY)\apss.obj \
132 $(PFM)\$(VARIETY)\poolmvff.obj \ 132 $(PFM)\$(VARIETY)\poolmvff.obj \
133 $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ) 133 $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ)
134 134
135$(PFM)\$(VARIETY)\sacss.exe: $(PFM)\$(VARIETY)\sacss.obj \
136 $(PFM)\$(VARIETY)\poolmvff.obj \
137 $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ)
138
135$(PFM)\$(VARIETY)\bttest.exe: $(PFM)\$(VARIETY)\bttest.obj \ 139$(PFM)\$(VARIETY)\bttest.exe: $(PFM)\$(VARIETY)\bttest.obj \
136 $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ) 140 $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ)
137 141
@@ -306,7 +310,7 @@ $(PFM)\$(VARIETY)\mpsplcb.lib: $(PFM)\$(VARIETY)\mpslibcb.obj
306 $(ECHO) $@ 310 $(ECHO) $@
307 @if not exist $(PFM) mkdir $(PFM) 311 @if not exist $(PFM) mkdir $(PFM)
308 @if not exist $(PFM)\$(VARIETY) mkdir $(PFM)\$(VARIETY) 312 @if not exist $(PFM)\$(VARIETY) mkdir $(PFM)\$(VARIETY)
309 ml /nologo /c /coff /Fo$@ $< 313 $(MASM) /nologo /c /Fo$@ $<
310 314
311# Coverage files 315# Coverage files
312#{$(PFM)\$(VARIETY)}.exe{$(PFM)\$(VARIETY)}.cov: 316#{$(PFM)\$(VARIETY)}.exe{$(PFM)\$(VARIETY)}.cov:
@@ -322,7 +326,7 @@ $(PFM)\$(VARIETY)\mpsplcb.lib: $(PFM)\$(VARIETY)\mpslibcb.obj
322 326
323{$(PFM)\$(VARIETY)}.obj{$(PFM)\$(VARIETY)}.exe: 327{$(PFM)\$(VARIETY)}.obj{$(PFM)\$(VARIETY)}.exe:
324 $(ECHO) $@ 328 $(ECHO) $@
325 $(LINKER) $(LINKFLAGS) /OUT:$@ $(**) 329 $(LINKER) $(LINKFLAGS) /PDB:$*.pdb /OUT:$@ $(**)
326 330
327 331
328# C. COPYRIGHT AND LICENSE 332# C. COPYRIGHT AND LICENSE
diff --git a/mps/code/commpre.nmk b/mps/code/commpre.nmk
index 05bfb422671..a27b704134c 100644
--- a/mps/code/commpre.nmk
+++ b/mps/code/commpre.nmk
@@ -160,7 +160,7 @@ CFTI = /DCONFIG_VAR_TI $(CRTFLAGSC) $(CFLAGSCOOL) $(CFLAGSINTERNAL)
160# %%VARIETY: define a macro containing the flags for the new variety 160# %%VARIETY: define a macro containing the flags for the new variety
161LINKER = link 161LINKER = link
162LINKFLAGSCOMMON = /nologo 162LINKFLAGSCOMMON = /nologo
163LINKFLAGSINTERNAL = 163LINKFLAGSINTERNAL = /DEBUG
164# ( Internal flags used to be set to /DEBUG:full ) 164# ( Internal flags used to be set to /DEBUG:full )
165LINKFLAGSEXTERNAL = /RELEASE 165LINKFLAGSEXTERNAL = /RELEASE
166 166
@@ -179,6 +179,7 @@ LFTI = $(LINKFLAGSCOOL) $(LINKFLAGSINTERNAL)
179# %%VARIETY: define a macro containing the flags for the new variety 179# %%VARIETY: define a macro containing the flags for the new variety
180LIBMAN = lib # can't call this LIB - it screws the environment 180LIBMAN = lib # can't call this LIB - it screws the environment
181LIBFLAGSCOMMON = /nologo 181LIBFLAGSCOMMON = /nologo
182
182LIBFLAGSWE = 183LIBFLAGSWE =
183LIBFLAGSWI = 184LIBFLAGSWI =
184LIBFLAGSHE = 185LIBFLAGSHE =
diff --git a/mps/code/dbgpool.h b/mps/code/dbgpool.h
index 6ca0493fa3a..4bc96b9eede 100644
--- a/mps/code/dbgpool.h
+++ b/mps/code/dbgpool.h
@@ -1,5 +1,7 @@
1/* dbgpool.h: POOL DEBUG MIXIN 1/* dbgpool.h: POOL DEBUG MIXIN
2 * 2 *
3 * See <design/object-debug>.
4 *
3 * $Id$ 5 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. 6 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5 * Portions copyright (C) 2002 Global Graphics Software. 7 * Portions copyright (C) 2002 Global Graphics Software.
diff --git a/mps/code/eventcnv.c b/mps/code/eventcnv.c
index a524fd56445..9fd35b9d853 100644
--- a/mps/code/eventcnv.c
+++ b/mps/code/eventcnv.c
@@ -247,7 +247,7 @@ static void printAddr(EventProc proc, Addr addr)
247 } 247 }
248 } else 248 } else
249 printf(style != 'C' ? 249 printf(style != 'C' ?
250 " %0"PRIwLONGEST PRIXLONGEST : 250 " %0"PRIwWORD PRIXLONGEST :
251 " %"PRIuLONGEST, 251 " %"PRIuLONGEST,
252 (ulongest_t)addr); 252 (ulongest_t)addr);
253} 253}
@@ -413,7 +413,7 @@ static void readLog(EventProc proc)
413 413
414 while (TRUE) { /* loop for each event */ 414 while (TRUE) { /* loop for each event */
415 char *eventFormat; 415 char *eventFormat;
416 int argCount, i; 416 size_t argCount, i;
417 Event event; 417 Event event;
418 EventCode code; 418 EventCode code;
419 Res res; 419 Res res;
diff --git a/mps/code/eventpro.c b/mps/code/eventpro.c
index 7583a9a70a9..5655d35171b 100644
--- a/mps/code/eventpro.c
+++ b/mps/code/eventpro.c
@@ -95,7 +95,7 @@ static size_t eventType2Index(EventType type)
95 for(i = 0; i < eventTypeCount; ++i) 95 for(i = 0; i < eventTypeCount; ++i)
96 if (eventTypes[i].type == type) 96 if (eventTypes[i].type == type)
97 return i; 97 return i;
98 error("Unknown event type %0"PRIwLONGEST PRIXLONGEST, (ulongest_t)type); 98 error("Unknown event type %0"PRIwWORD PRIXLONGEST, (ulongest_t)type);
99 return 0; 99 return 0;
100} 100}
101 101
@@ -110,7 +110,7 @@ static size_t eventCode2Index(EventCode code, Bool errorp)
110 if (eventTypes[i].code == code) 110 if (eventTypes[i].code == code)
111 return i; 111 return i;
112 if (errorp) 112 if (errorp)
113 error("Unknown event code %0"PRIwLONGEST PRIXLONGEST, (ulongest_t)code); 113 error("Unknown event code %0"PRIwWORD PRIXLONGEST, (ulongest_t)code);
114 return 0; 114 return 0;
115} 115}
116 116
diff --git a/mps/code/exposet0.c b/mps/code/exposet0.c
index 009347ec8bd..c7000214d97 100644
--- a/mps/code/exposet0.c
+++ b/mps/code/exposet0.c
@@ -45,7 +45,7 @@ static mps_gen_param_s testChain[genCOUNT] = {
45 45
46 46
47/* objNULL needs to be odd so that it's ignored in exactRoots. */ 47/* objNULL needs to be odd so that it's ignored in exactRoots. */
48#define objNULL ((mps_addr_t)0xDECEA5ED) 48#define objNULL ((mps_addr_t)MPS_WORD_CONST(0xDECEA5ED))
49 49
50 50
51static mps_pool_t pool_g; 51static mps_pool_t pool_g;
diff --git a/mps/code/fmtdytst.h b/mps/code/fmtdytst.h
index 10078bbd2c7..5aea06c7ee7 100644
--- a/mps/code/fmtdytst.h
+++ b/mps/code/fmtdytst.h
@@ -23,9 +23,9 @@ extern mps_res_t make_dylan_vector(mps_word_t *v, mps_ap_t ap, size_t slots);
23 23
24#define DYLAN_VECTOR_SLOT(o,n) (((mps_word_t *) (o))[(n)+2]) 24#define DYLAN_VECTOR_SLOT(o,n) (((mps_word_t *) (o))[(n)+2])
25 25
26#define DYLAN_INT(n) (((n) << 2) | 1) 26#define DYLAN_INT(n) (((mps_word_t)(n) << 2) | 1)
27 27
28#define DYLAN_INT_INT(d) ((d) >> 2) 28#define DYLAN_INT_INT(d) ((mps_word_t)(d) >> 2)
29 29
30#endif /* fmtdy_h */ 30#endif /* fmtdy_h */
31 31
diff --git a/mps/code/fmthe.c b/mps/code/fmthe.c
index 2e291b52553..ab24062d3ee 100644
--- a/mps/code/fmthe.c
+++ b/mps/code/fmthe.c
@@ -125,7 +125,7 @@ static mps_addr_t dylan_header_isfwd(mps_addr_t object)
125 125
126static void dylan_header_pad(mps_addr_t addr, size_t fullSize) 126static void dylan_header_pad(mps_addr_t addr, size_t fullSize)
127{ 127{
128 *(int*)addr = padHeader(fullSize); 128 *(int*)addr = (int)padHeader(fullSize);
129} 129}
130 130
131 131
diff --git a/mps/code/fmthe.h b/mps/code/fmthe.h
index 369a6b4a926..fa4c9897c7e 100644
--- a/mps/code/fmthe.h
+++ b/mps/code/fmthe.h
@@ -23,7 +23,7 @@ extern mps_res_t HeaderWeakFormatCheck(mps_addr_t addr);
23#define padTYPE 0xaa 23#define padTYPE 0xaa
24#define headerType(header) ((header) & (((mps_word_t)1 << headerTypeBits) - 1)) 24#define headerType(header) ((header) & (((mps_word_t)1 << headerTypeBits) - 1))
25#define headerPadSize(header) ((header) >> headerTypeBits) 25#define headerPadSize(header) ((header) >> headerTypeBits)
26#define padHeader(size) (((mps_word_t)size << headerTypeBits) | padTYPE) 26#define padHeader(size) ((size << headerTypeBits) | padTYPE)
27 27
28#endif /* fmthe_h */ 28#endif /* fmthe_h */
29 29
diff --git a/mps/code/locv.c b/mps/code/locv.c
index a1975e6a43d..010983fd878 100644
--- a/mps/code/locv.c
+++ b/mps/code/locv.c
@@ -27,7 +27,7 @@ static void stepper(mps_addr_t addr, mps_fmt_t fmt, mps_pool_t pool,
27 27
28static mps_fmt_A_s locv_fmt = 28static mps_fmt_A_s locv_fmt =
29 { 29 {
30 (mps_align_t)4, 30 (mps_align_t)0, /* .fmt.align.delayed: to be filled in */
31 scan, 31 scan,
32 skip, 32 skip,
33 copy, 33 copy,
@@ -48,6 +48,8 @@ int main(void)
48 mps_addr_t p; 48 mps_addr_t p;
49 mps_root_t root; 49 mps_root_t root;
50 50
51 locv_fmt.align = sizeof(void *); /* .fmt.align.delayed */
52
51 die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE), 53 die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE),
52 "mps_arena_create"); 54 "mps_arena_create");
53 die(mps_root_create_table(&root, arena, MPS_RANK_EXACT, 55 die(mps_root_create_table(&root, arena, MPS_RANK_EXACT,
@@ -61,22 +63,22 @@ int main(void)
61 63
62 die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "APCreate"); 64 die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "APCreate");
63 65
64 die(mps_reserve(&p, ap, (size_t)4), "mps_reserve 4"); 66 die(mps_reserve(&p, ap, sizeof(void *)), "mps_reserve min");
65 *(mps_word_t *)p = 4; 67 *(mps_word_t *)p = sizeof(void *);
66 cdie(mps_commit(ap, p, (size_t)4), "commit 4"); 68 cdie(mps_commit(ap, p, sizeof(void *)), "commit min");
67 69
68 die(mps_reserve(&roots[1], ap, (size_t)8), "mps_reserve 8"); 70 die(mps_reserve(&roots[1], ap, 2*sizeof(void *)), "mps_reserve 2*min");
69 p = roots[1]; 71 p = roots[1];
70 *(mps_word_t *)p = 8; 72 *(mps_word_t *)p = 2*sizeof(void *);
71 cdie(mps_commit(ap, p, (size_t)8), "commit 8"); 73 cdie(mps_commit(ap, p, 2*sizeof(void *)), "commit 2*min");
72 74
73 die(mps_reserve(&p, ap, (size_t)4096), "mps_reserve 4096"); 75 die(mps_reserve(&p, ap, (size_t)4096), "mps_reserve 4096");
74 *(mps_word_t *)p = 4096; 76 *(mps_word_t *)p = 4096;
75 cdie(mps_commit(ap, p, (size_t)4096), "commit 4096"); 77 cdie(mps_commit(ap, p, (size_t)4096), "commit 4096");
76 78
77 die(mps_reserve(&p, ap, (size_t)4), "mps_reserve last"); 79 die(mps_reserve(&p, ap, sizeof(void *)), "mps_reserve last");
78 *(mps_word_t *)p = 4; 80 *(mps_word_t *)p = sizeof(void *);
79 cdie(mps_commit(ap, p, (size_t)4), "commit last"); 81 cdie(mps_commit(ap, p, sizeof(void *)), "commit last");
80 82
81 { 83 {
82 size_t count = 0; 84 size_t count = 0;
diff --git a/mps/code/mpm.h b/mps/code/mpm.h
index 62dac8a381b..64fe96e09ad 100644
--- a/mps/code/mpm.h
+++ b/mps/code/mpm.h
@@ -405,11 +405,14 @@ extern double TraceWorkFactor;
405 405
406#define TRACE_SCAN_BEGIN(ss) \ 406#define TRACE_SCAN_BEGIN(ss) \
407 BEGIN \ 407 BEGIN \
408 Shift SCANzoneShift = (ss)->zoneShift; \ 408 /* Check range on zoneShift before casting to Shift. */ \
409 ZoneSet SCANwhite = (ss)->white; \ 409 AVER((ss)->zoneShift < MPS_WORD_WIDTH); \
410 RefSet SCANsummary = (ss)->unfixedSummary; \ 410 { \
411 Word SCANt; \ 411 Shift SCANzoneShift = (Shift)(ss)->zoneShift; \
412 { 412 ZoneSet SCANwhite = (ss)->white; \
413 RefSet SCANsummary = (ss)->unfixedSummary; \
414 Word SCANt; \
415 {
413 416
414/* Equivalent to <code/mps.h> MPS_FIX1 */ 417/* Equivalent to <code/mps.h> MPS_FIX1 */
415 418
@@ -431,8 +434,9 @@ extern double TraceWorkFactor;
431/* Equivalent to <code/mps.h> MPS_SCAN_END */ 434/* Equivalent to <code/mps.h> MPS_SCAN_END */
432 435
433#define TRACE_SCAN_END(ss) \ 436#define TRACE_SCAN_END(ss) \
437 } \
438 (ss)->unfixedSummary = SCANsummary; \
434 } \ 439 } \
435 (ss)->unfixedSummary = SCANsummary; \
436 END 440 END
437 441
438extern Res TraceScanArea(ScanState ss, Addr *base, Addr *limit); 442extern Res TraceScanArea(ScanState ss, Addr *base, Addr *limit);
diff --git a/mps/code/mpmss.c b/mps/code/mpmss.c
index c98f32c63a5..506c3c8c816 100644
--- a/mps/code/mpmss.c
+++ b/mps/code/mpmss.c
@@ -127,13 +127,28 @@ static size_t fixedSize(int i)
127} 127}
128 128
129 129
130/* testInArena -- test all the pool classes in the given arena */ 130static mps_pool_debug_option_s bothOptions8 = {
131 131 /* .fence_template = */ (void *)"postpost",
132static mps_pool_debug_option_s bothOptions = 132 /* .fence_size = */ 8,
133 { (void *)"postpost", 8, (void *)"DEAD", 4 }; 133 /* .free_template = */ (void *)"DEAD",
134 /* .free_size = */ 4
135};
136
137static mps_pool_debug_option_s bothOptions16 = {
138 /* .fence_template = */ (void *)"postpostpostpost",
139 /* .fence_size = */ 16,
140 /* .free_template = */ (void *)"DEAD",
141 /* .free_size = */ 4
142};
143
144static mps_pool_debug_option_s fenceOptions = {
145 /* .fence_template = */ (void *)"\0XXX ''\"\"'' XXX\0",
146 /* .fence_size = */ 16,
147 /* .free_template = */ NULL,
148 /* .free_size = */ 0
149};
134 150
135static mps_pool_debug_option_s fenceOptions = 151/* testInArena -- test all the pool classes in the given arena */
136 { (void *)"\0XXX ''\"\"'' XXX\0", 16, NULL, 0 };
137 152
138static int testInArena(mps_arena_t arena, mps_pool_debug_option_s *options) 153static int testInArena(mps_arena_t arena, mps_pool_debug_option_s *options)
139{ 154{
@@ -141,7 +156,7 @@ static int testInArena(mps_arena_t arena, mps_pool_debug_option_s *options)
141 /* cross-segment allocation (possibly MVFF ought not to). */ 156 /* cross-segment allocation (possibly MVFF ought not to). */
142 printf("MVFF\n"); 157 printf("MVFF\n");
143 die(stress(mps_class_mvff(), randomSize8, arena, 158 die(stress(mps_class_mvff(), randomSize8, arena,
144 (size_t)65536, (size_t)32, (size_t)4, TRUE, TRUE, TRUE), 159 (size_t)65536, (size_t)32, sizeof(void *), TRUE, TRUE, TRUE),
145 "stress MVFF"); 160 "stress MVFF");
146 printf("MV debug\n"); 161 printf("MV debug\n");
147 die(stress(mps_class_mv_debug(), randomSize, arena, 162 die(stress(mps_class_mv_debug(), randomSize, arena,
@@ -166,12 +181,15 @@ static int testInArena(mps_arena_t arena, mps_pool_debug_option_s *options)
166int main(int argc, char **argv) 181int main(int argc, char **argv)
167{ 182{
168 mps_arena_t arena; 183 mps_arena_t arena;
184 mps_pool_debug_option_s *bothOptions;
185
186 bothOptions = MPS_PF_ALIGN == 8 ? &bothOptions8 : &bothOptions16;
169 187
170 randomize(argc, argv); 188 randomize(argc, argv);
171 189
172 die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE), 190 die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE),
173 "mps_arena_create"); 191 "mps_arena_create");
174 testInArena(arena, &bothOptions); 192 testInArena(arena, bothOptions);
175 mps_arena_destroy(arena); 193 mps_arena_destroy(arena);
176 194
177 die(mps_arena_create(&arena, mps_arena_class_vm(), smallArenaSIZE), 195 die(mps_arena_create(&arena, mps_arena_class_vm(), smallArenaSIZE),
diff --git a/mps/code/mps.h b/mps/code/mps.h
index fd2c850ccf0..427d9ccba94 100644
--- a/mps/code/mps.h
+++ b/mps/code/mps.h
@@ -16,9 +16,19 @@
16#include <limits.h> 16#include <limits.h>
17 17
18 18
19/* Platform Dependencies */ 19/* Platform Dependencies
20 *
21 * We went for over ten years without any platform ifdefs in this header.
22 * Then Microsoft made unsigned long shorter than a pointer on Win64. Ugh.
23 */
20 24
25#ifndef MPS_T_WORD
26#if defined(_MSC_VER) && defined(_WIN32) && defined(_WIN64) && defined(_M_X64)
27#define MPS_T_WORD unsigned __int64
28#else
21#define MPS_T_WORD unsigned long /* won't be true on W3I6MV */ 29#define MPS_T_WORD unsigned long /* won't be true on W3I6MV */
30#endif
31#endif /* MPS_T_WORD */
22 32
23 33
24/* Abstract Types */ 34/* Abstract Types */
@@ -632,7 +642,7 @@ extern mps_res_t mps_fix(mps_ss_t, mps_addr_t *);
632 642
633#define MPS_FIX1(ss, ref) \ 643#define MPS_FIX1(ss, ref) \
634 (_mps_wt = (mps_word_t)1 << ((mps_word_t)(ref) >> _mps_w0 \ 644 (_mps_wt = (mps_word_t)1 << ((mps_word_t)(ref) >> _mps_w0 \
635 & (sizeof(mps_word_t) * CHAR_BIT - 1)), \ 645 & (sizeof(mps_word_t) * CHAR_BIT - 1)), \
636 _mps_w2 |= _mps_wt, \ 646 _mps_w2 |= _mps_wt, \
637 _mps_w1 & _mps_wt) 647 _mps_w1 & _mps_wt)
638 648
diff --git a/mps/code/mpsicv.c b/mps/code/mpsicv.c
index f2d3aa6f2da..6e067ebbcd5 100644
--- a/mps/code/mpsicv.c
+++ b/mps/code/mpsicv.c
@@ -29,7 +29,7 @@
29#define patternFREQ 100 29#define patternFREQ 100
30 30
31/* objNULL needs to be odd so that it's ignored in exactRoots. */ 31/* objNULL needs to be odd so that it's ignored in exactRoots. */
32#define objNULL ((mps_addr_t)0xDECEA5ED) 32#define objNULL ((mps_addr_t)MPS_WORD_CONST(0xDECEA5ED))
33#define FILLER_OBJECT_SIZE 1023 33#define FILLER_OBJECT_SIZE 1023
34 34
35#define genCOUNT 2 35#define genCOUNT 2
@@ -261,9 +261,9 @@ static void addr_pool_test(mps_arena_t arena,
261 mps_bool_t b; 261 mps_bool_t b;
262 mps_addr_t addr; 262 mps_addr_t addr;
263 /* DISTInguished values are to observe overwrites. */ 263 /* DISTInguished values are to observe overwrites. */
264 mps_pool_t poolDistinguished = (mps_pool_t)0x000d1521; 264 mps_pool_t poolDistinguished = (mps_pool_t)MPS_WORD_CONST(0x000d1521);
265 mps_pool_t pool = poolDistinguished; 265 mps_pool_t pool = poolDistinguished;
266 mps_fmt_t fmtDistinguished = (mps_fmt_t)0x000d1521; 266 mps_fmt_t fmtDistinguished = (mps_fmt_t)MPS_WORD_CONST(0x000d1521);
267 mps_fmt_t fmt = fmtDistinguished; 267 mps_fmt_t fmt = fmtDistinguished;
268 268
269 /* 0a -- obj1 in pool1 (unformatted) */ 269 /* 0a -- obj1 in pool1 (unformatted) */
@@ -427,13 +427,13 @@ static void *test(void *arg, size_t s)
427 exactRoots[j] = objNULL; 427 exactRoots[j] = objNULL;
428 } 428 }
429 for(j = 0; j < ambigRootsCOUNT; ++j) { 429 for(j = 0; j < ambigRootsCOUNT; ++j) {
430 ambigRoots[j] = (mps_addr_t)rnd(); 430 ambigRoots[j] = rnd_addr();
431 } 431 }
432 432
433 die(mps_root_create_table_masked(&exactRoot, arena, 433 die(mps_root_create_table_masked(&exactRoot, arena,
434 MPS_RANK_EXACT, (mps_rm_t)0, 434 MPS_RANK_EXACT, (mps_rm_t)0,
435 &exactRoots[0], exactRootsCOUNT, 435 &exactRoots[0], exactRootsCOUNT,
436 (mps_word_t)1), 436 MPS_WORD_CONST(1)),
437 "root_create_table(exact)"); 437 "root_create_table(exact)");
438 die(mps_root_create_table(&ambigRoot, arena, 438 die(mps_root_create_table(&ambigRoot, arena,
439 MPS_RANK_AMBIG, (mps_rm_t)0, 439 MPS_RANK_AMBIG, (mps_rm_t)0,
@@ -474,7 +474,7 @@ static void *test(void *arg, size_t s)
474 collections = mps_collections(arena); 474 collections = mps_collections(arena);
475 475
476 for(i = 0; i < OBJECTS; ++i) { 476 for(i = 0; i < OBJECTS; ++i) {
477 unsigned c; 477 mps_word_t c;
478 size_t r; 478 size_t r;
479 479
480 c = mps_collections(arena); 480 c = mps_collections(arena);
diff --git a/mps/code/mpstd.h b/mps/code/mpstd.h
index fd637864286..b71da925752 100644
--- a/mps/code/mpstd.h
+++ b/mps/code/mpstd.h
@@ -154,6 +154,33 @@
154#define MPS_WORD_SHIFT 5 154#define MPS_WORD_SHIFT 5
155#define MPS_PF_ALIGN 8 155#define MPS_PF_ALIGN 8
156 156
157
158/* "Predefined Macros" from "Visual Studio 2010" on MSDN
159 * <http://msdn.microsoft.com/en-us/library/b0084kay(v=vs.100).aspx>.
160 * Note that Win32 includes 64-bit Windows!
161 * We use the same alignment as MS malloc: 16, which is used for XMM
162 * operations.
163 * See MSDN -> x64 Software Conventions -> Overview of x64 Calling Conventions
164 * <http://msdn.microsoft.com/en-us/library/ms235286>
165 */
166
167#elif defined(_MSC_VER) && defined(_WIN32) && defined(_WIN64) && defined(_M_X64)
168#if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_W3I6MV)
169#error "specified CONFIG_PF_... inconsistent with detected w3i6mv"
170#endif
171#define MPS_PF_W3I6MV
172#define MPS_PF_STRING "w3i6mv"
173#define MPS_OS_W3
174#define MPS_ARCH_I6
175#define MPS_BUILD_MV
176#define MPS_T_WORD unsigned __int64
177#define MPS_T_LONGEST __int64
178#define MPS_T_ULONGEST unsigned __int64
179#define MPS_WORD_WIDTH 64
180#define MPS_WORD_SHIFT 6
181#define MPS_PF_ALIGN 16
182
183
157/* MW C/C++/ASM Lang Ref (CW9), pp. 184-186. Metrowerks does not document 184/* MW C/C++/ASM Lang Ref (CW9), pp. 184-186. Metrowerks does not document
158 * a way to determine the OS -- we assume MacOS 7. 185 * a way to determine the OS -- we assume MacOS 7.
159 */ 186 */
diff --git a/mps/code/mv2test.c b/mps/code/mv2test.c
index 91e683d055e..fc2f95ab435 100644
--- a/mps/code/mv2test.c
+++ b/mps/code/mv2test.c
@@ -236,7 +236,7 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
236 236
237 if (verbose) { 237 if (verbose) {
238 if(i && i%4==0) putchar('\n'); 238 if(i && i%4==0) putchar('\n');
239 printf("%"PRIwLONGEST PRIXLONGEST" %6"PRIXLONGEST" ", 239 printf("%"PRIwWORD PRIXLONGEST" %6"PRIXLONGEST" ",
240 (ulongest_t)ps[i], (ulongest_t)ss[i]); 240 (ulongest_t)ps[i], (ulongest_t)ss[i]);
241 } 241 }
242 } 242 }
@@ -274,7 +274,7 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
274 274
275 if (verbose) { 275 if (verbose) {
276 if(i && i%4==0) putchar('\n'); 276 if(i && i%4==0) putchar('\n');
277 printf("%"PRIwLONGEST PRIXLONGEST" %6"PRIXLONGEST" ", 277 printf("%"PRIwWORD PRIXLONGEST" %6"PRIXLONGEST" ",
278 (ulongest_t)ps[i], (ulongest_t)ss[i]); 278 (ulongest_t)ps[i], (ulongest_t)ss[i]);
279 } 279 }
280 } 280 }
diff --git a/mps/code/prmci6.h b/mps/code/prmci6.h
new file mode 100644
index 00000000000..a5ed5c99b77
--- /dev/null
+++ b/mps/code/prmci6.h
@@ -0,0 +1,65 @@
1/* prmci6.h: PROTECTION MUTATOR CONTEXT (x64)
2 *
3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5 *
6 * .readership: MPS developers.
7 */
8
9#ifndef prmci6_h
10#define prmci6_h
11
12
13#include "mpm.h"
14
15typedef Word *MRef; /* pointer to a machine word */
16
17MRef Prmci6AddressHoldingReg(MutatorFaultContext, unsigned int);
18
19void Prmci6DecodeFaultContext(MRef *, Byte **, MutatorFaultContext);
20
21void Prmci6StepOverIns(MutatorFaultContext, Size);
22
23#endif /* prmci6_h */
24
25
26/* C. COPYRIGHT AND LICENSE
27 *
28 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
29 * All rights reserved. This is an open source license. Contact
30 * Ravenbrook for commercial licensing options.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions are
34 * met:
35 *
36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 *
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 *
43 * 3. Redistributions in any form must be accompanied by information on how
44 * to obtain complete source code for this software and any accompanying
45 * software that uses this software. The source code must either be
46 * included in the distribution or be available for no more than the cost
47 * of distribution plus a nominal fee, and must be freely redistributable
48 * under reasonable conditions. For an executable file, complete source
49 * code means the source code for all modules it contains. It does not
50 * include source code for modules or files that typically accompany the
51 * major components of the operating system on which the executable file
52 * runs.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
55 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
56 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
57 * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
58 * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
59 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
60 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
61 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
62 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
63 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
64 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65 */
diff --git a/mps/code/prmci6w3.c b/mps/code/prmci6w3.c
new file mode 100644
index 00000000000..19ce79906ec
--- /dev/null
+++ b/mps/code/prmci6w3.c
@@ -0,0 +1,126 @@
1/* prmci6w3.c: PROTECTION MUTATOR CONTEXT INTEL 386 (Win32)
2 *
3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5 *
6 * PURPOSE
7 *
8 * .purpose: This module implements the part of the protection module
9 * that decodes the MutatorFaultContext.
10 *
11 * SOURCES
12 *
13 *
14 * ASSUMPTIONS
15 *
16 * .assume.regref: The resisters in the context can be modified by
17 * storing into an MRef pointer.
18 */
19
20#include "prmcw3.h"
21#include "prmci6.h"
22#include "mpm.h"
23
24SRCID(prmci6w3, "$Id$");
25
26
27/* Prmci6AddressHoldingReg -- Return an address for a given machine register */
28
29MRef Prmci6AddressHoldingReg(MutatorFaultContext context, unsigned int regnum)
30{
31 PCONTEXT wincont;
32
33 AVER(regnum <= 16);
34 AVER(regnum >= 0);
35
36 wincont = context->ep->ContextRecord;
37
38 switch (regnum) {
39 case 0: return (MRef)&wincont->Rax;
40 case 1: return (MRef)&wincont->Rcx;
41 case 2: return (MRef)&wincont->Rdx;
42 case 3: return (MRef)&wincont->Rbx;
43 case 4: return (MRef)&wincont->Rsp;
44 case 5: return (MRef)&wincont->Rbp;
45 case 6: return (MRef)&wincont->Rsi;
46 case 7: return (MRef)&wincont->Rdi;
47 case 8: return (MRef)&wincont->R8;
48 case 9: return (MRef)&wincont->R9;
49 case 10: return (MRef)&wincont->R10;
50 case 11: return (MRef)&wincont->R11;
51 case 12: return (MRef)&wincont->R12;
52 case 13: return (MRef)&wincont->R13;
53 case 14: return (MRef)&wincont->R14;
54 case 15: return (MRef)&wincont->R15;
55 }
56 NOTREACHED;
57 return NULL; /* suppress warning */
58}
59
60
61/* Prmci6DecodeFaultContext -- decode fault context */
62
63void Prmci6DecodeFaultContext(MRef *faultmemReturn, Byte **insvecReturn,
64 MutatorFaultContext context)
65{
66 LPEXCEPTION_RECORD er;
67
68 er = context->ep->ExceptionRecord;
69
70 /* Assert that this is an access violation. The computation of */
71 /* faultmem depends on this. */
72 AVER(er->ExceptionCode == EXCEPTION_ACCESS_VIOLATION);
73
74 *faultmemReturn = (MRef)er->ExceptionInformation[1];
75 *insvecReturn = (Byte*)context->ep->ContextRecord->Rip;
76}
77
78
79/* Prmci6StepOverIns -- skip an instruction by changing the context */
80
81void Prmci6StepOverIns(MutatorFaultContext context, Size inslen)
82{
83 context->ep->ContextRecord->Rip += (DWORD64)inslen;
84}
85
86
87/* C. COPYRIGHT AND LICENSE
88 *
89 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
90 * All rights reserved. This is an open source license. Contact
91 * Ravenbrook for commercial licensing options.
92 *
93 * Redistribution and use in source and binary forms, with or without
94 * modification, are permitted provided that the following conditions are
95 * met:
96 *
97 * 1. Redistributions of source code must retain the above copyright
98 * notice, this list of conditions and the following disclaimer.
99 *
100 * 2. Redistributions in binary form must reproduce the above copyright
101 * notice, this list of conditions and the following disclaimer in the
102 * documentation and/or other materials provided with the distribution.
103 *
104 * 3. Redistributions in any form must be accompanied by information on how
105 * to obtain complete source code for this software and any accompanying
106 * software that uses this software. The source code must either be
107 * included in the distribution or be available for no more than the cost
108 * of distribution plus a nominal fee, and must be freely redistributable
109 * under reasonable conditions. For an executable file, complete source
110 * code means the source code for all modules it contains. It does not
111 * include source code for modules or files that typically accompany the
112 * major components of the operating system on which the executable file
113 * runs.
114 *
115 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
116 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
117 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
118 * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
119 * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
120 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
121 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
122 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
123 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
124 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
125 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
126 */
diff --git a/mps/code/proti6.c b/mps/code/proti6.c
new file mode 100644
index 00000000000..37940f1103e
--- /dev/null
+++ b/mps/code/proti6.c
@@ -0,0 +1,124 @@
1/* proti6.c: PROTECTION MUTATOR CONTEXT (x64)
2 *
3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5 *
6 * .design: See <design/prot/> for the generic design of the interface
7 * which is implemented in this module, including the contracts for the
8 * functions.
9 *
10 * .purpose: This module implements the part of the protection module
11 * that implements the MutatorFaultContext type.
12 *
13 *
14 * SOURCES
15 *
16 * .source.amd64: AMD64 Architecture Programmer’s Manual Volume 3:
17 * General-Purpose and System Instructions
18 * <http://support.amd.com/us/Processor_TechDocs/24594_APM_v3.pdf>
19 *
20 *
21 * ASSUMPTIONS
22 *
23 * .assume.null: It's always safe for Prot*StepInstruction to return
24 * ResUNIMPL. A null implementation of this module would be overly
25 * conservative but otherwise correct.
26 *
27 */
28
29#include "mpm.h"
30#include "prmci6.h"
31
32SRCID(proti6, "$Id$");
33
34
35static Bool IsSimpleMov(Size *inslenReturn,
36 MRef *srcReturn,
37 MRef *destReturn,
38 MutatorFaultContext context)
39{
40 Byte *insvec;
41 MRef faultmem;
42
43 Prmci6DecodeFaultContext(&faultmem, &insvec, context);
44 /* Unimplemented */
45 UNUSED(inslenReturn);
46 UNUSED(srcReturn);
47 UNUSED(destReturn);
48
49 return FALSE;
50}
51
52
53Bool ProtCanStepInstruction(MutatorFaultContext context)
54{
55 Size inslen;
56 MRef src;
57 MRef dest;
58
59 /* .assume.null */
60 if(IsSimpleMov(&inslen, &src, &dest, context)) {
61 return TRUE;
62 }
63
64 return FALSE;
65}
66
67
68Res ProtStepInstruction(MutatorFaultContext context)
69{
70 Size inslen;
71 MRef src;
72 MRef dest;
73
74 /* .assume.null */
75 if(IsSimpleMov(&inslen, &src, &dest, context)) {
76 *dest = *src;
77 Prmci6StepOverIns(context, inslen);
78 return ResOK;
79 }
80
81 return ResUNIMPL;
82}
83
84
85/* C. COPYRIGHT AND LICENSE
86 *
87 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
88 * All rights reserved. This is an open source license. Contact
89 * Ravenbrook for commercial licensing options.
90 *
91 * Redistribution and use in source and binary forms, with or without
92 * modification, are permitted provided that the following conditions are
93 * met:
94 *
95 * 1. Redistributions of source code must retain the above copyright
96 * notice, this list of conditions and the following disclaimer.
97 *
98 * 2. Redistributions in binary form must reproduce the above copyright
99 * notice, this list of conditions and the following disclaimer in the
100 * documentation and/or other materials provided with the distribution.
101 *
102 * 3. Redistributions in any form must be accompanied by information on how
103 * to obtain complete source code for this software and any accompanying
104 * software that uses this software. The source code must either be
105 * included in the distribution or be available for no more than the cost
106 * of distribution plus a nominal fee, and must be freely redistributable
107 * under reasonable conditions. For an executable file, complete source
108 * code means the source code for all modules it contains. It does not
109 * include source code for modules or files that typically accompany the
110 * major components of the operating system on which the executable file
111 * runs.
112 *
113 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
114 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
115 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
116 * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
117 * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
118 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
119 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
120 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
121 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
122 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
123 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
124 */
diff --git a/mps/code/protw3.c b/mps/code/protw3.c
index 8a9e690b62d..2c8e3c312fc 100644
--- a/mps/code/protw3.c
+++ b/mps/code/protw3.c
@@ -32,7 +32,6 @@ void ProtSet(Addr base, Addr limit, AccessSet mode)
32 DWORD newProtect; 32 DWORD newProtect;
33 DWORD oldProtect; 33 DWORD oldProtect;
34 34
35 AVER(sizeof(int) == sizeof(Addr));
36 AVER(base < limit); 35 AVER(base < limit);
37 AVER(base != 0); 36 AVER(base != 0);
38 37
@@ -42,7 +41,7 @@ void ProtSet(Addr base, Addr limit, AccessSet mode)
42 if((mode & AccessREAD) != 0) 41 if((mode & AccessREAD) != 0)
43 newProtect = PAGE_NOACCESS; 42 newProtect = PAGE_NOACCESS;
44 43
45 if(VirtualProtect((LPVOID)base, (DWORD)AddrOffset(base, limit), 44 if(VirtualProtect((LPVOID)base, (SIZE_T)AddrOffset(base, limit),
46 newProtect, &oldProtect) == 0) 45 newProtect, &oldProtect) == 0)
47 NOTREACHED; 46 NOTREACHED;
48} 47}
@@ -51,8 +50,8 @@ void ProtSet(Addr base, Addr limit, AccessSet mode)
51LONG ProtSEHfilter(LPEXCEPTION_POINTERS info) 50LONG ProtSEHfilter(LPEXCEPTION_POINTERS info)
52{ 51{
53 LPEXCEPTION_RECORD er; 52 LPEXCEPTION_RECORD er;
54 DWORD iswrite; 53 ULONG_PTR iswrite;
55 DWORD address; 54 ULONG_PTR address;
56 AccessSet mode; 55 AccessSet mode;
57 Addr base, limit; 56 Addr base, limit;
58 LONG action; 57 LONG action;
diff --git a/mps/code/sacss.c b/mps/code/sacss.c
index 80bf5fca03a..6c5067583db 100644
--- a/mps/code/sacss.c
+++ b/mps/code/sacss.c
@@ -148,21 +148,41 @@ static size_t randomSize8(int i)
148 148
149/* testInArena -- test all the pool classes in the given arena */ 149/* testInArena -- test all the pool classes in the given arena */
150 150
151static mps_pool_debug_option_s debugOptions = 151static mps_pool_debug_option_s debugOptions8 = {
152 { (void *)"postpost", 8, NULL, 0 }; 152 /* .fence_template = */ (void *)"postpost",
153 /* .fence_size = */ 8,
154 /* .free_template = */ (void *)"DEAD",
155 /* .free_size = */ 4
156};
157
158static mps_pool_debug_option_s debugOptions16 = {
159 /* .fence_template = */ (void *)"postpostpostpost",
160 /* .fence_size = */ 16,
161 /* .free_template = */ (void *)"DEAD",
162 /* .free_size = */ 4
163};
164
165static mps_sac_classes_s classes8[4] = { {8, 1, 1}, {16, 1, 2}, {136, 9, 5},
166 {topClassSIZE, 9, 4} };
153 167
154static mps_sac_classes_s classes[4] = { {8, 1, 1}, {16, 1, 2}, {136, 9, 5}, 168static mps_sac_classes_s classes16[4] = { {16, 1, 1}, {32, 1, 2}, {144, 9, 5},
155 {topClassSIZE, 9, 4} }; 169 {topClassSIZE, 9, 4} };
156 170
157static int testInArena(mps_arena_t arena) 171static int testInArena(mps_arena_t arena)
158{ 172{
173 mps_pool_debug_option_s *debugOptions;
174 mps_sac_classes_s *classes;
175
176 debugOptions = MPS_PF_ALIGN == 8 ? &debugOptions8 : &debugOptions16;
177 classes = MPS_PF_ALIGN == 8 ? classes8 : classes16;
178
159 printf("MVFF\n\n"); 179 printf("MVFF\n\n");
160 die(stress(mps_class_mvff(), classCOUNT, classes, randomSize8, arena, 180 die(stress(mps_class_mvff(), classCOUNT, classes, randomSize8, arena,
161 (size_t)65536, (size_t)32, (size_t)4, TRUE, TRUE, TRUE), 181 (size_t)65536, (size_t)32, sizeof(void *), TRUE, TRUE, TRUE),
162 "stress MVFF"); 182 "stress MVFF");
163 printf("MV debug\n\n"); 183 printf("MV debug\n\n");
164 die(stress(mps_class_mv_debug(), classCOUNT, classes, randomSize8, arena, 184 die(stress(mps_class_mv_debug(), classCOUNT, classes, randomSize8, arena,
165 &debugOptions, (size_t)65536, (size_t)32, (size_t)65536), 185 debugOptions, (size_t)65536, (size_t)32, (size_t)65536),
166 "stress MV debug"); 186 "stress MV debug");
167 printf("MV\n\n"); 187 printf("MV\n\n");
168 die(stress(mps_class_mv(), classCOUNT, classes, randomSize8, arena, 188 die(stress(mps_class_mv(), classCOUNT, classes, randomSize8, arena,
diff --git a/mps/code/segsmss.c b/mps/code/segsmss.c
index 71036b3edbb..04fa587dee5 100644
--- a/mps/code/segsmss.c
+++ b/mps/code/segsmss.c
@@ -714,7 +714,7 @@ static mps_class_t mps_class_amst(void)
714#define totalSizeMAX sizeScale * 800 * (size_t)1024 714#define totalSizeMAX sizeScale * 800 * (size_t)1024
715#define totalSizeSTEP 200 * (size_t)1024 715#define totalSizeSTEP 200 * (size_t)1024
716/* objNULL needs to be odd so that it's ignored in exactRoots. */ 716/* objNULL needs to be odd so that it's ignored in exactRoots. */
717#define objNULL ((mps_addr_t)0xDECEA5ED) 717#define objNULL ((mps_addr_t)MPS_WORD_CONST(0xDECEA5ED))
718#define testArenaSIZE ((size_t)16<<20) 718#define testArenaSIZE ((size_t)16<<20)
719#define initTestFREQ 6000 719#define initTestFREQ 6000
720#define stressTestFREQ 40 720#define stressTestFREQ 40
@@ -778,7 +778,7 @@ static void *test(void *arg, size_t s)
778 for(i = 0; i < exactRootsCOUNT; ++i) 778 for(i = 0; i < exactRootsCOUNT; ++i)
779 exactRoots[i] = objNULL; 779 exactRoots[i] = objNULL;
780 for(i = 0; i < ambigRootsCOUNT; ++i) 780 for(i = 0; i < ambigRootsCOUNT; ++i)
781 ambigRoots[i] = (mps_addr_t)rnd(); 781 ambigRoots[i] = rnd_addr();
782 782
783 die(mps_root_create_table_masked(&exactRoot, arena, 783 die(mps_root_create_table_masked(&exactRoot, arena,
784 MPS_RANK_EXACT, (mps_rm_t)0, 784 MPS_RANK_EXACT, (mps_rm_t)0,
diff --git a/mps/code/ssw3i6.asm b/mps/code/ssw3i6.asm
new file mode 100644
index 00000000000..4589147758f
--- /dev/null
+++ b/mps/code/ssw3i6.asm
@@ -0,0 +1,113 @@
1; ssw3i6.asm : WIN32/x64 STACK SCANNER
2;
3; $Id$
4; Copyright (c) 2012 Ravenbrook Limited. See end of file for license.
5; Portions copyright (C) 2002 Global Graphics Software.
6
7; For register usage see
8; MSDN -> x64 Software Conventions -> Register Usage
9; <http://msdn.microsoft.com/en-us/library/9z1stfyw>
10
11.CODE
12EXTERN TraceScanArea : PROC
13
14StackScan PROC FRAME
15 ; Prolog follows. See
16 ; MSDN -> x64 Software Conventions -> Prolog and Epilog
17 ; <http://msdn.microsoft.com/en-us/library/tawsa7cb>
18 ; Also see
19 ; MSDN -> Microsoft Macro Assembler Reference -> Directives Reference
20 ; <http://msdn.microsoft.com/en-us/library/8t163bt0>
21 ; for the use of .pushreg and other directives.
22 ; Push the callee-save registers.
23 ; Stack must be 16-byte aligned; the return address is on top of the stack;
24 ; after pushing another register it will be 16-byte aligned again.
25 push rdi
26.pushreg rdi
27
28 push rsi
29.pushreg rsi
30 push rbx
31.pushreg rbx
32
33 push rbp
34.pushreg rbp
35 push r12
36.pushreg r12
37
38 push r13
39.pushreg r13
40 push r14
41.pushreg r14
42
43 push r15
44.pushreg r15
45 ; An odd number of qwords have been pushed on the stack (including the
46 ; return address) so we need to subtract an extra 8 bytes on top of the
47 ; 4 qwords we need for to reserve for the register parameter stack area.
48 ; See
49 ; MSDN -> x64 Software Conventions -> Stack Usage -> Stack Allocation
50 ; <http://msdn.microsoft.com/en-us/library/ew5tede7>
51 sub rsp, 40
52.allocstack 40
53.endprolog
54 ; for convenience set up arguments in reverse order.
55 mov r8, rdx ; stackBot
56 mov rdx, rsp ; top of stack
57 add rdx, 40 ; where last callee-save register stored
58 ; mov rcx, rcx ; ss already in the right register.
59 call TraceScanArea
60 add rsp, 40
61 pop r15 ; pop the callee-save registers
62 pop r14
63 pop r13
64 pop r12
65 pop rbp
66 pop rbx
67 pop rsi
68 pop rdi
69 ret
70
71StackScan ENDP
72
73END
74; C. COPYRIGHT AND LICENSE
75;
76; Copyright (C) 2001-2012 Ravenbrook Limited <http://www.ravenbrook.com/>.
77; All rights reserved. This is an open source license. Contact
78; Ravenbrook for commercial licensing options.
79;
80; Redistribution and use in source and binary forms, with or without
81; modification, are permitted provided that the following conditions are
82; met:
83;
84; 1. Redistributions of source code must retain the above copyright
85; notice, this list of conditions and the following disclaimer.
86;
87; 2. Redistributions in binary form must reproduce the above copyright
88; notice, this list of conditions and the following disclaimer in the
89; documentation and/or other materials provided with the distribution.
90;
91; 3. Redistributions in any form must be accompanied by information on how
92; to obtain complete source code for this software and any accompanying
93; software that uses this software. The source code must either be
94; included in the distribution or be available for no more than the cost
95; of distribution plus a nominal fee, and must be freely redistributable
96; under reasonable conditions. For an executable file, complete source
97; code means the source code for all modules it contains. It does not
98; include source code for modules or files that typically accompany the
99; major components of the operating system on which the executable file
100; runs.
101;
102; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
103; IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
104; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
105; PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
106; COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
107; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
108; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
109; USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
110; ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
111; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
112; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113
diff --git a/mps/code/steptest.c b/mps/code/steptest.c
index 16477d10f8e..bdb34489411 100644
--- a/mps/code/steptest.c
+++ b/mps/code/steptest.c
@@ -63,7 +63,7 @@ static int test_number = 0;
63 63
64 64
65/* objNULL needs to be odd so that it's ignored in exactRoots. */ 65/* objNULL needs to be odd so that it's ignored in exactRoots. */
66#define objNULL ((mps_addr_t)0xDECEA5ED) 66#define objNULL ((mps_addr_t)MPS_WORD_CONST(0xDECEA5ED))
67 67
68static mps_pool_t pool; 68static mps_pool_t pool;
69static mps_ap_t ap; 69static mps_ap_t ap;
@@ -83,7 +83,7 @@ double total_clock_time; /* Time spent reading the clock */
83long clock_reads; /* Number of times clock is read */ 83long clock_reads; /* Number of times clock is read */
84long steps; /* # of mps_arena_step calls returning 1 */ 84long steps; /* # of mps_arena_step calls returning 1 */
85long no_steps; /* # of mps_arena_step calls returning 0 */ 85long no_steps; /* # of mps_arena_step calls returning 0 */
86long alloc_bytes; /* # of bytes allocated */ 86size_t alloc_bytes; /* # of bytes allocated */
87long commit_failures; /* # of times mps_commit fails */ 87long commit_failures; /* # of times mps_commit fails */
88 88
89 89
@@ -323,7 +323,7 @@ static void *test(void *arg, size_t s)
323 for(i = 0; i < exactRootsCOUNT; ++i) 323 for(i = 0; i < exactRootsCOUNT; ++i)
324 exactRoots[i] = objNULL; 324 exactRoots[i] = objNULL;
325 for(i = 0; i < ambigRootsCOUNT; ++i) 325 for(i = 0; i < ambigRootsCOUNT; ++i)
326 ambigRoots[i] = (mps_addr_t)rnd(); 326 ambigRoots[i] = rnd_addr();
327 327
328 die(mps_root_create_table_masked(&exactRoot, arena, 328 die(mps_root_create_table_masked(&exactRoot, arena,
329 MPS_RANK_EXACT, (mps_rm_t)0, 329 MPS_RANK_EXACT, (mps_rm_t)0,
diff --git a/mps/code/table.c b/mps/code/table.c
index 772e45d9d30..b7ba512d270 100644
--- a/mps/code/table.c
+++ b/mps/code/table.c
@@ -65,7 +65,7 @@ static size_t sizeFloorLog2(size_t size)
65static ulong TableHash(Word key) 65static ulong TableHash(Word key)
66{ 66{
67 /* Shift some randomness into the low bits. */ 67 /* Shift some randomness into the low bits. */
68 return (key >> 10) + key; 68 return (ulong)((key >> 10) + key);
69} 69}
70 70
71 71
diff --git a/mps/code/testlib.h b/mps/code/testlib.h
index 63d462a6658..21ee34e1d2e 100644
--- a/mps/code/testlib.h
+++ b/mps/code/testlib.h
@@ -88,15 +88,17 @@
88#ifdef MPS_PF_W3I6MV 88#ifdef MPS_PF_W3I6MV
89#define PRIuLONGEST "llu" 89#define PRIuLONGEST "llu"
90#define PRIXLONGEST "llX" 90#define PRIXLONGEST "llX"
91#define PRIwLONGEST "16" 91#define PRIwWORD "16"
92typedef unsigned long long ulongest_t; 92typedef unsigned long long ulongest_t;
93#define MPS_WORD_CONST(n) (n##ull)
93#else 94#else
94#define PRIuLONGEST "lu" 95#define PRIuLONGEST "lu"
95#define PRIXLONGEST "lX" 96#define PRIXLONGEST "lX"
96#define PRIwLONGEST "8" 97#define PRIwWORD "8"
97typedef unsigned long ulongest_t; 98typedef unsigned long ulongest_t;
99#define MPS_WORD_CONST(n) (n##ul)
98#endif 100#endif
99#define PRIXPTR "0"PRIwLONGEST PRIXLONGEST 101#define PRIXPTR "0"PRIwWORD PRIXLONGEST
100 102
101 103
102/* testlib_unused -- declares that a variable is unused 104/* testlib_unused -- declares that a variable is unused
@@ -157,7 +159,10 @@ extern void verror(const char *format, va_list args);
157#define Insist(cond) insist1(cond, #cond) 159#define Insist(cond) insist1(cond, #cond)
158 160
159#define insist1(cond, condstring) \ 161#define insist1(cond, condstring) \
160 cdie(cond, condstring "\n" __FILE__ "\n" STR(__LINE__)) 162 if(cond) \
163 NOOP; \
164 else \
165 cdie(cond, condstring "\n" __FILE__ "\n" STR(__LINE__))
161 166
162 167
163/* rnd -- random number generator 168/* rnd -- random number generator
diff --git a/mps/code/thw3.c b/mps/code/thw3.c
new file mode 100644
index 00000000000..250951018da
--- /dev/null
+++ b/mps/code/thw3.c
@@ -0,0 +1,273 @@
1/* thw3i3.c: WIN32 THREAD MANAGER
2 *
3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5 *
6 * Implements thread registration, suspension, and stack
7 * scanning. See <design/thread-manager/>.
8 *
9 * This supports the <code/th.h> along with <code/thw3i3.c> or <code/thw3i6.c>
10 *
11 * .thread.id: The thread id is used to identify the current thread.
12 * .thread.handle: The thread handle needs the enough access to
13 * be able to suspend threads and to get their context. i.e.
14 * .thread.handle.susp-res: THREAD_SUSPEND_RESUME access
15 * .thread.handle.get-context: THREAD_GET_CONTEXT access
16 * An appropriate handle is created on registration.
17 *
18 *
19 * ASSUMPTIONS
20 *
21 * .error: some major errors are assumed not to happen.
22 * .error.close-handle: CloseHandle is assumed to succeed.
23 *
24 * Other errors are assumed to only happen in certain circumstances.
25 * .error.resume: ResumeThread is assumed to succeed unless the thread
26 * has been destroyed (in fact, perversely, it appears to succeeed even
27 * when the thread has been destroyed).
28 * .error.suspend: SuspendThread is assumed to succeed unless the thread
29 * has been destroyed.
30 *
31 *
32 * .nt: uses Win32 specific stuff
33 * HANDLE
34 * DWORD
35 * GetCurrentProcess
36 * DuplicateHandle
37 * THREAD_SUSPEND_RESUME
38 * GetCurrentThreadId
39 * CloseHandle
40 * SuspendThread
41 * ResumeThread
42 *
43 */
44
45#include "mpm.h"
46
47#if !defined(MPS_OS_W3) /* .nt */
48#error "Compiling thw3 when MPS_OS_W3 not defined."
49#endif
50
51#include "thw3.h"
52
53#include "mpswin.h"
54
55SRCID(thw3, "$Id$");
56
57
58Bool ThreadCheck(Thread thread)
59{
60 CHECKS(Thread, thread);
61 CHECKU(Arena, thread->arena);
62 CHECKL(thread->serial < thread->arena->threadSerial);
63 CHECKL(RingCheck(&thread->arenaRing));
64 return TRUE;
65}
66
67
68Bool ThreadCheckSimple(Thread thread)
69{
70 CHECKS(Thread, thread);
71 return TRUE;
72}
73
74
75Res ThreadRegister(Thread *threadReturn, Arena arena)
76{
77 Res res;
78 Thread thread;
79 HANDLE procHandle;
80 BOOL b;
81 void *p;
82
83 AVER(threadReturn != NULL);
84 AVERT(Arena, arena);
85
86 res = ControlAlloc(&p, arena, sizeof(ThreadStruct),
87 /* withReservoirPermit */ FALSE);
88 if(res != ResOK)
89 return res;
90 thread = (Thread)p; /* avoid pun */
91
92 /* Duplicate handle gives us a new handle with updated privileges.
93 * .thread.handle describes the ones needed.
94 */
95 procHandle = GetCurrentProcess();
96
97 b = DuplicateHandle(procHandle, GetCurrentThread(), procHandle,
98 &thread->handle,
99 THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT,
100 FALSE, 0);
101 if(!b)
102 return ResRESOURCE;
103
104 thread->id = GetCurrentThreadId();
105
106 RingInit(&thread->arenaRing);
107
108 thread->sig = ThreadSig;
109 thread->serial = arena->threadSerial;
110 ++arena->threadSerial;
111 thread->arena = arena;
112
113 AVERT(Thread, thread);
114
115 RingAppend(ArenaThreadRing(arena), &thread->arenaRing);
116
117 *threadReturn = thread;
118 return ResOK;
119}
120
121void ThreadDeregister(Thread thread, Arena arena)
122{
123 Bool b;
124
125 AVERT(Thread, thread);
126 AVERT(Arena, arena);
127
128 RingRemove(&thread->arenaRing);
129
130 thread->sig = SigInvalid;
131
132 RingFinish(&thread->arenaRing);
133
134 b = CloseHandle(thread->handle);
135 AVER(b); /* .error.close-handle */
136
137 ControlFree(arena, thread, sizeof(ThreadStruct));
138}
139
140
141/* Map over threads on ring calling f on each one except the
142 * current thread.
143 */
144static void mapThreadRing(Ring ring, void (*f)(Thread thread))
145{
146 Ring node;
147 DWORD id;
148
149 id = GetCurrentThreadId();
150 node = RingNext(ring);
151 while(node != ring) {
152 Ring next = RingNext(node);
153 Thread thread;
154
155 thread = RING_ELT(Thread, arenaRing, node);
156 AVERT(Thread, thread);
157 if(id != thread->id) /* .thread.id */
158 (*f)(thread);
159
160 node = next;
161 }
162}
163
164static void suspend(Thread thread)
165{
166 /* .thread.handle.susp-res */
167 /* .error.suspend */
168 /* In the error case (SuspendThread returning 0xFFFFFFFF), we */
169 /* assume the thread has been destroyed (as part of process shutdown). */
170 /* In which case we simply continue. */
171 /* [GetLastError appears to return 5 when SuspendThread is called */
172 /* on a destroyed thread, but I'm not sufficiently confident of this */
173 /* to check -- drj 1998-04-09] */
174 (void)SuspendThread(thread->handle);
175}
176
177void ThreadRingSuspend(Ring ring)
178{
179 mapThreadRing(ring, suspend);
180}
181
182static void resume(Thread thread)
183{
184 /* .thread.handle.susp-res */
185 /* .error.resume */
186 /* In the error case (ResumeThread returning 0xFFFFFFFF), we */
187 /* assume the thread has been destroyed (as part of process shutdown). */
188 /* In which case we simply continue. */
189 (void)ResumeThread(thread->handle);
190}
191
192void ThreadRingResume(Ring ring)
193{
194 mapThreadRing(ring, resume);
195}
196
197
198Thread ThreadRingThread(Ring threadRing)
199{
200 Thread thread;
201 AVERT(Ring, threadRing);
202 thread = RING_ELT(Thread, arenaRing, threadRing);
203 AVERT(Thread, thread);
204 return thread;
205}
206
207/* Must be thread-safe. See <design/interface-c/#thread-safety>. */
208Arena ThreadArena(Thread thread)
209{
210 /* Can't AVER thread as that would not be thread-safe */
211 /* AVERT(Thread, thread); */
212 return thread->arena;
213}
214
215Res ThreadDescribe(Thread thread, mps_lib_FILE *stream)
216{
217 Res res;
218
219 res = WriteF(stream,
220 "Thread $P ($U) {\n", (WriteFP)thread, (WriteFU)thread->serial,
221 " arena $P ($U)\n",
222 (WriteFP)thread->arena, (WriteFU)thread->arena->serial,
223 " handle $W\n", (WriteFW)thread->handle,
224 " id $U\n", (WriteFU)thread->id,
225 "} Thread $P ($U)\n", (WriteFP)thread, (WriteFU)thread->serial,
226 NULL);
227 if(res != ResOK)
228 return res;
229
230 return ResOK;
231}
232
233
234/* C. COPYRIGHT AND LICENSE
235 *
236 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
237 * All rights reserved. This is an open source license. Contact
238 * Ravenbrook for commercial licensing options.
239 *
240 * Redistribution and use in source and binary forms, with or without
241 * modification, are permitted provided that the following conditions are
242 * met:
243 *
244 * 1. Redistributions of source code must retain the above copyright
245 * notice, this list of conditions and the following disclaimer.
246 *
247 * 2. Redistributions in binary form must reproduce the above copyright
248 * notice, this list of conditions and the following disclaimer in the
249 * documentation and/or other materials provided with the distribution.
250 *
251 * 3. Redistributions in any form must be accompanied by information on how
252 * to obtain complete source code for this software and any accompanying
253 * software that uses this software. The source code must either be
254 * included in the distribution or be available for no more than the cost
255 * of distribution plus a nominal fee, and must be freely redistributable
256 * under reasonable conditions. For an executable file, complete source
257 * code means the source code for all modules it contains. It does not
258 * include source code for modules or files that typically accompany the
259 * major components of the operating system on which the executable file
260 * runs.
261 *
262 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
263 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
264 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
265 * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
266 * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
267 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
268 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
269 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
270 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
271 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
272 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273 */
diff --git a/mps/code/thw3.h b/mps/code/thw3.h
new file mode 100644
index 00000000000..78e57192236
--- /dev/null
+++ b/mps/code/thw3.h
@@ -0,0 +1,70 @@
1/* thw3.h: WIN32 THREAD MANAGER HEADER
2 *
3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5 *
6 * This is used in <code/thw3.c> and <code/thw3i3.c> and <code/thw3i6.c>
7 *
8 * .nt: uses Win32 specific stuff
9 * HANDLE
10 * DWORD
11 */
12
13#include "mpm.h"
14
15#if !defined(MPS_OS_W3) /* .nt */
16#error "Compiling thw3 when MPS_OS_W3 not defined."
17#endif
18
19#include "mpswin.h"
20
21typedef struct ThreadStruct { /* Win32 thread structure */
22 Sig sig; /* <design/sig/> */
23 Serial serial; /* from arena->threadSerial */
24 Arena arena; /* owning arena */
25 RingStruct arenaRing; /* threads attached to arena */
26 HANDLE handle; /* Handle of thread, see
27 * <code/thw3.c#thread.handle> */
28 DWORD id; /* Thread id of thread */
29} ThreadStruct;
30
31/* C. COPYRIGHT AND LICENSE
32 *
33 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
34 * All rights reserved. This is an open source license. Contact
35 * Ravenbrook for commercial licensing options.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions are
39 * met:
40 *
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 *
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
47 *
48 * 3. Redistributions in any form must be accompanied by information on how
49 * to obtain complete source code for this software and any accompanying
50 * software that uses this software. The source code must either be
51 * included in the distribution or be available for no more than the cost
52 * of distribution plus a nominal fee, and must be freely redistributable
53 * under reasonable conditions. For an executable file, complete source
54 * code means the source code for all modules it contains. It does not
55 * include source code for modules or files that typically accompany the
56 * major components of the operating system on which the executable file
57 * runs.
58 *
59 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
60 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
61 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
62 * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
63 * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
64 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
65 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
66 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
67 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
68 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
69 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70 */
diff --git a/mps/code/thw3i3.c b/mps/code/thw3i3.c
index 873f2b4643e..3e2e6ee1a5c 100644
--- a/mps/code/thw3i3.c
+++ b/mps/code/thw3i3.c
@@ -1,32 +1,20 @@
1/* thw3i3.c: WIN32 THREAD MANAGER 1/* thw3i3.c: WIN32 THREAD MANAGER x86
2 * 2 *
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. 4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5 * 5 *
6 * Implements thread registration, suspension, and stack 6 * Implements thread stack scanning. See <design/thread-manager/>.
7 * scanning. See <design/thread-manager/>.
8 * 7 *
9 * This supports the <code/th.h> 8 * This supports the <code/th.h> together with <code/thw3.c>
10 * 9 *
11 * .thread.id: The thread id is used to identify the current thread. 10 * .thread.id: The thread id is used to identify the current thread.
12 * .thread.handle: The thread handle needs the enough access to
13 * be able to suspend threads and to get their context. i.e.
14 * .thread.handle.susp-res: THREAD_SUSPEND_RESUME access
15 * .thread.handle.get-context: THREAD_GET_CONTEXT access
16 * An appropriate handle is created on registration.
17 * 11 *
18 * 12 *
19 * ASSUMPTIONS 13 * ASSUMPTIONS
20 * 14 *
21 * .error: some major errors are assumed not to happen. 15 * .error: some major errors are assumed not to happen.
22 * .error.close-handle: CloseHandle is assumed to succeed.
23 * 16 *
24 * Other errors are assumed to only happen in certain circumstances. 17 * Other errors are assumed to only happen in certain circumstances.
25 * .error.resume: ResumeThread is assumed to succeed unless the thread
26 * has been destroyed (in fact, perversely, it appears to succeeed even
27 * when the thread has been destroyed).
28 * .error.suspend: SuspendThread is assumed to succeed unless the thread
29 * has been destroyed.
30 * .error.get-context: GetThreadContext is assumed to succeed unless the 18 * .error.get-context: GetThreadContext is assumed to succeed unless the
31 * thread has been destroyed. 19 * thread has been destroyed.
32 * 20 *
@@ -53,13 +41,7 @@
53 * .nt: uses Win32 specific stuff 41 * .nt: uses Win32 specific stuff
54 * HANDLE 42 * HANDLE
55 * DWORD 43 * DWORD
56 * GetCurrentProcess
57 * DuplicateHandle
58 * THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT
59 * GetCurrentThreadId 44 * GetCurrentThreadId
60 * CloseHandle
61 * SuspendThread
62 * ResumeThread
63 * CONTEXT 45 * CONTEXT
64 * CONTEXT_CONTROL | CONTEXT_INTEGER 46 * CONTEXT_CONTROL | CONTEXT_INTEGER
65 * GetThreadContext 47 * GetThreadContext
@@ -75,175 +57,16 @@
75#include "mpm.h" 57#include "mpm.h"
76 58
77#if !defined(MPS_OS_W3) || !defined(MPS_ARCH_I3) /* .i3 .nt */ 59#if !defined(MPS_OS_W3) || !defined(MPS_ARCH_I3) /* .i3 .nt */
78#error "Compiling thnti3 when MPS_OS_W3 or MPS_ARCH_I3 not defined." 60#error "Compiling thw3i3 when MPS_OS_W3 or MPS_ARCH_I3 not defined."
79#endif 61#endif
80 62
63#include "thw3.h"
64
81#include "mpswin.h" 65#include "mpswin.h"
82 66
83SRCID(thw3i3, "$Id$"); 67SRCID(thw3i3, "$Id$");
84 68
85 69
86typedef struct ThreadStruct { /* Win32 thread structure */
87 Sig sig; /* <design/sig/> */
88 Serial serial; /* from arena->threadSerial */
89 Arena arena; /* owning arena */
90 RingStruct arenaRing; /* threads attached to arena */
91 HANDLE handle; /* Handle of thread, see
92 * <code/thnti3.c#thread.handle> */
93 DWORD id; /* Thread id of thread */
94} ThreadStruct;
95
96
97Bool ThreadCheck(Thread thread)
98{
99 CHECKS(Thread, thread);
100 CHECKU(Arena, thread->arena);
101 CHECKL(thread->serial < thread->arena->threadSerial);
102 CHECKL(RingCheck(&thread->arenaRing));
103 return TRUE;
104}
105
106
107Bool ThreadCheckSimple(Thread thread)
108{
109 CHECKS(Thread, thread);
110 return TRUE;
111}
112
113
114Res ThreadRegister(Thread *threadReturn, Arena arena)
115{
116 Res res;
117 Thread thread;
118 HANDLE procHandle;
119 BOOL b;
120 void *p;
121
122 AVER(threadReturn != NULL);
123 AVERT(Arena, arena);
124
125 res = ControlAlloc(&p, arena, sizeof(ThreadStruct),
126 /* withReservoirPermit */ FALSE);
127 if(res != ResOK)
128 return res;
129 thread = (Thread)p; /* avoid pun */
130
131 /* Duplicate handle gives us a new handle with updated privileges.
132 * .thread.handle describes the ones needed.
133 */
134 procHandle = GetCurrentProcess();
135
136 b = DuplicateHandle(procHandle, GetCurrentThread(), procHandle,
137 &thread->handle,
138 THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT,
139 FALSE, 0);
140 if(!b)
141 return ResRESOURCE;
142
143 thread->id = GetCurrentThreadId();
144
145 RingInit(&thread->arenaRing);
146
147 thread->sig = ThreadSig;
148 thread->serial = arena->threadSerial;
149 ++arena->threadSerial;
150 thread->arena = arena;
151
152 AVERT(Thread, thread);
153
154 RingAppend(ArenaThreadRing(arena), &thread->arenaRing);
155
156 *threadReturn = thread;
157 return ResOK;
158}
159
160void ThreadDeregister(Thread thread, Arena arena)
161{
162 Bool b;
163
164 AVERT(Thread, thread);
165 AVERT(Arena, arena);
166
167 RingRemove(&thread->arenaRing);
168
169 thread->sig = SigInvalid;
170
171 RingFinish(&thread->arenaRing);
172
173 b = CloseHandle(thread->handle);
174 AVER(b); /* .error.close-handle */
175
176 ControlFree(arena, thread, sizeof(ThreadStruct));
177}
178
179
180/* Map over threads on ring calling f on each one except the
181 * current thread.
182 */
183static void mapThreadRing(Ring ring, void (*f)(Thread thread))
184{
185 Ring node;
186 DWORD id;
187
188 id = GetCurrentThreadId();
189 node = RingNext(ring);
190 while(node != ring) {
191 Ring next = RingNext(node);
192 Thread thread;
193
194 thread = RING_ELT(Thread, arenaRing, node);
195 AVERT(Thread, thread);
196 if(id != thread->id) /* .thread.id */
197 (*f)(thread);
198
199 node = next;
200 }
201}
202
203static void suspend(Thread thread)
204{
205 /* .thread.handle.susp-res */
206 /* .error.suspend */
207 /* In the error case (SuspendThread returning 0xFFFFFFFF), we */
208 /* assume the thread has been destroyed (as part of process shutdown). */
209 /* In which case we simply continue. */
210 /* [GetLastError appears to return 5 when SuspendThread is called */
211 /* on a destroyed thread, but I'm not sufficiently confident of this */
212 /* to check -- drj 1998-04-09] */
213 (void)SuspendThread(thread->handle);
214}
215
216void ThreadRingSuspend(Ring ring)
217{
218 mapThreadRing(ring, suspend);
219}
220
221static void resume(Thread thread)
222{
223 /* .thread.handle.susp-res */
224 /* .error.resume */
225 /* In the error case (ResumeThread returning 0xFFFFFFFF), we */
226 /* assume the thread has been destroyed (as part of process shutdown). */
227 /* In which case we simply continue. */
228 (void)ResumeThread(thread->handle);
229}
230
231void ThreadRingResume(Ring ring)
232{
233 mapThreadRing(ring, resume);
234}
235
236
237Thread ThreadRingThread(Ring threadRing)
238{
239 Thread thread;
240 AVERT(Ring, threadRing);
241 thread = RING_ELT(Thread, arenaRing, threadRing);
242 AVERT(Thread, thread);
243 return thread;
244}
245
246
247Res ThreadScan(ScanState ss, Thread thread, void *stackBot) 70Res ThreadScan(ScanState ss, Thread thread, void *stackBot)
248{ 71{
249 DWORD id; 72 DWORD id;
@@ -303,33 +126,6 @@ Res ThreadScan(ScanState ss, Thread thread, void *stackBot)
303 return ResOK; 126 return ResOK;
304} 127}
305 128
306/* Must be thread-safe. See <design/interface-c/#thread-safety>. */
307Arena ThreadArena(Thread thread)
308{
309 /* Can't AVER thread as that would not be thread-safe */
310 /* AVERT(Thread, thread); */
311 return thread->arena;
312}
313
314Res ThreadDescribe(Thread thread, mps_lib_FILE *stream)
315{
316 Res res;
317
318 res = WriteF(stream,
319 "Thread $P ($U) {\n", (WriteFP)thread, (WriteFU)thread->serial,
320 " arena $P ($U)\n",
321 (WriteFP)thread->arena, (WriteFU)thread->arena->serial,
322 " handle $W\n", (WriteFW)thread->handle,
323 " id $U\n", (WriteFU)thread->id,
324 "} Thread $P ($U)\n", (WriteFP)thread, (WriteFU)thread->serial,
325 NULL);
326 if(res != ResOK)
327 return res;
328
329 return ResOK;
330}
331
332
333/* C. COPYRIGHT AND LICENSE 129/* C. COPYRIGHT AND LICENSE
334 * 130 *
335 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>. 131 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
diff --git a/mps/code/thw3i6.c b/mps/code/thw3i6.c
new file mode 100644
index 00000000000..86e5f6edc8f
--- /dev/null
+++ b/mps/code/thw3i6.c
@@ -0,0 +1,168 @@
1/* thw3i3.c: WIN32 THREAD MANAGER x86
2 *
3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5 *
6 * Implements thread stack scanning. See <design/thread-manager/>.
7 *
8 * This supports the <code/th.h> together with <code/thw3.c>
9 *
10 * .thread.id: The thread id is used to identify the current thread.
11 *
12 *
13 * ASSUMPTIONS
14 *
15 * .error: some major errors are assumed not to happen.
16 *
17 * Other errors are assumed to only happen in certain circumstances.
18 * .error.get-context: GetThreadContext is assumed to succeed unless the
19 * thread has been destroyed.
20 *
21 * .stack.full-descend: assumes full descending stack.
22 * i.e. stack pointer points to the last allocated location;
23 * stack grows downwards.
24 *
25 * .stack.below-bottom: it's legal for the stack pointer to be at a
26 * higher address than the registered bottom of stack. This might
27 * happen if the stack of another thread doesn't contain any frames
28 * belonging to the client language. In this case, the stack should
29 * not be scanned.
30 *
31 * .stack.align: assume roots on the stack are always word-aligned,
32 * but don't assume that the stack pointer is necessarily
33 * word-aligned at the time of reading the context of another thread.
34 *
35 * .i6: assumes MPS_ARCH_I6
36 * .i6.sp: The sp in the context is Rsp
37 * .i6.context: Rsp is in control context so .context.sp holds
38 * The root registers are Rdi, Rsi, Rbx, Rbp, Rdx, Rcx, Rax, R8 - R15
39 * these are given by CONTEXT_INTEGER, so .context.regroots holds.
40 *
41 * .nt: uses Win32 specific stuff
42 * HANDLE
43 * DWORD
44 * GetCurrentThreadId
45 * CONTEXT
46 * CONTEXT_CONTROL | CONTEXT_INTEGER
47 * GetThreadContext
48 *
49 * .context: ContextFlags determine what is recorded by
50 * GetThreadContext. This should be set to whichever bits of the
51 * context that need to be recorded. This should include:
52 * .context.sp: sp assumed to be recorded by CONTEXT_CONTROL.
53 * .context.regroots: assumed to be recorded by CONTEXT_INTEGER.
54 * see winnt.h for description of CONTEXT and ContextFlags.
55 */
56
57#include "mpm.h"
58
59#if !defined(MPS_OS_W3) || !defined(MPS_ARCH_I6) /* .i6 .nt */
60#error "Compiling thw3i6 when MPS_OS_W3 or MPS_ARCH_I6 not defined."
61#endif
62
63#include "thw3.h"
64
65#include "mpswin.h"
66
67SRCID(thw3i6, "$Id$");
68
69
70Res ThreadScan(ScanState ss, Thread thread, void *stackBot)
71{
72 DWORD id;
73 Res res;
74
75 id = GetCurrentThreadId();
76
77 if(id != thread->id) { /* .thread.id */
78 CONTEXT context;
79 BOOL success;
80 Addr *stackBase, *stackLimit, stackPtr;
81
82 /* scan stack and register roots in other threads */
83
84 /* This dumps the relevent registers into the context */
85 /* .context.flags */
86 context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
87 /* .thread.handle.get-context */
88 success = GetThreadContext(thread->handle, &context);
89 if(!success) {
90 /* .error.get-context */
91 /* We assume that the thread must have been destroyed. */
92 /* We ignore the situation by returning immediately. */
93 return ResOK;
94 }
95
96 stackPtr = (Addr)context.Rsp; /* .i6.sp */
97 /* .stack.align */
98 stackBase = (Addr *)AddrAlignUp(stackPtr, sizeof(Addr));
99 stackLimit = (Addr *)stackBot;
100 if (stackBase >= stackLimit)
101 return ResOK; /* .stack.below-bottom */
102
103 /* scan stack inclusive of current sp and exclusive of
104 * stackBot (.stack.full-descend)
105 */
106 res = TraceScanAreaTagged(ss, stackBase, stackLimit);
107 if(res != ResOK)
108 return res;
109
110 /* (.context.regroots)
111 * This scans the root registers (.context.regroots). It also
112 * unecessarily scans the rest of the context. The optimisation
113 * to scan only relevent parts would be machine dependent.
114 */
115 res = TraceScanAreaTagged(ss, (Addr *)&context,
116 (Addr *)((char *)&context + sizeof(CONTEXT)));
117 if(res != ResOK)
118 return res;
119
120 } else { /* scan this thread's stack */
121 res = StackScan(ss, stackBot);
122 if(res != ResOK)
123 return res;
124 }
125
126 return ResOK;
127}
128
129/* C. COPYRIGHT AND LICENSE
130 *
131 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
132 * All rights reserved. This is an open source license. Contact
133 * Ravenbrook for commercial licensing options.
134 *
135 * Redistribution and use in source and binary forms, with or without
136 * modification, are permitted provided that the following conditions are
137 * met:
138 *
139 * 1. Redistributions of source code must retain the above copyright
140 * notice, this list of conditions and the following disclaimer.
141 *
142 * 2. Redistributions in binary form must reproduce the above copyright
143 * notice, this list of conditions and the following disclaimer in the
144 * documentation and/or other materials provided with the distribution.
145 *
146 * 3. Redistributions in any form must be accompanied by information on how
147 * to obtain complete source code for this software and any accompanying
148 * software that uses this software. The source code must either be
149 * included in the distribution or be available for no more than the cost
150 * of distribution plus a nominal fee, and must be freely redistributable
151 * under reasonable conditions. For an executable file, complete source
152 * code means the source code for all modules it contains. It does not
153 * include source code for modules or files that typically accompany the
154 * major components of the operating system on which the executable file
155 * runs.
156 *
157 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
158 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
159 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
160 * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
161 * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
162 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
163 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
164 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
165 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
166 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
167 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
168 */
diff --git a/mps/code/trace.c b/mps/code/trace.c
index 0a7b73efa70..82b3047f1c7 100644
--- a/mps/code/trace.c
+++ b/mps/code/trace.c
@@ -1517,11 +1517,15 @@ static Res rootGrey(Root root, void *p)
1517} 1517}
1518 1518
1519 1519
1520static void TraceStartGenDesc_diag(GenDesc desc, int i) 1520static void TraceStartGenDesc_diag(GenDesc desc, Bool top, Index i)
1521{ 1521{
1522 Ring n, nn; 1522 Ring n, nn;
1523
1524#if !defined(DIAG_WITH_STREAM_AND_WRITEF)
1525 UNUSED(i);
1526#endif
1523 1527
1524 if(i < 0) { 1528 if(top) {
1525 DIAG_WRITEF(( DIAG_STREAM, 1529 DIAG_WRITEF(( DIAG_STREAM,
1526 " GenDesc [top]", 1530 " GenDesc [top]",
1527 NULL )); 1531 NULL ));
@@ -1538,7 +1542,8 @@ static void TraceStartGenDesc_diag(GenDesc desc, int i)
1538 RING_FOR(n, &desc->locusRing, nn) { 1542 RING_FOR(n, &desc->locusRing, nn) {
1539 DIAG_DECL( PoolGen gen = RING_ELT(PoolGen, genRing, n); ) 1543 DIAG_DECL( PoolGen gen = RING_ELT(PoolGen, genRing, n); )
1540 DIAG_WRITEF(( DIAG_STREAM, 1544 DIAG_WRITEF(( DIAG_STREAM,
1541 " PoolGen $U ($S)", (WriteFU)gen->nr, (WriteFS)gen->pool->class->name, 1545 " PoolGen $U ($S)",
1546 (WriteFU)gen->nr, (WriteFS)gen->pool->class->name,
1542 " totalSize $U", (WriteFU)gen->totalSize, 1547 " totalSize $U", (WriteFU)gen->totalSize,
1543 " newSize $U\n", (WriteFU)gen->newSizeAtCreate, 1548 " newSize $U\n", (WriteFU)gen->newSizeAtCreate,
1544 NULL )); 1549 NULL ));
@@ -1631,7 +1636,7 @@ void TraceStart(Trace trace, double mortality, double finishingTime)
1631 1636
1632 for(i = 0; i < chain->genCount; ++i) { 1637 for(i = 0; i < chain->genCount; ++i) {
1633 GenDesc desc = &chain->gens[i]; 1638 GenDesc desc = &chain->gens[i];
1634 TraceStartGenDesc_diag(desc, i); 1639 TraceStartGenDesc_diag(desc, FALSE, i);
1635 } 1640 }
1636 } 1641 }
1637 1642
@@ -1639,7 +1644,7 @@ void TraceStart(Trace trace, double mortality, double finishingTime)
1639 DIAG_WRITEF(( DIAG_STREAM, 1644 DIAG_WRITEF(( DIAG_STREAM,
1640 " topGen\n", 1645 " topGen\n",
1641 NULL )); 1646 NULL ));
1642 TraceStartGenDesc_diag(&arena->topGen, -1); 1647 TraceStartGenDesc_diag(&arena->topGen, TRUE, 0);
1643 } 1648 }
1644 1649
1645 DIAG_END( "TraceStart" ); 1650 DIAG_END( "TraceStart" );
diff --git a/mps/code/vmw3.c b/mps/code/vmw3.c
index ee33544793b..554209687d3 100644
--- a/mps/code/vmw3.c
+++ b/mps/code/vmw3.c
@@ -24,12 +24,6 @@
24 * a block of memory that occupies the last page in memory, so 24 * a block of memory that occupies the last page in memory, so
25 * that limit is representable and bigger than base. 25 * that limit is representable and bigger than base.
26 * 26 *
27 * .assume.dword-addr: We assume that the windows type DWORD and
28 * the MM type Addr are the same size.
29 *
30 * .assume.dword-align: We assume that the windows type DWORD and
31 * the MM type Align are assignment-compatible.
32 *
33 * .assume.lpvoid-addr: We assume that the windows type LPVOID and 27 * .assume.lpvoid-addr: We assume that the windows type LPVOID and
34 * the MM type Addr are assignment-compatible. 28 * the MM type Addr are assignment-compatible.
35 * 29 *
@@ -110,14 +104,14 @@ Res VMCreate(VM *vmReturn, Size size)
110 AVER(vmReturn != NULL); 104 AVER(vmReturn != NULL);
111 105
112 AVER(CHECKTYPE(LPVOID, Addr)); /* .assume.lpvoid-addr */ 106 AVER(CHECKTYPE(LPVOID, Addr)); /* .assume.lpvoid-addr */
113 AVER(sizeof(DWORD) == sizeof(Addr)); /* See .assume.dword-addr */ 107 AVER(CHECKTYPE(SIZE_T, Size));
114 AVER(CHECKTYPE(DWORD, Align)); /* See .assume.dword-align */
115 108
116 GetSystemInfo(&si); 109 GetSystemInfo(&si);
117 align = (Align)si.dwPageSize; 110 align = (Align)si.dwPageSize;
111 AVER((DWORD)align == si.dwPageSize); /* check it didn't truncate */
118 AVER(SizeIsP2(align)); /* see .assume.sysalign */ 112 AVER(SizeIsP2(align)); /* see .assume.sysalign */
119 size = SizeAlignUp(size, align); 113 size = SizeAlignUp(size, align);
120 if ((size == 0) || (size > (Size)(DWORD)-1)) 114 if ((size == 0) || (size > (Size)(SIZE_T)-1))
121 return ResRESOURCE; 115 return ResRESOURCE;
122 116
123 /* Allocate the vm descriptor. This is likely to be wasteful. */ 117 /* Allocate the vm descriptor. This is likely to be wasteful. */
@@ -151,7 +145,7 @@ Res VMCreate(VM *vmReturn, Size size)
151 return ResOK; 145 return ResOK;
152 146
153failReserve: 147failReserve:
154 b = VirtualFree((LPVOID)vm, (DWORD)0, MEM_RELEASE); 148 b = VirtualFree((LPVOID)vm, (SIZE_T)0, MEM_RELEASE);
155 AVER(b != 0); 149 AVER(b != 0);
156 return res; 150 return res;
157} 151}
@@ -171,10 +165,10 @@ void VMDestroy(VM vm)
171 * fail and it would be nice to have a dead sig there. */ 165 * fail and it would be nice to have a dead sig there. */
172 vm->sig = SigInvalid; 166 vm->sig = SigInvalid;
173 167
174 b = VirtualFree((LPVOID)vm->base, (DWORD)0, MEM_RELEASE); 168 b = VirtualFree((LPVOID)vm->base, (SIZE_T)0, MEM_RELEASE);
175 AVER(b != 0); 169 AVER(b != 0);
176 170
177 b = VirtualFree((LPVOID)vm, (DWORD)0, MEM_RELEASE); 171 b = VirtualFree((LPVOID)vm, (SIZE_T)0, MEM_RELEASE);
178 AVER(b != 0); 172 AVER(b != 0);
179 EVENT_P(VMDestroy, vm); 173 EVENT_P(VMDestroy, vm);
180} 174}
@@ -238,7 +232,7 @@ Res VMMap(VM vm, Addr base, Addr limit)
238 /* .improve.query-map: We could check that the pages we are about to 232 /* .improve.query-map: We could check that the pages we are about to
239 * map are unmapped using VirtualQuery. */ 233 * map are unmapped using VirtualQuery. */
240 234
241 b = VirtualAlloc((LPVOID)base, (DWORD)AddrOffset(base, limit), 235 b = VirtualAlloc((LPVOID)base, (SIZE_T)AddrOffset(base, limit),
242 MEM_COMMIT, PAGE_EXECUTE_READWRITE); 236 MEM_COMMIT, PAGE_EXECUTE_READWRITE);
243 if (b == NULL) 237 if (b == NULL)
244 return ResMEMORY; 238 return ResMEMORY;
@@ -268,7 +262,7 @@ void VMUnmap(VM vm, Addr base, Addr limit)
268 262
269 /* .improve.query-unmap: Could check that the pages we are about */ 263 /* .improve.query-unmap: Could check that the pages we are about */
270 /* to unmap are mapped, using VirtualQuery. */ 264 /* to unmap are mapped, using VirtualQuery. */
271 b = VirtualFree((LPVOID)base, (DWORD)AddrOffset(base, limit), MEM_DECOMMIT); 265 b = VirtualFree((LPVOID)base, (SIZE_T)AddrOffset(base, limit), MEM_DECOMMIT);
272 AVER(b != 0); /* .assume.free.success */ 266 AVER(b != 0); /* .assume.free.success */
273 vm->mapped -= AddrOffset(base, limit); 267 vm->mapped -= AddrOffset(base, limit);
274 268
diff --git a/mps/code/w3i3mv.nmk b/mps/code/w3i3mv.nmk
index 6a670938165..93ef97984f9 100644
--- a/mps/code/w3i3mv.nmk
+++ b/mps/code/w3i3mv.nmk
@@ -20,7 +20,7 @@ MPM = <ring> <mpm> <bt> <protocol> <boot> \
20 <root> <format> <buffer> <walk> <lockw3> \ 20 <root> <format> <buffer> <walk> <lockw3> \
21 <ref> <trace> <traceanc> <protw3> <proti3> <prmci3w3> \ 21 <ref> <trace> <traceanc> <protw3> <proti3> <prmci3w3> \
22 <shield> <vmw3> \ 22 <shield> <vmw3> \
23 <thw3i3> <ssw3i3> <mpsi> <mpsiw3> <ld> <spi3> \ 23 <thw3> <thw3i3> <ssw3i3> <mpsi> <mpsiw3> <ld> <spi3> \
24 <event> <seg> <sac> <poolmrg> <message> <dbgpool> <dbgpooli> \ 24 <event> <seg> <sac> <poolmrg> <message> <dbgpool> <dbgpooli> \
25 <abq> <meter> <cbs> <poolmv2> <splay> <diag> <version> 25 <abq> <meter> <cbs> <poolmv2> <splay> <diag> <version>
26SW = <ring> <mpm> <bt> <protocol> <boot> \ 26SW = <ring> <mpm> <bt> <protocol> <boot> \
@@ -29,7 +29,7 @@ SW = <ring> <mpm> <bt> <protocol> <boot> \
29 <root> <format> <buffer> <walk> \ 29 <root> <format> <buffer> <walk> \
30 <ref> <trace> <traceanc> <protsw> <prmcan> \ 30 <ref> <trace> <traceanc> <protsw> <prmcan> \
31 <shield> <vmw3> \ 31 <shield> <vmw3> \
32 <thw3i3> <ssan> <mpsi> <ld> \ 32 <thw3> <thw3i3> <ssan> <mpsi> <ld> \
33 <event> <seg> <sac> <poolmrg> <message> <mpsioan> \ 33 <event> <seg> <sac> <poolmrg> <message> <mpsioan> \
34 <poolams> <poolamsi> <dbgpool> <dbgpooli> \ 34 <poolams> <poolamsi> <dbgpool> <dbgpooli> \
35 <abq> <meter> <cbs> <poolmv2> <splay> <diag> <version> <poolmvff> 35 <abq> <meter> <cbs> <poolmv2> <splay> <diag> <version> <poolmvff>
diff --git a/mps/code/w3i6mv.nmk b/mps/code/w3i6mv.nmk
new file mode 100644
index 00000000000..f703ff2cc2c
--- /dev/null
+++ b/mps/code/w3i6mv.nmk
@@ -0,0 +1,363 @@
1# w3i6mv.nmk: WINDOWS (x64) NMAKE FILE
2#
3# $Id$
4# Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
5
6PFM = w3i6mv
7
8# @@@@ Can we remove this? RB 2012-03-26
9RAINBOWPATH = MSVISUAL\WIN32\I386
10DONGLELIB = $(RAINBOWPATH)\spromeps.lib
11
12# /Gs appears to be necessary to suppress stack checks. Stack checks
13# (if not suppressed) generate a dependency on the C library, __chkesp,
14# which causes the linker step to fail when building the DLL, mpsdy.dll.
15PFMDEFS = /DCONFIG_PF_STRING="w3i6mv" /DCONFIG_PF_W3I6MV \
16 /DWIN32 /D_WINDOWS /Gs /I$(RAINBOWPATH)
17MASM = ml64
18
19MPM = <ring> <mpm> <bt> <protocol> <boot> \
20 <arenavm> <arenacl> <locus> <arena> <global> <tract> <reserv> \
21 <pool> <poolabs> <poolmfs> <poolmv> \
22 <root> <format> <buffer> <walk> <lockw3> \
23 <ref> <trace> <traceanc> <protw3> <proti6> <prmci6w3> \
24 <shield> <vmw3> \
25 <thw3> <thw3i6> <ssw3i6> <mpsi> <mpsiw3> <ld> <span> \
26 <event> <seg> <sac> <poolmrg> <message> <dbgpool> <dbgpooli> \
27 <abq> <meter> <cbs> <poolmv2> <splay> <diag> <version>
28SW = <ring> <mpm> <bt> <protocol> <boot> \
29 <arenavm> <arenacl> <locus> <arena> <global> <tract> <reserv> \
30 <pool> <poolabs> <poolmfs> <poolmv> \
31 <root> <format> <buffer> <walk> \
32 <ref> <trace> <traceanc> <protsw> <prmcan> \
33 <shield> <vmw3> \
34 <thw3> <thw3i6> <ssan> <mpsi> <ld> \
35 <event> <seg> <sac> <poolmrg> <message> <mpsioan> \
36 <poolams> <poolamsi> <dbgpool> <dbgpooli> \
37 <abq> <meter> <cbs> <poolmv2> <splay> <diag> <version> <poolmvff>
38PLINTH = <mpsliban> <mpsioan>
39AMC = <poolamc>
40AMS = <poolams> <poolamsi>
41AWL = <poolawl>
42LO = <poollo>
43SNC = <poolsnc>
44DW = <fmtdy> <fmtno>
45FMTTEST = <fmthe> <fmtdy> <fmtno> <fmtdytst>
46POOLN = <pooln>
47TESTLIB = <testlib>
48
49
50!INCLUDE commpre.nmk
51
52
53# Source to object file mappings and CFLAGS amalgamation
54# %%VARIETY %%PART: Add new macros which expand to the files included
55# in the part for each variety
56# %%VARIETY: Add a CFLAGS macro which expands to the flags that that variety
57# should use when compiling C. And a LINKFLAGS macro which expands to the
58# flags that the variety should use when building executables. And a LIBFLAGS
59# macro which expands to the flags that the variety should use when building
60# libraries
61
62!IF "$(VARIETY)" == "he"
63CFLAGS=$(CFLAGSCOMMONPRE) $(CFHE) $(CFLAGSCOMMONPOST)
64LINKFLAGS=$(LINKFLAGSCOMMON) $(LFHE)
65LIBFLAGS=$(LIBFLAGSCOMMON) $(LIBFLAGSHE)
66MPMOBJ0 = $(MPM:<=w3i6mv\he\)
67MPMOBJ = $(MPMOBJ0:>=.obj)
68PLINTHOBJ0 = $(PLINTH:<=w3i6mv\he\)
69PLINTHOBJ = $(PLINTHOBJ0:>=.obj)
70SWOBJ0 = $(SW:<=w3i6mv\he\)
71SWOBJ = $(SWOBJ0:>=.obj)
72AMSOBJ0 = $(AMS:<=w3i6mv\he\)
73AMSOBJ = $(AMSOBJ0:>=.obj)
74AMCOBJ0 = $(AMC:<=w3i6mv\he\)
75AMCOBJ = $(AMCOBJ0:>=.obj)
76AWLOBJ0 = $(AWL:<=w3i6mv\he\)
77AWLOBJ = $(AWLOBJ0:>=.obj)
78LOOBJ0 = $(LO:<=w3i6mv\he\)
79LOOBJ = $(LOOBJ0:>=.obj)
80SNCOBJ0 = $(SNC:<=w3i6mv\he\)
81SNCOBJ = $(SNCOBJ0:>=.obj)
82DWOBJ0 = $(DW:<=w3i6mv\he\)
83DWOBJ = $(DWOBJ0:>=.obj)
84FMTTESTOBJ0 = $(FMTTEST:<=w3i6mv\he\)
85FMTTESTOBJ = $(FMTTESTOBJ0:>=.obj)
86POOLNOBJ0 = $(POOLN:<=w3i6mv\he\)
87POOLNOBJ = $(POOLNOBJ0:>=.obj)
88TESTLIBOBJ0 = $(TESTLIB:<=w3i6mv\he\)
89TESTLIBOBJ = $(TESTLIBOBJ0:>=.obj)
90
91!ELSEIF "$(VARIETY)" == "ce"
92CFLAGS=$(CFLAGSCOMMONPRE) $(CFCE) $(CFLAGSCOMMONPOST)
93LINKFLAGS=$(LINKFLAGSCOMMON) $(LFCE)
94LIBFLAGS=$(LIBFLAGSCOMMON) $(LIBFLAGSCE)
95MPMOBJ0 = $(MPM:<=w3i6mv\ce\)
96MPMOBJ = $(MPMOBJ0:>=.obj)
97PLINTHOBJ0 = $(PLINTH:<=w3i6mv\ce\)
98PLINTHOBJ = $(PLINTHOBJ0:>=.obj)
99SWOBJ0 = $(SW:<=w3i6mv\ce\)
100SWOBJ = $(SWOBJ0:>=.obj)
101AMSOBJ0 = $(AMS:<=w3i6mv\ce\)
102AMSOBJ = $(AMSOBJ0:>=.obj)
103AMCOBJ0 = $(AMC:<=w3i6mv\ce\)
104AMCOBJ = $(AMCOBJ0:>=.obj)
105AWLOBJ0 = $(AWL:<=w3i6mv\ce\)
106AWLOBJ = $(AWLOBJ0:>=.obj)
107LOOBJ0 = $(LO:<=w3i6mv\ce\)
108LOOBJ = $(LOOBJ0:>=.obj)
109SNCOBJ0 = $(SNC:<=w3i6mv\ce\)
110SNCOBJ = $(SNCOBJ0:>=.obj)
111DWOBJ0 = $(DW:<=w3i6mv\ce\)
112DWOBJ = $(DWOBJ0:>=.obj)
113FMTTESTOBJ0 = $(FMTTEST:<=w3i6mv\ce\)
114FMTTESTOBJ = $(FMTTESTOBJ0:>=.obj)
115POOLNOBJ0 = $(POOLN:<=w3i6mv\ce\)
116POOLNOBJ = $(POOLNOBJ0:>=.obj)
117TESTLIBOBJ0 = $(TESTLIB:<=w3i6mv\ce\)
118TESTLIBOBJ = $(TESTLIBOBJ0:>=.obj)
119
120!ELSEIF "$(VARIETY)" == "hi"
121CFLAGS=$(CFLAGSCOMMONPRE) $(CFHI) $(CFLAGSCOMMONPOST)
122LINKFLAGS=$(LINKFLAGSCOMMON) $(LFHI)
123LIBFLAGS=$(LIBFLAGSCOMMON) $(LIBFLAGSHI)
124MPMOBJ0 = $(MPM:<=w3i6mv\hi\)
125MPMOBJ = $(MPMOBJ0:>=.obj)
126PLINTHOBJ0 = $(PLINTH:<=w3i6mv\hi\)
127PLINTHOBJ = $(PLINTHOBJ0:>=.obj)
128SWOBJ0 = $(SW:<=w3i6mv\hi\)
129SWOBJ = $(SWOBJ0:>=.obj)
130AMSOBJ0 = $(AMS:<=w3i6mv\hi\)
131AMSOBJ = $(AMSOBJ0:>=.obj)
132AMCOBJ0 = $(AMC:<=w3i6mv\hi\)
133AMCOBJ = $(AMCOBJ0:>=.obj)
134AWLOBJ0 = $(AWL:<=w3i6mv\hi\)
135AWLOBJ = $(AWLOBJ0:>=.obj)
136LOOBJ0 = $(LO:<=w3i6mv\hi\)
137LOOBJ = $(LOOBJ0:>=.obj)
138SNCOBJ0 = $(SNC:<=w3i6mv\hi\)
139SNCOBJ = $(SNCOBJ0:>=.obj)
140DWOBJ0 = $(DW:<=w3i6mv\hi\)
141DWOBJ = $(DWOBJ0:>=.obj)
142FMTTESTOBJ0 = $(FMTTEST:<=w3i6mv\hi\)
143FMTTESTOBJ = $(FMTTESTOBJ0:>=.obj)
144POOLNOBJ0 = $(POOLN:<=w3i6mv\hi\)
145POOLNOBJ = $(POOLNOBJ0:>=.obj)
146TESTLIBOBJ0 = $(TESTLIB:<=w3i6mv\hi\)
147TESTLIBOBJ = $(TESTLIBOBJ0:>=.obj)
148
149!ELSEIF "$(VARIETY)" == "di"
150CFLAGS=$(CFLAGSCOMMONPRE) $(CFDI) $(CFLAGSCOMMONPOST)
151LINKFLAGS=$(LINKFLAGSCOMMON) $(LFDI)
152LIBFLAGS=$(LIBFLAGSCOMMON) $(LIBFLAGSDI)
153MPMOBJ0 = $(MPM:<=w3i6mv\di\)
154MPMOBJ = $(MPMOBJ0:>=.obj)
155PLINTHOBJ0 = $(PLINTH:<=w3i6mv\di\)
156PLINTHOBJ = $(PLINTHOBJ0:>=.obj)
157SWOBJ0 = $(SW:<=w3i6mv\di\)
158SWOBJ = $(SWOBJ0:>=.obj)
159AMSOBJ0 = $(AMS:<=w3i6mv\di\)
160AMSOBJ = $(AMSOBJ0:>=.obj)
161AMCOBJ0 = $(AMC:<=w3i6mv\di\)
162AMCOBJ = $(AMCOBJ0:>=.obj)
163AWLOBJ0 = $(AWL:<=w3i6mv\di\)
164AWLOBJ = $(AWLOBJ0:>=.obj)
165LOOBJ0 = $(LO:<=w3i6mv\di\)
166LOOBJ = $(LOOBJ0:>=.obj)
167SNCOBJ0 = $(SNC:<=w3i6mv\di\)
168SNCOBJ = $(SNCOBJ0:>=.obj)
169DWOBJ0 = $(DW:<=w3i6mv\di\)
170DWOBJ = $(DWOBJ0:>=.obj)
171FMTTESTOBJ0 = $(FMTTEST:<=w3i6mv\di\)
172FMTTESTOBJ = $(FMTTESTOBJ0:>=.obj)
173POOLNOBJ0 = $(POOLN:<=w3i6mv\di\)
174POOLNOBJ = $(POOLNOBJ0:>=.obj)
175TESTLIBOBJ0 = $(TESTLIB:<=w3i6mv\di\)
176TESTLIBOBJ = $(TESTLIBOBJ0:>=.obj)
177
178!ELSEIF "$(VARIETY)" == "ci"
179CFLAGS=$(CFLAGSCOMMONPRE) $(CFCI) $(CFLAGSCOMMONPOST)
180LINKFLAGS=$(LINKFLAGSCOMMON) $(LFCI)
181LIBFLAGS=$(LIBFLAGSCOMMON) $(LIBFLAGSCI)
182MPMOBJ0 = $(MPM:<=w3i6mv\ci\)
183MPMOBJ = $(MPMOBJ0:>=.obj)
184PLINTHOBJ0 = $(PLINTH:<=w3i6mv\ci\)
185PLINTHOBJ = $(PLINTHOBJ0:>=.obj)
186SWOBJ0 = $(SW:<=w3i6mv\ci\)
187SWOBJ = $(SWOBJ0:>=.obj)
188AMSOBJ0 = $(AMS:<=w3i6mv\ci\)
189AMSOBJ = $(AMSOBJ0:>=.obj)
190AMCOBJ0 = $(AMC:<=w3i6mv\ci\)
191AMCOBJ = $(AMCOBJ0:>=.obj)
192AWLOBJ0 = $(AWL:<=w3i6mv\ci\)
193AWLOBJ = $(AWLOBJ0:>=.obj)
194LOOBJ0 = $(LO:<=w3i6mv\ci\)
195LOOBJ = $(LOOBJ0:>=.obj)
196SNCOBJ0 = $(SNC:<=w3i6mv\ci\)
197SNCOBJ = $(SNCOBJ0:>=.obj)
198DWOBJ0 = $(DW:<=w3i6mv\ci\)
199DWOBJ = $(DWOBJ0:>=.obj)
200FMTTESTOBJ0 = $(FMTTEST:<=w3i6mv\ci\)
201FMTTESTOBJ = $(FMTTESTOBJ0:>=.obj)
202POOLNOBJ0 = $(POOLN:<=w3i6mv\ci\)
203POOLNOBJ = $(POOLNOBJ0:>=.obj)
204TESTLIBOBJ0 = $(TESTLIB:<=w3i6mv\ci\)
205TESTLIBOBJ = $(TESTLIBOBJ0:>=.obj)
206
207!ELSEIF "$(VARIETY)" == "ti"
208CFLAGS=$(CFLAGSCOMMONPRE) $(CFTI) $(CFLAGSCOMMONPOST)
209LINKFLAGS=$(LINKFLAGSCOMMON) $(LFTI)
210LIBFLAGS=$(LIBFLAGSCOMMON) $(LIBFLAGSTI)
211MPMOBJ0 = $(MPM:<=w3i6mv\ti\)
212MPMOBJ = $(MPMOBJ0:>=.obj)
213PLINTHOBJ0 = $(PLINTH:<=w3i6mv\ti\)
214PLINTHOBJ = $(PLINTHOBJ0:>=.obj)
215SWOBJ0 = $(SW:<=w3i6mv\ti\)
216SWOBJ = $(SWOBJ0:>=.obj)
217AMSOBJ0 = $(AMS:<=w3i6mv\ti\)
218AMSOBJ = $(AMSOBJ0:>=.obj)
219AMCOBJ0 = $(AMC:<=w3i6mv\ti\)
220AMCOBJ = $(AMCOBJ0:>=.obj)
221AWLOBJ0 = $(AWL:<=w3i6mv\ti\)
222AWLOBJ = $(AWLOBJ0:>=.obj)
223LOOBJ0 = $(LO:<=w3i6mv\ti\)
224LOOBJ = $(LOOBJ0:>=.obj)
225SNCOBJ0 = $(SNC:<=w3i6mv\ti\)
226SNCOBJ = $(SNCOBJ0:>=.obj)
227DWOBJ0 = $(DW:<=w3i6mv\ti\)
228DWOBJ = $(DWOBJ0:>=.obj)
229FMTTESTOBJ0 = $(FMTTEST:<=w3i6mv\ti\)
230FMTTESTOBJ = $(FMTTESTOBJ0:>=.obj)
231POOLNOBJ0 = $(POOLN:<=w3i6mv\ti\)
232POOLNOBJ = $(POOLNOBJ0:>=.obj)
233TESTLIBOBJ0 = $(TESTLIB:<=w3i6mv\ti\)
234TESTLIBOBJ = $(TESTLIBOBJ0:>=.obj)
235
236!ELSEIF "$(VARIETY)" == "wi"
237CFLAGS=$(CFLAGSCOMMONPRE) $(CFWI) $(CFLAGSCOMMONPOST)
238LINKFLAGS=$(LINKFLAGSCOMMON) $(LFWI)
239LIBFLAGS=$(LIBFLAGSCOMMON) $(LIBFLAGSWI)
240MPMOBJ0 = $(MPM:<=w3i6mv\wi\)
241MPMOBJ = $(MPMOBJ0:>=.obj)
242PLINTHOBJ0 = $(PLINTH:<=w3i6mv\wi\)
243PLINTHOBJ = $(PLINTHOBJ0:>=.obj)
244SWOBJ0 = $(SW:<=w3i6mv\wi\)
245SWOBJ = $(SWOBJ0:>=.obj)
246AMSOBJ0 = $(AMS:<=w3i6mv\wi\)
247AMSOBJ = $(AMSOBJ0:>=.obj)
248AMCOBJ0 = $(AMC:<=w3i6mv\wi\)
249AMCOBJ = $(AMCOBJ0:>=.obj)
250AWLOBJ0 = $(AWL:<=w3i6mv\wi\)
251AWLOBJ = $(AWLOBJ0:>=.obj)
252LOOBJ0 = $(LO:<=w3i6mv\wi\)
253LOOBJ = $(LOOBJ0:>=.obj)
254SNCOBJ0 = $(SNC:<=w3i6mv\wi\)
255SNCOBJ = $(SNCOBJ0:>=.obj)
256DWOBJ0 = $(DW:<=w3i6mv\wi\)
257DWOBJ = $(DWOBJ0:>=.obj)
258FMTTESTOBJ0 = $(FMTTEST:<=w3i6mv\wi\)
259FMTTESTOBJ = $(FMTTESTOBJ0:>=.obj)
260POOLNOBJ0 = $(POOLN:<=w3i6mv\wi\)
261POOLNOBJ = $(POOLNOBJ0:>=.obj)
262TESTLIBOBJ0 = $(TESTLIB:<=w3i6mv\wi\)
263TESTLIBOBJ = $(TESTLIBOBJ0:>=.obj)
264
265!ELSEIF "$(VARIETY)" == "we"
266CFLAGS=$(CFLAGSCOMMONPRE) $(CFWE) $(CFLAGSCOMMONPOST)
267LINKFLAGS=$(LINKFLAGSCOMMON) $(LFWE)
268LIBFLAGS=$(LIBFLAGSCOMMON) $(LIBFLAGSWE)
269MPMOBJ0 = $(MPM:<=w3i6mv\we\)
270MPMOBJ = $(MPMOBJ0:>=.obj)
271PLINTHOBJ0 = $(PLINTH:<=w3i6mv\we\)
272PLINTHOBJ = $(PLINTHOBJ0:>=.obj)
273SWOBJ0 = $(SW:<=w3i6mv\we\)
274SWOBJ = $(SWOBJ0:>=.obj)
275AMSOBJ0 = $(AMS:<=w3i6mv\we\)
276AMSOBJ = $(AMSOBJ0:>=.obj)
277AMCOBJ0 = $(AMC:<=w3i6mv\we\)
278AMCOBJ = $(AMCOBJ0:>=.obj)
279AWLOBJ0 = $(AWL:<=w3i6mv\we\)
280AWLOBJ = $(AWLOBJ0:>=.obj)
281LOOBJ0 = $(LO:<=w3i6mv\we\)
282LOOBJ = $(LOOBJ0:>=.obj)
283SNCOBJ0 = $(SNC:<=w3i6mv\we\)
284SNCOBJ = $(SNCOBJ0:>=.obj)
285DWOBJ0 = $(DW:<=w3i6mv\we\)
286DWOBJ = $(DWOBJ0:>=.obj)
287FMTTESTOBJ0 = $(FMTTEST:<=w3i6mv\we\)
288FMTTESTOBJ = $(FMTTESTOBJ0:>=.obj)
289POOLNOBJ0 = $(POOLN:<=w3i6mv\we\)
290POOLNOBJ = $(POOLNOBJ0:>=.obj)
291TESTLIBOBJ0 = $(TESTLIB:<=w3i6mv\we\)
292TESTLIBOBJ = $(TESTLIBOBJ0:>=.obj)
293
294#!ELSEIF "$(VARIETY)" == "cv"
295#CFLAGS=$(CFLAGSCOMMON) $(CFCV)
296#LINKFLAGS=$(LINKFLAGSCOMMON) $(LFCV)
297#LIBFLAGS=$(LIBFLAGSCOMMON) $(LIBFLAGSCV)
298#MPMOBJ0 = $(MPM:<=w3i6mv\cv\)
299#MPMOBJ = $(MPMOBJ0:>=.obj)
300#PLINTHOBJ0 = $(PLINTH:<=w3i6mv\cv\)
301#PLINTHOBJ = $(PLINTHOBJ0:>=.obj)
302#AMSOBJ0 = $(AMS:<=w3i6mv\cv\)
303#AMSOBJ = $(AMSOBJ0:>=.obj)
304#AMCOBJ0 = $(AMC:<=w3i6mv\cv\)
305#AMCOBJ = $(AMCOBJ0:>=.obj)
306#AWLOBJ0 = $(AWL:<=w3i6mv\cv\)
307#AWLOBJ = $(AWLOBJ0:>=.obj)
308#LOOBJ0 = $(LO:<=w3i6mv\cv\)
309#LOOBJ = $(LOOBJ0:>=.obj)
310#SNCOBJ0 = $(SNC:<=w3i6mv\cv\)
311#SNCOBJ = $(SNCOBJ0:>=.obj)
312#DWOBJ0 = $(DW:<=w3i6mv\cv\)
313#DWOBJ = $(DWOBJ0:>=.obj)
314#POOLNOBJ0 = $(POOLN:<=w3i6mv\cv\)
315#POOLNOBJ = $(POOLNOBJ0:>=.obj)
316#TESTLIBOBJ0 = $(TESTLIB:<=w3i6mv\cv\)
317#TESTLIBOBJ = $(TESTLIBOBJ0:>=.obj)
318
319!ENDIF
320
321
322!INCLUDE commpost.nmk
323
324
325# C. COPYRIGHT AND LICENSE
326#
327# Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
328# All rights reserved. This is an open source license. Contact
329# Ravenbrook for commercial licensing options.
330#
331# Redistribution and use in source and binary forms, with or without
332# modification, are permitted provided that the following conditions are
333# met:
334#
335# 1. Redistributions of source code must retain the above copyright
336# notice, this list of conditions and the following disclaimer.
337#
338# 2. Redistributions in binary form must reproduce the above copyright
339# notice, this list of conditions and the following disclaimer in the
340# documentation and/or other materials provided with the distribution.
341#
342# 3. Redistributions in any form must be accompanied by information on how
343# to obtain complete source code for this software and any accompanying
344# software that uses this software. The source code must either be
345# included in the distribution or be available for no more than the cost
346# of distribution plus a nominal fee, and must be freely redistributable
347# under reasonable conditions. For an executable file, complete source
348# code means the source code for all modules it contains. It does not
349# include source code for modules or files that typically accompany the
350# major components of the operating system on which the executable file
351# runs.
352#
353# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
354# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
355# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
356# PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
357# COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
358# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
359# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
360# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
361# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
362# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
363# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/mps/code/walkt0.c b/mps/code/walkt0.c
index 1764b3f9f10..4b2163d88ee 100644
--- a/mps/code/walkt0.c
+++ b/mps/code/walkt0.c
@@ -42,7 +42,7 @@ static mps_gen_param_s testChain[genCOUNT] = {
42}; 42};
43 43
44/* objNULL needs to be odd so that it's ignored in exactRoots. */ 44/* objNULL needs to be odd so that it's ignored in exactRoots. */
45#define objNULL ((mps_addr_t)0xDECEA5ED) 45#define objNULL ((mps_addr_t)MPS_WORD_CONST(0xDECEA5ED))
46 46
47static mps_ap_t ap; 47static mps_ap_t ap;
48static mps_addr_t exactRoots[exactRootsCOUNT]; 48static mps_addr_t exactRoots[exactRootsCOUNT];
diff --git a/mps/code/zcoll.c b/mps/code/zcoll.c
index 21b1ffbd07d..75ffe6f19f9 100644
--- a/mps/code/zcoll.c
+++ b/mps/code/zcoll.c
@@ -107,12 +107,12 @@ static ulongest_t cols(size_t bytes)
107 */ 107 */
108static void showStatsAscii(size_t notcon, size_t con, size_t live, size_t alimit) 108static void showStatsAscii(size_t notcon, size_t con, size_t live, size_t alimit)
109{ 109{
110 int n = cols(notcon); 110 ulongest_t n = cols(notcon);
111 int c = cols(notcon + con); 111 ulongest_t c = cols(notcon + con);
112 int l = cols(notcon + live); /* a fraction of con */ 112 ulongest_t l = cols(notcon + live); /* a fraction of con */
113 int a = cols(alimit); 113 ulongest_t a = cols(alimit);
114 int count; 114 ulongest_t count;
115 int i; 115 ulongest_t i;
116 116
117 /* if we can show alimit within 200 cols, do so */ 117 /* if we can show alimit within 200 cols, do so */
118 count = (a < 200) ? a + 1 : c; 118 count = (a < 200) ? a + 1 : c;
@@ -280,21 +280,21 @@ static void get(mps_arena_t arena)
280 * - how the mutator accesses objects (barrier hits). 280 * - how the mutator accesses objects (barrier hits).
281 */ 281 */
282 282
283enum { 283
284 CatalogRootIndex = 0, 284#define CatalogRootIndex 0
285 CatalogSig = 0x0000CA2A, /* CATAlog */ 285#define CatalogSig MPS_WORD_CONST(0x0000CA2A) /* CATAlog */
286 CatalogFix = 1, 286#define CatalogFix 1
287 CatalogVar = 10, 287#define CatalogVar 10
288 PageSig = 0x0000BA9E, /* PAGE */ 288#define PageSig MPS_WORD_CONST(0x0000BA9E) /* PAGE */
289 PageFix = 1, 289#define PageFix 1
290 PageVar = 100, 290#define PageVar 100
291 ArtSig = 0x0000A621, /* ARTIcle */ 291#define ArtSig MPS_WORD_CONST(0x0000A621) /* ARTIcle */
292 ArtFix = 1, 292#define ArtFix 1
293 ArtVar = 100, 293#define ArtVar 100
294 PolySig = 0x0000B071, /* POLYgon */ 294#define PolySig MPS_WORD_CONST(0x0000B071) /* POLYgon */
295 PolyFix = 1, 295#define PolyFix 1
296 PolyVar = 100 296#define PolyVar 100
297}; 297
298 298
299static void CatalogCheck(void) 299static void CatalogCheck(void)
300{ 300{
@@ -326,7 +326,7 @@ static void CatalogCheck(void)
326 if(w == DYLAN_INT(0)) 326 if(w == DYLAN_INT(0))
327 break; 327 break;
328 Art = (void *)w; 328 Art = (void *)w;
329 Insist(DYLAN_VECTOR_SLOT(Art, 0) = DYLAN_INT(ArtSig)); 329 Insist(DYLAN_VECTOR_SLOT(Art, 0) == DYLAN_INT(ArtSig));
330 Arts += 1; 330 Arts += 1;
331 331
332 for(k = 0; k < ArtVar; k += 1) { 332 for(k = 0; k < ArtVar; k += 1) {
@@ -335,7 +335,7 @@ static void CatalogCheck(void)
335 if(w == DYLAN_INT(0)) 335 if(w == DYLAN_INT(0))
336 break; 336 break;
337 Poly = (void *)w; 337 Poly = (void *)w;
338 Insist(DYLAN_VECTOR_SLOT(Poly, 0) = DYLAN_INT(PolySig)); 338 Insist(DYLAN_VECTOR_SLOT(Poly, 0) == DYLAN_INT(PolySig));
339 Polys += 1; 339 Polys += 1;
340 } 340 }
341 } 341 }