forked from cisco/ChezScheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMf-base
447 lines (373 loc) · 16 KB
/
Mf-base
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# Mf-base
# Copyright 1984-2016 Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Assumes recursive makes inherit command-line settings as in GNU make
# Running "make" or "make all" in this directory runs the mats (test
# programs) and produces a report of bugs and errors. Unless you make
# changes to the mats or to the system, the report file report-$(conf)
# (where $(conf) is set below)
# If an error or bug report occurs, refer to the offending ".mo" file
# produced by the mats and mentioned in the bug or error report to
# determine what failed.
# Running "make allx" runs a set of mats with various settings.
# "make bullyx" runs a different, more stressful set.
# Running make with the argument "clean" removes the .so files, .mo
# files, report files, and temporary files generated by the mats.
# The variables below may be changed to affect how the mats are run.
# For example, "make o=2 cp0=t ctb=8192" causes the mats to be run at
# optimize level 2 with cp0 enabled and collect-trip-bytes set to 8192.
# Scheme is the scheme executable to test, and SCHEMEHEAPDIRS tells
# it where to find its boot files
Scheme = ../bin/$m/scheme
export SCHEMEHEAPDIRS=.:../boot/%m
# Include is the directory holding scheme.h.
Include = ../boot/$m
# patchfile is the name of a patch to be loaded while running the mats.
patchfile =
# o is the optimize level at which the mats should be run.
o = 0
# p determines whether profiling is enabled: f for false, t for true.
defaultp = f
p = $(defaultp)
# pdhtml determines whether profile-dump-html is called at end of a run: f for false, t for true.
# NB: beware of lost profile information due to mats that call profile-clear
defaultpdhtml = f
pdhtml = $(defaultpdhtml)
# cp0 determines whether cp0 is run: f for no, t for yes
defaultcp0 = f
cp0 = $(defaultcp0)
# eval is the evaluator to use.
defaulteval = compile
eval = $(defaulteval)
# ctb is the value to which collect-trip-bytes is set.
defaultctb = (collect-trip-bytes)
ctb = $(defaultctb)
# cgr is the value to which collect-generation-radix is set.
defaultcgr = (collect-generation-radix)
cgr = $(defaultcgr)
# cmg is the value to which collect-maximum-generation is set.
defaultcmg = (collect-maximum-generation)
cmg = $(defaultcmg)
# rmg is the value to which release-minimum-generation is set.
defaultrmg = (release-minimum-generation)
rmg = $(defaultrmg)
# cis defines the value to which compile-interpret-simple is set: f for
# #f, t for #t
defaultcis = f
cis = $(defaultcis)
# spi defines the value to which suppress-primitive-inlining is set:
# f for #f, t for #t
defaultspi = f
spi = $(defaultspi)
# ehc defines the value to which $enable-check-heap is set:
# f for #f, t for #t
defaultehc = f
ehc = $(defaultehc)
# eoc determines whether object counts are enabled
defaulteoc = t
eoc = $(defaulteoc)
# set of mats to run
mats = primvars 3 4 5_1 5_2 5_3 5_4 5_5 bytevector thread\
misc cp0 5_6 5_7 5_8 6 io format 7 record hash enum 8 fx fl cfl foreign\
ftype unix windows examples ieee date exceptions oop
Examples = ../examples
MAKEFLAGS += --no-print-directory
conf = $(eval)-$o-$(spi)-$(cp0)-$(cis)
objdir=output-$(conf)
objname = $(mats:%=%.mo)
obj = $(objname:%=$(objdir)/%)
src = $(mats:%=%.ms)
# prettysrc is src to use for pretty-print test; we leave out mat files
# with cycles, e.g., primvars.ms, misc.ms, 4.ms, 5_1.ms, hash.ms
prettysrc = 3.ms 5_3.ms 5_4.ms 5_5.ms bytevector.ms\
thread.ms 5_6.ms 5_7.ms 5_8.ms 6.ms io.ms format.ms 7.ms record.ms enum.ms 8.ms\
fx.ms fl.ms cfl.ms foreign.ms unix.ms windows.ms examples.ms ieee.ms date.ms\
exceptions.ms
$(objdir)/%.mo : %.ms mat.so
echo '(optimize-level $o)'\
'(#%$$suppress-primitive-inlining #${spi})'\
'(#%$$enable-check-heap #${ehc})'\
'(compile-profile #$p)'\
'(collect-trip-bytes ${ctb})'\
'(collect-generation-radix ${cgr})'\
'(collect-maximum-generation ${cmg})'\
'(enable-object-counts #${eoc})'\
'(compile-interpret-simple #${cis})'\
'(set! *examples-directory* "${Examples}")'\
'(enable-cp0 #${cp0})'\
'(set! *scheme* "${Scheme}")'\
'(current-eval ${eval})'\
'(time ((mat-file "$(objdir)") "$*"))'\
'(unless (= (#%$$check-heap-errors) 0)'\
' (fprintf (console-error-port) "check heap detected errors---grep standard output for !!!\n")'\
' (abort))'\
| ${Scheme} -q mat.so ${patchfile}
# same as above except puts the .mo file in .
%.mo : %.ms mat.so
echo '(optimize-level $o)'\
'(#%$$suppress-primitive-inlining #${spi})'\
'(#%$$enable-check-heap #${ehc})'\
'(compile-profile #$p)'\
'(collect-trip-bytes ${ctb})'\
'(collect-generation-radix ${cgr})'\
'(collect-maximum-generation ${cmg})'\
'(enable-object-counts #${eoc})'\
'(compile-interpret-simple #${cis})'\
'(set! *examples-directory* "${Examples}")'\
'(enable-cp0 #${cp0})'\
'(set! *scheme* "${Scheme}")'\
'(current-eval ${eval})'\
'(time ((mat-file ".") "$*"))'\
'(parameterize ([source-directories (quote ("." "../s"))]) (when #${pdhtml} (profile-dump-html)))'\
'(unless (= (#%$$check-heap-errors) 0)'\
' (fprintf (console-error-port) "check heap detected errors---grep standard output for !!!\n")'\
' (abort))'\
| ${Scheme} -q mat.so ${patchfile}
%.so : %.ss
echo '(reset-handler abort) (time (compile-file "$*"))' | ${Scheme} -q ${patchfile}
report: report-$(conf)
experr: experr-$(conf)
report-$(conf): errors-$(conf)
$(MAKE) doreport
doreport: experr-$(conf)
rm -f report-$(conf)
-diff experr-$(conf) errors-$(conf) > report-$(conf) 2>&1
maybe-doreport:
-if [ -f errors-$(conf) ] ; then\
$(MAKE) doreport ;\
fi
errors-$(conf): ${obj}
$(MAKE) doerrors
doerrors:
rm -f errors-$(conf)
ifdef MSDOS
-(cd $(objdir); grep '^Error' $(objname)) | dos2unix > errors-$(conf)
-(cd $(objdir); grep '^Bug' $(objname)) | dos2unix >> errors-$(conf)
-(cd $(objdir); grep '^Warning' $(objname)) | dos2unix >> errors-$(conf)
-(cd $(objdir); grep '^Expected' $(objname)) | dos2unix\
>> errors-$(conf)
else
-(cd $(objdir); grep '^Error' $(objname)) > errors-$(conf)
-(cd $(objdir); grep '^Bug' $(objname)) >> errors-$(conf)
-(cd $(objdir); grep '^Warning' $(objname)) >> errors-$(conf)
-(cd $(objdir); grep '^Expected' $(objname))\
>> errors-$(conf)
endif
fastreport:
$(MAKE) doerrors
$(MAKE) doreport
allx: prettyclean
$(MAKE) allxhelp o=0
$(MAKE) allxhelp o=3
$(MAKE) allxhelp o=0 cp0=t
$(MAKE) allxhelp o=3 cp0=t
$(MAKE) allxhelp o=0 spi=t rmg=2 p=t
$(MAKE) allxhelp o=3 spi=t rmg=2 p=t
$(MAKE) allxhelp o=0 eval=interpret
$(MAKE) allxhelp o=3 eval=interpret
$(MAKE) allxhelp o=0 eval=interpret cp0=t rmg=2
$(MAKE) allxhelp o=3 eval=interpret cp0=t rmg=2
$(MAKE) allxhelp o=0 eoc=f ehc=t
$(MAKE) allxhelp o=3 eval=interpret ehc=t rmg=2
just-reports:
for EVAL in compile interpret ; do\
for O in 0 2 3 ; do\
for SPI in f t ; do\
for CP0 in f t ; do\
for CIS in f t ; do\
$(MAKE) maybe-doreport eval=$$EVAL o=$$O spi=$$SPI cp0=$$CP0 cis=$$CIS ;\
done\
done\
done\
done\
done
bullyx:
-$(MAKE) bully o=0
-$(MAKE) bully o=3
bully:
-$(MAKE) allxhelpnotall spi=t cp0=f
-$(MAKE) allxhelp spi=f cp0=f ctb='(/ (collect-trip-bytes) 64)' ehc=t
-$(MAKE) allxhelp spi=t cp0=f cis=t cmg=1
-$(MAKE) allxhelp spi=f cp0=f cis=t cmg=6 ehc=t
-$(MAKE) allxhelp spi=t cp0=t ctb='(/ (collect-trip-bytes) 64)' cgr=6
-$(MAKE) allxhelp spi=t cp0=f p=t eoc=f ehc=t
-$(MAKE) allxhelp spi=f cp0=t p=t ehc=t
-$(MAKE) allxhelp eval=interpret spi=f cp0=f
-$(MAKE) allxhelp eval=interpret spi=f cp0=t
-$(MAKE) allxhelp eval=interpret spi=t cp0=f ctb='(/ (collect-trip-bytes) 64)' ehc=t
-$(MAKE) allxhelp eval=interpret spi=t cp0=t cgr=2 ehc=t p=t
allxhelp:
$(MAKE) doheader
-$(MAKE) all
$(MAKE) dosummary
doheader:
printf "%s" "-------- o=$o" >> summary
if [ "$(spi)" != "$(defaultspi)" ] ; then printf " spi=$(spi)" >> summary ; fi
if [ "$(ehc)" != "$(defaultehc)" ] ; then printf " ehc=$(ehc)" >> summary ; fi
if [ "$(cp0)" != "$(defaultcp0)" ] ; then printf " cp0=$(cp0)" >> summary ; fi
if [ "$(cis)" != "$(defaultcis)" ] ; then printf " cis=$(cis)" >> summary ; fi
if [ "$p" != "$(defaultp)" ] ; then printf " p=$p" >> summary ; fi
if [ "$(eval)" != "$(defaulteval)" ] ; then printf " eval=$(eval)" >> summary ; fi
if [ "$(ctb)" != "$(defaultctb)" ] ; then printf " ctb=$(ctb)" >> summary ; fi
if [ "$(cgr)" != "$(defaultcgr)" ] ; then printf " cgr=$(cgr)" >> summary ; fi
if [ "$(cmg)" != "$(defaultcmg)" ] ; then printf " cmg=$(cmg)" >> summary ; fi
if [ "$(eoc)" != "$(defaulteoc)" ] ; then printf " eoc=$(eoc)" >> summary ; fi
if [ "$(hdrmsg)" != "" ] ; then printf " $(hdrmsg)" >> summary ; fi
dosummary:
printf " --------\n" >> summary
if [ -f report-$(conf) ] ; then\
cat report-$(conf) >> summary ;\
else \
printf 'NO REPORT\n' >> summary ;\
fi
allxhelpnotall:
rm -f mat.so
$(MAKE) doheader hdrmsg="not all"
-$(MAKE)
$(MAKE) dosummary
all0: ; $(MAKE) all o=0
all1: ; $(MAKE) all o=1
all2: ; $(MAKE) all o=2
all3: ; $(MAKE) all o=3
all: makescript$o $(src) oop.ss ht.ss mat.so killme cat_flush ${fobj} m4test.in m4test.out prettytest.ss ftype.h freq.in freq.out ${patchfile} examples
${Scheme} --verbose -q mat.so ${patchfile} < script.all$o
$(MAKE) doerrors
$(MAKE) doreport
script.all$o: Mf-base
script.all$o makescript$o:
echo '(optimize-level $o)'\
'(#%$$suppress-primitive-inlining #${spi})'\
'(#%$$enable-check-heap #${ehc})'\
'(compile-profile #$p)'\
'(collect-trip-bytes ${ctb})'\
'(collect-generation-radix ${cgr})'\
'(collect-maximum-generation ${cmg})'\
'(enable-object-counts #${eoc})'\
'(compile-interpret-simple #${cis})'\
'(set! *examples-directory* "${Examples}")'\
'(enable-cp0 #${cp0})'\
'(set! *scheme* "${Scheme}")'\
'(current-eval ${eval})'\
'(time (for-each (mat-file "$(objdir)")'\
' (quote ($(mats:%="%")))))'\
'(parameterize ([source-directories (quote ("." "../s"))]) (when #${pdhtml} (profile-dump-html)))'\
'(unless (= (#%$$check-heap-errors) 0)'\
' (fprintf (console-error-port) "check heap detected errors---grep standard output for !!!\n")'\
' (abort))'\
> script.all$o
source:
$(MAKE) source0 o=0
$(MAKE) source2 o=2
$(MAKE) source3 o=3
source$o: ${src} mat.ss oop.ss ht.ss killme.c cat_flush.c ${fsrc} freq.in freq.out m4test.in m4test.out ${mdsrc} script.all$o prettytest.ss ftype.h
rootsrc = $(shell cd ../../mats; echo *)
${rootsrc}: ; ln -s ../../mats/$@ $@
prettytest.ss:
rm -f prettytest.ss
$(MAKE) ${prettysrc}
ifdef MSDOS
cat ${prettysrc} | unix2dos > prettytest.ss
else
cat ${prettysrc} > prettytest.ss
endif
bullyprettytest.ss: ${src}
(cd ../s; make source)
cat ${src} ../s/*.ss > prettytest.ss
mat.so: ${patchfile}
foreign.mo ${objdir}/foreign.mo: ${fobj}
thread.mo ${objdir}/thread.mo: ${fobj}
examples.mo ${objdir}/examples.mo: m4test.in m4test.out freq.in freq.out examples
6.mo ${objdir}/6.mo: prettytest.ss
io.mo ${objdir}/io.mo: prettytest.ss
unix.mo ${objdir}/unix.mo io.mo ${objdir}/io.mo 6.mo ${objdir}/6.mo: cat_flush killme
oop.mo ${objdir}/oop.mo: oop.ss
ftype.mo ${objdir}/ftype.mo: ftype.h
hash.mo ${objdir}/hash.mo: ht.ss
examples:
( cd ../examples && ${MAKE} Scheme=${Scheme} )
prettyclean:
rm -f *.o ${mdclean} *.so *.mo experr* errors* report* summary testfile* testscript\
${fobj} prettytest.ss killme cat_flush so_locations\
script.all? *.html experr*.rej experr*.orig
rm -rf testdir*
rm -rf output-*
clean: prettyclean
rm -f Make.out
### rules for generating various experr files
# everything starts with the root experr files with default
# settings for the various parameters
experr-compile-$o-f-f-f: root-experr-compile-$o-f-f-f
cp root-experr-compile-$o-f-f-f experr-compile-$o-f-f-f
root-experr: # don't list dependencies!
rm -f root-experr-compile-$o-f-f-f
cp errors-compile-$o-f-f-f root-experr-compile-$o-f-f-f
# derive spi=t experr files by patching spi=f experr files
# cp first in case patch is empty, since patch produces an empty output
# file rather than a copy of the input file if the patch file is empty
experr-compile-$o-t-f-f: experr-compile-$o-f-f-f patch-compile-$o-t-f-f
cp experr-compile-$o-f-f-f experr-compile-$o-t-f-f
-patch experr-compile-$o-t-f-f patch-compile-$o-t-f-f
# derive cp0=t experr files by patching cp0=f experr files
experr-compile-$o-$(spi)-t-f: experr-compile-$o-$(spi)-f-f patch-compile-$o-$(spi)-t-f
cp experr-compile-$o-$(spi)-f-f experr-compile-$o-$(spi)-t-f
-patch experr-compile-$o-$(spi)-t-f patch-compile-$o-$(spi)-t-f
# derive cis=t experr files by patching cis=f experr files
experr-compile-$o-$(spi)-$(cp0)-t: experr-compile-$o-$(spi)-$(cp0)-f patch-compile-$o-$(spi)-$(cp0)-t
cp experr-compile-$o-$(spi)-$(cp0)-f experr-compile-$o-$(spi)-$(cp0)-t
-patch experr-compile-$o-$(spi)-$(cp0)-t patch-compile-$o-$(spi)-$(cp0)-t
# derive eval=interpret experr files by patching eval=compile experr files
# (with cis=f, since compile-interpret-simple does not affect interpret)
experr-interpret-$o-$(spi)-$(cp0)-$(cis): experr-compile-$o-$(spi)-$(cp0)-f patch-interpret-$o-$(spi)-$(cp0)-f
cp experr-compile-$o-$(spi)-$(cp0)-f experr-interpret-$o-$(spi)-$(cp0)-$(cis)
-patch experr-interpret-$o-$(spi)-$(cp0)-$(cis) patch-interpret-$o-$(spi)-$(cp0)-f
### rebuilding patch files
patches:
for O in 0 2 3 ; do\
if [ -f errors-compile-$$O-f-f-f -a -e errors-compile-$$O-t-f-f ] ; then \
$(MAKE) xpatch-compile-$$O-t-f-f o=$$O spi=t ; \
fi ;\
for SPI in f t ; do\
if [ -f errors-compile-$$O-$$SPI-f-f -a -e errors-compile-$$O-$$SPI-t-f ] ; then \
$(MAKE) xpatch-compile-$$O-$$SPI-t-f o=$$O spi=$$SPI cp0=t ;\
fi ;\
for CP0 in f t ; do\
if [ -f errors-compile-$$O-$$SPI-$$CP0-f -a -e errors-compile-$$O-$$SPI-$$CP0-t ] ; then \
$(MAKE) xpatch-compile-$$O-$$SPI-$$CP0-t o=$$O spi=$$SPI cp0=$$CP0 cis=t ;\
fi ;\
if [ -f errors-compile-$$O-$$SPI-$$CP0-f -a -e errors-interpret-$$O-$$SPI-$$CP0-f ] ; then \
$(MAKE) xpatch-interpret-$$O-$$SPI-$$CP0-f o=$$O spi=$$SPI cp0=$$CP0 ;\
fi\
done\
done\
done
xpatch-compile-$o-t-f-f: # don't list dependencies!
rm -f patch-compile-$o-t-f-f
-diff --context errors-compile-$o-f-f-f\
errors-compile-$o-t-f-f\
> patch-compile-$o-t-f-f
xpatch-compile-$o-$(spi)-t-f: # don't list dependencies!
rm -f patch-compile-$o-$(spi)-t-f
-diff --context errors-compile-$o-$(spi)-f-f\
errors-compile-$o-$(spi)-t-f\
> patch-compile-$o-$(spi)-t-f
xpatch-compile-$o-$(spi)-$(cp0)-t: # don't list dependencies!
rm -f patch-compile-$o-$(spi)-$(cp0)-t
-diff --context errors-compile-$o-$(spi)-$(cp0)-f\
errors-compile-$o-$(spi)-$(cp0)-t\
> patch-compile-$o-$(spi)-$(cp0)-t
xpatch-interpret-$o-$(spi)-$(cp0)-f: # don't list dependencies!
rm -f patch-interpret-$o-$(spi)-$(cp0)-f
-diff --context errors-compile-$o-$(spi)-$(cp0)-f\
errors-interpret-$o-$(spi)-$(cp0)-f\
> patch-interpret-$o-$(spi)-$(cp0)-f