Skip to content

8363584: Sort share/utilities includes #26428

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

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/hotspot/share/utilities/align.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/powerOfTwo.hpp"

#include <type_traits>

// Compute mask to use for aligning to or testing alignment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
// No concurrentHashTableTasks.hpp

#include "runtime/atomic.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/concurrentHashTable.inline.hpp"
#include "utilities/globalDefinitions.hpp"

// This inline file contains BulkDeleteTask and GrowTasks which are both bucket
// operations, which they are serialized with each other.
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/utilities/copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*
*/

#include "utilities/copy.hpp"
#include "runtime/sharedRuntime.hpp"
#include "utilities/align.hpp"
#include "utilities/byteswap.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
#include "utilities/unsigned5.hpp"
#include "utilities/vmError.hpp"

#include <stdio.h>
#include <stdarg.h>
#include <stdio.h>

// These functions needs to be exported on Windows only
#define DEBUGEXPORT WINDOWS_ONLY(JNIEXPORT)
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/utilities/elfFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
#include "utilities/elfSymbolTable.hpp"
#include "utilities/ostream.hpp"

#include <string.h>
#include <stdio.h>
#include <limits.h>
#include <new>
#include <stdio.h>
#include <string.h>

const char* ElfFile::USR_LIB_DEBUG_DIRECTORY = "/usr/lib/debug";

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/elfFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ typedef Elf32_Sym Elf_Sym;
#endif
#endif

#include "jvm_md.h"
#include "globalDefinitions.hpp"
#include "jvm_md.h"
#include "memory/allocation.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/decoder.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/init.hpp"
#include "runtime/java.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/os.hpp"
#include "runtime/atomic.hpp"
#include "utilities/events.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/utf8.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/fakeRttiSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#ifndef SHARE_UTILITIES_FAKERTTISUPPORT_HPP
#define SHARE_UTILITIES_FAKERTTISUPPORT_HPP

#include "utilities/globalDefinitions.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"

// Provides support for checked downcasts in a hierarchy of classes.
// The base class provides a member of this type, specialized on that
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/utilities/globalDefinitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
#ifndef SHARE_UTILITIES_GLOBALDEFINITIONS_HPP
#define SHARE_UTILITIES_GLOBALDEFINITIONS_HPP

// Get constants like JVM_T_CHAR and JVM_SIGNATURE_INT, before pulling in <jvm.h>.
#include "classfile_constants.h"

Choose a reason for hiding this comment

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

This include may no longer be needed, since jvm.h includes jvm_constants.h, which
includes classfile_constants.h. (As it should. Presumably it didn't used to and there was
an include-order problem as a result.) But that doesn't need to be addressed in this PR.
It can be dealt with in a new followup issue, and just stick to the sorting problems here.
https://bugs.openjdk.org/browse/JDK-8364087

Copy link
Member

Choose a reason for hiding this comment

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

I don't know what the comment is referring to as this file doesn't include jvm.h, but it does need the constants.

#include "utilities/compilerWarnings.hpp"
#include "utilities/debug.hpp"
#include "utilities/forbiddenFunctions.hpp"
#include "utilities/macros.hpp"

// Get constants like JVM_T_CHAR and JVM_SIGNATURE_INT, before pulling in <jvm.h>.
#include "classfile_constants.h"

#include COMPILER_HEADER(utilities/globalDefinitions)

#include <cstddef>
Expand Down
18 changes: 8 additions & 10 deletions src/hotspot/share/utilities/globalDefinitions_gcc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@

#include <alloca.h>
#include <ctype.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <pthread.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
Expand All @@ -48,16 +53,9 @@
#undef malloc
extern void *malloc(size_t) asm("vec_malloc");
#endif
#include <wchar.h>

#include <math.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <dlfcn.h>
#include <pthread.h>

#include <limits.h>
#include <errno.h>
#include <wchar.h>

#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(_AIX)
#include <signal.h>
Expand Down
25 changes: 13 additions & 12 deletions src/hotspot/share/utilities/globalDefinitions_visCPP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,24 @@
// globally used constants & types, class (forward)
// declarations and a few frequently used utility functions.

// Need this on windows to get the math constants (e.g., M_PI).
#define _USE_MATH_DEFINES

# include <ctype.h>
# include <string.h>
# include <fcntl.h>
# include <float.h> // for _isnan
# include <inttypes.h>
# include <io.h> // for stream.cpp
# include <limits.h>
# include <math.h>
# include <stdarg.h>
# include <stdlib.h>
# include <stdint.h>
# include <stddef.h>// for offsetof
# include <stdint.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <sys/stat.h>
# include <io.h> // for stream.cpp
# include <float.h> // for _isnan
# include <stdio.h> // for va_list
# include <time.h>
# include <fcntl.h>
# include <limits.h>
# include <inttypes.h>
// Need this on windows to get the math constants (e.g., M_PI).
#define _USE_MATH_DEFINES
# include <math.h>

// Only 64-bit Windows is supported
#ifndef _LP64
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/utilities/intpow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define SHARE_UTILITIES_INTPOW_HPP

#include "metaprogramming/enableIf.hpp"

#include <limits>
#include <type_traits>

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/utilities/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "utilities/json.hpp"
#include "utilities/ostream.hpp"

#include <math.h>

static const char* strchrnul_(const char *s, int c) {
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/utilities/ostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,11 +1077,11 @@ bufferedStream::~bufferedStream() {
#ifndef PRODUCT

#if defined(LINUX) || defined(AIX) || defined(_ALLBSD_SOURCE)
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#elif defined(_WINDOWS)
#include <Ws2tcpip.h>
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/utilities/packedTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
* questions.
*
*/
#include <cstring>

#include "utilities/align.hpp"
#include "utilities/count_leading_zeros.hpp"
#include "utilities/packedTable.hpp"

#include <cstring>

// The thresholds are inclusive, and in practice the limits are rounded
// to the nearest power-of-two - 1.
// Based on the max_key and max_value we figure out the number of bits required to store
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/utilities/powerOfTwo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "utilities/count_trailing_zeros.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"

#include <limits>
#include <type_traits>

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/utilities/rbTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "nmt/memTag.hpp"
#include "runtime/os.hpp"
#include "utilities/globalDefinitions.hpp"

#include <type_traits>

// An intrusive red-black tree is constructed with two template parameters:
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/utilities/rbTree.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
#ifndef SHARE_UTILITIES_RBTREE_INLINE_HPP
#define SHARE_UTILITIES_RBTREE_INLINE_HPP

#include "utilities/rbTree.hpp"

#include "metaprogramming/enableIf.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ostream.hpp"
#include "utilities/powerOfTwo.hpp"
#include "utilities/rbTree.hpp"

inline void IntrusiveRBNode::replace_child(IntrusiveRBNode* old_child, IntrusiveRBNode* new_child) {
if (_left == old_child) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/singleWriterSynchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "runtime/orderAccess.hpp"
#include "runtime/os.hpp"
#include "utilities/debug.hpp"
#include "utilities/singleWriterSynchronizer.hpp"
#include "utilities/macros.hpp"
#include "utilities/singleWriterSynchronizer.hpp"

SingleWriterSynchronizer::SingleWriterSynchronizer() :
_enter(0),
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/utf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
*/

#include "memory/allocation.hpp"
#include "runtime/os.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/utf8.hpp"
#include "runtime/os.hpp"

// Assume the utf8 string is in legal form and has been
// checked in the class file parser/format checker.
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/vmError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
#include "runtime/threads.hpp"
#include "runtime/threadSMR.hpp"
#include "runtime/trimNativeHeap.hpp"
#include "runtime/vm_version.hpp"
#include "runtime/vmOperations.hpp"
#include "runtime/vmThread.hpp"
#include "runtime/vm_version.hpp"
#include "sanitizers/ub.hpp"
#include "utilities/debug.hpp"
#include "utilities/decoder.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/waitBarrier_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "runtime/atomic.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/os.hpp"
#include "utilities/waitBarrier_generic.hpp"
#include "utilities/spinYield.hpp"
#include "utilities/waitBarrier_generic.hpp"

// Implements the striped semaphore wait barrier.
//
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/xmlstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "oops/methodData.hpp"
#include "oops/method.inline.hpp"
#include "oops/methodData.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/deoptimization.hpp"
#include "runtime/handles.inline.hpp"
Expand Down
3 changes: 2 additions & 1 deletion test/hotspot/jtreg/sources/TestIncludesAreSorted.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public class TestIncludesAreSorted {
"share/compiler",
"share/jvmci",
"share/oops",
"share/opto"
"share/opto",
"share/utilities"
};

/**
Expand Down