1

Is there any formal specification or detailed description of the intermediate code generated by the Scala compiler (i.e. passing the -Xprint-icode option to scalac)?

Thanks.

ale64bit
  • 6,232
  • 3
  • 24
  • 44
  • care to explain the downvote(s)? – ale64bit May 16 '15 at 22:25
  • 1
    I've only upvoted). Didn't find any such docs yet, however you may guess some info from [compiler's stages](http://lampwww.epfl.ch/~emir/bqbase/2005/02/11/scalaPhases.html) and respective scaladocs - at least you will know what is included, what is not – dk14 May 16 '15 at 23:08
  • 1
    Miguel Garcia implemented the new backend and wrote an article about it last year which is at http://magarciaepfl.github.io/scala/#GettingStarted. –  May 16 '15 at 23:52

2 Answers2

1

The icode format is going away, with the introduction of the new GenBCode backend, which goes directly from scalac Trees to ASM's bytecode representation. If I were you, I wouldn't invest time in learning it.

Instead, I suggest you print after cleanup instead (-Xprint:cleanup), which is the last phase before the backend, with scalac Trees, which are very easy to understand because they're basically Java code with a Scala syntax.

That said, if you insist on dealing with icode, I don't think there's any real documentation about it. But it almost has a one-to-one correspondance with the JVM bytecode: it has classes, fields and methods. And inside methods, there is a stack-based instruction set.

sjrd
  • 21,805
  • 2
  • 61
  • 91
  • That sounds good, thanks)) I wasn't interested particularly in icode, but more exactly on the backend's generated code, whatever it is. Said so, is there any spec for the new backend? maybe a doc in progress? – ale64bit May 16 '15 at 23:23
0

Look here for documentation for icode (page 35): http://infoscience.epfl.ch/record/150270/files/EPFL_TH4820.pdf

Lotus Fenn
  • 85
  • 7