New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new inliner does not inline methods that allocate an indylambda closure #9378

Closed
scabug opened this Issue Jul 3, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Jul 3, 2015

The GenBCode inliner doesn't inline methods that have an invokedynamic instruction, see here and here.

class A {
  @inline final def assert(c: Boolean, m: => String): Unit = {
    if (!c) println(m)
  }

  @inline final def assert(c: Boolean): Unit = assert(c, "")

  def test(b: Boolean): Unit = {
    assert(b)
  }
}
➜  sandbox git:(yoptInScala) ✗ qsc -Yopt:l:classpath -Yopt-warnings:_ Test.scala 
Test.scala:9: warning: A::assert(Z)V is annotated @inline but could not be inlined:
The callee A::assert(Z)V contains the instruction INVOKEDYNAMIC apply()Lscala/runtime/java8/JFunction0; [
      // handle kind 0x6 : INVOKESTATIC
      java/lang/invoke/LambdaMetafactory.altMetafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;
      // arguments:
      ()Ljava/lang/Object;,
      // handle kind 0x6 : INVOKESTATIC
      A.A$$$anonfun$1()Ljava/lang/String;,
      ()Ljava/lang/String;,
      3,
      1,
      Lscala/Serializable;.class,
      0
    ]
that would cause an IllegalAccessError when inlined into class A.
    assert(b)
          ^
one warning found

When enabling the new optimizer in scala/scala (scala/scala#4602), we needed to add a filter to some partest tests to make them ignore the new inliner warning:

  • presentation/t7678
  • run/t8029.scala
@scabug

This comment has been minimized.

Copy link

scabug commented Jul 3, 2015

@scabug

This comment has been minimized.

Copy link

scabug commented Jul 6, 2015

@scabug scabug closed this Jul 23, 2015

@scabug scabug added the blocker label Apr 7, 2017

@scabug scabug added this to the 2.12.0-M2 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment