Compilers and platforms

I was reading a blog the other day about Solaris on x86 and SPARC and the benefits to customers of being able to simply recompile their source to get it to run on the other platform, and it got me thinking that there must be an easier way.

On an internal mail alias here at Sun, I read something a couple of weeks ago which talked about how much better the Sun compilers are than GCC (or perhaps, how much faster the code produced is), and that one of the advantages the Sun compilers have is the generation of an intermediate code representation (ILF?) prior to (IIRC) the final code generation step.

So what I'm thinking is why can't users simply compile their code using the Sun compilers and have it leave the result in this intermediate form? We could then have an interpreter/translator/code-generator on each platform which when called to run the "binary" converts to platform specific assembler and runs it.

I'm reliably informed by a colleague that this is pretty much what .NET does, with the CLR providing the actual platform implementation, and the idea has been around much longer than that (probably even longer than I've been in computing).

It just strikes me that it would make life a lot easier for customers and ISV's and Sun could then write the CLR's for the various platforms and OS's. In fact, if Sun were really keen on OpenSource, they could even publish the ILF spec and allow people to write their own runtime environments.

I'm sure that there are some pretty substantial downsides to this idea, otherwise people in Sun with far bigger brains than me would have already put this into production, but it's food for thought for any of you compiler bods out there.

Comments:

Is that not just java?

Posted by Chris Gerhard on November 19, 2004 at 08:18 AM GMT #

What you describe is exactly what happens today when you use Java; the source code gets turned into bytecode, which is then loaded into the JVM, where the JIT/DynamicCompiler turns it into native code which is then executed (as a performance optimization, bytecode is interpreted first, until it has been used for a certain amount of times to warrant the native code generation and optimization work).

Posted by murphee on November 19, 2004 at 11:45 AM GMT #

For C or C++, the intermediate representation is platform-dependent. Heck, even the preprocessed source code is often platform-dependent. LLVM is an attempt to solve this, but I get the impression it's not bulletproof. (BTW, GCC does use an intermediate representation.)

Posted by Wes Felter on November 19, 2004 at 01:35 PM GMT #

Post a Comment:
Comments are closed for this entry.
About

tdw

Search

Top Tags
Archives
« April 2014
MonTueWedThuFriSatSun
 
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
    
       
Today