Skip to content

SD-233 synchronized blocks are JIT-friendly again#5417

Merged
retronym merged 1 commit intoscala:2.12.0from
retronym:ticket/SD-233
Sep 27, 2016
Merged

SD-233 synchronized blocks are JIT-friendly again#5417
retronym merged 1 commit intoscala:2.12.0from
retronym:ticket/SD-233

Conversation

@retronym
Copy link
Member

@retronym retronym commented Sep 26, 2016

GenBCode, the new backend in Scala 2.12, subtly changed
the way that synchronized blocks are emitted.

It used java/lang/Throwable as an explicitly named exception
type, rather than implying the same by omitting this in bytecode.

This appears to confuse HotSpot JIT, which reports a error
parsing the bytecode into its IR which leaves the enclosing method
stuck in interpreted mode.

This commit passes a null descriptor to restore the old pattern
(the same one used by javac.) I've checked that the JIT warnings
are gone and that the method can be compiled again.

Fixes scala/scala-dev#233

@scala-jenkins scala-jenkins added this to the 2.12.0-RC2 milestone Sep 26, 2016
@retronym retronym changed the title synchronized blocks are JIT-friendly again SD-233 synchronized blocks are JIT-friendly again Sep 26, 2016
@retronym
Copy link
Member Author

Review by @lrytz

@lrytz
Copy link
Member

lrytz commented Sep 26, 2016

LGTM

Another lesson in the arts of taming the mighty JIT gods..

@lrytz
Copy link
Member

lrytz commented Sep 26, 2016

@retronym here's a regression test: https://github.com/lrytz/scala/tree/sd233-test

I tried pushing to your branch, but

 ! [remote rejected] ticket/SD-233 -> ticket/SD-233 (permission denied)

Is "Allow edits from maintainers" checked? https://github.com/blog/2247-improving-collaboration-with-forks

@retronym
Copy link
Member Author

retronym commented Sep 26, 2016

@lrytz I haven't seen that option when pushing to scala/scala. I did see it pushing to sbt/sbt. Not sure why.

I've pushed your commit with the test, thanks!

I'd like to merge this soon and then restarr the 2.12.0 branch. I can then rebase my other performance oriented PRs and benchmark them (along with the residual commits in https://github.com/scala/scala/compare/2.12.x...retronym:opt/settings?expand=1) to see which ones still are worthwhile.

@lrytz
Copy link
Member

lrytz commented Sep 26, 2016

I don't see it when creating a PR, but in my PR #5415 it's there on the right

image

@retronym
Copy link
Member Author

Clicked!

@lrytz
Copy link
Member

lrytz commented Sep 26, 2016

OK, so it was off - for some reason it was on in my PR by default..

@retronym
Copy link
Member Author

I created the PR with the command line tool, hub. Perhaps the API defaults to the status quo, whereas the UI is different.

@adriaanm
Copy link
Contributor

Wow! Could you add a comment to the code as well? Also, I would be curious to see if this removes the need for the compute method for modules.

GenBCode, the new backend in Scala 2.12, subtly changed
the way that synchronized blocks are emitted.

It used `java/lang/Throwable` as an explicitly named exception
type, rather than implying the same by omitting this in bytecode.

This appears to confuse HotSpot JIT, which reports a error
parsing the bytecode into its IR which leaves the enclosing method
stuck in interpreted mode.

This commit passes a `null` descriptor to restore the old pattern
(the same one used by javac.) I've checked that the JIT warnings
are gone and that the method can be compiled again.
@retronym
Copy link
Member Author

@adriaanm Comment added. I'll benchmark the compiler bootstrapped through this change and reversion of the module lzycompute method, but I'd like to do that as a followup task.

@adriaanm
Copy link
Contributor

Thanks, sounds good!

@retronym retronym merged commit ceaf419 into scala:2.12.0 Sep 27, 2016
@retronym
Copy link
Member Author

Restarring proposed: #5422

@adriaanm adriaanm added the release-notes worth highlighting in next release notes label Oct 15, 2016
@adriaanm adriaanm modified the milestone: 2.12.0-RC2 Oct 29, 2016
@adriaanm adriaanm added the 2.12 label Oct 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes worth highlighting in next release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants