170 likes | 272 Vues
Explore code generation of Moscow ML for .NET Framework, assess CLR usability, leverage strongly typed languages, COPLAS project updates, related work, and backend optimizations.
E N D
Moscow ML Code Generation for Microsoft .Net Niels Jørgen Kokholm Copenhagen Programming Language Seminar December 12th 2002
Moscow ML • Standard ML batch compiler (mosmlc) • Standard ML Basis Library • Interactive evaluation system (mosml) • … • Runs on CaML light runtime • Written in Standard ML (and C) COPLAS
Microsoft .Net • Microsoft .NET Framework/ECMA CLI • Common Language Runtime (CLR) • Virtual “stack” machine specification similar to JVM • .NET Framework class libraries • Implementations: • MS .NET SDK • MS SSCLI (rotor) • Mono • DotGNU Portable.NET COPLAS
What • Work in progress • With Peter Sestoft • Long time goal: port Moscow ML to CLR • Started as four week project at ITU • May ’02 Andrzej Wasowski/PS COPLAS
Why • Assess usability of CLR as execution platform for functional languages and the portability of Moscow ML • Expand the range of HW/SW platforms on which Moscow ML run (or avoid porting CaML Light) • Leverage the safety and productivity potential of strongly typed languages in high-end, distributed, XML-aware, E-yada yada yada • Learn about code generation in a non-toy setting and about .NET COPLAS
Plan • Overall plan • Feasibility study • Can it be done with reasonable performance • CLR code generation • For pure Standard ML programs • Basis Library part 1 • Parts used by compiler • Bootstrap compiler • Interactive system • Basis Library part 2 COPLAS
Status • CLR code generation + library part .3 • May 2002 • Bootstrap compiler • October 2002 • No floating point types, quote/antiquote, … • No complete regression test • Performance compared to current Moscow ML • Small code benchmarks: 1-4 times as slow • Bootstrapped compiler: 5 times as slow COPLAS
Related work • Moscow ML on JVM • Peter Berthelsen, master thesis 1998 • SML.NET • Andrew Kennedy, Claudio Russo, Nick Benton (MS Research), released June 2002 • Standard ML compiler on CLR • Bootstrapped from SML/NJ • F# • Don Syme, MS Research • O’CaML on CLR COPLAS
CaML light vs. CLR COPLAS
Moscow ML Code Generation • Parsing, typecheck, translation • Compilation: • Closure splitting • Expression compilation • Byte code emission COPLAS
Changing the backend 1 • Textual assembler vs RTCG? • Verifiable or unverifiable code? • Efficiency COPLAS
Changing the backend 2 • Representation of run time values • Correct tail recursion • Exception handling • Boxing of primitive types COPLAS
Runtime value representation COPLAS
Closures COPLAS
Exception handling COPLAS
Boxing of primitive types COPLAS
Performance comparisons COPLAS