XDC 2014: Compiler News

The Xojo Developer Conference keynote address is usually where a bunch of future items are put on display.  This year it was iOS and Xojo Cloud (the latter just being released).  But sometimes the sessions that the engineers lead are just as informative.  Sometimes it’s hints about future things and sometimes it’s an outright roadmap.

In Geoff’s keynote presentation we learned that the ARM compiler and LLVM backend compiler are real and if not perfect, mostly working.  Joe Strout stated that many things still had to be finalized but it’s a good sign that a significant amount of work has already been put into them and they are functional.

In Joe Ranieri’s ‘About the Xojo Compiler’ session we learned a lot about what a compiler does.  The frontend of the compiler includes the lexer, parser, semantic analyzer, and the intermediate representation (IR) generator.  The results then get passed into the backend of the compiler which has an optimizer and code generator.  That output then gets sent to the linker.  Very technical stuff but interesting.

He then went on to explain how the compiler described isn’t actually what’s in use today. The current compiler is designed to emit machine code quickly and merges a number of the compilation steps together.  Unfortunately this results in it not being reusable for other tasks like autocomplete and there being at least two to three other parsers in the product.  The current compiler also has poor error recovery and diagnostics, and, expects 32-bit integers.  Obviously the compiler needs to be updated.

The new compiler will be designed and implemented very much like what was described earlier, providing a base for future plans. With the first release, the new compiler will create 64-bit applications.  Some of this is waiting on framework work to make sure they are capable of using 64-bits.

The new compiler will be built using LLVM, which has has some great optimization passes but they’re pretty generic to work across a lot of languages.  It will also have additional optimization passes that are specific for Xojo (the language).  This means that some things will get huge speed gains such as direct calls into the framework, redundant reference counting, and direct access to arrays.

The new compiler will have better diagnostics.  Hopefully this will turn into better compiler error messages.  So hopefully this means we can get better information than a generic ‘syntax error.’

Finally, the new compiler will have native linkers.  Currently the compiler does not have native linkers for Linux and Windows which requires the loader stub to do some work that will sometimes trigger Anti-Virus warnings.

The new compiler is scheduled for the first quarter of 2015.  It will not be an immediate replacement and the end Xojo user will be able to switch between the two compilers as fringe cases are found.  All of this is not new to anyone that was around during REALbasic version 5.

All-in-all this is good news.  It’s a little disappointing that it’s going to be another 9 months to see the new compiler but as with all things I’d much rather it work well in version 1 than have it take 3 releases to be usable.

In my next post I’ll talk a little bit about what some of these changes *might* mean in the future.