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

8260012: Reduce inclusion of collectedHeap.hpp and heapInspection.hpp #2347

Conversation

iklam
Copy link
Member

@iklam iklam commented Feb 2, 2021

collectedHeap.hpp is included by 477 out of 1000 .o files in HotSpot. This file in turn includes many other complex header files.

In many cases, an object file only directly includes this file via:

  • memAllocator.hpp (which does not actually use collectedHeap.hpp)
  • oop.inline.hpp and compressedOops.inline.hpp (only use collectedHeap.hpp in asserts via Universe::heap()->is_in()).

By refactoring the above 3 files, we can reduce the .o files that include collectedHeap.hpp to 242.

This RFE also removes the unnecessary inclusion of heapInspection.hpp from collectedHeap.hpp.

Build time of HotSpot is reduced for about 1%.

Tested with mach5: tier1, builds-tier2, builds-tier3, builds-tier4 and builds-tier5. Also locally: aarch64, arm, ppc64, s390, x86, and zero.


Progress

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

Issue

  • JDK-8260012: Reduce inclusion of collectedHeap.hpp and heapInspection.hpp

Reviewers

Download

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Feb 2, 2021

👋 Welcome back iklam! 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
Copy link

@openjdk openjdk bot commented Feb 2, 2021

@iklam The following labels will be automatically applied to this pull request:

  • hotspot
  • serviceability

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

@openjdk openjdk bot added serviceability hotspot labels Feb 2, 2021
@iklam
Copy link
Member Author

@iklam iklam commented Feb 2, 2021

/label remove serviceability

@openjdk openjdk bot removed the serviceability label Feb 2, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 2, 2021

@iklam
The serviceability label was successfully removed.

@iklam
Copy link
Member Author

@iklam iklam commented Feb 2, 2021

/label add gc

@openjdk
Copy link

@openjdk openjdk bot commented Feb 2, 2021

@iklam The label gc is not a valid label. These labels are valid:

  • serviceability
  • hotspot
  • sound
  • hotspot-compiler
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • 2d
  • security
  • swing
  • hotspot-runtime
  • jmx
  • build
  • nio
  • beans
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr
  • awt

@iklam
Copy link
Member Author

@iklam iklam commented Feb 2, 2021

/label add hotspot-gc

@openjdk openjdk bot added the hotspot-gc label Feb 2, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 2, 2021

@iklam
The hotspot-gc label was successfully added.

@iklam iklam marked this pull request as ready for review Feb 2, 2021
@openjdk openjdk bot added the rfr label Feb 2, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Feb 2, 2021

stefank
stefank approved these changes Feb 2, 2021
Copy link
Member

@stefank stefank left a comment

Looks good. A few things that you might want to consider, but I'm also fine with the patch as it is.

#include "memory/memRegion.hpp"
#include "oops/oopsHierarchy.hpp"
#include "runtime/thread.hpp"
Copy link
Member

@stefank stefank Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to, this could be changed to a forward declaration if we removed the default value (Thread* thread = Thread::current()) of the constructors. Not needed for this RFE though.

Copy link
Member Author

@iklam iklam Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memAllocator.hpp is not included very often (only 65 out of ~1000 .o files), so I decided to leave it as is.

@@ -515,7 +515,7 @@ BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result)
} else {
obj = *(oop*)res_addr;
}
assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check");
assert(obj == NULL || Universe::is_in_heap(obj), "sanity check");
Copy link
Member

@stefank stefank Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could have been changed to is_in_heap_or_null.

Copy link
Member Author

@iklam iklam Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -305,7 +305,7 @@ BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result)
case T_OBJECT:
case T_ARRAY: {
oop obj = *(oop*)tos_addr;
assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check");
assert(obj == NULL || Universe::is_in_heap(obj), "sanity check");
Copy link
Member

@stefank stefank Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could have been changed to is_in_heap_or_null.

Copy link
Member Author

@iklam iklam Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I also change other frame_.cpp files to use is_in_heap_or_null.

@@ -318,7 +318,7 @@ BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result)
case T_OBJECT:
case T_ARRAY: {
oop obj = *(oop*)tos_addr;
assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check");
assert(obj == NULL || Universe::is_in_heap(obj), "sanity check");
Copy link
Member

@stefank stefank Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could have been changed to is_in_heap_or_null.

@openjdk
Copy link

@openjdk openjdk bot commented Feb 2, 2021

@iklam 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:

8260012: Reduce inclusion of collectedHeap.hpp and heapInspection.hpp

Reviewed-by: stefank, tschatzl

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 label Feb 2, 2021
Copy link
Contributor

@tschatzl tschatzl left a comment

Checked a few includes for missing ones; obviously they are included transitively so add as you see fit.

#include "memory/memRegion.hpp"
#include "oops/oopsHierarchy.hpp"
#include "runtime/thread.hpp"
Copy link
Contributor

@tschatzl tschatzl Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utilities/globalDefinitions.hpp for HeapWord is missing.

Copy link
Member Author

@iklam iklam Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -25,7 +25,6 @@
#ifndef SHARE_OOPS_COMPRESSEDOOPS_INLINE_HPP
#define SHARE_OOPS_COMPRESSEDOOPS_INLINE_HPP

#include "gc/shared/collectedHeap.hpp"
Copy link
Contributor

@tschatzl tschatzl Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utilities/globalDefinitions.hpp for *PTR_FORMAT and others is missing.

Copy link
Member Author

@iklam iklam Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -25,7 +25,6 @@
#ifndef SHARE_OOPS_OOP_INLINE_HPP
#define SHARE_OOPS_OOP_INLINE_HPP

#include "gc/shared/collectedHeap.hpp"
Copy link
Contributor

@tschatzl tschatzl Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utilities/globalDefinitions.hpp for HeapWord is missing.
globals.hpp for some globals.
oopsHierarchy.hpp for narrowKlass
utilties/debug.hpp for assert

Copy link
Member Author

@iklam iklam Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks for the review.

@tschatzl
Copy link
Contributor

@tschatzl tschatzl commented Feb 3, 2021

Still good.

@iklam
Copy link
Member Author

@iklam iklam commented Feb 4, 2021

/integrate

@openjdk openjdk bot closed this Feb 4, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Feb 4, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 4, 2021

@iklam Pushed as commit 82028e7.

💡 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
hotspot hotspot-gc integrated
3 participants