As per Scala 2.10, what are the advantages (if any) of emitting bytecode for the JVM 1.7, when compared to the default of emitting for the 1.6?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Previous Scala versions emitted version 49.0 of the byte code, which corresponded to Java 5. With Scala 2.10 version the default was changed to version 50.0, corresponding to Java 6 and which has the principal advantage of activating the faster verifier introduced with that version, so it should lead to (slightly) better run time performance.
As you note, with 2.10 it became possible to emit version 51.0 byte code, which corresponds to Java 7. There are a few differences between version 50.0 and version 51.0: the biggest is the inclusion of the
invokedynamicinstruction, with the plumbing that goes with it (see the class file format definition for the gory details).As far as Scala usage of the 51.0 byte code goes, even though the technical parts are in place it is my understanding that work is still at an experimental stage in using this feature. See this EPFL presentation and this thread which shows that the team is working on getting the performance benefits of method handles without having to introduce a dependency on Java 7.
Scala 2.11 maintained the default of emitting version 50.0 bytecode, but the official plan is now to jump straight to Java 8 bytecode with Scala 2.12. In the meantime, there is a new back-end available for Scala 2.11 that will let you try out some of the features that are being prototyped for Scala 2.12, and which will become the default back-end with Scala 2.12.
Anyway, the long-awaited proposed benefits all come from using the
invokedynamicbytecode (and its associated MethodHandle structures). They include:(Spoiler: Using
MethodHandlesto implement closures in the experimental backend is currently slower than the present optimised closure creation!)