Skip to content

Commit 814730e

Browse files
author
Doug Simon
committed
8352645: Add tool support to check order of includes
Reviewed-by: stefank, kbarrett
1 parent d435362 commit 814730e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+431
-79
lines changed

doc/hotspot-style.html

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -207,27 +207,34 @@ <h3 id="source-files">Source Files</h3>
207207
<ul>
208208
<li><p>All source files must have a globally unique basename. The build
209209
system depends on this uniqueness.</p></li>
210-
<li><p>Keep the include lines within a section alphabetically sorted.</p></li>
211-
<li><p>Put conditional inclusions (`#if ...`) at the end of the section of HotSpot
212-
include lines. This also applies to macro-expanded includes of platform
213-
dependent files.</p></li>
214-
<li><p>Put system includes in a section after the HotSpot include lines with a blank
215-
line separating the two sections.</p></li>
210+
<li><p>Keep the include lines within a section alphabetically sorted by
211+
their lowercase value. If an include must be out of order for
212+
correctness, suffix with it a comment such as
213+
<code>// do not reorder</code>. Source code processing tools can also
214+
use this hint.</p></li>
215+
<li><p>Put conditional inclusions (<code>#if ...</code>) at the end of
216+
the section of HotSpot include lines. This also applies to
217+
macro-expanded includes of platform dependent files.</p></li>
218+
<li><p>Put system includes in a section after the HotSpot include lines
219+
with a blank line separating the two sections.</p></li>
216220
<li><p>Do not put non-trivial function implementations in .hpp files. If
217-
the implementation depends on other .hpp files, put it in a .cpp or
218-
a .inline.hpp file.</p></li>
221+
the implementation depends on other .hpp files, put it in a .cpp or a
222+
.inline.hpp file.</p></li>
219223
<li><p>.inline.hpp files should only be included in .cpp or .inline.hpp
220224
files.</p></li>
221-
<li><p>All .inline.hpp files should include their corresponding .hpp file as
222-
the first include line with a blank line separating it from the rest of the
223-
include lines. Declarations needed by other files should be put in the .hpp
224-
file, and not in the .inline.hpp file. This rule exists to resolve problems
225-
with circular dependencies between .inline.hpp files.</p></li>
226-
<li><p>Do not include a .hpp file if the corresponding .inline.hpp file is included.</p></li>
227-
<li><p>Use include guards for .hpp and .inline.hpp files. The name of the defined
228-
guard should be derived from the full search path of the file relative to the
229-
hotspot source directory. The guard should be all upper case with all paths
230-
separators and periods replaced by underscores.</p></li>
225+
<li><p>All .inline.hpp files should include their corresponding .hpp
226+
file as the first include line with a blank line separating it from the
227+
rest of the include lines. Declarations needed by other files should be
228+
put in the .hpp file, and not in the .inline.hpp file. This rule exists
229+
to resolve problems with circular dependencies between .inline.hpp
230+
files.</p></li>
231+
<li><p>Do not include a .hpp file if the corresponding .inline.hpp file
232+
is included.</p></li>
233+
<li><p>Use include guards for .hpp and .inline.hpp files. The name of
234+
the defined guard should be derived from the full search path of the
235+
file relative to the hotspot source directory. The guard should be all
236+
upper case with all paths separators and periods replaced by
237+
underscores.</p></li>
231238
<li><p>Some build configurations use precompiled headers to speed up the
232239
build times. The precompiled headers are included in the precompiled.hpp
233240
file. Note that precompiled.hpp is just a build time optimization, so

doc/hotspot-style.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ change should be done with a "setter" accessor matched to the simple
138138
* All source files must have a globally unique basename. The build
139139
system depends on this uniqueness.
140140

141-
* Keep the include lines within a section alphabetically sorted.
141+
* Keep the include lines within a section alphabetically sorted by their
142+
lowercase value. If an include must be out of order for correctness,
143+
suffix with it a comment such as `// do not reorder`. Source code
144+
processing tools can also use this hint.
142145

143146
* Put conditional inclusions (`#if ...`) at the end of the section of HotSpot
144147
include lines. This also applies to macro-expanded includes of platform

src/hotspot/cpu/aarch64/immediate_aarch64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
*
2424
*/
2525

26-
#include <stdlib.h>
27-
#include <stdint.h>
26+
#include <stdlib.h> // do not reorder
27+
#include <stdint.h> // do not reorder
2828

2929
#include "immediate_aarch64.hpp"
3030
#include "metaprogramming/primitiveConversions.hpp"

src/hotspot/os/windows/systemMemoryBarrier_windows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include "systemMemoryBarrier_windows.hpp"
2626

27-
#include <windows.h>
27+
#include <windows.h> // do not reorder
2828
#include <processthreadsapi.h>
2929

3030
bool WindowsSystemMemoryBarrier::initialize() {

src/hotspot/share/adlc/archDesc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
// archDesc.cpp - Internal format for architecture definition
27-
#include <unordered_set>
27+
#include <unordered_set> // do not reorder
2828
#include "adlc.hpp"
2929

3030
static FILE *errfile = stderr;

src/hotspot/share/c1/c1_CFGPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
*/
2424

2525
#include "c1/c1_CFGPrinter.hpp"
26-
#include "c1/c1_IR.hpp"
2726
#include "c1/c1_InstructionPrinter.hpp"
28-
#include "c1/c1_LIR.hpp"
27+
#include "c1/c1_IR.hpp"
2928
#include "c1/c1_LinearScan.hpp"
29+
#include "c1/c1_LIR.hpp"
3030
#include "c1/c1_ValueStack.hpp"
3131
#include "jvm.h"
3232

src/hotspot/share/c1/c1_CodeStubs.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#define SHARE_C1_C1_CODESTUBS_HPP
2727

2828
#include "c1/c1_FrameMap.hpp"
29-
#include "c1/c1_IR.hpp"
3029
#include "c1/c1_Instruction.hpp"
30+
#include "c1/c1_IR.hpp"
3131
#include "c1/c1_LIR.hpp"
3232
#include "c1/c1_Runtime1.hpp"
3333
#include "code/nativeInst.hpp"

src/hotspot/share/c1/c1_Compilation.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,19 @@
2525
#include "c1/c1_CFGPrinter.hpp"
2626
#include "c1/c1_Compilation.hpp"
2727
#include "c1/c1_IR.hpp"
28-
#include "c1/c1_LIRAssembler.hpp"
2928
#include "c1/c1_LinearScan.hpp"
29+
#include "c1/c1_LIRAssembler.hpp"
3030
#include "c1/c1_MacroAssembler.hpp"
3131
#include "c1/c1_RangeCheckElimination.hpp"
3232
#include "c1/c1_ValueMap.hpp"
3333
#include "c1/c1_ValueStack.hpp"
3434
#include "code/debugInfoRec.hpp"
3535
#include "compiler/compilationFailureInfo.hpp"
3636
#include "compiler/compilationMemoryStatistic.hpp"
37-
#include "compiler/compilerDirectives.hpp"
3837
#include "compiler/compileLog.hpp"
39-
#include "compiler/compileTask.hpp"
4038
#include "compiler/compiler_globals.hpp"
4139
#include "compiler/compilerDirectives.hpp"
40+
#include "compiler/compileTask.hpp"
4241
#include "memory/resourceArea.hpp"
4342
#include "runtime/sharedRuntime.hpp"
4443
#include "runtime/timerTrace.hpp"

src/hotspot/share/c1/c1_FrameMap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
#include "c1/c1_LIR.hpp"
3030
#include "code/vmreg.hpp"
3131
#include "memory/allocation.hpp"
32+
#include "oops/compressedOops.hpp"
3233
#include "runtime/frame.hpp"
3334
#include "utilities/globalDefinitions.hpp"
3435
#include "utilities/macros.hpp"
35-
#include "oops/compressedOops.hpp"
3636

3737
class ciMethod;
3838
class CallingConvention;

src/hotspot/share/c1/c1_GraphBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
*
2323
*/
2424

25-
#include "c1/c1_CFGPrinter.hpp"
2625
#include "c1/c1_Canonicalizer.hpp"
26+
#include "c1/c1_CFGPrinter.hpp"
2727
#include "c1/c1_Compilation.hpp"
2828
#include "c1/c1_GraphBuilder.hpp"
2929
#include "c1/c1_InstructionPrinter.hpp"

0 commit comments

Comments
 (0)