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

Could avoid use of ObjectRef created due due to pattern matchers CSE and behaviour under -optimize #9257

Open
scabug opened this issue Apr 1, 2015 · 1 comment
Milestone

Comments

@scabug
Copy link

scabug commented Apr 1, 2015

While analysis profiles of Scalac, I noticed an unexpected allocation hotspot in the Uncurry type map.

Here's a minimization:

case class C(x: Any)
class Test {
  def test(a: Any) = a match {
    case C("a") =>
    case C(x) => () => x
    // Patmat's CSE stores the results of the `asInstanceOf[C]` in a var
    // under -optimize, it doesn't bind a local for x at the beginning of the case body,
    // and instead selects temp.x from the closure body. This incurs an `ObjectRef`,
    // even though the closure only needs read only access.
    
    // Workaround: No ObjectRef needed in this case.
    // case C(x) => val xx = x; () => xx
  }
}
@scabug
Copy link
Author

scabug commented Apr 1, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9257?orig=1
Reporter: @retronym
Affected Versions: 2.11.6

@scabug scabug added this to the Backlog milestone Apr 7, 2017
@adriaanm adriaanm removed their assignment Sep 28, 2018
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

3 participants