13 |
Description: |
Description: |
14 |
|
|
15 |
---------------------------------------------------------------------- |
---------------------------------------------------------------------- |
16 |
|
Name: Allen Leung |
17 |
|
Date: 2002/03/21 20:30:00 EST |
18 |
|
Tag: leunga-20020321-cfg |
19 |
|
Description: |
20 |
|
|
21 |
|
Fixed a potential problem in cfg edge splitting. |
22 |
|
|
23 |
|
---------------------------------------------------------------------- |
24 |
|
Name: Allen Leung |
25 |
|
Date: 2002/03/21 17:15:00 EST |
26 |
|
Tag: leunga-20020321-x86-fp-cfg |
27 |
|
Description: |
28 |
|
|
29 |
|
1. Recoded the buggy parts of x86-fp. |
30 |
|
|
31 |
|
a. All the block reordering code has been removed. |
32 |
|
We now depend on the block placement phases to do this work. |
33 |
|
|
34 |
|
b. Critical edge splitting code has been simplified and moved into the |
35 |
|
CFG modules, as where they belong. |
36 |
|
|
37 |
|
Both of these were quite buggy and complex. The code is now much, much |
38 |
|
simpler. |
39 |
|
|
40 |
|
2. X86 backend. |
41 |
|
|
42 |
|
a. Added instructions for 64-bit support. Instruction selection for |
43 |
|
64-bit has not been committed, however, since that |
44 |
|
requires changes to MLTREE which haven't been approved by |
45 |
|
Lal and John. |
46 |
|
|
47 |
|
b. Added support for FUCOMI and FUCOMIP when generating code for |
48 |
|
PentiumPro and above. We only generate these instructions in |
49 |
|
the fast-fp mode. |
50 |
|
|
51 |
|
c. Added cases for JP and JNP in X86FreqProps. |
52 |
|
|
53 |
|
3. CFG |
54 |
|
|
55 |
|
CFG now has a bunch of methods for edge splitting and merging. |
56 |
|
|
57 |
|
4. Machine description. |
58 |
|
|
59 |
|
John's simplification of MLTREE_BASIS.fcond broke a few machine |
60 |
|
description things: |
61 |
|
|
62 |
|
rtl-build.{sig,sml} and hppa.mdl fixed. |
63 |
|
|
64 |
|
NOTE: the machine description stuff in the repository is still broken. |
65 |
|
Again, I can't put my fixes in because that involves |
66 |
|
changes to MLTREE. |
67 |
|
|
68 |
|
---------------------------------------------------------------------- |
69 |
|
Name: Matthias Blume |
70 |
|
Date: 2002/03/20 15:55:00 EST |
71 |
|
Tag: blume-20020320-kmp |
72 |
|
Description: |
73 |
|
|
74 |
|
Implemented Knuth-Morris-Pratt string matching in PreString and used |
75 |
|
it for String.isSubstring, Substring.isSubstring, and |
76 |
|
Substring.position. |
77 |
|
|
78 |
|
(Might need some stress-testing. Simple examples worked fine.) |
79 |
|
|
80 |
|
---------------------------------------------------------------------- |
81 |
|
Name: Matthias Blume |
82 |
|
Date: 2002/03/19 16:37:00 EST |
83 |
|
Tag: blume-20020319-witnesses |
84 |
|
Description: |
85 |
|
|
86 |
|
Added a structure C.W and functions convert/Ptr.convert to ml-nlffi-lib. |
87 |
|
|
88 |
|
This implements a generic mechanism for changing constness qualifiers |
89 |
|
anywhere within big C types without resorting to outright "casts". |
90 |
|
(So far, functions such as C.rw/C.ro or C.Ptr.rw/C.Ptr.ro only let you |
91 |
|
modify the constness at the outermost level.) |
92 |
|
The implementation of "convert" is based on the idea of "witness" |
93 |
|
values -- values that are not used by the operation but whose types |
94 |
|
"testify" to their applicability. On the implementation side, "convert" |
95 |
|
is simply a projection (returning its second curried argument). With |
96 |
|
cross-module inlining, it should not result in any machine code being |
97 |
|
generated. |
98 |
|
|
99 |
|
---------------------------------------------------------------------- |
100 |
|
Name: Matthias Blume |
101 |
|
Date: 2002/03/15 16:40:00 EST |
102 |
|
Tag: blume-20020315-basis |
103 |
|
Description: |
104 |
|
|
105 |
|
Provided (preliminary?) implementations for |
106 |
|
|
107 |
|
{String,Substring}.{concatWith,isSuffix,isSubstring} |
108 |
|
|
109 |
|
and |
110 |
|
|
111 |
|
Substring.full |
112 |
|
|
113 |
|
Those are in the Basis spec but they were missing in SML/NJ. |
114 |
|
|
115 |
|
---------------------------------------------------------------------- |
116 |
|
Name: Matthias Blume |
117 |
|
Date: 2002/03/14 21:30:00 EST |
118 |
|
Tag: blume-20020314-controls |
119 |
|
Description: |
120 |
|
|
121 |
|
Controls: |
122 |
|
--------- |
123 |
|
|
124 |
|
1. Factored out the recently-added Controls : CONTROLS stuff and put |
125 |
|
it into its own library $/controls-lib.cm. The source tree for |
126 |
|
this is under src/smlnj-lib/Controls. |
127 |
|
|
128 |
|
2. Changed the names of types and functions in this interface, so they |
129 |
|
make a bit more "sense": |
130 |
|
|
131 |
|
module -> registry |
132 |
|
'a registry -> 'a group |
133 |
|
|
134 |
|
3. The interface now deals in ref cells only. The getter/setter interface |
135 |
|
is (mostly) gone. |
136 |
|
|
137 |
|
4. Added a function that lets one register an already-existing ref cell. |
138 |
|
|
139 |
|
5. Made the corresponding modifications to the rest of the code so that |
140 |
|
everything compiles again. |
141 |
|
|
142 |
|
6. Changed the implementation of Controls.MLRISC back to something closer |
143 |
|
to the original. In particular, this module (and therefore MLRISC) |
144 |
|
does not depend on Controls. There now is some link-time code in |
145 |
|
int-sys.sml that registers the MLRISC controls with the Controls |
146 |
|
module. |
147 |
|
|
148 |
|
CM: |
149 |
|
--- |
150 |
|
|
151 |
|
* One can now specify the lambda-split aggressiveness in init.cmi. |
152 |
|
|
153 |
|
---------------------------------------------------------------------- |
154 |
|
Name: Allen Leung |
155 |
|
Date: 2002/03/13 17:30:00 EST |
156 |
|
Tag: leunga-20020313-x86-fp-unary |
157 |
|
Description: |
158 |
|
|
159 |
|
Bug fix for: |
160 |
|
|
161 |
|
> leunga@weaselbane:~/Yale/tmp/sml-dist{21} bin/sml |
162 |
|
> Standard ML of New Jersey v110.39.1 [FLINT v1.5], March 08, 2002 |
163 |
|
> - fun f(x,(y,z)) = Real.~ y; |
164 |
|
> [autoloading] |
165 |
|
> [autoloading done] |
166 |
|
> fchsl (%eax), 184(%esp) |
167 |
|
> Error: MLRisc bug: X86MCEmitter.emitInstr |
168 |
|
> |
169 |
|
> uncaught exception Error |
170 |
|
> raised at: ../MLRISC/control/mlriscErrormsg.sml:16.14-16.19 |
171 |
|
|
172 |
|
The problem was that the code generator did not generate any fp registers |
173 |
|
in this case, and the ra didn't know that it needed to run the X86FP phase to |
174 |
|
translate the pseudo fp instruction. This only happened with unary fp |
175 |
|
operators in certain situations. |
176 |
|
|
177 |
|
---------------------------------------------------------------------- |
178 |
|
Name: Matthias Blume |
179 |
|
Date: 2002/03/13 14:00:00 EST |
180 |
|
Tag: blume-20020313-overload-etc |
181 |
|
Description: |
182 |
|
|
183 |
|
1. Added _overload as a synonym for overload for backward compatibility. |
184 |
|
(Control.overloadKW must be true for either version to be accepted.) |
185 |
|
|
186 |
|
2. Fixed bug in install script that caused more things to be installed |
187 |
|
than what was requested in config/targets. |
188 |
|
|
189 |
|
3. Made CM aware of the (_)overload construct so that autoloading |
190 |
|
works. |
191 |
|
|
192 |
|
---------------------------------------------------------------------- |
193 |
|
Name: Matthias Blume |
194 |
|
Date: 2002/03/12 22:03:00 EST |
195 |
|
Tag: blume-20020312-url |
196 |
|
Description: |
197 |
|
|
198 |
|
Forgot to update BOOT and srcarchiveurl. |
199 |
|
|
200 |
|
---------------------------------------------------------------------- |
201 |
|
Name: Matthias Blume |
202 |
|
Date: 2002/03/12 17:30:00 EST |
203 |
|
Tag: blume-20020312-version110392 |
204 |
|
Description: |
205 |
|
|
206 |
|
Yet another version number bump (because of small changes to the |
207 |
|
binfile format). Version number is now 110.39.2. NEW BOOTFILES! |
208 |
|
|
209 |
|
Changes: |
210 |
|
|
211 |
|
The new pid generation scheme described a few weeks ago was overly |
212 |
|
complicated. I implemented a new mechanism that is simpler and |
213 |
|
provides a bit more "stability": Once CM has seen a compilation |
214 |
|
unit, it keeps its identity constant (as long as you do not delete |
215 |
|
those crucial CM/GUID/* files). This means that when you change |
216 |
|
an interface, compile, then go back to the old interface, and |
217 |
|
compile again, you arrive at the original pid. |
218 |
|
|
219 |
|
There now also is a mechanism that instructs CM to use the plain |
220 |
|
environment hash as a module's pid (effectively making its GUID |
221 |
|
the empty string). For this, "noguid" must be specified as an |
222 |
|
option to the .sml file in question within its .cm file. |
223 |
|
This is most useful for code that is being generated by tools such |
224 |
|
as ml-nlffigen (because during development programmers tend to |
225 |
|
erase the tool's entire output directory tree including CM's cached |
226 |
|
GUIDs). "noguid" is somewhat dangerous (since it can be used to locally |
227 |
|
revert to the old, broken behavior of SML/NJ, but in specific cases |
228 |
|
where there is no danger of interface confusion, its use is ok |
229 |
|
(I think). |
230 |
|
|
231 |
|
ml-nlffigen by default generates "noguid" annotations. They can be |
232 |
|
turned off by specifying -guid in its command line. |
233 |
|
|
234 |
|
---------------------------------------------------------------------- |
235 |
|
Name: Lal George |
236 |
|
Date: 2002/03/12 12 14:42:36 EST |
237 |
|
Tag: george-20020312-frequency-computation |
238 |
|
Description: |
239 |
|
|
240 |
|
Integrated jump chaining and static block frequency into the |
241 |
|
compiler. More details and numbers later. |
242 |
|
|
243 |
|
---------------------------------------------------------------------- |
244 |
|
Name: Lal George |
245 |
|
Date: 2002/03/11 11 22:38:53 EST |
246 |
|
Tag: george-20020311-jump-chain-elim |
247 |
|
Description: |
248 |
|
|
249 |
|
Tested the jump chain elimination on all architectures (except the |
250 |
|
hppa). This is on by default right now and is profitable for the |
251 |
|
alpha and x86, however, it may not be profitable for the sparc and ppc |
252 |
|
when compiling the compiler. |
253 |
|
|
254 |
|
The gc test will typically jump to a label at the end of the cluster, |
255 |
|
where there is another jump to an external cluster containing the actual |
256 |
|
code to invoke gc. This is to allow factoring of common gc invocation |
257 |
|
sequences. That is to say, we generate: |
258 |
|
|
259 |
|
f: |
260 |
|
testgc |
261 |
|
ja L1 % jump if above to L1 |
262 |
|
|
263 |
|
L1: |
264 |
|
jmp L2 |
265 |
|
|
266 |
|
|
267 |
|
After jump chain elimination the 'ja L1' instructions is converted to |
268 |
|
'ja L2'. On the sparc and ppc, many of the 'ja L2' instructions may end |
269 |
|
up being implemented in their long form (if L2 is far away) using: |
270 |
|
|
271 |
|
jbe L3 % jump if below or equal to L3 |
272 |
|
jmp L2 |
273 |
|
L3: |
274 |
|
... |
275 |
|
|
276 |
|
|
277 |
|
For large compilation units L2 may be far away. |
278 |
|
|
279 |
|
|
280 |
|
---------------------------------------------------------------------- |
281 |
|
Name: Matthias Blume |
282 |
|
Date: 2002/03/11 13:30:00 EST |
283 |
|
Tag: blume-20020311-mltreeeval |
284 |
|
Description: |
285 |
|
|
286 |
|
A functor parameter was missing. |
287 |
|
|
288 |
|
---------------------------------------------------------------------- |
289 |
|
Name: Allen Leung |
290 |
|
Date: 2002/03/11 10:30:00 EST |
291 |
|
Tag: leunga-20020311-runtime-string0 |
292 |
|
Description: |
293 |
|
|
294 |
|
The representation of the empty string now points to a |
295 |
|
legal null terminated C string instead of unit. It is now possible |
296 |
|
to convert an ML string into C string with InlineT.CharVector.getData. |
297 |
|
This compiles into one single machine instruction. |
298 |
|
|
299 |
|
---------------------------------------------------------------------- |
300 |
|
Name: Allen Leung |
301 |
|
Date: 2002/03/10 23:55:00 EST |
302 |
|
Tag: leunga-20020310-x86-call |
303 |
|
Description: |
304 |
|
|
305 |
|
Added machine generation for CALL instruction (relative displacement mode) |
306 |
|
|
307 |
|
---------------------------------------------------------------------- |
308 |
|
Name: Matthias Blume |
309 |
|
Date: 2002/03/08 16:05:00 |
310 |
|
Tag: blume-20020308-entrypoints |
311 |
|
Description: |
312 |
|
|
313 |
|
Version number bumped to 110.39.1. NEW BOOTFILES! |
314 |
|
|
315 |
|
Entrypoints: non-zero offset into a code object where execution should begin. |
316 |
|
|
317 |
|
- Added the notion of an entrypoint to CodeObj. |
318 |
|
- Added reading/writing of entrypoint info to Binfile. |
319 |
|
- Made runtime system bootloader aware of entrypoints. |
320 |
|
- Use the address of the label of the first function given to mlriscGen |
321 |
|
as the entrypoint. This address is currently always 0, but it will |
322 |
|
not be 0 once we turn on block placement. |
323 |
|
- Removed the linkage cluster code (which was The Other Way(tm) of dealing |
324 |
|
with entry points) from mlriscGen. |
325 |
|
|
326 |
|
---------------------------------------------------------------------- |
327 |
|
Name: Allen Leung |
328 |
|
Date: 2002/03/07 20:45:00 EST |
329 |
|
Tag: leunga-20020307-x86-cmov |
330 |
|
Description: |
331 |
|
|
332 |
|
Bug fixes for CMOVcc on x86. |
333 |
|
|
334 |
|
1. Added machine code generation for CMOVcc |
335 |
|
2. CMOVcc is now generated in preference over SETcc on PentiumPro or above. |
336 |
|
3. CMOVcc cannot have an immediate operand as argument. |
337 |
|
|
338 |
|
---------------------------------------------------------------------- |
339 |
|
Name: Matthias Blume |
340 |
|
Date: 2002/03/07 16:15:00 EST |
341 |
|
Tag: blume-20020307-controls |
342 |
|
Description: |
343 |
|
|
344 |
|
This is a very large but mostly boring patch which makes (almost) |
345 |
|
every tuneable compiler knob (i.e., pretty much everything under |
346 |
|
Control.* plus a few other things) configurable via both the command |
347 |
|
line and environment variables in the style CM did its configuration |
348 |
|
until now. |
349 |
|
|
350 |
|
Try starting sml with '-h' (or, if you are brave, '-H') |
351 |
|
|
352 |
|
To this end, I added a structure Controls : CONTROLS to smlnj-lib.cm which |
353 |
|
implements the underlying generic mechanism. |
354 |
|
|
355 |
|
The interface to some of the existing such facilities has changed somewhat. |
356 |
|
For example, the MLRiscControl module now provides mkFoo instead of getFoo. |
357 |
|
(The getFoo interface is still there for backward-compatibility, but its |
358 |
|
use is deprecated.) |
359 |
|
|
360 |
|
The ml-build script passes -Cxxx=yyy command-line arguments through so |
361 |
|
that one can now twiddle the compiler settings when using this "batch" |
362 |
|
compiler. |
363 |
|
|
364 |
|
TODO items: |
365 |
|
|
366 |
|
We should go through and throw out all controls that are no longer |
367 |
|
connected to anything. Moreover, we should go through and provide |
368 |
|
meaningful (and correct!) documentation strings for those controls |
369 |
|
that still are connected. |
370 |
|
|
371 |
|
Currently, multiple calls to Controls.new are accepted (only the first |
372 |
|
has any effect). Eventually we should make sure that every control |
373 |
|
is being made (via Controls.new) exactly once. Future access can then |
374 |
|
be done using Controls.acc. |
375 |
|
|
376 |
|
Finally, it would probably be a good idea to use the getter-setter |
377 |
|
interface to controls rather than ref cells. For the time being, both |
378 |
|
styles are provided by the Controls module, but getter-setter pairs are |
379 |
|
better if thread-safety is of any concern because they can be wrapped. |
380 |
|
|
381 |
|
***************************************** |
382 |
|
|
383 |
|
One bug fix: The function blockPlacement in three of the MLRISC |
384 |
|
backpatch files used to be hard-wired to one of two possibilities at |
385 |
|
link time (according to the value of the placementFlag). But (I |
386 |
|
think) it should rather sense the flag every time. |
387 |
|
|
388 |
|
***************************************** |
389 |
|
|
390 |
|
Other assorted changes (by other people who did not supply a HISTORY entry): |
391 |
|
|
392 |
|
1. the cross-module inliner now works much better (Monnier) |
393 |
|
2. representation of weights, frequencies, and probabilities in MLRISC |
394 |
|
changed in preparation of using those for weighted block placement |
395 |
|
(Reppy, George) |
396 |
|
|
397 |
|
---------------------------------------------------------------------- |
398 |
|
Name: Lal George |
399 |
|
Date: 2002/03/07 14:44:24 EST 2002 |
400 |
|
Tag: george-20020307-weighted-block-placement |
401 |
|
|
402 |
|
Tested the weighted block placement optimization on all architectures |
403 |
|
(except the hppa) using AMPL to generate the block and edge frequencies. |
404 |
|
Changes were required in the machine properties to correctly |
405 |
|
categorize trap instructions. There is an MLRISC flag |
406 |
|
"weighted-block-placement" that can be used to enable weighted block |
407 |
|
placement, but this will be ineffective without block/edge |
408 |
|
frequencies (coming soon). |
409 |
|
|
410 |
|
|
411 |
|
---------------------------------------------------------------------- |
412 |
|
Name: Lal George |
413 |
|
Date: 2002/03/05 17:24:48 EST |
414 |
|
Tag: george-20020305-linkage-cluster |
415 |
|
|
416 |
|
In order to support the block placement optimization, a new cluster |
417 |
|
is generated as the very first cluster (called the linkage cluster). |
418 |
|
It contains a single jump to the 'real' entry point for the compilation |
419 |
|
unit. Block placement has no effect on the linkage cluster itself, but |
420 |
|
all the other clusters have full freedom in the manner in which they |
421 |
|
reorder blocks or functions. |
422 |
|
|
423 |
|
On the x86 the typical linkage code that is generated is: |
424 |
|
---------------------- |
425 |
|
.align 2 |
426 |
|
L0: |
427 |
|
addl $L1-L0, 72(%esp) |
428 |
|
jmp L1 |
429 |
|
|
430 |
|
|
431 |
|
.align 2 |
432 |
|
L1: |
433 |
|
---------------------- |
434 |
|
|
435 |
|
72(%esp) is the memory location for the stdlink register. This |
436 |
|
must contain the address of the CPS function being called. In the |
437 |
|
above example, it contains the address of L0; before |
438 |
|
calling L1 (the real entry point for the compilation unit), it |
439 |
|
must contain the address for L1, and hence |
440 |
|
|
441 |
|
addl $L1-L0, 72(%esp) |
442 |
|
|
443 |
|
I have tested this on all architectures except the hppa.The increase |
444 |
|
in code size is of course negligible |
445 |
|
|
446 |
|
---------------------------------------------------------------------- |
447 |
|
Name: Allen Leung |
448 |
|
Date: 2002/03/03 13:20:00 EST |
449 |
|
Tag: leunga-20020303-mlrisc-tools |
450 |
|
|
451 |
|
Added #[ ... ] expressions to mlrisc tools |
452 |
|
|
453 |
|
---------------------------------------------------------------------- |
454 |
|
Name: Matthias Blume |
455 |
|
Date: 2002/02/27 12:29:00 EST |
456 |
|
Tag: blume-20020227-cdebug |
457 |
|
Description: |
458 |
|
|
459 |
|
- made types in structure C and C_Debug to be equal |
460 |
|
- got rid of code duplication (c-int.sml vs. c-int-debug.sml) |
461 |
|
- there no longer is a C_Int_Debug (C_Debug is directly derived from C) |
462 |
|
|
463 |
|
---------------------------------------------------------------------- |
464 |
|
Name: Matthias Blume |
465 |
|
Date: 2002/02/26 12:00:00 EST |
466 |
|
Tag: blume-20020226-ffi |
467 |
|
Description: |
468 |
|
|
469 |
|
1. Fixed a minor bug in CM's "noweb" tool: |
470 |
|
If numbering is turned off, then truly don't number (i.e., do not |
471 |
|
supply the -L option to noweb). The previous behavior was to supply |
472 |
|
-L'' -- which caused noweb to use the "default" line numbering scheme. |
473 |
|
Thanks to Chris Richards for pointing this out (and supplying the fix). |
474 |
|
|
475 |
|
2. Once again, I reworked some aspects of the FFI: |
476 |
|
|
477 |
|
A. The incomplete/complete type business: |
478 |
|
|
479 |
|
- Signatures POINTER_TO_INCOMPLETE_TYPE and accompanying functors are |
480 |
|
gone! |
481 |
|
- ML types representing an incomplete type are now *equal* to |
482 |
|
ML types representing their corresponding complete types (just like |
483 |
|
in C). This is still safe because ml-nlffigen will not generate |
484 |
|
RTTI for incomplete types, nor will it generate functions that |
485 |
|
require access to such RTTI. But when ML code generated from both |
486 |
|
incomplete and complete versions of the C type meet, the ML types |
487 |
|
are trivially interoperable. |
488 |
|
|
489 |
|
NOTE: These changes restore the full generality of the translation |
490 |
|
(which was previously lost when I eliminated functorization)! |
491 |
|
|
492 |
|
B. Enum types: |
493 |
|
|
494 |
|
- Structure C now has a type constructor "enum" that is similar to |
495 |
|
how the "su" constructor works. However, "enum" is not a phantom |
496 |
|
type because each "T enum" has values (and is isomorphic to |
497 |
|
MLRep.Signed.int). |
498 |
|
- There are generic access operations for enum objects (using |
499 |
|
MLRep.Signed.int). |
500 |
|
- ml-nlffigen will generate a structure E_foo for each "enum foo". |
501 |
|
* The structure contains the definition of type "mlrep" (the ML-side |
502 |
|
representation type of the enum). Normally, mlrep is the same |
503 |
|
as "MLRep.Signed.int", but if ml-nlffigen was invoked with "-ec", |
504 |
|
then mlrep will be defined as a datatype -- thus facilitating |
505 |
|
pattern matching on mlrep values. |
506 |
|
("-ec" will be suppressed if there are duplicate values in an |
507 |
|
enumeration.) |
508 |
|
* Constructors ("-ec") or values (no "-ec") e_xxx of type mlrep |
509 |
|
will be generated for each C enum constant xxx. |
510 |
|
* Conversion functions m2i and i2m convert between mlrep and |
511 |
|
MLRep.Signed.int. (Without "-ec", these functions are identities.) |
512 |
|
* Coversion functions c and ml convert between mlrep and "tag enum". |
513 |
|
* Access functions (get/set) fetch and store mlrep values. |
514 |
|
- By default (unless ml-nlffigen was invoked with "-nocollect"), unnamed |
515 |
|
enumerations are merged into one single enumeration represented by |
516 |
|
structure E_'. |
517 |
|
|
518 |
|
---------------------------------------------------------------------- |
519 |
|
Name: Allen Leung |
520 |
|
Date: 2002/02/25 04:45:00 EST |
521 |
|
Tag: leunga-20020225-cps-spill |
522 |
|
|
523 |
|
This is a new implementation of the CPS spill phase. |
524 |
|
The new phase is in the new file compiler/CodeGen/cpscompile/spill-new.sml |
525 |
|
In case of problems, replace it with the old file spill.sml |
526 |
|
|
527 |
|
The current compiler runs into some serious performance problems when |
528 |
|
constructing a large record. This can happen when we try to compile a |
529 |
|
structure with many items. Even a very simple structure like the following |
530 |
|
makes the compiler slow down. |
531 |
|
|
532 |
|
structure Foo = struct |
533 |
|
val x_1 = 0w1 : Word32.int |
534 |
|
val x_2 = 0w2 : Word32.int |
535 |
|
val x_3 = 0w3 : Word32.int |
536 |
|
... |
537 |
|
val x_N = 0wN : Word32.int |
538 |
|
end |
539 |
|
|
540 |
|
The following table shows the compile time, from N=1000 to N=4000, |
541 |
|
with the old compiler: |
542 |
|
|
543 |
|
N |
544 |
|
1000 CPS 100 spill 0.04u 0.00s 0.00g |
545 |
|
MLRISC ra 0.06u 0.00s 0.05g |
546 |
|
(spills = 0 reloads = 0) |
547 |
|
TOTAL 0.63u 0.07s 0.21g |
548 |
|
|
549 |
|
1100 CPS 100 spill 8.25u 0.32s 0.64g |
550 |
|
MLRISC ra 5.68u 0.59s 3.93g |
551 |
|
(spills = 0 reloads = 0) |
552 |
|
TOTAL 14.71u 0.99s 4.81g |
553 |
|
|
554 |
|
1500 CPS 100 spill 58.55u 2.34s 1.74g |
555 |
|
MLRISC ra 5.54u 0.65s 3.91g |
556 |
|
(spills = 543 reloads = 1082) |
557 |
|
TOTAL 65.40u 3.13s 6.00g |
558 |
|
|
559 |
|
2000 CPS 100 spill 126.69u 4.84s 3.08g |
560 |
|
MLRISC ra 0.80u 0.10s 0.55g |
561 |
|
(spills = 42 reloads = 84) |
562 |
|
TOTAL 129.42u 5.10s 4.13g |
563 |
|
|
564 |
|
3000 CPS 100 spill 675.59u 19.03s 11.64g |
565 |
|
MLRISC ra 2.69u 0.27s 1.38g |
566 |
|
(spills = 62 reloads = 124) |
567 |
|
TOTAL 682.48u 19.61s 13.99g |
568 |
|
|
569 |
|
4000 CPS 100 spill 2362.82u 56.28s 43.60g |
570 |
|
MLRISC ra 4.96u 0.27s 2.72g |
571 |
|
(spills = 85 reloads = 170) |
572 |
|
TOTAL 2375.26u 57.21s 48.00g |
573 |
|
|
574 |
|
As you can see the old cps spill module suffers from some serious |
575 |
|
performance problem. But since I cannot decipher the old code fully, |
576 |
|
instead of patching the problems up, I'm reimplementing it |
577 |
|
with a different algorithm. The new code is more modular, |
578 |
|
smaller when compiled, and substantially faster |
579 |
|
(O(n log n) time and O(n) space). Timing of the new spill module: |
580 |
|
|
581 |
|
4000 CPS 100 spill 0.02u 0.00s 0.00g |
582 |
|
MLRISC ra 0.25u 0.02s 0.15g |
583 |
|
(spills=1 reloads=3) |
584 |
|
TOTAL 7.74u 0.34s 1.62g |
585 |
|
|
586 |
|
Implementation details: |
587 |
|
|
588 |
|
As far as I can tell, the purpose of the CPS spill module is to make sure the |
589 |
|
number of live variables at any program point (the bandwidth) |
590 |
|
does not exceed a certain limit, which is determined by the |
591 |
|
size of the spill area. |
592 |
|
|
593 |
|
When the bandwidth is too large, we decrease the register pressure by |
594 |
|
packing live variables into spill records. How we achieve this is |
595 |
|
completely different than what we did in the old code. |
596 |
|
|
597 |
|
First, there is something about the MLRiscGen code generator |
598 |
|
that we should be aware of: |
599 |
|
|
600 |
|
o MLRiscGen performs code motion! |
601 |
|
|
602 |
|
In particular, it will move floating point computations and |
603 |
|
address computations involving only the heap pointer to |
604 |
|
their use sites (if there is only a single use). |
605 |
|
What this means is that if we have a CPS record construction |
606 |
|
statement |
607 |
|
|
608 |
|
RECORD(k,vl,w,e) |
609 |
|
|
610 |
|
we should never count the new record address w as live if w |
611 |
|
has only one use (which is often the case). |
612 |
|
|
613 |
|
We should do something similar to floating point, but the transformation |
614 |
|
there is much more complex, so I won't deal with that. |
615 |
|
|
616 |
|
Secondly, there are now two new cps primops at our disposal: |
617 |
|
|
618 |
|
1. rawrecord of record_kind option |
619 |
|
This pure operator allocates some uninitialized storage from the heap. |
620 |
|
There are two forms: |
621 |
|
|
622 |
|
rawrecord NONE [INT n] allocates a tagless record of length n |
623 |
|
rawrecord (SOME rk) [INT n] allocates a tagged record of length n |
624 |
|
and initializes the tag. |
625 |
|
|
626 |
|
2. rawupdate of cty |
627 |
|
rawupdate cty (v,i,x) |
628 |
|
Assigns to x to the ith component of record v. |
629 |
|
The storelist is not updated. |
630 |
|
|
631 |
|
We use these new primops for both spilling and increment record construction. |
632 |
|
|
633 |
|
1. Spilling. |
634 |
|
|
635 |
|
This is implemented with a linear scan algorithm (but generalized |
636 |
|
to trees). The algorithm will create a single spill record at the |
637 |
|
beginning of the cps function and use rawupdate to spill to it, |
638 |
|
and SELECT or SELp to reload from it. So both spills and reloads |
639 |
|
are fine-grain operations. In contrast, in the old algorithm |
640 |
|
"spills" have to be bundled together in records. |
641 |
|
|
642 |
|
Ideally, we should sink the spill record construction to where |
643 |
|
it is needed. We can even split the spill record into multiple ones |
644 |
|
at the places where they are needed. But CPS is not a good |
645 |
|
representation for global code motion, so I'll keep it simple and |
646 |
|
am not attempting this. |
647 |
|
|
648 |
|
2. Incremental record construction (aka record splitting). |
649 |
|
|
650 |
|
Long records with many component values which are simulatenously live |
651 |
|
(recall that single use record addresses are not considered to |
652 |
|
be live) are constructed with rawrecord and rawupdate. |
653 |
|
We allocate space on the heap with rawrecord first, then gradually |
654 |
|
fill it in with rawupdate. This is the technique suggested to me |
655 |
|
by Matthias. |
656 |
|
|
657 |
|
Some restrictions on when this is applicable: |
658 |
|
1. It is not a VECTOR record. The code generator currently does not handle |
659 |
|
this case. VECTOR record uses double indirection like arrays. |
660 |
|
2. All the record component values are defined in the same "basic block" |
661 |
|
as the record constructor. This is to prevent speculative |
662 |
|
record construction. |
663 |
|
|
664 |
|
---------------------------------------------------------------------- |
665 |
|
Name: Allen Leung |
666 |
|
Date: 2002/02/22 01:02:00 EST |
667 |
|
Tag: leunga-20020222-mlrisc-tools |
668 |
|
|
669 |
|
Minor bug fixes in the parser and rewriter |
670 |
|
|
671 |
|
---------------------------------------------------------------------- |
672 |
|
Name: Allen Leung |
673 |
|
Date: 2002/02/21 20:20:00 EST |
674 |
|
Tag: leunga-20020221-peephole |
675 |
|
|
676 |
|
Regenerated the peephole files. Some contained typos in the specification |
677 |
|
and some didn't compile because of pretty printing bugs in the old version |
678 |
|
of 'nowhere'. |
679 |
|
|
680 |
|
---------------------------------------------------------------------- |
681 |
|
Name: Allen Leung |
682 |
|
Date: 2002/02/19 20:20:00 EST |
683 |
|
Tag: leunga-20020219-mlrisc-tools |
684 |
|
Description: |
685 |
|
|
686 |
|
Minor bug fixes to the mlrisc-tools library: |
687 |
|
|
688 |
|
1. Fixed up parsing colon suffixed keywords |
689 |
|
2. Added the ability to shut the error messages up |
690 |
|
3. Reimplemented the pretty printer and fixed up/improved |
691 |
|
the pretty printing of handle and -> types. |
692 |
|
4. Fixed up generation of literal symbols in the nowhere tool. |
693 |
|
5. Added some SML keywords to to sml.sty |
694 |
|
|
695 |
|
---------------------------------------------------------------------- |
696 |
|
Name: Matthias Blume |
697 |
|
Date: 2002/02/19 16:20:00 EST |
698 |
|
Tag: blume-20020219-cmffi |
699 |
|
Description: |
700 |
|
|
701 |
|
A wild mix of changes, some minor, some major: |
702 |
|
|
703 |
|
* All C FFI-related libraries are now anchored under $c: |
704 |
|
$/c.cm --> $c/c.cm |
705 |
|
$/c-int.cm --> $c/internals/c-int.cm |
706 |
|
$/memory.cm --> $c/memory/memory.cm |
707 |
|
|
708 |
|
* "make" tool (in CM) now treats its argument pathname slightly |
709 |
|
differently: |
710 |
|
1. If the native expansion is an absolute name, then before invoking |
711 |
|
the "make" command on it, CM will apply OS.Path.mkRelative |
712 |
|
(with relativeTo = OS.FileSys.getDir()) to it. |
713 |
|
2. The argument will be passed through to subsequent phases of CM |
714 |
|
processing without "going native". In particular, if the argument |
715 |
|
was an anchored path, then "make" will not lose track of that anchor. |
716 |
|
|
717 |
|
* Compiler backends now "know" their respective C calling conventions |
718 |
|
instead of having to be told about it by ml-nlffigen. This relieves |
719 |
|
ml-nlffigen from one of its burdens. |
720 |
|
|
721 |
|
* The X86Backend has been split into X86CCallBackend and X86StdCallBackend. |
722 |
|
|
723 |
|
* Export C_DEBUG and C_Debug from $c/c.cm. |
724 |
|
|
725 |
|
* C type encoding in ml-nlffi-lib has been improved to model the conceptual |
726 |
|
subtyping relationship between incomplete pointers and their complete |
727 |
|
counterparts. For this, ('t, 'c) ptr has been changed to 'o ptr -- |
728 |
|
with the convention of instantiating 'o with ('t, 'c) obj whenever |
729 |
|
the pointer target type is complete. In the incomplete case, 'o |
730 |
|
will be instantiated with some "'c iobj" -- a type obtained by |
731 |
|
using one of the functors PointerToIncompleteType or PointerToCompleteType. |
732 |
|
|
733 |
|
Operations that work on both incomplete and complete pointer types are |
734 |
|
typed as taking an 'o ptr while operations that require the target to |
735 |
|
be known are typed as taking some ('t, 'c) obj ptr. |
736 |
|
|
737 |
|
voidptr is now a bit "more concrete", namely "type voidptr = void ptr'" |
738 |
|
where void is an eqtype without any values. This makes it possible |
739 |
|
to work on voidptr values using functions meant to operate on light |
740 |
|
incomplete pointers. |
741 |
|
|
742 |
|
* As a result of the above, signature POINTER_TO_INCOMPLETE_TYPE has |
743 |
|
been vastly simplified. |
744 |
|
|
745 |
|
---------------------------------------------------------------------- |
746 |
|
Name: Matthias Blume |
747 |
|
Date: 2002/02/19 10:48:00 EST |
748 |
|
Tag: blume-20020219-pqfix |
749 |
|
Description: |
750 |
|
|
751 |
|
Applied Chris Okasaki's bug fix for priority queues. |
752 |
|
|
753 |
|
---------------------------------------------------------------------- |
754 |
Name: Matthias Blume |
Name: Matthias Blume |
755 |
Date: 2002/02/15 17:05:00 |
Date: 2002/02/15 17:05:00 |
756 |
Tag: Release_110_39 |
Tag: Release_110_39 |