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

AnyVal leaves no-op residue which the optimizer can't eliminate #7393

Open
scabug opened this issue Apr 19, 2013 · 5 comments
Open

AnyVal leaves no-op residue which the optimizer can't eliminate #7393

scabug opened this issue Apr 19, 2013 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Apr 19, 2013

Compile this under -optimise:

class A { def f1 = 3 max 4 }

You are treated to not one but two no-ops in the bytecode. First we have to load Predef, because maybe Predef hasn't been loaded yet. Then we have to load the RichInt companion object, because maybe that hasn't been loaded either. And if we mark max @inline, it won't make any difference.

  //  0: getstatic     #16                 // Field scala/runtime/RichInt$.MODULE$:Lscala/runtime/RichInt$;
  //  3: getstatic     #21                 // Field scala/Predef$.MODULE$:Lscala/Predef$;
  //  6: astore_1
  //  7: iconst_3
  //  8: iconst_4
  //  9: invokevirtual #25                 // Method scala/runtime/RichInt$.max$extension:(II)I
  // 12: ireturn

Pull request to follow.

  //  after pull request
  //  0: iconst_3
  //  1: iconst_4
  //  2: if_icmpgt     9
  //  5: iconst_4
  //  6: goto          10
  //  9: iconst_3
  // 10: ireturn
@scabug
Copy link
Author

scabug commented Apr 19, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7393?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Apr 19, 2013

@paulp said:
scala/scala#2416

@scabug
Copy link
Author

scabug commented Apr 19, 2013

@magarciaEPFL said:
Somewhat complementary, the @reallyStatic annotation (provisional name) appears more widely applicable (top level objects, value classes) and its prototype works fine for Mode, and other classes in the compiler.

Description: https://groups.google.com/d/msg/scala-internals/B_yPFKRlE44/j0awDzzvHW4J

Implementation:
magarciaEPFL/scala@2ff2322
magarciaEPFL/scala@253ba27

For now the above can be seen in action only with the new backend (which is also doing fine)
magarciaEPFL/scala@master...GenRefactored25

Details about the new backend: http://magarciaepfl.github.io/scala/

@scabug
Copy link
Author

scabug commented Jan 14, 2016

@SethTisue said:
@lrytz any hope here with the new optimizer?

@scabug
Copy link
Author

scabug commented Jan 15, 2016

@lrytz said:
It's not on the short list for 2.12.0, but we'll get there eventually (scala/scala-dev#16).

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

No branches or pull requests

2 participants