RFR: 8264797: Do not include klassVtable.hpp from instanceKlass.hpp

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR: 8264797: Do not include klassVtable.hpp from instanceKlass.hpp

Ioi Lam-2
instanceKlass.hpp is a popular header, included by 647 of about 1000 HotSpot .o files. It unnecessarily includes klassVtable.hpp (only forward class declarations are needed).

After refactoring, the number of .o files that includes klassVtable.hpp reduces from 647 to 132.

-------------

Commit messages:
 - 8264797: Do not include klassVtable.hpp from instanceKlass.hpp

Changes: https://git.openjdk.java.net/jdk/pull/3360/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3360&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8264797
  Stats: 6 lines in 5 files changed: 5 ins; 1 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3360.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3360/head:pull/3360

PR: https://git.openjdk.java.net/jdk/pull/3360
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8264797: Do not include klassVtable.hpp from instanceKlass.hpp

Coleen Phillimore-3
On Tue, 6 Apr 2021 17:07:23 GMT, Ioi Lam <[hidden email]> wrote:

> instanceKlass.hpp is a popular header, included by 647 of about 1000 HotSpot .o files. It unnecessarily includes klassVtable.hpp (only forward class declarations are needed).
>
> After refactoring, the number of .o files that includes klassVtable.hpp reduces from 647 to 132.

I thought you'd need to include the file because of this, because it's not a pointer:
  klassItable itable() const;        // return klassItable wrapper

That's good that you don't!

-------------

Marked as reviewed by coleenp (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/3360
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8264797: Do not include klassVtable.hpp from instanceKlass.hpp

Ioi Lam-2
On Tue, 6 Apr 2021 19:23:07 GMT, Coleen Phillimore <[hidden email]> wrote:

> I thought you'd need to include the file because of this, because it's not a pointer:
> klassItable itable() const; // return klassItable wrapper
>
> That's good that you don't!

Thanks for the review.

I looked this up to make sure what I am doing is allowed. Accord to the C++ specification, a forward-declared class is an incomplete type, which cannot be used "_in general, when the size and layout of the type must be known_". In this case, we just have a declaration of a function, so an incomplete type is allowed.

- https://en.cppreference.com/w/cpp/language/class
- https://en.cppreference.com/w/cpp/language/type#Incomplete_type

-------------

PR: https://git.openjdk.java.net/jdk/pull/3360
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8264797: Do not include klassVtable.hpp from instanceKlass.hpp

Stefan Karlsson-3
In reply to this post by Ioi Lam-2
On Tue, 6 Apr 2021 17:07:23 GMT, Ioi Lam <[hidden email]> wrote:

> instanceKlass.hpp is a popular header, included by 647 of about 1000 HotSpot .o files. It unnecessarily includes klassVtable.hpp (only forward class declarations are needed).
>
> After refactoring, the number of .o files that includes klassVtable.hpp reduces from 647 to 132.

Marked as reviewed by stefank (Reviewer).

-------------

PR: https://git.openjdk.java.net/jdk/pull/3360
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8264797: Do not include klassVtable.hpp from instanceKlass.hpp

Ioi Lam-2
On Tue, 6 Apr 2021 20:04:38 GMT, Stefan Karlsson <[hidden email]> wrote:

>> instanceKlass.hpp is a popular header, included by 647 of about 1000 HotSpot .o files. It unnecessarily includes klassVtable.hpp (only forward class declarations are needed).
>>
>> After refactoring, the number of .o files that includes klassVtable.hpp reduces from 647 to 132.
>
> Marked as reviewed by stefank (Reviewer).

Thanks @stefank and @coleenp for the review!

-------------

PR: https://git.openjdk.java.net/jdk/pull/3360
Reply | Threaded
Open this post in threaded view
|

Integrated: 8264797: Do not include klassVtable.hpp from instanceKlass.hpp

Ioi Lam-2
In reply to this post by Ioi Lam-2
On Tue, 6 Apr 2021 17:07:23 GMT, Ioi Lam <[hidden email]> wrote:

> instanceKlass.hpp is a popular header, included by 647 of about 1000 HotSpot .o files. It unnecessarily includes klassVtable.hpp (only forward class declarations are needed).
>
> After refactoring, the number of .o files that includes klassVtable.hpp reduces from 647 to 132.

This pull request has now been integrated.

Changeset: c3abdc9a
Author:    Ioi Lam <[hidden email]>
URL:       https://git.openjdk.java.net/jdk/commit/c3abdc9a
Stats:     6 lines in 5 files changed: 5 ins; 1 del; 0 mod

8264797: Do not include klassVtable.hpp from instanceKlass.hpp

Reviewed-by: coleenp, stefank

-------------

PR: https://git.openjdk.java.net/jdk/pull/3360