-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove unnececary boxing in a.synchronized(1)
#505
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
Labels
Comments
DarkDimius
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 28, 2015
DarkDimius
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 28, 2015
DarkDimius
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 30, 2015
Fixed in scalac: scala/scala@92d1af1 |
Raising the priority since it affects thread safe lazy vals. For example: def test = {
lazy val foo = 1
...
} compiles to: def test = {
lazy var foo$lzy1: dotty.runtime.LazyInt = new dotty.runtime.LazyInt()
def foo$lzyINIT1(): Int =
Int.unbox(
foo$lzy1.synchronized(
Int.box(
if (foo$lzy1.initialized()) foo$lzy1.value() else {
foo$lzy1.value_=(1)
foo$lzy1.initialized_=(true)
foo$lzy1.value()
}
)
)
)
def foo(): Int =
if (foo$lzy1.initialized()) foo$lzy1.value() else foo$lzyINIT1()
...
} |
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 1, 2018
`synchronized` is now treated as a magic method by the compiler and is no longer erased (similarly to `asInstanceOf` and `isInstanceOf`). Backend is updated to handle this new magic polymorphic method.
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 1, 2018
`synchronized` is now treated as a magic method by the compiler and is no longer erased (similarly to `asInstanceOf` and `isInstanceOf`). Backend is updated to handle this new magic polymorphic method.
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 1, 2018
`synchronized` is now treated as a magic method by the compiler and is no longer erased (similarly to `asInstanceOf` and `isInstanceOf`). Backend is updated to handle this new magic polymorphic method.
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 1, 2018
`synchronized` is now treated as a magic method by the compiler and is no longer erased (similarly to `asInstanceOf` and `isInstanceOf`). Backend is updated to handle this new magic polymorphic method.
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 6, 2018
`synchronized` is now treated as a magic method by the compiler and is no longer erased (similarly to `asInstanceOf` and `isInstanceOf`). Backend is updated to handle this new magic polymorphic method.
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 8, 2018
`synchronized` is now treated as a magic method by the compiler and is no longer erased (similarly to `asInstanceOf` and `isInstanceOf`). Backend is updated to handle this new magic polymorphic method.
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 8, 2018
`synchronized` is now treated as a magic method by the compiler and is no longer erased (similarly to `asInstanceOf` and `isInstanceOf`). Backend is updated to handle this new magic polymorphic method.
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 8, 2018
`synchronized` is now treated as a magic method by the compiler and is no longer erased (similarly to `asInstanceOf` and `isInstanceOf`). Backend is updated to handle this new magic polymorphic method.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Both Scalac and Dotty assume that
synchronized
takes and returns an Object after erasure.Actually it doesn't so there's no need to box.
We could potentially leave synchronized as a polymorphic method after erasure and save a bit on GC pressure and bytecode size.
The text was updated successfully, but these errors were encountered: