This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Dependencies between the compiler phases

2 replies
Valentin Wüstholz
Joined: 2009-08-19,
User offline. Last seen 42 years 45 weeks ago.

Hi,

I'm working on a new Scala backend as part of my Master's thesis at
ETH Zürich. I already asked the same question on the "scala" list and
people there suggested that this list might be a better place to ask
questions like these.

I was wondering which compiler phases depend on each other. Is this
documented anywhere? I use Scala 2.7.5 for my compiler plugin.

I'm particularly interested in the phases that depend on the 'erasure'
phase. Apparently at least the 'constructors' and the 'flatten' phase
seem to depend on it. Is this correct?

What about other phases, such as lazyVals, lambdaLift, flatten, mixer
or cleanup?

Cheers,

Valentin

Iulian Dragos 2
Joined: 2009-02-10,
User offline. Last seen 42 years 45 weeks ago.
Re: Dependencies between the compiler phases

Each phase is necessary for successfully compiling Scala code (except
for the optimization phases). If you want to compile only a subset of
the language, you could (probably) skip some, but I am very skeptical
this works well. You can try '-Yskip:' and see for yourself.

All phases assume their place in the sequence, and handle a (subset) of
the AST or types. After erasure, since types are erased, all phases will
assume the simpler language of types, and therefore won't work as expected.

If you need to write a new code generator you can insert it before any
phase, for instance erasure (all phases produce well-typed code), and
take advantage of the extra available information (but also handle a
richer language, like inner classes).

iulian

Valentin Wüstholz wrote:
> Hi,
>
> I'm working on a new Scala backend as part of my Master's thesis at
> ETH Zürich. I already asked the same question on the "scala" list and
> people there suggested that this list might be a better place to ask
> questions like these.
>
> I was wondering which compiler phases depend on each other. Is this
> documented anywhere? I use Scala 2.7.5 for my compiler plugin.
>
> I'm particularly interested in the phases that depend on the 'erasure'
> phase. Apparently at least the 'constructors' and the 'flatten' phase
> seem to depend on it. Is this correct?
>
> What about other phases, such as lazyVals, lambdaLift, flatten, mixer
> or cleanup?
>
> Cheers,
>
> Valentin
>

Valentin Wüstholz
Joined: 2009-08-19,
User offline. Last seen 42 years 45 weeks ago.
Re: Dependencies between the compiler phases

Thanks! In general, we don't really mind if we can only support a
subset of the language since this is just a proof of concept
implementation.

But putting the code generator before the erasure phase would mean
that we have to implement a lot of the later phases ourselves. This
would take a lot of time besides being a maintenance nightmare.
Therefore we had hoped that a phase like erasure would be more or less
right before the JVM code generator. This should make it a lot easier
to target different platforms. After all, erasure is something quite
JVM specific. C#/.Net for instance doesn't use erasure.

Cheers,

Valentin

On Tue, Sep 8, 2009 at 5:33 PM, Iulian Dragos wrote:
> Each phase is necessary for successfully compiling Scala code (except for
> the optimization phases). If you want to compile only a subset of the
> language, you could (probably) skip some, but I am very skeptical this works
> well. You can try '-Yskip:' and see for yourself.
>
> All phases assume their place in the sequence, and handle a (subset) of the
> AST or types. After erasure, since types are erased, all phases will assume
> the simpler language of types, and therefore won't work as expected.
>
> If you need to write a new code generator you can insert it before any
> phase, for instance erasure (all phases produce well-typed code), and take
> advantage of the extra available information (but also handle a richer
> language, like inner classes).
>
> iulian
>
> Valentin Wüstholz wrote:
>>
>> Hi,
>>
>> I'm working on a new Scala backend as part of my Master's thesis at
>> ETH Zürich. I already asked the same question on the "scala" list and
>> people there suggested that this list might be a better place to ask
>> questions like these.
>>
>> I was wondering which compiler phases depend on each other. Is this
>> documented anywhere? I use Scala 2.7.5 for my compiler plugin.
>>
>> I'm particularly interested in the phases that depend on the 'erasure'
>> phase. Apparently at least the 'constructors' and the 'flatten' phase
>> seem to depend on it. Is this correct?
>>
>> What about other phases, such as lazyVals, lambdaLift, flatten, mixer
>> or cleanup?
>>
>> Cheers,
>>
>> Valentin
>>
>
>
> --
> Iulian Dragos
> =============
> EPFL-IIF-LAMP 1
> INR 321 http://lamp.epfl.ch/~dragos
>
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland