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

Compiler generates different bytecode with -Ydebug -Ylog:specialize #6223

Closed
scabug opened this issue Aug 13, 2012 · 4 comments
Closed

Compiler generates different bytecode with -Ydebug -Ylog:specialize #6223

scabug opened this issue Aug 13, 2012 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Aug 13, 2012

Here's a pretty simple program:

class Bar[@specialized(Int) Q](q:Q) {
  def qux[@specialized(Int) Z](f:Q => Z) = new Bar(f(q))
}

When compiled with -Ylog:specialize -Ydebug it generates different bytecode than what would otherwise be created. Here is a diff of the Bar$mcI$sp bytecode I generated using "javap -c 'Bar$mcI$sp'":

23a24,41
> public Bar qux$mIc$sp(scala.Function1);
>   Code:
>    0: aload_0
>    1: aload_1
>    2: invokevirtual   #39; //Method qux$mIcI$sp:(Lscala/Function1;)LBar;>    5: areturn
> 
> public Bar qux$mIcI$sp(scala.Function1);
>   Code:
>    0: new     #2; //class Bar$mcI$sp
>    3: dup
>    4: aload_1
>    5: aload_0
>    6: getfield        #19; //Field q$mcI$sp:I
>    9: invokeinterface #43,  2; //InterfaceMethod scala/Function1.apply$mcII$sp:(I)I
>    14:        invokespecial   #46; //Method "<init>":(I)V
>    17:        areturn
>

As you can see, two extra methods are being created.

I think that scalac should be generating these methods in all cases, so as you can imagine I'm quite interested in why they only get generated when doing debugging!

I will comment on this ticket as I learn more.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 13, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6223?orig=1
Reporter: @non
Affected Versions: 2.9.2, 2.10.0

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 13, 2012

@non said:
This will be fixed if scala/scala#1128 is merged.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 14, 2012

@non said:
Fixed in 97ae6f6.

1 similar comment
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 14, 2012

@non said:
Fixed in 97ae6f6.

@scabug scabug closed this Aug 14, 2012
@scabug scabug added this to the 2.10.0-M6 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.