GitXplorerGitXplorer
l

experimental-backend-2.11

public
3 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
76b7a45b73a08e5b17641d3fc179e9861bba2f80

Merge pull request #1 from xuwei-k/bump-versions

llrytz committed 9 years ago
Unverified
0e8d48024d181b0de183262b7a64913d12878d75

bump versions

xxuwei-k committed 9 years ago
Unverified
c129439e26f02f059c893d8420b4e0bfe009643f

Update README.md

llrytz committed 10 years ago
Unverified
48aba48ba25c8481982c1a5108792fcf490e7a5d

Create README.md

llrytz committed 10 years ago
Unverified
44a6e8b61926b2087dcd8d23d3243c03f6dd971f

Initial Commit

llrytz committed 10 years ago

README

The README file for this repository.

Example sbt project for the experimental backend in Scala 2.11.

See https://github.com/scala/make-release-notes/blob/2.11.x/experimental-backend.md

➜  experimental-backend-2.11 git:(master) java -version
java version "1.8.0_25"


➜  experimental-backend-2.11 git:(master) cat src/main/scala/Test.scala 
object Test extends App {
  @inline def m = 10

  def g = {
    val f = (x: Int) => x + m
    f(1)
  }

  println(g)
}


➜  experimental-backend-2.11 git:(master) sbt run
[...]
11


➜  experimental-backend-2.11 git:(master) find target -name '*.class'
target/scala-2.11/classes/Test$.class
target/scala-2.11/classes/Test$delayedInit$body.class
target/scala-2.11/classes/Test.class



➜  experimental-backend-2.11 git:(master) javap -c -classpath target/scala-2.11/classes/ Test\$
[...]
  public int g();
       0: aload_0
       1: invokedynamic #92,  0             // InvokeDynamic #0:apply$mcII$sp:(LTest$;)Lscala/compat/java8/JFunction1$mcII$sp;
       6: checkcast     #94                 // class scala/Function1
       9: astore_1
      10: aload_1
      11: iconst_1
      12: invokeinterface #96,  2           // InterfaceMethod scala/Function1.apply$mcII$sp:(I)I
      17: ireturn

  public final int Test$$$anonfun$1(int);
       0: iload_1
       1: aload_0
       2: astore_2
       3: bipush        10
       5: istore_3
       6: iload_3
       7: iadd
       8: ireturn

Note

  • no classfile for the closure is generated
  • closure created using invokedynamic
  • the call to m is inlined in the closure body (bipush 10)