Skip to content

Commit

Permalink
Merge branch 'upstream-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Datadog Syncup Service committed Nov 4, 2023
2 parents 81faeb2 + df599db commit 5fd93d1
Show file tree
Hide file tree
Showing 36 changed files with 1,138 additions and 417 deletions.
11 changes: 8 additions & 3 deletions make/CreateJmods.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,14 @@ else # not java.base
endif
endif

# Set main class of jdk.httpserver module
ifeq ($(MODULE), jdk.httpserver)
JMOD_FLAGS += --main-class sun.net.httpserver.simpleserver.Main
################################################################################
# Include module specific build settings

-include Jmod.gmk

# Set main class
ifneq ($(JMOD_FLAGS_main_class), )
JMOD_FLAGS += $(JMOD_FLAGS_main_class)
endif

# Changes to the jmod tool itself should also trigger a rebuild of all jmods.
Expand Down
5 changes: 3 additions & 2 deletions make/Main.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@ JMOD_TARGETS := $(addsuffix -jmod, $(JMOD_MODULES))

define DeclareJmodRecipe
$1-jmod:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
MODULE=$1)
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
$(patsubst %,-I%/modules/$1,$(PHASE_MAKEDIRS)) \
-f CreateJmods.gmk MODULE=$1)
endef

$(foreach m, $(JMOD_MODULES), $(eval $(call DeclareJmodRecipe,$m)))
Expand Down
26 changes: 26 additions & 0 deletions make/modules/jdk.httpserver/Jmod.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

JMOD_FLAGS_main_class := --main-class sun.net.httpserver.simpleserver.Main
26 changes: 26 additions & 0 deletions make/modules/jdk.jartool/Jmod.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

JMOD_FLAGS_main_class := --main-class sun.tools.jar.Main
26 changes: 26 additions & 0 deletions make/modules/jdk.jfr/Jmod.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

JMOD_FLAGS_main_class := --main-class jdk.jfr.internal.tool.Main
26 changes: 26 additions & 0 deletions make/modules/jdk.jpackage/Jmod.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

JMOD_FLAGS_main_class := --main-class jdk.jpackage.main.Main
26 changes: 26 additions & 0 deletions make/modules/jdk.jshell/Jmod.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

JMOD_FLAGS_main_class := --main-class jdk.internal.jshell.tool.JShellToolProvider
26 changes: 26 additions & 0 deletions make/modules/jdk.jstatd/Jmod.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

JMOD_FLAGS_main_class := --main-class sun.tools.jstatd.Jstatd
1 change: 1 addition & 0 deletions make/test/JtregNativeHotspot.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ ifeq ($(call isTargetOs, linux), true)
BUILD_TEST_exeinvoke_exeinvoke.c_OPTIMIZATION := NONE
BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exeFPRegs := -ldl
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libAsyncGetCallTraceTest := -ldl
BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libfast-math := -ffast-math
else
BUILD_HOTSPOT_JTREG_EXCLUDE += libtest-rw.c libtest-rwx.c \
exeinvoke.c exestack-gap.c exestack-tls.c libAsyncGetCallTraceTest.cpp
Expand Down
40 changes: 38 additions & 2 deletions src/hotspot/os/bsd/os_bsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
# include <dlfcn.h>
# include <errno.h>
# include <fcntl.h>
# include <fenv.h>
# include <inttypes.h>
# include <poll.h>
# include <pthread.h>
Expand Down Expand Up @@ -975,6 +976,41 @@ bool os::dll_address_to_library_name(address addr, char* buf,
// in case of error it checks if .dll/.so was built for the
// same architecture as Hotspot is running on

void *os::Bsd::dlopen_helper(const char *filename, int mode) {
#ifndef IA32
// Save and restore the floating-point environment around dlopen().
// There are known cases where global library initialization sets
// FPU flags that affect computation accuracy, for example, enabling
// Flush-To-Zero and Denormals-Are-Zero. Do not let those libraries
// break Java arithmetic. Unfortunately, this might affect libraries
// that might depend on these FPU features for performance and/or
// numerical "accuracy", but we need to protect Java semantics first
// and foremost. See JDK-8295159.

// This workaround is ineffective on IA32 systems because the MXCSR
// register (which controls flush-to-zero mode) is not stored in the
// legacy fenv.

fenv_t default_fenv;
int rtn = fegetenv(&default_fenv);
assert(rtn == 0, "fegetenv must succeed");
#endif // IA32

void * result= ::dlopen(filename, RTLD_LAZY);

#ifndef IA32
if (result != nullptr && ! IEEE_subnormal_handling_OK()) {
// We just dlopen()ed a library that mangled the floating-point
// flags. Silently fix things now.
int rtn = fesetenv(&default_fenv);
assert(rtn == 0, "fesetenv must succeed");
assert(IEEE_subnormal_handling_OK(), "fsetenv didn't work");
}
#endif // IA32

return result;
}

#ifdef __APPLE__
void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
#ifdef STATIC_BUILD
Expand All @@ -984,7 +1020,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {

void* result;
JFR_ONLY(NativeLibraryLoadEvent load_event(filename, &result);)
result = ::dlopen(filename, RTLD_LAZY);
result = os::Bsd::dlopen_helper(filename, RTLD_LAZY);
if (result != nullptr) {
Events::log_dll_message(nullptr, "Loaded shared library %s", filename);
// Successful loading
Expand Down Expand Up @@ -1017,7 +1053,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {

void* result;
JFR_ONLY(NativeLibraryLoadEvent load_event(filename, &result);)
result = ::dlopen(filename, RTLD_LAZY);
result = os::Bsd::dlopen_helper(filename, RTLD_LAZY);
if (result != nullptr) {
Events::log_dll_message(nullptr, "Loaded shared library %s", filename);
// Successful loading
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/os/bsd/os_bsd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class os::Bsd {
// Real-time clock functions
static void clock_init(void);

static void *dlopen_helper(const char *path, int mode);

// Stack repair handling

// none present
Expand Down
30 changes: 30 additions & 0 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
# include <signal.h>
# include <endian.h>
# include <errno.h>
# include <fenv.h>
# include <dlfcn.h>
# include <stdio.h>
# include <unistd.h>
Expand Down Expand Up @@ -1802,6 +1803,25 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
}

void * os::Linux::dlopen_helper(const char *filename, char *ebuf, int ebuflen) {
#ifndef IA32
// Save and restore the floating-point environment around dlopen().
// There are known cases where global library initialization sets
// FPU flags that affect computation accuracy, for example, enabling
// Flush-To-Zero and Denormals-Are-Zero. Do not let those libraries
// break Java arithmetic. Unfortunately, this might affect libraries
// that might depend on these FPU features for performance and/or
// numerical "accuracy", but we need to protect Java semantics first
// and foremost. See JDK-8295159.

// This workaround is ineffective on IA32 systems because the MXCSR
// register (which controls flush-to-zero mode) is not stored in the
// legacy fenv.

fenv_t default_fenv;
int rtn = fegetenv(&default_fenv);
assert(rtn == 0, "fegetenv must succeed");
#endif // IA32

void* result;
JFR_ONLY(NativeLibraryLoadEvent load_event(filename, &result);)
result = ::dlopen(filename, RTLD_LAZY);
Expand All @@ -1820,6 +1840,16 @@ void * os::Linux::dlopen_helper(const char *filename, char *ebuf, int ebuflen) {
} else {
Events::log_dll_message(nullptr, "Loaded shared library %s", filename);
log_info(os)("shared library load of %s was successful", filename);
#ifndef IA32
// Quickly test to make sure subnormals are correctly handled.
if (! IEEE_subnormal_handling_OK()) {
// We just dlopen()ed a library that mangled the floating-point
// flags. Silently fix things now.
int rtn = fesetenv(&default_fenv);
assert(rtn == 0, "fesetenv must succeed");
assert(IEEE_subnormal_handling_OK(), "fsetenv didn't work");
}
#endif // IA32
}
return result;
}
Expand Down
7 changes: 5 additions & 2 deletions src/hotspot/share/services/heapDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ enum {

// Supports I/O operations for a dump
// Base class for dump and parallel dump
class AbstractDumpWriter : public ResourceObj {
class AbstractDumpWriter : public CHeapObj<mtInternal> {
protected:
enum {
io_buffer_max_size = 1*M,
Expand Down Expand Up @@ -1955,7 +1955,9 @@ void DumpMerger::do_merge() {
merge_file(path);
}
// Delete selected segmented heap file nevertheless
remove(path);
if (remove(path) != 0) {
log_info(heapdump)("Removal of segment file (%d) failed (%d)", i, errno);
}
}

// restore compressor for further use
Expand Down Expand Up @@ -2358,6 +2360,7 @@ void VM_HeapDumper::work(uint worker_id) {
_dumper_controller->wait_all_dumpers_complete();
} else {
_dumper_controller->dumper_complete(local_writer, writer());
delete local_writer;
return;
}
}
Expand Down
29 changes: 29 additions & 0 deletions src/hotspot/share/utilities/globalDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,32 @@ STATIC_ASSERT(nth_bit(1|2) == 0x8);

STATIC_ASSERT(right_n_bits(3) == 0x7);
STATIC_ASSERT(right_n_bits(1|2) == 0x7);

// Check for Flush-To-Zero mode

// On some processors faster execution can be achieved by setting a
// mode to return zero for extremely small results, rather than an
// IEEE-754 subnormal number. This mode is not compatible with the
// Java Language Standard.

// We need the addition of _large_subnormal and _small_subnormal to be
// performed at runtime. _small_subnormal is volatile so that
// expressions involving it cannot be evaluated at compile time.
static const double large_subnormal_double
= jdouble_cast(0x0030000000000000); // 0x1.0p-1020;
static const volatile double small_subnormal_double
= jdouble_cast(0x0000000000000003); // 0x0.0000000000003p-1022;

// Quickly test to make sure IEEE-754 subnormal numbers are correctly
// handled.
bool IEEE_subnormal_handling_OK() {
// _small_subnormal is the smallest subnormal number that has two
// bits set. _large_subnormal is a number such that, when
// _small_subnormal is added to it, must be rounded according to the
// mode. These two tests detect the rounding mode in use. If
// subnormals are turned off (i.e. subnormals-are-zero) flush-to-
// zero mode is in use.

return (large_subnormal_double + small_subnormal_double > large_subnormal_double
&& -large_subnormal_double - small_subnormal_double < -large_subnormal_double);
}
4 changes: 4 additions & 0 deletions src/hotspot/share/utilities/globalDefinitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,4 +1335,8 @@ template<typename K> int primitive_compare(const K& k0, const K& k1) {
template<typename T>
std::add_rvalue_reference_t<T> declval() noexcept;

// Quickly test to make sure IEEE-754 subnormal numbers are correctly
// handled.
bool IEEE_subnormal_handling_OK();

#endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP
Loading

0 comments on commit 5fd93d1

Please sign in to comment.