21.01.2013 Views

Lecture Notes in Computer Science 4917

Lecture Notes in Computer Science 4917

Lecture Notes in Computer Science 4917

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

136 M. Cornero et al.<br />

Once the assembly has been loaded, the front-end builds GCC types for all the<br />

CLI types declared or referenced <strong>in</strong> the assembly. To do this, some referenced<br />

assemblies may need to be loaded too.<br />

After build<strong>in</strong>g GCC types, the front-end parses the CIL code stream of each<br />

method def<strong>in</strong>ed <strong>in</strong> the assembly <strong>in</strong> order to build GCC GENERIC trees for them.<br />

Most CIL operations are simple and map naturally to GENERIC expressions<br />

or to GCC built-<strong>in</strong> functions. GENERIC trees are then translated to the more<br />

strict GIMPLE representation (gimplified) and passed to the next GCC passes<br />

to be optimized and translated to native code.<br />

F<strong>in</strong>ally, the front-end creates a ma<strong>in</strong> function for the program which performs<br />

any required <strong>in</strong>itialization and calls the assembly entry po<strong>in</strong>t.<br />

Currently, the ma<strong>in</strong> source of limitations <strong>in</strong> the implementation of a full CIL<br />

front-end is the lack of a run-time library which is necessary to implement virtual<br />

mach<strong>in</strong>e services like garbage collection, dynamic class load<strong>in</strong>g and reflection.<br />

These services are not required <strong>in</strong> order to use CIL as an <strong>in</strong>termediate<br />

language for compil<strong>in</strong>g C or other traditional languages. Also, CIL programs<br />

usually require a standard class library which would need to be ported to this<br />

environment. The effort to build this <strong>in</strong>frastructure was outside the scope of our<br />

experiment.<br />

2.4 Tools<br />

From the user’s po<strong>in</strong>t of view, the toolcha<strong>in</strong> is identical to a native toolcha<strong>in</strong>.<br />

We essentially use an assembler and a l<strong>in</strong>ker. As expected, the assembler takes<br />

the CLI <strong>in</strong> textual form and generates an object representation. The l<strong>in</strong>ker takes<br />

several of those object files and produces the f<strong>in</strong>al CLI executable.<br />

At this po<strong>in</strong>t we rely on tools provided by the projects Mono [3] and Portable.-<br />

NET [1]. We plan to switch to a Mono only solution, to limit the number of<br />

dependences we have on other projects, and to avoid us<strong>in</strong>g the non-standard file<br />

format used by Portable.NET for object files.<br />

3 Experiments and Results<br />

3.1 Setup<br />

This section describes the experimental setup we used to compare the code generated<br />

through a traditional compilation flow with the one generated us<strong>in</strong>g CLI<br />

as <strong>in</strong>termediate representation. GCC 4.1 is the common compilation technology<br />

for all the experiments; of course, different compilation flows use different<br />

comb<strong>in</strong>ations of GCC front-ends and back-ends. The compilation flows under<br />

exam<strong>in</strong>ation are:<br />

– configuration a: C to native, -O2 optimization level. In other words, this is<br />

the traditional compilation flow, it is used as a reference to compare aga<strong>in</strong>st.<br />

– configuration b: CtoCLI at -O2 optimization level, followed by CLI to native,<br />

also at -O2. This gives us an upper bound of the achievable performance<br />

when go<strong>in</strong>g through CLI .

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!