Skip to content
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

Unexpected line number on invokedynamic #15108

Closed
adpi2 opened this issue May 5, 2022 · 2 comments
Closed

Unexpected line number on invokedynamic #15108

adpi2 opened this issue May 5, 2022 · 2 comments
Assignees
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@adpi2
Copy link
Member

adpi2 commented May 5, 2022

Compiler version

3.1.2

Minimized code

package example

class A {
  def foo: Unit = {
    Seq(1).foreach { x =>
      println(x)
      println(x)
    }
  }
}

Output

  public void foo();
    Code:
       0: getstatic     #18                 // Field scala/package$.MODULE$:Lscala/package$;
       3: invokevirtual #22                 // Method scala/package$.Seq:()Lscala/collection/immutable/Seq$;
       6: getstatic     #27                 // Field scala/runtime/ScalaRunTime$.MODULE$:Lscala/runtime/ScalaRunTime$;
       9: iconst_1
      10: newarray       int
      12: dup
      13: iconst_0
      14: iconst_1
      15: iastore
      16: invokevirtual #31                 // Method scala/runtime/ScalaRunTime$.wrapIntArray:([I)Lscala/collection/immutable/ArraySeq;
      19: invokevirtual #37                 // Method scala/collection/immutable/Seq$.apply:(Lscala/collection/immutable/Seq;)Lscala/collection/SeqOps;
      22: invokedynamic #55,  0             // InvokeDynamic #0:apply$mcVI$sp:()Lscala/runtime/java8/JFunction1$mcVI$sp;
      27: invokeinterface #61,  2           // InterfaceMethod scala/collection/SeqOps.foreach:(Lscala/Function1;)V
      32: return
    LineNumberTable:
      line 4: 0
      line 5: 0
      line 7: 22
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0      33     0  this   Lexample/A;

Expectation

In the LineNumberTable I don't expect line 7: 22. I would prefer line 5: 22.

Note however that bytecode 22: invokedynamic has no associated line number in Scala 2, which is fine.

@adpi2 adpi2 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 5, 2022
@ghost
Copy link

ghost commented May 5, 2022

I believe this is the same issue as #15098, which shows how it affects debuggers. 😄

@adpi2
Copy link
Member Author

adpi2 commented May 6, 2022

Right, this is a duplicate of #15098

@adpi2 adpi2 closed this as completed May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

2 participants