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

JDK-8260593: javac can skip a temporary local variable when pattern matching over a local variable #2313

Closed
wants to merge 2 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Jan 29, 2021

When translating type test like <expr> instanceof String s, javac needs to a) check if the value of <expr> is a String, and if yes, b) create a new variable s, and assign the value of <expr> into it. But, <expr> needs to be evaluated only once. So, javac will create a temporary local variable to hold the value of <expr>. But, if <expr> itself is a local variable, there is no need to create another temporary local variable, javac can read the original local variable twice, leading to a shorter bytecode.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8260593: javac can skip a temporary local variable when pattern matching over a local variable

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2313/head:pull/2313
$ git checkout pull/2313

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 29, 2021

👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 29, 2021
@openjdk
Copy link

openjdk bot commented Jan 29, 2021

@lahodaj The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Jan 29, 2021
@mlbridge
Copy link

mlbridge bot commented Jan 29, 2021

Webrevs

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

looks sensible

@openjdk
Copy link

openjdk bot commented Jan 29, 2021

@lahodaj This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8260593: javac can skip a temporary local variable when pattern matching over a local variable

Reviewed-by: vromero

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 24 new commits pushed to the master branch:

  • c0cde7d: 8259814: test/jdk/tools/jlink/plugins/CompressorPluginTest.java has compilation issues
  • aec0377: 8257498: Remove useless skeleton predicates
  • ab727f0: 8260591: Shenandoah: improve parallelism for concurrent thread root scans
  • cf94208: 8259395: Patching automatic module with additional packages re-creates module without "requires java.base"
  • 039affc: 8260577: Unused code in AbstractCompiler after Shark compiler removal
  • 8a9004d: 8260574: Remove parallel constructs in GenCollectedHeap::process_roots
  • 0da9cad: 8260501: [Vector API] Improve register usage for shift operations on x86
  • a61ff87: 8260685: ProblemList 2 compiler/jvmci/compilerToVM tests in Xcomp configs
  • fcfe647: 8260462: Missing in Modality.html
  • 67a34da: 8260630: Templatize literal_size
  • ... and 14 more: https://git.openjdk.java.net/jdk/compare/0675473486bc0ee321654d308b600874cf5ce41e...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 29, 2021
@cl4es
Copy link
Member

cl4es commented Feb 3, 2021

Thanks for picking up and fixing this, Jan!

@lahodaj
Copy link
Contributor Author

lahodaj commented Feb 8, 2021

/integrate

@openjdk openjdk bot closed this Feb 8, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 8, 2021
@openjdk
Copy link

openjdk bot commented Feb 8, 2021

@lahodaj Since your change was applied there have been 128 commits pushed to the master branch:

  • deb0544: 8261251: Shenandoah: Use object size for full GC humongous compaction
  • d45343e: 8260899: ARM32: SyncOnValueBasedClassTest fails with assert(is_valid()) failed: invalid register
  • 9d59dec: 8248876: LoadObject with bad base address created for exec file on linux
  • aa5bc6e: 8258953: AArch64: move NEON instructions to aarch64_neon.ad
  • c5ff454: 8250989: Consolidate buffer allocation code for CDS static/dynamic dumping
  • 0e18634: 8261270: MakeMethodNotCompilableTest fails with -XX:TieredStopAtLevel={1,2,3}
  • 7a2db85: 8261022: Fix incorrect result of Math.abs() with char type
  • 2c3a86f: 8261280: Remove THREAD argument from compute_loader_lock_object
  • 74d40ab: 8261200: Some code in the ICC_Profile may not close file streams properly
  • d7acfae: Merge
  • ... and 118 more: https://git.openjdk.java.net/jdk/compare/0675473486bc0ee321654d308b600874cf5ce41e...master

Your commit was automatically rebased without conflicts.

Pushed as commit d0a8f2f.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org integrated Pull request has been integrated
3 participants