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

8352645: Add tool support to check order of includes #24247

Closed
wants to merge 12 commits into from
Closed
43 changes: 25 additions & 18 deletions doc/hotspot-style.html
Original file line number Diff line number Diff line change
@@ -207,27 +207,34 @@ <h3 id="source-files">Source Files</h3>
<ul>
<li><p>All source files must have a globally unique basename. The build
system depends on this uniqueness.</p></li>
<li><p>Keep the include lines within a section alphabetically sorted.</p></li>
<li><p>Put conditional inclusions (`#if ...`) at the end of the section of HotSpot
include lines. This also applies to macro-expanded includes of platform
dependent files.</p></li>
<li><p>Put system includes in a section after the HotSpot include lines with a blank
line separating the two sections.</p></li>
<li><p>Keep the include lines within a section alphabetically sorted by
their lowercase value. If an include must be out of order for
correctness, suffix with it a comment such as
<code>// do not reorder</code>. Source code processing tools can also
use this hint.</p></li>
<li><p>Put conditional inclusions (<code>#if ...</code>) at the end of
the section of HotSpot include lines. This also applies to
macro-expanded includes of platform dependent files.</p></li>
<li><p>Put system includes in a section after the HotSpot include lines
with a blank line separating the two sections.</p></li>
<li><p>Do not put non-trivial function implementations in .hpp files. If
the implementation depends on other .hpp files, put it in a .cpp or
a .inline.hpp file.</p></li>
the implementation depends on other .hpp files, put it in a .cpp or a
.inline.hpp file.</p></li>
<li><p>.inline.hpp files should only be included in .cpp or .inline.hpp
files.</p></li>
<li><p>All .inline.hpp files should include their corresponding .hpp file as
the first include line with a blank line separating it from the rest of the
include lines. Declarations needed by other files should be put in the .hpp
file, and not in the .inline.hpp file. This rule exists to resolve problems
with circular dependencies between .inline.hpp files.</p></li>
<li><p>Do not include a .hpp file if the corresponding .inline.hpp file is included.</p></li>
<li><p>Use include guards for .hpp and .inline.hpp files. The name of the defined
guard should be derived from the full search path of the file relative to the
hotspot source directory. The guard should be all upper case with all paths
separators and periods replaced by underscores.</p></li>
<li><p>All .inline.hpp files should include their corresponding .hpp
file as the first include line with a blank line separating it from the
rest of the include lines. Declarations needed by other files should be
put in the .hpp file, and not in the .inline.hpp file. This rule exists
to resolve problems with circular dependencies between .inline.hpp
files.</p></li>
<li><p>Do not include a .hpp file if the corresponding .inline.hpp file
is included.</p></li>
<li><p>Use include guards for .hpp and .inline.hpp files. The name of
the defined guard should be derived from the full search path of the
file relative to the hotspot source directory. The guard should be all
upper case with all paths separators and periods replaced by
underscores.</p></li>
<li><p>Some build configurations use precompiled headers to speed up the
build times. The precompiled headers are included in the precompiled.hpp
file. Note that precompiled.hpp is just a build time optimization, so
5 changes: 4 additions & 1 deletion doc/hotspot-style.md
Original file line number Diff line number Diff line change
@@ -138,7 +138,10 @@ change should be done with a "setter" accessor matched to the simple
* All source files must have a globally unique basename. The build
system depends on this uniqueness.

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

* Put conditional inclusions (`#if ...`) at the end of the section of HotSpot
include lines. This also applies to macro-expanded includes of platform
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/immediate_aarch64.cpp
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@
*
*/

#include <stdlib.h>
#include <stdint.h>
#include <stdlib.h> // do not reorder
#include <stdint.h> // do not reorder

#include "immediate_aarch64.hpp"
#include "metaprogramming/primitiveConversions.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/os/windows/systemMemoryBarrier_windows.cpp
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@

#include "systemMemoryBarrier_windows.hpp"

#include <windows.h>
#include <windows.h> // do not reorder
#include <processthreadsapi.h>

bool WindowsSystemMemoryBarrier::initialize() {
2 changes: 1 addition & 1 deletion src/hotspot/share/adlc/archDesc.cpp
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@


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

static FILE *errfile = stderr;
4 changes: 2 additions & 2 deletions src/hotspot/share/c1/c1_CFGPrinter.cpp
Original file line number Diff line number Diff line change
@@ -23,10 +23,10 @@
*/

#include "c1/c1_CFGPrinter.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_InstructionPrinter.hpp"
#include "c1/c1_LIR.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_LinearScan.hpp"
#include "c1/c1_LIR.hpp"
#include "c1/c1_ValueStack.hpp"
#include "jvm.h"

2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_CodeStubs.hpp
Original file line number Diff line number Diff line change
@@ -26,8 +26,8 @@
#define SHARE_C1_C1_CODESTUBS_HPP

#include "c1/c1_FrameMap.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_Instruction.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_LIR.hpp"
#include "c1/c1_Runtime1.hpp"
#include "code/nativeInst.hpp"
5 changes: 2 additions & 3 deletions src/hotspot/share/c1/c1_Compilation.cpp
Original file line number Diff line number Diff line change
@@ -25,20 +25,19 @@
#include "c1/c1_CFGPrinter.hpp"
#include "c1/c1_Compilation.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_LIRAssembler.hpp"
#include "c1/c1_LinearScan.hpp"
#include "c1/c1_LIRAssembler.hpp"
#include "c1/c1_MacroAssembler.hpp"
#include "c1/c1_RangeCheckElimination.hpp"
#include "c1/c1_ValueMap.hpp"
#include "c1/c1_ValueStack.hpp"
#include "code/debugInfoRec.hpp"
#include "compiler/compilationFailureInfo.hpp"
#include "compiler/compilationMemoryStatistic.hpp"
#include "compiler/compilerDirectives.hpp"
#include "compiler/compileLog.hpp"
#include "compiler/compileTask.hpp"
#include "compiler/compiler_globals.hpp"
#include "compiler/compilerDirectives.hpp"
#include "compiler/compileTask.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/timerTrace.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_FrameMap.hpp
Original file line number Diff line number Diff line change
@@ -29,10 +29,10 @@
#include "c1/c1_LIR.hpp"
#include "code/vmreg.hpp"
#include "memory/allocation.hpp"
#include "oops/compressedOops.hpp"
#include "runtime/frame.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include "oops/compressedOops.hpp"

class ciMethod;
class CallingConvention;
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_GraphBuilder.cpp
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@
*
*/

#include "c1/c1_CFGPrinter.hpp"
#include "c1/c1_Canonicalizer.hpp"
#include "c1/c1_CFGPrinter.hpp"
#include "c1/c1_Compilation.hpp"
#include "c1/c1_GraphBuilder.hpp"
#include "c1/c1_InstructionPrinter.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_GraphBuilder.hpp
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@
#ifndef SHARE_C1_C1_GRAPHBUILDER_HPP
#define SHARE_C1_C1_GRAPHBUILDER_HPP

#include "c1/c1_IR.hpp"
#include "c1/c1_Instruction.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_ValueMap.hpp"
#include "c1/c1_ValueStack.hpp"
#include "ci/ciMethodData.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_IR.cpp
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@
#include "c1/c1_Compilation.hpp"
#include "c1/c1_FrameMap.hpp"
#include "c1/c1_GraphBuilder.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_InstructionPrinter.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_Optimizer.hpp"
#include "compiler/oopMap.hpp"
#include "memory/resourceArea.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_Instruction.cpp
Original file line number Diff line number Diff line change
@@ -22,9 +22,9 @@
*
*/

#include "c1/c1_IR.hpp"
#include "c1/c1_Instruction.hpp"
#include "c1/c1_InstructionPrinter.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_ValueStack.hpp"
#include "ci/ciObjArrayKlass.hpp"
#include "ci/ciTypeArrayKlass.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_InstructionPrinter.cpp
Original file line number Diff line number Diff line change
@@ -22,12 +22,12 @@
*
*/

#include "classfile/vmSymbols.hpp"
#include "c1/c1_InstructionPrinter.hpp"
#include "c1/c1_ValueStack.hpp"
#include "ci/ciArray.hpp"
#include "ci/ciInstance.hpp"
#include "ci/ciObject.hpp"
#include "classfile/vmSymbols.hpp"


#ifndef PRODUCT
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_InstructionPrinter.hpp
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@
#ifndef SHARE_C1_C1_INSTRUCTIONPRINTER_HPP
#define SHARE_C1_C1_INSTRUCTIONPRINTER_HPP

#include "c1/c1_IR.hpp"
#include "c1/c1_Instruction.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_Runtime1.hpp"

#ifndef PRODUCT
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_LinearScan.cpp
Original file line number Diff line number Diff line change
@@ -27,8 +27,8 @@
#include "c1/c1_Compilation.hpp"
#include "c1/c1_FrameMap.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_LIRGenerator.hpp"
#include "c1/c1_LinearScan.hpp"
#include "c1/c1_LIRGenerator.hpp"
#include "c1/c1_ValueStack.hpp"
#include "code/vmreg.inline.hpp"
#include "runtime/timerTrace.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_LinearScan.hpp
Original file line number Diff line number Diff line change
@@ -27,8 +27,8 @@

#include "c1/c1_FpuStackSim.hpp"
#include "c1/c1_FrameMap.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_Instruction.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_LIR.hpp"
#include "c1/c1_LIRGenerator.hpp"
#include "compiler/oopMap.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_Optimizer.cpp
Original file line number Diff line number Diff line change
@@ -25,9 +25,9 @@
#include "c1/c1_Optimizer.hpp"
#include "c1/c1_ValueSet.hpp"
#include "c1/c1_ValueStack.hpp"
#include "compiler/compileLog.hpp"
#include "memory/resourceArea.hpp"
#include "utilities/bitMap.inline.hpp"
#include "compiler/compileLog.hpp"

typedef GrowableArray<ValueSet*> ValueSetList;

2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_Optimizer.hpp
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@
#ifndef SHARE_C1_C1_OPTIMIZER_HPP
#define SHARE_C1_C1_OPTIMIZER_HPP

#include "c1/c1_IR.hpp"
#include "c1/c1_Instruction.hpp"
#include "c1/c1_IR.hpp"

class Optimizer {
private:
4 changes: 2 additions & 2 deletions src/hotspot/share/c1/c1_RangeCheckElimination.cpp
Original file line number Diff line number Diff line change
@@ -22,9 +22,9 @@
*
*/

#include "c1/c1_ValueStack.hpp"
#include "c1/c1_RangeCheckElimination.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_RangeCheckElimination.hpp"
#include "c1/c1_ValueStack.hpp"
#include "ci/ciMethodData.hpp"
#include "runtime/deoptimization.hpp"
#include "utilities/bitMap.inline.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_Runtime1.cpp
Original file line number Diff line number Diff line change
@@ -49,8 +49,8 @@
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
#include "oops/access.inline.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
#include "prims/jvmtiExport.hpp"
#include "runtime/atomic.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_ValueStack.cpp
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@
*
*/

#include "c1/c1_IR.hpp"
#include "c1/c1_InstructionPrinter.hpp"
#include "c1/c1_IR.hpp"
#include "c1/c1_ValueStack.hpp"


2 changes: 1 addition & 1 deletion src/hotspot/share/ci/bcEscapeAnalyzer.cpp
Original file line number Diff line number Diff line change
@@ -22,12 +22,12 @@
*
*/

#include "classfile/vmIntrinsics.hpp"
#include "ci/bcEscapeAnalyzer.hpp"
#include "ci/ciConstant.hpp"
#include "ci/ciField.hpp"
#include "ci/ciMethodBlocks.hpp"
#include "ci/ciStreams.hpp"
#include "classfile/vmIntrinsics.hpp"
#include "compiler/compiler_globals.hpp"
#include "interpreter/bytecode.hpp"
#include "oops/oop.inline.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/ci/bcEscapeAnalyzer.hpp
Original file line number Diff line number Diff line change
@@ -26,9 +26,9 @@
#define SHARE_CI_BCESCAPEANALYZER_HPP

#ifdef COMPILER2
#include "ci/ciObject.hpp"
#include "ci/ciMethod.hpp"
#include "ci/ciMethodData.hpp"
#include "ci/ciObject.hpp"
#include "code/dependencies.hpp"
#include "libadt/vectset.hpp"
#include "memory/allocation.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/ci/ciCallSite.cpp
Original file line number Diff line number Diff line change
@@ -22,9 +22,9 @@
*
*/

#include "classfile/javaClasses.inline.hpp"
#include "ci/ciCallSite.hpp"
#include "ci/ciUtilities.inline.hpp"
#include "classfile/javaClasses.inline.hpp"

// ciCallSite

2 changes: 1 addition & 1 deletion src/hotspot/share/ci/ciEnv.cpp
Original file line number Diff line number Diff line change
@@ -42,8 +42,8 @@
#include "compiler/compilationLog.hpp"
#include "compiler/compilationPolicy.hpp"
#include "compiler/compileBroker.hpp"
#include "compiler/compilerEvent.hpp"
#include "compiler/compileLog.hpp"
#include "compiler/compilerEvent.hpp"
#include "compiler/compileTask.hpp"
#include "compiler/disassembler.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/ci/ciEnv.hpp
Original file line number Diff line number Diff line change
@@ -31,9 +31,9 @@
#include "code/debugInfoRec.hpp"
#include "code/dependencies.hpp"
#include "code/exceptionHandlerTable.hpp"
#include "compiler/cHeapStringHolder.hpp"
#include "compiler/compiler_globals.hpp"
#include "compiler/compilerThread.hpp"
#include "compiler/cHeapStringHolder.hpp"
#include "oops/methodData.hpp"
#include "runtime/javaThread.hpp"

2 changes: 1 addition & 1 deletion src/hotspot/share/ci/ciInstance.cpp
Original file line number Diff line number Diff line change
@@ -22,13 +22,13 @@
*
*/

#include "classfile/javaClasses.inline.hpp"
#include "ci/ciConstant.hpp"
#include "ci/ciField.hpp"
#include "ci/ciInstance.hpp"
#include "ci/ciInstanceKlass.hpp"
#include "ci/ciNullObject.hpp"
#include "ci/ciUtilities.inline.hpp"
#include "classfile/javaClasses.inline.hpp"
#include "classfile/vmClasses.hpp"
#include "oops/oop.inline.hpp"

2 changes: 1 addition & 1 deletion src/hotspot/share/ci/ciInstanceKlass.cpp
Original file line number Diff line number Diff line change
@@ -31,10 +31,10 @@
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "oops/fieldStreams.inline.hpp"
#include "oops/instanceKlass.inline.hpp"
#include "oops/klass.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/fieldStreams.inline.hpp"
#include "runtime/fieldDescriptor.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/jniHandles.inline.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/ci/ciMethod.cpp
Original file line number Diff line number Diff line change
@@ -28,9 +28,9 @@
#include "ci/ciMethod.hpp"
#include "ci/ciMethodBlocks.hpp"
#include "ci/ciMethodData.hpp"
#include "ci/ciReplay.hpp"
#include "ci/ciStreams.hpp"
#include "ci/ciSymbol.hpp"
#include "ci/ciReplay.hpp"
#include "ci/ciSymbols.hpp"
#include "ci/ciUtilities.inline.hpp"
#include "compiler/abstractCompiler.hpp"
2 changes: 1 addition & 1 deletion src/hotspot/share/ci/ciReplay.cpp
Original file line number Diff line number Diff line change
@@ -22,10 +22,10 @@
*
*/

#include "ci/ciKlass.hpp"
#include "ci/ciMethodData.hpp"
#include "ci/ciReplay.hpp"
#include "ci/ciSymbol.hpp"
#include "ci/ciKlass.hpp"
#include "ci/ciUtilities.inline.hpp"
#include "classfile/javaClasses.hpp"
#include "classfile/symbolTable.hpp"
Loading