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

yes, what's under the hood? A story of ICode, Pickler, and ... UnPickler.

7 replies
Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.

Hi,

I've been further exploring some phases of nsc, and wondered finally what
makes icode different from Java bytecode. Are there any notes summarizing
that?

So far I've found this: "Unlike Java bytecode, icode uses typed local
variables" [1]

I'm asking because the comments in scala.tools.nsc.backend.icode describe
structural aspects of icode, and not in particular its differences with Java
bytecode (semantics?). Those semantics in turn would help when following
the analyses in scala.tools.nsc.backend.icode.analysis.

Given that I haven't yet made a lot of time-traval across compilation
phases, it hasn't striken me with the full force of enlightment what
interplay there is between icode (on the one hand) and
scala.tools.nsc.symtab.classfile.Pickler and UnPlickler on the other.

Pointers to information on the above would be welcome!

Miguel
http://www.sts.tu-harburg.de/people/mi.garcia

[1] Optimizing Higher-Order Functions in Scala,
http://infoscience.epfl.ch/record/128135/files/paper.pdf

Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.
Re: yes, what's under the hood? A story of ICode, Pickler, and

To all those following this thread,

There's a very clear introduction about Pickler in chapter 2 of
http://lamp.epfl.ch/teaching/projects/archive/coppel_report.pdf

Miguel

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: yes, what's under the hood? A story of ICode, Pickler, and

On Sun, Nov 15, 2009 at 08:03:15PM +0100, Miguel Garcia wrote:
> To all those following this thread,
>
> There's a very clear introduction about Pickler in chapter 2 of
> http://lamp.epfl.ch/teaching/projects/archive/coppel_report.pdf

Thank you! I have done my share of spelunking through lamp PDFs but I'd
never gotten around to reading that one.

Randall R Schulz
Joined: 2008-12-16,
User offline. Last seen 1 year 29 weeks ago.
Re: yes, what's under the hood? A story of ICode, Pickler, and

On Sunday November 15 2009, Miguel Garcia wrote:
> ...
>
> There's a very clear introduction about Pickler in chapter 2 of
> http://lamp.epfl.ch/teaching/projects/archive/coppel_report.pdf

That document is now nearly two years old. To what extent does it
describe Scala 2.8 and to what extent is it obsolete?

> Miguel

Randall Schulz

Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.
Re: yes, what's under the hood? A story of ICode, Pickler, and

From: "Randall R Schulz"
> That document is now nearly two years old. To what extent does it
> describe Scala 2.8 and to what extent is it obsolete?

Even if it were from last week, one would still need to cross-check with
trunk :-) Some aspects may be obsolete, but all in all saves time for
newcomers. And the discussion on reflection was new to me. It's a cool pdf.

BTW, I forgot to link the accompanying sources:
http://lamp.epfl.ch/teaching/projects/archive/coppel_sources.zip

Miguel

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: yes, what's under the hood? A story of ICode, Pickler, and

On Sun, Nov 15, 2009 at 11:25:35AM -0800, Randall R Schulz wrote:
> That document is now nearly two years old. To what extent does it
> describe Scala 2.8 and to what extent is it obsolete?

Here's my reliable source on such questions:

git whatchanged --since="Jan 12 2008" -- src/compiler/scala/tools/nsc/symtab/classfile/*Pickler.scala

I'm glad to have any high level documentation; being somewhat dated
doesn't bother me because I can't trust the details anyway.

Randall R Schulz
Joined: 2008-12-16,
User offline. Last seen 1 year 29 weeks ago.
Re: yes, what's under the hood? A story of ICode, Pickler, and

On Sunday November 15 2009, Miguel Garcia wrote:
> From: "Randall R Schulz"
>
> > That document is now nearly two years old. To what extent does it
> > describe Scala 2.8 and to what extent is it obsolete?
>
> Even if it were from last week, one would still need to cross-check
> with trunk :-) Some aspects may be obsolete, but all in all saves
> time for newcomers. And the discussion on reflection was new to me.
> It's a cool pdf.

Indeed. Please don't take my question as looking a gift horse in the
mouth.

> ...
>
>
> Miguel

Randall Schulz

Iulian Dragos 2
Joined: 2009-02-10,
User offline. Last seen 42 years 45 weeks ago.
Re: yes, what's under the hood? A story of ICode, Pickler, and


On Sun, Nov 15, 2009 at 10:49 AM, Miguel Garcia <miguel.garcia@tuhh.de> wrote:

Hi,

I've been further exploring some phases of nsc, and wondered finally what makes icode different from Java bytecode. Are there any notes summarizing that?

No, unfortunately. They will be, though.. in a few months time (my thesis).

So far I've found this: "Unlike Java bytecode, icode uses typed local variables"  [1]

ICode instructions are very close to java bytecode. Besides typed local variables, there are instructions for dealing with objects (in the Scala sense), and boxing/unboxing operations have their own opcode.

More interesting differences appear in structure. Unlike java bytecode which is linear, ICode uses a control-flow graph representation, where nodes are basic blocks. Exception handlers are 'covering' basic blocks instead of ranges, and there's a def-use link between the 'NEW' operation and its corresponding constructor call, to help analysis.

This list is probably incomplete, but should give you a starting point. A good way to see exactly what's different between bytecode and icode is to check the icode reader. That piece of code is reading java bytecodes from disk and presenting them to the analyzer in icode form, so that inlining and all the other goodies can be applied on library code.

Given that I haven't yet made a lot of time-traval across compilation phases, it hasn't striken me with the full force of enlightment what interplay there is between icode (on the one hand) and
scala.tools.nsc.symtab.classfile.Pickler and UnPlickler on the other.

None. Pickling is only about type signatures, and happens immediately after type checking.

cheers,
iulian
 


Pointers to information on the above would be welcome!


Miguel
http://www.sts.tu-harburg.de/people/mi.garcia


[1] Optimizing Higher-Order Functions in Scala, http://infoscience.epfl.ch/record/128135/files/paper.pdf





--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

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