--- a/.hgtags Sat Oct 26 23:59:51 2019 +0200
+++ b/.hgtags Mon Oct 28 18:43:04 2019 +0100
@@ -591,3 +591,5 @@
d29f0181ba424a95d881aba5eabf2e393abcc70f jdk-14+16
5c83830390baafb76a1fbe33443c57620bd45fb9 jdk-14+17
e84d8379815ba0d3e50fb096d28c25894cb50b8c jdk-14+18
+9b67dd88a9313e982ec5f710a7747161bc8f0c23 jdk-14+19
+54ffb15c48399dd59922ee22bb592d815307e77c jdk-14+20
--- a/make/Bundles.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/Bundles.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -50,6 +50,7 @@
# files or directories may contain spaces.
# BASE_DIRS : Base directories for the root dir in the bundle.
# SUBDIR : Optional name of root dir in bundle.
+# OUTPUTDIR : Optionally override output dir
SetupBundleFile = $(NamedParamsMacroTemplate)
define SetupBundleFileBody
@@ -70,8 +71,11 @@
$$(call SetIfEmpty, $1_UNZIP_DEBUGINFO, false)
- $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME): $$($1_FILES)
+ $$(call SetIfEmpty, $1_OUTPUTDIR, $$(BUNDLES_OUTPUTDIR))
+
+ $$($1_OUTPUTDIR)/$$($1_BUNDLE_NAME): $$($1_FILES)
$$(call MakeTargetDir)
+ $$(call LogWarn, Creating $$($1_BUNDLE_NAME))
# If any of the files contain a space in the file name, FindFiles
# will have replaced it with ?. Tar does not accept that so need to
# switch it back.
@@ -137,7 +141,7 @@
endif
endif
- $1 += $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME)
+ $1 += $$($1_OUTPUTDIR)/$$($1_BUNDLE_NAME)
endef
@@ -165,7 +169,7 @@
################################################################################
-ifneq ($(filter product-bundles legacy-bundles, $(MAKECMDGOALS)), )
+ifneq ($(filter product-bundles% legacy-bundles, $(MAKECMDGOALS)), )
SYMBOLS_EXCLUDE_PATTERN := %.debuginfo %.diz %.pdb %.map
--- a/make/CompileInterimLangtools.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/CompileInterimLangtools.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -49,6 +49,13 @@
TARGETS += $(patsubst %, $(BUILDTOOLS_OUTPUTDIR)/gensrc/%/module-info.java, \
$(INTERIM_LANGTOOLS_MODULES))
+$(eval $(call SetupCopyFiles, COPY_PREVIEW_FEATURES, \
+ FILES := $(TOPDIR)/src/java.base/share/classes/jdk/internal/PreviewFeature.java, \
+ DEST := $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim/jdk/internal/, \
+))
+
+TARGETS += $(COPY_PREVIEW_FEATURES)
+
################################################################################
# Setup the rules to build interim langtools, which is compiled by the boot
# javac and can be run on the boot jdk. This will be used to compile the rest of
@@ -72,13 +79,15 @@
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \
ADD_JAVAC_FLAGS := --module-path $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules \
$$(INTERIM_LANGTOOLS_ADD_EXPORTS) \
+ --patch-module java.base=$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim \
+ --add-exports java.base/jdk.internal=jdk.compiler.interim \
-Xlint:-module, \
))
$1_DEPS_INTERIM := $$(addsuffix .interim, $$(filter \
$$(INTERIM_LANGTOOLS_BASE_MODULES), $$(call FindTransitiveDepsForModule, $1)))
- $$(BUILD_$1.interim): $$(foreach d, $$($1_DEPS_INTERIM), $$(BUILD_$$d))
+ $$(BUILD_$1.interim): $$(foreach d, $$($1_DEPS_INTERIM), $$(BUILD_$$d)) $(COPY_PREVIEW_FEATURES)
TARGETS += $$(BUILD_$1.interim)
endef
--- a/make/Docs.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/Docs.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -95,6 +95,7 @@
-tag see \
-taglet build.tools.taglet.ExtLink \
-taglet build.tools.taglet.Incubating \
+ -taglet build.tools.taglet.Preview \
-tagletpath $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
$(CUSTOM_JAVADOC_TAGS) \
#
@@ -191,26 +192,26 @@
################################################################################
# Functions
-# Helper function for creating a png file from a dot file generated by the
+# Helper function for creating a svg file from a dot file generated by the
# GenGraphs tool.
# param 1: SetupJavadocGeneration namespace ($1)
# param 2: module name
#
-define setup_gengraph_dot_to_png
+define setup_gengraph_dot_to_svg
$1_$2_DOT_SRC := $$($1_GENGRAPHS_DIR)/$2.dot
- $1_$2_PNG_TARGET := $$($1_TARGET_DIR)/$2/module-graph.png
+ $1_$2_SVG_TARGET := $$($1_TARGET_DIR)/$2/module-graph.svg
- # For each module needing a graph, create a png file from the dot file
+ # For each module needing a graph, create a svg file from the dot file
# generated by the GenGraphs tool and store it in the target dir.
- $$(eval $$(call SetupExecute, gengraphs_png_$1_$2, \
+ $$(eval $$(call SetupExecute, gengraphs_svg_$1_$2, \
INFO := Running dot for module graphs for $2, \
DEPS := $$(gengraphs_$1_TARGET), \
- OUTPUT_FILE := $$($1_$2_PNG_TARGET), \
+ OUTPUT_FILE := $$($1_$2_SVG_TARGET), \
SUPPORT_DIR := $$($1_GENGRAPHS_DIR), \
- COMMAND := $$(DOT) -Tpng -o $$($1_$2_PNG_TARGET) $$($1_$2_DOT_SRC), \
+ COMMAND := $$(DOT) -Tsvg -o $$($1_$2_SVG_TARGET) $$($1_$2_DOT_SRC), \
))
- $1_MODULEGRAPH_TARGETS += $$($1_$2_PNG_TARGET)
+ $1_MODULEGRAPH_TARGETS += $$($1_$2_SVG_TARGET)
endef
# Helper function to create the overview.html file to use with the -overview
@@ -281,7 +282,7 @@
ifeq ($$(ENABLE_FULL_DOCS), true)
# Tell the ModuleGraph taglet to generate html links to soon-to-be-created
- # png files with module graphs.
+ # svg files with module graphs.
$1_JAVA_ARGS += -DenableModuleGraph=true
endif
@@ -361,8 +362,8 @@
$1_JAVADOC_TARGETS := $$(javadoc_$1_TARGET)
ifeq ($$(ENABLE_FULL_DOCS), true)
- # We have asked ModuleGraph to generate links to png files. Now we must
- # produce the png files.
+ # We have asked ModuleGraph to generate links to svg files. Now we must
+ # produce the svg files.
# Locate which modules has the @moduleGraph tag in their module-info.java
$1_MODULES_NEEDING_GRAPH := $$(strip $$(foreach m, $$($1_ALL_MODULES), \
@@ -387,11 +388,11 @@
--dot-attributes $$(GENGRAPHS_PROPS), \
))
- # For each module needing a graph, create a png file from the dot file
+ # For each module needing a graph, create a svg file from the dot file
# generated by the GenGraphs tool and store it in the target dir.
# They will depend on gengraphs_$1_TARGET, and will be added to $1.
$$(foreach m, $$($1_MODULES_NEEDING_GRAPH), \
- $$(eval $$(call setup_gengraph_dot_to_png,$1,$$m)) \
+ $$(eval $$(call setup_gengraph_dot_to_svg,$1,$$m)) \
)
endif
endef
--- a/make/RunTests.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/RunTests.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -185,13 +185,13 @@
$$(FIXPATH) $$(JDK_UNDER_TEST)/bin/jaotc \
$$($1_JAOTC_OPTS) --output $$@ --module $$($1_MODULE) \
)
- $$(call ExecuteWithLog, $$@.check, \
+ $$(call ExecuteWithLog, $$@.check, ( \
$$(FIXPATH) $$(JDK_UNDER_TEST)/bin/java \
$$($1_VM_OPTIONS) -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions \
-XX:+PrintAOT -XX:+UseAOTStrictLoading \
-XX:AOTLibrary=$$@ -version \
> $$@.verify-aot \
- )
+ ))
$1_AOT_OPTIONS += -XX:+UnlockExperimentalVMOptions
$1_AOT_OPTIONS += -XX:AOTLibrary=$$($1_AOT_LIB)
@@ -593,7 +593,7 @@
$$(call LogWarn)
$$(call LogWarn, Running test '$$($1_TEST)')
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
- $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/gtest, \
+ $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/gtest, ( \
$$(FIXPATH) $$(TEST_IMAGE_DIR)/hotspot/gtest/$$($1_VARIANT)/gtestLauncher \
-jdk $(JDK_UNDER_TEST) $$($1_GTEST_FILTER) \
--gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \
@@ -602,7 +602,7 @@
> >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) \
&& $$(ECHO) $$$$? > $$($1_EXITCODE) \
|| $$(ECHO) $$$$? > $$($1_EXITCODE) \
- )
+ ))
$1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt
@@ -705,7 +705,7 @@
$$(call LogWarn)
$$(call LogWarn, Running test '$$($1_TEST)')
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
- $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/micro, \
+ $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/micro, ( \
$$(FIXPATH) $$($1_MICRO_TEST_JDK)/bin/java $$($1_MICRO_JAVA_OPTIONS) \
-jar $$($1_MICRO_BENCHMARKS_JAR) \
$$($1_MICRO_ITER) $$($1_MICRO_FORK) $$($1_MICRO_TIME) \
@@ -715,7 +715,7 @@
> >($(TEE) $$($1_TEST_RESULTS_DIR)/micro.txt) \
&& $$(ECHO) $$$$? > $$($1_EXITCODE) \
|| $$(ECHO) $$$$? > $$($1_EXITCODE) \
- )
+ ))
$1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/micro.txt
@@ -928,7 +928,7 @@
$$(call LogWarn)
$$(call LogWarn, Running test '$$($1_TEST)')
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
- $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/jtreg, \
+ $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/jtreg, ( \
$$(COV_ENVIRONMENT) \
$$(JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \
-Dprogram=jtreg -jar $$(JT_HOME)/lib/jtreg.jar \
@@ -943,7 +943,7 @@
$$($1_TEST_NAME) \
&& $$(ECHO) $$$$? > $$($1_EXITCODE) \
|| $$(ECHO) $$$$? > $$($1_EXITCODE) \
- )
+ ))
$1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/text/stats.txt
@@ -1019,12 +1019,12 @@
$$(call LogWarn)
$$(call LogWarn, Running test '$$($1_TEST)')
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
- $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/test-execution, \
+ $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/test-execution, ( \
$$($1_TEST_COMMAND_LINE) \
> >($(TEE) $$($1_TEST_RESULTS_DIR)/test-output.txt) \
&& $$(ECHO) $$$$? > $$($1_EXITCODE) \
|| $$(ECHO) $$$$? > $$($1_EXITCODE) \
- )
+ ))
$1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt
--- a/make/autoconf/basics.m4 Sat Oct 26 23:59:51 2019 +0200
+++ b/make/autoconf/basics.m4 Mon Oct 28 18:43:04 2019 +0100
@@ -489,31 +489,43 @@
# for unknown variables in the end.
CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
+ tool_override=[$]$1
+ AC_MSG_NOTICE([User supplied override $1="$tool_override"])
+
# Check if we try to supply an empty value
- if test "x[$]$1" = x; then
- AC_MSG_NOTICE([Setting user supplied tool $1= (no value)])
+ if test "x$tool_override" = x; then
AC_MSG_CHECKING([for $1])
AC_MSG_RESULT([disabled])
else
+ # Split up override in command part and argument part
+ tool_and_args=($tool_override)
+ [ tool_command=${tool_and_args[0]} ]
+ [ unset 'tool_and_args[0]' ]
+ [ tool_args=${tool_and_args[@]} ]
+
# Check if the provided tool contains a complete path.
- tool_specified="[$]$1"
- tool_basename="${tool_specified##*/}"
- if test "x$tool_basename" = "x$tool_specified"; then
+ tool_basename="${tool_command##*/}"
+ if test "x$tool_basename" = "x$tool_command"; then
# A command without a complete path is provided, search $PATH.
- AC_MSG_NOTICE([Will search for user supplied tool $1=$tool_basename])
+ AC_MSG_NOTICE([Will search for user supplied tool "$tool_basename"])
AC_PATH_PROG($1, $tool_basename)
if test "x[$]$1" = x; then
- AC_MSG_ERROR([User supplied tool $tool_basename could not be found])
+ AC_MSG_ERROR([User supplied tool $1="$tool_basename" could not be found])
fi
else
# Otherwise we believe it is a complete path. Use it as it is.
- AC_MSG_NOTICE([Will use user supplied tool $1=$tool_specified])
- AC_MSG_CHECKING([for $1])
- if test ! -x "$tool_specified"; then
+ AC_MSG_NOTICE([Will use user supplied tool "$tool_command"])
+ AC_MSG_CHECKING([for $tool_command])
+ if test ! -x "$tool_command"; then
AC_MSG_RESULT([not found])
- AC_MSG_ERROR([User supplied tool $1=$tool_specified does not exist or is not executable])
+ AC_MSG_ERROR([User supplied tool $1="$tool_command" does not exist or is not executable])
fi
- AC_MSG_RESULT([$tool_specified])
+ $1="$tool_command"
+ AC_MSG_RESULT([found])
+ fi
+ if test "x$tool_args" != x; then
+ # If we got arguments, re-append them to the command after the fixup.
+ $1="[$]$1 $tool_args"
fi
fi
fi
--- a/make/autoconf/flags-cflags.m4 Sat Oct 26 23:59:51 2019 +0200
+++ b/make/autoconf/flags-cflags.m4 Mon Oct 28 18:43:04 2019 +0100
@@ -170,11 +170,11 @@
DISABLE_WARNING_PREFIX="-erroff="
CFLAGS_WARNINGS_ARE_ERRORS="-errwarn=%all"
- WARNINGS_ENABLE_ALL_CFLAGS="-v"
- WARNINGS_ENABLE_ALL_CXXFLAGS="+w"
+ WARNINGS_ENABLE_ALL_CFLAGS="-v -fd -xtransition"
+ WARNINGS_ENABLE_ALL_CXXFLAGS="+w +w2"
- DISABLED_WARNINGS_C=""
- DISABLED_WARNINGS_CXX=""
+ DISABLED_WARNINGS_C="E_OLD_STYLE_FUNC_DECL E_OLD_STYLE_FUNC_DEF E_SEMANTICS_OF_OP_CHG_IN_ANSI_C E_NO_REPLACEMENT_IN_STRING E_DECLARATION_IN_CODE"
+ DISABLED_WARNINGS_CXX="inllargeuse inllargeint notused wemptydecl notemsource"
;;
gcc)
--- a/make/autoconf/jdk-options.m4 Sat Oct 26 23:59:51 2019 +0200
+++ b/make/autoconf/jdk-options.m4 Mon Oct 28 18:43:04 2019 +0100
@@ -599,7 +599,14 @@
AC_MSG_RESULT([yes, forced])
ENABLE_GENERATE_CLASSLIST="true"
if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xfalse"; then
- AC_MSG_WARN([Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS and enable-cds=$ENABLE_CDS])
+ if test "x$ENABLE_CDS" = "xfalse"; then
+ # In GenerateLinkOptData.gmk, DumpLoadedClassList is used to generate the
+ # classlist file. It never will work in this case since the VM will report
+ # an error for DumpLoadedClassList when CDS is disabled.
+ AC_MSG_ERROR([Generation of classlist is not possible with enable-cds=false])
+ else
+ AC_MSG_WARN([Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS and enable-cds=$ENABLE_CDS])
+ fi
fi
elif test "x$enable_generate_classlist" = "xno"; then
AC_MSG_RESULT([no, forced])
--- a/make/common/MakeBase.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/common/MakeBase.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -564,8 +564,8 @@
# Param 1 - The path to base the name of the log file / command line file on
# Param 2 - The command to run
ExecuteWithLog = \
- $(call LogCmdlines, Exececuting: [$(strip $2)]) \
- $(call MakeDir, $(dir $(strip $1))) \
+ $(call LogCmdlines, Executing: [$(strip $2)]) \
+ $(call MakeDir, $(dir $(strip $1)) $(MAKESUPPORT_OUTPUTDIR)/failure-logs) \
$(call WriteFile, $2, $(strip $1).cmdline) \
( $(RM) $(strip $1).log && $(strip $2) > >($(TEE) -a $(strip $1).log) 2> >($(TEE) -a $(strip $1).log >&2) || \
( exitcode=$(DOLLAR)? && \
--- a/make/common/TestFilesCompilation.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/common/TestFilesCompilation.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -98,7 +98,7 @@
DISABLED_WARNINGS_gcc := format undef unused-function unused-value, \
DISABLED_WARNINGS_clang := undef format-nonliteral \
missing-field-initializers sometimes-uninitialized, \
- DISABLED_WARNINGS_CXX_solstudio := wvarhidenmem, \
+ DISABLED_WARNINGS_CXX_solstudio := wvarhidenmem doubunder, \
LIBS := $$($1_LIBS_$$(name)), \
TOOLCHAIN := $(if $$(filter %.cpp, $$(file)), TOOLCHAIN_LINK_CXX, TOOLCHAIN_DEFAULT), \
OPTIMIZATION := $$(if $$($1_OPTIMIZATION_$$(name)),$$($1_OPTIMIZATION_$$(name)),LOW), \
--- a/make/conf/jib-profiles.js Sat Oct 26 23:59:51 2019 +0200
+++ b/make/conf/jib-profiles.js Mon Oct 28 18:43:04 2019 +0100
@@ -839,13 +839,17 @@
if (testedProfile == null) {
testedProfile = input.build_os + "-" + input.build_cpu;
}
- var testedProfileJDK = testedProfile + ".jdk";
- var testedProfileTest = ""
- if (testedProfile.endsWith("-jcov")) {
- testedProfileTest = testedProfile.substring(0, testedProfile.length - "-jcov".length) + ".test";
+ var testedProfileJdk = testedProfile + ".jdk";
+ // Make it possible to use the test image from a different profile
+ var testImageProfile;
+ if (input.testImageProfile != null) {
+ testImageProfile = input.testImageProfile;
+ } else if (testedProfile.endsWith("-jcov")) {
+ testImageProfile = testedProfile.substring(0, testedProfile.length - "-jcov".length);
} else {
- testedProfileTest = testedProfile + ".test";
+ testImageProfile = testedProfile;
}
+ var testedProfileTest = testImageProfile + ".test"
var testOnlyMake = [ "run-test-prebuilt", "LOG_CMDLINES=true", "JTREG_VERBOSE=fail,error,time" ];
if (testedProfile.endsWith("-gcov")) {
testOnlyMake = concat(testOnlyMake, "GCOV_ENABLED=true")
@@ -855,14 +859,14 @@
target_os: input.build_os,
target_cpu: input.build_cpu,
dependencies: [
- "jtreg", "gnumake", "boot_jdk", "devkit", "jib", "jcov", testedProfileJDK,
+ "jtreg", "gnumake", "boot_jdk", "devkit", "jib", "jcov", testedProfileJdk,
testedProfileTest
],
src: "src.conf",
make_args: testOnlyMake,
environment: {
"BOOT_JDK": common.boot_jdk_home,
- "JDK_IMAGE_DIR": input.get(testedProfileJDK, "home_path"),
+ "JDK_IMAGE_DIR": input.get(testedProfileJdk, "home_path"),
"TEST_IMAGE_DIR": input.get(testedProfileTest, "home_path")
},
labels: "test"
@@ -871,10 +875,10 @@
// If actually running the run-test-prebuilt profile, verify that the input
// variable is valid and if so, add the appropriate target_* values from
- // the tested profile.
+ // the tested profile. Use testImageProfile value as backup.
if (input.profile == "run-test-prebuilt") {
- if (profiles[testedProfile] == null) {
- error("testedProfile is not defined: " + testedProfile);
+ if (profiles[testedProfile] == null && profiles[testImageProfile] == null) {
+ error("testedProfile is not defined: " + testedProfile + " " + testImageProfile);
}
}
if (profiles[testedProfile] != null) {
@@ -882,6 +886,11 @@
= profiles[testedProfile]["target_os"];
testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_cpu"]
= profiles[testedProfile]["target_cpu"];
+ } else if (profiles[testImageProfile] != null) {
+ testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_os"]
+ = profiles[testImageProfile]["target_os"];
+ testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_cpu"]
+ = profiles[testImageProfile]["target_cpu"];
}
profiles = concatObjects(profiles, testOnlyProfilesPrebuilt);
@@ -1346,3 +1355,8 @@
|| (input.build_os == "linux"
&& java.lang.System.getProperty("os.version").contains("Microsoft")));
}
+
+var error = function (s) {
+ java.lang.System.err.println("[ERROR] " + s);
+ exit(1);
+};
--- a/make/hotspot/gensrc/GensrcAdlc.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/hotspot/gensrc/GensrcAdlc.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -75,7 +75,6 @@
OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc, \
DEBUG_SYMBOLS := false, \
DISABLED_WARNINGS_clang := tautological-compare, \
- DISABLED_WARNINGS_solstudio := notemsource, \
DEFINE_THIS_FILE := false, \
))
--- a/make/hotspot/lib/CompileJvm.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/hotspot/lib/CompileJvm.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -78,14 +78,14 @@
################################################################################
# Disabled warnings
-DISABLED_WARNINGS_gcc := extra parentheses comment unknown-pragmas address \
+DISABLED_WARNINGS_gcc := parentheses comment unknown-pragmas address \
delete-non-virtual-dtor char-subscripts array-bounds int-in-bool-context \
ignored-qualifiers missing-field-initializers implicit-fallthrough \
empty-body strict-overflow sequence-point maybe-uninitialized \
- misleading-indentation
+ misleading-indentation cast-function-type
ifeq ($(call check-jvm-feature, zero), true)
- DISABLED_WARNINGS_gcc += return-type switch
+ DISABLED_WARNINGS_gcc += return-type switch clobbered
endif
DISABLED_WARNINGS_clang := tautological-compare \
--- a/make/hotspot/symbols/symbols-unix Sat Oct 26 23:59:51 2019 +0200
+++ b/make/hotspot/symbols/symbols-unix Mon Oct 28 18:43:04 2019 +0100
@@ -97,6 +97,7 @@
JVM_GetDeclaredClasses
JVM_GetDeclaringClass
JVM_GetEnclosingMethodInfo
+JVM_GetExtendedNPEMessage
JVM_GetFieldIxModifiers
JVM_GetFieldTypeAnnotations
JVM_GetInheritedAccessControlContext
--- a/make/jdk/src/classes/build/tools/taglet/ModuleGraph.java Sat Oct 26 23:59:51 2019 +0200
+++ b/make/jdk/src/classes/build/tools/taglet/ModuleGraph.java Mon Oct 28 18:43:04 2019 +0100
@@ -64,7 +64,7 @@
}
String moduleName = ((ModuleElement) element).getQualifiedName().toString();
- String imageFile = "module-graph.png";
+ String imageFile = "module-graph.svg";
int thumbnailHeight = -1;
String hoverImage = "";
if (!moduleName.equals("java.base")) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make/jdk/src/classes/build/tools/taglet/Preview.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2019, 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.
+ */
+
+package build.tools.taglet;
+
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Predicate;
+import javax.lang.model.element.Element;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.TextTree;
+import com.sun.source.doctree.UnknownInlineTagTree;
+import jdk.javadoc.doclet.Taglet;
+import static jdk.javadoc.doclet.Taglet.Location.*;
+
+/**
+ * An block tag to insert a standard warning about a preview API.
+ */
+public class Preview implements Taglet {
+
+ /** Returns the set of locations in which a taglet may be used. */
+ @Override
+ public Set<Location> getAllowedLocations() {
+ return EnumSet.of(MODULE, PACKAGE, TYPE, CONSTRUCTOR, METHOD, FIELD);
+ }
+
+ @Override
+ public boolean isInlineTag() {
+ return true;
+ }
+
+ @Override
+ public String getName() {
+ return "preview";
+ }
+
+ @Override
+ public String toString(List<? extends DocTree> tags, Element elem) {
+ UnknownInlineTagTree previewTag = (UnknownInlineTagTree) tags.get(0);
+ List<? extends DocTree> previewContent = previewTag.getContent();
+ String previewText = ((TextTree) previewContent.get(0)).getBody();
+ String[] summaryAndDetails = previewText.split("\n\r?\n\r?");
+ String summary = summaryAndDetails[0];
+ String details = summaryAndDetails.length > 1 ? summaryAndDetails[1] : summaryAndDetails[0];
+ StackTraceElement[] stackTrace = new Exception().getStackTrace();
+ Predicate<StackTraceElement> isSummary =
+ el -> el.getClassName().endsWith("HtmlDocletWriter") &&
+ el.getMethodName().equals("addSummaryComment");
+ if (Arrays.stream(stackTrace).anyMatch(isSummary)) {
+ return "<div style=\"display:inline-block; font-weight:bold\">" + summary + "</div><br>";
+ }
+ return "<div style=\"border: 1px solid red; border-radius: 5px; padding: 5px; display:inline-block; font-size: larger\">" + details + "</div><br>";
+ }
+}
+
--- a/make/launcher/Launcher-jdk.pack.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/launcher/Launcher-jdk.pack.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -87,6 +87,7 @@
CFLAGS_solaris := -KPIC, \
CFLAGS_macosx := -fPIC, \
DISABLED_WARNINGS_clang := format-nonliteral, \
+ DISABLED_WARNINGS_solstudio := wunreachable, \
LDFLAGS := $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS := $(UNPACKEXE_LIBS) $(LIBCXX), \
--- a/make/lib/Awt2dLibraries.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/lib/Awt2dLibraries.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -229,7 +229,6 @@
format-nonliteral parentheses unused-value unused-function, \
DISABLED_WARNINGS_clang := logical-op-parentheses extern-initializer \
sign-compare format-nonliteral, \
- DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \
DISABLED_WARNINGS_microsoft := 4244 4267 4996, \
ASFLAGS := $(LIBAWT_ASFLAGS), \
LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \
@@ -339,8 +338,8 @@
implicit-fallthrough undef unused-function, \
DISABLED_WARNINGS_clang := parentheses format undef \
logical-op-parentheses format-nonliteral int-conversion, \
- DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE \
- E_ASSIGNMENT_TYPE_MISMATCH E_NON_CONST_INIT, \
+ DISABLED_WARNINGS_solstudio := E_ASSIGNMENT_TYPE_MISMATCH \
+ E_NON_CONST_INIT, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN) \
-L$(INSTALL_LIBRARIES_HERE), \
@@ -620,7 +619,8 @@
E_ENUM_VAL_OVERFLOWS_INT_MAX, \
DISABLED_WARNINGS_CXX_solstudio := \
truncwarn wvarhidenmem wvarhidemem wbadlkginit identexpected \
- hidevf w_novirtualdescr arrowrtn2 refmemnoconstr_aggr unknownpragma, \
+ hidevf w_novirtualdescr arrowrtn2 refmemnoconstr_aggr unknownpragma \
+ doubunder wunreachable, \
DISABLED_WARNINGS_microsoft := 4267 4244 4018 4090 4996 4146 4334 4819 4101 4068 4805 4138, \
LDFLAGS := $(subst -Xlinker -z -Xlinker defs,, \
$(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB))) $(LDFLAGS_CXX_JDK) \
@@ -848,8 +848,7 @@
maybe-uninitialized shift-negative-value implicit-fallthrough \
unused-function, \
DISABLED_WARNINGS_clang := incompatible-pointer-types sign-compare, \
- DISABLED_WARNINGS_solstudio := E_NEWLINE_NOT_LAST E_DECLARATION_IN_CODE \
- E_STATEMENT_NOT_REACHED, \
+ DISABLED_WARNINGS_solstudio := E_STATEMENT_NOT_REACHED, \
DISABLED_WARNINGS_microsoft := 4018 4244 4267, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/make/lib/CoreLibraries.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/lib/CoreLibraries.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -212,9 +212,6 @@
CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \
DISABLED_WARNINGS_gcc := unused-function, \
DISABLED_WARNINGS_clang := sometimes-uninitialized format-nonliteral, \
- DISABLED_WARNINGS_solstudio := \
- E_ASM_DISABLES_OPTIMIZATION \
- E_STATEMENT_NOT_REACHED, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS_unix := $(LIBZ_LIBS), \
--- a/make/lib/Lib-jdk.hotspot.agent.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/lib/Lib-jdk.hotspot.agent.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -61,7 +61,7 @@
DISABLED_WARNINGS_microsoft := 4267, \
DISABLED_WARNINGS_gcc := sign-compare pointer-arith, \
DISABLED_WARNINGS_clang := sign-compare pointer-arith format-nonliteral, \
- DISABLED_WARNINGS_CXX_solstudio := truncwarn unknownpragma, \
+ DISABLED_WARNINGS_CXX_solstudio := truncwarn unknownpragma doubunder, \
CFLAGS := $(CFLAGS_JDKLIB) $(SA_CFLAGS), \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(SA_CFLAGS) $(SA_CXXFLAGS), \
EXTRA_SRC := $(LIBSA_EXTRA_SRC), \
--- a/make/lib/Lib-jdk.pack.gmk Sat Oct 26 23:59:51 2019 +0200
+++ b/make/lib/Lib-jdk.pack.gmk Mon Oct 28 18:43:04 2019 +0100
@@ -38,6 +38,7 @@
EXTRA_HEADER_DIRS := $(call GetJavaHeaderDir, java.base), \
DISABLED_WARNINGS_gcc := implicit-fallthrough, \
DISABLED_WARNINGS_clang := format-nonliteral, \
+ DISABLED_WARNINGS_solstudio := wunreachable, \
LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_windows := -map:$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpack.map -debug, \
--- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -58,7 +58,7 @@
Address gc_state(rthread, in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
__ ldrb(rscratch1, gc_state);
if (dest_uninitialized) {
- __ tbz(rscratch2, ShenandoahHeap::HAS_FORWARDED_BITPOS, done);
+ __ tbz(rscratch1, ShenandoahHeap::HAS_FORWARDED_BITPOS, done);
} else {
__ mov(rscratch2, ShenandoahHeap::HAS_FORWARDED | ShenandoahHeap::MARKING);
__ tst(rscratch1, rscratch2);
@@ -262,7 +262,7 @@
__ leave();
}
-void ShenandoahBarrierSetAssembler::load_reference_barrier_native(MacroAssembler* masm, Register dst, Register tmp) {
+void ShenandoahBarrierSetAssembler::load_reference_barrier_native(MacroAssembler* masm, Register dst, Address load_addr) {
if (!ShenandoahLoadRefBarrier) {
return;
}
@@ -272,6 +272,8 @@
Label is_null;
Label done;
+ __ block_comment("load_reference_barrier_native { ");
+
__ cbz(dst, is_null);
__ enter();
@@ -285,6 +287,7 @@
__ mov(rscratch2, dst);
__ push_call_clobbered_registers();
__ mov(lr, CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native));
+ __ lea(r1, load_addr);
__ mov(r0, rscratch2);
__ blr(lr);
__ mov(rscratch2, r0);
@@ -294,6 +297,7 @@
__ bind(done);
__ leave();
__ bind(is_null);
+ __ block_comment("} load_reference_barrier_native");
}
void ShenandoahBarrierSetAssembler::storeval_barrier(MacroAssembler* masm, Register dst, Register tmp) {
@@ -327,20 +331,32 @@
bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0;
bool on_reference = on_weak || on_phantom;
- bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0;
+ bool is_traversal_mode = ShenandoahHeap::heap()->is_traversal_mode();
+ bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0 || is_traversal_mode;
+
+ Register result_dst = dst;
+
+ if (on_oop) {
+ // We want to preserve src
+ if (dst == src.base() || dst == src.index()) {
+ dst = rscratch1;
+ }
+ assert_different_registers(dst, src.base(), src.index());
+ }
BarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp_thread);
if (on_oop) {
- if (not_in_heap) {
- if (ShenandoahHeap::heap()->is_traversal_mode()) {
- load_reference_barrier(masm, dst, tmp1);
- keep_alive = true;
- } else {
- load_reference_barrier_native(masm, dst, tmp1);
- }
- } else {
- load_reference_barrier(masm, dst, tmp1);
- }
+ if (not_in_heap && !is_traversal_mode) {
+ load_reference_barrier_native(masm, dst, src);
+ } else {
+ load_reference_barrier(masm, dst, tmp1);
+ }
+
+ if (dst != result_dst) {
+ __ mov(result_dst, dst);
+ dst = result_dst;
+ }
+
if (ShenandoahKeepAliveBarrier && on_reference && keep_alive) {
__ enter();
satb_write_barrier_pre(masm /* masm */,
--- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -58,7 +58,7 @@
void resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst, Register tmp = noreg);
void load_reference_barrier(MacroAssembler* masm, Register dst, Register tmp);
void load_reference_barrier_not_null(MacroAssembler* masm, Register dst, Register tmp);
- void load_reference_barrier_native(MacroAssembler* masm, Register dst, Register tmp);
+ void load_reference_barrier_native(MacroAssembler* masm, Register dst, Address load_addr);
address generate_shenandoah_lrb(StubCodeGenerator* cgen);
--- a/src/hotspot/cpu/aarch64/gc/z/zGlobals_aarch64.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/aarch64/gc/z/zGlobals_aarch64.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -142,8 +142,7 @@
size_t ZPlatformAddressOffsetBits() {
const size_t min_address_offset_bits = 42; // 4TB
const size_t max_address_offset_bits = 44; // 16TB
- const size_t virtual_to_physical_ratio = 7; // 7:1
- const size_t address_offset = ZUtils::round_up_power_of_2(MaxHeapSize * virtual_to_physical_ratio);
+ const size_t address_offset = ZUtils::round_up_power_of_2(MaxHeapSize * ZVirtualToPhysicalRatio);
const size_t address_offset_bits = log2_intptr(address_offset);
return MIN2(MAX2(address_offset_bits, min_address_offset_bits), max_address_offset_bits);
}
--- a/src/hotspot/cpu/aarch64/gc/z/zGlobals_aarch64.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/aarch64/gc/z/zGlobals_aarch64.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -24,23 +24,13 @@
#ifndef CPU_AARCH64_GC_Z_ZGLOBALS_AARCH64_HPP
#define CPU_AARCH64_GC_Z_ZGLOBALS_AARCH64_HPP
-//
-// Page Allocation Tiers
-// ---------------------
-//
-// Page Type Page Size Object Size Limit Object Alignment
-// ------------------------------------------------------------------
-// Small 2M <= 265K <MinObjAlignmentInBytes>
-// Medium 32M <= 4M 4K
-// Large X*M > 4M 2M
-// ------------------------------------------------------------------
-//
const size_t ZPlatformGranuleSizeShift = 21; // 2MB
+const size_t ZPlatformHeapViews = 3;
const size_t ZPlatformNMethodDisarmedOffset = 4;
const size_t ZPlatformCacheLineSize = 64;
-uintptr_t ZPlatformAddressBase();
-size_t ZPlatformAddressOffsetBits();
-size_t ZPlatformAddressMetadataShift();
+uintptr_t ZPlatformAddressBase();
+size_t ZPlatformAddressOffsetBits();
+size_t ZPlatformAddressMetadataShift();
#endif // CPU_AARCH64_GC_Z_ZGLOBALS_AARCH64_HPP
--- a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -774,7 +774,7 @@
bool is_oop = type == T_OBJECT || type == T_ARRAY;
LIR_Opr result = new_register(type);
value.load_item();
- assert(type == T_INT || is_oop LP64_ONLY( || type == T_LONG ), "unexpected type");
+ assert(type == T_INT || is_oop || (type == T_LONG && VM_Version::supports_ldrexd()), "unexpected type");
LIR_Opr tmp = (UseCompressedOops && is_oop) ? new_pointer_register() : LIR_OprFact::illegalOpr;
__ xchg(addr, value.result(), result, tmp);
return result;
@@ -783,7 +783,7 @@
LIR_Opr LIRGenerator::atomic_add(BasicType type, LIR_Opr addr, LIRItem& value) {
LIR_Opr result = new_register(type);
value.load_item();
- assert(type == T_INT LP64_ONLY( || type == T_LONG), "unexpected type");
+ assert(type == T_INT || (type == T_LONG && VM_Version::supports_ldrexd ()), "unexpected type");
LIR_Opr tmp = new_register(type);
__ xadd(addr, value.result(), result, tmp);
return result;
--- a/src/hotspot/cpu/ppc/assembler_ppc.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/ppc/assembler_ppc.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -444,6 +444,9 @@
FDIV_OPCODE = (63u << OPCODE_SHIFT | 18u << 1),
FDIVS_OPCODE = (59u << OPCODE_SHIFT | 18u << 1),
FMR_OPCODE = (63u << OPCODE_SHIFT | 72u << 1),
+ FRIN_OPCODE = (63u << OPCODE_SHIFT | 392u << 1),
+ FRIP_OPCODE = (63u << OPCODE_SHIFT | 456u << 1),
+ FRIM_OPCODE = (63u << OPCODE_SHIFT | 488u << 1),
// These are special Power6 opcodes, reused for "lfdepx" and "stfdepx"
// on Power7. Do not use.
// MFFGPR_OPCODE = (31u << OPCODE_SHIFT | 607u << 1),
@@ -545,6 +548,9 @@
XVMSUBADP_OPCODE=(60u << OPCODE_SHIFT | 113u << 3),
XVNMSUBASP_OPCODE=(60u<< OPCODE_SHIFT | 209u << 3),
XVNMSUBADP_OPCODE=(60u<< OPCODE_SHIFT | 241u << 3),
+ XVRDPI_OPCODE = (60u << OPCODE_SHIFT | 201u << 2),
+ XVRDPIM_OPCODE = (60u << OPCODE_SHIFT | 249u << 2),
+ XVRDPIP_OPCODE = (60u << OPCODE_SHIFT | 233u << 2),
// Deliver A Random Number (introduced with POWER9)
DARN_OPCODE = (31u << OPCODE_SHIFT | 755u << 1),
@@ -1981,6 +1987,10 @@
inline void fmr( FloatRegister d, FloatRegister b);
inline void fmr_( FloatRegister d, FloatRegister b);
+ inline void frin( FloatRegister d, FloatRegister b);
+ inline void frip( FloatRegister d, FloatRegister b);
+ inline void frim( FloatRegister d, FloatRegister b);
+
// inline void mffgpr( FloatRegister d, Register b);
// inline void mftgpr( Register d, FloatRegister b);
inline void cmpb( Register a, Register s, Register b);
@@ -2241,6 +2251,9 @@
inline void xvmsubadp(VectorSRegister d, VectorSRegister a, VectorSRegister b);
inline void xvnmsubasp(VectorSRegister d, VectorSRegister a, VectorSRegister b);
inline void xvnmsubadp(VectorSRegister d, VectorSRegister a, VectorSRegister b);
+ inline void xvrdpi( VectorSRegister d, VectorSRegister b);
+ inline void xvrdpim( VectorSRegister d, VectorSRegister b);
+ inline void xvrdpip( VectorSRegister d, VectorSRegister b);
// VSX Extended Mnemonics
inline void xxspltd( VectorSRegister d, VectorSRegister a, int x);
--- a/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -675,6 +675,10 @@
inline void Assembler::fmr( FloatRegister d, FloatRegister b) { emit_int32( FMR_OPCODE | frt(d) | frb(b) | rc(0)); }
inline void Assembler::fmr_(FloatRegister d, FloatRegister b) { emit_int32( FMR_OPCODE | frt(d) | frb(b) | rc(1)); }
+inline void Assembler::frin( FloatRegister d, FloatRegister b) { emit_int32( FRIN_OPCODE | frt(d) | frb(b) | rc(0)); }
+inline void Assembler::frip( FloatRegister d, FloatRegister b) { emit_int32( FRIP_OPCODE | frt(d) | frb(b) | rc(0)); }
+inline void Assembler::frim( FloatRegister d, FloatRegister b) { emit_int32( FRIM_OPCODE | frt(d) | frb(b) | rc(0)); }
+
// These are special Power6 opcodes, reused for "lfdepx" and "stfdepx"
// on Power7. Do not use.
//inline void Assembler::mffgpr( FloatRegister d, Register b) { emit_int32( MFFGPR_OPCODE | frt(d) | rb(b) | rc(0)); }
@@ -796,6 +800,10 @@
inline void Assembler::xvmsubadp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMSUBADP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
inline void Assembler::xvnmsubasp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVNMSUBASP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
inline void Assembler::xvnmsubadp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVNMSUBADP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvrdpi( VectorSRegister d, VectorSRegister b) { emit_int32( XVRDPI_OPCODE | vsrt(d) | vsrb(b)); }
+inline void Assembler::xvrdpim( VectorSRegister d, VectorSRegister b) { emit_int32( XVRDPIM_OPCODE | vsrt(d) | vsrb(b)); }
+inline void Assembler::xvrdpip( VectorSRegister d, VectorSRegister b) { emit_int32( XVRDPIP_OPCODE | vsrt(d) | vsrb(b)); }
+
inline void Assembler::mtvrd( VectorRegister d, Register a) { emit_int32( MTVSRD_OPCODE | vsrt(d->to_vsr()) | ra(a)); }
inline void Assembler::mfvrd( Register a, VectorRegister d) { emit_int32( MFVSRD_OPCODE | vsrt(d->to_vsr()) | ra(a)); }
inline void Assembler::mtvrwz( VectorRegister d, Register a) { emit_int32( MTVSRWZ_OPCODE | vsrt(d->to_vsr()) | ra(a)); }
--- a/src/hotspot/cpu/ppc/ppc.ad Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/ppc/ppc.ad Mon Oct 28 18:43:04 2019 +0100
@@ -972,6 +972,8 @@
// To keep related declarations/definitions/uses close together,
// we switch between source %{ }% and source_hpp %{ }% freely as needed.
+#include "opto/convertnode.hpp"
+
// Returns true if Node n is followed by a MemBar node that
// will do an acquire. If so, this node must not do the acquire
// operation.
@@ -2272,6 +2274,7 @@
case Op_AddVL:
case Op_SubVL:
case Op_MulVI:
+ case Op_RoundDoubleModeV:
return SuperwordUseVSX;
case Op_PopCountVI:
return (SuperwordUseVSX && UsePopCountInstruction);
@@ -14454,6 +14457,53 @@
ins_pipe(pipe_class_default);
%}
+// Round Instructions
+instruct roundD_reg(regD dst, regD src, immI8 rmode) %{
+ match(Set dst (RoundDoubleMode src rmode));
+ format %{ "RoundDoubleMode $src,$rmode" %}
+ size(4);
+ ins_encode %{
+ switch ($rmode$$constant) {
+ case RoundDoubleModeNode::rmode_rint:
+ __ frin($dst$$FloatRegister, $src$$FloatRegister);
+ break;
+ case RoundDoubleModeNode::rmode_floor:
+ __ frim($dst$$FloatRegister, $src$$FloatRegister);
+ break;
+ case RoundDoubleModeNode::rmode_ceil:
+ __ frip($dst$$FloatRegister, $src$$FloatRegister);
+ break;
+ default:
+ ShouldNotReachHere();
+ }
+ %}
+ ins_pipe(pipe_class_default);
+%}
+
+// Vector Round Instructions
+instruct vround2D_reg(vecX dst, vecX src, immI8 rmode) %{
+ match(Set dst (RoundDoubleModeV src rmode));
+ predicate(n->as_Vector()->length() == 2);
+ format %{ "RoundDoubleModeV $src,$rmode" %}
+ size(4);
+ ins_encode %{
+ switch ($rmode$$constant) {
+ case RoundDoubleModeNode::rmode_rint:
+ __ xvrdpi($dst$$VectorSRegister, $src$$VectorSRegister);
+ break;
+ case RoundDoubleModeNode::rmode_floor:
+ __ xvrdpim($dst$$VectorSRegister, $src$$VectorSRegister);
+ break;
+ case RoundDoubleModeNode::rmode_ceil:
+ __ xvrdpip($dst$$VectorSRegister, $src$$VectorSRegister);
+ break;
+ default:
+ ShouldNotReachHere();
+ }
+ %}
+ ins_pipe(pipe_class_default);
+%}
+
// Vector Negate Instructions
instruct vneg4F_reg(vecX dst, vecX src) %{
--- a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -592,10 +592,10 @@
__ load_const_optimized(R4_ARG2, (address) name, R11_scratch1);
if (pass_oop) {
__ mr(R5_ARG3, Rexception);
- __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_klass_exception), false);
+ __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_klass_exception));
} else {
__ load_const_optimized(R5_ARG3, (address) message, R11_scratch1);
- __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_exception), false);
+ __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_exception));
}
// Throw exception.
@@ -2105,7 +2105,7 @@
// The member name argument must be restored if _invokestatic is re-executed after a PopFrame call.
// Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL.
__ ld(R4_ARG2, 0, R18_locals);
- __ MacroAssembler::call_VM(R4_ARG2, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), R4_ARG2, R19_method, R14_bcp, false);
+ __ call_VM(R4_ARG2, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), R4_ARG2, R19_method, R14_bcp);
__ restore_interpreter_state(R11_scratch1, /*bcp_and_mdx_only*/ true);
__ cmpdi(CCR0, R4_ARG2, 0);
__ beq(CCR0, L_done);
--- a/src/hotspot/cpu/s390/interp_masm_s390.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1072,8 +1072,7 @@
void InterpreterMacroAssembler::unlock_object(Register monitor, Register object) {
if (UseHeavyMonitors) {
- call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit),
- monitor, /*check_for_exceptions=*/ true);
+ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), monitor);
return;
}
@@ -1147,8 +1146,7 @@
// The lock has been converted into a heavy lock and hence
// we need to get into the slow case.
z_stg(object, obj_entry); // Restore object entry, has been cleared above.
- call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit),
- monitor, /*check_for_exceptions=*/false);
+ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), monitor);
// }
@@ -2095,7 +2093,7 @@
Label jvmti_post_done;
MacroAssembler::load_and_test_int(Z_R0, Address(Z_thread, JavaThread::interp_only_mode_offset()));
z_bre(jvmti_post_done);
- call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_entry), /*check_exceptions=*/false);
+ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_entry));
bind(jvmti_post_done);
}
}
@@ -2129,7 +2127,7 @@
MacroAssembler::load_and_test_int(Z_R0, Address(Z_thread, JavaThread::interp_only_mode_offset()));
z_bre(jvmti_post_done);
if (!native_method) push(state); // see frame::interpreter_frame_result()
- call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit), /*check_exceptions=*/false);
+ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit));
if (!native_method) pop(state);
bind(jvmti_post_done);
}
--- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -247,54 +247,6 @@
__ bind(done);
}
-void ShenandoahBarrierSetAssembler::resolve_forward_pointer(MacroAssembler* masm, Register dst, Register tmp) {
- assert(ShenandoahCASBarrier, "should be enabled");
- Label is_null;
- __ testptr(dst, dst);
- __ jcc(Assembler::zero, is_null);
- resolve_forward_pointer_not_null(masm, dst, tmp);
- __ bind(is_null);
-}
-
-void ShenandoahBarrierSetAssembler::resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst, Register tmp) {
- assert(ShenandoahCASBarrier || ShenandoahLoadRefBarrier, "should be enabled");
- // The below loads the mark word, checks if the lowest two bits are
- // set, and if so, clear the lowest two bits and copy the result
- // to dst. Otherwise it leaves dst alone.
- // Implementing this is surprisingly awkward. I do it here by:
- // - Inverting the mark word
- // - Test lowest two bits == 0
- // - If so, set the lowest two bits
- // - Invert the result back, and copy to dst
-
- bool borrow_reg = (tmp == noreg);
- if (borrow_reg) {
- // No free registers available. Make one useful.
- tmp = LP64_ONLY(rscratch1) NOT_LP64(rdx);
- if (tmp == dst) {
- tmp = LP64_ONLY(rscratch2) NOT_LP64(rcx);
- }
- __ push(tmp);
- }
-
- assert_different_registers(dst, tmp);
-
- Label done;
- __ movptr(tmp, Address(dst, oopDesc::mark_offset_in_bytes()));
- __ notptr(tmp);
- __ testb(tmp, markWord::marked_value);
- __ jccb(Assembler::notZero, done);
- __ orptr(tmp, markWord::marked_value);
- __ notptr(tmp);
- __ mov(dst, tmp);
- __ bind(done);
-
- if (borrow_reg) {
- __ pop(tmp);
- }
-}
-
-
void ShenandoahBarrierSetAssembler::load_reference_barrier_not_null(MacroAssembler* masm, Register dst) {
assert(ShenandoahLoadRefBarrier, "Should be enabled");
@@ -333,7 +285,7 @@
#endif
}
-void ShenandoahBarrierSetAssembler::load_reference_barrier_native(MacroAssembler* masm, Register dst) {
+void ShenandoahBarrierSetAssembler::load_reference_barrier_native(MacroAssembler* masm, Register dst, Address src) {
if (!ShenandoahLoadRefBarrier) {
return;
}
@@ -341,6 +293,7 @@
Label done;
Label not_null;
Label slow_path;
+ __ block_comment("load_reference_barrier_native { ");
// null check
__ testptr(dst, dst);
@@ -371,7 +324,7 @@
__ bind(slow_path);
if (dst != rax) {
- __ xchgptr(dst, rax); // Move obj into rax and save rax into obj.
+ __ push(rax);
}
__ push(rcx);
__ push(rdx);
@@ -388,8 +341,9 @@
__ push(r15);
#endif
- __ movptr(rdi, rax);
- __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native), rdi);
+ assert_different_registers(dst, rsi);
+ __ lea(rsi, src);
+ __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native), dst, rsi);
#ifdef _LP64
__ pop(r15);
@@ -407,10 +361,12 @@
__ pop(rcx);
if (dst != rax) {
- __ xchgptr(rax, dst); // Swap back obj with rax.
+ __ movptr(dst, rax);
+ __ pop(rax);
}
__ bind(done);
+ __ block_comment("load_reference_barrier_native { ");
}
void ShenandoahBarrierSetAssembler::storeval_barrier(MacroAssembler* masm, Register dst, Register tmp) {
@@ -474,14 +430,43 @@
bool is_traversal_mode = ShenandoahHeap::heap()->is_traversal_mode();
bool keep_alive = ((decorators & AS_NO_KEEPALIVE) == 0) || is_traversal_mode;
+ Register result_dst = dst;
+ bool use_tmp1_for_dst = false;
+
+ if (on_oop) {
+ // We want to preserve src
+ if (dst == src.base() || dst == src.index()) {
+ // Use tmp1 for dst if possible, as it is not used in BarrierAssembler::load_at()
+ if (tmp1->is_valid() && tmp1 != src.base() && tmp1 != src.index()) {
+ dst = tmp1;
+ use_tmp1_for_dst = true;
+ } else {
+ dst = rdi;
+ __ push(dst);
+ }
+ }
+ assert_different_registers(dst, src.base(), src.index());
+ }
+
BarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp_thread);
+
if (on_oop) {
if (not_in_heap && !is_traversal_mode) {
- load_reference_barrier_native(masm, dst);
+ load_reference_barrier_native(masm, dst, src);
} else {
load_reference_barrier(masm, dst);
}
+ if (dst != result_dst) {
+ __ movptr(result_dst, dst);
+
+ if (!use_tmp1_for_dst) {
+ __ pop(dst);
+ }
+
+ dst = result_dst;
+ }
+
if (ShenandoahKeepAliveBarrier && on_reference && keep_alive) {
const Register thread = NOT_LP64(tmp_thread) LP64_ONLY(r15_thread);
assert_different_registers(dst, tmp1, tmp_thread);
@@ -572,8 +557,9 @@
bool exchange, Register tmp1, Register tmp2) {
assert(ShenandoahCASBarrier, "Should only be used when CAS barrier is enabled");
assert(oldval == rax, "must be in rax for implicit use in cmpxchg");
+ assert_different_registers(oldval, newval, tmp1, tmp2);
- Label retry, done;
+ Label L_success, L_failure;
// Remember oldval for retry logic below
#ifdef _LP64
@@ -585,8 +571,10 @@
__ movptr(tmp1, oldval);
}
- // Step 1. Try to CAS with given arguments. If successful, then we are done,
- // and can safely return.
+ // Step 1. Fast-path.
+ //
+ // Try to CAS with given arguments. If successful, then we are done.
+
if (os::is_MP()) __ lock();
#ifdef _LP64
if (UseCompressedOops) {
@@ -596,21 +584,32 @@
{
__ cmpxchgptr(newval, addr);
}
- __ jcc(Assembler::equal, done, true);
+ __ jcc(Assembler::equal, L_success);
// Step 2. CAS had failed. This may be a false negative.
//
// The trouble comes when we compare the to-space pointer with the from-space
- // pointer to the same object. To resolve this, it will suffice to resolve both
- // oldval and the value from memory -- this will give both to-space pointers.
+ // pointer to the same object. To resolve this, it will suffice to resolve
+ // the value from memory -- this will give both to-space pointers.
// If they mismatch, then it was a legitimate failure.
//
+ // Before reaching to resolve sequence, see if we can avoid the whole shebang
+ // with filters.
+
+ // Filter: when offending in-memory value is NULL, the failure is definitely legitimate
+ __ testptr(oldval, oldval);
+ __ jcc(Assembler::zero, L_failure);
+
+ // Filter: when heap is stable, the failure is definitely legitimate
#ifdef _LP64
- if (UseCompressedOops) {
- __ decode_heap_oop(tmp1);
- }
+ const Register thread = r15_thread;
+#else
+ const Register thread = tmp2;
+ __ get_thread(thread);
#endif
- resolve_forward_pointer(masm, tmp1);
+ Address gc_state(thread, in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
+ __ testb(gc_state, ShenandoahHeap::HAS_FORWARDED);
+ __ jcc(Assembler::zero, L_failure);
#ifdef _LP64
if (UseCompressedOops) {
@@ -621,18 +620,70 @@
{
__ movptr(tmp2, oldval);
}
- resolve_forward_pointer(masm, tmp2);
+
+ // Decode offending in-memory value.
+ // Test if-forwarded
+ __ testb(Address(tmp2, oopDesc::mark_offset_in_bytes()), markWord::marked_value);
+ __ jcc(Assembler::noParity, L_failure); // When odd number of bits, then not forwarded
+ __ jcc(Assembler::zero, L_failure); // When it is 00, then also not forwarded
+
+ // Load and mask forwarding pointer
+ __ movptr(tmp2, Address(tmp2, oopDesc::mark_offset_in_bytes()));
+ __ shrptr(tmp2, 2);
+ __ shlptr(tmp2, 2);
+#ifdef _LP64
+ if (UseCompressedOops) {
+ __ decode_heap_oop(tmp1); // decode for comparison
+ }
+#endif
+
+ // Now we have the forwarded offender in tmp2.
+ // Compare and if they don't match, we have legitimate failure
__ cmpptr(tmp1, tmp2);
- __ jcc(Assembler::notEqual, done, true);
+ __ jcc(Assembler::notEqual, L_failure);
+
+ // Step 3. Need to fix the memory ptr before continuing.
+ //
+ // At this point, we have from-space oldval in the register, and its to-space
+ // address is in tmp2. Let's try to update it into memory. We don't care if it
+ // succeeds or not. If it does, then the retrying CAS would see it and succeed.
+ // If this fixup fails, this means somebody else beat us to it, and necessarily
+ // with to-space ptr store. We still have to do the retry, because the GC might
+ // have updated the reference for us.
- // Step 3. Try to CAS again with resolved to-space pointers.
+#ifdef _LP64
+ if (UseCompressedOops) {
+ __ encode_heap_oop(tmp2); // previously decoded at step 2.
+ }
+#endif
+
+ if (os::is_MP()) __ lock();
+#ifdef _LP64
+ if (UseCompressedOops) {
+ __ cmpxchgl(tmp2, addr);
+ } else
+#endif
+ {
+ __ cmpxchgptr(tmp2, addr);
+ }
+
+ // Step 4. Try to CAS again.
//
- // Corner case: it may happen that somebody stored the from-space pointer
- // to memory while we were preparing for retry. Therefore, we can fail again
- // on retry, and so need to do this in loop, always resolving the failure
- // witness.
- __ bind(retry);
+ // This is guaranteed not to have false negatives, because oldval is definitely
+ // to-space, and memory pointer is to-space as well. Nothing is able to store
+ // from-space ptr into memory anymore. Make sure oldval is restored, after being
+ // garbled during retries.
+ //
+#ifdef _LP64
+ if (UseCompressedOops) {
+ __ movl(oldval, tmp2);
+ } else
+#endif
+ {
+ __ movptr(oldval, tmp2);
+ }
+
if (os::is_MP()) __ lock();
#ifdef _LP64
if (UseCompressedOops) {
@@ -642,41 +693,28 @@
{
__ cmpxchgptr(newval, addr);
}
- __ jcc(Assembler::equal, done, true);
+ if (!exchange) {
+ __ jccb(Assembler::equal, L_success); // fastpath, peeking into Step 5, no need to jump
+ }
-#ifdef _LP64
- if (UseCompressedOops) {
- __ movl(tmp2, oldval);
- __ decode_heap_oop(tmp2);
- } else
-#endif
- {
- __ movptr(tmp2, oldval);
- }
- resolve_forward_pointer(masm, tmp2);
-
- __ cmpptr(tmp1, tmp2);
- __ jcc(Assembler::equal, retry, true);
+ // Step 5. If we need a boolean result out of CAS, set the flag appropriately.
+ // and promote the result. Note that we handle the flag from both the 1st and 2nd CAS.
+ // Otherwise, failure witness for CAE is in oldval on all paths, and we can return.
- // Step 4. If we need a boolean result out of CAS, check the flag again,
- // and promote the result. Note that we handle the flag from both the CAS
- // itself and from the retry loop.
- __ bind(done);
- if (!exchange) {
+ if (exchange) {
+ __ bind(L_failure);
+ __ bind(L_success);
+ } else {
assert(res != NULL, "need result register");
-#ifdef _LP64
- __ setb(Assembler::equal, res);
- __ movzbl(res, res);
-#else
- // Need something else to clean the result, because some registers
- // do not have byte encoding that movzbl wants. Cannot do the xor first,
- // because it modifies the flags.
- Label res_non_zero;
+
+ Label exit;
+ __ bind(L_failure);
+ __ xorptr(res, res);
+ __ jmpb(exit);
+
+ __ bind(L_success);
__ movptr(res, 1);
- __ jcc(Assembler::equal, res_non_zero, true);
- __ xorptr(res, res);
- __ bind(res_non_zero);
-#endif
+ __ bind(exit);
}
}
--- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -55,9 +55,6 @@
bool tosca_live,
bool expand_call);
- void resolve_forward_pointer(MacroAssembler* masm, Register dst, Register tmp = noreg);
- void resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst, Register tmp = noreg);
-
void load_reference_barrier_not_null(MacroAssembler* masm, Register dst);
void storeval_barrier_impl(MacroAssembler* masm, Register dst, Register tmp);
@@ -76,7 +73,7 @@
#endif
void load_reference_barrier(MacroAssembler* masm, Register dst);
- void load_reference_barrier_native(MacroAssembler* masm, Register dst);
+ void load_reference_barrier_native(MacroAssembler* masm, Register dst, Address src);
void cmpxchg_oop(MacroAssembler* masm,
Register res, Address addr, Register oldval, Register newval,
--- a/src/hotspot/cpu/x86/gc/z/zGlobals_x86.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/x86/gc/z/zGlobals_x86.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -142,8 +142,7 @@
size_t ZPlatformAddressOffsetBits() {
const size_t min_address_offset_bits = 42; // 4TB
const size_t max_address_offset_bits = 44; // 16TB
- const size_t virtual_to_physical_ratio = 7; // 7:1
- const size_t address_offset = ZUtils::round_up_power_of_2(MaxHeapSize * virtual_to_physical_ratio);
+ const size_t address_offset = ZUtils::round_up_power_of_2(MaxHeapSize * ZVirtualToPhysicalRatio);
const size_t address_offset_bits = log2_intptr(address_offset);
return MIN2(MAX2(address_offset_bits, min_address_offset_bits), max_address_offset_bits);
}
--- a/src/hotspot/cpu/x86/gc/z/zGlobals_x86.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/x86/gc/z/zGlobals_x86.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -24,23 +24,13 @@
#ifndef CPU_X86_GC_Z_ZGLOBALS_X86_HPP
#define CPU_X86_GC_Z_ZGLOBALS_X86_HPP
-//
-// Page Allocation Tiers
-// ---------------------
-//
-// Page Type Page Size Object Size Limit Object Alignment
-// ------------------------------------------------------------------
-// Small 2M <= 265K <MinObjAlignmentInBytes>
-// Medium 32M <= 4M 4K
-// Large X*M > 4M 2M
-// ------------------------------------------------------------------
-//
const size_t ZPlatformGranuleSizeShift = 21; // 2MB
+const size_t ZPlatformHeapViews = 3;
const size_t ZPlatformNMethodDisarmedOffset = 4;
const size_t ZPlatformCacheLineSize = 64;
-uintptr_t ZPlatformAddressBase();
-size_t ZPlatformAddressOffsetBits();
-size_t ZPlatformAddressMetadataShift();
+uintptr_t ZPlatformAddressBase();
+size_t ZPlatformAddressOffsetBits();
+size_t ZPlatformAddressMetadataShift();
#endif // CPU_X86_GC_Z_ZGLOBALS_X86_HPP
--- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -114,7 +114,8 @@
// short offset operators (jmp and jcc)
char* disp = (char*) &branch[1];
int imm8 = target - (address) &disp[1];
- guarantee(this->is8bit(imm8), "Short forward jump exceeds 8-bit offset at %s:%d", file, line);
+ guarantee(this->is8bit(imm8), "Short forward jump exceeds 8-bit offset at %s:%d",
+ file == NULL ? "<NULL>" : file, line);
*disp = imm8;
} else {
int* disp = (int*) &branch[(op == 0x0F || op == 0xC7)? 2: 1];
--- a/src/hotspot/cpu/x86/x86.ad Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/cpu/x86/x86.ad Mon Oct 28 18:43:04 2019 +0100
@@ -1280,7 +1280,7 @@
case Op_AbsVS:
case Op_AbsVI:
case Op_AddReductionVI:
- if (UseSSE < 3) // requires at least SSE3
+ if (UseSSE < 3 || !VM_Version::supports_ssse3()) // requires at least SSSE3
ret_value = false;
break;
case Op_MulReductionVI:
--- a/src/hotspot/os/aix/os_aix.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/aix/os_aix.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1034,8 +1034,6 @@
}
bool os::supports_vtime() { return true; }
-bool os::enable_vtime() { return false; }
-bool os::vtime_enabled() { return false; }
double os::elapsedVTime() {
struct rusage usage;
@@ -3625,11 +3623,6 @@
return;
}
-bool os::distribute_processes(uint length, uint* distribution) {
- // Not yet implemented.
- return false;
-}
-
bool os::bind_to_processor(uint processor_id) {
// Not yet implemented.
return false;
--- a/src/hotspot/os/aix/os_aix.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/aix/os_aix.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -44,7 +44,6 @@
static julong _physical_memory;
static pthread_t _main_thread;
- static Mutex* _createThread_lock;
static int _page_size;
// -1 = uninitialized, 0 = AIX, 1 = OS/400 (PASE)
@@ -90,8 +89,6 @@
public:
static void init_thread_fpu_state();
static pthread_t main_thread(void) { return _main_thread; }
- static void set_createThread_lock(Mutex* lk) { _createThread_lock = lk; }
- static Mutex* createThread_lock(void) { return _createThread_lock; }
static void hotspot_sigmask(Thread* thread);
// Given an address, returns the size of the page backing that address
--- a/src/hotspot/os/aix/os_aix.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/aix/os_aix.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -64,8 +64,6 @@
::dlclose(lib);
}
-inline const int os::default_file_open_flags() { return 0;}
-
inline jlong os::lseek(int fd, jlong offset, int whence) {
return (jlong) ::lseek64(fd, offset, whence);
}
--- a/src/hotspot/os/bsd/os_bsd.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/bsd/os_bsd.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -877,8 +877,6 @@
}
bool os::supports_vtime() { return true; }
-bool os::enable_vtime() { return false; }
-bool os::vtime_enabled() { return false; }
double os::elapsedVTime() {
// better than nothing, but not much
@@ -3282,11 +3280,6 @@
#endif
}
-bool os::distribute_processes(uint length, uint* distribution) {
- // Not yet implemented.
- return false;
-}
-
bool os::bind_to_processor(uint processor_id) {
// Not yet implemented.
return false;
--- a/src/hotspot/os/bsd/os_bsd.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/bsd/os_bsd.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -67,8 +67,6 @@
::dlclose(lib);
}
-inline const int os::default_file_open_flags() { return 0;}
-
inline jlong os::lseek(int fd, jlong offset, int whence) {
return (jlong) ::lseek(fd, offset, whence);
}
--- a/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -22,7 +22,7 @@
*/
#include "gc/z/zErrno.hpp"
-#include "gc/z/zCPU.hpp"
+#include "gc/z/zCPU.inline.hpp"
#include "gc/z/zNUMA.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
--- a/src/hotspot/os/linux/osContainer_linux.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/linux/osContainer_linux.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -131,14 +131,34 @@
* hierarchy. If set to true consider also memory.stat
* file if everything else seems unlimited */
bool _uses_mem_hierarchy;
+ volatile jlong _memory_limit_in_bytes;
+ volatile jlong _next_check_counter;
public:
CgroupMemorySubsystem(char *root, char *mountpoint) : CgroupSubsystem::CgroupSubsystem(root, mountpoint) {
_uses_mem_hierarchy = false;
+ _memory_limit_in_bytes = -1;
+ _next_check_counter = min_jlong;
+
}
bool is_hierarchical() { return _uses_mem_hierarchy; }
void set_hierarchical(bool value) { _uses_mem_hierarchy = value; }
+
+ bool should_check_memory_limit() {
+ return os::elapsed_counter() > _next_check_counter;
+ }
+ jlong memory_limit_in_bytes() { return _memory_limit_in_bytes; }
+ void set_memory_limit_in_bytes(jlong value) {
+ _memory_limit_in_bytes = value;
+ // max memory limit is unlikely to change, but we want to remain
+ // responsive to configuration changes. A very short (20ms) grace time
+ // between re-read avoids excessive overhead during startup without
+ // significantly reducing the VMs ability to promptly react to reduced
+ // memory availability
+ _next_check_counter = os::elapsed_counter() + (NANOSECS_PER_SEC/50);
+ }
+
};
CgroupMemorySubsystem* memory = NULL;
@@ -461,6 +481,16 @@
* OSCONTAINER_ERROR for not supported
*/
jlong OSContainer::memory_limit_in_bytes() {
+ if (!memory->should_check_memory_limit()) {
+ return memory->memory_limit_in_bytes();
+ }
+ jlong memory_limit = read_memory_limit_in_bytes();
+ // Update CgroupMemorySubsystem to avoid re-reading container settings too often
+ memory->set_memory_limit_in_bytes(memory_limit);
+ return memory_limit;
+}
+
+jlong OSContainer::read_memory_limit_in_bytes() {
GET_CONTAINER_INFO(julong, memory, "/memory.limit_in_bytes",
"Memory Limit is: " JULONG_FORMAT, JULONG_FORMAT, memlimit);
--- a/src/hotspot/os/linux/osContainer_linux.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/linux/osContainer_linux.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -36,6 +36,7 @@
private:
static bool _is_initialized;
static bool _is_containerized;
+ static jlong read_memory_limit_in_bytes();
public:
static void init();
--- a/src/hotspot/os/linux/os_linux.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/linux/os_linux.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -148,11 +148,9 @@
int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
int (*os::Linux::_pthread_setname_np)(pthread_t, const char*) = NULL;
-Mutex* os::Linux::_createThread_lock = NULL;
pthread_t os::Linux::_main_thread;
int os::Linux::_page_size = -1;
bool os::Linux::_supports_fast_thread_cpu_time = false;
-uint32_t os::Linux::_os_version = 0;
const char * os::Linux::_glibc_version = NULL;
const char * os::Linux::_libpthread_version = NULL;
@@ -1364,8 +1362,6 @@
}
bool os::supports_vtime() { return true; }
-bool os::enable_vtime() { return false; }
-bool os::vtime_enabled() { return false; }
double os::elapsedVTime() {
struct rusage usage;
@@ -4823,48 +4819,6 @@
return (tp.tv_sec * NANOSECS_PER_SEC) + tp.tv_nsec;
}
-void os::Linux::initialize_os_info() {
- assert(_os_version == 0, "OS info already initialized");
-
- struct utsname _uname;
-
- uint32_t major;
- uint32_t minor;
- uint32_t fix;
-
- int rc;
-
- // Kernel version is unknown if
- // verification below fails.
- _os_version = 0x01000000;
-
- rc = uname(&_uname);
- if (rc != -1) {
-
- rc = sscanf(_uname.release,"%d.%d.%d", &major, &minor, &fix);
- if (rc == 3) {
-
- if (major < 256 && minor < 256 && fix < 256) {
- // Kernel version format is as expected,
- // set it overriding unknown state.
- _os_version = (major << 16) |
- (minor << 8 ) |
- (fix << 0 ) ;
- }
- }
- }
-}
-
-uint32_t os::Linux::os_version() {
- assert(_os_version != 0, "not initialized");
- return _os_version & 0x00FFFFFF;
-}
-
-bool os::Linux::os_version_is_known() {
- assert(_os_version != 0, "not initialized");
- return _os_version & 0x01000000 ? false : true;
-}
-
/////
// glibc on Linux platform uses non-documented flag
// to indicate, that some special sort of signal
@@ -5084,8 +5038,6 @@
Linux::initialize_system_info();
- Linux::initialize_os_info();
-
os::Linux::CPUPerfTicks pticks;
bool res = os::Linux::get_tick_information(&pticks, -1);
@@ -5262,9 +5214,6 @@
}
}
- // Initialize lock used to serialize thread creation (see os::create_thread)
- Linux::set_createThread_lock(new Mutex(Mutex::leaf, "createThread_lock", false));
-
// at-exit methods are called in the reverse order of their registration.
// atexit functions are called on return from main or as a result of a
// call to exit(3C). There can be only 32 of these functions registered
@@ -5465,11 +5414,6 @@
}
}
-bool os::distribute_processes(uint length, uint* distribution) {
- // Not yet implemented.
- return false;
-}
-
bool os::bind_to_processor(uint processor_id) {
// Not yet implemented.
return false;
--- a/src/hotspot/os/linux/os_linux.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/linux/os_linux.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -55,20 +55,10 @@
static GrowableArray<int>* _cpu_to_node;
static GrowableArray<int>* _nindex_to_node;
- // 0x00000000 = uninitialized,
- // 0x01000000 = kernel version unknown,
- // otherwise a 32-bit number:
- // Ox00AABBCC
- // AA, Major Version
- // BB, Minor Version
- // CC, Fix Version
- static uint32_t _os_version;
-
protected:
static julong _physical_memory;
static pthread_t _main_thread;
- static Mutex* _createThread_lock;
static int _page_size;
static julong available_memory();
@@ -136,8 +126,6 @@
// returns kernel thread id (similar to LWP id on Solaris), which can be
// used to access /proc
static pid_t gettid();
- static void set_createThread_lock(Mutex* lk) { _createThread_lock = lk; }
- static Mutex* createThread_lock(void) { return _createThread_lock; }
static void hotspot_sigmask(Thread* thread);
static address initial_thread_stack_bottom(void) { return _initial_thread_stack_bottom; }
@@ -196,7 +184,6 @@
// Stack overflow handling
static bool manually_expand_stack(JavaThread * t, address addr);
- static int max_register_window_saves_before_flushing();
// fast POSIX clocks support
static void fast_thread_clock_init(void);
@@ -211,10 +198,6 @@
static jlong fast_thread_cpu_time(clockid_t clockid);
- static void initialize_os_info();
- static bool os_version_is_known();
- static uint32_t os_version();
-
// Stack repair handling
// none present
--- a/src/hotspot/os/linux/os_linux.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/linux/os_linux.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -59,8 +59,6 @@
::dlclose(lib);
}
-inline const int os::default_file_open_flags() { return 0;}
-
inline jlong os::lseek(int fd, jlong offset, int whence) {
return (jlong) ::lseek64(fd, offset, whence);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/os/posix/gc/z/zInitialize_posix.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+#include "precompiled.hpp"
+#include "gc/z/zInitialize.hpp"
+
+void ZInitialize::initialize_os() {
+ // Does nothing
+}
--- a/src/hotspot/os/posix/gc/z/zVirtualMemory_posix.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/posix/gc/z/zVirtualMemory_posix.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -29,6 +29,10 @@
#include <sys/mman.h>
#include <sys/types.h>
+void ZVirtualMemoryManager::initialize_os() {
+ // Does nothing
+}
+
static void unmap(uintptr_t start, size_t size) {
const int res = munmap((void*)start, size);
assert(res == 0, "Failed to unmap memory");
@@ -51,7 +55,7 @@
return true;
}
-bool ZVirtualMemoryManager::reserve_platform(uintptr_t start, size_t size) {
+bool ZVirtualMemoryManager::reserve_contiguous_platform(uintptr_t start, size_t size) {
// Reserve address views
const uintptr_t marked0 = ZAddress::marked0(start);
const uintptr_t marked1 = ZAddress::marked1(start);
--- a/src/hotspot/os/posix/os_posix.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/posix/os_posix.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -167,11 +167,6 @@
return n;
}
-bool os::is_debugger_attached() {
- // not implemented
- return false;
-}
-
void os::wait_for_keypress_at_exit(void) {
// don't do anything on posix platforms
return;
@@ -690,6 +685,9 @@
#endif
{ SIGHUP, "SIGHUP" },
{ SIGILL, "SIGILL" },
+#ifdef SIGINFO
+ { SIGINFO, "SIGINFO" },
+#endif
{ SIGINT, "SIGINT" },
#ifdef SIGIO
{ SIGIO, "SIGIO" },
--- a/src/hotspot/os/solaris/os_solaris.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/solaris/os_solaris.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -265,8 +265,6 @@
}
}
-static int _processors_online = 0;
-
jint os::Solaris::_os_thread_limit = 0;
volatile jint os::Solaris::_os_thread_count = 0;
@@ -291,7 +289,6 @@
void os::Solaris::initialize_system_info() {
set_processor_count(sysconf(_SC_NPROCESSORS_CONF));
- _processors_online = sysconf(_SC_NPROCESSORS_ONLN);
_physical_memory = (julong)sysconf(_SC_PHYS_PAGES) *
(julong)sysconf(_SC_PAGESIZE);
}
@@ -320,7 +317,6 @@
// Query the number of cpus available to us.
if (pset_info(pset, NULL, &pset_cpus, NULL) == 0) {
assert(pset_cpus > 0 && pset_cpus <= online_cpus, "sanity check");
- _processors_online = pset_cpus;
return pset_cpus;
}
}
@@ -328,136 +324,6 @@
return online_cpus;
}
-static bool find_processors_in_pset(psetid_t pset,
- processorid_t** id_array,
- uint_t* id_length) {
- bool result = false;
- // Find the number of processors in the processor set.
- if (pset_info(pset, NULL, id_length, NULL) == 0) {
- // Make up an array to hold their ids.
- *id_array = NEW_C_HEAP_ARRAY(processorid_t, *id_length, mtInternal);
- // Fill in the array with their processor ids.
- if (pset_info(pset, NULL, id_length, *id_array) == 0) {
- result = true;
- }
- }
- return result;
-}
-
-// Callers of find_processors_online() must tolerate imprecise results --
-// the system configuration can change asynchronously because of DR
-// or explicit psradm operations.
-//
-// We also need to take care that the loop (below) terminates as the
-// number of processors online can change between the _SC_NPROCESSORS_ONLN
-// request and the loop that builds the list of processor ids. Unfortunately
-// there's no reliable way to determine the maximum valid processor id,
-// so we use a manifest constant, MAX_PROCESSOR_ID, instead. See p_online
-// man pages, which claim the processor id set is "sparse, but
-// not too sparse". MAX_PROCESSOR_ID is used to ensure that we eventually
-// exit the loop.
-//
-// In the future we'll be able to use sysconf(_SC_CPUID_MAX), but that's
-// not available on S8.0.
-
-static bool find_processors_online(processorid_t** id_array,
- uint* id_length) {
- const processorid_t MAX_PROCESSOR_ID = 100000;
- // Find the number of processors online.
- *id_length = sysconf(_SC_NPROCESSORS_ONLN);
- // Make up an array to hold their ids.
- *id_array = NEW_C_HEAP_ARRAY(processorid_t, *id_length, mtInternal);
- // Processors need not be numbered consecutively.
- long found = 0;
- processorid_t next = 0;
- while (found < *id_length && next < MAX_PROCESSOR_ID) {
- processor_info_t info;
- if (processor_info(next, &info) == 0) {
- // NB, PI_NOINTR processors are effectively online ...
- if (info.pi_state == P_ONLINE || info.pi_state == P_NOINTR) {
- (*id_array)[found] = next;
- found += 1;
- }
- }
- next += 1;
- }
- if (found < *id_length) {
- // The loop above didn't identify the expected number of processors.
- // We could always retry the operation, calling sysconf(_SC_NPROCESSORS_ONLN)
- // and re-running the loop, above, but there's no guarantee of progress
- // if the system configuration is in flux. Instead, we just return what
- // we've got. Note that in the worst case find_processors_online() could
- // return an empty set. (As a fall-back in the case of the empty set we
- // could just return the ID of the current processor).
- *id_length = found;
- }
-
- return true;
-}
-
-static bool assign_distribution(processorid_t* id_array,
- uint id_length,
- uint* distribution,
- uint distribution_length) {
- // We assume we can assign processorid_t's to uint's.
- assert(sizeof(processorid_t) == sizeof(uint),
- "can't convert processorid_t to uint");
- // Quick check to see if we won't succeed.
- if (id_length < distribution_length) {
- return false;
- }
- // Assign processor ids to the distribution.
- // Try to shuffle processors to distribute work across boards,
- // assuming 4 processors per board.
- const uint processors_per_board = ProcessDistributionStride;
- // Find the maximum processor id.
- processorid_t max_id = 0;
- for (uint m = 0; m < id_length; m += 1) {
- max_id = MAX2(max_id, id_array[m]);
- }
- // The next id, to limit loops.
- const processorid_t limit_id = max_id + 1;
- // Make up markers for available processors.
- bool* available_id = NEW_C_HEAP_ARRAY(bool, limit_id, mtInternal);
- for (uint c = 0; c < limit_id; c += 1) {
- available_id[c] = false;
- }
- for (uint a = 0; a < id_length; a += 1) {
- available_id[id_array[a]] = true;
- }
- // Step by "boards", then by "slot", copying to "assigned".
- // NEEDS_CLEANUP: The assignment of processors should be stateful,
- // remembering which processors have been assigned by
- // previous calls, etc., so as to distribute several
- // independent calls of this method. What we'd like is
- // It would be nice to have an API that let us ask
- // how many processes are bound to a processor,
- // but we don't have that, either.
- // In the short term, "board" is static so that
- // subsequent distributions don't all start at board 0.
- static uint board = 0;
- uint assigned = 0;
- // Until we've found enough processors ....
- while (assigned < distribution_length) {
- // ... find the next available processor in the board.
- for (uint slot = 0; slot < processors_per_board; slot += 1) {
- uint try_id = board * processors_per_board + slot;
- if ((try_id < limit_id) && (available_id[try_id] == true)) {
- distribution[assigned] = try_id;
- available_id[try_id] = false;
- assigned += 1;
- break;
- }
- }
- board += 1;
- if (board * processors_per_board + 0 >= limit_id) {
- board = 0;
- }
- }
- FREE_C_HEAP_ARRAY(bool, available_id);
- return true;
-}
-
void os::set_native_thread_name(const char *name) {
if (Solaris::_pthread_setname_np != NULL) {
// Only the first 31 bytes of 'name' are processed by pthread_setname_np
@@ -470,31 +336,6 @@
}
}
-bool os::distribute_processes(uint length, uint* distribution) {
- bool result = false;
- // Find the processor id's of all the available CPUs.
- processorid_t* id_array = NULL;
- uint id_length = 0;
- // There are some races between querying information and using it,
- // since processor sets can change dynamically.
- psetid_t pset = PS_NONE;
- // Are we running in a processor set?
- if ((pset_bind(PS_QUERY, P_PID, P_MYID, &pset) == 0) && pset != PS_NONE) {
- result = find_processors_in_pset(pset, &id_array, &id_length);
- } else {
- result = find_processors_online(&id_array, &id_length);
- }
- if (result == true) {
- if (id_length >= length) {
- result = assign_distribution(id_array, id_length, distribution, length);
- } else {
- result = false;
- }
- }
- FREE_C_HEAP_ARRAY(processorid_t, id_array);
- return result;
-}
-
bool os::bind_to_processor(uint processor_id) {
// We assume that a processorid_t can be stored in a uint.
assert(sizeof(uint) == sizeof(processorid_t),
@@ -1237,8 +1078,6 @@
}
bool os::supports_vtime() { return true; }
-bool os::enable_vtime() { return false; }
-bool os::vtime_enabled() { return false; }
double os::elapsedVTime() {
return (double)gethrvtime() / (double)hrtime_hz;
--- a/src/hotspot/os/solaris/os_solaris.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/solaris/os_solaris.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -271,10 +271,6 @@
static void correct_stack_boundaries_for_primordial_thread(Thread* thr);
- // Stack overflow handling
-
- static int max_register_window_saves_before_flushing();
-
// Stack repair handling
// none present
--- a/src/hotspot/os/solaris/os_solaris.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/solaris/os_solaris.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -61,8 +61,6 @@
inline void os::dll_unload(void *lib) { ::dlclose(lib); }
-inline const int os::default_file_open_flags() { return 0;}
-
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
--- a/src/hotspot/os/windows/os_windows.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/windows/os_windows.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -795,6 +795,10 @@
}
}
+uint os::processor_id() {
+ return (uint)GetCurrentProcessorNumber();
+}
+
void os::set_native_thread_name(const char *name) {
// See: http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
@@ -826,11 +830,6 @@
} __except(EXCEPTION_EXECUTE_HANDLER) {}
}
-bool os::distribute_processes(uint length, uint* distribution) {
- // Not yet implemented.
- return false;
-}
-
bool os::bind_to_processor(uint processor_id) {
// Not yet implemented.
return false;
@@ -911,8 +910,6 @@
}
bool os::supports_vtime() { return true; }
-bool os::enable_vtime() { return false; }
-bool os::vtime_enabled() { return false; }
double os::elapsedVTime() {
FILETIME created;
@@ -3904,12 +3901,6 @@
_setmode(_fileno(stderr), _O_BINARY);
}
-
-bool os::is_debugger_attached() {
- return IsDebuggerPresent() ? true : false;
-}
-
-
void os::wait_for_keypress_at_exit(void) {
if (PauseAtExit) {
fprintf(stderr, "Press any key to continue...\n");
--- a/src/hotspot/os/windows/os_windows.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os/windows/os_windows.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -30,8 +30,6 @@
inline const char* os::dll_file_extension() { return ".dll"; }
-inline const int os::default_file_open_flags() { return O_BINARY | O_NOINHERIT;}
-
inline void os::dll_unload(void *lib) {
::FreeLibrary((HMODULE)lib);
}
--- a/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -65,21 +65,22 @@
}
if (ret_frame.is_interpreted_frame()) {
- frame::ijava_state* istate = ret_frame.get_ijava_state();
- if (MetaspaceObj::is_valid((Method*)(istate->method)) == false) {
- return false;
- }
- uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/];
- uint64_t istate_bcp = istate->bcp;
- uint64_t code_start = (uint64_t)(((Method*)(istate->method))->code_base());
- uint64_t code_end = (uint64_t)(((Method*)istate->method)->code_base() + ((Method*)istate->method)->code_size());
- if (istate_bcp >= code_start && istate_bcp < code_end) {
- // we have a valid bcp, don't touch it, do nothing
- } else if (reg_bcp >= code_start && reg_bcp < code_end) {
- istate->bcp = reg_bcp;
+ frame::ijava_state *istate = ret_frame.get_ijava_state();
+ const Method *m = (const Method*)(istate->method);
+ if (!Method::is_valid_method(m)) return false;
+ if (!Metaspace::contains(m->constMethod())) return false;
+
+ uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/];
+ uint64_t istate_bcp = istate->bcp;
+ uint64_t code_start = (uint64_t)(m->code_base());
+ uint64_t code_end = (uint64_t)(m->code_base() + m->code_size());
+ if (istate_bcp >= code_start && istate_bcp < code_end) {
+ // we have a valid bcp, don't touch it, do nothing
+ } else if (reg_bcp >= code_start && reg_bcp < code_end) {
+ istate->bcp = reg_bcp;
} else {
- return false;
- }
+ return false;
+ }
}
if (!ret_frame.safe_for_sender(this)) {
// nothing else to try if the frame isn't good
--- a/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -63,21 +63,24 @@
if (ret_frame.is_interpreted_frame()) {
frame::z_ijava_state* istate = ret_frame.ijava_state_unchecked();
- if ((stack_base() >= (address)istate && (address)istate > stack_end()) ||
- MetaspaceObj::is_valid((Method*)(istate->method)) == false) {
- return false;
- }
- uint64_t reg_bcp = uc->uc_mcontext.gregs[13/*Z_BCP*/];
- uint64_t istate_bcp = istate->bcp;
- uint64_t code_start = (uint64_t)(((Method*)(istate->method))->code_base());
- uint64_t code_end = (uint64_t)(((Method*)istate->method)->code_base() + ((Method*)istate->method)->code_size());
- if (istate_bcp >= code_start && istate_bcp < code_end) {
- // we have a valid bcp, don't touch it, do nothing
- } else if (reg_bcp >= code_start && reg_bcp < code_end) {
- istate->bcp = reg_bcp;
- } else {
- return false;
- }
+ if (stack_base() >= (address)istate && (address)istate > stack_end()) {
+ return false;
+ }
+ const Method *m = (const Method*)(istate->method);
+ if (!Method::is_valid_method(m)) return false;
+ if (!Metaspace::contains(m->constMethod())) return false;
+
+ uint64_t reg_bcp = uc->uc_mcontext.gregs[13/*Z_BCP*/];
+ uint64_t istate_bcp = istate->bcp;
+ uint64_t code_start = (uint64_t)(m->code_base());
+ uint64_t code_end = (uint64_t)(m->code_base() + m->code_size());
+ if (istate_bcp >= code_start && istate_bcp < code_end) {
+ // we have a valid bcp, don't touch it, do nothing
+ } else if (reg_bcp >= code_start && reg_bcp < code_end) {
+ istate->bcp = reg_bcp;
+ } else {
+ return false;
+ }
}
if (!ret_frame.safe_for_sender(this)) {
// nothing else to try if the frame isn't good
--- a/src/hotspot/os_cpu/solaris_sparc/os_solaris_sparc.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/os_cpu/solaris_sparc/os_solaris_sparc.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -86,12 +86,6 @@
size_t os::Posix::_java_thread_min_stack_allowed = 86 * K;
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
-int os::Solaris::max_register_window_saves_before_flushing() {
- // We should detect this at run time. For now, filling
- // in with a constant.
- return 8;
-}
-
static void handle_unflushed_register_windows(gwindows_t *win) {
int restore_count = win->wbcnt;
int i;
--- a/src/hotspot/share/aot/aotCodeHeap.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/aot/aotCodeHeap.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -93,7 +93,7 @@
Handle protection_domain(thread, caller->method_holder()->protection_domain());
// Ignore wrapping L and ;
- if (name[0] == 'L') {
+ if (name[0] == JVM_SIGNATURE_CLASS) {
assert(len > 2, "small name %s", name);
name++;
len -= 2;
--- a/src/hotspot/share/c1/c1_InstructionPrinter.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/c1/c1_InstructionPrinter.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -33,19 +33,11 @@
#ifndef PRODUCT
const char* InstructionPrinter::basic_type_name(BasicType type) {
- switch (type) {
- case T_BOOLEAN: return "boolean";
- case T_BYTE : return "byte";
- case T_CHAR : return "char";
- case T_SHORT : return "short";
- case T_INT : return "int";
- case T_LONG : return "long";
- case T_FLOAT : return "float";
- case T_DOUBLE : return "double";
- case T_ARRAY : return "array";
- case T_OBJECT : return "object";
- default : return "???";
+ const char* n = type2name(type);
+ if (n == NULL || type > T_VOID) {
+ return "???";
}
+ return n;
}
--- a/src/hotspot/share/ci/ciEnv.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/ci/ciEnv.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -413,8 +413,8 @@
// Now we need to check the SystemDictionary
Symbol* sym = name->get_symbol();
- if (sym->char_at(0) == 'L' &&
- sym->char_at(sym->utf8_length()-1) == ';') {
+ if (sym->char_at(0) == JVM_SIGNATURE_CLASS &&
+ sym->char_at(sym->utf8_length()-1) == JVM_SIGNATURE_ENDCLASS) {
// This is a name from a signature. Strip off the trimmings.
// Call recursive to keep scope of strippedsym.
TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
@@ -440,7 +440,7 @@
// setup up the proper type to return on OOM
ciKlass* fail_type;
- if (sym->char_at(0) == '[') {
+ if (sym->char_at(0) == JVM_SIGNATURE_ARRAY) {
fail_type = _unloaded_ciobjarrayklass;
} else {
fail_type = _unloaded_ciinstance_klass;
@@ -466,8 +466,8 @@
// we must build an array type around it. The CI requires array klasses
// to be loaded if their element klasses are loaded, except when memory
// is exhausted.
- if (sym->char_at(0) == '[' &&
- (sym->char_at(1) == '[' || sym->char_at(1) == 'L')) {
+ if (sym->char_at(0) == JVM_SIGNATURE_ARRAY &&
+ (sym->char_at(1) == JVM_SIGNATURE_ARRAY || sym->char_at(1) == JVM_SIGNATURE_CLASS)) {
// We have an unloaded array.
// Build it on the fly if the element class exists.
TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
--- a/src/hotspot/share/ci/ciInstanceKlass.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/ci/ciInstanceKlass.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -116,7 +116,7 @@
jobject loader, jobject protection_domain)
: ciKlass(name, T_OBJECT)
{
- assert(name->char_at(0) != '[', "not an instance klass");
+ assert(name->char_at(0) != JVM_SIGNATURE_ARRAY, "not an instance klass");
_init_state = (InstanceKlass::ClassState)0;
_nonstatic_field_size = -1;
_has_nonstatic_fields = false;
--- a/src/hotspot/share/ci/ciObjArrayKlass.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/ci/ciObjArrayKlass.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -112,16 +112,16 @@
Symbol* base_name_sym = element_name->get_symbol();
char* name;
- if (base_name_sym->char_at(0) == '[' ||
- (base_name_sym->char_at(0) == 'L' && // watch package name 'Lxx'
- base_name_sym->char_at(element_len-1) == ';')) {
+ if (base_name_sym->char_at(0) == JVM_SIGNATURE_ARRAY ||
+ (base_name_sym->char_at(0) == JVM_SIGNATURE_CLASS && // watch package name 'Lxx'
+ base_name_sym->char_at(element_len-1) == JVM_SIGNATURE_ENDCLASS)) {
int new_len = element_len + dimension + 1; // for the ['s and '\0'
name = CURRENT_THREAD_ENV->name_buffer(new_len);
int pos = 0;
for ( ; pos < dimension; pos++) {
- name[pos] = '[';
+ name[pos] = JVM_SIGNATURE_ARRAY;
}
strncpy(name+pos, (char*)element_name->base(), element_len);
name[new_len-1] = '\0';
@@ -133,11 +133,11 @@
name = CURRENT_THREAD_ENV->name_buffer(new_len);
int pos = 0;
for ( ; pos < dimension; pos++) {
- name[pos] = '[';
+ name[pos] = JVM_SIGNATURE_ARRAY;
}
- name[pos++] = 'L';
+ name[pos++] = JVM_SIGNATURE_CLASS;
strncpy(name+pos, (char*)element_name->base(), element_len);
- name[new_len-2] = ';';
+ name[new_len-2] = JVM_SIGNATURE_ENDCLASS;
name[new_len-1] = '\0';
}
return ciSymbol::make(name);
--- a/src/hotspot/share/ci/ciObjectFactory.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/ci/ciObjectFactory.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -486,7 +486,7 @@
// Two cases: this is an unloaded ObjArrayKlass or an
// unloaded InstanceKlass. Deal with both.
- if (name->char_at(0) == '[') {
+ if (name->char_at(0) == JVM_SIGNATURE_ARRAY) {
// Decompose the name.'
FieldArrayInfo fd;
BasicType element_type = FieldType::get_array_info(name->get_symbol(),
--- a/src/hotspot/share/ci/ciReplay.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/ci/ciReplay.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -814,18 +814,18 @@
}
oop java_mirror = k->java_mirror();
- if (field_signature[0] == '[') {
+ if (field_signature[0] == JVM_SIGNATURE_ARRAY) {
int length = parse_int("array length");
oop value = NULL;
- if (field_signature[1] == '[') {
+ if (field_signature[1] == JVM_SIGNATURE_ARRAY) {
// multi dimensional array
ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK);
if (kelem == NULL) {
return;
}
int rank = 0;
- while (field_signature[rank] == '[') {
+ while (field_signature[rank] == JVM_SIGNATURE_ARRAY) {
rank++;
}
jint* dims = NEW_RESOURCE_ARRAY(jint, rank);
@@ -851,7 +851,8 @@
value = oopFactory::new_intArray(length, CHECK);
} else if (strcmp(field_signature, "[J") == 0) {
value = oopFactory::new_longArray(length, CHECK);
- } else if (field_signature[0] == '[' && field_signature[1] == 'L') {
+ } else if (field_signature[0] == JVM_SIGNATURE_ARRAY &&
+ field_signature[1] == JVM_SIGNATURE_CLASS) {
Klass* kelem = resolve_klass(field_signature + 1, CHECK);
value = oopFactory::new_objArray(kelem, length, CHECK);
} else {
@@ -892,7 +893,7 @@
} else if (strcmp(field_signature, "Ljava/lang/String;") == 0) {
Handle value = java_lang_String::create_from_str(string_value, CHECK);
java_mirror->obj_field_put(fd.offset(), value());
- } else if (field_signature[0] == 'L') {
+ } else if (field_signature[0] == JVM_SIGNATURE_CLASS) {
Klass* k = resolve_klass(string_value, CHECK);
oop value = InstanceKlass::cast(k)->allocate_instance(CHECK);
java_mirror->obj_field_put(fd.offset(), value);
--- a/src/hotspot/share/classfile/classFileParser.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/classFileParser.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -731,7 +731,7 @@
const unsigned int name_len = name->utf8_length();
if (tag == JVM_CONSTANT_Methodref &&
name_len != 0 &&
- name->char_at(0) == '<' &&
+ name->char_at(0) == JVM_SIGNATURE_SPECIAL &&
name != vmSymbols::object_initializer_name()) {
classfile_parse_error(
"Bad method name at constant pool index %u in class file %s",
@@ -2448,17 +2448,10 @@
parsed_code_attribute = true;
// Stack size, locals size, and code size
- if (_major_version == 45 && _minor_version <= 2) {
- cfs->guarantee_more(4, CHECK_NULL);
- max_stack = cfs->get_u1_fast();
- max_locals = cfs->get_u1_fast();
- code_length = cfs->get_u2_fast();
- } else {
- cfs->guarantee_more(8, CHECK_NULL);
- max_stack = cfs->get_u2_fast();
- max_locals = cfs->get_u2_fast();
- code_length = cfs->get_u4_fast();
- }
+ cfs->guarantee_more(8, CHECK_NULL);
+ max_stack = cfs->get_u2_fast();
+ max_locals = cfs->get_u2_fast();
+ code_length = cfs->get_u4_fast();
if (_need_verify) {
guarantee_property(args_size <= max_locals,
"Arguments can't fit into locals in class file %s",
@@ -2489,13 +2482,8 @@
unsigned int calculated_attribute_length = 0;
- if (_major_version > 45 || (_major_version == 45 && _minor_version > 2)) {
- calculated_attribute_length =
- sizeof(max_stack) + sizeof(max_locals) + sizeof(code_length);
- } else {
- // max_stack, locals and length are smaller in pre-version 45.2 classes
- calculated_attribute_length = sizeof(u1) + sizeof(u1) + sizeof(u2);
- }
+ calculated_attribute_length =
+ sizeof(max_stack) + sizeof(max_locals) + sizeof(code_length);
calculated_attribute_length +=
code_length +
sizeof(exception_table_length) +
@@ -4961,24 +4949,25 @@
if (length == 0) return false; // Must have at least one char.
for (const char* p = name; p != name + length; p++) {
switch(*p) {
- case '.':
- case ';':
- case '[':
+ case JVM_SIGNATURE_DOT:
+ case JVM_SIGNATURE_ENDCLASS:
+ case JVM_SIGNATURE_ARRAY:
// do not permit '.', ';', or '['
return false;
- case '/':
+ case JVM_SIGNATURE_SLASH:
// check for '//' or leading or trailing '/' which are not legal
// unqualified name must not be empty
if (type == ClassFileParser::LegalClass) {
- if (p == name || p+1 >= name+length || *(p+1) == '/') {
+ if (p == name || p+1 >= name+length ||
+ *(p+1) == JVM_SIGNATURE_SLASH) {
return false;
}
} else {
return false; // do not permit '/' unless it's class name
}
break;
- case '<':
- case '>':
+ case JVM_SIGNATURE_SPECIAL:
+ case JVM_SIGNATURE_ENDSPECIAL:
// do not permit '<' or '>' in method names
if (type == ClassFileParser::LegalMethod) {
return false;
@@ -5015,7 +5004,7 @@
last_is_slash = false;
continue;
}
- if (slash_ok && ch == '/') {
+ if (slash_ok && ch == JVM_SIGNATURE_SLASH) {
if (last_is_slash) {
return NULL; // Don't permit consecutive slashes
}
@@ -5095,14 +5084,14 @@
const char* const p = skip_over_field_name(signature + 1, true, --length);
// The next character better be a semicolon
- if (p && (p - signature) > 1 && p[0] == ';') {
+ if (p && (p - signature) > 1 && p[0] == JVM_SIGNATURE_ENDCLASS) {
return p + 1;
}
}
else {
// Skip leading 'L' and ignore first appearance of ';'
signature++;
- const char* c = (const char*) memchr(signature, ';', length - 1);
+ const char* c = (const char*) memchr(signature, JVM_SIGNATURE_ENDCLASS, length - 1);
// Format check signature
if (c != NULL) {
int newlen = c - (char*) signature;
@@ -5151,7 +5140,7 @@
p = skip_over_field_signature(bytes, false, length, CHECK);
legal = (p != NULL) && ((p - bytes) == (int)length);
} else if (_major_version < JAVA_1_5_VERSION) {
- if (bytes[0] != '<') {
+ if (bytes[0] != JVM_SIGNATURE_SPECIAL) {
p = skip_over_field_name(bytes, true, length);
legal = (p != NULL) && ((p - bytes) == (int)length);
}
@@ -5186,7 +5175,7 @@
if (length > 0) {
if (_major_version < JAVA_1_5_VERSION) {
- if (bytes[0] != '<') {
+ if (bytes[0] != JVM_SIGNATURE_SPECIAL) {
const char* p = skip_over_field_name(bytes, false, length);
legal = (p != NULL) && ((p - bytes) == (int)length);
}
@@ -5219,7 +5208,7 @@
bool legal = false;
if (length > 0) {
- if (bytes[0] == '<') {
+ if (bytes[0] == JVM_SIGNATURE_SPECIAL) {
if (name == vmSymbols::object_initializer_name() || name == vmSymbols::class_initializer_name()) {
legal = true;
}
@@ -5303,7 +5292,7 @@
// The first non-signature thing better be a ')'
if ((length > 0) && (*p++ == JVM_SIGNATURE_ENDFUNC)) {
length--;
- if (name->utf8_length() > 0 && name->char_at(0) == '<') {
+ if (name->utf8_length() > 0 && name->char_at(0) == JVM_SIGNATURE_SPECIAL) {
// All internal methods must return void
if ((length == 1) && (p[0] == JVM_SIGNATURE_VOID)) {
return args_size;
@@ -5705,7 +5694,7 @@
// its _class_name field.
void ClassFileParser::prepend_host_package_name(const InstanceKlass* unsafe_anonymous_host, TRAPS) {
ResourceMark rm(THREAD);
- assert(strrchr(_class_name->as_C_string(), '/') == NULL,
+ assert(strrchr(_class_name->as_C_string(), JVM_SIGNATURE_SLASH) == NULL,
"Unsafe anonymous class should not be in a package");
const char* host_pkg_name =
ClassLoader::package_from_name(unsafe_anonymous_host->name()->as_C_string(), NULL);
@@ -5738,7 +5727,7 @@
assert(_unsafe_anonymous_host != NULL, "Expected an unsafe anonymous class");
const jbyte* anon_last_slash = UTF8::strrchr((const jbyte*)_class_name->base(),
- _class_name->utf8_length(), '/');
+ _class_name->utf8_length(), JVM_SIGNATURE_SLASH);
if (anon_last_slash == NULL) { // Unnamed package
prepend_host_package_name(_unsafe_anonymous_host, CHECK);
} else {
@@ -6343,7 +6332,7 @@
if (class_name != NULL) {
ResourceMark rm;
char* name = class_name->as_C_string();
- return strchr(name, '.') == NULL;
+ return strchr(name, JVM_SIGNATURE_DOT) == NULL;
} else {
return true;
}
--- a/src/hotspot/share/classfile/classListParser.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/classListParser.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -229,17 +229,17 @@
jio_fprintf(defaultStream::error_stream(), "}\n");
}
-void ClassListParser::print_actual_interfaces(InstanceKlass *ik) {
+void ClassListParser::print_actual_interfaces(InstanceKlass* ik) {
int n = ik->local_interfaces()->length();
jio_fprintf(defaultStream::error_stream(), "Actual interfaces[%d] = {\n", n);
for (int i = 0; i < n; i++) {
- InstanceKlass* e = InstanceKlass::cast(ik->local_interfaces()->at(i));
+ InstanceKlass* e = ik->local_interfaces()->at(i);
jio_fprintf(defaultStream::error_stream(), " %s\n", e->name()->as_klass_external_name());
}
jio_fprintf(defaultStream::error_stream(), "}\n");
}
-void ClassListParser::error(const char *msg, ...) {
+void ClassListParser::error(const char* msg, ...) {
va_list ap;
va_start(ap, msg);
int error_index = _token - _line;
@@ -328,7 +328,7 @@
Klass* ClassListParser::load_current_class(TRAPS) {
TempNewSymbol class_name_symbol = SymbolTable::new_symbol(_class_name);
- Klass *klass = NULL;
+ Klass* klass = NULL;
if (!is_loading_from_source()) {
// Load classes for the boot/platform/app loaders only.
if (is_super_specified()) {
--- a/src/hotspot/share/classfile/classLoader.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/classLoader.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -187,7 +187,7 @@
*bad_class_name = false;
}
- const char* const last_slash = strrchr(class_name, '/');
+ const char* const last_slash = strrchr(class_name, JVM_SIGNATURE_SLASH);
if (last_slash == NULL) {
// No package name
return NULL;
@@ -195,16 +195,16 @@
char* class_name_ptr = (char*) class_name;
// Skip over '['s
- if (*class_name_ptr == '[') {
+ if (*class_name_ptr == JVM_SIGNATURE_ARRAY) {
do {
class_name_ptr++;
- } while (*class_name_ptr == '[');
+ } while (*class_name_ptr == JVM_SIGNATURE_ARRAY);
// Fully qualified class names should not contain a 'L'.
// Set bad_class_name to true to indicate that the package name
// could not be obtained due to an error condition.
// In this situation, is_same_class_package returns false.
- if (*class_name_ptr == 'L') {
+ if (*class_name_ptr == JVM_SIGNATURE_CLASS) {
if (bad_class_name != NULL) {
*bad_class_name = true;
}
--- a/src/hotspot/share/classfile/defaultMethods.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/defaultMethods.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -146,7 +146,7 @@
return interface_index() >= number_of_interfaces();
}
InstanceKlass* interface_at(int index) {
- return InstanceKlass::cast(_class->local_interfaces()->at(index));
+ return _class->local_interfaces()->at(index);
}
InstanceKlass* next_super() { return _class->java_super(); }
InstanceKlass* next_interface() {
@@ -1012,7 +1012,7 @@
klass->class_loader_data(), new_size, NULL, CHECK);
// original_ordering might be empty if this class has no methods of its own
- if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) {
+ if (JvmtiExport::can_maintain_original_method_order() || Arguments::is_dumping_archive()) {
merged_ordering = MetadataFactory::new_array<int>(
klass->class_loader_data(), new_size, CHECK);
}
--- a/src/hotspot/share/classfile/dictionary.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/dictionary.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -156,7 +156,6 @@
// Tells whether the initiating class' protection domain can access the klass in this entry
bool is_valid_protection_domain(Handle protection_domain) {
if (!ProtectionDomainVerification) return true;
- if (!SystemDictionary::has_checkPackageAccess()) return true;
return protection_domain() == NULL
? true
--- a/src/hotspot/share/classfile/javaAssertions.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/javaAssertions.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -79,7 +79,7 @@
// JVM_DesiredAssertionStatus pass the external_name() to
// JavaAssertion::enabled(), but that is done once per loaded class.
for (int i = 0; i < len; ++i) {
- if (name_copy[i] == '.') name_copy[i] = '/';
+ if (name_copy[i] == JVM_SIGNATURE_DOT) name_copy[i] = JVM_SIGNATURE_SLASH;
}
if (TraceJavaAssertions) {
@@ -135,7 +135,7 @@
for (index = len - 1; p != 0; p = p->next(), --index) {
assert(index >= 0, "length does not match list");
Handle s = java_lang_String::create_from_str(p->name(), CHECK);
- s = java_lang_String::char_converter(s, '/', '.', CHECK);
+ s = java_lang_String::char_converter(s, JVM_SIGNATURE_SLASH, JVM_SIGNATURE_DOT, CHECK);
names->obj_at_put(index, s());
enabled->bool_at_put(index, p->enabled());
}
@@ -163,10 +163,10 @@
// does not include a package, length will be 0 which will match items for the
// default package (from options "-ea:..." or "-da:...").
size_t len = strlen(classname);
- for (/* empty */; len > 0 && classname[len] != '/'; --len) /* empty */;
+ for (/* empty */; len > 0 && classname[len] != JVM_SIGNATURE_SLASH; --len) /* empty */;
do {
- assert(len == 0 || classname[len] == '/', "not a package name");
+ assert(len == 0 || classname[len] == JVM_SIGNATURE_SLASH, "not a package name");
for (OptionList* p = _packages; p != 0; p = p->next()) {
if (strncmp(p->name(), classname, len) == 0 && p->name()[len] == '\0') {
return p;
@@ -175,7 +175,7 @@
// Find the length of the next package, taking care to avoid decrementing
// past 0 (len is unsigned).
- while (len > 0 && classname[--len] != '/') /* empty */;
+ while (len > 0 && classname[--len] != JVM_SIGNATURE_SLASH) /* empty */;
} while (len > 0);
return 0;
--- a/src/hotspot/share/classfile/javaClasses.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/javaClasses.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -87,6 +87,21 @@
ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
};
+// Register native methods of Object
+void java_lang_Object::register_natives(TRAPS) {
+ InstanceKlass* obj = SystemDictionary::Object_klass();
+ Method::register_native(obj, vmSymbols::hashCode_name(),
+ vmSymbols::void_int_signature(), (address) &JVM_IHashCode, CHECK);
+ Method::register_native(obj, vmSymbols::wait_name(),
+ vmSymbols::long_void_signature(), (address) &JVM_MonitorWait, CHECK);
+ Method::register_native(obj, vmSymbols::notify_name(),
+ vmSymbols::void_method_signature(), (address) &JVM_MonitorNotify, CHECK);
+ Method::register_native(obj, vmSymbols::notifyAll_name(),
+ vmSymbols::void_method_signature(), (address) &JVM_MonitorNotifyAll, CHECK);
+ Method::register_native(obj, vmSymbols::clone_name(),
+ vmSymbols::void_object_signature(), (address) &JVM_Clone, THREAD);
+}
+
int JavaClasses::compute_injected_offset(InjectedFieldID id) {
return _injected_fields[id].compute_offset();
}
@@ -377,7 +392,7 @@
if (_to_java_string_fn == NULL) {
void *lib_handle = os::native_java_library();
- _to_java_string_fn = CAST_TO_FN_PTR(to_java_string_fn_t, os::dll_lookup(lib_handle, "JNU_NewStringPlatform"));
+ _to_java_string_fn = CAST_TO_FN_PTR(to_java_string_fn_t, os::dll_lookup(lib_handle, "NewStringPlatform"));
if (_to_java_string_fn == NULL) {
fatal("NewStringPlatform missing");
}
@@ -1545,7 +1560,7 @@
int java_lang_Class::classRedefinedCount_offset = -1;
#define CLASS_FIELDS_DO(macro) \
- macro(classRedefinedCount_offset, k, "classRedefinedCount", int_signature, false) ; \
+ macro(classRedefinedCount_offset, k, "classRedefinedCount", int_signature, false); \
macro(_class_loader_offset, k, "classLoader", classloader_signature, false); \
macro(_component_mirror_offset, k, "componentType", class_signature, false); \
macro(_module_offset, k, "module", module_signature, false); \
@@ -1938,7 +1953,6 @@
return method != NULL && (method->constants()->version() == version);
}
-
// This class provides a simple wrapper over the internal structure of
// exception backtrace to insulate users of the backtrace from needing
// to know what it looks like.
@@ -1950,7 +1964,11 @@
typeArrayOop _methods;
typeArrayOop _bcis;
objArrayOop _mirrors;
- typeArrayOop _names; // needed to insulate method name against redefinition
+ typeArrayOop _names; // Needed to insulate method name against redefinition.
+ // This is set to a java.lang.Boolean(true) if the top frame
+ // of the backtrace is omitted because it shall be hidden.
+ // Else it is null.
+ oop _has_hidden_top_frame;
int _index;
NoSafepointVerifier _nsv;
@@ -1960,6 +1978,7 @@
trace_mirrors_offset = java_lang_Throwable::trace_mirrors_offset,
trace_names_offset = java_lang_Throwable::trace_names_offset,
trace_next_offset = java_lang_Throwable::trace_next_offset,
+ trace_hidden_offset = java_lang_Throwable::trace_hidden_offset,
trace_size = java_lang_Throwable::trace_size,
trace_chunk_size = java_lang_Throwable::trace_chunk_size
};
@@ -1985,11 +2004,15 @@
assert(names != NULL, "names array should be initialized in backtrace");
return names;
}
+ static oop get_has_hidden_top_frame(objArrayHandle chunk) {
+ oop hidden = chunk->obj_at(trace_hidden_offset);
+ return hidden;
+ }
public:
// constructor for new backtrace
- BacktraceBuilder(TRAPS): _head(NULL), _methods(NULL), _bcis(NULL), _mirrors(NULL), _names(NULL) {
+ BacktraceBuilder(TRAPS): _head(NULL), _methods(NULL), _bcis(NULL), _mirrors(NULL), _names(NULL), _has_hidden_top_frame(NULL) {
expand(CHECK);
_backtrace = Handle(THREAD, _head);
_index = 0;
@@ -2000,6 +2023,7 @@
_bcis = get_bcis(backtrace);
_mirrors = get_mirrors(backtrace);
_names = get_names(backtrace);
+ _has_hidden_top_frame = get_has_hidden_top_frame(backtrace);
assert(_methods->length() == _bcis->length() &&
_methods->length() == _mirrors->length() &&
_mirrors->length() == _names->length(),
@@ -2037,6 +2061,7 @@
new_head->obj_at_put(trace_bcis_offset, new_bcis());
new_head->obj_at_put(trace_mirrors_offset, new_mirrors());
new_head->obj_at_put(trace_names_offset, new_names());
+ new_head->obj_at_put(trace_hidden_offset, NULL);
_head = new_head();
_methods = new_methods();
@@ -2077,6 +2102,16 @@
_index++;
}
+ void set_has_hidden_top_frame(TRAPS) {
+ if (_has_hidden_top_frame == NULL) {
+ jvalue prim;
+ prim.z = 1;
+ PauseNoSafepointVerifier pnsv(&_nsv);
+ _has_hidden_top_frame = java_lang_boxing_object::create(T_BOOLEAN, &prim, CHECK);
+ _head->obj_at_put(trace_hidden_offset, _has_hidden_top_frame);
+ }
+ }
+
};
struct BacktraceElement : public StackObj {
@@ -2406,7 +2441,13 @@
}
}
if (method->is_hidden()) {
- if (skip_hidden) continue;
+ if (skip_hidden) {
+ if (total_count == 0) {
+ // The top frame will be hidden from the stack trace.
+ bt.set_has_hidden_top_frame(CHECK);
+ }
+ continue;
+ }
}
bt.push(method, bci, CHECK);
total_count++;
@@ -2523,6 +2564,37 @@
}
}
+bool java_lang_Throwable::get_top_method_and_bci(oop throwable, Method** method, int* bci) {
+ Thread* THREAD = Thread::current();
+ objArrayHandle result(THREAD, objArrayOop(backtrace(throwable)));
+ BacktraceIterator iter(result, THREAD);
+ // No backtrace available.
+ if (!iter.repeat()) return false;
+
+ // If the exception happened in a frame that has been hidden, i.e.,
+ // omitted from the back trace, we can not compute the message.
+ oop hidden = ((objArrayOop)backtrace(throwable))->obj_at(trace_hidden_offset);
+ if (hidden != NULL) {
+ return false;
+ }
+
+ // Get first backtrace element.
+ BacktraceElement bte = iter.next(THREAD);
+
+ InstanceKlass* holder = InstanceKlass::cast(java_lang_Class::as_Klass(bte._mirror()));
+ assert(holder != NULL, "first element should be non-null");
+ Method* m = holder->method_with_orig_idnum(bte._method_id, bte._version);
+
+ // Original version is no longer available.
+ if (m == NULL || !version_matches(m, bte._version)) {
+ return false;
+ }
+
+ *method = m;
+ *bci = bte._bci;
+ return true;
+}
+
oop java_lang_StackTraceElement::create(const methodHandle& method, int bci, TRAPS) {
// Allocate java.lang.StackTraceElement instance
InstanceKlass* k = SystemDictionary::StackTraceElement_klass();
--- a/src/hotspot/share/classfile/javaClasses.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/javaClasses.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -88,6 +88,13 @@
BASIC_JAVA_CLASSES_DO_PART1(f) \
BASIC_JAVA_CLASSES_DO_PART2(f)
+// Interface to java.lang.Object objects
+
+class java_lang_Object : AllStatic {
+ public:
+ static void register_natives(TRAPS);
+};
+
// Interface to java.lang.String objects
class java_lang_String : AllStatic {
@@ -201,7 +208,9 @@
static inline bool value_equals(typeArrayOop str_value1, typeArrayOop str_value2);
// Conversion between '.' and '/' formats
- static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); }
+ static Handle externalize_classname(Handle java_string, TRAPS) {
+ return char_converter(java_string, JVM_SIGNATURE_SLASH, JVM_SIGNATURE_DOT, THREAD);
+ }
// Conversion
static Symbol* as_symbol(oop java_string);
@@ -518,7 +527,8 @@
trace_mirrors_offset = 2,
trace_names_offset = 3,
trace_next_offset = 4,
- trace_size = 5,
+ trace_hidden_offset = 5,
+ trace_size = 6,
trace_chunk_size = 32
};
@@ -568,6 +578,8 @@
static void java_printStackTrace(Handle throwable, TRAPS);
// Debugging
friend class JavaClasses;
+ // Gets the method and bci of the top frame (TOS). Returns false if this failed.
+ static bool get_top_method_and_bci(oop throwable, Method** method, int* bci);
};
--- a/src/hotspot/share/classfile/modules.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/modules.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -331,7 +331,7 @@
if (!h_loader.is_null() &&
!SystemDictionary::is_platform_class_loader(h_loader()) &&
(strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0 &&
- (package_name[JAVAPKG_LEN] == '/' || package_name[JAVAPKG_LEN] == '\0'))) {
+ (package_name[JAVAPKG_LEN] == JVM_SIGNATURE_SLASH || package_name[JAVAPKG_LEN] == '\0'))) {
const char* class_loader_name = loader_data->loader_name_and_id();
size_t pkg_len = strlen(package_name);
char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len + 1);
--- a/src/hotspot/share/classfile/systemDictionary.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -109,8 +109,6 @@
oop SystemDictionary::_java_system_loader = NULL;
oop SystemDictionary::_java_platform_loader = NULL;
-bool SystemDictionary::_has_checkPackageAccess = false;
-
// Default ProtectionDomainCacheSize value
const int defaultProtectionDomainCacheSize = 1009;
@@ -447,8 +445,6 @@
Handle class_loader,
Handle protection_domain,
TRAPS) {
- if(!has_checkPackageAccess()) return;
-
// Now we have to call back to java to check if the initating class has access
JavaValue result(T_VOID);
LogTarget(Debug, protectiondomain) lt;
@@ -1976,6 +1972,10 @@
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
}
+ assert(WK_KLASS(Object_klass) != NULL, "well-known classes should now be initialized");
+
+ java_lang_Object::register_natives(CHECK);
+
// Calculate offsets for String and Class classes since they are loaded and
// can be used after this point.
java_lang_String::compute_offsets();
@@ -1993,14 +1993,14 @@
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Reference_klass), scan, CHECK);
// Preload ref klasses and set reference types
- InstanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER);
+ WK_KLASS(Reference_klass)->set_reference_type(REF_OTHER);
InstanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass));
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(PhantomReference_klass), scan, CHECK);
- InstanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT);
- InstanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK);
- InstanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL);
- InstanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM);
+ WK_KLASS(SoftReference_klass)->set_reference_type(REF_SOFT);
+ WK_KLASS(WeakReference_klass)->set_reference_type(REF_WEAK);
+ WK_KLASS(FinalReference_klass)->set_reference_type(REF_FINAL);
+ WK_KLASS(PhantomReference_klass)->set_reference_type(REF_PHANTOM);
// JSR 292 classes
WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
@@ -2021,11 +2021,6 @@
//_box_klasses[T_OBJECT] = WK_KLASS(object_klass);
//_box_klasses[T_ARRAY] = WK_KLASS(object_klass);
- { // Compute whether we should use checkPackageAccess or NOT
- Method* method = InstanceKlass::cast(ClassLoader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature());
- _has_checkPackageAccess = (method != NULL);
- }
-
#ifdef ASSERT
if (UseSharedSpaces) {
assert(JvmtiExport::is_early_phase(),
@@ -2137,26 +2132,6 @@
{
MutexLocker mu1(SystemDictionary_lock, THREAD);
- // See whether biased locking is enabled and if so set it for this
- // klass.
- // Note that this must be done past the last potential blocking
- // point / safepoint. We might enable biased locking lazily using a
- // VM_Operation to iterate the SystemDictionary and installing the
- // biasable mark word into each InstanceKlass's prototype header.
- // To avoid race conditions where we accidentally miss enabling the
- // optimization for one class in the process of being added to the
- // dictionary, we must not safepoint after the test of
- // BiasedLocking::enabled().
- if (UseBiasedLocking && BiasedLocking::enabled()) {
- // Set biased locking bit for all loaded classes; it will be
- // cleared if revocation occurs too often for this type
- // NOTE that we must only do this when the class is initally
- // defined, not each time it is referenced from a new class loader
- if (k->class_loader() == class_loader()) {
- k->set_prototype_header(markWord::biased_locking_prototype());
- }
- }
-
// Make a new dictionary entry.
Dictionary* dictionary = loader_data->dictionary();
InstanceKlass* sd_check = find_class(d_hash, name, dictionary);
@@ -2533,7 +2508,7 @@
// It's a primitive. (Void has a primitive mirror too.)
char ch = type->char_at(0);
- assert(is_java_primitive(char2type(ch)) || ch == 'V', "");
+ assert(is_java_primitive(char2type(ch)) || ch == JVM_SIGNATURE_VOID, "");
return Handle(THREAD, find_java_mirror_for_type(ch));
} else if (FieldType::is_obj(type) || FieldType::is_array(type)) {
--- a/src/hotspot/share/classfile/systemDictionary.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -155,6 +155,7 @@
do_klass(reflect_ConstantPool_klass, reflect_ConstantPool ) \
do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, reflect_UnsafeStaticFieldAccessorImpl ) \
do_klass(reflect_CallerSensitive_klass, reflect_CallerSensitive ) \
+ do_klass(reflect_NativeConstructorAccessorImpl_klass, reflect_NativeConstructorAccessorImpl ) \
\
/* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
do_klass(DirectMethodHandle_klass, java_lang_invoke_DirectMethodHandle ) \
@@ -218,7 +219,6 @@
\
/*end*/
-
class SystemDictionary : AllStatic {
friend class BootstrapInfo;
friend class VMStructs;
@@ -382,7 +382,6 @@
int limit = (int)end_id + 1;
resolve_wk_klasses_until((WKID) limit, start_id, THREAD);
}
-
public:
#define WK_KLASS_DECLARE(name, symbol) \
static InstanceKlass* name() { return check_klass(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); } \
@@ -429,9 +428,6 @@
}
public:
- // Tells whether ClassLoader.checkPackageAccess is present
- static bool has_checkPackageAccess() { return _has_checkPackageAccess; }
-
static bool Parameter_klass_loaded() { return WK_KLASS(reflect_Parameter_klass) != NULL; }
static bool Class_klass_loaded() { return WK_KLASS(Class_klass) != NULL; }
static bool Cloneable_klass_loaded() { return WK_KLASS(Cloneable_klass) != NULL; }
@@ -630,21 +626,6 @@
// Basic find on classes in the midst of being loaded
static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
- // Add a placeholder for a class being loaded
- static void add_placeholder(int index,
- Symbol* class_name,
- ClassLoaderData* loader_data);
- static void remove_placeholder(int index,
- Symbol* class_name,
- ClassLoaderData* loader_data);
-
- // Performs cleanups after resolve_super_or_fail. This typically needs
- // to be called on failure.
- // Won't throw, but can block.
- static void resolution_cleanups(Symbol* class_name,
- ClassLoaderData* loader_data,
- TRAPS);
-
// Resolve well-known classes so they can be used like SystemDictionary::String_klass()
static void resolve_well_known_classes(TRAPS);
@@ -666,8 +647,6 @@
static oop _java_system_loader;
static oop _java_platform_loader;
- static bool _has_checkPackageAccess;
-
public:
static TableStatistics placeholders_statistics();
static TableStatistics loader_constraints_statistics();
--- a/src/hotspot/share/classfile/verificationType.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/verificationType.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -71,7 +71,7 @@
if (log_is_enabled(Debug, class, resolve)) {
Verifier::trace_class_resolution(from_class, klass);
}
- return InstanceKlass::cast(from_class)->is_subclass_of(this_class);
+ return from_class->is_subclass_of(this_class);
}
return false;
@@ -122,19 +122,19 @@
assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array");
Symbol* component;
switch (name()->char_at(1)) {
- case 'Z': return VerificationType(Boolean);
- case 'B': return VerificationType(Byte);
- case 'C': return VerificationType(Char);
- case 'S': return VerificationType(Short);
- case 'I': return VerificationType(Integer);
- case 'J': return VerificationType(Long);
- case 'F': return VerificationType(Float);
- case 'D': return VerificationType(Double);
- case '[':
+ case JVM_SIGNATURE_BOOLEAN: return VerificationType(Boolean);
+ case JVM_SIGNATURE_BYTE: return VerificationType(Byte);
+ case JVM_SIGNATURE_CHAR: return VerificationType(Char);
+ case JVM_SIGNATURE_SHORT: return VerificationType(Short);
+ case JVM_SIGNATURE_INT: return VerificationType(Integer);
+ case JVM_SIGNATURE_LONG: return VerificationType(Long);
+ case JVM_SIGNATURE_FLOAT: return VerificationType(Float);
+ case JVM_SIGNATURE_DOUBLE: return VerificationType(Double);
+ case JVM_SIGNATURE_ARRAY:
component = context->create_temporary_symbol(
name(), 1, name()->utf8_length());
return VerificationType::reference_type(component);
- case 'L':
+ case JVM_SIGNATURE_CLASS:
component = context->create_temporary_symbol(
name(), 2, name()->utf8_length() - 1);
return VerificationType::reference_type(component);
--- a/src/hotspot/share/classfile/verificationType.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/verificationType.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -209,24 +209,24 @@
bool is_x_array(char sig) const {
return is_null() || (is_array() && (name()->char_at(1) == sig));
}
- bool is_int_array() const { return is_x_array('I'); }
- bool is_byte_array() const { return is_x_array('B'); }
- bool is_bool_array() const { return is_x_array('Z'); }
- bool is_char_array() const { return is_x_array('C'); }
- bool is_short_array() const { return is_x_array('S'); }
- bool is_long_array() const { return is_x_array('J'); }
- bool is_float_array() const { return is_x_array('F'); }
- bool is_double_array() const { return is_x_array('D'); }
- bool is_object_array() const { return is_x_array('L'); }
- bool is_array_array() const { return is_x_array('['); }
+ bool is_int_array() const { return is_x_array(JVM_SIGNATURE_INT); }
+ bool is_byte_array() const { return is_x_array(JVM_SIGNATURE_BYTE); }
+ bool is_bool_array() const { return is_x_array(JVM_SIGNATURE_BOOLEAN); }
+ bool is_char_array() const { return is_x_array(JVM_SIGNATURE_CHAR); }
+ bool is_short_array() const { return is_x_array(JVM_SIGNATURE_SHORT); }
+ bool is_long_array() const { return is_x_array(JVM_SIGNATURE_LONG); }
+ bool is_float_array() const { return is_x_array(JVM_SIGNATURE_FLOAT); }
+ bool is_double_array() const { return is_x_array(JVM_SIGNATURE_DOUBLE); }
+ bool is_object_array() const { return is_x_array(JVM_SIGNATURE_CLASS); }
+ bool is_array_array() const { return is_x_array(JVM_SIGNATURE_ARRAY); }
bool is_reference_array() const
{ return is_object_array() || is_array_array(); }
bool is_object() const
{ return (is_reference() && !is_null() && name()->utf8_length() >= 1 &&
- name()->char_at(0) != '['); }
+ name()->char_at(0) != JVM_SIGNATURE_ARRAY); }
bool is_array() const
{ return (is_reference() && !is_null() && name()->utf8_length() >= 2 &&
- name()->char_at(0) == '['); }
+ name()->char_at(0) == JVM_SIGNATURE_ARRAY); }
bool is_uninitialized() const
{ return ((_u._data & Uninitialized) == Uninitialized); }
bool is_uninitialized_this() const
@@ -322,7 +322,7 @@
int dimensions() const {
assert(is_array(), "Must be an array");
int index = 0;
- while (name()->char_at(index) == '[') index++;
+ while (name()->char_at(index) == JVM_SIGNATURE_ARRAY) index++;
return index;
}
--- a/src/hotspot/share/classfile/verifier.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/verifier.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -2852,7 +2852,7 @@
}
}
- if (method_name->char_at(0) == '<') {
+ if (method_name->char_at(0) == JVM_SIGNATURE_SPECIAL) {
// Make sure <init> can only be invoked by invokespecial
if (opcode != Bytecodes::_invokespecial ||
method_name != vmSymbols::object_initializer_name()) {
@@ -3028,21 +3028,23 @@
// Check for more than MAX_ARRAY_DIMENSIONS
length = (int)strlen(component_name);
if (length > MAX_ARRAY_DIMENSIONS &&
- component_name[MAX_ARRAY_DIMENSIONS - 1] == '[') {
+ component_name[MAX_ARRAY_DIMENSIONS - 1] == JVM_SIGNATURE_ARRAY) {
verify_error(ErrorContext::bad_code(bci),
"Illegal anewarray instruction, array has more than 255 dimensions");
}
// add one dimension to component
length++;
arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length + 1);
- int n = os::snprintf(arr_sig_str, length + 1, "[%s", component_name);
+ int n = os::snprintf(arr_sig_str, length + 1, "%c%s",
+ JVM_SIGNATURE_ARRAY, component_name);
assert(n == length, "Unexpected number of characters in string");
} else { // it's an object or interface
const char* component_name = component_type.name()->as_utf8();
// add one dimension to component with 'L' prepended and ';' postpended.
length = (int)strlen(component_name) + 3;
arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length + 1);
- int n = os::snprintf(arr_sig_str, length + 1, "[L%s;", component_name);
+ int n = os::snprintf(arr_sig_str, length + 1, "%c%c%s;",
+ JVM_SIGNATURE_ARRAY, JVM_SIGNATURE_CLASS, component_name);
assert(n == length, "Unexpected number of characters in string");
}
Symbol* arr_sig = create_temporary_symbol(arr_sig_str, length);
--- a/src/hotspot/share/classfile/vmSymbols.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/vmSymbols.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -970,7 +970,7 @@
case F_RNY:fname = "native synchronized "; break;
default: break;
}
- const char* kptr = strrchr(kname, '/');
+ const char* kptr = strrchr(kname, JVM_SIGNATURE_SLASH);
if (kptr != NULL) kname = kptr + 1;
int len = jio_snprintf(buf, buflen, "%s: %s%s.%s%s",
str, fname, kname, mname, sname);
--- a/src/hotspot/share/classfile/vmSymbols.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/classfile/vmSymbols.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -243,6 +243,7 @@
template(reflect_Reflection, "jdk/internal/reflect/Reflection") \
template(reflect_CallerSensitive, "jdk/internal/reflect/CallerSensitive") \
template(reflect_CallerSensitive_signature, "Ljdk/internal/reflect/CallerSensitive;") \
+ template(reflect_NativeConstructorAccessorImpl, "jdk/internal/reflect/NativeConstructorAccessorImpl")\
template(checkedExceptions_name, "checkedExceptions") \
template(clazz_name, "clazz") \
template(exceptionTypes_name, "exceptionTypes") \
--- a/src/hotspot/share/code/nmethod.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/code/nmethod.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1826,57 +1826,183 @@
}
}
-#define NMETHOD_SENTINEL ((nmethod*)badAddress)
-
nmethod* volatile nmethod::_oops_do_mark_nmethods;
-// An nmethod is "marked" if its _mark_link is set non-null.
-// Even if it is the end of the linked list, it will have a non-null link value,
-// as long as it is on the list.
-// This code must be MP safe, because it is used from parallel GC passes.
-bool nmethod::test_set_oops_do_mark() {
- assert(nmethod::oops_do_marking_is_active(), "oops_do_marking_prologue must be called");
- if (_oops_do_mark_link == NULL) {
- // Claim this nmethod for this thread to mark.
- if (Atomic::replace_if_null(NMETHOD_SENTINEL, &_oops_do_mark_link)) {
- // Atomically append this nmethod (now claimed) to the head of the list:
- nmethod* observed_mark_nmethods = _oops_do_mark_nmethods;
- for (;;) {
- nmethod* required_mark_nmethods = observed_mark_nmethods;
- _oops_do_mark_link = required_mark_nmethods;
- observed_mark_nmethods =
- Atomic::cmpxchg(this, &_oops_do_mark_nmethods, required_mark_nmethods);
- if (observed_mark_nmethods == required_mark_nmethods)
- break;
- }
- // Mark was clear when we first saw this guy.
- LogTarget(Trace, gc, nmethod) lt;
- if (lt.is_enabled()) {
- LogStream ls(lt);
- CompileTask::print(&ls, this, "oops_do, mark", /*short_form:*/ true);
- }
- return false;
+void nmethod::oops_do_log_change(const char* state) {
+ LogTarget(Trace, gc, nmethod) lt;
+ if (lt.is_enabled()) {
+ LogStream ls(lt);
+ CompileTask::print(&ls, this, state, true /* short_form */);
+ }
+}
+
+bool nmethod::oops_do_try_claim() {
+ if (oops_do_try_claim_weak_request()) {
+ nmethod* result = oops_do_try_add_to_list_as_weak_done();
+ assert(result == NULL, "adding to global list as weak done must always succeed.");
+ return true;
+ }
+ return false;
+}
+
+bool nmethod::oops_do_try_claim_weak_request() {
+ assert(SafepointSynchronize::is_at_safepoint(), "only at safepoint");
+
+ if ((_oops_do_mark_link == NULL) &&
+ (Atomic::replace_if_null(mark_link(this, claim_weak_request_tag), &_oops_do_mark_link))) {
+ oops_do_log_change("oops_do, mark weak request");
+ return true;
+ }
+ return false;
+}
+
+void nmethod::oops_do_set_strong_done(nmethod* old_head) {
+ _oops_do_mark_link = mark_link(old_head, claim_strong_done_tag);
+}
+
+nmethod::oops_do_mark_link* nmethod::oops_do_try_claim_strong_done() {
+ assert(SafepointSynchronize::is_at_safepoint(), "only at safepoint");
+
+ oops_do_mark_link* old_next = Atomic::cmpxchg(mark_link(this, claim_strong_done_tag), &_oops_do_mark_link, mark_link(NULL, claim_weak_request_tag));
+ if (old_next == NULL) {
+ oops_do_log_change("oops_do, mark strong done");
+ }
+ return old_next;
+}
+
+nmethod::oops_do_mark_link* nmethod::oops_do_try_add_strong_request(nmethod::oops_do_mark_link* next) {
+ assert(SafepointSynchronize::is_at_safepoint(), "only at safepoint");
+ assert(next == mark_link(this, claim_weak_request_tag), "Should be claimed as weak");
+
+ oops_do_mark_link* old_next = Atomic::cmpxchg(mark_link(this, claim_strong_request_tag), &_oops_do_mark_link, next);
+ if (old_next == next) {
+ oops_do_log_change("oops_do, mark strong request");
+ }
+ return old_next;
+}
+
+bool nmethod::oops_do_try_claim_weak_done_as_strong_done(nmethod::oops_do_mark_link* next) {
+ assert(SafepointSynchronize::is_at_safepoint(), "only at safepoint");
+ assert(extract_state(next) == claim_weak_done_tag, "Should be claimed as weak done");
+
+ oops_do_mark_link* old_next = Atomic::cmpxchg(mark_link(extract_nmethod(next), claim_strong_done_tag), &_oops_do_mark_link, next);
+ if (old_next == next) {
+ oops_do_log_change("oops_do, mark weak done -> mark strong done");
+ return true;
+ }
+ return false;
+}
+
+nmethod* nmethod::oops_do_try_add_to_list_as_weak_done() {
+ assert(SafepointSynchronize::is_at_safepoint(), "only at safepoint");
+
+ assert(extract_state(_oops_do_mark_link) == claim_weak_request_tag ||
+ extract_state(_oops_do_mark_link) == claim_strong_request_tag,
+ "must be but is nmethod " PTR_FORMAT " %u", p2i(extract_nmethod(_oops_do_mark_link)), extract_state(_oops_do_mark_link));
+
+ nmethod* old_head = Atomic::xchg(this, &_oops_do_mark_nmethods);
+ // Self-loop if needed.
+ if (old_head == NULL) {
+ old_head = this;
+ }
+ // Try to install end of list and weak done tag.
+ if (Atomic::cmpxchg(mark_link(old_head, claim_weak_done_tag), &_oops_do_mark_link, mark_link(this, claim_weak_request_tag)) == mark_link(this, claim_weak_request_tag)) {
+ oops_do_log_change("oops_do, mark weak done");
+ return NULL;
+ } else {
+ return old_head;
+ }
+}
+
+void nmethod::oops_do_add_to_list_as_strong_done() {
+ assert(SafepointSynchronize::is_at_safepoint(), "only at safepoint");
+
+ nmethod* old_head = Atomic::xchg(this, &_oops_do_mark_nmethods);
+ // Self-loop if needed.
+ if (old_head == NULL) {
+ old_head = this;
+ }
+ assert(_oops_do_mark_link == mark_link(this, claim_strong_done_tag), "must be but is nmethod " PTR_FORMAT " state %u",
+ p2i(extract_nmethod(_oops_do_mark_link)), extract_state(_oops_do_mark_link));
+
+ oops_do_set_strong_done(old_head);
+}
+
+void nmethod::oops_do_process_weak(OopsDoProcessor* p) {
+ if (!oops_do_try_claim_weak_request()) {
+ // Failed to claim for weak processing.
+ oops_do_log_change("oops_do, mark weak request fail");
+ return;
+ }
+
+ p->do_regular_processing(this);
+
+ nmethod* old_head = oops_do_try_add_to_list_as_weak_done();
+ if (old_head == NULL) {
+ return;
+ }
+ oops_do_log_change("oops_do, mark weak done fail");
+ // Adding to global list failed, another thread added a strong request.
+ assert(extract_state(_oops_do_mark_link) == claim_strong_request_tag,
+ "must be but is %u", extract_state(_oops_do_mark_link));
+
+ oops_do_log_change("oops_do, mark weak request -> mark strong done");
+
+ oops_do_set_strong_done(old_head);
+ // Do missing strong processing.
+ p->do_remaining_strong_processing(this);
+}
+
+void nmethod::oops_do_process_strong(OopsDoProcessor* p) {
+ oops_do_mark_link* next_raw = oops_do_try_claim_strong_done();
+ if (next_raw == NULL) {
+ p->do_regular_processing(this);
+ oops_do_add_to_list_as_strong_done();
+ return;
+ }
+ // Claim failed. Figure out why and handle it.
+ if (oops_do_has_weak_request(next_raw)) {
+ oops_do_mark_link* old = next_raw;
+ // Claim failed because being weak processed (state == "weak request").
+ // Try to request deferred strong processing.
+ next_raw = oops_do_try_add_strong_request(old);
+ if (next_raw == old) {
+ // Successfully requested deferred strong processing.
+ return;
}
+ // Failed because of a concurrent transition. No longer in "weak request" state.
}
- // On fall through, another racing thread marked this nmethod before we did.
- return true;
+ if (oops_do_has_any_strong_state(next_raw)) {
+ // Already claimed for strong processing or requested for such.
+ return;
+ }
+ if (oops_do_try_claim_weak_done_as_strong_done(next_raw)) {
+ // Successfully claimed "weak done" as "strong done". Do the missing marking.
+ p->do_remaining_strong_processing(this);
+ return;
+ }
+ // Claim failed, some other thread got it.
}
void nmethod::oops_do_marking_prologue() {
+ assert_at_safepoint();
+
log_trace(gc, nmethod)("oops_do_marking_prologue");
- assert(_oops_do_mark_nmethods == NULL, "must not call oops_do_marking_prologue twice in a row");
- // We use cmpxchg instead of regular assignment here because the user
- // may fork a bunch of threads, and we need them all to see the same state.
- nmethod* observed = Atomic::cmpxchg(NMETHOD_SENTINEL, &_oops_do_mark_nmethods, (nmethod*)NULL);
- guarantee(observed == NULL, "no races in this sequential code");
+ assert(_oops_do_mark_nmethods == NULL, "must be empty");
}
void nmethod::oops_do_marking_epilogue() {
- assert(_oops_do_mark_nmethods != NULL, "must not call oops_do_marking_epilogue twice in a row");
- nmethod* cur = _oops_do_mark_nmethods;
- while (cur != NMETHOD_SENTINEL) {
- assert(cur != NULL, "not NULL-terminated");
- nmethod* next = cur->_oops_do_mark_link;
+ assert_at_safepoint();
+
+ nmethod* next = _oops_do_mark_nmethods;
+ _oops_do_mark_nmethods = NULL;
+ if (next == NULL) {
+ return;
+ }
+ nmethod* cur;
+ do {
+ cur = next;
+ next = extract_nmethod(cur->_oops_do_mark_link);
cur->_oops_do_mark_link = NULL;
DEBUG_ONLY(cur->verify_oop_relocations());
@@ -1885,11 +2011,8 @@
LogStream ls(lt);
CompileTask::print(&ls, cur, "oops_do, unmark", /*short_form:*/ true);
}
- cur = next;
- }
- nmethod* required = _oops_do_mark_nmethods;
- nmethod* observed = Atomic::cmpxchg((nmethod*)NULL, &_oops_do_mark_nmethods, required);
- guarantee(observed == required, "no races in this sequential code");
+ // End if self-loop has been detected.
+ } while (cur != next);
log_trace(gc, nmethod)("oops_do_marking_epilogue");
}
@@ -2262,6 +2385,8 @@
assert(voc.ok(), "embedded oops must be OK");
Universe::heap()->verify_nmethod(this);
+ assert(_oops_do_mark_link == NULL, "_oops_do_mark_link for %s should be NULL but is " PTR_FORMAT,
+ nm->method()->external_name(), p2i(_oops_do_mark_link));
verify_scopes();
CompiledICLocker nm_verify(this);
--- a/src/hotspot/share/code/nmethod.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/code/nmethod.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -67,8 +67,8 @@
friend class NMethodSweeper;
friend class CodeCache; // scavengable oops
friend class JVMCINMethodData;
+
private:
-
// Shared fields for all nmethod's
int _entry_bci; // != InvocationEntryBci if this nmethod is an on-stack replacement method
jmethodID _jmethod_id; // Cache of method()->jmethod_id()
@@ -76,8 +76,119 @@
// To support simple linked-list chaining of nmethods:
nmethod* _osr_link; // from InstanceKlass::osr_nmethods_head
+ // STW two-phase nmethod root processing helpers.
+ //
+ // When determining liveness of a given nmethod to do code cache unloading,
+ // some collectors need to to different things depending on whether the nmethods
+ // need to absolutely be kept alive during root processing; "strong"ly reachable
+ // nmethods are known to be kept alive at root processing, but the liveness of
+ // "weak"ly reachable ones is to be determined later.
+ //
+ // We want to allow strong and weak processing of nmethods by different threads
+ // at the same time without heavy synchronization. Additional constraints are
+ // to make sure that every nmethod is processed a minimal amount of time, and
+ // nmethods themselves are always iterated at most once at a particular time.
+ //
+ // Note that strong processing work must be a superset of weak processing work
+ // for this code to work.
+ //
+ // We store state and claim information in the _oops_do_mark_link member, using
+ // the two LSBs for the state and the remaining upper bits for linking together
+ // nmethods that were already visited.
+ // The last element is self-looped, i.e. points to itself to avoid some special
+ // "end-of-list" sentinel value.
+ //
+ // _oops_do_mark_link special values:
+ //
+ // _oops_do_mark_link == NULL: the nmethod has not been visited at all yet, i.e.
+ // is Unclaimed.
+ //
+ // For other values, its lowest two bits indicate the following states of the nmethod:
+ //
+ // weak_request (WR): the nmethod has been claimed by a thread for weak processing
+ // weak_done (WD): weak processing has been completed for this nmethod.
+ // strong_request (SR): the nmethod has been found to need strong processing while
+ // being weak processed.
+ // strong_done (SD): strong processing has been completed for this nmethod .
+ //
+ // The following shows the _only_ possible progressions of the _oops_do_mark_link
+ // pointer.
+ //
+ // Given
+ // N as the nmethod
+ // X the current next value of _oops_do_mark_link
+ //
+ // Unclaimed (C)-> N|WR (C)-> X|WD: the nmethod has been processed weakly by
+ // a single thread.
+ // Unclaimed (C)-> N|WR (C)-> X|WD (O)-> X|SD: after weak processing has been
+ // completed (as above) another thread found that the nmethod needs strong
+ // processing after all.
+ // Unclaimed (C)-> N|WR (O)-> N|SR (C)-> X|SD: during weak processing another
+ // thread finds that the nmethod needs strong processing, marks it as such and
+ // terminates. The original thread completes strong processing.
+ // Unclaimed (C)-> N|SD (C)-> X|SD: the nmethod has been processed strongly from
+ // the beginning by a single thread.
+ //
+ // "|" describes the concatentation of bits in _oops_do_mark_link.
+ //
+ // The diagram also describes the threads responsible for changing the nmethod to
+ // the next state by marking the _transition_ with (C) and (O), which mean "current"
+ // and "other" thread respectively.
+ //
+ struct oops_do_mark_link; // Opaque data type.
+
+ // States used for claiming nmethods during root processing.
+ static const uint claim_weak_request_tag = 0;
+ static const uint claim_weak_done_tag = 1;
+ static const uint claim_strong_request_tag = 2;
+ static const uint claim_strong_done_tag = 3;
+
+ static oops_do_mark_link* mark_link(nmethod* nm, uint tag) {
+ assert(tag <= claim_strong_done_tag, "invalid tag %u", tag);
+ assert(is_aligned(nm, 4), "nmethod pointer must have zero lower two LSB");
+ return (oops_do_mark_link*)(((uintptr_t)nm & ~0x3) | tag);
+ }
+
+ static uint extract_state(oops_do_mark_link* link) {
+ return (uint)((uintptr_t)link & 0x3);
+ }
+
+ static nmethod* extract_nmethod(oops_do_mark_link* link) {
+ return (nmethod*)((uintptr_t)link & ~0x3);
+ }
+
+ void oops_do_log_change(const char* state);
+
+ static bool oops_do_has_weak_request(oops_do_mark_link* next) {
+ return extract_state(next) == claim_weak_request_tag;
+ }
+
+ static bool oops_do_has_any_strong_state(oops_do_mark_link* next) {
+ return extract_state(next) >= claim_strong_request_tag;
+ }
+
+ // Attempt Unclaimed -> N|WR transition. Returns true if successful.
+ bool oops_do_try_claim_weak_request();
+
+ // Attempt Unclaimed -> N|SD transition. Returns the current link.
+ oops_do_mark_link* oops_do_try_claim_strong_done();
+ // Attempt N|WR -> X|WD transition. Returns NULL if successful, X otherwise.
+ nmethod* oops_do_try_add_to_list_as_weak_done();
+
+ // Attempt X|WD -> N|SR transition. Returns the current link.
+ oops_do_mark_link* oops_do_try_add_strong_request(oops_do_mark_link* next);
+ // Attempt X|WD -> X|SD transition. Returns true if successful.
+ bool oops_do_try_claim_weak_done_as_strong_done(oops_do_mark_link* next);
+
+ // Do the N|SD -> X|SD transition.
+ void oops_do_add_to_list_as_strong_done();
+
+ // Sets this nmethod as strongly claimed (as part of N|SD -> X|SD and N|SR -> X|SD
+ // transitions).
+ void oops_do_set_strong_done(nmethod* old_head);
+
static nmethod* volatile _oops_do_mark_nmethods;
- nmethod* volatile _oops_do_mark_link;
+ oops_do_mark_link* volatile _oops_do_mark_link;
// offsets for entry points
address _entry_point; // entry point with class check
@@ -480,11 +591,30 @@
void oops_do(OopClosure* f) { oops_do(f, false); }
void oops_do(OopClosure* f, bool allow_dead);
- bool test_set_oops_do_mark();
+ // All-in-one claiming of nmethods: returns true if the caller successfully claimed that
+ // nmethod.
+ bool oops_do_try_claim();
+
+ // Class containing callbacks for the oops_do_process_weak/strong() methods
+ // below.
+ class OopsDoProcessor {
+ public:
+ // Process the oops of the given nmethod based on whether it has been called
+ // in a weak or strong processing context, i.e. apply either weak or strong
+ // work on it.
+ virtual void do_regular_processing(nmethod* nm) = 0;
+ // Assuming that the oops of the given nmethod has already been its weak
+ // processing applied, apply the remaining strong processing part.
+ virtual void do_remaining_strong_processing(nmethod* nm) = 0;
+ };
+
+ // The following two methods do the work corresponding to weak/strong nmethod
+ // processing.
+ void oops_do_process_weak(OopsDoProcessor* p);
+ void oops_do_process_strong(OopsDoProcessor* p);
+
static void oops_do_marking_prologue();
static void oops_do_marking_epilogue();
- static bool oops_do_marking_is_active() { return _oops_do_mark_nmethods != NULL; }
- bool test_oops_do_mark() { return _oops_do_mark_link != NULL; }
private:
ScopeDesc* scope_desc_in(address begin, address end);
--- a/src/hotspot/share/compiler/methodMatcher.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/compiler/methodMatcher.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -264,11 +264,13 @@
c_match = check_mode(class_name, error_msg);
m_match = check_mode(method_name, error_msg);
- if ((strchr(class_name, '<') != NULL) || (strchr(class_name, '>') != NULL)) {
+ if ((strchr(class_name, JVM_SIGNATURE_SPECIAL) != NULL) ||
+ (strchr(class_name, JVM_SIGNATURE_ENDSPECIAL) != NULL)) {
error_msg = "Chars '<' and '>' not allowed in class name";
return;
}
- if ((strchr(method_name, '<') != NULL) || (strchr(method_name, '>') != NULL)) {
+ if ((strchr(method_name, JVM_SIGNATURE_SPECIAL) != NULL) ||
+ (strchr(method_name, JVM_SIGNATURE_ENDSPECIAL) != NULL)) {
if ((strncmp("<init>", method_name, 255) != 0) && (strncmp("<clinit>", method_name, 255) != 0)) {
error_msg = "Chars '<' and '>' only allowed in <init> and <clinit>";
return;
--- a/src/hotspot/share/compiler/oopMap.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/compiler/oopMap.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -308,10 +308,13 @@
// handle derived pointers first (otherwise base pointer may be
// changed before derived pointer offset has been collected)
- OopMapValue omv;
{
- OopMapStream oms(map);
- if (!oms.is_done()) {
+ for (OopMapStream oms(map); !oms.is_done(); oms.next()) {
+ OopMapValue omv = oms.current();
+ if (omv.type() != OopMapValue::derived_oop_value) {
+ continue;
+ }
+
#ifndef TIERED
COMPILER1_PRESENT(ShouldNotReachHere();)
#if INCLUDE_JVMCI
@@ -320,31 +323,25 @@
}
#endif
#endif // !TIERED
- do {
- omv = oms.current();
- if (omv.type() == OopMapValue::derived_oop_value) {
- oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
- guarantee(loc != NULL, "missing saved register");
- oop *derived_loc = loc;
- oop *base_loc = fr->oopmapreg_to_location(omv.content_reg(), reg_map);
- // Ignore NULL oops and decoded NULL narrow oops which
- // equal to CompressedOops::base() when a narrow oop
- // implicit null check is used in compiled code.
- // The narrow_oop_base could be NULL or be the address
- // of the page below heap depending on compressed oops mode.
- if (base_loc != NULL && *base_loc != NULL && !CompressedOops::is_base(*base_loc)) {
- derived_oop_fn(base_loc, derived_loc);
- }
- }
- oms.next();
- } while (!oms.is_done());
+ oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
+ guarantee(loc != NULL, "missing saved register");
+ oop *derived_loc = loc;
+ oop *base_loc = fr->oopmapreg_to_location(omv.content_reg(), reg_map);
+ // Ignore NULL oops and decoded NULL narrow oops which
+ // equal to CompressedOops::base() when a narrow oop
+ // implicit null check is used in compiled code.
+ // The narrow_oop_base could be NULL or be the address
+ // of the page below heap depending on compressed oops mode.
+ if (base_loc != NULL && *base_loc != NULL && !CompressedOops::is_base(*base_loc)) {
+ derived_oop_fn(base_loc, derived_loc);
+ }
}
}
{
// We want coop and oop oop_types
for (OopMapStream oms(map); !oms.is_done(); oms.next()) {
- omv = oms.current();
+ OopMapValue omv = oms.current();
oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
// It should be an error if no location can be found for a
// register mentioned as contained an oop of some kind. Maybe
--- a/src/hotspot/share/gc/g1/g1Analytics.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1Analytics.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -229,10 +229,6 @@
_rs_length_seq->add(rs_length);
}
-size_t G1Analytics::predict_rs_length_diff() const {
- return get_new_size_prediction(_rs_length_diff_seq);
-}
-
double G1Analytics::predict_alloc_rate_ms() const {
return get_new_prediction(_alloc_rate_ms_seq);
}
@@ -334,7 +330,7 @@
}
size_t G1Analytics::predict_rs_length() const {
- return get_new_size_prediction(_rs_length_seq);
+ return get_new_size_prediction(_rs_length_seq) + get_new_prediction(_rs_length_diff_seq);
}
size_t G1Analytics::predict_pending_cards() const {
--- a/src/hotspot/share/gc/g1/g1Analytics.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1Analytics.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -115,8 +115,6 @@
void report_pending_cards(double pending_cards);
void report_rs_length(double rs_length);
- size_t predict_rs_length_diff() const;
-
double predict_alloc_rate_ms() const;
int num_alloc_rate_ms() const;
--- a/src/hotspot/share/gc/g1/g1CodeBlobClosure.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1CodeBlobClosure.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -26,6 +26,7 @@
#include "code/nmethod.hpp"
#include "gc/g1/g1CodeBlobClosure.hpp"
#include "gc/g1/g1CollectedHeap.inline.hpp"
+#include "gc/g1/g1ConcurrentMark.inline.hpp"
#include "gc/g1/heapRegion.hpp"
#include "gc/g1/heapRegionRemSet.hpp"
#include "oops/access.inline.hpp"
@@ -52,14 +53,62 @@
do_oop_work(o);
}
-void G1CodeBlobClosure::do_code_blob(CodeBlob* cb) {
- nmethod* nm = cb->as_nmethod_or_null();
- if (nm != NULL) {
- if (!nm->test_set_oops_do_mark()) {
- _oc.set_nm(nm);
- nm->oops_do(&_oc);
- nm->fix_oop_relocations();
- }
+template<typename T>
+void G1CodeBlobClosure::MarkingOopClosure::do_oop_work(T* p) {
+ T oop_or_narrowoop = RawAccess<>::oop_load(p);
+ if (!CompressedOops::is_null(oop_or_narrowoop)) {
+ oop o = CompressedOops::decode_not_null(oop_or_narrowoop);
+ _cm->mark_in_next_bitmap(_worker_id, o);
}
}
+G1CodeBlobClosure::MarkingOopClosure::MarkingOopClosure(uint worker_id) :
+ _cm(G1CollectedHeap::heap()->concurrent_mark()), _worker_id(worker_id) { }
+
+void G1CodeBlobClosure::MarkingOopClosure::do_oop(oop* o) {
+ do_oop_work(o);
+}
+
+void G1CodeBlobClosure::MarkingOopClosure::do_oop(narrowOop* o) {
+ do_oop_work(o);
+}
+
+void G1CodeBlobClosure::do_evacuation_and_fixup(nmethod* nm) {
+ _oc.set_nm(nm);
+ nm->oops_do(&_oc);
+ nm->fix_oop_relocations();
+}
+
+void G1CodeBlobClosure::do_marking(nmethod* nm) {
+ nm->oops_do(&_marking_oc);
+}
+
+class G1NmethodProcessor : public nmethod::OopsDoProcessor {
+ G1CodeBlobClosure* _cl;
+
+public:
+ G1NmethodProcessor(G1CodeBlobClosure* cl) : _cl(cl) { }
+
+ void do_regular_processing(nmethod* nm) {
+ _cl->do_evacuation_and_fixup(nm);
+ }
+
+ void do_remaining_strong_processing(nmethod* nm) {
+ _cl->do_marking(nm);
+ }
+};
+
+void G1CodeBlobClosure::do_code_blob(CodeBlob* cb) {
+ nmethod* nm = cb->as_nmethod_or_null();
+ if (nm == NULL) {
+ return;
+ }
+
+ G1NmethodProcessor cl(this);
+
+ if (_strong) {
+ nm->oops_do_process_strong(&cl);
+ } else {
+ nm->oops_do_process_weak(&cl);
+ }
+}
--- a/src/hotspot/share/gc/g1/g1CodeBlobClosure.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1CodeBlobClosure.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -28,9 +28,11 @@
#include "gc/g1/g1CollectedHeap.hpp"
#include "memory/iterator.hpp"
+class G1ConcurrentMark;
class nmethod;
class G1CodeBlobClosure : public CodeBlobClosure {
+ // Gather nmethod remembered set entries.
class HeapRegionGatheringOopClosure : public OopClosure {
G1CollectedHeap* _g1h;
OopClosure* _work;
@@ -50,9 +52,35 @@
}
};
+ // Mark all oops below TAMS.
+ class MarkingOopClosure : public OopClosure {
+ G1ConcurrentMark* _cm;
+ uint _worker_id;
+
+ template <typename T>
+ void do_oop_work(T* p);
+
+ public:
+ MarkingOopClosure(uint worker_id);
+
+ void do_oop(oop* o);
+ void do_oop(narrowOop* o);
+ };
+
HeapRegionGatheringOopClosure _oc;
+ MarkingOopClosure _marking_oc;
+
+ bool _strong;
+
+ void do_code_blob_weak(CodeBlob* cb);
+ void do_code_blob_strong(CodeBlob* cb);
+
public:
- G1CodeBlobClosure(OopClosure* oc) : _oc(oc) {}
+ G1CodeBlobClosure(uint worker_id, OopClosure* oc, bool strong) :
+ _oc(oc), _marking_oc(worker_id), _strong(strong) { }
+
+ void do_evacuation_and_fixup(nmethod* nm);
+ void do_marking(nmethod* nm);
void do_code_blob(CodeBlob* cb);
};
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1630,7 +1630,6 @@
}
jint G1CollectedHeap::initialize() {
- os::enable_vtime();
// Necessary to satisfy locking discipline assertions.
@@ -3614,6 +3613,7 @@
p->record_or_add_time_secs(termination_phase, worker_id, cl.term_time());
p->record_or_add_thread_work_item(termination_phase, worker_id, cl.term_attempts());
}
+ assert(pss->trim_ticks().seconds() == 0.0, "Unexpected partial trimming during evacuation");
}
virtual void start_work(uint worker_id) { }
@@ -3655,22 +3655,14 @@
class G1EvacuateRegionsTask : public G1EvacuateRegionsBaseTask {
G1RootProcessor* _root_processor;
- void verify_trim_ticks(G1ParScanThreadState* pss, const char* location) {
- assert(pss->trim_ticks().seconds() == 0.0, "Unexpected partial trimming during evacuation at %s %.3lf " JLONG_FORMAT, location, pss->trim_ticks().seconds(), pss->trim_ticks().value());
- }
-
void scan_roots(G1ParScanThreadState* pss, uint worker_id) {
_root_processor->evacuate_roots(pss, worker_id);
- verify_trim_ticks(pss, "roots");
_g1h->rem_set()->scan_heap_roots(pss, worker_id, G1GCPhaseTimes::ScanHR, G1GCPhaseTimes::ObjCopy);
- verify_trim_ticks(pss, "heap roots");
_g1h->rem_set()->scan_collection_set_regions(pss, worker_id, G1GCPhaseTimes::ScanHR, G1GCPhaseTimes::CodeRoots, G1GCPhaseTimes::ObjCopy);
- verify_trim_ticks(pss, "scan cset");
}
void evacuate_live_objects(G1ParScanThreadState* pss, uint worker_id) {
G1EvacuateRegionsBaseTask::evacuate_live_objects(pss, worker_id, G1GCPhaseTimes::ObjCopy, G1GCPhaseTimes::Termination);
- verify_trim_ticks(pss, "evac live");
}
void start_work(uint worker_id) {
@@ -4076,7 +4068,7 @@
Atomic::add(r->rem_set()->occupied_locked(), &_rs_length);
if (!is_young) {
- g1h->_hot_card_cache->reset_card_counts(r);
+ g1h->hot_card_cache()->reset_card_counts(r);
}
if (!evacuation_failed) {
@@ -4106,7 +4098,7 @@
_cl.complete_work();
G1Policy* policy = G1CollectedHeap::heap()->policy();
- policy->record_max_rs_length(_rs_length);
+ policy->record_rs_length(_rs_length);
policy->cset_regions_freed();
}
public:
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -129,7 +129,6 @@
};
class G1CollectedHeap : public CollectedHeap {
- friend class G1FreeCollectionSetTask;
friend class VM_CollectForMetadataAllocation;
friend class VM_G1CollectForAllocation;
friend class VM_G1CollectFull;
@@ -1138,7 +1137,7 @@
return _reserved.contains(addr);
}
- G1HotCardCache* g1_hot_card_cache() const { return _hot_card_cache; }
+ G1HotCardCache* hot_card_cache() const { return _hot_card_cache; }
G1CardTable* card_table() const {
return _card_table;
--- a/src/hotspot/share/gc/g1/g1FullCollector.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -198,13 +198,17 @@
// Recursively traverse all live objects and mark them.
GCTraceTime(Info, gc, phases) info("Phase 1: Mark live objects", scope()->timer());
- // Do the actual marking.
- G1FullGCMarkTask marking_task(this);
- run_task(&marking_task);
+ {
+ // Do the actual marking.
+ G1FullGCMarkTask marking_task(this);
+ run_task(&marking_task);
+ }
- // Process references discovered during marking.
- G1FullGCReferenceProcessingExecutor reference_processing(this);
- reference_processing.execute(scope()->timer(), scope()->tracer());
+ {
+ // Process references discovered during marking.
+ G1FullGCReferenceProcessingExecutor reference_processing(this);
+ reference_processing.execute(scope()->timer(), scope()->tracer());
+ }
// Weak oops cleanup.
{
--- a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -114,8 +114,9 @@
hr->rem_set()->clear();
hr->clear_cardtable();
- if (_g1h->g1_hot_card_cache()->use_cache()) {
- _g1h->g1_hot_card_cache()->reset_card_counts(hr);
+ G1HotCardCache* hcc = _g1h->hot_card_cache();
+ if (hcc->use_cache()) {
+ hcc->reset_card_counts(hr);
}
}
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -62,7 +62,6 @@
_gc_par_phases[JVMTIRoots] = new WorkerDataArray<double>(max_gc_threads, "JVMTI Roots (ms):");
AOT_ONLY(_gc_par_phases[AOTCodeRoots] = new WorkerDataArray<double>(max_gc_threads, "AOT Root Scan (ms):");)
_gc_par_phases[CMRefRoots] = new WorkerDataArray<double>(max_gc_threads, "CM RefProcessor Roots (ms):");
- _gc_par_phases[WaitForStrongRoots] = new WorkerDataArray<double>(max_gc_threads, "Wait For Strong Roots (ms):");
_gc_par_phases[MergeER] = new WorkerDataArray<double>(max_gc_threads, "Eager Reclaim (ms):");
@@ -165,7 +164,7 @@
void G1GCPhaseTimes::reset() {
_cur_collection_initial_evac_time_ms = 0.0;
- _cur_optional_evac_ms = 0.0;
+ _cur_optional_evac_time_ms = 0.0;
_cur_collection_code_root_fixup_time_ms = 0.0;
_cur_strong_code_root_purge_time_ms = 0.0;
_cur_merge_heap_roots_time_ms = 0.0;
@@ -417,14 +416,14 @@
}
double G1GCPhaseTimes::print_evacuate_optional_collection_set() const {
- const double sum_ms = _cur_optional_evac_ms + _cur_optional_merge_heap_roots_time_ms;
+ const double sum_ms = _cur_optional_evac_time_ms + _cur_optional_merge_heap_roots_time_ms;
if (sum_ms > 0) {
info_time("Merge Optional Heap Roots", _cur_optional_merge_heap_roots_time_ms);
debug_time("Prepare Optional Merge Heap Roots", _cur_optional_prepare_merge_heap_roots_time_ms);
debug_phase(_gc_par_phases[OptMergeRS]);
- info_time("Evacuate Optional Collection Set", _cur_optional_evac_ms);
+ info_time("Evacuate Optional Collection Set", _cur_optional_evac_time_ms);
debug_phase(_gc_par_phases[OptScanHR]);
debug_phase(_gc_par_phases[OptObjCopy]);
debug_phase(_gc_par_phases[OptCodeRoots]);
@@ -566,7 +565,6 @@
"JVMTIRoots",
AOT_ONLY("AOTCodeRoots" COMMA)
"CMRefRoots",
- "WaitForStrongRoots",
"MergeER",
"MergeRS",
"OptMergeRS",
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -57,7 +57,6 @@
JVMTIRoots,
AOT_ONLY(AOTCodeRoots COMMA)
CMRefRoots,
- WaitForStrongRoots,
MergeER,
MergeRS,
OptMergeRS,
@@ -83,7 +82,7 @@
};
static const GCParPhases ExtRootScanSubPhasesFirst = ThreadRoots;
- static const GCParPhases ExtRootScanSubPhasesLast = WaitForStrongRoots;
+ static const GCParPhases ExtRootScanSubPhasesLast = CMRefRoots;
enum GCMergeRSWorkTimes {
MergeRSMergedSparse,
@@ -157,7 +156,7 @@
WorkerDataArray<size_t>* _redirtied_cards;
double _cur_collection_initial_evac_time_ms;
- double _cur_optional_evac_ms;
+ double _cur_optional_evac_time_ms;
double _cur_collection_code_root_fixup_time_ms;
double _cur_strong_code_root_purge_time_ms;
@@ -297,7 +296,7 @@
}
void record_or_add_optional_evac_time(double ms) {
- _cur_optional_evac_ms += ms;
+ _cur_optional_evac_time_ms += ms;
}
void record_or_add_code_root_fixup_time(double ms) {
@@ -416,7 +415,7 @@
}
double cur_collection_par_time_ms() {
- return _cur_collection_initial_evac_time_ms;
+ return _cur_collection_initial_evac_time_ms + _cur_optional_evac_time_ms;
}
double cur_clear_ct_time_ms() {
--- a/src/hotspot/share/gc/g1/g1Policy.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1Policy.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -68,7 +68,7 @@
_reserve_regions(0),
_young_gen_sizer(G1YoungGenSizer::create_gen_sizer()),
_free_regions_at_end_of_collection(0),
- _max_rs_length(0),
+ _rs_length(0),
_rs_length_prediction(0),
_pending_cards_at_gc_start(0),
_pending_cards_at_prev_gc_end(0),
@@ -330,8 +330,7 @@
const double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0;
const double survivor_regions_evac_time = predict_survivor_regions_evac_time();
const size_t pending_cards = _analytics->predict_pending_cards();
- const size_t adj_rs_length = rs_length + _analytics->predict_rs_length_diff();
- const size_t scanned_cards = _analytics->predict_card_num(adj_rs_length, true /* for_young_gc */);
+ const size_t scanned_cards = _analytics->predict_card_num(rs_length, true /* for_young_gc */);
const double base_time_ms =
predict_base_elapsed_time_ms(pending_cards, scanned_cards) +
survivor_regions_evac_time;
@@ -753,13 +752,13 @@
_analytics->report_cost_per_remset_card_ms(cost_per_remset_card_ms, this_pause_was_young_only);
}
- if (_max_rs_length > 0) {
+ if (_rs_length > 0) {
double cards_per_entry_ratio =
- (double) remset_cards_scanned / (double) _max_rs_length;
+ (double) remset_cards_scanned / (double) _rs_length;
_analytics->report_cards_per_entry_ratio(cards_per_entry_ratio, this_pause_was_young_only);
}
- // This is defensive. For a while _max_rs_length could get
+ // This is defensive. For a while _rs_length could get
// smaller than _recorded_rs_length which was causing
// rs_length_diff to get very large and mess up the RSet length
// predictions. The reason was unsafe concurrent updates to the
@@ -774,8 +773,8 @@
// conditional below just in case.
size_t rs_length_diff = 0;
size_t recorded_rs_length = _collection_set->recorded_rs_length();
- if (_max_rs_length > recorded_rs_length) {
- rs_length_diff = _max_rs_length - recorded_rs_length;
+ if (_rs_length > recorded_rs_length) {
+ rs_length_diff = _rs_length - recorded_rs_length;
}
_analytics->report_rs_length_diff((double) rs_length_diff);
@@ -806,7 +805,7 @@
// During mixed gc we do not use them for young gen sizing.
if (this_pause_was_young_only) {
_analytics->report_pending_cards((double) _pending_cards_at_gc_start);
- _analytics->report_rs_length((double) _max_rs_length);
+ _analytics->report_rs_length((double) _rs_length);
}
}
@@ -951,7 +950,7 @@
}
double G1Policy::predict_base_elapsed_time_ms(size_t pending_cards) const {
- size_t rs_length = _analytics->predict_rs_length() + _analytics->predict_rs_length_diff();
+ size_t rs_length = _analytics->predict_rs_length();
size_t card_num = _analytics->predict_card_num(rs_length, collector_state()->in_young_only_phase());
return predict_base_elapsed_time_ms(pending_cards, card_num);
}
--- a/src/hotspot/share/gc/g1/g1Policy.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1Policy.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -96,7 +96,7 @@
uint _free_regions_at_end_of_collection;
- size_t _max_rs_length;
+ size_t _rs_length;
size_t _rs_length_prediction;
@@ -136,8 +136,8 @@
hr->install_surv_rate_group(_survivor_surv_rate_group);
}
- void record_max_rs_length(size_t rs_length) {
- _max_rs_length = rs_length;
+ void record_rs_length(size_t rs_length) {
+ _rs_length = rs_length;
}
double predict_base_elapsed_time_ms(size_t pending_cards) const;
--- a/src/hotspot/share/gc/g1/g1RemSet.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1RemSet.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -487,7 +487,7 @@
G1CardTable* ct,
G1HotCardCache* hot_card_cache) :
_scan_state(new G1RemSetScanState()),
- _prev_period_summary(),
+ _prev_period_summary(false),
_g1h(g1h),
_ct(ct),
_g1p(_g1h->policy()),
@@ -1404,7 +1404,7 @@
if ((G1SummarizeRSetStatsPeriod > 0) && log_is_enabled(Trace, gc, remset) &&
(period_count % G1SummarizeRSetStatsPeriod == 0)) {
- G1RemSetSummary current(this);
+ G1RemSetSummary current;
_prev_period_summary.subtract_from(¤t);
Log(gc, remset) log;
@@ -1421,7 +1421,7 @@
Log(gc, remset, exit) log;
if (log.is_trace()) {
log.trace(" Cumulative RS summary");
- G1RemSetSummary current(this);
+ G1RemSetSummary current;
ResourceMark rm;
LogStream ls(log.trace());
current.print_on(&ls);
--- a/src/hotspot/share/gc/g1/g1RemSetSummary.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1RemSetSummary.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -81,8 +81,7 @@
return _rs_threads_vtimes[thread];
}
-G1RemSetSummary::G1RemSetSummary() :
- _rem_set(NULL),
+G1RemSetSummary::G1RemSetSummary(bool should_update) :
_total_mutator_refined_cards(0),
_total_concurrent_refined_cards(0),
_num_coarsenings(0),
@@ -91,17 +90,10 @@
_sampling_thread_vtime(0.0f) {
memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes);
-}
-G1RemSetSummary::G1RemSetSummary(G1RemSet* rem_set) :
- _rem_set(rem_set),
- _total_mutator_refined_cards(0),
- _total_concurrent_refined_cards(0),
- _num_coarsenings(0),
- _num_vtimes(G1ConcurrentRefine::max_num_threads()),
- _rs_threads_vtimes(NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC)),
- _sampling_thread_vtime(0.0f) {
- update();
+ if (should_update) {
+ update();
+ }
}
G1RemSetSummary::~G1RemSetSummary() {
--- a/src/hotspot/share/gc/g1/g1RemSetSummary.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1RemSetSummary.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -36,8 +36,6 @@
private:
friend class GetRSThreadVTimeClosure;
- G1RemSet* _rem_set;
-
size_t _total_mutator_refined_cards;
size_t _total_concurrent_refined_cards;
@@ -57,8 +55,7 @@
void update();
public:
- G1RemSetSummary();
- G1RemSetSummary(G1RemSet* remset);
+ G1RemSetSummary(bool should_update = true);
~G1RemSetSummary();
--- a/src/hotspot/share/gc/g1/g1RootClosures.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1RootClosures.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -45,8 +45,6 @@
CodeBlobClosure* strong_codeblobs() { return &_closures._codeblobs; }
CodeBlobClosure* weak_codeblobs() { return &_closures._codeblobs; }
-
- bool trace_metadata() { return false; }
};
// Closures used during initial mark.
@@ -71,10 +69,6 @@
CodeBlobClosure* strong_codeblobs() { return &_strong._codeblobs; }
CodeBlobClosure* weak_codeblobs() { return &_weak._codeblobs; }
-
- // If we are not marking all weak roots then we are tracing
- // which metadata is alive.
- bool trace_metadata() { return MarkWeak == G1MarkPromotedFromRoot; }
};
G1EvacuationRootClosures* G1EvacuationRootClosures::create_root_closures(G1ParScanThreadState* pss, G1CollectedHeap* g1h) {
--- a/src/hotspot/share/gc/g1/g1RootClosures.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1RootClosures.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -52,9 +52,6 @@
// Applied to code blobs treated as weak roots.
virtual CodeBlobClosure* weak_codeblobs() = 0;
- // Is this closure used for tracing metadata?
- virtual bool trace_metadata() = 0;
-
static G1EvacuationRootClosures* create_root_closures(G1ParScanThreadState* pss, G1CollectedHeap* g1h);
};
--- a/src/hotspot/share/gc/g1/g1RootProcessor.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1RootProcessor.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -45,34 +45,10 @@
#include "services/management.hpp"
#include "utilities/macros.hpp"
-void G1RootProcessor::worker_has_discovered_all_strong_nmethods() {
- assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
-
- uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes);
- if (new_value == n_workers()) {
- // This thread is last. Notify the others.
- MonitorLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
- _lock.notify_all();
- }
-}
-
-void G1RootProcessor::wait_until_all_strong_nmethods_discovered() {
- assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
-
- if ((uint)_n_workers_discovered_strong_classes != n_workers()) {
- MonitorLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
- while ((uint)_n_workers_discovered_strong_classes != n_workers()) {
- ml.wait(0);
- }
- }
-}
-
G1RootProcessor::G1RootProcessor(G1CollectedHeap* g1h, uint n_workers) :
_g1h(g1h),
_process_strong_tasks(G1RP_PS_NumElements),
- _srs(n_workers),
- _lock(Mutex::leaf, "G1 Root Scan barrier lock", false, Mutex::_safepoint_check_never),
- _n_workers_discovered_strong_classes(0) {}
+ _srs(n_workers) {}
void G1RootProcessor::evacuate_roots(G1ParScanThreadState* pss, uint worker_id) {
G1GCPhaseTimes* phase_times = _g1h->phase_times();
@@ -80,7 +56,7 @@
G1EvacPhaseTimesTracker timer(phase_times, pss, G1GCPhaseTimes::ExtRootScan, worker_id);
G1EvacuationRootClosures* closures = pss->closures();
- process_java_roots(closures, phase_times, worker_id, closures->trace_metadata() /* notify_claimed_nmethods_done */);
+ process_java_roots(closures, phase_times, worker_id);
process_vm_roots(closures, phase_times, worker_id);
@@ -96,12 +72,6 @@
}
}
- if (closures->trace_metadata()) {
- G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::WaitForStrongRoots, worker_id);
- // Wait to make sure all workers passed the strong nmethods phase.
- wait_until_all_strong_nmethods_discovered();
- }
-
_process_strong_tasks.all_tasks_completed(n_workers());
}
@@ -171,8 +141,7 @@
void G1RootProcessor::process_java_roots(G1RootClosures* closures,
G1GCPhaseTimes* phase_times,
- uint worker_id,
- bool notify_claimed_nmethods_done) {
+ uint worker_id) {
// We need to make make sure that the "strong" nmethods are processed first
// using the strong closure. Only after that we process the weakly reachable
// nmethods.
@@ -197,12 +166,6 @@
closures->strong_codeblobs());
}
- // This is the point where this worker thread will not find more strong nmethods.
- // Report this so G1 can synchronize the strong and weak CLDs/nmethods processing.
- if (notify_claimed_nmethods_done) {
- worker_has_discovered_all_strong_nmethods();
- }
-
{
G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CLDGRoots, worker_id);
if (_process_strong_tasks.try_claim_task(G1RP_PS_ClassLoaderDataGraph_oops_do)) {
--- a/src/hotspot/share/gc/g1/g1RootProcessor.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1RootProcessor.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -50,10 +50,6 @@
SubTasksDone _process_strong_tasks;
StrongRootsScope _srs;
- // Used to implement the Thread work barrier.
- Monitor _lock;
- volatile jint _n_workers_discovered_strong_classes;
-
enum G1H_process_roots_tasks {
G1RP_PS_Universe_oops_do,
G1RP_PS_JNIHandles_oops_do,
@@ -69,13 +65,9 @@
G1RP_PS_NumElements
};
- void worker_has_discovered_all_strong_nmethods();
- void wait_until_all_strong_nmethods_discovered();
-
void process_java_roots(G1RootClosures* closures,
G1GCPhaseTimes* phase_times,
- uint worker_id,
- bool notify_claimed_nmethods_done = false);
+ uint worker_id);
void process_vm_roots(G1RootClosures* closures,
G1GCPhaseTimes* phase_times,
--- a/src/hotspot/share/gc/g1/g1SharedClosures.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1SharedClosures.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -32,6 +32,11 @@
// Simple holder object for a complete set of closures used by the G1 evacuation code.
template <G1Mark Mark>
class G1SharedClosures {
+ static bool needs_strong_processing() {
+ // Request strong code root processing when G1MarkFromRoot is passed in during
+ // initial mark.
+ return Mark == G1MarkFromRoot;
+ }
public:
G1ParCopyClosure<G1BarrierNone, Mark> _oops;
G1ParCopyClosure<G1BarrierCLD, Mark> _oops_in_cld;
@@ -43,5 +48,5 @@
_oops(g1h, pss),
_oops_in_cld(g1h, pss),
_clds(&_oops_in_cld, process_only_dirty),
- _codeblobs(&_oops) {}
+ _codeblobs(pss->worker_id(), &_oops, needs_strong_processing()) {}
};
--- a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -211,34 +211,41 @@
LIRGenerator* gen = access.gen();
DecoratorSet decorators = access.decorators();
- if ((decorators & IN_NATIVE) != 0) {
+ bool is_traversal_mode = ShenandoahHeap::heap()->is_traversal_mode();
+
+ if ((decorators & IN_NATIVE) != 0 && !is_traversal_mode) {
assert(access.is_oop(), "IN_NATIVE access only for oop values");
BarrierSetC1::load_at_resolved(access, result);
LIR_OprList* args = new LIR_OprList();
+ LIR_Opr addr = access.resolved_addr();
+ addr = ensure_in_register(gen, addr);
args->append(result);
+ args->append(addr);
BasicTypeList signature;
signature.append(T_OBJECT);
+ signature.append(T_ADDRESS);
LIR_Opr call_result = gen->call_runtime(&signature, args,
CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native),
objectType, NULL);
__ move(call_result, result);
- return;
- }
-
- if (ShenandoahLoadRefBarrier) {
- LIR_Opr tmp = gen->new_register(T_OBJECT);
- BarrierSetC1::load_at_resolved(access, tmp);
- tmp = load_reference_barrier(access.gen(), tmp, access.resolved_addr());
- __ move(tmp, result);
} else {
- BarrierSetC1::load_at_resolved(access, result);
+ if (ShenandoahLoadRefBarrier) {
+ LIR_Opr tmp = gen->new_register(T_OBJECT);
+ BarrierSetC1::load_at_resolved(access, tmp);
+ tmp = load_reference_barrier(access.gen(), tmp, access.resolved_addr());
+ __ move(tmp, result);
+ } else {
+ BarrierSetC1::load_at_resolved(access, result);
+ }
}
if (ShenandoahKeepAliveBarrier) {
bool is_weak = (decorators & ON_WEAK_OOP_REF) != 0;
bool is_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0;
bool is_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;
- if (is_weak || is_phantom || is_anonymous) {
+ bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0 || is_traversal_mode;
+
+ if ((is_weak || is_phantom || is_anonymous) && keep_alive) {
// Register the value in the referent field with the pre-barrier
LabelObj *Lcont_anonymous;
if (is_anonymous) {
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -297,8 +297,15 @@
}
bool ShenandoahBarrierSetC2::is_shenandoah_lrb_call(Node* call) {
- return call->is_CallLeaf() &&
- call->as_CallLeaf()->entry_point() == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier);
+ if (!call->is_CallLeaf()) {
+ return false;
+ }
+
+ address entry_point = call->as_CallLeaf()->entry_point();
+ return (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier)) ||
+ (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_fixup)) ||
+ (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_fixup_narrow)) ||
+ (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native));
}
bool ShenandoahBarrierSetC2::is_shenandoah_marking_if(PhaseTransform *phase, Node* n) {
@@ -536,9 +543,12 @@
bool mismatched = (decorators & C2_MISMATCHED) != 0;
bool unknown = (decorators & ON_UNKNOWN_OOP_REF) != 0;
bool on_heap = (decorators & IN_HEAP) != 0;
- bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
+ bool on_weak_ref = (decorators & (ON_WEAK_OOP_REF | ON_PHANTOM_OOP_REF)) != 0;
bool is_unordered = (decorators & MO_UNORDERED) != 0;
bool need_cpu_mem_bar = !is_unordered || mismatched || !on_heap;
+ bool is_traversal_mode = ShenandoahHeap::heap()->is_traversal_mode();
+ bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0 || is_traversal_mode;
+ bool in_native = (decorators & IN_NATIVE) != 0;
Node* top = Compile::current()->top();
@@ -547,7 +557,7 @@
if (access.is_oop()) {
if (ShenandoahLoadRefBarrier) {
- load = new ShenandoahLoadReferenceBarrierNode(NULL, load, (decorators & IN_NATIVE) != 0);
+ load = new ShenandoahLoadReferenceBarrierNode(NULL, load, in_native && !is_traversal_mode);
if (access.is_parse_access()) {
load = static_cast<C2ParseAccess &>(access).kit()->gvn().transform(load);
} else {
@@ -563,7 +573,7 @@
// Also we need to add memory barrier to prevent commoning reads
// from this field across safepoint since GC can change its value.
bool need_read_barrier = ShenandoahKeepAliveBarrier &&
- (on_heap && (on_weak || (unknown && offset != top && obj != top)));
+ (on_weak_ref || (unknown && offset != top && obj != top));
if (!access.is_oop() || !need_read_barrier) {
return load;
@@ -573,7 +583,7 @@
C2ParseAccess& parse_access = static_cast<C2ParseAccess&>(access);
GraphKit* kit = parse_access.kit();
- if (on_weak) {
+ if (on_weak_ref && keep_alive) {
// Use the pre-barrier to record the value in the referent field
satb_write_barrier_pre(kit, false /* do_load */,
NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */,
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1033,7 +1033,7 @@
address calladdr = is_native ? CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native)
: target;
- const char* name = is_native ? "oop_load_from_native_barrier" : "load_reference_barrier";
+ const char* name = is_native ? "load_reference_barrier_native" : "load_reference_barrier";
Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(), calladdr, name, TypeRawPtr::BOTTOM);
call->init_req(TypeFunc::Control, ctrl);
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -65,13 +65,6 @@
return true;
}
- if (available < threshold_bytes_allocated) {
- log_info(gc)("Trigger: Free (" SIZE_FORMAT "%s) is lower than allocated recently (" SIZE_FORMAT "%s)",
- byte_size_in_proper_unit(available), proper_unit_for_byte_size(available),
- byte_size_in_proper_unit(threshold_bytes_allocated), proper_unit_for_byte_size(threshold_bytes_allocated));
- return true;
- }
-
size_t bytes_allocated = heap->bytes_allocated_since_gc_start();
if (bytes_allocated > threshold_bytes_allocated) {
log_info(gc)("Trigger: Allocated since last cycle (" SIZE_FORMAT "%s) is larger than allocation threshold (" SIZE_FORMAT "%s)",
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -29,6 +29,11 @@
#include "logging/log.hpp"
#include "logging/logTag.hpp"
+ShenandoahPassiveHeuristics::ShenandoahPassiveHeuristics() : ShenandoahHeuristics() {
+ // Passive runs with max speed for allocation, because GC is always STW
+ SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahPacing);
+}
+
bool ShenandoahPassiveHeuristics::should_start_gc() const {
// Never do concurrent GCs.
return false;
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -28,7 +28,9 @@
class ShenandoahPassiveHeuristics : public ShenandoahHeuristics {
public:
- virtual bool should_start_gc() const;
+ ShenandoahPassiveHeuristics();
+
+ virtual bool should_start_gc() const;
virtual bool should_process_references();
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahTraversalAggressiveHeuristics.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahTraversalAggressiveHeuristics.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -75,6 +75,9 @@
RegionData *data = get_region_data_cache(heap->num_regions());
size_t cnt = 0;
+ // About to choose the collection set, make sure we have pinned regions in correct state
+ heap->assert_pinned_region_status();
+
// Step 0. Prepare all regions
for (size_t i = 0; i < heap->num_regions(); i++) {
ShenandoahHeapRegion* r = heap->get_region(i);
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahTraversalHeuristics.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahTraversalHeuristics.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -59,6 +59,9 @@
RegionData *data = get_region_data_cache(heap->num_regions());
size_t cnt = 0;
+ // About to choose the collection set, make sure we have pinned regions in correct state
+ heap->assert_pinned_region_status();
+
// Step 0. Prepare all regions
for (size_t i = 0; i < heap->num_regions(); i++) {
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -262,27 +262,39 @@
}
}
-oop ShenandoahBarrierSet::oop_load_from_native_barrier(oop obj) {
+oop ShenandoahBarrierSet::load_reference_barrier_native(oop obj, oop* load_addr) {
+ return load_reference_barrier_native_impl(obj, load_addr);
+}
+
+oop ShenandoahBarrierSet::load_reference_barrier_native(oop obj, narrowOop* load_addr) {
+ // Assumption: narrow oop version should not be used anywhere.
+ ShouldNotReachHere();
+ return NULL;
+}
+
+template <class T>
+oop ShenandoahBarrierSet::load_reference_barrier_native_impl(oop obj, T* load_addr) {
if (CompressedOops::is_null(obj)) {
return NULL;
}
ShenandoahMarkingContext* const marking_context = _heap->marking_context();
-
- if (_heap->is_evacuation_in_progress()) {
- // Normal GC
- if (!marking_context->is_marked(obj)) {
+ if (_heap->is_evacuation_in_progress() && !marking_context->is_marked(obj)) {
+ Thread* thr = Thread::current();
+ if (thr->is_Java_thread()) {
return NULL;
- }
- } else if (_heap->is_concurrent_traversal_in_progress()) {
- // Traversal GC
- if (marking_context->is_complete() &&
- !marking_context->is_marked(resolve_forwarded_not_null(obj))) {
- return NULL;
+ } else {
+ return obj;
}
}
- return load_reference_barrier_not_null(obj);
+ oop fwd = load_reference_barrier_not_null(obj);
+ if (load_addr != NULL && fwd != obj) {
+ // Since we are here and we know the load address, update the reference.
+ ShenandoahHeap::cas_oop(fwd, load_addr, obj);
+ }
+
+ return fwd;
}
void ShenandoahBarrierSet::clone_barrier_runtime(oop src) {
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -84,8 +84,6 @@
void write_ref_field_work(void* v, oop o, bool release = false);
- oop oop_load_from_native_barrier(oop obj);
-
virtual void on_thread_create(Thread* thread);
virtual void on_thread_destroy(Thread* thread);
virtual void on_thread_attach(Thread* thread);
@@ -106,6 +104,9 @@
template <class T>
oop load_reference_barrier_mutator_work(oop obj, T* load_addr);
+ oop load_reference_barrier_native(oop obj, oop* load_addr);
+ oop load_reference_barrier_native(oop obj, narrowOop* load_addr);
+
void enqueue(oop obj);
private:
@@ -118,6 +119,9 @@
oop load_reference_barrier_impl(oop obj);
+ template <class T>
+ oop load_reference_barrier_native_impl(oop obj, T* load_addr);
+
static void keep_alive_if_weak(DecoratorSet decorators, oop value) {
assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -69,7 +69,7 @@
template <typename T>
inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_load_not_in_heap(T* addr) {
oop value = Raw::oop_load_not_in_heap(addr);
- value = ShenandoahBarrierSet::barrier_set()->oop_load_from_native_barrier(value);
+ value = ShenandoahBarrierSet::barrier_set()->load_reference_barrier_native(value, addr);
keep_alive_if_weak(decorators, value);
return value;
}
--- a/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -27,6 +27,7 @@
class ShenandoahHeap;
class ShenandoahMarkingContext;
+class ShenandoahHeapRegionSet;
class Thread;
class ShenandoahForwardedIsAliveClosure: public BoolObjectClosure {
@@ -65,6 +66,20 @@
inline void do_oop_work(T* p);
};
+class ShenandoahTraversalUpdateRefsClosure: public OopClosure {
+private:
+ ShenandoahHeap* const _heap;
+ ShenandoahHeapRegionSet* const _traversal_set;
+
+public:
+ inline ShenandoahTraversalUpdateRefsClosure();
+ inline void do_oop(oop* p);
+ inline void do_oop(narrowOop* p);
+private:
+ template <class T>
+ inline void do_oop_work(T* p);
+};
+
class ShenandoahEvacuateUpdateRootsClosure: public BasicOopIterateClosure {
private:
ShenandoahHeap* _heap;
--- a/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -26,6 +26,7 @@
#include "gc/shenandoah/shenandoahAsserts.hpp"
#include "gc/shenandoah/shenandoahClosures.hpp"
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
+#include "gc/shenandoah/shenandoahTraversalGC.hpp"
#include "oops/compressedOops.inline.hpp"
#include "runtime/thread.hpp"
@@ -78,6 +79,29 @@
void ShenandoahUpdateRefsClosure::do_oop(oop* p) { do_oop_work(p); }
void ShenandoahUpdateRefsClosure::do_oop(narrowOop* p) { do_oop_work(p); }
+ShenandoahTraversalUpdateRefsClosure::ShenandoahTraversalUpdateRefsClosure() :
+ _heap(ShenandoahHeap::heap()),
+ _traversal_set(ShenandoahHeap::heap()->traversal_gc()->traversal_set()) {
+ assert(_heap->is_traversal_mode(), "Why we here?");
+}
+
+template <class T>
+void ShenandoahTraversalUpdateRefsClosure::do_oop_work(T* p) {
+ T o = RawAccess<>::oop_load(p);
+ if (!CompressedOops::is_null(o)) {
+ oop obj = CompressedOops::decode_not_null(o);
+ if (_heap->in_collection_set(obj) || _traversal_set->is_in((HeapWord*)obj)) {
+ obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
+ RawAccess<IS_NOT_NULL>::oop_store(p, obj);
+ } else {
+ shenandoah_assert_not_forwarded(p, obj);
+ }
+ }
+}
+
+void ShenandoahTraversalUpdateRefsClosure::do_oop(oop* p) { do_oop_work(p); }
+void ShenandoahTraversalUpdateRefsClosure::do_oop(narrowOop* p) { do_oop_work(p); }
+
ShenandoahEvacuateUpdateRootsClosure::ShenandoahEvacuateUpdateRootsClosure() :
_heap(ShenandoahHeap::heap()), _thread(Thread::current()) {
}
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -442,8 +442,6 @@
weak_refs_work(full_gc);
}
- _heap->parallel_cleaning(full_gc);
-
assert(task_queues()->is_empty(), "Should be empty");
TASKQUEUE_STATS_ONLY(task_queues()->print_taskqueue_stats());
TASKQUEUE_STATS_ONLY(task_queues()->reset_taskqueue_stats());
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1478,6 +1478,12 @@
if (!cancelled_gc()) {
concurrent_mark()->finish_mark_from_roots(/* full_gc = */ false);
+ // Marking is completed, deactivate SATB barrier
+ set_concurrent_mark_in_progress(false);
+ mark_complete_marking_context();
+
+ parallel_cleaning(false /* full gc*/);
+
if (has_forwarded_objects()) {
// Degen may be caused by failed evacuation of roots
if (is_degenerated_gc_in_progress()) {
@@ -1485,39 +1491,50 @@
} else {
concurrent_mark()->update_thread_roots(ShenandoahPhaseTimings::update_roots);
}
+ set_has_forwarded_objects(false);
}
if (ShenandoahVerify) {
verifier()->verify_roots_no_forwarded();
}
-
- stop_concurrent_marking();
-
+ // All allocations past TAMS are implicitly live, adjust the region data.
+ // Bitmaps/TAMS are swapped at this point, so we need to poll complete bitmap.
{
ShenandoahGCPhase phase(ShenandoahPhaseTimings::complete_liveness);
-
- // All allocations past TAMS are implicitly live, adjust the region data.
- // Bitmaps/TAMS are swapped at this point, so we need to poll complete bitmap.
ShenandoahCompleteLivenessClosure cl;
parallel_heap_region_iterate(&cl);
}
+ // Force the threads to reacquire their TLABs outside the collection set.
+ {
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::retire_tlabs);
+ make_parsable(true);
+ }
+
+ // We are about to select the collection set, make sure it knows about
+ // current pinning status. Also, this allows trashing more regions that
+ // now have their pinning status dropped.
+ {
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::sync_pinned);
+ sync_pinned_region_status();
+ }
+
+ // Trash the collection set left over from previous cycle, if any.
+ {
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::trash_cset);
+ trash_cset_regions();
+ }
+
{
- ShenandoahGCPhase prepare_evac(ShenandoahPhaseTimings::prepare_evac);
-
- make_parsable(true);
-
- trash_cset_regions();
-
- {
- ShenandoahHeapLocker locker(lock());
- _collection_set->clear();
- _free_set->clear();
-
- heuristics()->choose_collection_set(_collection_set);
-
- _free_set->rebuild();
- }
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::prepare_evac);
+
+ ShenandoahHeapLocker locker(lock());
+ _collection_set->clear();
+ _free_set->clear();
+
+ heuristics()->choose_collection_set(_collection_set);
+
+ _free_set->rebuild();
}
// If collection set has candidates, start evacuation.
@@ -1562,8 +1579,10 @@
}
} else {
+ // If this cycle was updating references, we need to keep the has_forwarded_objects
+ // flag on, for subsequent phases to deal with it.
concurrent_mark()->cancel();
- stop_concurrent_marking();
+ set_concurrent_mark_in_progress(false);
if (process_references()) {
// Abandon reference processing right away: pre-cleaning must have failed.
@@ -1580,7 +1599,10 @@
set_evacuation_in_progress(false);
- retire_and_reset_gclabs();
+ {
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_evac_retire_gclabs);
+ retire_and_reset_gclabs();
+ }
if (ShenandoahVerify) {
verifier()->verify_after_evacuation();
@@ -1776,6 +1798,7 @@
// it, we fail degeneration right away and slide into Full GC to recover.
{
+ sync_pinned_region_status();
collection_set()->clear_current_index();
ShenandoahHeapRegion* r;
@@ -1855,17 +1878,6 @@
op_full(GCCause::_shenandoah_upgrade_to_full_gc);
}
-void ShenandoahHeap::stop_concurrent_marking() {
- assert(is_concurrent_mark_in_progress(), "How else could we get here?");
- set_concurrent_mark_in_progress(false);
- if (!cancelled_gc()) {
- // If we needed to update refs, and concurrent marking has been cancelled,
- // we need to finish updating references.
- set_has_forwarded_objects(false);
- mark_complete_marking_context();
- }
-}
-
void ShenandoahHeap::force_satb_flush_all_threads() {
if (!is_concurrent_mark_in_progress() && !is_concurrent_traversal_in_progress()) {
// No need to flush SATBs
@@ -1902,7 +1914,7 @@
}
void ShenandoahHeap::set_concurrent_traversal_in_progress(bool in_progress) {
- set_gc_state_mask(TRAVERSAL | HAS_FORWARDED | UPDATEREFS, in_progress);
+ set_gc_state_mask(TRAVERSAL, in_progress);
ShenandoahBarrierSet::satb_mark_queue_set().set_active_all_threads(in_progress, !in_progress);
}
@@ -2034,11 +2046,19 @@
// Cleanup weak roots
ShenandoahGCPhase phase(timing_phase);
if (has_forwarded_objects()) {
- ShenandoahForwardedIsAliveClosure is_alive;
- ShenandoahUpdateRefsClosure keep_alive;
- ShenandoahParallelWeakRootsCleaningTask<ShenandoahForwardedIsAliveClosure, ShenandoahUpdateRefsClosure>
- cleaning_task(&is_alive, &keep_alive, num_workers);
- _workers->run_task(&cleaning_task);
+ if (is_traversal_mode()) {
+ ShenandoahForwardedIsAliveClosure is_alive;
+ ShenandoahTraversalUpdateRefsClosure keep_alive;
+ ShenandoahParallelWeakRootsCleaningTask<ShenandoahForwardedIsAliveClosure, ShenandoahTraversalUpdateRefsClosure>
+ cleaning_task(&is_alive, &keep_alive, num_workers);
+ _workers->run_task(&cleaning_task);
+ } else {
+ ShenandoahForwardedIsAliveClosure is_alive;
+ ShenandoahUpdateRefsClosure keep_alive;
+ ShenandoahParallelWeakRootsCleaningTask<ShenandoahForwardedIsAliveClosure, ShenandoahUpdateRefsClosure>
+ cleaning_task(&is_alive, &keep_alive, num_workers);
+ _workers->run_task(&cleaning_task);
+ }
} else {
ShenandoahIsAliveClosure is_alive;
#ifdef ASSERT
@@ -2060,7 +2080,12 @@
}
void ShenandoahHeap::set_has_forwarded_objects(bool cond) {
- set_gc_state_mask(HAS_FORWARDED, cond);
+ if (is_traversal_mode()) {
+ set_gc_state_mask(HAS_FORWARDED | UPDATEREFS, cond);
+ } else {
+ set_gc_state_mask(HAS_FORWARDED, cond);
+ }
+
}
void ShenandoahHeap::set_process_references(bool pr) {
@@ -2127,16 +2152,45 @@
}
oop ShenandoahHeap::pin_object(JavaThread* thr, oop o) {
- ShenandoahHeapLocker locker(lock());
- heap_region_containing(o)->make_pinned();
+ heap_region_containing(o)->record_pin();
return o;
}
void ShenandoahHeap::unpin_object(JavaThread* thr, oop o) {
+ heap_region_containing(o)->record_unpin();
+}
+
+void ShenandoahHeap::sync_pinned_region_status() {
ShenandoahHeapLocker locker(lock());
- heap_region_containing(o)->make_unpinned();
+
+ for (size_t i = 0; i < num_regions(); i++) {
+ ShenandoahHeapRegion *r = get_region(i);
+ if (r->is_active()) {
+ if (r->is_pinned()) {
+ if (r->pin_count() == 0) {
+ r->make_unpinned();
+ }
+ } else {
+ if (r->pin_count() > 0) {
+ r->make_pinned();
+ }
+ }
+ }
+ }
+
+ assert_pinned_region_status();
}
+#ifdef ASSERT
+void ShenandoahHeap::assert_pinned_region_status() {
+ for (size_t i = 0; i < num_regions(); i++) {
+ ShenandoahHeapRegion* r = get_region(i);
+ assert((r->is_pinned() && r->pin_count() > 0) || (!r->is_pinned() && r->pin_count() == 0),
+ "Region " SIZE_FORMAT " pinning status is inconsistent", i);
+ }
+}
+#endif
+
GCTimer* ShenandoahHeap::gc_timer() const {
return _gc_timer;
}
@@ -2229,7 +2283,10 @@
set_evacuation_in_progress(false);
- retire_and_reset_gclabs();
+ {
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_update_refs_retire_gclabs);
+ retire_and_reset_gclabs();
+ }
if (ShenandoahVerify) {
if (!is_degenerated_gc_in_progress()) {
@@ -2239,15 +2296,20 @@
}
set_update_refs_in_progress(true);
- make_parsable(true);
- for (uint i = 0; i < num_regions(); i++) {
- ShenandoahHeapRegion* r = get_region(i);
- r->set_concurrent_iteration_safe_limit(r->top());
+
+ {
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_update_refs_prepare);
+
+ make_parsable(true);
+ for (uint i = 0; i < num_regions(); i++) {
+ ShenandoahHeapRegion* r = get_region(i);
+ r->set_concurrent_iteration_safe_limit(r->top());
+ }
+
+ // Reset iterator.
+ _update_refs_iterator.reset();
}
- // Reset iterator.
- _update_refs_iterator.reset();
-
if (ShenandoahPacing) {
pacer()->setup_for_updaterefs();
}
@@ -2258,7 +2320,7 @@
// Check if there is left-over work, and finish it
if (_update_refs_iterator.has_next()) {
- ShenandoahGCPhase final_work(ShenandoahPhaseTimings::final_update_refs_finish_work);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs_finish_work);
// Finish updating references where we left off.
clear_cancelled_gc();
@@ -2287,9 +2349,18 @@
verifier()->verify_roots_in_to_space();
}
- ShenandoahGCPhase final_update_refs(ShenandoahPhaseTimings::final_update_refs_recycle);
-
- trash_cset_regions();
+ // Drop unnecessary "pinned" state from regions that does not have CP marks
+ // anymore, as this would allow trashing them below.
+ {
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs_sync_pinned);
+ sync_pinned_region_status();
+ }
+
+ {
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs_trash_cset);
+ trash_cset_regions();
+ }
+
set_has_forwarded_objects(false);
set_update_refs_in_progress(false);
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -43,6 +43,7 @@
class ShenandoahGCStateResetter;
class ShenandoahHeuristics;
class ShenandoahMarkingContext;
+class ShenandoahMarkCompact;
class ShenandoahMode;
class ShenandoahPhaseTimings;
class ShenandoahHeap;
@@ -574,6 +575,9 @@
oop pin_object(JavaThread* thread, oop obj);
void unpin_object(JavaThread* thread, oop obj);
+ void sync_pinned_region_status();
+ void assert_pinned_region_status() NOT_DEBUG_RETURN;
+
// ---------- Allocation support
//
private:
@@ -713,8 +717,6 @@
void deduplicate_string(oop str);
- void stop_concurrent_marking();
-
private:
void trash_cset_regions();
void update_heap_references(bool concurrent);
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -130,15 +130,18 @@
}
inline oop ShenandoahHeap::cas_oop(oop n, oop* addr, oop c) {
+ assert(is_aligned(addr, HeapWordSize), "Address should be aligned: " PTR_FORMAT, p2i(addr));
return (oop) Atomic::cmpxchg(n, addr, c);
}
inline oop ShenandoahHeap::cas_oop(oop n, narrowOop* addr, narrowOop c) {
+ assert(is_aligned(addr, sizeof(narrowOop)), "Address should be aligned: " PTR_FORMAT, p2i(addr));
narrowOop val = CompressedOops::encode(n);
return CompressedOops::decode((narrowOop) Atomic::cmpxchg(val, addr, c));
}
inline oop ShenandoahHeap::cas_oop(oop n, narrowOop* addr, oop c) {
+ assert(is_aligned(addr, sizeof(narrowOop)), "Address should be aligned: " PTR_FORMAT, p2i(addr));
narrowOop cmp = CompressedOops::encode(c);
narrowOop val = CompressedOops::encode(n);
return CompressedOops::decode((narrowOop) Atomic::cmpxchg(val, addr, cmp));
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -59,7 +59,6 @@
_reserved(MemRegion(start, size_words)),
_region_number(index),
_new_top(NULL),
- _critical_pins(0),
_empty_time(os::elapsedTime()),
_state(committed ? _empty_committed : _empty_uncommitted),
_tlab_allocs(0),
@@ -69,7 +68,8 @@
_seqnum_first_alloc_gc(0),
_seqnum_last_alloc_mutator(0),
_seqnum_last_alloc_gc(0),
- _live_data(0) {
+ _live_data(0),
+ _critical_pins(0) {
ContiguousSpace::initialize(_reserved, true, committed);
}
@@ -187,25 +187,20 @@
void ShenandoahHeapRegion::make_pinned() {
_heap->assert_heaplock_owned_by_current_thread();
+ assert(pin_count() > 0, "Should have pins: " SIZE_FORMAT, pin_count());
+
switch (_state) {
case _regular:
- assert (_critical_pins == 0, "sanity");
set_state(_pinned);
case _pinned_cset:
case _pinned:
- _critical_pins++;
return;
case _humongous_start:
- assert (_critical_pins == 0, "sanity");
set_state(_pinned_humongous_start);
case _pinned_humongous_start:
- _critical_pins++;
return;
case _cset:
- guarantee(_heap->cancelled_gc(), "only valid when evac has been cancelled");
- assert (_critical_pins == 0, "sanity");
_state = _pinned_cset;
- _critical_pins++;
return;
default:
report_illegal_transition("pinning");
@@ -214,32 +209,20 @@
void ShenandoahHeapRegion::make_unpinned() {
_heap->assert_heaplock_owned_by_current_thread();
+ assert(pin_count() == 0, "Should not have pins: " SIZE_FORMAT, pin_count());
+
switch (_state) {
case _pinned:
- assert (_critical_pins > 0, "sanity");
- _critical_pins--;
- if (_critical_pins == 0) {
- set_state(_regular);
- }
+ set_state(_regular);
return;
case _regular:
case _humongous_start:
- assert (_critical_pins == 0, "sanity");
return;
case _pinned_cset:
- guarantee(_heap->cancelled_gc(), "only valid when evac has been cancelled");
- assert (_critical_pins > 0, "sanity");
- _critical_pins--;
- if (_critical_pins == 0) {
- set_state(_cset);
- }
+ set_state(_cset);
return;
case _pinned_humongous_start:
- assert (_critical_pins > 0, "sanity");
- _critical_pins--;
- if (_critical_pins == 0) {
- set_state(_humongous_start);
- }
+ set_state(_humongous_start);
return;
default:
report_illegal_transition("unpinning");
@@ -434,7 +417,7 @@
st->print("|G " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_gclab_allocs()), proper_unit_for_byte_size(get_gclab_allocs()));
st->print("|S " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_shared_allocs()), proper_unit_for_byte_size(get_shared_allocs()));
st->print("|L " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_live_data_bytes()), proper_unit_for_byte_size(get_live_data_bytes()));
- st->print("|CP " SIZE_FORMAT_W(3), _critical_pins);
+ st->print("|CP " SIZE_FORMAT_W(3), pin_count());
st->print("|SN " UINT64_FORMAT_X_W(12) ", " UINT64_FORMAT_X_W(8) ", " UINT64_FORMAT_X_W(8) ", " UINT64_FORMAT_X_W(8),
seqnum_first_alloc_mutator(), seqnum_last_alloc_mutator(),
seqnum_first_alloc_gc(), seqnum_last_alloc_gc());
@@ -702,3 +685,16 @@
}
_state = to;
}
+
+void ShenandoahHeapRegion::record_pin() {
+ Atomic::add((size_t)1, &_critical_pins);
+}
+
+void ShenandoahHeapRegion::record_unpin() {
+ assert(pin_count() > 0, "Region " SIZE_FORMAT " should have non-zero pins", region_number());
+ Atomic::sub((size_t)1, &_critical_pins);
+}
+
+size_t ShenandoahHeapRegion::pin_count() const {
+ return Atomic::load(&_critical_pins);
+}
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -203,6 +203,10 @@
RegionState state() const { return _state; }
int state_ordinal() const { return region_state_to_ordinal(_state); }
+ void record_pin();
+ void record_unpin();
+ size_t pin_count() const;
+
private:
static size_t RegionCount;
static size_t RegionSizeBytes;
@@ -238,7 +242,6 @@
// Rarely updated fields
HeapWord* _new_top;
- size_t _critical_pins;
double _empty_time;
// Seldom updated fields
@@ -255,6 +258,7 @@
uint64_t _seqnum_last_alloc_gc;
volatile size_t _live_data;
+ volatile size_t _critical_pins;
// Claim some space at the end to protect next region
DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0);
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeuristics.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeuristics.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -120,6 +120,9 @@
ShenandoahHeap* heap = ShenandoahHeap::heap();
+ // Check all pinned regions have updated status before choosing the collection set.
+ heap->assert_pinned_region_status();
+
// Step 1. Build up the region candidates we care about, rejecting losers and accepting winners right away.
size_t num_regions = heap->num_regions();
--- a/src/hotspot/share/gc/shenandoah/shenandoahLock.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahLock.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -41,6 +41,9 @@
ShenandoahLock() : _state(unlocked), _owner(NULL) {};
void lock() {
+#ifdef ASSERT
+ assert(_owner != Thread::current(), "reentrant locking attempt, would deadlock");
+#endif
Thread::SpinAcquire(&_state, "Shenandoah Heap Lock");
#ifdef ASSERT
assert(_state == locked, "must be locked");
--- a/src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -110,7 +110,7 @@
// b. Cancel concurrent mark, if in progress
if (heap->is_concurrent_mark_in_progress()) {
heap->concurrent_mark()->cancel();
- heap->stop_concurrent_marking();
+ heap->set_concurrent_mark_in_progress(false);
}
assert(!heap->is_concurrent_mark_in_progress(), "sanity");
@@ -128,6 +128,9 @@
// e. Set back forwarded objects bit back, in case some steps above dropped it.
heap->set_has_forwarded_objects(has_forwarded_objects);
+ // f. Sync pinned region status from the CP marks
+ heap->sync_pinned_region_status();
+
// The rest of prologue:
BiasedLocking::preserve_marks();
_preserved_marks->init(heap->workers()->active_workers());
@@ -240,8 +243,8 @@
cm->update_roots(ShenandoahPhaseTimings::full_gc_roots);
cm->mark_roots(ShenandoahPhaseTimings::full_gc_roots);
cm->finish_mark_from_roots(/* full_gc = */ true);
-
heap->mark_complete_marking_context();
+ heap->parallel_cleaning(true /* full_gc */);
}
class ShenandoahPrepareForCompactionObjectClosure : public ObjectClosure {
@@ -505,6 +508,10 @@
ShenandoahHeap* heap = ShenandoahHeap::heap();
+ // About to figure out which regions can be compacted, make sure pinning status
+ // had been updated in GC prologue.
+ heap->assert_pinned_region_status();
+
{
// Trash the immediately collectible regions before computing addresses
ShenandoahTrashImmediateGarbageClosure tigcl;
--- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -214,15 +214,30 @@
_mark_context(ShenandoahHeap::heap()->marking_context()) {
}
- template <class T, bool STRING_DEDUP, bool DEGEN>
+ template <class T, bool STRING_DEDUP, bool DEGEN, bool ATOMIC_UPDATE>
void work(T* p);
};
+class ShenandoahTraversalRootsClosure : public ShenandoahTraversalSuperClosure {
+private:
+ template <class T>
+ inline void do_oop_work(T* p) { work<T, false, false, false>(p); }
+
+public:
+ ShenandoahTraversalRootsClosure(ShenandoahObjToScanQueue* q, ReferenceProcessor* rp) :
+ ShenandoahTraversalSuperClosure(q, rp) {}
+
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop(oop* p) { do_oop_work(p); }
+
+ virtual bool do_metadata() { return false; }
+};
+
class ShenandoahTraversalClosure : public ShenandoahTraversalSuperClosure {
private:
template <class T>
- inline void do_oop_work(T* p) { work<T, false, false>(p); }
+ inline void do_oop_work(T* p) { work<T, false, false, true>(p); }
public:
ShenandoahTraversalClosure(ShenandoahObjToScanQueue* q, ReferenceProcessor* rp) :
@@ -237,7 +252,7 @@
class ShenandoahTraversalMetadataClosure : public ShenandoahTraversalSuperClosure {
private:
template <class T>
- inline void do_oop_work(T* p) { work<T, false, false>(p); }
+ inline void do_oop_work(T* p) { work<T, false, false, true>(p); }
public:
ShenandoahTraversalMetadataClosure(ShenandoahObjToScanQueue* q, ReferenceProcessor* rp) :
@@ -252,7 +267,7 @@
class ShenandoahTraversalDedupClosure : public ShenandoahTraversalSuperClosure {
private:
template <class T>
- inline void do_oop_work(T* p) { work<T, true, false>(p); }
+ inline void do_oop_work(T* p) { work<T, true, false, true>(p); }
public:
ShenandoahTraversalDedupClosure(ShenandoahObjToScanQueue* q, ReferenceProcessor* rp) :
@@ -267,7 +282,7 @@
class ShenandoahTraversalMetadataDedupClosure : public ShenandoahTraversalSuperClosure {
private:
template <class T>
- inline void do_oop_work(T* p) { work<T, true, false>(p); }
+ inline void do_oop_work(T* p) { work<T, true, false, true>(p); }
public:
ShenandoahTraversalMetadataDedupClosure(ShenandoahObjToScanQueue* q, ReferenceProcessor* rp) :
@@ -282,7 +297,7 @@
class ShenandoahTraversalDegenClosure : public ShenandoahTraversalSuperClosure {
private:
template <class T>
- inline void do_oop_work(T* p) { work<T, false, true>(p); }
+ inline void do_oop_work(T* p) { work<T, false, true, false>(p); }
public:
ShenandoahTraversalDegenClosure(ShenandoahObjToScanQueue* q, ReferenceProcessor* rp) :
@@ -297,7 +312,7 @@
class ShenandoahTraversalMetadataDegenClosure : public ShenandoahTraversalSuperClosure {
private:
template <class T>
- inline void do_oop_work(T* p) { work<T, false, true>(p); }
+ inline void do_oop_work(T* p) { work<T, false, true, false>(p); }
public:
ShenandoahTraversalMetadataDegenClosure(ShenandoahObjToScanQueue* q, ReferenceProcessor* rp) :
@@ -312,7 +327,7 @@
class ShenandoahTraversalDedupDegenClosure : public ShenandoahTraversalSuperClosure {
private:
template <class T>
- inline void do_oop_work(T* p) { work<T, true, true>(p); }
+ inline void do_oop_work(T* p) { work<T, true, true, false>(p); }
public:
ShenandoahTraversalDedupDegenClosure(ShenandoahObjToScanQueue* q, ReferenceProcessor* rp) :
@@ -327,7 +342,7 @@
class ShenandoahTraversalMetadataDedupDegenClosure : public ShenandoahTraversalSuperClosure {
private:
template <class T>
- inline void do_oop_work(T* p) { work<T, true, true>(p); }
+ inline void do_oop_work(T* p) { work<T, true, true, false>(p); }
public:
ShenandoahTraversalMetadataDedupDegenClosure(ShenandoahObjToScanQueue* q, ReferenceProcessor* rp) :
--- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -38,9 +38,9 @@
_heap->maybe_update_with_forwarded(p);
}
-template <class T, bool STRING_DEDUP, bool DEGEN>
+template <class T, bool STRING_DEDUP, bool DEGEN, bool ATOMIC_UPDATE>
inline void ShenandoahTraversalSuperClosure::work(T* p) {
- _traversal_gc->process_oop<T, STRING_DEDUP, DEGEN>(p, _thread, _queue, _mark_context);
+ _traversal_gc->process_oop<T, STRING_DEDUP, DEGEN, ATOMIC_UPDATE>(p, _thread, _queue, _mark_context);
}
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_INLINE_HPP
--- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -100,8 +100,10 @@
f(purge_par, " Parallel Cleanup") \
f(purge_cldg, " CLDG") \
f(complete_liveness, " Complete Liveness") \
+ f(retire_tlabs, " Retire TLABs") \
+ f(sync_pinned, " Sync Pinned") \
+ f(trash_cset, " Trash CSet") \
f(prepare_evac, " Prepare Evacuation") \
- f(recycle_regions, " Recycle regions") \
\
/* Per-thread timer block, should have "roots" counters in consistent order */ \
f(init_evac, " Initial Evacuation") \
@@ -127,9 +129,12 @@
\
f(final_evac_gross, "Pause Final Evac (G)") \
f(final_evac, "Pause Final Evac (N)") \
+ f(final_evac_retire_gclabs, " Retire GCLABs") \
\
f(init_update_refs_gross, "Pause Init Update Refs (G)") \
f(init_update_refs, "Pause Init Update Refs (N)") \
+ f(init_update_refs_retire_gclabs, " Retire GCLABs") \
+ f(init_update_refs_prepare, " Prepare") \
\
f(final_update_refs_gross, "Pause Final Update Refs (G)") \
f(final_update_refs, "Pause Final Update Refs (N)") \
@@ -157,7 +162,8 @@
f(final_update_refs_string_dedup_queue_roots, " UR: Dedup Queue Roots") \
f(final_update_refs_finish_queues, " UR: Finish Queues") \
\
- f(final_update_refs_recycle, " Recycle") \
+ f(final_update_refs_sync_pinned, " Sync Pinned") \
+ f(final_update_refs_trash_cset, " Trash CSet") \
\
f(degen_gc_gross, "Pause Degenerated GC (G)") \
f(degen_gc, "Pause Degenerated GC (N)") \
@@ -189,6 +195,7 @@
f(traversal_gc_prepare, " Prepare") \
f(traversal_gc_make_parsable, " Make Parsable") \
f(traversal_gc_resize_tlabs, " Resize TLABs") \
+ f(traversal_gc_prepare_sync_pinned, " Sync Pinned") \
\
/* Per-thread timer block, should have "roots" counters in consistent order */ \
f(init_traversal_gc_work, " Work") \
@@ -260,6 +267,7 @@
f(final_traversal_update_string_dedup_queue_roots, " TU: Dedup Queue Roots") \
f(final_traversal_update_finish_queues, " TU: Finish Queues") \
\
+ f(traversal_gc_sync_pinned, " Sync Pinned") \
f(traversal_gc_cleanup, " Cleanup") \
\
f(full_gc_gross, "Pause Full GC (G)") \
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -189,6 +189,18 @@
_thread_roots(n_workers > 1) {
}
+void ShenandoahRootUpdater::strong_roots_do(uint worker_id, OopClosure* oops_cl) {
+ CodeBlobToOopClosure update_blobs(oops_cl, CodeBlobToOopClosure::FixRelocations);
+ CLDToOopClosure clds(oops_cl, ClassLoaderData::_claim_strong);
+
+ _serial_roots.oops_do(oops_cl, worker_id);
+ _vm_roots.oops_do(oops_cl, worker_id);
+
+ _thread_roots.oops_do(oops_cl, NULL, worker_id);
+ _cld_roots.cld_do(&clds, worker_id);
+ _code_roots.code_blobs_do(&update_blobs, worker_id);
+}
+
ShenandoahRootAdjuster::ShenandoahRootAdjuster(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
ShenandoahRootProcessor(phase),
_thread_roots(n_workers > 1) {
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -304,6 +304,8 @@
template<typename IsAlive, typename KeepAlive>
void roots_do(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive);
+
+ void strong_roots_do(uint worker_id, OopClosure* oops_cl);
};
// Adjuster all roots at a safepoint during full gc
--- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -82,6 +82,6 @@
ShenandoahBarrierSet::barrier_set()->clone_barrier(s);
JRT_END
-JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_native(oopDesc * src))
- return (oopDesc*) ShenandoahBarrierSet::barrier_set()->oop_load_from_native_barrier(oop(src));
+JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_native(oopDesc * src, oop* load_addr))
+ return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier_native(oop(src), load_addr);
JRT_END
--- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -42,7 +42,7 @@
static oopDesc* load_reference_barrier_fixup(oopDesc* src, oop* load_addr);
static oopDesc* load_reference_barrier_fixup_narrow(oopDesc* src, narrowOop* load_addr);
- static oopDesc* load_reference_barrier_native(oopDesc* src);
+ static oopDesc* load_reference_barrier_native(oopDesc* src, oop* load_addr);
static void shenandoah_clone_barrier(oopDesc* src);
};
--- a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -186,7 +186,7 @@
// Step 1: Process ordinary GC roots.
{
- ShenandoahTraversalClosure roots_cl(q, rp);
+ ShenandoahTraversalRootsClosure roots_cl(q, rp);
ShenandoahMarkCLDClosure cld_cl(&roots_cl);
MarkingCodeBlobClosure code_cl(&roots_cl, CodeBlobToOopClosure::FixRelocations);
if (unload_classes) {
@@ -266,7 +266,7 @@
// in similar way during nmethod-register process. Therefore, we don't need to rescan code
// roots here.
if (!_heap->is_degenerated_gc_in_progress()) {
- ShenandoahTraversalClosure roots_cl(q, rp);
+ ShenandoahTraversalRootsClosure roots_cl(q, rp);
ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
if (unload_classes) {
ShenandoahRemarkCLDClosure remark_cld_cl(&roots_cl);
@@ -340,9 +340,6 @@
}
void ShenandoahTraversalGC::prepare() {
- _heap->collection_set()->clear();
- assert(_heap->collection_set()->count() == 0, "collection set not clear");
-
{
ShenandoahGCPhase phase(ShenandoahPhaseTimings::traversal_gc_make_parsable);
_heap->make_parsable(true);
@@ -356,15 +353,26 @@
assert(_heap->marking_context()->is_bitmap_clear(), "need clean mark bitmap");
assert(!_heap->marking_context()->is_complete(), "should not be complete");
- ShenandoahFreeSet* free_set = _heap->free_set();
+ // About to choose the collection set, make sure we know which regions are pinned.
+ {
+ ShenandoahGCPhase phase_cleanup(ShenandoahPhaseTimings::traversal_gc_prepare_sync_pinned);
+ _heap->sync_pinned_region_status();
+ }
+
ShenandoahCollectionSet* collection_set = _heap->collection_set();
+ {
+ ShenandoahHeapLocker lock(_heap->lock());
- // Find collection set
- _heap->heuristics()->choose_collection_set(collection_set);
- prepare_regions();
+ collection_set->clear();
+ assert(collection_set->count() == 0, "collection set not clear");
- // Rebuild free set
- free_set->rebuild();
+ // Find collection set
+ _heap->heuristics()->choose_collection_set(collection_set);
+ prepare_regions();
+
+ // Rebuild free set
+ _heap->free_set()->rebuild();
+ }
log_info(gc, ergo)("Collectable Garbage: " SIZE_FORMAT "%s, " SIZE_FORMAT "%s CSet, " SIZE_FORMAT " CSet regions",
byte_size_in_proper_unit(collection_set->garbage()), proper_unit_for_byte_size(collection_set->garbage()),
@@ -385,11 +393,11 @@
{
ShenandoahGCPhase phase_prepare(ShenandoahPhaseTimings::traversal_gc_prepare);
- ShenandoahHeapLocker lock(_heap->lock());
prepare();
}
_heap->set_concurrent_traversal_in_progress(true);
+ _heap->set_has_forwarded_objects(true);
bool process_refs = _heap->process_references();
if (process_refs) {
@@ -601,14 +609,24 @@
TASKQUEUE_STATS_ONLY(_task_queues->reset_taskqueue_stats());
// No more marking expected
+ _heap->set_concurrent_traversal_in_progress(false);
_heap->mark_complete_marking_context();
fixup_roots();
_heap->parallel_cleaning(false);
+ _heap->set_has_forwarded_objects(false);
+
// Resize metaspace
MetaspaceGC::compute_new_size();
+ // Need to see that pinned region status is updated: newly pinned regions must not
+ // be trashed. New unpinned regions should be trashed.
+ {
+ ShenandoahGCPhase phase_cleanup(ShenandoahPhaseTimings::traversal_gc_sync_pinned);
+ _heap->sync_pinned_region_status();
+ }
+
// Still good? We can now trash the cset, and make final verification
{
ShenandoahGCPhase phase_cleanup(ShenandoahPhaseTimings::traversal_gc_cleanup);
@@ -651,7 +669,6 @@
}
assert(_task_queues->is_empty(), "queues must be empty after traversal GC");
- _heap->set_concurrent_traversal_in_progress(false);
assert(!_heap->cancelled_gc(), "must not be cancelled when getting out here");
if (ShenandoahVerify) {
@@ -697,8 +714,7 @@
void work(uint worker_id) {
ShenandoahParallelWorkerSession worker_session(worker_id);
ShenandoahTraversalFixRootsClosure cl;
- ShenandoahForwardedIsAliveClosure is_alive;
- _rp->roots_do<ShenandoahForwardedIsAliveClosure, ShenandoahTraversalFixRootsClosure>(worker_id, &is_alive, &cl);
+ _rp->strong_roots_do(worker_id, &cl);
}
};
@@ -751,7 +767,7 @@
template <class T>
inline void do_oop_work(T* p) {
- _traversal_gc->process_oop<T, false /* string dedup */, false /* degen */>(p, _thread, _queue, _mark_context);
+ _traversal_gc->process_oop<T, false /* string dedup */, false /* degen */, true /* atomic update */>(p, _thread, _queue, _mark_context);
}
public:
@@ -773,7 +789,7 @@
template <class T>
inline void do_oop_work(T* p) {
- _traversal_gc->process_oop<T, false /* string dedup */, true /* degen */>(p, _thread, _queue, _mark_context);
+ _traversal_gc->process_oop<T, false /* string dedup */, true /* degen */, false /* atomic update */>(p, _thread, _queue, _mark_context);
}
public:
@@ -796,7 +812,7 @@
template <class T>
inline void do_oop_work(T* p) {
ShenandoahEvacOOMScope evac_scope;
- _traversal_gc->process_oop<T, false /* string dedup */, false /* degen */>(p, _thread, _queue, _mark_context);
+ _traversal_gc->process_oop<T, false /* string dedup */, false /* degen */, true /* atomic update */>(p, _thread, _queue, _mark_context);
}
public:
@@ -819,7 +835,7 @@
template <class T>
inline void do_oop_work(T* p) {
ShenandoahEvacOOMScope evac_scope;
- _traversal_gc->process_oop<T, false /* string dedup */, true /* degen */>(p, _thread, _queue, _mark_context);
+ _traversal_gc->process_oop<T, false /* string dedup */, true /* degen */, false /* atomic update */>(p, _thread, _queue, _mark_context);
}
public:
--- a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -48,7 +48,7 @@
void concurrent_traversal_collection();
void final_traversal_collection();
- template <class T, bool STRING_DEDUP, bool DEGEN>
+ template <class T, bool STRING_DEDUP, bool DEGEN, bool ATOMIC_UPDATE>
inline void process_oop(T* p, Thread* thread, ShenandoahObjToScanQueue* queue, ShenandoahMarkingContext* const mark_context);
bool check_and_handle_cancelled_gc(ShenandoahTaskTerminator* terminator, bool sts_yield);
--- a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -35,12 +35,13 @@
#include "oops/compressedOops.inline.hpp"
#include "oops/oop.inline.hpp"
-template <class T, bool STRING_DEDUP, bool DEGEN>
+template <class T, bool STRING_DEDUP, bool DEGEN, bool ATOMIC_UPDATE>
void ShenandoahTraversalGC::process_oop(T* p, Thread* thread, ShenandoahObjToScanQueue* queue, ShenandoahMarkingContext* const mark_context) {
T o = RawAccess<>::oop_load(p);
if (!CompressedOops::is_null(o)) {
oop obj = CompressedOops::decode_not_null(o);
if (DEGEN) {
+ assert(!ATOMIC_UPDATE, "Degen path assumes non-atomic updates");
oop forw = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
if (obj != forw) {
// Update reference.
@@ -54,7 +55,11 @@
}
shenandoah_assert_forwarded_except(p, obj, _heap->cancelled_gc());
// Update reference.
- ShenandoahHeap::cas_oop(forw, p, obj);
+ if (ATOMIC_UPDATE) {
+ ShenandoahHeap::cas_oop(forw, p, obj);
+ } else {
+ RawAccess<IS_NOT_NULL>::oop_store(p, forw);
+ }
obj = forw;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/z/zAddressSpaceLimit.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+#include "precompiled.hpp"
+#include "gc/z/zAddressSpaceLimit.hpp"
+#include "gc/z/zGlobals.hpp"
+#include "runtime/os.hpp"
+#include "utilities/align.hpp"
+
+static size_t address_space_limit() {
+ julong limit = 0;
+
+ if (os::has_allocatable_memory_limit(&limit)) {
+ return (size_t)limit;
+ }
+
+ // No limit
+ return SIZE_MAX;
+}
+
+size_t ZAddressSpaceLimit::mark_stack() {
+ // Allow mark stacks to occupy 10% of the address space
+ const size_t limit = address_space_limit() / 10;
+ return align_up(limit, ZMarkStackSpaceExpandSize);
+}
+
+size_t ZAddressSpaceLimit::heap_view() {
+ // Allow all heap views to occupy 50% of the address space
+ const size_t limit = address_space_limit() / 2 / ZHeapViews;
+ return align_up(limit, ZGranuleSize);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/z/zAddressSpaceLimit.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+#ifndef SHARE_GC_Z_ZADDRESSSPACELIMIT_HPP
+#define SHARE_GC_Z_ZADDRESSSPACELIMIT_HPP
+
+#include "memory/allocation.hpp"
+
+class ZAddressSpaceLimit : public AllStatic {
+public:
+ static size_t mark_stack();
+ static size_t heap_view();
+};
+
+#endif // SHARE_GC_Z_ZADDRESSSPACELIMIT_HPP
--- a/src/hotspot/share/gc/z/zArguments.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zArguments.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -22,6 +22,7 @@
*/
#include "precompiled.hpp"
+#include "gc/z/zAddressSpaceLimit.hpp"
#include "gc/z/zArguments.hpp"
#include "gc/z/zCollectedHeap.hpp"
#include "gc/z/zWorkers.hpp"
@@ -37,6 +38,15 @@
void ZArguments::initialize() {
GCArguments::initialize();
+ // Check mark stack size
+ const size_t mark_stack_space_limit = ZAddressSpaceLimit::mark_stack();
+ if (ZMarkStackSpaceLimit > mark_stack_space_limit) {
+ if (!FLAG_IS_DEFAULT(ZMarkStackSpaceLimit)) {
+ vm_exit_during_initialization("ZMarkStackSpaceLimit too large for limited address space");
+ }
+ FLAG_SET_DEFAULT(ZMarkStackSpaceLimit, mark_stack_space_limit);
+ }
+
// Enable NUMA by default
if (FLAG_IS_DEFAULT(UseNUMA)) {
FLAG_SET_DEFAULT(UseNUMA, true);
--- a/src/hotspot/share/gc/z/zArray.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zArray.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -74,15 +74,13 @@
template <typename T>
class ZArrayIterator : public ZArrayIteratorImpl<T, ZARRAY_SERIAL> {
public:
- ZArrayIterator(ZArray<T>* array) :
- ZArrayIteratorImpl<T, ZARRAY_SERIAL>(array) {}
+ ZArrayIterator(ZArray<T>* array);
};
template <typename T>
class ZArrayParallelIterator : public ZArrayIteratorImpl<T, ZARRAY_PARALLEL> {
public:
- ZArrayParallelIterator(ZArray<T>* array) :
- ZArrayIteratorImpl<T, ZARRAY_PARALLEL>(array) {}
+ ZArrayParallelIterator(ZArray<T>* array);
};
#endif // SHARE_GC_Z_ZARRAY_HPP
--- a/src/hotspot/share/gc/z/zArray.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zArray.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -117,4 +117,12 @@
return false;
}
+template <typename T>
+inline ZArrayIterator<T>::ZArrayIterator(ZArray<T>* array) :
+ ZArrayIteratorImpl<T, ZARRAY_SERIAL>(array) {}
+
+template <typename T>
+inline ZArrayParallelIterator<T>::ZArrayParallelIterator(ZArray<T>* array) :
+ ZArrayIteratorImpl<T, ZARRAY_PARALLEL>(array) {}
+
#endif // SHARE_GC_Z_ZARRAY_INLINE_HPP
--- a/src/hotspot/share/gc/z/zCPU.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zCPU.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -22,15 +22,15 @@
*/
#include "precompiled.hpp"
-#include "gc/z/zCPU.hpp"
+#include "gc/z/zCPU.inline.hpp"
#include "logging/log.hpp"
#include "memory/padded.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/thread.inline.hpp"
#include "utilities/debug.hpp"
-#define ZCPU_UNKNOWN_AFFINITY (Thread*)-1;
-#define ZCPU_UNKNOWN_SELF (Thread*)-2;
+#define ZCPU_UNKNOWN_AFFINITY ((Thread*)-1)
+#define ZCPU_UNKNOWN_SELF ((Thread*)-2)
PaddedEnd<ZCPU::ZCPUAffinity>* ZCPU::_affinity = NULL;
THREAD_LOCAL Thread* ZCPU::_self = ZCPU_UNKNOWN_SELF;
@@ -51,20 +51,13 @@
os::initial_active_processor_count());
}
-uint32_t ZCPU::count() {
- return os::processor_count();
-}
-
-uint32_t ZCPU::id() {
- assert(_affinity != NULL, "Not initialized");
-
- // Fast path
- if (_affinity[_cpu]._thread == _self) {
- return _cpu;
+uint32_t ZCPU::id_slow() {
+ // Set current thread
+ if (_self == ZCPU_UNKNOWN_SELF) {
+ _self = Thread::current();
}
- // Slow path
- _self = Thread::current();
+ // Set current CPU
_cpu = os::processor_id();
// Update affinity table
--- a/src/hotspot/share/gc/z/zCPU.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zCPU.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -40,6 +40,8 @@
static THREAD_LOCAL Thread* _self;
static THREAD_LOCAL uint32_t _cpu;
+ static uint32_t id_slow();
+
public:
static void initialize();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/z/zCPU.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+#ifndef SHARE_GC_Z_ZCPU_INLINE_HPP
+#define SHARE_GC_Z_ZCPU_INLINE_HPP
+
+#include "gc/z/zCPU.hpp"
+#include "runtime/os.hpp"
+#include "utilities/debug.hpp"
+
+inline uint32_t ZCPU::count() {
+ return os::processor_count();
+}
+
+inline uint32_t ZCPU::id() {
+ assert(_affinity != NULL, "Not initialized");
+
+ // Fast path
+ if (_affinity[_cpu]._thread == _self) {
+ return _cpu;
+ }
+
+ // Slow path
+ return id_slow();
+}
+
+#endif // SHARE_GC_Z_ZCPU_INLINE_HPP
--- a/src/hotspot/share/gc/z/zDirector.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zDirector.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -48,14 +48,6 @@
ZStatAllocRate::avg_sd() / M);
}
-bool ZDirector::is_first() const {
- return ZStatCycle::ncycles() == 0;
-}
-
-bool ZDirector::is_warm() const {
- return ZStatCycle::ncycles() >= 3;
-}
-
bool ZDirector::rule_timer() const {
if (ZCollectionInterval == 0) {
// Rule disabled
@@ -73,7 +65,7 @@
}
bool ZDirector::rule_warmup() const {
- if (is_warm()) {
+ if (ZStatCycle::is_warm()) {
// Rule disabled
return false;
}
@@ -93,7 +85,7 @@
}
bool ZDirector::rule_allocation_rate() const {
- if (is_first()) {
+ if (ZStatCycle::is_first()) {
// Rule disabled
return false;
}
@@ -140,7 +132,7 @@
}
bool ZDirector::rule_proactive() const {
- if (!ZProactive || !is_warm()) {
+ if (!ZProactive || !ZStatCycle::is_warm()) {
// Rule disabled
return false;
}
--- a/src/hotspot/share/gc/z/zDirector.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zDirector.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -36,9 +36,6 @@
void sample_allocation_rate() const;
- bool is_first() const;
- bool is_warm() const;
-
bool rule_timer() const;
bool rule_warmup() const;
bool rule_allocation_rate() const;
--- a/src/hotspot/share/gc/z/zDriver.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zDriver.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -250,11 +250,17 @@
case GCCause::_z_allocation_stall:
case GCCause::_z_proactive:
case GCCause::_z_high_usage:
- case GCCause::_metadata_GC_threshold:
// Start asynchronous GC
_gc_cycle_port.send_async(cause);
break;
+ case GCCause::_metadata_GC_threshold:
+ // Start asynchronous GC, but only if the GC is warm
+ if (ZStatCycle::is_warm()) {
+ _gc_cycle_port.send_async(cause);
+ }
+ break;
+
case GCCause::_gc_locker:
// Restart VM operation previously blocked by the GC locker
_gc_locker_port.signal();
--- a/src/hotspot/share/gc/z/zForwardingTable.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zForwardingTable.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -22,27 +22,27 @@
*/
#include "precompiled.hpp"
-#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zForwarding.inline.hpp"
#include "gc/z/zForwardingTable.inline.hpp"
+#include "gc/z/zGlobals.hpp"
#include "gc/z/zGranuleMap.inline.hpp"
#include "utilities/debug.hpp"
ZForwardingTable::ZForwardingTable() :
- _map() {}
+ _map(ZAddressOffsetMax) {}
void ZForwardingTable::insert(ZForwarding* forwarding) {
- const uintptr_t addr = ZAddress::good(forwarding->start());
+ const uintptr_t offset = forwarding->start();
const size_t size = forwarding->size();
- assert(get(addr) == NULL, "Invalid entry");
- _map.put(addr, size, forwarding);
+ assert(_map.get(offset) == NULL, "Invalid entry");
+ _map.put(offset, size, forwarding);
}
void ZForwardingTable::remove(ZForwarding* forwarding) {
- const uintptr_t addr = ZAddress::good(forwarding->start());
+ const uintptr_t offset = forwarding->start();
const size_t size = forwarding->size();
- assert(get(addr) == forwarding, "Invalid entry");
- _map.put(addr, size, NULL);
+ assert(_map.get(offset) == forwarding, "Invalid entry");
+ _map.put(offset, size, NULL);
}
--- a/src/hotspot/share/gc/z/zForwardingTable.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zForwardingTable.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -24,11 +24,13 @@
#ifndef SHARE_GC_Z_ZFORWARDINGTABLE_INLINE_HPP
#define SHARE_GC_Z_ZFORWARDINGTABLE_INLINE_HPP
+#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zForwardingTable.hpp"
#include "gc/z/zGranuleMap.inline.hpp"
inline ZForwarding* ZForwardingTable::get(uintptr_t addr) const {
- return _map.get(addr);
+ assert(!ZAddress::is_null(addr), "Invalid address");
+ return _map.get(ZAddress::offset(addr));
}
#endif // SHARE_GC_Z_ZFORWARDINGTABLE_INLINE_HPP
--- a/src/hotspot/share/gc/z/zFuture.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zFuture.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -34,7 +34,10 @@
T _value;
public:
+ ZFuture();
+
void set(T value);
+ T peek();
T get();
};
--- a/src/hotspot/share/gc/z/zFuture.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zFuture.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -29,6 +29,10 @@
#include "runtime/thread.hpp"
template <typename T>
+inline ZFuture<T>::ZFuture() :
+ _value() {}
+
+template <typename T>
inline void ZFuture<T>::set(T value) {
// Set value
_value = value;
@@ -38,6 +42,11 @@
}
template <typename T>
+inline T ZFuture<T>::peek() {
+ return _value;
+}
+
+template <typename T>
inline T ZFuture<T>::get() {
// Wait for notification
Thread* const thread = Thread::current();
--- a/src/hotspot/share/gc/z/zGlobals.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zGlobals.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -44,6 +44,23 @@
const size_t ZGranuleSizeShift = ZPlatformGranuleSizeShift;
const size_t ZGranuleSize = (size_t)1 << ZGranuleSizeShift;
+// Number of heap views
+const size_t ZHeapViews = ZPlatformHeapViews;
+
+// Virtual memory to physical memory ratio
+const size_t ZVirtualToPhysicalRatio = 16; // 16:1
+
+//
+// Page Tiers (assuming ZGranuleSize=2M)
+// -------------------------------------
+//
+// Page Size Object Size Object Alignment
+// --------------------------------------------------
+// Small 2M <= 265K MinObjAlignmentInBytes
+// Medium 32M <= 4M 4K
+// Large N x 2M > 4M 2M
+//
+
// Page types
const uint8_t ZPageTypeSmall = 0;
const uint8_t ZPageTypeMedium = 1;
@@ -113,6 +130,7 @@
// Cache line size
const size_t ZCacheLineSize = ZPlatformCacheLineSize;
+#define ZCACHE_ALIGNED ATTRIBUTE_ALIGNED(ZCacheLineSize)
// Mark stack space
extern uintptr_t ZMarkStackSpaceStart;
--- a/src/hotspot/share/gc/z/zGranuleMap.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zGranuleMap.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -38,15 +38,15 @@
const size_t _size;
T* const _map;
- size_t index_for_addr(uintptr_t addr) const;
+ size_t index_for_offset(uintptr_t offset) const;
public:
- ZGranuleMap();
+ ZGranuleMap(size_t max_offset);
~ZGranuleMap();
- T get(uintptr_t addr) const;
- void put(uintptr_t addr, T value);
- void put(uintptr_t addr, size_t size, T value);
+ T get(uintptr_t offset) const;
+ void put(uintptr_t offset, T value);
+ void put(uintptr_t offset, size_t size, T value);
};
template <typename T>
--- a/src/hotspot/share/gc/z/zGranuleMap.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zGranuleMap.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -24,15 +24,18 @@
#ifndef SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
#define SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
-#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zGlobals.hpp"
#include "gc/z/zGranuleMap.hpp"
#include "memory/allocation.inline.hpp"
+#include "utilities/align.hpp"
+#include "utilities/debug.hpp"
template <typename T>
-inline ZGranuleMap<T>::ZGranuleMap() :
- _size(ZAddressOffsetMax >> ZGranuleSizeShift),
- _map(MmapArrayAllocator<T>::allocate(_size, mtGC)) {}
+inline ZGranuleMap<T>::ZGranuleMap(size_t max_offset) :
+ _size(max_offset >> ZGranuleSizeShift),
+ _map(MmapArrayAllocator<T>::allocate(_size, mtGC)) {
+ assert(is_aligned(max_offset, ZGranuleSize), "Misaligned");
+}
template <typename T>
inline ZGranuleMap<T>::~ZGranuleMap() {
@@ -40,32 +43,30 @@
}
template <typename T>
-inline size_t ZGranuleMap<T>::index_for_addr(uintptr_t addr) const {
- assert(!ZAddress::is_null(addr), "Invalid address");
-
- const size_t index = ZAddress::offset(addr) >> ZGranuleSizeShift;
+inline size_t ZGranuleMap<T>::index_for_offset(uintptr_t offset) const {
+ const size_t index = offset >> ZGranuleSizeShift;
assert(index < _size, "Invalid index");
return index;
}
template <typename T>
-inline T ZGranuleMap<T>::get(uintptr_t addr) const {
- const size_t index = index_for_addr(addr);
+inline T ZGranuleMap<T>::get(uintptr_t offset) const {
+ const size_t index = index_for_offset(offset);
return _map[index];
}
template <typename T>
-inline void ZGranuleMap<T>::put(uintptr_t addr, T value) {
- const size_t index = index_for_addr(addr);
+inline void ZGranuleMap<T>::put(uintptr_t offset, T value) {
+ const size_t index = index_for_offset(offset);
_map[index] = value;
}
template <typename T>
-inline void ZGranuleMap<T>::put(uintptr_t addr, size_t size, T value) {
+inline void ZGranuleMap<T>::put(uintptr_t offset, size_t size, T value) {
assert(is_aligned(size, ZGranuleSize), "Misaligned");
- const size_t start_index = index_for_addr(addr);
+ const size_t start_index = index_for_offset(offset);
const size_t end_index = start_index + (size >> ZGranuleSizeShift);
for (size_t index = start_index; index < end_index; index++) {
_map[index] = value;
--- a/src/hotspot/share/gc/z/zHeap.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zHeap.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -34,7 +34,7 @@
#include "gc/z/zRelocationSetSelector.hpp"
#include "gc/z/zResurrection.hpp"
#include "gc/z/zStat.hpp"
-#include "gc/z/zThread.hpp"
+#include "gc/z/zThread.inline.hpp"
#include "gc/z/zVerify.hpp"
#include "gc/z/zWorkers.inline.hpp"
#include "logging/log.hpp"
@@ -244,34 +244,14 @@
return _page_allocator.uncommit(delay);
}
-void ZHeap::before_flip() {
- if (ZVerifyViews) {
- // Unmap all pages
- _page_allocator.debug_unmap_all_pages();
- }
-}
-
-void ZHeap::after_flip() {
- if (ZVerifyViews) {
- // Map all pages
- ZPageTableIterator iter(&_page_table);
- for (ZPage* page; iter.next(&page);) {
- _page_allocator.debug_map_page(page);
- }
- _page_allocator.debug_map_cached_pages();
- }
-}
-
void ZHeap::flip_to_marked() {
- before_flip();
+ ZVerifyViewsFlip flip(&_page_allocator);
ZAddress::flip_to_marked();
- after_flip();
}
void ZHeap::flip_to_remapped() {
- before_flip();
+ ZVerifyViewsFlip flip(&_page_allocator);
ZAddress::flip_to_remapped();
- after_flip();
}
void ZHeap::mark_start() {
@@ -460,6 +440,14 @@
iter.objects_do(cl, visit_weaks);
}
+void ZHeap::pages_do(ZPageClosure* cl) {
+ ZPageTableIterator iter(&_page_table);
+ for (ZPage* page; iter.next(&page);) {
+ cl->do_page(page);
+ }
+ _page_allocator.pages_do(cl);
+}
+
void ZHeap::serviceability_initialize() {
_serviceability.initialize();
}
--- a/src/hotspot/share/gc/z/zHeap.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zHeap.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -63,9 +63,6 @@
size_t heap_max_size() const;
size_t heap_max_reserve_size() const;
- void before_flip();
- void after_flip();
-
void flip_to_marked();
void flip_to_remapped();
@@ -151,6 +148,7 @@
// Iteration
void object_iterate(ObjectClosure* cl, bool visit_weaks);
+ void pages_do(ZPageClosure* cl);
// Serviceability
void serviceability_initialize();
--- a/src/hotspot/share/gc/z/zHeapIterator.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zHeapIterator.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "classfile/classLoaderData.hpp"
#include "classfile/classLoaderDataGraph.hpp"
+#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zBarrier.inline.hpp"
#include "gc/z/zGlobals.hpp"
#include "gc/z/zGranuleMap.inline.hpp"
@@ -126,7 +127,7 @@
ZHeapIterator::ZHeapIterator() :
_visit_stack(),
- _visit_map() {}
+ _visit_map(ZAddressOffsetMax) {}
ZHeapIterator::~ZHeapIterator() {
ZVisitMapIterator iter(&_visit_map);
@@ -148,11 +149,11 @@
}
ZHeapIteratorBitMap* ZHeapIterator::object_map(oop obj) {
- const uintptr_t addr = ZOop::to_address(obj);
- ZHeapIteratorBitMap* map = _visit_map.get(addr);
+ const uintptr_t offset = ZAddress::offset(ZOop::to_address(obj));
+ ZHeapIteratorBitMap* map = _visit_map.get(offset);
if (map == NULL) {
map = new ZHeapIteratorBitMap(object_index_max());
- _visit_map.put(addr, map);
+ _visit_map.put(offset, map);
}
return map;
--- a/src/hotspot/share/gc/z/zInitialize.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zInitialize.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -50,4 +50,6 @@
ZTracer::initialize();
ZLargePages::initialize();
ZBarrierSet::set_barrier_set(barrier_set);
+
+ initialize_os();
}
--- a/src/hotspot/share/gc/z/zInitialize.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zInitialize.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -29,6 +29,9 @@
class ZBarrierSet;
class ZInitialize {
+private:
+ void initialize_os();
+
public:
ZInitialize(ZBarrierSet* barrier_set);
};
--- a/src/hotspot/share/gc/z/zList.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zList.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -25,7 +25,6 @@
#define SHARE_GC_Z_ZLIST_HPP
#include "memory/allocation.hpp"
-#include "utilities/debug.hpp"
template <typename T> class ZList;
@@ -38,27 +37,15 @@
ZListNode* _next;
ZListNode* _prev;
- ZListNode(ZListNode* next, ZListNode* prev) :
- _next(next),
- _prev(prev) {}
+ ZListNode(ZListNode* next, ZListNode* prev);
- void set_unused() {
- _next = NULL;
- _prev = NULL;
- }
+ void set_unused();
public:
- ZListNode() {
- set_unused();
- }
+ ZListNode();
+ ~ZListNode();
- ~ZListNode() {
- set_unused();
- }
-
- bool is_unused() const {
- return _next == NULL && _prev == NULL;
- }
+ bool is_unused() const;
};
// Doubly linked list
@@ -72,139 +59,34 @@
ZList(const ZList<T>& list);
ZList<T>& operator=(const ZList<T>& list);
- void verify() const {
- assert(_head._next->_prev == &_head, "List corrupt");
- assert(_head._prev->_next == &_head, "List corrupt");
- }
-
- void insert(ZListNode<T>* before, ZListNode<T>* node) {
- verify();
+ void verify() const;
- assert(node->is_unused(), "Already in a list");
- node->_prev = before;
- node->_next = before->_next;
- before->_next = node;
- node->_next->_prev = node;
+ void insert(ZListNode<T>* before, ZListNode<T>* node);
- _size++;
- }
-
- ZListNode<T>* cast_to_inner(T* elem) const {
- return &elem->_node;
- }
-
- T* cast_to_outer(ZListNode<T>* node) const {
- return (T*)((uintptr_t)node - offset_of(T, _node));
- }
+ ZListNode<T>* cast_to_inner(T* elem) const;
+ T* cast_to_outer(ZListNode<T>* node) const;
public:
- ZList() :
- _head(&_head, &_head),
- _size(0) {
- verify();
- }
-
- size_t size() const {
- verify();
- return _size;
- }
+ ZList();
- bool is_empty() const {
- return _size == 0;
- }
-
- T* first() const {
- return is_empty() ? NULL : cast_to_outer(_head._next);
- }
-
- T* last() const {
- return is_empty() ? NULL : cast_to_outer(_head._prev);
- }
+ size_t size() const;
+ bool is_empty() const;
- T* next(T* elem) const {
- verify();
- ZListNode<T>* next = cast_to_inner(elem)->_next;
- return (next == &_head) ? NULL : cast_to_outer(next);
- }
-
- T* prev(T* elem) const {
- verify();
- ZListNode<T>* prev = cast_to_inner(elem)->_prev;
- return (prev == &_head) ? NULL : cast_to_outer(prev);
- }
-
- void insert_first(T* elem) {
- insert(&_head, cast_to_inner(elem));
- }
-
- void insert_last(T* elem) {
- insert(_head._prev, cast_to_inner(elem));
- }
-
- void insert_before(T* before, T* elem) {
- insert(cast_to_inner(before)->_prev, cast_to_inner(elem));
- }
-
- void insert_after(T* after, T* elem) {
- insert(cast_to_inner(after), cast_to_inner(elem));
- }
-
- void remove(T* elem) {
- verify();
+ T* first() const;
+ T* last() const;
+ T* next(T* elem) const;
+ T* prev(T* elem) const;
- ZListNode<T>* const node = cast_to_inner(elem);
- assert(!node->is_unused(), "Not in a list");
-
- ZListNode<T>* const next = node->_next;
- ZListNode<T>* const prev = node->_prev;
- assert(next->_prev == node, "List corrupt");
- assert(prev->_next == node, "List corrupt");
-
- prev->_next = next;
- next->_prev = prev;
- node->set_unused();
-
- _size--;
- }
-
- T* remove_first() {
- T* elem = first();
- if (elem != NULL) {
- remove(elem);
- }
-
- return elem;
- }
+ void insert_first(T* elem);
+ void insert_last(T* elem);
+ void insert_before(T* before, T* elem);
+ void insert_after(T* after, T* elem);
- T* remove_last() {
- T* elem = last();
- if (elem != NULL) {
- remove(elem);
- }
-
- return elem;
- }
-
- void transfer(ZList<T>* list) {
- verify();
+ void remove(T* elem);
+ T* remove_first();
+ T* remove_last();
- if (!list->is_empty()) {
- list->_head._next->_prev = _head._prev;
- list->_head._prev->_next = _head._prev->_next;
-
- _head._prev->_next = list->_head._next;
- _head._prev = list->_head._prev;
-
- list->_head._next = &list->_head;
- list->_head._prev = &list->_head;
-
- _size += list->_size;
- list->_size = 0;
-
- list->verify();
- verify();
- }
- }
+ void transfer(ZList<T>* list);
};
template <typename T, bool forward>
@@ -226,15 +108,13 @@
template <typename T>
class ZListIterator : public ZListIteratorImpl<T, ZLIST_FORWARD> {
public:
- ZListIterator(const ZList<T>* list) :
- ZListIteratorImpl<T, ZLIST_FORWARD>(list) {}
+ ZListIterator(const ZList<T>* list);
};
template <typename T>
class ZListReverseIterator : public ZListIteratorImpl<T, ZLIST_REVERSE> {
public:
- ZListReverseIterator(const ZList<T>* list) :
- ZListIteratorImpl<T, ZLIST_REVERSE>(list) {}
+ ZListReverseIterator(const ZList<T>* list);
};
#endif // SHARE_GC_Z_ZLIST_HPP
--- a/src/hotspot/share/gc/z/zList.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zList.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -25,14 +25,193 @@
#define SHARE_GC_Z_ZLIST_INLINE_HPP
#include "gc/z/zList.hpp"
+#include "utilities/debug.hpp"
+
+template <typename T>
+inline ZListNode<T>::ZListNode(ZListNode* next, ZListNode* prev) :
+ _next(next),
+ _prev(prev) {}
+
+template <typename T>
+inline void ZListNode<T>::set_unused() {
+ _next = NULL;
+ _prev = NULL;
+}
+
+template <typename T>
+inline ZListNode<T>::ZListNode() {
+ set_unused();
+}
+
+template <typename T>
+inline ZListNode<T>::~ZListNode() {
+ set_unused();
+}
+
+template <typename T>
+inline bool ZListNode<T>::is_unused() const {
+ return _next == NULL && _prev == NULL;
+}
+
+template <typename T>
+inline void ZList<T>::verify() const {
+ assert(_head._next->_prev == &_head, "List corrupt");
+ assert(_head._prev->_next == &_head, "List corrupt");
+}
+
+template <typename T>
+inline void ZList<T>::insert(ZListNode<T>* before, ZListNode<T>* node) {
+ verify();
+
+ assert(node->is_unused(), "Already in a list");
+ node->_prev = before;
+ node->_next = before->_next;
+ before->_next = node;
+ node->_next->_prev = node;
+
+ _size++;
+}
+
+template <typename T>
+inline ZListNode<T>* ZList<T>::cast_to_inner(T* elem) const {
+ return &elem->_node;
+}
+
+template <typename T>
+inline T* ZList<T>::cast_to_outer(ZListNode<T>* node) const {
+ return (T*)((uintptr_t)node - offset_of(T, _node));
+}
+
+template <typename T>
+inline ZList<T>::ZList() :
+ _head(&_head, &_head),
+ _size(0) {
+ verify();
+}
+
+template <typename T>
+inline size_t ZList<T>::size() const {
+ verify();
+ return _size;
+}
+
+template <typename T>
+inline bool ZList<T>::is_empty() const {
+ return _size == 0;
+}
+
+template <typename T>
+inline T* ZList<T>::first() const {
+ return is_empty() ? NULL : cast_to_outer(_head._next);
+}
+
+template <typename T>
+inline T* ZList<T>::last() const {
+ return is_empty() ? NULL : cast_to_outer(_head._prev);
+}
+
+template <typename T>
+inline T* ZList<T>::next(T* elem) const {
+ verify();
+ ZListNode<T>* next = cast_to_inner(elem)->_next;
+ return (next == &_head) ? NULL : cast_to_outer(next);
+}
+
+template <typename T>
+inline T* ZList<T>::prev(T* elem) const {
+ verify();
+ ZListNode<T>* prev = cast_to_inner(elem)->_prev;
+ return (prev == &_head) ? NULL : cast_to_outer(prev);
+}
+
+template <typename T>
+inline void ZList<T>::insert_first(T* elem) {
+ insert(&_head, cast_to_inner(elem));
+}
+
+template <typename T>
+inline void ZList<T>::insert_last(T* elem) {
+ insert(_head._prev, cast_to_inner(elem));
+}
+
+template <typename T>
+inline void ZList<T>::insert_before(T* before, T* elem) {
+ insert(cast_to_inner(before)->_prev, cast_to_inner(elem));
+}
+
+template <typename T>
+inline void ZList<T>::insert_after(T* after, T* elem) {
+ insert(cast_to_inner(after), cast_to_inner(elem));
+}
+
+template <typename T>
+inline void ZList<T>::remove(T* elem) {
+ verify();
+
+ ZListNode<T>* const node = cast_to_inner(elem);
+ assert(!node->is_unused(), "Not in a list");
+
+ ZListNode<T>* const next = node->_next;
+ ZListNode<T>* const prev = node->_prev;
+ assert(next->_prev == node, "List corrupt");
+ assert(prev->_next == node, "List corrupt");
+
+ prev->_next = next;
+ next->_prev = prev;
+ node->set_unused();
+
+ _size--;
+}
+
+template <typename T>
+inline T* ZList<T>::remove_first() {
+ T* elem = first();
+ if (elem != NULL) {
+ remove(elem);
+ }
+
+ return elem;
+}
+
+template <typename T>
+inline T* ZList<T>::remove_last() {
+ T* elem = last();
+ if (elem != NULL) {
+ remove(elem);
+ }
+
+ return elem;
+}
+
+template <typename T>
+inline void ZList<T>::transfer(ZList<T>* list) {
+ verify();
+
+ if (!list->is_empty()) {
+ list->_head._next->_prev = _head._prev;
+ list->_head._prev->_next = _head._prev->_next;
+
+ _head._prev->_next = list->_head._next;
+ _head._prev = list->_head._prev;
+
+ list->_head._next = &list->_head;
+ list->_head._prev = &list->_head;
+
+ _size += list->_size;
+ list->_size = 0;
+
+ list->verify();
+ verify();
+ }
+}
template <typename T, bool forward>
-ZListIteratorImpl<T, forward>::ZListIteratorImpl(const ZList<T>* list) :
+inline ZListIteratorImpl<T, forward>::ZListIteratorImpl(const ZList<T>* list) :
_list(list),
_next(forward ? list->first() : list->last()) {}
template <typename T, bool forward>
-bool ZListIteratorImpl<T, forward>::next(T** elem) {
+inline bool ZListIteratorImpl<T, forward>::next(T** elem) {
if (_next != NULL) {
*elem = _next;
_next = forward ? _list->next(_next) : _list->prev(_next);
@@ -43,4 +222,12 @@
return false;
}
+template <typename T>
+inline ZListIterator<T>::ZListIterator(const ZList<T>* list) :
+ ZListIteratorImpl<T, ZLIST_FORWARD>(list) {}
+
+template <typename T>
+inline ZListReverseIterator<T>::ZListReverseIterator(const ZList<T>* list) :
+ ZListIteratorImpl<T, ZLIST_REVERSE>(list) {}
+
#endif // SHARE_GC_Z_ZLIST_INLINE_HPP
--- a/src/hotspot/share/gc/z/zLiveMap.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zLiveMap.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -25,7 +25,7 @@
#include "gc/z/zHeap.inline.hpp"
#include "gc/z/zLiveMap.inline.hpp"
#include "gc/z/zStat.hpp"
-#include "gc/z/zThread.hpp"
+#include "gc/z/zThread.inline.hpp"
#include "logging/log.hpp"
#include "runtime/atomic.hpp"
#include "runtime/orderAccess.hpp"
--- a/src/hotspot/share/gc/z/zMark.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zMark.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -34,7 +34,7 @@
#include "gc/z/zRootsIterator.hpp"
#include "gc/z/zStat.hpp"
#include "gc/z/zTask.hpp"
-#include "gc/z/zThread.hpp"
+#include "gc/z/zThread.inline.hpp"
#include "gc/z/zThreadLocalAllocBuffer.hpp"
#include "gc/z/zUtils.inline.hpp"
#include "gc/z/zWorkers.inline.hpp"
--- a/src/hotspot/share/gc/z/zMarkStack.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zMarkStack.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -73,8 +73,8 @@
class ZMarkStripe {
private:
- ZMarkStackList _published ATTRIBUTE_ALIGNED(ZCacheLineSize);
- ZMarkStackList _overflowed ATTRIBUTE_ALIGNED(ZCacheLineSize);
+ ZCACHE_ALIGNED ZMarkStackList _published;
+ ZCACHE_ALIGNED ZMarkStackList _overflowed;
public:
ZMarkStripe();
--- a/src/hotspot/share/gc/z/zMarkStackAllocator.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zMarkStackAllocator.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -50,8 +50,8 @@
class ZMarkStackAllocator {
private:
- ZMarkStackMagazineList _freelist ATTRIBUTE_ALIGNED(ZCacheLineSize);
- ZMarkStackSpace _space ATTRIBUTE_ALIGNED(ZCacheLineSize);
+ ZCACHE_ALIGNED ZMarkStackMagazineList _freelist;
+ ZCACHE_ALIGNED ZMarkStackSpace _space;
void prime_freelist();
ZMarkStackMagazine* create_magazine_from_space(uintptr_t addr, size_t size);
--- a/src/hotspot/share/gc/z/zMarkTerminate.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zMarkTerminate.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -30,9 +30,9 @@
class ZMarkTerminate {
private:
- uint _nworkers;
- volatile uint _nworking_stage0 ATTRIBUTE_ALIGNED(ZCacheLineSize);
- volatile uint _nworking_stage1;
+ uint _nworkers;
+ ZCACHE_ALIGNED volatile uint _nworking_stage0;
+ volatile uint _nworking_stage1;
bool enter_stage(volatile uint* nworking_stage);
void exit_stage(volatile uint* nworking_stage);
--- a/src/hotspot/share/gc/z/zMemory.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zMemory.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -26,6 +26,65 @@
#include "gc/z/zMemory.inline.hpp"
#include "memory/allocation.inline.hpp"
+ZMemory* ZMemoryManager::create(uintptr_t start, size_t size) {
+ ZMemory* const area = new ZMemory(start, size);
+ if (_callbacks._create != NULL) {
+ _callbacks._create(area);
+ }
+ return area;
+}
+
+void ZMemoryManager::destroy(ZMemory* area) {
+ if (_callbacks._destroy != NULL) {
+ _callbacks._destroy(area);
+ }
+ delete area;
+}
+
+void ZMemoryManager::shrink_from_front(ZMemory* area, size_t size) {
+ if (_callbacks._shrink_from_front != NULL) {
+ _callbacks._shrink_from_front(area, size);
+ }
+ area->shrink_from_front(size);
+}
+
+void ZMemoryManager::shrink_from_back(ZMemory* area, size_t size) {
+ if (_callbacks._shrink_from_back != NULL) {
+ _callbacks._shrink_from_back(area, size);
+ }
+ area->shrink_from_back(size);
+}
+
+void ZMemoryManager::grow_from_front(ZMemory* area, size_t size) {
+ if (_callbacks._grow_from_front != NULL) {
+ _callbacks._grow_from_front(area, size);
+ }
+ area->grow_from_front(size);
+}
+
+void ZMemoryManager::grow_from_back(ZMemory* area, size_t size) {
+ if (_callbacks._grow_from_back != NULL) {
+ _callbacks._grow_from_back(area, size);
+ }
+ area->grow_from_back(size);
+}
+
+ZMemoryManager::Callbacks::Callbacks() :
+ _create(NULL),
+ _destroy(NULL),
+ _shrink_from_front(NULL),
+ _shrink_from_back(NULL),
+ _grow_from_front(NULL),
+ _grow_from_back(NULL) {}
+
+ZMemoryManager::ZMemoryManager() :
+ _freelist(),
+ _callbacks() {}
+
+void ZMemoryManager::register_callbacks(const Callbacks& callbacks) {
+ _callbacks = callbacks;
+}
+
uintptr_t ZMemoryManager::alloc_from_front(size_t size) {
ZListIterator<ZMemory> iter(&_freelist);
for (ZMemory* area; iter.next(&area);) {
@@ -34,12 +93,12 @@
// Exact match, remove area
const uintptr_t start = area->start();
_freelist.remove(area);
- delete area;
+ destroy(area);
return start;
} else {
// Larger than requested, shrink area
const uintptr_t start = area->start();
- area->shrink_from_front(size);
+ shrink_from_front(area, size);
return start;
}
}
@@ -57,12 +116,12 @@
const uintptr_t start = area->start();
*allocated = area->size();
_freelist.remove(area);
- delete area;
+ destroy(area);
return start;
} else {
// Larger than requested, shrink area
const uintptr_t start = area->start();
- area->shrink_from_front(size);
+ shrink_from_front(area, size);
*allocated = size;
return start;
}
@@ -81,11 +140,11 @@
// Exact match, remove area
const uintptr_t start = area->start();
_freelist.remove(area);
- delete area;
+ destroy(area);
return start;
} else {
// Larger than requested, shrink area
- area->shrink_from_back(size);
+ shrink_from_back(area, size);
return area->end();
}
}
@@ -103,11 +162,11 @@
const uintptr_t start = area->start();
*allocated = area->size();
_freelist.remove(area);
- delete area;
+ destroy(area);
return start;
} else {
// Larger than requested, shrink area
- area->shrink_from_back(size);
+ shrink_from_back(area, size);
*allocated = size;
return area->end();
}
@@ -129,20 +188,20 @@
if (prev != NULL && start == prev->end()) {
if (end == area->start()) {
// Merge with prev and current area
- prev->grow_from_back(size + area->size());
+ grow_from_back(prev, size + area->size());
_freelist.remove(area);
delete area;
} else {
// Merge with prev area
- prev->grow_from_back(size);
+ grow_from_back(prev, size);
}
} else if (end == area->start()) {
// Merge with current area
- area->grow_from_front(size);
+ grow_from_front(area, size);
} else {
// Insert new area before current area
assert(end < area->start(), "Areas must not overlap");
- ZMemory* new_area = new ZMemory(start, size);
+ ZMemory* const new_area = create(start, size);
_freelist.insert_before(area, new_area);
}
@@ -155,10 +214,10 @@
ZMemory* const last = _freelist.last();
if (last != NULL && start == last->end()) {
// Merge with last area
- last->grow_from_back(size);
+ grow_from_back(last, size);
} else {
// Insert new area last
- ZMemory* new_area = new ZMemory(start, size);
+ ZMemory* const new_area = create(start, size);
_freelist.insert_last(new_area);
}
}
--- a/src/hotspot/share/gc/z/zMemory.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zMemory.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -49,14 +49,42 @@
};
class ZMemoryManager {
+public:
+ typedef void (*CreateDestroyCallback)(const ZMemory* area);
+ typedef void (*ResizeCallback)(const ZMemory* area, size_t size);
+
+ struct Callbacks {
+ CreateDestroyCallback _create;
+ CreateDestroyCallback _destroy;
+ ResizeCallback _shrink_from_front;
+ ResizeCallback _shrink_from_back;
+ ResizeCallback _grow_from_front;
+ ResizeCallback _grow_from_back;
+
+ Callbacks();
+ };
+
private:
ZList<ZMemory> _freelist;
+ Callbacks _callbacks;
+
+ ZMemory* create(uintptr_t start, size_t size);
+ void destroy(ZMemory* area);
+ void shrink_from_front(ZMemory* area, size_t size);
+ void shrink_from_back(ZMemory* area, size_t size);
+ void grow_from_front(ZMemory* area, size_t size);
+ void grow_from_back(ZMemory* area, size_t size);
public:
+ ZMemoryManager();
+
+ void register_callbacks(const Callbacks& callbacks);
+
uintptr_t alloc_from_front(size_t size);
uintptr_t alloc_from_front_at_most(size_t size, size_t* allocated);
uintptr_t alloc_from_back(size_t size);
uintptr_t alloc_from_back_at_most(size_t size, size_t* allocated);
+
void free(uintptr_t start, size_t size);
};
--- a/src/hotspot/share/gc/z/zMemory.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zMemory.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -24,6 +24,7 @@
#ifndef SHARE_GC_Z_ZMEMORY_INLINE_HPP
#define SHARE_GC_Z_ZMEMORY_INLINE_HPP
+#include "gc/z/zList.inline.hpp"
#include "gc/z/zMemory.hpp"
#include "utilities/debug.hpp"
--- a/src/hotspot/share/gc/z/zNMethodTableIteration.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zNMethodTableIteration.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -31,9 +31,9 @@
class ZNMethodTableIteration {
private:
- ZNMethodTableEntry* _table;
- size_t _size;
- volatile size_t _claimed ATTRIBUTE_ALIGNED(ZCacheLineSize);
+ ZNMethodTableEntry* _table;
+ size_t _size;
+ ZCACHE_ALIGNED volatile size_t _claimed;
public:
ZNMethodTableIteration();
--- a/src/hotspot/share/gc/z/zObjectAllocator.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zObjectAllocator.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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
@@ -28,8 +28,9 @@
#include "gc/z/zObjectAllocator.hpp"
#include "gc/z/zPage.inline.hpp"
#include "gc/z/zStat.hpp"
-#include "gc/z/zThread.hpp"
+#include "gc/z/zThread.inline.hpp"
#include "gc/z/zUtils.inline.hpp"
+#include "gc/z/zValue.inline.hpp"
#include "logging/log.hpp"
#include "runtime/atomic.hpp"
#include "runtime/safepoint.hpp"
--- a/src/hotspot/share/gc/z/zObjectAllocator.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zObjectAllocator.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
--- a/src/hotspot/share/gc/z/zPage.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zPage.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -22,6 +22,7 @@
*/
#include "precompiled.hpp"
+#include "gc/z/zList.inline.hpp"
#include "gc/z/zPage.inline.hpp"
#include "gc/z/zPhysicalMemory.inline.hpp"
#include "gc/z/zVirtualMemory.inline.hpp"
@@ -52,6 +53,8 @@
assert_initialized();
}
+ZPage::~ZPage() {}
+
void ZPage::assert_initialized() const {
assert(!_virtual.is_null(), "Should not be null");
assert(!_physical.is_null(), "Should not be null");
--- a/src/hotspot/share/gc/z/zPage.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zPage.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -56,6 +56,7 @@
public:
ZPage(const ZVirtualMemory& vmem, const ZPhysicalMemory& pmem);
ZPage(uint8_t type, const ZVirtualMemory& vmem, const ZPhysicalMemory& pmem);
+ ~ZPage();
uint32_t object_max_count() const;
size_t object_alignment_shift() const;
@@ -111,4 +112,9 @@
void print() const;
};
+class ZPageClosure {
+public:
+ virtual void do_page(const ZPage* page) = 0;
+};
+
#endif // SHARE_GC_Z_ZPAGE_HPP
--- a/src/hotspot/share/gc/z/zPageAllocator.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zPageAllocator.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -60,7 +60,9 @@
_type(type),
_size(size),
_flags(flags),
- _total_collections(total_collections) {}
+ _total_collections(total_collections),
+ _node(),
+ _result() {}
uint8_t type() const {
return _type;
@@ -78,6 +80,10 @@
return _total_collections;
}
+ ZPage* peek() {
+ return _result.peek();
+ }
+
ZPage* wait() {
return _result.get();
}
@@ -108,6 +114,7 @@
_allocated(0),
_reclaimed(0),
_queue(),
+ _satisfied(),
_safe_delete(),
_uncommit(false),
_initialized(false) {
@@ -289,11 +296,7 @@
void ZPageAllocator::map_page(const ZPage* page) const {
// Map physical memory
- if (!page->is_mapped()) {
- _physical.map(page->physical_memory(), page->start());
- } else if (ZVerifyViews) {
- _physical.debug_map(page->physical_memory(), page->start());
- }
+ _physical.map(page->physical_memory(), page->start());
}
size_t ZPageAllocator::max_available(bool no_reserve) const {
@@ -433,14 +436,21 @@
} while (page == gc_marker);
{
- // Guard deletion of underlying semaphore. This is a workaround for a
- // bug in sem_post() in glibc < 2.21, where it's not safe to destroy
+ //
+ // We grab the lock here for two different reasons:
+ //
+ // 1) Guard deletion of underlying semaphore. This is a workaround for
+ // a bug in sem_post() in glibc < 2.21, where it's not safe to destroy
// the semaphore immediately after returning from sem_wait(). The
// reason is that sem_post() can touch the semaphore after a waiting
// thread have returned from sem_wait(). To avoid this race we are
// forcing the waiting thread to acquire/release the lock held by the
// posting thread. https://sourceware.org/bugzilla/show_bug.cgi?id=12674
+ //
+ // 2) Guard the list of satisfied pages.
+ //
ZLocker<ZLock> locker(&_lock);
+ _satisfied.remove(&request);
}
}
@@ -462,7 +472,9 @@
}
// Map page if needed
- map_page(page);
+ if (!page->is_mapped()) {
+ map_page(page);
+ }
// Reset page. This updates the page's sequence number and must
// be done after page allocation, which potentially blocked in
@@ -500,6 +512,7 @@
// the dequeue operation must happen first, since the request
// will immediately be deallocated once it has been satisfied.
_queue.remove(request);
+ _satisfied.insert_first(request);
request->satisfy(page);
}
}
@@ -686,28 +699,21 @@
_physical.debug_map(page->physical_memory(), page->start());
}
-class ZPageCacheDebugMapClosure : public StackObj {
-private:
- const ZPageAllocator* const _allocator;
-
-public:
- ZPageCacheDebugMapClosure(const ZPageAllocator* allocator) :
- _allocator(allocator) {}
-
- virtual void do_page(const ZPage* page) {
- _allocator->debug_map_page(page);
- }
-};
-
-void ZPageAllocator::debug_map_cached_pages() const {
+void ZPageAllocator::debug_unmap_page(const ZPage* page) const {
assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
- ZPageCacheDebugMapClosure cl(this);
- _cache.pages_do(&cl);
+ _physical.debug_unmap(page->physical_memory(), page->start());
}
-void ZPageAllocator::debug_unmap_all_pages() const {
- assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
- _physical.debug_unmap(ZPhysicalMemorySegment(0 /* start */, ZAddressOffsetMax), 0 /* offset */);
+void ZPageAllocator::pages_do(ZPageClosure* cl) const {
+ ZListIterator<ZPageAllocRequest> iter(&_satisfied);
+ for (ZPageAllocRequest* request; iter.next(&request);) {
+ const ZPage* const page = request->peek();
+ if (page != NULL) {
+ cl->do_page(page);
+ }
+ }
+
+ _cache.pages_do(cl);
}
bool ZPageAllocator::is_alloc_stalled() const {
@@ -728,7 +734,8 @@
}
// Out of memory, fail allocation request
- _queue.remove_first();
+ _queue.remove(request);
+ _satisfied.insert_first(request);
request->satisfy(NULL);
}
}
--- a/src/hotspot/share/gc/z/zPageAllocator.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zPageAllocator.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -54,11 +54,12 @@
size_t _allocated;
ssize_t _reclaimed;
ZList<ZPageAllocRequest> _queue;
+ ZList<ZPageAllocRequest> _satisfied;
mutable ZSafeDelete<ZPage> _safe_delete;
bool _uncommit;
bool _initialized;
- static ZPage* const gc_marker;
+ static ZPage* const gc_marker;
void prime_cache(size_t size);
@@ -117,11 +118,12 @@
void map_page(const ZPage* page) const;
void debug_map_page(const ZPage* page) const;
- void debug_map_cached_pages() const;
- void debug_unmap_all_pages() const;
+ void debug_unmap_page(const ZPage* page) const;
bool is_alloc_stalled() const;
void check_out_of_memory();
+
+ void pages_do(ZPageClosure* cl) const;
};
#endif // SHARE_GC_Z_ZPAGEALLOCATOR_HPP
--- a/src/hotspot/share/gc/z/zPageCache.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zPageCache.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -27,6 +27,7 @@
#include "gc/z/zPage.inline.hpp"
#include "gc/z/zPageCache.hpp"
#include "gc/z/zStat.hpp"
+#include "gc/z/zValue.inline.hpp"
#include "logging/log.hpp"
static const ZStatCounter ZCounterPageCacheHitL1("Memory", "Page Cache Hit L1", ZStatUnitOpsPerSecond);
@@ -239,3 +240,26 @@
flush_list(cl, &_medium, to);
flush_per_numa_lists(cl, &_small, to);
}
+
+void ZPageCache::pages_do(ZPageClosure* cl) const {
+ // Small
+ ZPerNUMAConstIterator<ZList<ZPage> > iter_numa(&_small);
+ for (const ZList<ZPage>* list; iter_numa.next(&list);) {
+ ZListIterator<ZPage> iter_small(list);
+ for (ZPage* page; iter_small.next(&page);) {
+ cl->do_page(page);
+ }
+ }
+
+ // Medium
+ ZListIterator<ZPage> iter_medium(&_medium);
+ for (ZPage* page; iter_medium.next(&page);) {
+ cl->do_page(page);
+ }
+
+ // Large
+ ZListIterator<ZPage> iter_large(&_large);
+ for (ZPage* page; iter_large.next(&page);) {
+ cl->do_page(page);
+ }
+}
--- a/src/hotspot/share/gc/z/zPageCache.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zPageCache.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -71,7 +71,7 @@
void flush(ZPageCacheFlushClosure* cl, ZList<ZPage>* to);
- template <typename Closure> void pages_do(Closure* cl) const;
+ void pages_do(ZPageClosure* cl) const;
};
#endif // SHARE_GC_Z_ZPAGECACHE_HPP
--- a/src/hotspot/share/gc/z/zPageCache.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zPageCache.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -26,33 +26,10 @@
#include "gc/z/zList.inline.hpp"
#include "gc/z/zPageCache.hpp"
+#include "gc/z/zValue.inline.hpp"
inline size_t ZPageCache::available() const {
return _available;
}
-template <typename Closure>
-inline void ZPageCache::pages_do(Closure* cl) const {
- // Small
- ZPerNUMAConstIterator<ZList<ZPage> > iter_numa(&_small);
- for (const ZList<ZPage>* list; iter_numa.next(&list);) {
- ZListIterator<ZPage> iter_small(list);
- for (ZPage* page; iter_small.next(&page);) {
- cl->do_page(page);
- }
- }
-
- // Medium
- ZListIterator<ZPage> iter_medium(&_medium);
- for (ZPage* page; iter_medium.next(&page);) {
- cl->do_page(page);
- }
-
- // Large
- ZListIterator<ZPage> iter_large(&_large);
- for (ZPage* page; iter_large.next(&page);) {
- cl->do_page(page);
- }
-}
-
#endif // SHARE_GC_Z_ZPAGECACHE_INLINE_HPP
--- a/src/hotspot/share/gc/z/zPageTable.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zPageTable.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -22,7 +22,7 @@
*/
#include "precompiled.hpp"
-#include "gc/z/zAddress.inline.hpp"
+#include "gc/z/zGlobals.hpp"
#include "gc/z/zGranuleMap.inline.hpp"
#include "gc/z/zPage.inline.hpp"
#include "gc/z/zPageTable.inline.hpp"
@@ -30,24 +30,24 @@
#include "utilities/debug.hpp"
ZPageTable::ZPageTable() :
- _map() {}
+ _map(ZAddressOffsetMax) {}
void ZPageTable::insert(ZPage* page) {
- const uintptr_t addr = ZAddress::good(page->start());
+ const uintptr_t offset = page->start();
const size_t size = page->size();
// Make sure a newly created page is
// visible before updating the page table.
OrderAccess::storestore();
- assert(get(addr) == NULL, "Invalid entry");
- _map.put(addr, size, page);
+ assert(_map.get(offset) == NULL, "Invalid entry");
+ _map.put(offset, size, page);
}
void ZPageTable::remove(ZPage* page) {
- const uintptr_t addr = ZAddress::good(page->start());
+ const uintptr_t offset = page->start();
const size_t size = page->size();
- assert(get(addr) == page, "Invalid entry");
- _map.put(addr, size, NULL);
+ assert(_map.get(offset) == page, "Invalid entry");
+ _map.put(offset, size, NULL);
}
--- a/src/hotspot/share/gc/z/zPageTable.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zPageTable.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -29,7 +29,8 @@
#include "gc/z/zPageTable.hpp"
inline ZPage* ZPageTable::get(uintptr_t addr) const {
- return _map.get(addr);
+ assert(!ZAddress::is_null(addr), "Invalid address");
+ return _map.get(ZAddress::offset(addr));
}
inline ZPageTableIterator::ZPageTableIterator(const ZPageTable* page_table) :
--- a/src/hotspot/share/gc/z/zReferenceProcessor.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zReferenceProcessor.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -32,6 +32,7 @@
#include "gc/z/zTask.hpp"
#include "gc/z/zTracer.inline.hpp"
#include "gc/z/zUtils.inline.hpp"
+#include "gc/z/zValue.inline.hpp"
#include "memory/universe.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/os.hpp"
--- a/src/hotspot/share/gc/z/zRelocate.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zRelocate.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -33,6 +33,7 @@
#include "gc/z/zRootsIterator.hpp"
#include "gc/z/zStat.hpp"
#include "gc/z/zTask.hpp"
+#include "gc/z/zThread.inline.hpp"
#include "gc/z/zThreadLocalAllocBuffer.hpp"
#include "gc/z/zWorkers.hpp"
#include "logging/log.hpp"
--- a/src/hotspot/share/gc/z/zRootsIterator.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zRootsIterator.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -149,7 +149,7 @@
virtual void do_code_blob(CodeBlob* cb) {
nmethod* const nm = cb->as_nmethod_or_null();
- if (nm != NULL && !nm->test_set_oops_do_mark()) {
+ if (nm != NULL && nm->oops_do_try_claim()) {
CodeBlobToOopClosure::do_code_blob(cb);
_bs->disarm(nm);
}
--- a/src/hotspot/share/gc/z/zStat.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zStat.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -23,7 +23,7 @@
#include "precompiled.hpp"
#include "gc/z/zCollectedHeap.hpp"
-#include "gc/z/zCPU.hpp"
+#include "gc/z/zCPU.inline.hpp"
#include "gc/z/zGlobals.hpp"
#include "gc/z/zHeap.inline.hpp"
#include "gc/z/zLargePages.inline.hpp"
@@ -716,7 +716,7 @@
}
void ZStatSubPhase::register_end(const Ticks& start, const Ticks& end) const {
- ZTracer::tracer()->report_thread_phase(*this, start, end);
+ ZTracer::tracer()->report_thread_phase(name(), start, end);
const Tickspan duration = end - start;
ZStatSample(_sampler, duration.value());
@@ -736,7 +736,7 @@
}
void ZStatCriticalPhase::register_end(const Ticks& start, const Ticks& end) const {
- ZTracer::tracer()->report_thread_phase(*this, start, end);
+ ZTracer::tracer()->report_thread_phase(name(), start, end);
const Tickspan duration = end - start;
ZStatSample(_sampler, duration.value());
@@ -759,7 +759,7 @@
//
// Stat sample/inc
//
-void ZStatSample(const ZStatSampler& sampler, uint64_t value, bool trace) {
+void ZStatSample(const ZStatSampler& sampler, uint64_t value) {
ZStatSamplerData* const cpu_data = sampler.get();
Atomic::add(1u, &cpu_data->_nsamples);
Atomic::add(value, &cpu_data->_sum);
@@ -782,18 +782,14 @@
max = prev_max;
}
- if (trace) {
- ZTracer::tracer()->report_stat_sampler(sampler, value);
- }
+ ZTracer::tracer()->report_stat_sampler(sampler, value);
}
-void ZStatInc(const ZStatCounter& counter, uint64_t increment, bool trace) {
+void ZStatInc(const ZStatCounter& counter, uint64_t increment) {
ZStatCounterData* const cpu_data = counter.get();
const uint64_t value = Atomic::add(increment, &cpu_data->_counter);
- if (trace) {
- ZTracer::tracer()->report_stat_counter(counter, increment, value);
- }
+ ZTracer::tracer()->report_stat_counter(counter, increment, value);
}
void ZStatInc(const ZStatUnsampledCounter& counter, uint64_t increment) {
@@ -1049,6 +1045,14 @@
_normalized_duration.add(normalized_duration);
}
+bool ZStatCycle::is_first() {
+ return _ncycles == 0;
+}
+
+bool ZStatCycle::is_warm() {
+ return _ncycles >= 3;
+}
+
uint64_t ZStatCycle::ncycles() {
return _ncycles;
}
@@ -1215,6 +1219,20 @@
ZStatHeap::ZAtRelocateStart ZStatHeap::_at_relocate_start;
ZStatHeap::ZAtRelocateEnd ZStatHeap::_at_relocate_end;
+size_t ZStatHeap::capacity_high() {
+ return MAX4(_at_mark_start.capacity,
+ _at_mark_end.capacity,
+ _at_relocate_start.capacity,
+ _at_relocate_end.capacity);
+}
+
+size_t ZStatHeap::capacity_low() {
+ return MIN4(_at_mark_start.capacity,
+ _at_mark_end.capacity,
+ _at_relocate_start.capacity,
+ _at_relocate_end.capacity);
+}
+
size_t ZStatHeap::available(size_t used) {
return _at_initialize.max_capacity - used;
}
@@ -1282,8 +1300,8 @@
size_t used_high,
size_t used_low) {
_at_relocate_end.capacity = capacity;
- _at_relocate_end.capacity_high = capacity;
- _at_relocate_end.capacity_low = _at_mark_start.capacity;
+ _at_relocate_end.capacity_high = capacity_high();
+ _at_relocate_end.capacity_low = capacity_low();
_at_relocate_end.reserve = reserve(used);
_at_relocate_end.reserve_high = reserve(used_low);
_at_relocate_end.reserve_low = reserve(used_high);
--- a/src/hotspot/share/gc/z/zStat.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zStat.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -315,8 +315,8 @@
//
// Stat sample/increment
//
-void ZStatSample(const ZStatSampler& sampler, uint64_t value, bool trace = ZStatisticsForceTrace);
-void ZStatInc(const ZStatCounter& counter, uint64_t increment = 1, bool trace = ZStatisticsForceTrace);
+void ZStatSample(const ZStatSampler& sampler, uint64_t value);
+void ZStatInc(const ZStatCounter& counter, uint64_t increment = 1);
void ZStatInc(const ZStatUnsampledCounter& counter, uint64_t increment = 1);
//
@@ -374,6 +374,8 @@
static void at_start();
static void at_end(double boost_factor);
+ static bool is_first();
+ static bool is_warm();
static uint64_t ncycles();
static const AbsSeq& normalized_duration();
static double time_since_last();
@@ -519,6 +521,8 @@
size_t free_low;
} _at_relocate_end;
+ static size_t capacity_high();
+ static size_t capacity_low();
static size_t available(size_t used);
static size_t reserve(size_t used);
static size_t free(size_t used);
--- a/src/hotspot/share/gc/z/zThread.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zThread.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -22,7 +22,7 @@
*/
#include "precompiled.hpp"
-#include "gc/z/zThread.hpp"
+#include "gc/z/zThread.inline.hpp"
#include "runtime/thread.hpp"
#include "utilities/debug.hpp"
--- a/src/hotspot/share/gc/z/zThread.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zThread.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -26,7 +26,6 @@
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
-#include "utilities/debug.hpp"
class ZThread : public AllStatic {
friend class ZTask;
@@ -43,12 +42,7 @@
static THREAD_LOCAL uint _worker_id;
static void initialize();
-
- static void ensure_initialized() {
- if (!_initialized) {
- initialize();
- }
- }
+ static void ensure_initialized();
static void set_worker();
static void set_runtime_worker();
@@ -59,36 +53,12 @@
public:
static const char* name();
-
- static uintptr_t id() {
- ensure_initialized();
- return _id;
- }
-
- static bool is_vm() {
- ensure_initialized();
- return _is_vm;
- }
-
- static bool is_java() {
- ensure_initialized();
- return _is_java;
- }
-
- static bool is_worker() {
- ensure_initialized();
- return _is_worker;
- }
-
- static bool is_runtime_worker() {
- ensure_initialized();
- return _is_runtime_worker;
- }
-
- static uint worker_id() {
- assert(has_worker_id(), "Worker id not initialized");
- return _worker_id;
- }
+ static uintptr_t id();
+ static bool is_vm();
+ static bool is_java();
+ static bool is_worker();
+ static bool is_runtime_worker();
+ static uint worker_id();
};
#endif // SHARE_GC_Z_ZTHREAD_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/z/zThread.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015, 2019, 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.
+ *
+ * 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.
+ */
+
+#ifndef SHARE_GC_Z_ZTHREAD_INLINE_HPP
+#define SHARE_GC_Z_ZTHREAD_INLINE_HPP
+
+#include "gc/z/zThread.hpp"
+#include "utilities/debug.hpp"
+
+inline void ZThread::ensure_initialized() {
+ if (!_initialized) {
+ initialize();
+ }
+}
+
+inline uintptr_t ZThread::id() {
+ ensure_initialized();
+ return _id;
+}
+
+inline bool ZThread::is_vm() {
+ ensure_initialized();
+ return _is_vm;
+}
+
+inline bool ZThread::is_java() {
+ ensure_initialized();
+ return _is_java;
+}
+
+inline bool ZThread::is_worker() {
+ ensure_initialized();
+ return _is_worker;
+}
+
+inline bool ZThread::is_runtime_worker() {
+ ensure_initialized();
+ return _is_runtime_worker;
+}
+
+inline uint ZThread::worker_id() {
+ assert(has_worker_id(), "Worker id not initialized");
+ return _worker_id;
+}
+
+#endif // SHARE_GC_Z_ZTHREAD_INLINE_HPP
--- a/src/hotspot/share/gc/z/zThreadLocalAllocBuffer.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zThreadLocalAllocBuffer.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zThreadLocalAllocBuffer.hpp"
+#include "gc/z/zValue.inline.hpp"
#include "runtime/globals.hpp"
#include "runtime/thread.hpp"
--- a/src/hotspot/share/gc/z/zTracer.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zTracer.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -22,18 +22,19 @@
*/
#include "precompiled.hpp"
+#include "gc/shared/gcId.hpp"
#include "gc/z/zStat.hpp"
#include "gc/z/zTracer.hpp"
-#include "gc/shared/gcId.hpp"
-#include "gc/shared/gcLocker.hpp"
#include "jfr/jfrEvents.hpp"
-#include "runtime/safepoint.hpp"
#include "runtime/safepointVerifiers.hpp"
+#include "utilities/debug.hpp"
+#include "utilities/macros.hpp"
#if INCLUDE_JFR
#include "jfr/metadata/jfrSerializer.hpp"
#endif
#if INCLUDE_JFR
+
class ZStatisticsCounterTypeConstant : public JfrSerializer {
public:
virtual void serialize(JfrCheckpointWriter& writer) {
@@ -64,7 +65,8 @@
true /* permit_cache */,
new ZStatisticsSamplerTypeConstant());
}
-#endif
+
+#endif // INCLUDE_JFR
ZTracer* ZTracer::_tracer = NULL;
@@ -77,24 +79,24 @@
JFR_ONLY(register_jfr_type_serializers());
}
-void ZTracer::send_stat_counter(uint32_t counter_id, uint64_t increment, uint64_t value) {
+void ZTracer::send_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value) {
NoSafepointVerifier nsv;
EventZStatisticsCounter e;
if (e.should_commit()) {
- e.set_id(counter_id);
+ e.set_id(counter.id());
e.set_increment(increment);
e.set_value(value);
e.commit();
}
}
-void ZTracer::send_stat_sampler(uint32_t sampler_id, uint64_t value) {
+void ZTracer::send_stat_sampler(const ZStatSampler& sampler, uint64_t value) {
NoSafepointVerifier nsv;
EventZStatisticsSampler e;
if (e.should_commit()) {
- e.set_id(sampler_id);
+ e.set_id(sampler.id());
e.set_value(value);
e.commit();
}
@@ -113,7 +115,7 @@
}
}
-void ZTracer::send_page_alloc(size_t size, size_t used, size_t free, size_t cache, bool nonblocking, bool noreserve) {
+void ZTracer::send_page_alloc(size_t size, size_t used, size_t free, size_t cache, ZAllocationFlags flags) {
NoSafepointVerifier nsv;
EventZPageAllocation e;
@@ -122,28 +124,8 @@
e.set_usedAfter(used);
e.set_freeAfter(free);
e.set_inCacheAfter(cache);
- e.set_nonBlocking(nonblocking);
- e.set_noReserve(noreserve);
+ e.set_nonBlocking(flags.non_blocking());
+ e.set_noReserve(flags.no_reserve());
e.commit();
}
}
-
-void ZTracer::report_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value) {
- send_stat_counter(counter.id(), increment, value);
-}
-
-void ZTracer::report_stat_sampler(const ZStatSampler& sampler, uint64_t value) {
- send_stat_sampler(sampler.id(), value);
-}
-
-void ZTracer::report_thread_phase(const ZStatPhase& phase, const Ticks& start, const Ticks& end) {
- send_thread_phase(phase.name(), start, end);
-}
-
-void ZTracer::report_thread_phase(const char* name, const Ticks& start, const Ticks& end) {
- send_thread_phase(name, start, end);
-}
-
-void ZTracer::report_page_alloc(size_t size, size_t used, size_t free, size_t cache, ZAllocationFlags flags) {
- send_page_alloc(size, used, free, cache, flags.non_blocking(), flags.no_reserve());
-}
--- a/src/hotspot/share/gc/z/zTracer.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zTracer.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -37,10 +37,10 @@
ZTracer();
- void send_stat_counter(uint32_t counter_id, uint64_t increment, uint64_t value);
- void send_stat_sampler(uint32_t sampler_id, uint64_t value);
+ void send_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value);
+ void send_stat_sampler(const ZStatSampler& sampler, uint64_t value);
void send_thread_phase(const char* name, const Ticks& start, const Ticks& end);
- void send_page_alloc(size_t size, size_t used, size_t free, size_t cache, bool nonblocking, bool noreserve);
+ void send_page_alloc(size_t size, size_t used, size_t free, size_t cache, ZAllocationFlags flags);
public:
static ZTracer* tracer();
@@ -48,7 +48,6 @@
void report_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value);
void report_stat_sampler(const ZStatSampler& sampler, uint64_t value);
- void report_thread_phase(const ZStatPhase& phase, const Ticks& start, const Ticks& end);
void report_thread_phase(const char* name, const Ticks& start, const Ticks& end);
void report_page_alloc(size_t size, size_t used, size_t free, size_t cache, ZAllocationFlags flags);
};
--- a/src/hotspot/share/gc/z/zTracer.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zTracer.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -24,12 +24,38 @@
#ifndef SHARE_GC_Z_ZTRACER_INLINE_HPP
#define SHARE_GC_Z_ZTRACER_INLINE_HPP
+#include "gc/z/zStat.hpp"
#include "gc/z/zTracer.hpp"
+#include "jfr/jfrEvents.hpp"
inline ZTracer* ZTracer::tracer() {
return _tracer;
}
+inline void ZTracer::report_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value) {
+ if (EventZStatisticsCounter::is_enabled()) {
+ send_stat_counter(counter, increment, value);
+ }
+}
+
+inline void ZTracer::report_stat_sampler(const ZStatSampler& sampler, uint64_t value) {
+ if (EventZStatisticsSampler::is_enabled()) {
+ send_stat_sampler(sampler, value);
+ }
+}
+
+inline void ZTracer::report_thread_phase(const char* name, const Ticks& start, const Ticks& end) {
+ if (EventZThreadPhase::is_enabled()) {
+ send_thread_phase(name, start, end);
+ }
+}
+
+inline void ZTracer::report_page_alloc(size_t size, size_t used, size_t free, size_t cache, ZAllocationFlags flags) {
+ if (EventZPageAllocation::is_enabled()) {
+ send_page_alloc(size, used, free, cache, flags);
+ }
+}
+
inline ZTraceThreadPhase::ZTraceThreadPhase(const char* name) :
_start(Ticks::now()),
_name(name) {}
--- a/src/hotspot/share/gc/z/zValue.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zValue.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -25,13 +25,11 @@
#define SHARE_GC_Z_ZVALUE_HPP
#include "memory/allocation.hpp"
-#include "gc/z/zCPU.hpp"
-#include "gc/z/zGlobals.hpp"
-#include "gc/z/zNUMA.hpp"
-#include "gc/z/zThread.hpp"
-#include "gc/z/zUtils.hpp"
-#include "runtime/globals.hpp"
-#include "utilities/align.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+//
+// Storage
+//
template <typename S>
class ZValueStorage : public AllStatic {
@@ -42,202 +40,93 @@
public:
static const size_t offset = 4 * K;
- static uintptr_t alloc(size_t size) {
- guarantee(size <= offset, "Allocation too large");
-
- // Allocate entry in existing memory block
- const uintptr_t addr = align_up(_top, S::alignment());
- _top = addr + size;
-
- if (_top < _end) {
- // Success
- return addr;
- }
-
- // Allocate new block of memory
- const size_t block_alignment = offset;
- const size_t block_size = offset * S::count();
- _top = ZUtils::alloc_aligned(block_alignment, block_size);
- _end = _top + offset;
-
- // Retry allocation
- return alloc(size);
- }
+ static uintptr_t alloc(size_t size);
};
-template <typename T> uintptr_t ZValueStorage<T>::_end = 0;
-template <typename T> uintptr_t ZValueStorage<T>::_top = 0;
-
class ZContendedStorage : public ZValueStorage<ZContendedStorage> {
public:
- static size_t alignment() {
- return ZCacheLineSize;
- }
-
- static uint32_t count() {
- return 1;
- }
-
- static uint32_t id() {
- return 0;
- }
+ static size_t alignment();
+ static uint32_t count();
+ static uint32_t id();
};
class ZPerCPUStorage : public ZValueStorage<ZPerCPUStorage> {
public:
- static size_t alignment() {
- return sizeof(uintptr_t);
- }
-
- static uint32_t count() {
- return ZCPU::count();
- }
-
- static uint32_t id() {
- return ZCPU::id();
- }
+ static size_t alignment();
+ static uint32_t count();
+ static uint32_t id();
};
class ZPerNUMAStorage : public ZValueStorage<ZPerNUMAStorage> {
public:
- static size_t alignment() {
- return sizeof(uintptr_t);
- }
-
- static uint32_t count() {
- return ZNUMA::count();
- }
-
- static uint32_t id() {
- return ZNUMA::id();
- }
+ static size_t alignment();
+ static uint32_t count();
+ static uint32_t id();
};
class ZPerWorkerStorage : public ZValueStorage<ZPerWorkerStorage> {
public:
- static size_t alignment() {
- return sizeof(uintptr_t);
- }
-
- static uint32_t count() {
- return MAX2(ParallelGCThreads, ConcGCThreads);
- }
-
- static uint32_t id() {
- return ZThread::worker_id();
- }
+ static size_t alignment();
+ static uint32_t count();
+ static uint32_t id();
};
-template <typename S, typename T>
-class ZValueIterator;
+//
+// Value
+//
template <typename S, typename T>
class ZValue : public CHeapObj<mtGC> {
private:
const uintptr_t _addr;
- uintptr_t value_addr(uint32_t value_id) const {
- return _addr + (value_id * S::offset);
- }
+ uintptr_t value_addr(uint32_t value_id) const;
public:
- ZValue() :
- _addr(S::alloc(sizeof(T))) {
- // Initialize all instances
- ZValueIterator<S, T> iter(this);
- for (T* addr; iter.next(&addr);) {
- ::new (addr) T;
- }
- }
+ ZValue();
+ ZValue(const T& value);
- ZValue(const T& value) :
- _addr(S::alloc(sizeof(T))) {
- // Initialize all instances
- ZValueIterator<S, T> iter(this);
- for (T* addr; iter.next(&addr);) {
- ::new (addr) T(value);
- }
- }
-
- // Not implemented
- ZValue(const ZValue<S, T>& value);
- ZValue<S, T>& operator=(const ZValue<S, T>& value);
+ const T* addr(uint32_t value_id = S::id()) const;
+ T* addr(uint32_t value_id = S::id());
- const T* addr(uint32_t value_id = S::id()) const {
- return reinterpret_cast<const T*>(value_addr(value_id));
- }
-
- T* addr(uint32_t value_id = S::id()) {
- return reinterpret_cast<T*>(value_addr(value_id));
- }
-
- const T& get(uint32_t value_id = S::id()) const {
- return *addr(value_id);
- }
+ const T& get(uint32_t value_id = S::id()) const;
+ T& get(uint32_t value_id = S::id());
- T& get(uint32_t value_id = S::id()) {
- return *addr(value_id);
- }
-
- void set(const T& value, uint32_t value_id = S::id()) {
- get(value_id) = value;
- }
-
- void set_all(const T& value) {
- ZValueIterator<S, T> iter(this);
- for (T* addr; iter.next(&addr);) {
- *addr = value;
- }
- }
+ void set(const T& value, uint32_t value_id = S::id());
+ void set_all(const T& value);
};
template <typename T>
class ZContended : public ZValue<ZContendedStorage, T> {
public:
- ZContended() :
- ZValue<ZContendedStorage, T>() {}
-
- ZContended(const T& value) :
- ZValue<ZContendedStorage, T>(value) {}
-
- using ZValue<ZContendedStorage, T>::operator=;
+ ZContended();
+ ZContended(const T& value);
};
template <typename T>
class ZPerCPU : public ZValue<ZPerCPUStorage, T> {
public:
- ZPerCPU() :
- ZValue<ZPerCPUStorage, T>() {}
-
- ZPerCPU(const T& value) :
- ZValue<ZPerCPUStorage, T>(value) {}
-
- using ZValue<ZPerCPUStorage, T>::operator=;
+ ZPerCPU();
+ ZPerCPU(const T& value);
};
template <typename T>
class ZPerNUMA : public ZValue<ZPerNUMAStorage, T> {
public:
- ZPerNUMA() :
- ZValue<ZPerNUMAStorage, T>() {}
-
- ZPerNUMA(const T& value) :
- ZValue<ZPerNUMAStorage, T>(value) {}
-
- using ZValue<ZPerNUMAStorage, T>::operator=;
+ ZPerNUMA();
+ ZPerNUMA(const T& value);
};
template <typename T>
class ZPerWorker : public ZValue<ZPerWorkerStorage, T> {
public:
- ZPerWorker() :
- ZValue<ZPerWorkerStorage, T>() {}
+ ZPerWorker();
+ ZPerWorker(const T& value);
+};
- ZPerWorker(const T& value) :
- ZValue<ZPerWorkerStorage, T>(value) {}
-
- using ZValue<ZPerWorkerStorage, T>::operator=;
-};
+//
+// Iterator
+//
template <typename S, typename T>
class ZValueIterator {
@@ -246,38 +135,27 @@
uint32_t _value_id;
public:
- ZValueIterator(ZValue<S, T>* value) :
- _value(value),
- _value_id(0) {}
+ ZValueIterator(ZValue<S, T>* value);
- bool next(T** value) {
- if (_value_id < S::count()) {
- *value = _value->addr(_value_id++);
- return true;
- }
- return false;
- }
+ bool next(T** value);
};
template <typename T>
class ZPerCPUIterator : public ZValueIterator<ZPerCPUStorage, T> {
public:
- ZPerCPUIterator(ZPerCPU<T>* value) :
- ZValueIterator<ZPerCPUStorage, T>(value) {}
+ ZPerCPUIterator(ZPerCPU<T>* value);
};
template <typename T>
class ZPerNUMAIterator : public ZValueIterator<ZPerNUMAStorage, T> {
public:
- ZPerNUMAIterator(ZPerNUMA<T>* value) :
- ZValueIterator<ZPerNUMAStorage, T>(value) {}
+ ZPerNUMAIterator(ZPerNUMA<T>* value);
};
template <typename T>
class ZPerWorkerIterator : public ZValueIterator<ZPerWorkerStorage, T> {
public:
- ZPerWorkerIterator(ZPerWorker<T>* value) :
- ZValueIterator<ZPerWorkerStorage, T>(value) {}
+ ZPerWorkerIterator(ZPerWorker<T>* value);
};
template <typename S, typename T>
@@ -287,38 +165,27 @@
uint32_t _value_id;
public:
- ZValueConstIterator(const ZValue<S, T>* value) :
- _value(value),
- _value_id(0) {}
+ ZValueConstIterator(const ZValue<S, T>* value);
- bool next(const T** value) {
- if (_value_id < S::count()) {
- *value = _value->addr(_value_id++);
- return true;
- }
- return false;
- }
+ bool next(const T** value);
};
template <typename T>
class ZPerCPUConstIterator : public ZValueConstIterator<ZPerCPUStorage, T> {
public:
- ZPerCPUConstIterator(const ZPerCPU<T>* value) :
- ZValueConstIterator<ZPerCPUStorage, T>(value) {}
+ ZPerCPUConstIterator(const ZPerCPU<T>* value);
};
template <typename T>
class ZPerNUMAConstIterator : public ZValueConstIterator<ZPerNUMAStorage, T> {
public:
- ZPerNUMAConstIterator(const ZPerNUMA<T>* value) :
- ZValueConstIterator<ZPerNUMAStorage, T>(value) {}
+ ZPerNUMAConstIterator(const ZPerNUMA<T>* value);
};
template <typename T>
class ZPerWorkerConstIterator : public ZValueConstIterator<ZPerWorkerStorage, T> {
public:
- ZPerWorkerConstIterator(const ZPerWorker<T>* value) :
- ZValueConstIterator<ZPerWorkerStorage, T>(value) {}
+ ZPerWorkerConstIterator(const ZPerWorker<T>* value);
};
#endif // SHARE_GC_Z_ZVALUE_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/z/zValue.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2015, 2019, 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.
+ *
+ * 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.
+ */
+
+#ifndef SHARE_GC_Z_ZVALUE_INLINE_HPP
+#define SHARE_GC_Z_ZVALUE_INLINE_HPP
+
+#include "gc/z/zCPU.inline.hpp"
+#include "gc/z/zGlobals.hpp"
+#include "gc/z/zNUMA.hpp"
+#include "gc/z/zThread.inline.hpp"
+#include "gc/z/zUtils.hpp"
+#include "gc/z/zValue.hpp"
+#include "runtime/globals.hpp"
+#include "utilities/align.hpp"
+
+//
+// Storage
+//
+
+template <typename T> uintptr_t ZValueStorage<T>::_end = 0;
+template <typename T> uintptr_t ZValueStorage<T>::_top = 0;
+
+template <typename S>
+uintptr_t ZValueStorage<S>::alloc(size_t size) {
+ assert(size <= offset, "Allocation too large");
+
+ // Allocate entry in existing memory block
+ const uintptr_t addr = align_up(_top, S::alignment());
+ _top = addr + size;
+
+ if (_top < _end) {
+ // Success
+ return addr;
+ }
+
+ // Allocate new block of memory
+ const size_t block_alignment = offset;
+ const size_t block_size = offset * S::count();
+ _top = ZUtils::alloc_aligned(block_alignment, block_size);
+ _end = _top + offset;
+
+ // Retry allocation
+ return alloc(size);
+}
+
+inline size_t ZContendedStorage::alignment() {
+ return ZCacheLineSize;
+}
+
+inline uint32_t ZContendedStorage::count() {
+ return 1;
+}
+
+inline uint32_t ZContendedStorage::id() {
+ return 0;
+}
+
+inline size_t ZPerCPUStorage::alignment() {
+ return sizeof(uintptr_t);
+}
+
+inline uint32_t ZPerCPUStorage::count() {
+ return ZCPU::count();
+}
+
+inline uint32_t ZPerCPUStorage::id() {
+ return ZCPU::id();
+}
+
+inline size_t ZPerNUMAStorage::alignment() {
+ return sizeof(uintptr_t);
+}
+
+inline uint32_t ZPerNUMAStorage::count() {
+ return ZNUMA::count();
+}
+
+inline uint32_t ZPerNUMAStorage::id() {
+ return ZNUMA::id();
+}
+
+inline size_t ZPerWorkerStorage::alignment() {
+ return sizeof(uintptr_t);
+}
+
+inline uint32_t ZPerWorkerStorage::count() {
+ return MAX2(ParallelGCThreads, ConcGCThreads);
+}
+
+inline uint32_t ZPerWorkerStorage::id() {
+ return ZThread::worker_id();
+}
+
+//
+// Value
+//
+
+template <typename S, typename T>
+inline uintptr_t ZValue<S, T>::value_addr(uint32_t value_id) const {
+ return _addr + (value_id * S::offset);
+}
+
+template <typename S, typename T>
+inline ZValue<S, T>::ZValue() :
+ _addr(S::alloc(sizeof(T))) {
+ // Initialize all instances
+ ZValueIterator<S, T> iter(this);
+ for (T* addr; iter.next(&addr);) {
+ ::new (addr) T;
+ }
+}
+
+template <typename S, typename T>
+inline ZValue<S, T>::ZValue(const T& value) :
+ _addr(S::alloc(sizeof(T))) {
+ // Initialize all instances
+ ZValueIterator<S, T> iter(this);
+ for (T* addr; iter.next(&addr);) {
+ ::new (addr) T(value);
+ }
+}
+
+template <typename S, typename T>
+inline const T* ZValue<S, T>::addr(uint32_t value_id) const {
+ return reinterpret_cast<const T*>(value_addr(value_id));
+}
+
+template <typename S, typename T>
+inline T* ZValue<S, T>::addr(uint32_t value_id) {
+ return reinterpret_cast<T*>(value_addr(value_id));
+}
+
+template <typename S, typename T>
+inline const T& ZValue<S, T>::get(uint32_t value_id) const {
+ return *addr(value_id);
+}
+
+template <typename S, typename T>
+inline T& ZValue<S, T>::get(uint32_t value_id) {
+ return *addr(value_id);
+}
+
+template <typename S, typename T>
+inline void ZValue<S, T>::set(const T& value, uint32_t value_id) {
+ get(value_id) = value;
+}
+
+template <typename S, typename T>
+inline void ZValue<S, T>::set_all(const T& value) {
+ ZValueIterator<S, T> iter(this);
+ for (T* addr; iter.next(&addr);) {
+ *addr = value;
+ }
+}
+
+template <typename T>
+inline ZContended<T>::ZContended() :
+ ZValue<ZContendedStorage, T>() {}
+
+template <typename T>
+inline ZContended<T>::ZContended(const T& value) :
+ ZValue<ZContendedStorage, T>(value) {}
+
+template <typename T>
+inline ZPerCPU<T>::ZPerCPU() :
+ ZValue<ZPerCPUStorage, T>() {}
+
+template <typename T>
+inline ZPerCPU<T>::ZPerCPU(const T& value) :
+ ZValue<ZPerCPUStorage, T>(value) {}
+
+template <typename T>
+inline ZPerNUMA<T>::ZPerNUMA() :
+ ZValue<ZPerNUMAStorage, T>() {}
+
+template <typename T>
+inline ZPerNUMA<T>::ZPerNUMA(const T& value) :
+ ZValue<ZPerNUMAStorage, T>(value) {}
+
+template <typename T>
+inline ZPerWorker<T>::ZPerWorker() :
+ ZValue<ZPerWorkerStorage, T>() {}
+
+template <typename T>
+inline ZPerWorker<T>::ZPerWorker(const T& value) :
+ ZValue<ZPerWorkerStorage, T>(value) {}
+
+//
+// Iterator
+//
+
+template <typename S, typename T>
+inline ZValueIterator<S, T>::ZValueIterator(ZValue<S, T>* value) :
+ _value(value),
+ _value_id(0) {}
+
+template <typename S, typename T>
+inline bool ZValueIterator<S, T>::next(T** value) {
+ if (_value_id < S::count()) {
+ *value = _value->addr(_value_id++);
+ return true;
+ }
+ return false;
+}
+
+template <typename T>
+inline ZPerCPUIterator<T>::ZPerCPUIterator(ZPerCPU<T>* value) :
+ ZValueIterator<ZPerCPUStorage, T>(value) {}
+
+template <typename T>
+inline ZPerNUMAIterator<T>::ZPerNUMAIterator(ZPerNUMA<T>* value) :
+ ZValueIterator<ZPerNUMAStorage, T>(value) {}
+
+template <typename T>
+inline ZPerWorkerIterator<T>::ZPerWorkerIterator(ZPerWorker<T>* value) :
+ ZValueIterator<ZPerWorkerStorage, T>(value) {}
+
+template <typename S, typename T>
+inline ZValueConstIterator<S, T>::ZValueConstIterator(const ZValue<S, T>* value) :
+ _value(value),
+ _value_id(0) {}
+
+template <typename S, typename T>
+inline bool ZValueConstIterator<S, T>::next(const T** value) {
+ if (_value_id < S::count()) {
+ *value = _value->addr(_value_id++);
+ return true;
+ }
+ return false;
+}
+
+template <typename T>
+inline ZPerCPUConstIterator<T>::ZPerCPUConstIterator(const ZPerCPU<T>* value) :
+ ZValueConstIterator<ZPerCPUStorage, T>(value) {}
+
+template <typename T>
+inline ZPerNUMAConstIterator<T>::ZPerNUMAConstIterator(const ZPerNUMA<T>* value) :
+ ZValueConstIterator<ZPerNUMAStorage, T>(value) {}
+
+template <typename T>
+inline ZPerWorkerConstIterator<T>::ZPerWorkerConstIterator(const ZPerWorker<T>* value) :
+ ZValueConstIterator<ZPerWorkerStorage, T>(value) {}
+
+#endif // SHARE_GC_Z_ZVALUE_INLINE_HPP
--- a/src/hotspot/share/gc/z/zVerify.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zVerify.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -26,6 +26,7 @@
#include "gc/z/zAddress.hpp"
#include "gc/z/zHeap.inline.hpp"
#include "gc/z/zOop.hpp"
+#include "gc/z/zPageAllocator.hpp"
#include "gc/z/zResurrection.hpp"
#include "gc/z/zRootsIterator.hpp"
#include "gc/z/zStat.hpp"
@@ -170,3 +171,38 @@
ZStatTimerDisable disable;
roots_and_objects(true /* verify_weaks */);
}
+
+template <bool Map>
+class ZPageDebugMapOrUnmapClosure : public ZPageClosure {
+private:
+ const ZPageAllocator* const _allocator;
+
+public:
+ ZPageDebugMapOrUnmapClosure(const ZPageAllocator* allocator) :
+ _allocator(allocator) {}
+
+ void do_page(const ZPage* page) {
+ if (Map) {
+ _allocator->debug_map_page(page);
+ } else {
+ _allocator->debug_unmap_page(page);
+ }
+ }
+};
+
+ZVerifyViewsFlip::ZVerifyViewsFlip(const ZPageAllocator* allocator) :
+ _allocator(allocator) {
+ if (ZVerifyViews) {
+ // Unmap all pages
+ ZPageDebugMapOrUnmapClosure<false /* Map */> cl(_allocator);
+ ZHeap::heap()->pages_do(&cl);
+ }
+}
+
+ZVerifyViewsFlip::~ZVerifyViewsFlip() {
+ if (ZVerifyViews) {
+ // Map all pages
+ ZPageDebugMapOrUnmapClosure<true /* Map */> cl(_allocator);
+ ZHeap::heap()->pages_do(&cl);
+ }
+}
--- a/src/hotspot/share/gc/z/zVerify.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zVerify.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -26,6 +26,8 @@
#include "memory/allocation.hpp"
+class ZPageAllocator;
+
class ZVerify : public AllStatic {
private:
template <typename RootsIterator> static void roots();
@@ -45,4 +47,13 @@
static void after_weak_processing();
};
+class ZVerifyViewsFlip {
+private:
+ const ZPageAllocator* const _allocator;
+
+public:
+ ZVerifyViewsFlip(const ZPageAllocator* allocator);
+ ~ZVerifyViewsFlip();
+};
+
#endif // SHARE_GC_Z_ZVERIFY_HPP
--- a/src/hotspot/share/gc/z/zVirtualMemory.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zVirtualMemory.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -22,10 +22,13 @@
*/
#include "precompiled.hpp"
+#include "gc/z/zAddressSpaceLimit.hpp"
#include "gc/z/zGlobals.hpp"
#include "gc/z/zVirtualMemory.inline.hpp"
#include "logging/log.hpp"
#include "services/memTracker.hpp"
+#include "utilities/debug.hpp"
+#include "utilities/align.hpp"
ZVirtualMemoryManager::ZVirtualMemoryManager(size_t max_capacity) :
_manager(),
@@ -38,33 +41,105 @@
return;
}
- log_info(gc, init)("Address Space: " SIZE_FORMAT "T", ZAddressOffsetMax / K / G);
-
// Reserve address space
- if (reserve(0, ZAddressOffsetMax) < max_capacity) {
- log_error(gc)("Failed to reserve address space for Java heap");
+ if (!reserve(max_capacity)) {
+ log_error(gc)("Failed to reserve enough address space for Java heap");
return;
}
+ // Initialize OS specific parts
+ initialize_os();
+
// Successfully initialized
_initialized = true;
}
-size_t ZVirtualMemoryManager::reserve(uintptr_t start, size_t size) {
- if (size < ZGranuleSize) {
+size_t ZVirtualMemoryManager::reserve_discontiguous(uintptr_t start, size_t size, size_t min_range) {
+ if (size < min_range) {
+ // Too small
+ return 0;
+ }
+
+ assert(is_aligned(size, ZGranuleSize), "Misaligned");
+
+ if (reserve_contiguous_platform(start, size)) {
+ // Make the address range free
+ _manager.free(start, size);
+ return size;
+ }
+
+ const size_t half = size / 2;
+ if (half < min_range) {
// Too small
return 0;
}
- if (!reserve_platform(start, size)) {
- const size_t half = size / 2;
- return reserve(start, half) + reserve(start + half, half);
+ // Divide and conquer
+ const size_t first_part = align_down(half, ZGranuleSize);
+ const size_t second_part = size - first_part;
+ return reserve_discontiguous(start, first_part, min_range) +
+ reserve_discontiguous(start + first_part, second_part, min_range);
+}
+
+size_t ZVirtualMemoryManager::reserve_discontiguous(size_t size) {
+ // Don't try to reserve address ranges smaller than 1% of the requested size.
+ // This avoids an explosion of reservation attempts in case large parts of the
+ // address space is already occupied.
+ const size_t min_range = align_up(size / 100, ZGranuleSize);
+ size_t start = 0;
+ size_t reserved = 0;
+
+ // Reserve size somewhere between [0, ZAddressOffsetMax)
+ while (reserved < size && start < ZAddressOffsetMax) {
+ const size_t remaining = MIN2(size - reserved, ZAddressOffsetMax - start);
+ reserved += reserve_discontiguous(start, remaining, min_range);
+ start += remaining;
}
- // Make the address range free
- _manager.free(start, size);
+ return reserved;
+}
+
+bool ZVirtualMemoryManager::reserve_contiguous(size_t size) {
+ // Allow at most 8192 attempts spread evenly across [0, ZAddressOffsetMax)
+ const size_t end = ZAddressOffsetMax - size;
+ const size_t increment = align_up(end / 8192, ZGranuleSize);
+
+ for (size_t start = 0; start <= end; start += increment) {
+ if (reserve_contiguous_platform(start, size)) {
+ // Make the address range free
+ _manager.free(start, size);
+
+ // Success
+ return true;
+ }
+ }
+
+ // Failed
+ return false;
+}
- return size;
+bool ZVirtualMemoryManager::reserve(size_t max_capacity) {
+ const size_t limit = MIN2(ZAddressOffsetMax, ZAddressSpaceLimit::heap_view());
+ const size_t size = MIN2(max_capacity * ZVirtualToPhysicalRatio, limit);
+
+ size_t reserved = size;
+ bool contiguous = true;
+
+ // Prefer a contiguous address space
+ if (!reserve_contiguous(size)) {
+ // Fall back to a discontiguous address space
+ reserved = reserve_discontiguous(size);
+ contiguous = false;
+ }
+
+ log_info(gc, init)("Address Space Type: %s/%s/%s",
+ (contiguous ? "Contiguous" : "Discontiguous"),
+ (limit == ZAddressOffsetMax ? "Unrestricted" : "Restricted"),
+ (reserved == size ? "Complete" : "Degraded"));
+ log_info(gc, init)("Address Space Size: " SIZE_FORMAT "M x " SIZE_FORMAT " = " SIZE_FORMAT "M",
+ reserved / M, ZHeapViews, (reserved * ZHeapViews) / M);
+
+ return reserved >= max_capacity;
}
void ZVirtualMemoryManager::nmt_reserve(uintptr_t start, size_t size) {
--- a/src/hotspot/share/gc/z/zVirtualMemory.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zVirtualMemory.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -50,8 +50,14 @@
ZMemoryManager _manager;
bool _initialized;
- bool reserve_platform(uintptr_t start, size_t size);
- size_t reserve(uintptr_t start, size_t size);
+ void initialize_os();
+
+ bool reserve_contiguous_platform(uintptr_t start, size_t size);
+ bool reserve_contiguous(size_t size);
+ size_t reserve_discontiguous(uintptr_t start, size_t size, size_t min_range);
+ size_t reserve_discontiguous(size_t size);
+ bool reserve(size_t max_capacity);
+
void nmt_reserve(uintptr_t start, size_t size);
public:
--- a/src/hotspot/share/gc/z/zWeakRootsProcessor.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/zWeakRootsProcessor.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, 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
@@ -24,8 +24,6 @@
#ifndef SHARE_GC_Z_ZWEAKROOTSPROCESSOR_HPP
#define SHARE_GC_Z_ZWEAKROOTSPROCESSOR_HPP
-#include "gc/z/zValue.hpp"
-
class ZWorkers;
class ZWeakRootsProcessor {
--- a/src/hotspot/share/gc/z/z_globals.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/gc/z/z_globals.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -67,9 +67,6 @@
"Time between statistics print outs (in seconds)") \
range(1, (uint)-1) \
\
- diagnostic(bool, ZStatisticsForceTrace, false, \
- "Force tracing of ZStats") \
- \
diagnostic(bool, ZProactive, true, \
"Enable proactive GC cycles") \
\
--- a/src/hotspot/share/include/jvm.h Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/include/jvm.h Mon Oct 28 18:43:04 2019 +0100
@@ -192,6 +192,13 @@
JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
/*
+ * java.lang.NullPointerException
+ */
+
+JNIEXPORT jstring JNICALL
+JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable);
+
+/*
* java.lang.StackWalker
*/
enum {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/interpreter/bytecodeUtils.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,1481 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019 SAP SE. 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.
+ *
+ * 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.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "classfile/systemDictionary.hpp"
+#include "gc/shared/gcLocker.hpp"
+#include "interpreter/bytecodeUtils.hpp"
+#include "memory/resourceArea.hpp"
+#include "runtime/signature.hpp"
+#include "runtime/safepointVerifiers.hpp"
+#include "utilities/events.hpp"
+#include "utilities/ostream.hpp"
+
+class SimulatedOperandStack;
+class ExceptionMessageBuilder;
+
+// The entries of a SimulatedOperandStack. They carry the analysis
+// information gathered for the slot.
+class StackSlotAnalysisData {
+ private:
+
+ friend class SimulatedOperandStack;
+ friend class ExceptionMessageBuilder;
+
+ unsigned int _bci:17; // The bci of the bytecode that pushed the current value on the operand stack.
+ // INVALID if ambiguous, e.g. after a control flow merge.
+ // 16 bits for bci (max bytecode size) and one for INVALID.
+ unsigned int _type:15; // The BasicType of the value on the operand stack.
+
+ // Merges this slot data with the given one and returns the result. If
+ // the bcis of the two merged objects are different, the bci of the result
+ // will be undefined. If the types are different, the result type is T_CONFLICT.
+ // (An exception is if one type is an array and the other is object, then
+ // the result type will be T_OBJECT).
+ StackSlotAnalysisData merge(StackSlotAnalysisData other);
+
+ public:
+
+ // Creates a new object with an invalid bci and the given type.
+ StackSlotAnalysisData(BasicType type = T_CONFLICT);
+
+ // Creates a new object with the given bci and type.
+ StackSlotAnalysisData(int bci, BasicType type);
+
+ enum {
+ // An invalid bytecode index, as > 65535.
+ INVALID = 0x1FFFF
+ };
+
+ // Returns the bci. If the bci is invalid, INVALID is returned.
+ unsigned int get_bci();
+
+ // Returns true, if the bci is not invalid.
+ bool has_bci() { return get_bci() != INVALID; }
+
+ // Returns the type of the slot data.
+ BasicType get_type();
+};
+
+// A stack consisting of SimulatedOperandStackEntries.
+// This represents the analysis information for the operand stack
+// for a given bytecode at a given bci.
+// It also holds an additional field that serves to collect
+// information whether local slots were written.
+class SimulatedOperandStack: CHeapObj<mtInternal> {
+
+ private:
+
+ friend class ExceptionMessageBuilder;
+ friend class StackSlotAnalysisData;
+
+ // The stack.
+ GrowableArray<StackSlotAnalysisData> _stack;
+
+ // Optimized bytecode can reuse local variable slots for several
+ // local variables.
+ // If there is no variable name information, we print 'parameter<i>'
+ // if a parameter maps to a local slot. Once a local slot has been
+ // written, we don't know any more whether it was written as the
+ // corresponding parameter, or whether another local has been
+ // mapped to the slot. So we don't want to print 'parameter<i>' any
+ // more, but 'local<i>'. Similary for 'this'.
+ // Therefore, during the analysis, we mark a bit for local slots that
+ // get written and propagate this information.
+ // We only run the analysis for 64 slots. If a method has more
+ // parameters, we print 'local<i>' in all cases.
+ uint64_t _written_local_slots;
+
+ SimulatedOperandStack(): _written_local_slots(0) { };
+ SimulatedOperandStack(const SimulatedOperandStack ©);
+
+ // Pushes the given slot data.
+ void push_raw(StackSlotAnalysisData slotData);
+
+ // Like push_raw, but if the slotData has type long or double, we push two.
+ void push(StackSlotAnalysisData slotData);
+
+ // Like push(slotData), but using bci/type to create an instance of
+ // StackSlotAnalysisData first.
+ void push(int bci, BasicType type);
+
+ // Pops the given number of entries.
+ void pop(int slots);
+
+ // Merges this with the given stack by merging all entries. The
+ // size of the stacks must be the same.
+ void merge(SimulatedOperandStack const& other);
+
+ public:
+
+ // Returns the size of the stack.
+ int get_size() const;
+
+ // Returns the slot data at the given index. Slot 0 is top of stack.
+ StackSlotAnalysisData get_slot_data(int slot);
+
+ // Mark that local slot i was written.
+ void set_local_slot_written(int i);
+
+ // Check whether local slot i was written by this or a previous bytecode.
+ bool local_slot_was_written(int i);
+};
+
+// Helper class to build internal exception messages for exceptions
+// that are thrown because prerequisites to execute a bytecode
+// are not met.
+// E.g., if a NPE is thrown because an iload can not be executed
+// by the VM because the reference to load from is null.
+//
+// It analyses the bytecode to assemble Java-like message text
+// to give precise information where in a larger expression the
+// exception occured.
+//
+// To assemble this message text, it is needed to know how
+// operand stack slot entries were pushed on the operand stack.
+// This class contains an analysis over the bytecodes to compute
+// this information. The information is stored in a
+// SimulatedOperandStack for each bytecode.
+class ExceptionMessageBuilder : public StackObj {
+
+ // The stacks for each bytecode.
+ GrowableArray<SimulatedOperandStack*>* _stacks;
+
+ // The method.
+ Method* _method;
+
+ // The number of entries used (the sum of all entries of all stacks).
+ int _nr_of_entries;
+
+ // If true, we have added at least one new stack.
+ bool _added_one;
+
+ // If true, we have processed all bytecodes.
+ bool _all_processed;
+
+ // The maximum number of entries we want to use. This is used to
+ // limit the amount of memory we waste for insane methods (as they
+ // appear in JCK tests).
+ static const int _max_entries = 1000000;
+
+ static const int _max_cause_detail = 5;
+
+ // Merges the stack the the given bci with the given stack. If there
+ // is no stack at the bci, we just put the given stack there. This
+ // method doesn't takes ownership of the stack.
+ void merge(int bci, SimulatedOperandStack* stack);
+
+ // Processes the instruction at the given bci in the method. Returns
+ // the size of the instruction.
+ int do_instruction(int bci);
+
+ bool print_NPE_cause0(outputStream *os, int bci, int slot, int max_detail,
+ bool inner_expr = false, const char *prefix = NULL);
+
+ public:
+
+ // Creates an ExceptionMessageBuilder object and runs the analysis
+ // building SimulatedOperandStacks for each bytecode in the given
+ // method (the method must be rewritten already). Note that you're
+ // not allowed to use this object when crossing a safepoint! If the
+ // bci is != -1, we only create the stacks as far as needed to get a
+ // stack for the bci.
+ ExceptionMessageBuilder(Method* method, int bci = -1);
+
+ // Releases the resources.
+ ~ExceptionMessageBuilder();
+
+ // Returns the number of stacks (this is the size of the method).
+ int get_size() { return _stacks->length() - 1; }
+
+ // Assuming that a NullPointerException was thrown at the given bci,
+ // we return the nr of the slot holding the null reference. If this
+ // NPE is created by hand, we return -2 as the slot. If there
+ // cannot be a NullPointerException at the bci, -1 is returned.
+ int get_NPE_null_slot(int bci);
+
+ // Prints a java-like expression for the bytecode that pushed
+ // the value to the given slot being live at the given bci.
+ // It constructs the expression by recursing backwards over the
+ // bytecode using the results of the analysis done in the
+ // constructor of ExceptionMessageBuilder.
+ // os: The stream to print the message to.
+ // bci: The index of the bytecode that caused the NPE.
+ // slot: The slot on the operand stack that contains null.
+ // The slots are numbered from TOS downwards, i.e.,
+ // TOS has the slot number 0, that below 1 and so on.
+ //
+ // Returns false if nothing was printed, else true.
+ bool print_NPE_cause(outputStream *os, int bci, int slot);
+
+ // Prints a string describing the failed action.
+ void print_NPE_failed_action(outputStream *os, int bci);
+};
+
+// Replaces the following well-known class names:
+// java.lang.Object -> Object
+// java.lang.String -> String
+static char *trim_well_known_class_names_from_signature(char *signature) {
+ size_t len = strlen(signature);
+ size_t skip_len = strlen("java.lang.");
+ size_t min_pattern_len = strlen("java.lang.String");
+ if (len < min_pattern_len) return signature;
+
+ for (size_t isrc = 0, idst = 0; isrc <= len; isrc++, idst++) {
+ // We must be careful not to trim names like test.java.lang.String.
+ if ((isrc == 0 && strncmp(signature + isrc, "java.lang.Object", min_pattern_len) == 0) ||
+ (isrc == 0 && strncmp(signature + isrc, "java.lang.String", min_pattern_len) == 0) ||
+ (isrc > 1 && strncmp(signature + isrc-2, ", java.lang.Object", min_pattern_len+2) == 0) ||
+ (isrc > 1 && strncmp(signature + isrc-2, ", java.lang.String", min_pattern_len+2) == 0) ) {
+ isrc += skip_len;
+ }
+ if (idst != isrc) {
+ signature[idst] = signature[isrc];
+ }
+ }
+ return signature;
+}
+
+// Replaces the following well-known class names:
+// java.lang.Object -> Object
+// java.lang.String -> String
+static void print_klass_name(outputStream *os, Symbol *klass) {
+ const char *name = klass->as_klass_external_name();
+ if (strcmp(name, "java.lang.Object") == 0) name = "Object";
+ if (strcmp(name, "java.lang.String") == 0) name = "String";
+ os->print("%s", name);
+}
+
+// Prints the name of the method that is described at constant pool
+// index cp_index in the constant pool of method 'method'.
+static void print_method_name(outputStream *os, Method* method, int cp_index) {
+ ResourceMark rm;
+ ConstantPool* cp = method->constants();
+ Symbol* klass = cp->klass_ref_at_noresolve(cp_index);
+ Symbol* name = cp->name_ref_at(cp_index);
+ Symbol* signature = cp->signature_ref_at(cp_index);
+
+ print_klass_name(os, klass);
+ os->print(".%s(", name->as_C_string());
+ stringStream sig;
+ signature->print_as_signature_external_parameters(&sig);
+ os->print("%s)", trim_well_known_class_names_from_signature(sig.as_string()));
+}
+
+// Prints the name of the field that is described at constant pool
+// index cp_index in the constant pool of method 'method'.
+static void print_field_and_class(outputStream *os, Method* method, int cp_index) {
+ ResourceMark rm;
+ ConstantPool* cp = method->constants();
+ Symbol* klass = cp->klass_ref_at_noresolve(cp_index);
+ Symbol *name = cp->name_ref_at(cp_index);
+ print_klass_name(os, klass);
+ os->print(".%s", name->as_C_string());
+}
+
+// Returns the name of the field that is described at constant pool
+// index cp_index in the constant pool of method 'method'.
+static char const* get_field_name(Method* method, int cp_index) {
+ Symbol* name = method->constants()->name_ref_at(cp_index);
+ return name->as_C_string();
+}
+
+static void print_local_var(outputStream *os, unsigned int bci, Method* method, int slot, bool is_parameter) {
+ if (method->has_localvariable_table()) {
+ for (int i = 0; i < method->localvariable_table_length(); i++) {
+ LocalVariableTableElement* elem = method->localvariable_table_start() + i;
+ unsigned int start = elem->start_bci;
+ unsigned int end = start + elem->length;
+
+ if ((bci >= start) && (bci < end) && (elem->slot == slot)) {
+ ConstantPool* cp = method->constants();
+ char *var = cp->symbol_at(elem->name_cp_index)->as_C_string();
+ os->print("%s", var);
+
+ return;
+ }
+ }
+ }
+
+ // Handle at least some cases we know.
+ if (!method->is_static() && (slot == 0) && is_parameter) {
+ os->print("this");
+ } else {
+ int curr = method->is_static() ? 0 : 1;
+ SignatureStream ss(method->signature());
+ int param_index = 1;
+ bool found = false;
+
+ for (SignatureStream ss(method->signature()); !ss.is_done(); ss.next()) {
+ if (ss.at_return_type()) {
+ continue;
+ }
+ int size = type2size[ss.type()];
+ if ((slot >= curr) && (slot < curr + size)) {
+ found = true;
+ break;
+ }
+ param_index += 1;
+ curr += size;
+ }
+
+ if (found && is_parameter) {
+ os->print("<parameter%d>", param_index);
+ } else {
+ // This is the best we can do.
+ os->print("<local%d>", slot);
+ }
+ }
+}
+
+StackSlotAnalysisData::StackSlotAnalysisData(BasicType type) : _bci(INVALID), _type(type) {}
+
+StackSlotAnalysisData::StackSlotAnalysisData(int bci, BasicType type) : _bci(bci), _type(type) {
+ assert(bci >= 0, "BCI must be >= 0");
+ assert(bci < 65536, "BCI must be < 65536");
+}
+
+unsigned int StackSlotAnalysisData::get_bci() {
+ return _bci;
+}
+
+BasicType StackSlotAnalysisData::get_type() {
+ return (BasicType)_type;
+}
+
+StackSlotAnalysisData StackSlotAnalysisData::merge(StackSlotAnalysisData other) {
+ if (get_type() != other.get_type()) {
+ if (((get_type() == T_OBJECT) || (get_type() == T_ARRAY)) &&
+ ((other.get_type() == T_OBJECT) || (other.get_type() == T_ARRAY))) {
+ if (get_bci() == other.get_bci()) {
+ return StackSlotAnalysisData(get_bci(), T_OBJECT);
+ } else {
+ return StackSlotAnalysisData(T_OBJECT);
+ }
+ } else {
+ return StackSlotAnalysisData(T_CONFLICT);
+ }
+ }
+
+ if (get_bci() == other.get_bci()) {
+ return *this;
+ } else {
+ return StackSlotAnalysisData(get_type());
+ }
+}
+
+SimulatedOperandStack::SimulatedOperandStack(const SimulatedOperandStack ©) {
+ for (int i = 0; i < copy.get_size(); i++) {
+ push_raw(copy._stack.at(i));
+ }
+ _written_local_slots = copy._written_local_slots;
+}
+
+void SimulatedOperandStack::push_raw(StackSlotAnalysisData slotData) {
+ if (slotData.get_type() == T_VOID) {
+ return;
+ }
+
+ _stack.push(slotData);
+}
+
+void SimulatedOperandStack::push(StackSlotAnalysisData slotData) {
+ if (type2size[slotData.get_type()] == 2) {
+ push_raw(slotData);
+ push_raw(slotData);
+ } else {
+ push_raw(slotData);
+ }
+}
+
+void SimulatedOperandStack::push(int bci, BasicType type) {
+ push(StackSlotAnalysisData(bci, type));
+}
+
+void SimulatedOperandStack::pop(int slots) {
+ for (int i = 0; i < slots; ++i) {
+ _stack.pop();
+ }
+
+ assert(get_size() >= 0, "Popped too many slots");
+}
+
+void SimulatedOperandStack::merge(SimulatedOperandStack const& other) {
+ assert(get_size() == other.get_size(), "Stacks not of same size");
+
+ for (int i = get_size() - 1; i >= 0; --i) {
+ _stack.at_put(i, _stack.at(i).merge(other._stack.at(i)));
+ }
+ _written_local_slots = _written_local_slots | other._written_local_slots;
+}
+
+int SimulatedOperandStack::get_size() const {
+ return _stack.length();
+}
+
+StackSlotAnalysisData SimulatedOperandStack::get_slot_data(int slot) {
+ assert(slot >= 0, "Slot=%d < 0", slot);
+ assert(slot < get_size(), "Slot=%d >= size=%d", slot, get_size());
+
+ return _stack.at(get_size() - slot - 1);
+}
+
+void SimulatedOperandStack::set_local_slot_written(int i) {
+ // Local slots > 63 are very unlikely. Consider these
+ // as written all the time. Saves space and complexity
+ // for dynamic data size.
+ if (i > 63) return;
+ _written_local_slots = _written_local_slots | (1ULL << i);
+}
+
+bool SimulatedOperandStack::local_slot_was_written(int i) {
+ if (i > 63) return true;
+ return (_written_local_slots & (1ULL << i)) != 0;
+}
+
+ExceptionMessageBuilder::ExceptionMessageBuilder(Method* method, int bci) :
+ _method(method), _nr_of_entries(0),
+ _added_one(true), _all_processed(false) {
+
+ ConstMethod* const_method = method->constMethod();
+ const int len = const_method->code_size();
+
+ assert(bci >= 0, "BCI too low: %d", bci);
+ assert(bci < len, "BCI too large: %d size: %d", bci, len);
+
+ _stacks = new GrowableArray<SimulatedOperandStack*> (len + 1);
+
+ for (int i = 0; i <= len; ++i) {
+ _stacks->push(NULL);
+ }
+
+ // Initialize stack a bci 0.
+ _stacks->at_put(0, new SimulatedOperandStack());
+
+ // And initialize the start of all exception handlers.
+ if (const_method->has_exception_handler()) {
+ ExceptionTableElement *et = const_method->exception_table_start();
+ for (int i = 0; i < const_method->exception_table_length(); ++i) {
+ u2 index = et[i].handler_pc;
+
+ if (_stacks->at(index) == NULL) {
+ _stacks->at_put(index, new SimulatedOperandStack());
+ _stacks->at(index)->push(index, T_OBJECT);
+ }
+ }
+ }
+
+ // Do this until each bytecode has a stack or we haven't
+ // added a new stack in one iteration.
+ while (!_all_processed && _added_one) {
+ _all_processed = true;
+ _added_one = false;
+
+ for (int i = 0; i < len; ) {
+ // Analyse bytecode i. Step by size of the analyzed bytecode to next bytecode.
+ i += do_instruction(i);
+
+ // If we want the data only for a certain bci, we can possibly end early.
+ if ((bci == i) && (_stacks->at(i) != NULL)) {
+ _all_processed = true;
+ break;
+ }
+
+ if (_nr_of_entries > _max_entries) {
+ return;
+ }
+ }
+ }
+}
+
+ExceptionMessageBuilder::~ExceptionMessageBuilder() {
+ if (_stacks != NULL) {
+ for (int i = 0; i < _stacks->length(); ++i) {
+ delete _stacks->at(i);
+ }
+ }
+}
+
+void ExceptionMessageBuilder::merge(int bci, SimulatedOperandStack* stack) {
+ assert(stack != _stacks->at(bci), "Cannot merge itself");
+
+ if (_stacks->at(bci) != NULL) {
+ stack->merge(*_stacks->at(bci));
+ } else {
+ // Got a new stack, so count the entries.
+ _nr_of_entries += stack->get_size();
+ }
+
+ // Replace the stack at this bci with a copy of our new merged stack.
+ delete _stacks->at(bci);
+ _stacks->at_put(bci, new SimulatedOperandStack(*stack));
+}
+
+int ExceptionMessageBuilder::do_instruction(int bci) {
+ ConstMethod* const_method = _method->constMethod();
+ address code_base = _method->constMethod()->code_base();
+
+ // We use the java code, since we don't want to cope with all the fast variants.
+ int len = Bytecodes::java_length_at(_method, code_base + bci);
+
+ // If we have no stack for this bci, we cannot process the bytecode now.
+ if (_stacks->at(bci) == NULL) {
+ _all_processed = false;
+ return len;
+ }
+
+ // Make a local copy of the stack for this bci to work on.
+ SimulatedOperandStack* stack = new SimulatedOperandStack(*_stacks->at(bci));
+
+ // dest_bci is != -1 if we branch.
+ int dest_bci = -1;
+
+ // This is for table and lookup switch.
+ static const int initial_length = 2;
+ GrowableArray<int> dests(initial_length);
+
+ bool flow_ended = false;
+
+ // Get the bytecode.
+ bool is_wide = false;
+ Bytecodes::Code raw_code = Bytecodes::code_at(_method, code_base + bci);
+ Bytecodes::Code code = Bytecodes::java_code_at(_method, code_base + bci);
+ int pos = bci + 1;
+
+ if (code == Bytecodes::_wide) {
+ is_wide = true;
+ code = Bytecodes::java_code_at(_method, code_base + bci + 1);
+ pos += 1;
+ }
+
+ // Now simulate the action of each bytecode.
+ switch (code) {
+ case Bytecodes::_nop:
+ case Bytecodes::_aconst_null:
+ case Bytecodes::_iconst_m1:
+ case Bytecodes::_iconst_0:
+ case Bytecodes::_iconst_1:
+ case Bytecodes::_iconst_2:
+ case Bytecodes::_iconst_3:
+ case Bytecodes::_iconst_4:
+ case Bytecodes::_iconst_5:
+ case Bytecodes::_lconst_0:
+ case Bytecodes::_lconst_1:
+ case Bytecodes::_fconst_0:
+ case Bytecodes::_fconst_1:
+ case Bytecodes::_fconst_2:
+ case Bytecodes::_dconst_0:
+ case Bytecodes::_dconst_1:
+ case Bytecodes::_bipush:
+ case Bytecodes::_sipush:
+ case Bytecodes::_iload:
+ case Bytecodes::_lload:
+ case Bytecodes::_fload:
+ case Bytecodes::_dload:
+ case Bytecodes::_aload:
+ case Bytecodes::_iload_0:
+ case Bytecodes::_iload_1:
+ case Bytecodes::_iload_2:
+ case Bytecodes::_iload_3:
+ case Bytecodes::_lload_0:
+ case Bytecodes::_lload_1:
+ case Bytecodes::_lload_2:
+ case Bytecodes::_lload_3:
+ case Bytecodes::_fload_0:
+ case Bytecodes::_fload_1:
+ case Bytecodes::_fload_2:
+ case Bytecodes::_fload_3:
+ case Bytecodes::_dload_0:
+ case Bytecodes::_dload_1:
+ case Bytecodes::_dload_2:
+ case Bytecodes::_dload_3:
+ case Bytecodes::_aload_0:
+ case Bytecodes::_aload_1:
+ case Bytecodes::_aload_2:
+ case Bytecodes::_aload_3:
+ case Bytecodes::_iinc:
+ case Bytecodes::_new:
+ stack->push(bci, Bytecodes::result_type(code));
+ break;
+
+ case Bytecodes::_ldc:
+ case Bytecodes::_ldc_w:
+ case Bytecodes::_ldc2_w: {
+ int cp_index;
+ ConstantPool* cp = _method->constants();
+
+ if (code == Bytecodes::_ldc) {
+ cp_index = *(uint8_t*) (code_base + pos);
+
+ if (raw_code == Bytecodes::_fast_aldc) {
+ cp_index = cp->object_to_cp_index(cp_index);
+ }
+ } else {
+ if (raw_code == Bytecodes::_fast_aldc_w) {
+ cp_index = Bytes::get_native_u2(code_base + pos);
+ cp_index = cp->object_to_cp_index(cp_index);
+ }
+ else {
+ cp_index = Bytes::get_Java_u2(code_base + pos);
+ }
+ }
+
+ constantTag tag = cp->tag_at(cp_index);
+ if (tag.is_klass() || tag.is_unresolved_klass() ||
+ tag.is_method() || tag.is_interface_method() ||
+ tag.is_field() || tag.is_string()) {
+ stack->push(bci, T_OBJECT);
+ } else if (tag.is_int()) {
+ stack->push(bci, T_INT);
+ } else if (tag.is_long()) {
+ stack->push(bci, T_LONG);
+ } else if (tag.is_float()) {
+ stack->push(bci, T_FLOAT);
+ } else if (tag.is_double()) {
+ stack->push(bci, T_DOUBLE);
+ } else {
+ assert(false, "Unexpected tag");
+ }
+ break;
+ }
+
+ case Bytecodes::_iaload:
+ case Bytecodes::_faload:
+ case Bytecodes::_aaload:
+ case Bytecodes::_baload:
+ case Bytecodes::_caload:
+ case Bytecodes::_saload:
+ case Bytecodes::_laload:
+ case Bytecodes::_daload:
+ stack->pop(2);
+ stack->push(bci, Bytecodes::result_type(code));
+ break;
+
+ case Bytecodes::_istore:
+ case Bytecodes::_lstore:
+ case Bytecodes::_fstore:
+ case Bytecodes::_dstore:
+ case Bytecodes::_astore:
+ int index;
+ if (is_wide) {
+ index = Bytes::get_Java_u2(code_base + bci + 2);
+ } else {
+ index = *(uint8_t*) (code_base + bci + 1);
+ }
+ stack->set_local_slot_written(index);
+ stack->pop(-Bytecodes::depth(code));
+ break;
+ case Bytecodes::_istore_0:
+ case Bytecodes::_lstore_0:
+ case Bytecodes::_fstore_0:
+ case Bytecodes::_dstore_0:
+ case Bytecodes::_astore_0:
+ stack->set_local_slot_written(0);
+ stack->pop(-Bytecodes::depth(code));
+ break;
+ case Bytecodes::_istore_1:
+ case Bytecodes::_fstore_1:
+ case Bytecodes::_lstore_1:
+ case Bytecodes::_dstore_1:
+ case Bytecodes::_astore_1:
+ stack->set_local_slot_written(1);
+ stack->pop(-Bytecodes::depth(code));
+ break;
+ case Bytecodes::_istore_2:
+ case Bytecodes::_lstore_2:
+ case Bytecodes::_fstore_2:
+ case Bytecodes::_dstore_2:
+ case Bytecodes::_astore_2:
+ stack->set_local_slot_written(2);
+ stack->pop(-Bytecodes::depth(code));
+ break;
+ case Bytecodes::_istore_3:
+ case Bytecodes::_lstore_3:
+ case Bytecodes::_fstore_3:
+ case Bytecodes::_dstore_3:
+ case Bytecodes::_astore_3:
+ stack->set_local_slot_written(3);
+ stack->pop(-Bytecodes::depth(code));
+ break;
+ case Bytecodes::_iastore:
+ case Bytecodes::_lastore:
+ case Bytecodes::_fastore:
+ case Bytecodes::_dastore:
+ case Bytecodes::_aastore:
+ case Bytecodes::_bastore:
+ case Bytecodes::_castore:
+ case Bytecodes::_sastore:
+ case Bytecodes::_pop:
+ case Bytecodes::_pop2:
+ case Bytecodes::_monitorenter:
+ case Bytecodes::_monitorexit:
+ case Bytecodes::_breakpoint:
+ stack->pop(-Bytecodes::depth(code));
+ break;
+
+ case Bytecodes::_dup:
+ stack->push_raw(stack->get_slot_data(0));
+ break;
+
+ case Bytecodes::_dup_x1: {
+ StackSlotAnalysisData top1 = stack->get_slot_data(0);
+ StackSlotAnalysisData top2 = stack->get_slot_data(1);
+ stack->pop(2);
+ stack->push_raw(top1);
+ stack->push_raw(top2);
+ stack->push_raw(top1);
+ break;
+ }
+
+ case Bytecodes::_dup_x2: {
+ StackSlotAnalysisData top1 = stack->get_slot_data(0);
+ StackSlotAnalysisData top2 = stack->get_slot_data(1);
+ StackSlotAnalysisData top3 = stack->get_slot_data(2);
+ stack->pop(3);
+ stack->push_raw(top1);
+ stack->push_raw(top3);
+ stack->push_raw(top2);
+ stack->push_raw(top1);
+ break;
+ }
+
+ case Bytecodes::_dup2:
+ stack->push_raw(stack->get_slot_data(1));
+ // The former '0' entry is now at '1'.
+ stack->push_raw(stack->get_slot_data(1));
+ break;
+
+ case Bytecodes::_dup2_x1: {
+ StackSlotAnalysisData top1 = stack->get_slot_data(0);
+ StackSlotAnalysisData top2 = stack->get_slot_data(1);
+ StackSlotAnalysisData top3 = stack->get_slot_data(2);
+ stack->pop(3);
+ stack->push_raw(top2);
+ stack->push_raw(top1);
+ stack->push_raw(top3);
+ stack->push_raw(top2);
+ stack->push_raw(top1);
+ break;
+ }
+
+ case Bytecodes::_dup2_x2: {
+ StackSlotAnalysisData top1 = stack->get_slot_data(0);
+ StackSlotAnalysisData top2 = stack->get_slot_data(1);
+ StackSlotAnalysisData top3 = stack->get_slot_data(2);
+ StackSlotAnalysisData top4 = stack->get_slot_data(3);
+ stack->pop(4);
+ stack->push_raw(top2);
+ stack->push_raw(top1);
+ stack->push_raw(top4);
+ stack->push_raw(top3);
+ stack->push_raw(top2);
+ stack->push_raw(top1);
+ break;
+ }
+
+ case Bytecodes::_swap: {
+ StackSlotAnalysisData top1 = stack->get_slot_data(0);
+ StackSlotAnalysisData top2 = stack->get_slot_data(1);
+ stack->pop(2);
+ stack->push(top1);
+ stack->push(top2);
+ break;
+ }
+
+ case Bytecodes::_iadd:
+ case Bytecodes::_ladd:
+ case Bytecodes::_fadd:
+ case Bytecodes::_dadd:
+ case Bytecodes::_isub:
+ case Bytecodes::_lsub:
+ case Bytecodes::_fsub:
+ case Bytecodes::_dsub:
+ case Bytecodes::_imul:
+ case Bytecodes::_lmul:
+ case Bytecodes::_fmul:
+ case Bytecodes::_dmul:
+ case Bytecodes::_idiv:
+ case Bytecodes::_ldiv:
+ case Bytecodes::_fdiv:
+ case Bytecodes::_ddiv:
+ case Bytecodes::_irem:
+ case Bytecodes::_lrem:
+ case Bytecodes::_frem:
+ case Bytecodes::_drem:
+ case Bytecodes::_iand:
+ case Bytecodes::_land:
+ case Bytecodes::_ior:
+ case Bytecodes::_lor:
+ case Bytecodes::_ixor:
+ case Bytecodes::_lxor:
+ stack->pop(2 * type2size[Bytecodes::result_type(code)]);
+ stack->push(bci, Bytecodes::result_type(code));
+ break;
+
+ case Bytecodes::_ineg:
+ case Bytecodes::_lneg:
+ case Bytecodes::_fneg:
+ case Bytecodes::_dneg:
+ stack->pop(type2size[Bytecodes::result_type(code)]);
+ stack->push(bci, Bytecodes::result_type(code));
+ break;
+
+ case Bytecodes::_ishl:
+ case Bytecodes::_lshl:
+ case Bytecodes::_ishr:
+ case Bytecodes::_lshr:
+ case Bytecodes::_iushr:
+ case Bytecodes::_lushr:
+ stack->pop(1 + type2size[Bytecodes::result_type(code)]);
+ stack->push(bci, Bytecodes::result_type(code));
+ break;
+
+ case Bytecodes::_i2l:
+ case Bytecodes::_i2f:
+ case Bytecodes::_i2d:
+ case Bytecodes::_f2i:
+ case Bytecodes::_f2l:
+ case Bytecodes::_f2d:
+ case Bytecodes::_i2b:
+ case Bytecodes::_i2c:
+ case Bytecodes::_i2s:
+ stack->pop(1);
+ stack->push(bci, Bytecodes::result_type(code));
+ break;
+
+ case Bytecodes::_l2i:
+ case Bytecodes::_l2f:
+ case Bytecodes::_l2d:
+ case Bytecodes::_d2i:
+ case Bytecodes::_d2l:
+ case Bytecodes::_d2f:
+ stack->pop(2);
+ stack->push(bci, Bytecodes::result_type(code));
+ break;
+
+ case Bytecodes::_lcmp:
+ case Bytecodes::_fcmpl:
+ case Bytecodes::_fcmpg:
+ case Bytecodes::_dcmpl:
+ case Bytecodes::_dcmpg:
+ stack->pop(1 - Bytecodes::depth(code));
+ stack->push(bci, T_INT);
+ break;
+
+ case Bytecodes::_ifeq:
+ case Bytecodes::_ifne:
+ case Bytecodes::_iflt:
+ case Bytecodes::_ifge:
+ case Bytecodes::_ifgt:
+ case Bytecodes::_ifle:
+ case Bytecodes::_if_icmpeq:
+ case Bytecodes::_if_icmpne:
+ case Bytecodes::_if_icmplt:
+ case Bytecodes::_if_icmpge:
+ case Bytecodes::_if_icmpgt:
+ case Bytecodes::_if_icmple:
+ case Bytecodes::_if_acmpeq:
+ case Bytecodes::_if_acmpne:
+ case Bytecodes::_ifnull:
+ case Bytecodes::_ifnonnull:
+ stack->pop(-Bytecodes::depth(code));
+ dest_bci = bci + (int16_t) Bytes::get_Java_u2(code_base + pos);
+ break;
+
+ case Bytecodes::_jsr:
+ // NOTE: Bytecodes has wrong depth for jsr.
+ stack->push(bci, T_ADDRESS);
+ dest_bci = bci + (int16_t) Bytes::get_Java_u2(code_base + pos);
+ flow_ended = true;
+ break;
+
+ case Bytecodes::_jsr_w: {
+ // NOTE: Bytecodes has wrong depth for jsr.
+ stack->push(bci, T_ADDRESS);
+ dest_bci = bci + (int32_t) Bytes::get_Java_u4(code_base + pos);
+ flow_ended = true;
+ break;
+ }
+
+ case Bytecodes::_ret:
+ // We don't track local variables, so we cannot know were we
+ // return. This makes the stacks imprecise, but we have to
+ // live with that.
+ flow_ended = true;
+ break;
+
+ case Bytecodes::_tableswitch: {
+ stack->pop(1);
+ pos = (pos + 3) & ~3;
+ dest_bci = bci + (int32_t) Bytes::get_Java_u4(code_base + pos);
+ int low = (int32_t) Bytes::get_Java_u4(code_base + pos + 4);
+ int high = (int32_t) Bytes::get_Java_u4(code_base + pos + 8);
+
+ for (int64_t i = low; i <= high; ++i) {
+ dests.push(bci + (int32_t) Bytes::get_Java_u4(code_base + pos + 12 + 4 * (i - low)));
+ }
+
+ break;
+ }
+
+ case Bytecodes::_lookupswitch: {
+ stack->pop(1);
+ pos = (pos + 3) & ~3;
+ dest_bci = bci + (int32_t) Bytes::get_Java_u4(code_base + pos);
+ int nr_of_dests = (int32_t) Bytes::get_Java_u4(code_base + pos + 4);
+
+ for (int i = 0; i < nr_of_dests; ++i) {
+ dests.push(bci + (int32_t) Bytes::get_Java_u4(code_base + pos + 12 + 8 * i));
+ }
+
+ break;
+ }
+
+ case Bytecodes::_ireturn:
+ case Bytecodes::_lreturn:
+ case Bytecodes::_freturn:
+ case Bytecodes::_dreturn:
+ case Bytecodes::_areturn:
+ case Bytecodes::_return:
+ case Bytecodes::_athrow:
+ stack->pop(-Bytecodes::depth(code));
+ flow_ended = true;
+ break;
+
+ case Bytecodes::_getstatic:
+ case Bytecodes::_getfield: {
+ // Find out the type of the field accessed.
+ int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
+ ConstantPool* cp = _method->constants();
+ int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
+ int type_index = cp->signature_ref_index_at(name_and_type_index);
+ Symbol* signature = cp->symbol_at(type_index);
+ // Simulate the bytecode: pop the address, push the 'value' loaded
+ // from the field.
+ stack->pop(1 - Bytecodes::depth(code));
+ stack->push(bci, char2type((char) signature->char_at(0)));
+ break;
+ }
+
+ case Bytecodes::_putstatic:
+ case Bytecodes::_putfield: {
+ int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
+ ConstantPool* cp = _method->constants();
+ int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
+ int type_index = cp->signature_ref_index_at(name_and_type_index);
+ Symbol* signature = cp->symbol_at(type_index);
+ ResultTypeFinder result_type(signature);
+ stack->pop(type2size[char2type((char) signature->char_at(0))] - Bytecodes::depth(code) - 1);
+ break;
+ }
+
+ case Bytecodes::_invokevirtual:
+ case Bytecodes::_invokespecial:
+ case Bytecodes::_invokestatic:
+ case Bytecodes::_invokeinterface:
+ case Bytecodes::_invokedynamic: {
+ ConstantPool* cp = _method->constants();
+ int cp_index;
+
+ if (code == Bytecodes::_invokedynamic) {
+ cp_index = ((int) Bytes::get_native_u4(code_base + pos));
+ } else {
+ cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
+ }
+
+ int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
+ int type_index = cp->signature_ref_index_at(name_and_type_index);
+ Symbol* signature = cp->symbol_at(type_index);
+
+ if ((code != Bytecodes::_invokestatic) && (code != Bytecodes::_invokedynamic)) {
+ // Pop receiver.
+ stack->pop(1);
+ }
+
+ stack->pop(ArgumentSizeComputer(signature).size());
+ ResultTypeFinder result_type(signature);
+ stack->push(bci, result_type.type());
+ break;
+ }
+
+ case Bytecodes::_newarray:
+ case Bytecodes::_anewarray:
+ case Bytecodes::_instanceof:
+ stack->pop(1);
+ stack->push(bci, Bytecodes::result_type(code));
+ break;
+
+ case Bytecodes::_arraylength:
+ // The return type of arraylength is wrong in the bytecodes table (T_VOID).
+ stack->pop(1);
+ stack->push(bci, T_INT);
+ break;
+
+ case Bytecodes::_checkcast:
+ break;
+
+ case Bytecodes::_multianewarray:
+ stack->pop(*(uint8_t*) (code_base + pos + 2));
+ stack->push(bci, T_OBJECT);
+ break;
+
+ case Bytecodes::_goto:
+ stack->pop(-Bytecodes::depth(code));
+ dest_bci = bci + (int16_t) Bytes::get_Java_u2(code_base + pos);
+ flow_ended = true;
+ break;
+
+
+ case Bytecodes::_goto_w:
+ stack->pop(-Bytecodes::depth(code));
+ dest_bci = bci + (int32_t) Bytes::get_Java_u4(code_base + pos);
+ flow_ended = true;
+ break;
+
+ default:
+ // Allow at least the bcis which have stack info to work.
+ _all_processed = false;
+ _added_one = false;
+ delete stack;
+
+ return len;
+ }
+
+ // Put new stack to the next instruction, if we might reach it from
+ // this bci.
+ if (!flow_ended) {
+ if (_stacks->at(bci + len) == NULL) {
+ _added_one = true;
+ }
+ merge(bci + len, stack);
+ }
+
+ // Put the stack to the branch target too.
+ if (dest_bci != -1) {
+ if (_stacks->at(dest_bci) == NULL) {
+ _added_one = true;
+ }
+ merge(dest_bci, stack);
+ }
+
+ // If we have more than one branch target, process these too.
+ for (int64_t i = 0; i < dests.length(); ++i) {
+ if (_stacks->at(dests.at(i)) == NULL) {
+ _added_one = true;
+ }
+ merge(dests.at(i), stack);
+ }
+
+ delete stack;
+
+ return len;
+}
+
+#define INVALID_BYTECODE_ENCOUNTERED -1
+#define NPE_EXPLICIT_CONSTRUCTED -2
+int ExceptionMessageBuilder::get_NPE_null_slot(int bci) {
+ // Get the bytecode.
+ address code_base = _method->constMethod()->code_base();
+ Bytecodes::Code code = Bytecodes::java_code_at(_method, code_base + bci);
+ int pos = bci + 1; // Position of argument of the bytecode.
+ if (code == Bytecodes::_wide) {
+ code = Bytecodes::java_code_at(_method, code_base + bci + 1);
+ pos += 1;
+ }
+
+ switch (code) {
+ case Bytecodes::_getfield:
+ case Bytecodes::_arraylength:
+ case Bytecodes::_athrow:
+ case Bytecodes::_monitorenter:
+ case Bytecodes::_monitorexit:
+ return 0;
+ case Bytecodes::_iaload:
+ case Bytecodes::_faload:
+ case Bytecodes::_aaload:
+ case Bytecodes::_baload:
+ case Bytecodes::_caload:
+ case Bytecodes::_saload:
+ case Bytecodes::_laload:
+ case Bytecodes::_daload:
+ return 1;
+ case Bytecodes::_iastore:
+ case Bytecodes::_fastore:
+ case Bytecodes::_aastore:
+ case Bytecodes::_bastore:
+ case Bytecodes::_castore:
+ case Bytecodes::_sastore:
+ return 2;
+ case Bytecodes::_lastore:
+ case Bytecodes::_dastore:
+ return 3;
+ case Bytecodes::_putfield: {
+ int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
+ ConstantPool* cp = _method->constants();
+ int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
+ int type_index = cp->signature_ref_index_at(name_and_type_index);
+ Symbol* signature = cp->symbol_at(type_index);
+ return type2size[char2type((char) signature->char_at(0))];
+ }
+ case Bytecodes::_invokevirtual:
+ case Bytecodes::_invokespecial:
+ case Bytecodes::_invokeinterface: {
+ int cp_index = Bytes::get_native_u2(code_base+ pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
+ ConstantPool* cp = _method->constants();
+ int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
+ int name_index = cp->name_ref_index_at(name_and_type_index);
+ Symbol* name = cp->symbol_at(name_index);
+
+ // Assume the the call of a constructor can never cause a NullPointerException
+ // (which is true in Java). This is mainly used to avoid generating wrong
+ // messages for NullPointerExceptions created explicitly by new in Java code.
+ if (name != vmSymbols::object_initializer_name()) {
+ int type_index = cp->signature_ref_index_at(name_and_type_index);
+ Symbol* signature = cp->symbol_at(type_index);
+ // The 'this' parameter was null. Return the slot of it.
+ return ArgumentSizeComputer(signature).size();
+ } else {
+ return NPE_EXPLICIT_CONSTRUCTED;
+ }
+ }
+
+ default:
+ break;
+ }
+
+ return INVALID_BYTECODE_ENCOUNTERED;
+}
+
+bool ExceptionMessageBuilder::print_NPE_cause(outputStream* os, int bci, int slot) {
+ if (print_NPE_cause0(os, bci, slot, _max_cause_detail, false, " because \"")) {
+ os->print("\" is null");
+ return true;
+ }
+ return false;
+}
+
+// Recursively print what was null.
+//
+// Go to the bytecode that pushed slot 'slot' on the operand stack
+// at bytecode 'bci'. Compute a message for that bytecode. If
+// necessary (array, field), recur further.
+// At most do max_detail recursions.
+// Prefix is used to print a proper beginning of the whole
+// sentence.
+// inner_expr is used to omit some text, like 'static' in
+// inner expressions like array subscripts.
+//
+// Returns true if something was printed.
+//
+bool ExceptionMessageBuilder::print_NPE_cause0(outputStream* os, int bci, int slot,
+ int max_detail,
+ bool inner_expr, const char *prefix) {
+ assert(bci >= 0, "BCI too low");
+ assert(bci < get_size(), "BCI too large");
+
+ if (max_detail <= 0) {
+ return false;
+ }
+
+ if (_stacks->at(bci) == NULL) {
+ return false;
+ }
+
+ SimulatedOperandStack* stack = _stacks->at(bci);
+ assert(slot >= 0, "Slot nr. too low");
+ assert(slot < stack->get_size(), "Slot nr. too large");
+
+ StackSlotAnalysisData slotData = stack->get_slot_data(slot);
+
+ if (!slotData.has_bci()) {
+ return false;
+ }
+
+ // Get the bytecode.
+ unsigned int source_bci = slotData.get_bci();
+ address code_base = _method->constMethod()->code_base();
+ Bytecodes::Code code = Bytecodes::java_code_at(_method, code_base + source_bci);
+ bool is_wide = false;
+ int pos = source_bci + 1;
+
+ if (code == Bytecodes::_wide) {
+ is_wide = true;
+ code = Bytecodes::java_code_at(_method, code_base + source_bci + 1);
+ pos += 1;
+ }
+
+ if (max_detail == _max_cause_detail &&
+ prefix != NULL &&
+ code != Bytecodes::_invokevirtual &&
+ code != Bytecodes::_invokespecial &&
+ code != Bytecodes::_invokestatic &&
+ code != Bytecodes::_invokeinterface) {
+ os->print("%s", prefix);
+ }
+
+ switch (code) {
+ case Bytecodes::_iload_0:
+ case Bytecodes::_aload_0:
+ print_local_var(os, source_bci, _method, 0, !stack->local_slot_was_written(0));
+ return true;
+
+ case Bytecodes::_iload_1:
+ case Bytecodes::_aload_1:
+ print_local_var(os, source_bci, _method, 1, !stack->local_slot_was_written(1));
+ return true;
+
+ case Bytecodes::_iload_2:
+ case Bytecodes::_aload_2:
+ print_local_var(os, source_bci, _method, 2, !stack->local_slot_was_written(2));
+ return true;
+
+ case Bytecodes::_iload_3:
+ case Bytecodes::_aload_3:
+ print_local_var(os, source_bci, _method, 3, !stack->local_slot_was_written(3));
+ return true;
+
+ case Bytecodes::_iload:
+ case Bytecodes::_aload: {
+ int index;
+ if (is_wide) {
+ index = Bytes::get_Java_u2(code_base + source_bci + 2);
+ } else {
+ index = *(uint8_t*) (code_base + source_bci + 1);
+ }
+ print_local_var(os, source_bci, _method, index, !stack->local_slot_was_written(index));
+ return true;
+ }
+
+ case Bytecodes::_aconst_null:
+ os->print("null");
+ return true;
+ case Bytecodes::_iconst_m1:
+ os->print("-1");
+ return true;
+ case Bytecodes::_iconst_0:
+ os->print("0");
+ return true;
+ case Bytecodes::_iconst_1:
+ os->print("1");
+ return true;
+ case Bytecodes::_iconst_2:
+ os->print("2");
+ return true;
+ case Bytecodes::_iconst_3:
+ os->print("3");
+ return true;
+ case Bytecodes::_iconst_4:
+ os->print("4");
+ return true;
+ case Bytecodes::_iconst_5:
+ os->print("5");
+ return true;
+ case Bytecodes::_bipush: {
+ jbyte con = *(jbyte*) (code_base + source_bci + 1);
+ os->print("%d", con);
+ return true;
+ }
+ case Bytecodes::_sipush: {
+ u2 con = Bytes::get_Java_u2(code_base + source_bci + 1);
+ os->print("%d", con);
+ return true;
+ }
+ case Bytecodes::_iaload:
+ case Bytecodes::_aaload: {
+ // Print the 'name' of the array. Go back to the bytecode that
+ // pushed the array reference on the operand stack.
+ if (!print_NPE_cause0(os, source_bci, 1, max_detail - 1, inner_expr)) {
+ // Returned false. Max recursion depth was reached. Print dummy.
+ os->print("<array>");
+ }
+ os->print("[");
+ // Print the index expression. Go back to the bytecode that
+ // pushed the index on the operand stack.
+ // inner_expr == true so we don't print unwanted strings
+ // as "The return value of'". And don't decrement max_detail so we always
+ // get a value here and only cancel out on the dereference.
+ if (!print_NPE_cause0(os, source_bci, 0, max_detail, true)) {
+ // Returned false. We don't print complex array index expressions. Print placeholder.
+ os->print("...");
+ }
+ os->print("]");
+ return true;
+ }
+
+ case Bytecodes::_getstatic: {
+ int cp_index = Bytes::get_native_u2(code_base + pos) + ConstantPool::CPCACHE_INDEX_TAG;
+ print_field_and_class(os, _method, cp_index);
+ return true;
+ }
+
+ case Bytecodes::_getfield: {
+ // Print the sender. Go back to the bytecode that
+ // pushed the sender on the operand stack.
+ if (print_NPE_cause0(os, source_bci, 0, max_detail - 1, inner_expr)) {
+ os->print(".");
+ }
+ int cp_index = Bytes::get_native_u2(code_base + pos) + ConstantPool::CPCACHE_INDEX_TAG;
+ os->print("%s", get_field_name(_method, cp_index));
+ return true;
+ }
+
+ case Bytecodes::_invokevirtual:
+ case Bytecodes::_invokespecial:
+ case Bytecodes::_invokestatic:
+ case Bytecodes::_invokeinterface: {
+ int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
+ if (max_detail == _max_cause_detail && !inner_expr) {
+ os->print(" because the return value of \"");
+ }
+ print_method_name(os, _method, cp_index);
+ return true;
+ }
+
+ default: break;
+ }
+ return false;
+}
+
+void ExceptionMessageBuilder::print_NPE_failed_action(outputStream *os, int bci) {
+
+ // Get the bytecode.
+ address code_base = _method->constMethod()->code_base();
+ Bytecodes::Code code = Bytecodes::java_code_at(_method, code_base + bci);
+ int pos = bci + 1;
+ if (code == Bytecodes::_wide) {
+ code = Bytecodes::java_code_at(_method, code_base + bci + 1);
+ pos += 1;
+ }
+
+ switch (code) {
+ case Bytecodes::_iaload:
+ os->print("Cannot load from int array"); break;
+ case Bytecodes::_faload:
+ os->print("Cannot load from float array"); break;
+ case Bytecodes::_aaload:
+ os->print("Cannot load from object array"); break;
+ case Bytecodes::_baload:
+ os->print("Cannot load from byte/boolean array"); break;
+ case Bytecodes::_caload:
+ os->print("Cannot load from char array"); break;
+ case Bytecodes::_saload:
+ os->print("Cannot load from short array"); break;
+ case Bytecodes::_laload:
+ os->print("Cannot load from long array"); break;
+ case Bytecodes::_daload:
+ os->print("Cannot load from double array"); break;
+
+ case Bytecodes::_iastore:
+ os->print("Cannot store to int array"); break;
+ case Bytecodes::_fastore:
+ os->print("Cannot store to float array"); break;
+ case Bytecodes::_aastore:
+ os->print("Cannot store to object array"); break;
+ case Bytecodes::_bastore:
+ os->print("Cannot store to byte/boolean array"); break;
+ case Bytecodes::_castore:
+ os->print("Cannot store to char array"); break;
+ case Bytecodes::_sastore:
+ os->print("Cannot store to short array"); break;
+ case Bytecodes::_lastore:
+ os->print("Cannot store to long array"); break;
+ case Bytecodes::_dastore:
+ os->print("Cannot store to double array"); break;
+
+ case Bytecodes::_arraylength:
+ os->print("Cannot read the array length"); break;
+ case Bytecodes::_athrow:
+ os->print("Cannot throw exception"); break;
+ case Bytecodes::_monitorenter:
+ os->print("Cannot enter synchronized block"); break;
+ case Bytecodes::_monitorexit:
+ os->print("Cannot exit synchronized block"); break;
+ case Bytecodes::_getfield: {
+ int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
+ ConstantPool* cp = _method->constants();
+ int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
+ int name_index = cp->name_ref_index_at(name_and_type_index);
+ Symbol* name = cp->symbol_at(name_index);
+ os->print("Cannot read field \"%s\"", name->as_C_string());
+ } break;
+ case Bytecodes::_putfield: {
+ int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
+ os->print("Cannot assign field \"%s\"", get_field_name(_method, cp_index));
+ } break;
+ case Bytecodes::_invokevirtual:
+ case Bytecodes::_invokespecial:
+ case Bytecodes::_invokeinterface: {
+ int cp_index = Bytes::get_native_u2(code_base+ pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
+ os->print("Cannot invoke \"");
+ print_method_name(os, _method, cp_index);
+ os->print("\"");
+ } break;
+
+ default:
+ assert(0, "We should have checked this bytecode in get_NPE_null_slot().");
+ break;
+ }
+}
+
+// Main API
+bool BytecodeUtils::get_NPE_message_at(outputStream* ss, Method* method, int bci) {
+
+ NoSafepointVerifier _nsv; // Cannot use this object over a safepoint.
+
+ // If this NPE was created via reflection, we have no real NPE.
+ if (method->method_holder() ==
+ SystemDictionary::reflect_NativeConstructorAccessorImpl_klass()) {
+ return false;
+ }
+
+ // Analyse the bytecodes.
+ ResourceMark rm;
+ ExceptionMessageBuilder emb(method, bci);
+
+ // The slot of the operand stack that contains the null reference.
+ // Also checks for NPE explicitly constructed and returns NPE_EXPLICIT_CONSTRUCTED.
+ int slot = emb.get_NPE_null_slot(bci);
+
+ // Build the message.
+ if (slot == NPE_EXPLICIT_CONSTRUCTED) {
+ // We don't want to print a message.
+ return false;
+ } else if (slot == INVALID_BYTECODE_ENCOUNTERED) {
+ // We encountered a bytecode that does not dereference a reference.
+ DEBUG_ONLY(ss->print("There cannot be a NullPointerException at bci %d of method %s",
+ bci, method->external_name()));
+ NOT_DEBUG(return false);
+ } else {
+ // Print string describing which action (bytecode) could not be
+ // performed because of the null reference.
+ emb.print_NPE_failed_action(ss, bci);
+ // Print a description of what is null.
+ if (!emb.print_NPE_cause(ss, bci, slot)) {
+ // Nothing was printed. End the sentence without the 'because'
+ // subordinate sentence.
+ }
+ }
+ return true;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/interpreter/bytecodeUtils.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019 SAP SE. 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.
+ *
+ * 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.
+ *
+ */
+
+#ifndef SHARE_INTERPRETER_BYTECODEUTILS_HPP
+#define SHARE_INTERPRETER_BYTECODEUTILS_HPP
+
+#include "memory/allocation.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+class Method;
+class outputStream;
+
+class BytecodeUtils : public AllStatic {
+ public:
+ // NPE extended message. Return true if string is printed.
+ static bool get_NPE_message_at(outputStream* ss, Method* method, int bci);
+};
+
+#endif // SHARE_INTERPRETER_BYTECODEUTILS_HPP
--- a/src/hotspot/share/interpreter/interpreterRuntime.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1249,15 +1249,15 @@
char sig_type = '\0';
switch(cp_entry->flag_state()) {
- case btos: sig_type = 'B'; break;
- case ztos: sig_type = 'Z'; break;
- case ctos: sig_type = 'C'; break;
- case stos: sig_type = 'S'; break;
- case itos: sig_type = 'I'; break;
- case ftos: sig_type = 'F'; break;
- case atos: sig_type = 'L'; break;
- case ltos: sig_type = 'J'; break;
- case dtos: sig_type = 'D'; break;
+ case btos: sig_type = JVM_SIGNATURE_BYTE; break;
+ case ztos: sig_type = JVM_SIGNATURE_BOOLEAN; break;
+ case ctos: sig_type = JVM_SIGNATURE_CHAR; break;
+ case stos: sig_type = JVM_SIGNATURE_SHORT; break;
+ case itos: sig_type = JVM_SIGNATURE_INT; break;
+ case ftos: sig_type = JVM_SIGNATURE_FLOAT; break;
+ case atos: sig_type = JVM_SIGNATURE_CLASS; break;
+ case ltos: sig_type = JVM_SIGNATURE_LONG; break;
+ case dtos: sig_type = JVM_SIGNATURE_DOUBLE; break;
default: ShouldNotReachHere(); return;
}
bool is_static = (obj == NULL);
--- a/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1497,35 +1497,6 @@
ik = new_ik;
}
-// During retransform/redefine, copy the Method specific trace flags
-// from the previous ik ("the original klass") to the new ik ("the scratch_klass").
-// The open code for retransform/redefine does not know about these.
-// In doing this migration here, we ensure the new Methods (defined in scratch klass)
-// will carry over trace tags from the old Methods being replaced,
-// ensuring flag/tag continuity while being transparent to open code.
-static void copy_method_trace_flags(const InstanceKlass* the_original_klass, const InstanceKlass* the_scratch_klass) {
- assert(the_original_klass != NULL, "invariant");
- assert(the_scratch_klass != NULL, "invariant");
- assert(the_original_klass->name() == the_scratch_klass->name(), "invariant");
- const Array<Method*>* old_methods = the_original_klass->methods();
- const Array<Method*>* new_methods = the_scratch_klass->methods();
- const bool equal_array_length = old_methods->length() == new_methods->length();
- // The Method array has the property of being sorted.
- // If they are the same length, there is a one-to-one mapping.
- // If they are unequal, there was a method added (currently only
- // private static methods allowed to be added), use lookup.
- for (int i = 0; i < old_methods->length(); ++i) {
- const Method* const old_method = old_methods->at(i);
- Method* const new_method = equal_array_length ? new_methods->at(i) :
- the_scratch_klass->find_method(old_method->name(), old_method->signature());
- assert(new_method != NULL, "invariant");
- assert(new_method->name() == old_method->name(), "invariant");
- assert(new_method->signature() == old_method->signature(), "invariant");
- new_method->set_trace_flags(old_method->trace_flags());
- assert(new_method->trace_flags() == old_method->trace_flags(), "invariant");
- }
-}
-
static bool is_retransforming(const InstanceKlass* ik, TRAPS) {
assert(ik != NULL, "invariant");
assert(JdkJfrEvent::is_a(ik), "invariant");
@@ -1533,16 +1504,7 @@
assert(name != NULL, "invariant");
Handle class_loader(THREAD, ik->class_loader());
Handle protection_domain(THREAD, ik->protection_domain());
- // nota bene: use lock-free dictionary lookup
- const InstanceKlass* prev_ik = (const InstanceKlass*)SystemDictionary::find(name, class_loader, protection_domain, THREAD);
- if (prev_ik == NULL) {
- return false;
- }
- // an existing ik implies a retransform/redefine
- assert(prev_ik != NULL, "invariant");
- assert(JdkJfrEvent::is_a(prev_ik), "invariant");
- copy_method_trace_flags(prev_ik, ik);
- return true;
+ return SystemDictionary::find(name, class_loader, protection_domain, THREAD) != NULL;
}
// target for JFR_ON_KLASS_CREATION hook
@@ -1571,12 +1533,8 @@
return;
}
assert(JdkJfrEvent::is_subklass(ik), "invariant");
- if (is_retransforming(ik, THREAD)) {
- // not the initial klass load
- return;
- }
- if (ik->is_abstract()) {
- // abstract classes are not instrumented
+ if (ik->is_abstract() || is_retransforming(ik, THREAD)) {
+ // abstract and scratch classes are not instrumented
return;
}
ResourceMark rm(THREAD);
--- a/src/hotspot/share/jfr/jfr.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/jfr.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -48,14 +48,14 @@
static void on_unloading_classes();
static void on_thread_start(Thread* thread);
static void on_thread_exit(Thread* thread);
- static void exclude_thread(Thread* thread);
- static bool is_excluded(Thread* thread);
- static void include_thread(Thread* thread);
static void on_java_thread_dismantle(JavaThread* jt);
static void on_vm_shutdown(bool exception_handler = false);
static bool on_flight_recorder_option(const JavaVMOption** option, char* delimiter);
static bool on_start_flight_recording_option(const JavaVMOption** option, char* delimiter);
static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f);
+ static void exclude_thread(Thread* thread);
+ static bool is_excluded(Thread* thread);
+ static void include_thread(Thread* thread);
};
#endif // SHARE_JFR_JFR_HPP
--- a/src/hotspot/share/jfr/leakprofiler/checkpoint/eventEmitter.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/eventEmitter.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -34,6 +34,7 @@
#include "memory/resourceArea.hpp"
#include "oops/markWord.hpp"
#include "oops/oop.inline.hpp"
+#include "runtime/mutexLocker.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/vmThread.hpp"
@@ -51,8 +52,8 @@
}
void EventEmitter::emit(ObjectSampler* sampler, int64_t cutoff_ticks, bool emit_all) {
+ assert(JfrStream_lock->owned_by_self(), "invariant");
assert(sampler != NULL, "invariant");
-
ResourceMark rm;
EdgeStore edge_store;
if (cutoff_ticks <= 0) {
@@ -68,6 +69,7 @@
}
size_t EventEmitter::write_events(ObjectSampler* object_sampler, EdgeStore* edge_store, bool emit_all) {
+ assert_locked_or_safepoint(JfrStream_lock);
assert(_thread == Thread::current(), "invariant");
assert(_thread->jfr_thread_local() == _jfr_thread_local, "invariant");
assert(object_sampler != NULL, "invariant");
--- a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -37,6 +37,7 @@
#include "jfr/recorder/stacktrace/jfrStackTraceRepository.hpp"
#include "jfr/utilities/jfrHashtable.hpp"
#include "jfr/utilities/jfrTypes.hpp"
+#include "runtime/mutexLocker.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/thread.hpp"
#include "utilities/growableArray.hpp"
@@ -291,6 +292,7 @@
// caller needs ResourceMark
void ObjectSampleCheckpoint::on_rotation(const ObjectSampler* sampler, JfrStackTraceRepository& stack_trace_repo) {
+ assert(JfrStream_lock->owned_by_self(), "invariant");
assert(sampler != NULL, "invariant");
assert(LeakProfiler::is_running(), "invariant");
install_stack_traces(sampler, stack_trace_repo);
@@ -397,6 +399,7 @@
}
void ObjectSampleCheckpoint::write(const ObjectSampler* sampler, EdgeStore* edge_store, bool emit_all, Thread* thread) {
+ assert_locked_or_safepoint(JfrStream_lock);
assert(sampler != NULL, "invariant");
assert(edge_store != NULL, "invariant");
assert(thread != NULL, "invariant");
--- a/src/hotspot/share/jfr/leakprofiler/leakProfiler.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/leakprofiler/leakProfiler.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -31,6 +31,7 @@
#include "jfr/recorder/service/jfrOptionSet.hpp"
#include "logging/log.hpp"
#include "memory/iterator.hpp"
+#include "runtime/mutexLocker.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/vmThread.hpp"
@@ -92,6 +93,7 @@
if (!is_running()) {
return;
}
+ MutexLocker lock(JfrStream_lock);
// exclusive access to object sampler instance
ObjectSampler* const sampler = ObjectSampler::acquire();
assert(sampler != NULL, "invariant");
--- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -24,15 +24,18 @@
#include "precompiled.hpp"
#include "classfile/javaClasses.inline.hpp"
-#include "jfr/recorder/jfrRecorder.hpp"
+#include "jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp"
+#include "jfr/leakprofiler/leakProfiler.hpp"
#include "jfr/recorder/checkpoint/jfrCheckpointManager.hpp"
#include "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp"
#include "jfr/recorder/checkpoint/types/jfrTypeManager.hpp"
+#include "jfr/recorder/checkpoint/types/jfrTypeSet.hpp"
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp"
+#include "jfr/recorder/jfrRecorder.hpp"
+#include "jfr/recorder/repository/jfrChunkWriter.hpp"
#include "jfr/recorder/service/jfrOptionSet.hpp"
#include "jfr/recorder/storage/jfrMemorySpace.inline.hpp"
#include "jfr/recorder/storage/jfrStorageUtils.inline.hpp"
-#include "jfr/recorder/repository/jfrChunkWriter.hpp"
#include "jfr/utilities/jfrBigEndian.hpp"
#include "jfr/utilities/jfrIterator.hpp"
#include "jfr/utilities/jfrThreadIterator.hpp"
@@ -357,7 +360,7 @@
typedef DiscardOp<DefaultDiscarder<JfrBuffer> > DiscardOperation;
size_t JfrCheckpointManager::clear() {
- JfrTypeManager::clear();
+ JfrTypeSet::clear();
DiscardOperation discarder(mutexed); // mutexed discard mode
process_free_list(discarder, _free_list_mspace);
process_free_list(discarder, _epoch_transition_mspace);
@@ -408,7 +411,7 @@
void JfrCheckpointManager::shift_epoch() {
debug_only(const u1 current_epoch = JfrTraceIdEpoch::current();)
- JfrTraceIdEpoch::shift_epoch();
+ JfrTraceIdEpoch::shift_epoch();
assert(current_epoch != JfrTraceIdEpoch::current(), "invariant");
}
@@ -416,16 +419,41 @@
assert(SafepointSynchronize::is_at_safepoint(), "invariant");
JfrTypeManager::on_rotation();
notify_threads();
- shift_epoch();
}
void JfrCheckpointManager::write_type_set() {
- JfrTypeManager::write_type_set();
+ assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
+ if (LeakProfiler::is_running()) {
+ Thread* const t = Thread::current();
+ // can safepoint here
+ MutexLocker cld_lock(ClassLoaderDataGraph_lock);
+ MutexLocker module_lock(Module_lock);
+ JfrCheckpointWriter leakp_writer(t);
+ JfrCheckpointWriter writer(t);
+ JfrTypeSet::serialize(&writer, &leakp_writer, false, false);
+ ObjectSampleCheckpoint::on_type_set(leakp_writer);
+ } else {
+ // can safepoint here
+ MutexLocker cld_lock(ClassLoaderDataGraph_lock);
+ MutexLocker module_lock(Module_lock);
+ JfrCheckpointWriter writer(Thread::current());
+ JfrTypeSet::serialize(&writer, NULL, false, false);
+ }
write();
}
void JfrCheckpointManager::write_type_set_for_unloaded_classes() {
- JfrTypeManager::write_type_set_for_unloaded_classes();
+ assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
+ JfrCheckpointWriter writer(Thread::current());
+ const JfrCheckpointContext ctx = writer.context();
+ JfrTypeSet::serialize(&writer, NULL, true, false);
+ if (LeakProfiler::is_running()) {
+ ObjectSampleCheckpoint::on_type_set_unload(writer);
+ }
+ if (!JfrRecorder::is_recording()) {
+ // discard by rewind
+ writer.set_context(ctx);
+ }
}
bool JfrCheckpointManager::is_type_set_required() {
@@ -433,7 +461,15 @@
}
size_t JfrCheckpointManager::flush_type_set() {
- const size_t elements = JfrTypeManager::flush_type_set();
+ assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
+ size_t elements = 0;
+ {
+ JfrCheckpointWriter writer(Thread::current());
+ // can safepoint here
+ MutexLocker cld_lock(ClassLoaderDataGraph_lock);
+ MutexLocker module_lock(Module_lock);
+ elements = JfrTypeSet::serialize(&writer, NULL, false, true);
+ }
flush();
return elements;
}
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -31,12 +31,13 @@
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcWhen.hpp"
#include "jfr/leakprofiler/leakProfiler.hpp"
-#include "jfr/recorder/checkpoint/jfrCheckpointManager.hpp"
+#include "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp"
#include "jfr/recorder/checkpoint/types/jfrType.hpp"
#include "jfr/recorder/jfrRecorder.hpp"
#include "jfr/recorder/checkpoint/types/jfrThreadGroup.hpp"
#include "jfr/recorder/checkpoint/types/jfrThreadState.hpp"
-#include "jfr/recorder/checkpoint/types/jfrTypeSet.hpp"
+#include "jfr/support/jfrThreadLocal.hpp"
+#include "jfr/writers/jfrJavaEventWriter.hpp"
#include "jfr/utilities/jfrThreadIterator.hpp"
#include "memory/metaspaceGCThresholdUpdater.hpp"
#include "memory/referenceType.hpp"
@@ -266,55 +267,6 @@
}
}
-class TypeSetSerialization {
- private:
- JfrCheckpointWriter* _leakp_writer;
- size_t _elements;
- public:
- TypeSetSerialization(JfrCheckpointWriter* leakp_writer = NULL) :
- _leakp_writer(leakp_writer), _elements(0) {}
- void write(JfrCheckpointWriter& writer, bool class_unload, bool flushpoint) {
- assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
- assert_locked_or_safepoint(Module_lock);
- _elements = JfrTypeSet::serialize(&writer, _leakp_writer, class_unload, flushpoint);
- }
- size_t elements() const {
- return _elements;
- }
-};
-
-void ClassUnloadTypeSet::serialize(JfrCheckpointWriter& writer) {
- TypeSetSerialization type_set;
- type_set.write(writer, true, false);
-};
-
-void FlushTypeSet::serialize(JfrCheckpointWriter& writer) {
- assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
- MutexLocker cld_lock(ClassLoaderDataGraph_lock);
- MutexLocker module_lock(Module_lock);
- TypeSetSerialization type_set;
- type_set.write(writer, false, true);
- _elements = type_set.elements();
-}
-
-size_t FlushTypeSet::elements() const {
- return _elements;
-}
-
-TypeSet::TypeSet(JfrCheckpointWriter* leakp_writer) : _leakp_writer(leakp_writer) {}
-
-void TypeSet::clear() {
- JfrTypeSet::clear();
-}
-
-void TypeSet::serialize(JfrCheckpointWriter& writer) {
- assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
- MutexLocker cld_lock(ClassLoaderDataGraph_lock);
- MutexLocker module_lock(Module_lock);
- TypeSetSerialization type_set(_leakp_writer);
- type_set.write(writer, false, false);
-};
-
void ThreadStateConstant::serialize(JfrCheckpointWriter& writer) {
JfrThreadState::serialize(writer);
}
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -27,27 +27,6 @@
#include "jfr/metadata/jfrSerializer.hpp"
-class TypeSet : public JfrSerializer {
- private:
- JfrCheckpointWriter* _leakp_writer;
- public:
- explicit TypeSet(JfrCheckpointWriter* leakp_writer = NULL);
- void serialize(JfrCheckpointWriter& writer);
- void clear();
-};
-
-class ClassUnloadTypeSet : public JfrSerializer {
- public:
- void serialize(JfrCheckpointWriter& writer);
-};
-
-class FlushTypeSet : public JfrSerializer {
- size_t _elements;
- public:
- void serialize(JfrCheckpointWriter& writer);
- size_t elements() const;
-};
-
class FlagValueOriginConstant : public JfrSerializer {
public:
void serialize(JfrCheckpointWriter& writer);
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -23,20 +23,19 @@
*/
#include "precompiled.hpp"
-#include "jfr/jfr.hpp"
-#include "jfr/leakprofiler/leakProfiler.hpp"
-#include "jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp"
#include "jfr/metadata/jfrSerializer.hpp"
#include "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp"
#include "jfr/recorder/checkpoint/types/jfrType.hpp"
#include "jfr/recorder/checkpoint/types/jfrTypeManager.hpp"
+#include "jfr/recorder/jfrRecorder.hpp"
#include "jfr/utilities/jfrDoublyLinkedList.hpp"
#include "jfr/utilities/jfrIterator.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/handles.inline.hpp"
+#include "runtime/safepoint.hpp"
+#include "runtime/semaphore.hpp"
#include "runtime/thread.inline.hpp"
#include "utilities/exceptions.hpp"
-#include "runtime/semaphore.hpp"
class JfrSerializerRegistration : public JfrCHeapObj {
private:
@@ -142,41 +141,6 @@
type_thread.serialize(writer);
}
-size_t JfrTypeManager::flush_type_set() {
- JfrCheckpointWriter writer;
- FlushTypeSet flush;
- flush.serialize(writer);
- return flush.elements();
-}
-
-void JfrTypeManager::write_type_set() {
- if (!LeakProfiler::is_running()) {
- JfrCheckpointWriter writer;
- TypeSet set;
- set.serialize(writer);
- return;
- }
- JfrCheckpointWriter leakp_writer;
- JfrCheckpointWriter writer;
- TypeSet set(&leakp_writer);
- set.serialize(writer);
- ObjectSampleCheckpoint::on_type_set(leakp_writer);
-}
-
-void JfrTypeManager::write_type_set_for_unloaded_classes() {
- JfrCheckpointWriter writer;
- const JfrCheckpointContext ctx = writer.context();
- ClassUnloadTypeSet class_unload_set;
- class_unload_set.serialize(writer);
- if (LeakProfiler::is_running()) {
- ObjectSampleCheckpoint::on_type_set_unload(writer);
- }
- if (!Jfr::is_recording()) {
- // discard anything written
- writer.set_context(ctx);
- }
-}
-
class SerializerRegistrationGuard : public StackObj {
private:
static Semaphore _mutex_semaphore;
@@ -206,11 +170,6 @@
}
}
-void JfrTypeManager::clear() {
- TypeSet type_set;
- type_set.clear();
-}
-
void JfrTypeManager::on_rotation() {
const Iterator iter(types);
while (iter.has_next()) {
@@ -238,7 +197,7 @@
}
assert(!types.in_list(registration), "invariant");
DEBUG_ONLY(assert_not_registered_twice(id, types);)
- if (Jfr::is_recording()) {
+ if (JfrRecorder::is_recording()) {
JfrCheckpointWriter writer(STATICS);
registration->invoke(writer);
new_registration = true;
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -33,16 +33,12 @@
public:
static bool initialize();
static void destroy();
- static void clear();
static void on_rotation();
static void write_threads(JfrCheckpointWriter& writer);
static void create_thread_blob(Thread* t);
static void write_thread_checkpoint(Thread* t);
static bool has_new_static_type();
static void write_static_types(JfrCheckpointWriter& writer);
- static size_t flush_type_set();
- static void write_type_set();
- static void write_type_set_for_unloaded_classes();
};
#endif // SHARE_JFR_RECORDER_CHECKPOINT_TYPES_JFRTYPEMANAGER_HPP
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -43,6 +43,7 @@
#include "oops/objArrayKlass.hpp"
#include "oops/oop.inline.hpp"
#include "utilities/accessFlags.hpp"
+#include "utilities/bitMap.inline.hpp"
typedef const Klass* KlassPtr;
typedef const PackageEntry* PkgPtr;
@@ -117,7 +118,7 @@
static traceid module_id(PkgPtr pkg, bool leakp) {
assert(pkg != NULL, "invariant");
ModPtr module_entry = pkg->module();
- if (module_entry == NULL || !module_entry->is_named()) {
+ if (module_entry == NULL) {
return 0;
}
if (leakp) {
@@ -136,9 +137,7 @@
static traceid cld_id(CldPtr cld, bool leakp) {
assert(cld != NULL, "invariant");
- if (cld->is_unsafe_anonymous()) {
- return 0;
- }
+ assert(!cld->is_unsafe_anonymous(), "invariant");
if (leakp) {
SET_LEAKP(cld);
} else {
@@ -153,6 +152,17 @@
return ptr->access_flags().get_flags();
}
+static bool is_unsafe_anonymous(const Klass* klass) {
+ assert(klass != NULL, "invariant");
+ return klass->is_instance_klass() && ((const InstanceKlass*)klass)->is_unsafe_anonymous();
+}
+
+static ClassLoaderData* get_cld(const Klass* klass) {
+ assert(klass != NULL, "invariant");
+ return is_unsafe_anonymous(klass) ?
+ InstanceKlass::cast(klass)->unsafe_anonymous_host()->class_loader_data() : klass->class_loader_data();
+}
+
template <typename T>
static void set_serialized(const T* ptr) {
assert(ptr != NULL, "invariant");
@@ -184,7 +194,7 @@
assert(theklass->is_typeArray_klass(), "invariant");
}
writer->write(artifact_id(klass));
- writer->write(cld_id(klass->class_loader_data(), leakp));
+ writer->write(cld_id(get_cld(klass), leakp));
writer->write(mark_symbol(klass, leakp));
writer->write(pkg_id);
writer->write(get_flags(klass));
@@ -538,13 +548,22 @@
do_previous_epoch_artifact(_subsystem_callback, cld);
}
-class CldFieldSelector {
+class KlassCldFieldSelector {
public:
typedef CldPtr TypePtr;
static TypePtr select(KlassPtr klass) {
assert(klass != NULL, "invariant");
- CldPtr cld = klass->class_loader_data();
- return cld->is_unsafe_anonymous() ? NULL : cld;
+ return get_cld(klass);
+ }
+};
+
+class ModuleCldFieldSelector {
+public:
+ typedef CldPtr TypePtr;
+ static TypePtr select(KlassPtr klass) {
+ assert(klass != NULL, "invariant");
+ ModPtr mod = ModuleFieldSelector::select(klass);
+ return mod != NULL ? mod->loader_data() : NULL;
}
};
@@ -570,14 +589,18 @@
typedef JfrTypeWriterHost<CldWriterImpl, TYPE_CLASSLOADER> CldWriter;
typedef CompositeFunctor<CldPtr, CldWriter, ClearArtifact<CldPtr> > CldWriterWithClear;
typedef JfrArtifactCallbackHost<CldPtr, CldWriterWithClear> CldCallback;
-typedef KlassToFieldEnvelope<CldFieldSelector, CldWriter> KlassCldWriter;
+typedef KlassToFieldEnvelope<KlassCldFieldSelector, CldWriter> KlassCldWriter;
+typedef KlassToFieldEnvelope<ModuleCldFieldSelector, CldWriter> ModuleCldWriter;
+typedef CompositeFunctor<KlassPtr, KlassCldWriter, ModuleCldWriter> KlassAndModuleCldWriter;
typedef LeakPredicate<CldPtr> LeakCldPredicate;
typedef JfrPredicatedTypeWriterImplHost<CldPtr, LeakCldPredicate, write__classloader__leakp> LeakCldWriterImpl;
typedef JfrTypeWriterHost<LeakCldWriterImpl, TYPE_CLASSLOADER> LeakCldWriter;
typedef CompositeFunctor<CldPtr, LeakCldWriter, CldWriter> CompositeCldWriter;
-typedef KlassToFieldEnvelope<CldFieldSelector, CompositeCldWriter> KlassCompositeCldWriter;
+typedef KlassToFieldEnvelope<KlassCldFieldSelector, CompositeCldWriter> KlassCompositeCldWriter;
+typedef KlassToFieldEnvelope<ModuleCldFieldSelector, CompositeCldWriter> ModuleCompositeCldWriter;
+typedef CompositeFunctor<KlassPtr, KlassCompositeCldWriter, ModuleCompositeCldWriter> KlassAndModuleCompositeCldWriter;
typedef CompositeFunctor<CldPtr, CompositeCldWriter, ClearArtifact<CldPtr> > CompositeCldWriterWithClear;
typedef JfrArtifactCallbackHost<CldPtr, CompositeCldWriterWithClear> CompositeCldCallback;
@@ -585,14 +608,16 @@
assert(_writer != NULL, "invariant");
CldWriter cldw(_writer, _class_unload);
KlassCldWriter kcw(&cldw);
+ ModuleCldWriter mcw(&cldw);
+ KlassAndModuleCldWriter kmcw(&kcw, &mcw);
if (current_epoch()) {
- _artifacts->iterate_klasses(kcw);
+ _artifacts->iterate_klasses(kmcw);
_artifacts->tally(cldw);
return;
}
assert(previous_epoch(), "invariant");
if (_leakp_writer == NULL) {
- _artifacts->iterate_klasses(kcw);
+ _artifacts->iterate_klasses(kmcw);
ClearArtifact<CldPtr> clear;
CldWriterWithClear cldwwc(&cldw, &clear);
CldCallback callback(&cldwwc);
@@ -602,7 +627,9 @@
LeakCldWriter lcldw(_leakp_writer, _class_unload);
CompositeCldWriter ccldw(&lcldw, &cldw);
KlassCompositeCldWriter kccldw(&ccldw);
- _artifacts->iterate_klasses(kccldw);
+ ModuleCompositeCldWriter mccldw(&ccldw);
+ KlassAndModuleCompositeCldWriter kmccldw(&kccldw, &mccldw);
+ _artifacts->iterate_klasses(kmccldw);
ClearArtifact<CldPtr> clear;
CompositeCldWriterWithClear ccldwwc(&ccldw, &clear);
CompositeCldCallback callback(&ccldwwc);
@@ -652,7 +679,31 @@
return write_method(writer, method, true);
}
-template <typename MethodCallback, typename KlassCallback, bool leakp>
+class BitMapFilter {
+ ResourceBitMap _bitmap;
+ public:
+ explicit BitMapFilter(int length = 0) : _bitmap((size_t)length) {}
+ bool operator()(size_t idx) {
+ if (_bitmap.size() == 0) {
+ return true;
+ }
+ if (_bitmap.at(idx)) {
+ return false;
+ }
+ _bitmap.set_bit(idx);
+ return true;
+ }
+};
+
+class AlwaysTrue {
+ public:
+ explicit AlwaysTrue(int length = 0) {}
+ bool operator()(size_t idx) {
+ return true;
+ }
+};
+
+template <typename MethodCallback, typename KlassCallback, class Filter, bool leakp>
class MethodIteratorHost {
private:
MethodCallback _method_cb;
@@ -671,13 +722,19 @@
bool operator()(KlassPtr klass) {
if (_method_used_predicate(klass)) {
- const InstanceKlass* const ik = InstanceKlass::cast(klass);
+ const InstanceKlass* ik = InstanceKlass::cast(klass);
const int len = ik->methods()->length();
- for (int i = 0; i < len; ++i) {
- MethodPtr method = ik->methods()->at(i);
- if (_method_flag_predicate(method)) {
- _method_cb(method);
+ Filter filter(ik->previous_versions() != NULL ? len : 0);
+ while (ik != NULL) {
+ for (int i = 0; i < len; ++i) {
+ MethodPtr method = ik->methods()->at(i);
+ if (_method_flag_predicate(method) && filter(i)) {
+ _method_cb(method);
+ }
}
+ // There can be multiple versions of the same method running
+ // due to redefinition. Need to inspect the complete set of methods.
+ ik = ik->previous_versions();
}
}
return _klass_cb(klass);
@@ -701,12 +758,12 @@
typedef JfrPredicatedTypeWriterImplHost<MethodPtr, MethodPredicate, write__method> MethodWriterImplTarget;
typedef Wrapper<KlassPtr, Stub> KlassCallbackStub;
typedef JfrTypeWriterHost<MethodWriterImplTarget, TYPE_METHOD> MethodWriterImpl;
-typedef MethodIteratorHost<MethodWriterImpl, KlassCallbackStub, false> MethodWriter;
+typedef MethodIteratorHost<MethodWriterImpl, KlassCallbackStub, BitMapFilter, false> MethodWriter;
typedef LeakPredicate<MethodPtr> LeakMethodPredicate;
typedef JfrPredicatedTypeWriterImplHost<MethodPtr, LeakMethodPredicate, write__method__leakp> LeakMethodWriterImplTarget;
typedef JfrTypeWriterHost<LeakMethodWriterImplTarget, TYPE_METHOD> LeakMethodWriterImpl;
-typedef MethodIteratorHost<LeakMethodWriterImpl, KlassCallbackStub, true> LeakMethodWriter;
+typedef MethodIteratorHost<LeakMethodWriterImpl, KlassCallbackStub, BitMapFilter, true> LeakMethodWriter;
typedef CompositeFunctor<KlassPtr, LeakMethodWriter, MethodWriter> CompositeMethodWriter;
static void write_methods() {
@@ -832,7 +889,7 @@
typedef Wrapper<KlassPtr, ClearArtifact> ClearKlassBits;
typedef Wrapper<MethodPtr, ClearArtifact> ClearMethodFlag;
-typedef MethodIteratorHost<ClearMethodFlag, ClearKlassBits, false> ClearKlassAndMethods;
+typedef MethodIteratorHost<ClearMethodFlag, ClearKlassBits, AlwaysTrue, false> ClearKlassAndMethods;
static size_t teardown() {
assert(_artifacts != NULL, "invariant");
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -38,14 +38,12 @@
static const int meta_offset = low_offset - 1;
#endif
-inline void set_bits(jbyte bits, jbyte* const dest) {
+inline void set_bits(jbyte bits, jbyte volatile* const dest) {
assert(dest != NULL, "invariant");
if (bits != (*dest & bits)) {
*dest |= bits;
- OrderAccess::storeload();
- return;
+ OrderAccess::storestore();
}
- OrderAccess::loadload();
}
inline jbyte traceid_and(jbyte current, jbyte bits) {
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -25,17 +25,13 @@
#include "precompiled.hpp"
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp"
#include "runtime/safepoint.hpp"
-#include "runtime/orderAccess.hpp"
// Alternating epochs on each rotation allow for concurrent tagging.
-// The regular epoch shift happens only during a safepoint.
-// The fence is there only for the emergency dump case which happens outside of safepoint.
+// The epoch shift happens only during a safepoint.
bool JfrTraceIdEpoch::_epoch_state = false;
bool volatile JfrTraceIdEpoch::_tag_state = false;
void JfrTraceIdEpoch::shift_epoch() {
+ assert(SafepointSynchronize::is_at_safepoint(), "invariant");
_epoch_state = !_epoch_state;
- if (!SafepointSynchronize::is_at_safepoint()) {
- OrderAccess::fence();
- }
}
--- a/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -336,17 +336,25 @@
*
* 1. if the thread state is not "_thread_in_vm", we will quick transition
* it to "_thread_in_vm".
-* 2. the nesting state for both resource and handle areas are unknown,
-* so we allocate new fresh arenas, discarding the old ones.
-* 3. if the thread is the owner of some critical lock(s), unlock them.
+* 2. if the thread is the owner of some critical lock(s), unlock them.
*
* If we end up deadlocking in the attempt of dumping out jfr data,
* we rely on the WatcherThread task "is_error_reported()",
-* to exit the VM after a hard-coded timeout.
+* to exit the VM after a hard-coded timeout (disallow WatcherThread to emergency dump).
* This "safety net" somewhat explains the aggressiveness in this attempt.
*
*/
-static void prepare_for_emergency_dump(Thread* thread) {
+static bool prepare_for_emergency_dump() {
+ if (JfrStream_lock->owned_by_self()) {
+ // crashed during jfr rotation, disallow recursion
+ return false;
+ }
+ Thread* const thread = Thread::current();
+ if (thread->is_Watcher_thread()) {
+ // need WatcherThread as a safeguard against potential deadlocks
+ return false;
+ }
+
if (thread->is_Java_thread()) {
((JavaThread*)thread)->set_thread_state(_thread_in_vm);
}
@@ -384,7 +392,6 @@
VMOperationRequest_lock->unlock();
}
-
if (Service_lock->owned_by_self()) {
Service_lock->unlock();
}
@@ -412,6 +419,7 @@
if (JfrStacktrace_lock->owned_by_self()) {
JfrStacktrace_lock->unlock();
}
+ return true;
}
static volatile int jfr_shutdown_lock = 0;
@@ -421,24 +429,9 @@
}
void JfrEmergencyDump::on_vm_shutdown(bool exception_handler) {
- if (!guard_reentrancy()) {
+ if (!(guard_reentrancy() && prepare_for_emergency_dump())) {
return;
}
- // function made non-reentrant
- Thread* thread = Thread::current();
- if (exception_handler) {
- // we are crashing
- if (thread->is_Watcher_thread()) {
- // The Watcher thread runs the periodic thread sampling task.
- // If it has crashed, it is likely that another thread is
- // left in a suspended state. This would mean the system
- // will not be able to ever move to a safepoint. We try
- // to avoid issuing safepoint operations when attempting
- // an emergency dump, but a safepoint might be already pending.
- return;
- }
- prepare_for_emergency_dump(thread);
- }
EventDumpReason event;
if (event.should_commit()) {
event.set_reason(exception_handler ? "Crash" : "Out of Memory");
@@ -450,8 +443,6 @@
LeakProfiler::emit_events(max_jlong, false);
}
const int messages = MSGBIT(MSG_VM_ERROR);
- ResourceMark rm(thread);
- HandleMark hm(thread);
JfrRecorderService service;
service.rotate(messages);
}
--- a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -56,86 +56,9 @@
#include "runtime/vmOperations.hpp"
#include "runtime/vmThread.hpp"
-// set data iff *dest == NULL
-static bool try_set(void* const data, void** dest, bool clear) {
- assert(data != NULL, "invariant");
- const void* const current = *dest;
- if (current != NULL) {
- if (current != data) {
- // already set
- return false;
- }
- assert(current == data, "invariant");
- if (!clear) {
- // recursion disallowed
- return false;
- }
- }
- return Atomic::cmpxchg(clear ? NULL : data, dest, current) == current;
-}
-
-static void* rotation_thread = NULL;
-static const int rotation_try_limit = 1000;
-static const int rotation_retry_sleep_millis = 10;
-
// incremented on each flushpoint
static u8 flushpoint_id = 0;
-class RotationLock : public StackObj {
- private:
- Thread* const _thread;
- bool _acquired;
-
- void log(bool recursion) {
- assert(!_acquired, "invariant");
- const char* error_msg = NULL;
- if (recursion) {
- error_msg = "Unable to issue rotation due to recursive calls.";
- }
- else {
- error_msg = "Unable to issue rotation due to wait timeout.";
- }
- log_info(jfr)( // For user, should not be "jfr, system"
- "%s", error_msg);
- }
- public:
- RotationLock(Thread* thread) : _thread(thread), _acquired(false) {
- assert(_thread != NULL, "invariant");
- if (_thread == rotation_thread) {
- // recursion not supported
- log(true);
- return;
- }
-
- // limited to not spin indefinitely
- for (int i = 0; i < rotation_try_limit; ++i) {
- if (try_set(_thread, &rotation_thread, false)) {
- _acquired = true;
- assert(_thread == rotation_thread, "invariant");
- return;
- }
- if (_thread->is_Java_thread()) {
- // in order to allow the system to move to a safepoint
- MutexLocker msg_lock(JfrMsg_lock);
- JfrMsg_lock->wait(rotation_retry_sleep_millis);
- }
- else {
- os::naked_short_sleep(rotation_retry_sleep_millis);
- }
- }
- log(false);
- }
-
- ~RotationLock() {
- assert(_thread != NULL, "invariant");
- if (_acquired) {
- assert(_thread == rotation_thread, "invariant");
- while (!try_set(_thread, &rotation_thread, true));
- }
- }
- bool not_acquired() const { return !_acquired; }
-};
-
template <typename E, typename Instance, size_t(Instance::*func)()>
class Content {
private:
@@ -438,10 +361,7 @@
}
void JfrRecorderService::start() {
- RotationLock rl(Thread::current());
- if (rl.not_acquired()) {
- return;
- }
+ MutexLocker lock(JfrStream_lock);
log_debug(jfr, system)("Request to START recording");
assert(!is_recording(), "invariant");
clear();
@@ -460,9 +380,9 @@
}
void JfrRecorderService::pre_safepoint_clear() {
- _stack_trace_repository.clear();
_string_pool.clear();
_storage.clear();
+ _stack_trace_repository.clear();
}
void JfrRecorderService::invoke_safepoint_clear() {
@@ -472,11 +392,11 @@
void JfrRecorderService::safepoint_clear() {
assert(SafepointSynchronize::is_at_safepoint(), "invariant");
- _stack_trace_repository.clear();
_string_pool.clear();
_storage.clear();
_checkpoint_manager.shift_epoch();
_chunkwriter.set_time_stamp();
+ _stack_trace_repository.clear();
}
void JfrRecorderService::post_safepoint_clear() {
@@ -500,6 +420,7 @@
}
void JfrRecorderService::prepare_for_vm_error_rotation() {
+ assert(JfrStream_lock->owned_by_self(), "invariant");
if (!_chunkwriter.is_valid()) {
open_new_chunk(true);
}
@@ -507,10 +428,11 @@
}
void JfrRecorderService::vm_error_rotation() {
+ assert(JfrStream_lock->owned_by_self(), "invariant");
if (_chunkwriter.is_valid()) {
Thread* const t = Thread::current();
_storage.flush_regular_buffer(t->jfr_thread_local()->native_buffer(), t);
- invoke_flush(t);
+ invoke_flush();
_chunkwriter.set_time_stamp();
_repository.close_chunk();
assert(!_chunkwriter.is_valid(), "invariant");
@@ -519,10 +441,8 @@
}
void JfrRecorderService::rotate(int msgs) {
- RotationLock rl(Thread::current());
- if (rl.not_acquired()) {
- return;
- }
+ assert(!JfrStream_lock->owned_by_self(), "invariant");
+ MutexLocker lock(JfrStream_lock);
static bool vm_error = false;
if (msgs & MSGBIT(MSG_VM_ERROR)) {
vm_error = true;
@@ -541,6 +461,7 @@
}
void JfrRecorderService::in_memory_rotation() {
+ assert(JfrStream_lock->owned_by_self(), "invariant");
// currently running an in-memory recording
assert(!_storage.control().to_disk(), "invariant");
open_new_chunk();
@@ -551,6 +472,7 @@
}
void JfrRecorderService::chunk_rotation() {
+ assert(JfrStream_lock->owned_by_self(), "invariant");
finalize_current_chunk();
open_new_chunk();
}
@@ -570,18 +492,18 @@
void JfrRecorderService::pre_safepoint_write() {
assert(_chunkwriter.is_valid(), "invariant");
- if (_stack_trace_repository.is_modified()) {
- write_stacktrace(_stack_trace_repository, _chunkwriter, false);
- }
- if (_string_pool.is_modified()) {
- write_stringpool(_string_pool, _chunkwriter);
- }
if (LeakProfiler::is_running()) {
// Exclusive access to the object sampler instance.
// The sampler is released (unlocked) later in post_safepoint_write.
ObjectSampleCheckpoint::on_rotation(ObjectSampler::acquire(), _stack_trace_repository);
}
+ if (_string_pool.is_modified()) {
+ write_stringpool(_string_pool, _chunkwriter);
+ }
write_storage(_storage, _chunkwriter);
+ if (_stack_trace_repository.is_modified()) {
+ write_stacktrace(_stack_trace_repository, _chunkwriter, false);
+ }
}
void JfrRecorderService::invoke_safepoint_write() {
@@ -591,13 +513,14 @@
void JfrRecorderService::safepoint_write() {
assert(SafepointSynchronize::is_at_safepoint(), "invariant");
- write_stacktrace(_stack_trace_repository, _chunkwriter, true);
if (_string_pool.is_modified()) {
write_stringpool_safepoint(_string_pool, _chunkwriter);
}
+ _checkpoint_manager.on_rotation();
_storage.write_at_safepoint();
- _checkpoint_manager.on_rotation();
+ _checkpoint_manager.shift_epoch();
_chunkwriter.set_time_stamp();
+ write_stacktrace(_stack_trace_repository, _chunkwriter, true);
}
void JfrRecorderService::post_safepoint_write() {
@@ -643,18 +566,19 @@
}
size_t JfrRecorderService::flush() {
+ assert(JfrStream_lock->owned_by_self(), "invariant");
size_t total_elements = flush_metadata(_chunkwriter);
const size_t storage_elements = flush_storage(_storage, _chunkwriter);
if (0 == storage_elements) {
return total_elements;
}
total_elements += storage_elements;
+ if (_string_pool.is_modified()) {
+ total_elements += flush_stringpool(_string_pool, _chunkwriter);
+ }
if (_stack_trace_repository.is_modified()) {
total_elements += flush_stacktrace(_stack_trace_repository, _chunkwriter);
}
- if (_string_pool.is_modified()) {
- total_elements += flush_stringpool(_string_pool, _chunkwriter);
- }
if (_checkpoint_manager.is_type_set_required()) {
total_elements += flush_typeset(_checkpoint_manager, _chunkwriter);
} else if (_checkpoint_manager.is_static_type_set_required()) {
@@ -667,9 +591,10 @@
typedef Content<EventFlush, JfrRecorderService, &JfrRecorderService::flush> FlushFunctor;
typedef WriteContent<FlushFunctor> Flush;
-void JfrRecorderService::invoke_flush(Thread* t) {
- assert(t != NULL, "invariant");
+void JfrRecorderService::invoke_flush() {
+ assert(JfrStream_lock->owned_by_self(), "invariant");
assert(_chunkwriter.is_valid(), "invariant");
+ Thread* const t = Thread::current();
ResourceMark rm(t);
HandleMark hm(t);
++flushpoint_id;
@@ -682,12 +607,8 @@
}
void JfrRecorderService::flushpoint() {
- Thread* const t = Thread::current();
- RotationLock rl(t);
- if (rl.not_acquired() || !_chunkwriter.is_valid()) {
- return;
- }
- invoke_flush(t);
+ MutexLocker lock(JfrStream_lock);
+ invoke_flush();
}
void JfrRecorderService::process_full_buffers() {
--- a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -33,7 +33,6 @@
class JfrStackTraceRepository;
class JfrStorage;
class JfrStringPool;
-class Thread;
class JfrRecorderService : public StackObj {
private:
@@ -50,7 +49,7 @@
void finalize_current_chunk();
void prepare_for_vm_error_rotation();
void vm_error_rotation();
- void invoke_flush(Thread* t);
+ void invoke_flush();
void clear();
void pre_safepoint_clear();
@@ -67,13 +66,13 @@
public:
JfrRecorderService();
void start();
+ size_t flush();
void rotate(int msgs);
void flushpoint();
void process_full_buffers();
void scavenge();
void evaluate_chunk_size_for_rotation();
static bool is_recording();
- size_t flush();
};
#endif // SHARE_JFR_RECORDER_SERVICE_JFRRECORDERSERVICE_HPP
--- a/src/hotspot/share/jvmci/compilerRuntime.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jvmci/compilerRuntime.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -73,7 +73,7 @@
Handle protection_domain(THREAD, caller->method_holder()->protection_domain());
// Ignore wrapping L and ;
- if (name[0] == 'L') {
+ if (name[0] == JVM_SIGNATURE_CLASS) {
assert(len > 2, "small name %s", name);
name++;
len -= 2;
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -535,8 +535,8 @@
JVMCI_THROW_MSG_NULL(ClassNotFoundException, str);
}
} else {
- if (class_name->char_at(0) == 'L' &&
- class_name->char_at(class_name->utf8_length()-1) == ';') {
+ if (class_name->char_at(0) == JVM_SIGNATURE_CLASS &&
+ class_name->char_at(class_name->utf8_length()-1) == JVM_SIGNATURE_ENDCLASS) {
// This is a name from a signature. Strip off the trimmings.
// Call recursive to keep scope of strippedsym.
TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1,
@@ -2330,6 +2330,16 @@
return true;
C2V_END
+C2V_VMENTRY_PREFIX(jlong, getCurrentJavaThread, (JNIEnv* env, jobject c2vm))
+ if (base_thread == NULL) {
+ // Called from unattached JVMCI shared library thread
+ return 0L;
+ }
+ JVMCITraceMark jtm("getCurrentJavaThread");
+ assert(base_thread->is_Java_thread(), "just checking");
+ return (jlong) p2i(base_thread);
+C2V_END
+
C2V_VMENTRY_PREFIX(jboolean, attachCurrentThread, (JNIEnv* env, jobject c2vm, jboolean as_daemon))
if (base_thread == NULL) {
// Called from unattached JVMCI shared library thread
@@ -2743,6 +2753,7 @@
{CC "deleteGlobalHandle", CC "(J)V", FN_PTR(deleteGlobalHandle)},
{CC "registerNativeMethods", CC "(" CLASS ")[J", FN_PTR(registerNativeMethods)},
{CC "isCurrentThreadAttached", CC "()Z", FN_PTR(isCurrentThreadAttached)},
+ {CC "getCurrentJavaThread", CC "()J", FN_PTR(getCurrentJavaThread)},
{CC "attachCurrentThread", CC "(Z)Z", FN_PTR(attachCurrentThread)},
{CC "detachCurrentThread", CC "()V", FN_PTR(detachCurrentThread)},
{CC "translate", CC "(" OBJECT ")J", FN_PTR(translate)},
--- a/src/hotspot/share/jvmci/jvmciRuntime.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -980,8 +980,8 @@
JVMCI_EXCEPTION_CONTEXT;
// Now we need to check the SystemDictionary
- if (sym->char_at(0) == 'L' &&
- sym->char_at(sym->utf8_length()-1) == ';') {
+ if (sym->char_at(0) == JVM_SIGNATURE_CLASS &&
+ sym->char_at(sym->utf8_length()-1) == JVM_SIGNATURE_ENDCLASS) {
// This is a name from a signature. Strip off the trimmings.
// Call recursive to keep scope of strippedsym.
TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
@@ -1013,8 +1013,8 @@
// we must build an array type around it. The CI requires array klasses
// to be loaded if their element klasses are loaded, except when memory
// is exhausted.
- if (sym->char_at(0) == '[' &&
- (sym->char_at(1) == '[' || sym->char_at(1) == 'L')) {
+ if (sym->char_at(0) == JVM_SIGNATURE_ARRAY &&
+ (sym->char_at(1) == JVM_SIGNATURE_ARRAY || sym->char_at(1) == JVM_SIGNATURE_CLASS)) {
// We have an unloaded array.
// Build it on the fly if the element class exists.
TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
@@ -1271,7 +1271,7 @@
if (method_holder->is_instance_klass()) {
return InstanceKlass::cast(method_holder);
} else if (method_holder->is_array_klass()) {
- return InstanceKlass::cast(SystemDictionary::Object_klass());
+ return SystemDictionary::Object_klass();
} else {
ShouldNotReachHere();
}
--- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -180,6 +180,7 @@
nonstatic_field(JavaThread, _pending_transfer_to_interpreter, bool) \
nonstatic_field(JavaThread, _jvmci_counters, jlong*) \
nonstatic_field(JavaThread, _should_post_on_exceptions_flag, int) \
+ nonstatic_field(JavaThread, _jni_environment, JNIEnv) \
nonstatic_field(JavaThread, _reserved_stack_activation, address) \
\
static_field(java_lang_Class, _klass_offset, int) \
@@ -538,6 +539,7 @@
declare_constant(FieldInfo::field_slots) \
\
declare_constant(InstanceKlass::linked) \
+ declare_constant(InstanceKlass::being_initialized) \
declare_constant(InstanceKlass::fully_initialized) \
declare_constant(InstanceKlass::_misc_is_unsafe_anonymous) \
\
--- a/src/hotspot/share/memory/heapInspection.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/memory/heapInspection.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -72,8 +72,8 @@
ResourceMark rm;
const char* name1 = e1->klass()->external_name();
const char* name2 = e2->klass()->external_name();
- bool d1 = (name1[0] == '[');
- bool d2 = (name2[0] == '[');
+ bool d1 = (name1[0] == JVM_SIGNATURE_ARRAY);
+ bool d2 = (name2[0] == JVM_SIGNATURE_ARRAY);
if (d1 && !d2) {
return -1;
} else if (d2 && !d1) {
--- a/src/hotspot/share/memory/iterator.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/memory/iterator.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -59,7 +59,7 @@
void MarkingCodeBlobClosure::do_code_blob(CodeBlob* cb) {
nmethod* nm = cb->as_nmethod_or_null();
- if (nm != NULL && !nm->test_set_oops_do_mark()) {
+ if (nm != NULL && nm->oops_do_try_claim()) {
do_nmethod(nm);
}
}
--- a/src/hotspot/share/oops/generateOopMap.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/oops/generateOopMap.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, 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
@@ -1993,14 +1993,14 @@
// This is used to parse the signature for fields, since they are very simple...
CellTypeState *GenerateOopMap::sigchar_to_effect(char sigch, int bci, CellTypeState *out) {
// Object and array
- if (sigch=='L' || sigch=='[') {
+ if (sigch==JVM_SIGNATURE_CLASS || sigch==JVM_SIGNATURE_ARRAY) {
out[0] = CellTypeState::make_line_ref(bci);
out[1] = CellTypeState::bottom;
return out;
}
- if (sigch == 'J' || sigch == 'D' ) return vvCTS; // Long and Double
- if (sigch == 'V' ) return epsilonCTS; // Void
- return vCTS; // Otherwise
+ if (sigch == JVM_SIGNATURE_LONG || sigch == JVM_SIGNATURE_DOUBLE) return vvCTS; // Long and Double
+ if (sigch == JVM_SIGNATURE_VOID) return epsilonCTS; // Void
+ return vCTS; // Otherwise
}
long GenerateOopMap::_total_byte_count = 0;
--- a/src/hotspot/share/oops/instanceKlass.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/oops/instanceKlass.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -69,6 +69,7 @@
#include "prims/jvmtiThreadState.hpp"
#include "prims/methodComparator.hpp"
#include "runtime/atomic.hpp"
+#include "runtime/biasedLocking.hpp"
#include "runtime/fieldDescriptor.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/javaCalls.hpp"
@@ -456,6 +457,12 @@
if (Arguments::is_dumping_archive()) {
SystemDictionaryShared::init_dumptime_info(this);
}
+
+ // Set biased locking bit for all instances of this class; it will be
+ // cleared if revocation occurs too often for this type
+ if (UseBiasedLocking && BiasedLocking::enabled()) {
+ set_prototype_header(markWord::biased_locking_prototype());
+ }
}
void InstanceKlass::deallocate_methods(ClassLoaderData* loader_data,
@@ -2408,6 +2415,11 @@
// --> see ArrayKlass::complete_create_array_klass()
array_klasses()->restore_unshareable_info(ClassLoaderData::the_null_class_loader_data(), Handle(), CHECK);
}
+
+ // Initialize current biased locking state.
+ if (UseBiasedLocking && BiasedLocking::enabled()) {
+ set_prototype_header(markWord::biased_locking_prototype());
+ }
}
// returns true IFF is_in_error_state() has been changed as a result of this call.
@@ -2497,10 +2509,18 @@
#endif
}
+static void method_release_C_heap_structures(Method* m) {
+ m->release_C_heap_structures();
+}
+
void InstanceKlass::release_C_heap_structures(InstanceKlass* ik) {
// Clean up C heap
ik->release_C_heap_structures();
ik->constants()->release_C_heap_structures();
+
+ // Deallocate and call destructors for MDO mutexes
+ ik->methods_do(method_release_C_heap_structures);
+
}
void InstanceKlass::release_C_heap_structures() {
@@ -2586,7 +2606,7 @@
// Add L as type indicator
int dest_index = 0;
- dest[dest_index++] = 'L';
+ dest[dest_index++] = JVM_SIGNATURE_CLASS;
// Add the actual class name
for (int src_index = 0; src_index < src_length; ) {
@@ -2599,7 +2619,7 @@
}
// Add the semicolon and the NULL
- dest[dest_index++] = ';';
+ dest[dest_index++] = JVM_SIGNATURE_ENDCLASS;
dest[dest_index] = '\0';
return dest;
}
--- a/src/hotspot/share/oops/klass.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/oops/klass.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -340,19 +340,17 @@
static ByteSize access_flags_offset() { return in_ByteSize(offset_of(Klass, _access_flags)); }
// Unpacking layout_helper:
- enum {
- _lh_neutral_value = 0, // neutral non-array non-instance value
- _lh_instance_slow_path_bit = 0x01,
- _lh_log2_element_size_shift = BitsPerByte*0,
- _lh_log2_element_size_mask = BitsPerLong-1,
- _lh_element_type_shift = BitsPerByte*1,
- _lh_element_type_mask = right_n_bits(BitsPerByte), // shifted mask
- _lh_header_size_shift = BitsPerByte*2,
- _lh_header_size_mask = right_n_bits(BitsPerByte), // shifted mask
- _lh_array_tag_bits = 2,
- _lh_array_tag_shift = BitsPerInt - _lh_array_tag_bits,
- _lh_array_tag_obj_value = ~0x01 // 0x80000000 >> 30
- };
+ static const int _lh_neutral_value = 0; // neutral non-array non-instance value
+ static const int _lh_instance_slow_path_bit = 0x01;
+ static const int _lh_log2_element_size_shift = BitsPerByte*0;
+ static const int _lh_log2_element_size_mask = BitsPerLong-1;
+ static const int _lh_element_type_shift = BitsPerByte*1;
+ static const int _lh_element_type_mask = right_n_bits(BitsPerByte); // shifted mask
+ static const int _lh_header_size_shift = BitsPerByte*2;
+ static const int _lh_header_size_mask = right_n_bits(BitsPerByte); // shifted mask
+ static const int _lh_array_tag_bits = 2;
+ static const int _lh_array_tag_shift = BitsPerInt - _lh_array_tag_bits;
+ static const int _lh_array_tag_obj_value = ~0x01; // 0x80000000 >> 30
static const unsigned int _lh_array_tag_type_value = 0Xffffffff; // ~0x00, // 0xC0000000 >> 30
--- a/src/hotspot/share/oops/method.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/oops/method.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "classfile/classLoaderDataGraph.hpp"
#include "classfile/metadataOnStackMark.hpp"
+#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "code/codeCache.hpp"
#include "code/debugInfoRec.hpp"
@@ -118,11 +119,6 @@
void Method::deallocate_contents(ClassLoaderData* loader_data) {
MetadataFactory::free_metadata(loader_data, constMethod());
set_constMethod(NULL);
-#if INCLUDE_JVMCI
- if (method_data()) {
- FailedSpeculation::free_failed_speculations(method_data()->get_failed_speculations_address());
- }
-#endif
MetadataFactory::free_metadata(loader_data, method_data());
set_method_data(NULL);
MetadataFactory::free_metadata(loader_data, method_counters());
@@ -131,6 +127,16 @@
if (code() != NULL) _code = NULL;
}
+void Method::release_C_heap_structures() {
+ if (method_data()) {
+#if INCLUDE_JVMCI
+ FailedSpeculation::free_failed_speculations(method_data()->get_failed_speculations_address());
+#endif
+ // Destroy MethodData
+ method_data()->~MethodData();
+ }
+}
+
address Method::get_i2c_entry() {
assert(adapter() != NULL, "must have");
return adapter()->get_i2c_entry();
@@ -373,7 +379,83 @@
assert(valid_itable_index(), "");
}
+// The RegisterNatives call being attempted tried to register with a method that
+// is not native. Ask JVM TI what prefixes have been specified. Then check
+// to see if the native method is now wrapped with the prefixes. See the
+// SetNativeMethodPrefix(es) functions in the JVM TI Spec for details.
+static Method* find_prefixed_native(Klass* k, Symbol* name, Symbol* signature, TRAPS) {
+#if INCLUDE_JVMTI
+ ResourceMark rm(THREAD);
+ Method* method;
+ int name_len = name->utf8_length();
+ char* name_str = name->as_utf8();
+ int prefix_count;
+ char** prefixes = JvmtiExport::get_all_native_method_prefixes(&prefix_count);
+ for (int i = 0; i < prefix_count; i++) {
+ char* prefix = prefixes[i];
+ int prefix_len = (int)strlen(prefix);
+ // try adding this prefix to the method name and see if it matches another method name
+ int trial_len = name_len + prefix_len;
+ char* trial_name_str = NEW_RESOURCE_ARRAY(char, trial_len + 1);
+ strcpy(trial_name_str, prefix);
+ strcat(trial_name_str, name_str);
+ TempNewSymbol trial_name = SymbolTable::probe(trial_name_str, trial_len);
+ if (trial_name == NULL) {
+ continue; // no such symbol, so this prefix wasn't used, try the next prefix
+ }
+ method = k->lookup_method(trial_name, signature);
+ if (method == NULL) {
+ continue; // signature doesn't match, try the next prefix
+ }
+ if (method->is_native()) {
+ method->set_is_prefixed_native();
+ return method; // wahoo, we found a prefixed version of the method, return it
+ }
+ // found as non-native, so prefix is good, add it, probably just need more prefixes
+ name_len = trial_len;
+ name_str = trial_name_str;
+ }
+#endif // INCLUDE_JVMTI
+ return NULL; // not found
+}
+
+bool Method::register_native(Klass* k, Symbol* name, Symbol* signature, address entry, TRAPS) {
+ Method* method = k->lookup_method(name, signature);
+ if (method == NULL) {
+ ResourceMark rm(THREAD);
+ stringStream st;
+ st.print("Method '");
+ print_external_name(&st, k, name, signature);
+ st.print("' name or signature does not match");
+ THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
+ }
+ if (!method->is_native()) {
+ // trying to register to a non-native method, see if a JVM TI agent has added prefix(es)
+ method = find_prefixed_native(k, name, signature, THREAD);
+ if (method == NULL) {
+ ResourceMark rm(THREAD);
+ stringStream st;
+ st.print("Method '");
+ print_external_name(&st, k, name, signature);
+ st.print("' is not declared as native");
+ THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
+ }
+ }
+
+ if (entry != NULL) {
+ method->set_native_function(entry, native_bind_event_is_interesting);
+ } else {
+ method->clear_native_function();
+ }
+ if (PrintJNIResolving) {
+ ResourceMark rm(THREAD);
+ tty->print_cr("[Registering JNI native method %s.%s]",
+ method->method_holder()->external_name(),
+ method->name()->as_C_string());
+ }
+ return true;
+}
bool Method::was_executed_more_than(int n) {
// Invocation counter is reset when the Method* is compiled.
--- a/src/hotspot/share/oops/method.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/oops/method.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -346,6 +346,12 @@
// InterpreterRuntime::exception_handler_for_exception.
static int fast_exception_handler_bci_for(const methodHandle& mh, Klass* ex_klass, int throw_bci, TRAPS);
+ static bool register_native(Klass* k,
+ Symbol* name,
+ Symbol* signature,
+ address entry,
+ TRAPS);
+
// method data access
MethodData* method_data() const {
return _method_data;
@@ -1006,6 +1012,8 @@
// Deallocation function for redefine classes or if an error occurs
void deallocate_contents(ClassLoaderData* loader_data);
+ void release_C_heap_structures();
+
Method* get_new_method() const {
InstanceKlass* holder = method_holder();
Method* new_method = holder->method_with_idnum(orig_method_idnum());
--- a/src/hotspot/share/oops/methodData.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/oops/methodData.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -2445,7 +2445,7 @@
virtual void metaspace_pointers_do(MetaspaceClosure* iter);
virtual MetaspaceObj::Type type() const { return MethodDataType; }
- // Deallocation support - no pointer fields to deallocate
+ // Deallocation support - no metaspace pointer fields to deallocate
void deallocate_contents(ClassLoaderData* loader_data) {}
// GC support
--- a/src/hotspot/share/oops/objArrayKlass.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/oops/objArrayKlass.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -106,14 +106,14 @@
int len = element_klass->name()->utf8_length();
char *new_str = NEW_RESOURCE_ARRAY(char, len + 4);
int idx = 0;
- new_str[idx++] = '[';
+ new_str[idx++] = JVM_SIGNATURE_ARRAY;
if (element_klass->is_instance_klass()) { // it could be an array or simple type
- new_str[idx++] = 'L';
+ new_str[idx++] = JVM_SIGNATURE_CLASS;
}
memcpy(&new_str[idx], name_str, len * sizeof(char));
idx += len;
if (element_klass->is_instance_klass()) {
- new_str[idx++] = ';';
+ new_str[idx++] = JVM_SIGNATURE_ENDCLASS;
}
new_str[idx++] = '\0';
name = SymbolTable::new_permanent_symbol(new_str);
--- a/src/hotspot/share/oops/oopsHierarchy.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/oops/oopsHierarchy.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -37,8 +37,6 @@
Thread* t = Thread::current_or_null();
if (t != NULL && t->is_Java_thread()) {
frame fr = os::current_frame();
- // This points to the oop creator, I guess current frame points to caller
- assert (fr.pc(), "should point to a vm frame");
t->unhandled_oops()->register_unhandled_oop(this, fr.pc());
}
}
--- a/src/hotspot/share/oops/symbol.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/oops/symbol.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -201,8 +201,8 @@
int length = (int)strlen(str);
// Turn all '/'s into '.'s (also for array klasses)
for (int index = 0; index < length; index++) {
- if (str[index] == '/') {
- str[index] = '.';
+ if (str[index] == JVM_SIGNATURE_SLASH) {
+ str[index] = JVM_SIGNATURE_DOT;
}
}
return str;
@@ -210,8 +210,8 @@
static void print_class(outputStream *os, char *class_str, int len) {
for (int i = 0; i < len; ++i) {
- if (class_str[i] == '/') {
- os->put('.');
+ if (class_str[i] == JVM_SIGNATURE_SLASH) {
+ os->put(JVM_SIGNATURE_DOT);
} else {
os->put(class_str[i]);
}
@@ -221,9 +221,9 @@
static void print_array(outputStream *os, char *array_str, int len) {
int dimensions = 0;
for (int i = 0; i < len; ++i) {
- if (array_str[i] == '[') {
+ if (array_str[i] == JVM_SIGNATURE_ARRAY) {
dimensions++;
- } else if (array_str[i] == 'L') {
+ } else if (array_str[i] == JVM_SIGNATURE_CLASS) {
// Expected format: L<type name>;. Skip 'L' and ';' delimiting the type name.
print_class(os, array_str+i+1, len-i-2);
break;
--- a/src/hotspot/share/opto/convertnode.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/opto/convertnode.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -532,6 +532,11 @@
}
//=============================================================================
+RoundDoubleModeNode* RoundDoubleModeNode::make(PhaseGVN& gvn, Node* arg, RoundDoubleModeNode::RoundingMode rmode) {
+ ConINode* rm = gvn.intcon(rmode);
+ return new RoundDoubleModeNode(arg, (Node *)rm);
+}
+
//------------------------------Identity---------------------------------------
// Remove redundant roundings.
Node* RoundDoubleModeNode::Identity(PhaseGVN* phase) {
--- a/src/hotspot/share/opto/convertnode.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/opto/convertnode.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -215,7 +215,13 @@
//-----------------------------RoundDoubleModeNode-----------------------------
class RoundDoubleModeNode: public Node {
public:
+ enum RoundingMode {
+ rmode_rint = 0,
+ rmode_floor = 1,
+ rmode_ceil = 2
+ };
RoundDoubleModeNode(Node *in1, Node * rmode): Node(0, in1, rmode) {}
+ static RoundDoubleModeNode* make(PhaseGVN& gvn, Node* arg, RoundDoubleModeNode::RoundingMode rmode);
virtual int Opcode() const;
virtual const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
--- a/src/hotspot/share/opto/library_call.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/opto/library_call.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1822,9 +1822,9 @@
switch (id) {
case vmIntrinsics::_dabs: n = new AbsDNode( arg); break;
case vmIntrinsics::_dsqrt: n = new SqrtDNode(C, control(), arg); break;
- case vmIntrinsics::_ceil: n = new RoundDoubleModeNode(arg, makecon(TypeInt::make(2))); break;
- case vmIntrinsics::_floor: n = new RoundDoubleModeNode(arg, makecon(TypeInt::make(1))); break;
- case vmIntrinsics::_rint: n = new RoundDoubleModeNode(arg, makecon(TypeInt::make(0))); break;
+ case vmIntrinsics::_ceil: n = RoundDoubleModeNode::make(_gvn, arg, RoundDoubleModeNode::rmode_ceil); break;
+ case vmIntrinsics::_floor: n = RoundDoubleModeNode::make(_gvn, arg, RoundDoubleModeNode::rmode_floor); break;
+ case vmIntrinsics::_rint: n = RoundDoubleModeNode::make(_gvn, arg, RoundDoubleModeNode::rmode_rint); break;
default: fatal_unexpected_iid(id); break;
}
set_result(_gvn.transform(n));
--- a/src/hotspot/share/opto/loopnode.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/opto/loopnode.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1378,7 +1378,7 @@
bool exceeding_node_budget(uint required = 0) {
assert(C->live_nodes() < C->max_node_limit(), "sanity");
uint available = C->max_node_limit() - C->live_nodes();
- return available < required + _nodes_required;
+ return available < required + _nodes_required + REQUIRE_MIN;
}
uint require_nodes(uint require, uint minreq = REQUIRE_MIN) {
--- a/src/hotspot/share/opto/loopopts.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/opto/loopopts.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -3159,7 +3159,8 @@
Node_List worklist(area);
Node_List sink_list(area);
- if (!may_require_nodes(loop->est_loop_clone_sz(2))) {
+ uint estimate = loop->est_loop_clone_sz(1);
+ if (exceeding_node_budget(estimate)) {
return false;
}
@@ -3184,8 +3185,7 @@
// Set of non-cfg nodes to peel are those that are control
// dependent on the cfg nodes.
- uint i;
- for(i = 0; i < loop->_body.size(); i++ ) {
+ for (uint i = 0; i < loop->_body.size(); i++) {
Node *n = loop->_body.at(i);
Node *n_c = has_ctrl(n) ? get_ctrl(n) : n;
if (peel.test(n_c->_idx)) {
@@ -3200,7 +3200,7 @@
// Get a post order schedule of nodes in the peel region
// Result in right-most operand.
- scheduled_nodelist(loop, peel, peel_list );
+ scheduled_nodelist(loop, peel, peel_list);
assert(is_valid_loop_partition(loop, peel, peel_list, not_peel), "bad partition");
@@ -3220,25 +3220,21 @@
// Evacuate nodes in peel region into the not_peeled region if possible
uint new_phi_cnt = 0;
uint cloned_for_outside_use = 0;
- for (i = 0; i < peel_list.size();) {
+ for (uint i = 0; i < peel_list.size();) {
Node* n = peel_list.at(i);
#ifndef PRODUCT
if (TracePartialPeeling) n->dump();
#endif
bool incr = true;
- if ( !n->is_CFG() ) {
-
- if ( has_use_in_set(n, not_peel) ) {
-
+ if (!n->is_CFG()) {
+ if (has_use_in_set(n, not_peel)) {
// If not used internal to the peeled region,
// move "n" from peeled to not_peeled region.
-
- if ( !has_use_internal_to_set(n, peel, loop) ) {
-
+ if (!has_use_internal_to_set(n, peel, loop)) {
// if not pinned and not a load (which maybe anti-dependent on a store)
// and not a CMove (Matcher expects only bool->cmove).
if (n->in(0) == NULL && !n->is_Load() && !n->is_CMove()) {
- cloned_for_outside_use += clone_for_use_outside_loop( loop, n, worklist );
+ cloned_for_outside_use += clone_for_use_outside_loop(loop, n, worklist);
sink_list.push(n);
peel >>= n->_idx; // delete n from peel set.
not_peel <<= n->_idx; // add n to not_peel set.
@@ -3254,7 +3250,7 @@
} else {
// Otherwise check for special def-use cases that span
// the peel/not_peel boundary such as bool->if
- clone_for_special_use_inside_loop( loop, n, not_peel, sink_list, worklist );
+ clone_for_special_use_inside_loop(loop, n, not_peel, sink_list, worklist);
new_phi_cnt++;
}
}
@@ -3262,7 +3258,11 @@
if (incr) i++;
}
- if (new_phi_cnt > old_phi_cnt + PartialPeelNewPhiDelta) {
+ estimate += cloned_for_outside_use + new_phi_cnt;
+ bool exceed_node_budget = !may_require_nodes(estimate);
+ bool exceed_phi_limit = new_phi_cnt > old_phi_cnt + PartialPeelNewPhiDelta;
+
+ if (exceed_node_budget || exceed_phi_limit) {
#ifndef PRODUCT
if (TracePartialPeeling) {
tty->print_cr("\nToo many new phis: %d old %d new cmpi: %c",
@@ -3310,7 +3310,7 @@
const uint clone_exit_idx = 1;
const uint orig_exit_idx = 2;
- assert(is_valid_clone_loop_form( loop, peel_list, orig_exit_idx, clone_exit_idx ), "bad clone loop");
+ assert(is_valid_clone_loop_form(loop, peel_list, orig_exit_idx, clone_exit_idx), "bad clone loop");
Node* head_clone = old_new[head->_idx];
LoopNode* new_head_clone = old_new[new_head->_idx]->as_Loop();
@@ -3318,7 +3318,7 @@
// Add phi if "def" node is in peel set and "use" is not
- for(i = 0; i < peel_list.size(); i++ ) {
+ for (uint i = 0; i < peel_list.size(); i++) {
Node *def = peel_list.at(i);
if (!def->is_CFG()) {
for (DUIterator_Fast jmax, j = def->fast_outs(jmax); j < jmax; j++) {
@@ -3374,7 +3374,7 @@
// cloned-not_peeled in(0) in(0)
// orig-peeled
- for(i = 0; i < loop->_body.size(); i++ ) {
+ for (uint i = 0; i < loop->_body.size(); i++) {
Node *n = loop->_body.at(i);
if (!n->is_CFG() && n->in(0) != NULL &&
not_peel.test(n->_idx) && peel.test(n->in(0)->_idx)) {
--- a/src/hotspot/share/opto/memnode.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/opto/memnode.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -736,9 +736,7 @@
// Also, asserts a cross-check of the type against the expected address type.
const TypePtr* MemNode::calculate_adr_type(const Type* t, const TypePtr* cross_check) {
if (t == Type::TOP) return NULL; // does not touch memory any more?
- #ifdef PRODUCT
- cross_check = NULL;
- #else
+ #ifdef ASSERT
if (!VerifyAliases || VMError::is_error_reported() || Node::in_dump()) cross_check = NULL;
#endif
const TypePtr* tp = t->isa_ptr();
@@ -3534,37 +3532,51 @@
// within the initialization without creating a vicious cycle, such as:
// { Foo p = new Foo(); p.next = p; }
// True for constants and parameters and small combinations thereof.
-bool InitializeNode::detect_init_independence(Node* n, int& count) {
- if (n == NULL) return true; // (can this really happen?)
- if (n->is_Proj()) n = n->in(0);
- if (n == this) return false; // found a cycle
- if (n->is_Con()) return true;
- if (n->is_Start()) return true; // params, etc., are OK
- if (n->is_Root()) return true; // even better
-
- Node* ctl = n->in(0);
- if (ctl != NULL && !ctl->is_top()) {
- if (ctl->is_Proj()) ctl = ctl->in(0);
- if (ctl == this) return false;
-
- // If we already know that the enclosing memory op is pinned right after
- // the init, then any control flow that the store has picked up
- // must have preceded the init, or else be equal to the init.
- // Even after loop optimizations (which might change control edges)
- // a store is never pinned *before* the availability of its inputs.
- if (!MemNode::all_controls_dominate(n, this))
- return false; // failed to prove a good control
- }
-
- // Check data edges for possible dependencies on 'this'.
- if ((count += 1) > 20) return false; // complexity limit
- for (uint i = 1; i < n->req(); i++) {
- Node* m = n->in(i);
- if (m == NULL || m == n || m->is_top()) continue;
- uint first_i = n->find_edge(m);
- if (i != first_i) continue; // process duplicate edge just once
- if (!detect_init_independence(m, count)) {
- return false;
+bool InitializeNode::detect_init_independence(Node* value, PhaseGVN* phase) {
+ ResourceMark rm;
+ Unique_Node_List worklist;
+ worklist.push(value);
+
+ uint complexity_limit = 20;
+ for (uint j = 0; j < worklist.size(); j++) {
+ if (j >= complexity_limit) {
+ return false; // Bail out if processed too many nodes
+ }
+
+ Node* n = worklist.at(j);
+ if (n == NULL) continue; // (can this really happen?)
+ if (n->is_Proj()) n = n->in(0);
+ if (n == this) return false; // found a cycle
+ if (n->is_Con()) continue;
+ if (n->is_Start()) continue; // params, etc., are OK
+ if (n->is_Root()) continue; // even better
+
+ // There cannot be any dependency if 'n' is a CFG node that dominates the current allocation
+ if (n->is_CFG() && phase->is_dominator(n, allocation())) {
+ continue;
+ }
+
+ Node* ctl = n->in(0);
+ if (ctl != NULL && !ctl->is_top()) {
+ if (ctl->is_Proj()) ctl = ctl->in(0);
+ if (ctl == this) return false;
+
+ // If we already know that the enclosing memory op is pinned right after
+ // the init, then any control flow that the store has picked up
+ // must have preceded the init, or else be equal to the init.
+ // Even after loop optimizations (which might change control edges)
+ // a store is never pinned *before* the availability of its inputs.
+ if (!MemNode::all_controls_dominate(n, this))
+ return false; // failed to prove a good control
+ }
+
+ // Check data edges for possible dependencies on 'this'.
+ for (uint i = 1; i < n->req(); i++) {
+ Node* m = n->in(i);
+ if (m == NULL || m == n || m->is_top()) continue;
+
+ // Only process data inputs once
+ worklist.push(m);
}
}
@@ -3575,7 +3587,7 @@
// an initialization. Returns zero if a check fails.
// On success, returns the (constant) offset to which the store applies,
// within the initialized memory.
-intptr_t InitializeNode::can_capture_store(StoreNode* st, PhaseTransform* phase, bool can_reshape) {
+intptr_t InitializeNode::can_capture_store(StoreNode* st, PhaseGVN* phase, bool can_reshape) {
const int FAIL = 0;
if (st->req() != MemNode::ValueIn + 1)
return FAIL; // an inscrutable StoreNode (card mark?)
@@ -3597,8 +3609,8 @@
return FAIL; // mismatched access
}
Node* val = st->in(MemNode::ValueIn);
- int complexity_count = 0;
- if (!detect_init_independence(val, complexity_count))
+
+ if (!detect_init_independence(val, phase))
return FAIL; // stored value must be 'simple enough'
// The Store can be captured only if nothing after the allocation
@@ -3796,7 +3808,7 @@
// rawstore1 rawstore2)
//
Node* InitializeNode::capture_store(StoreNode* st, intptr_t start,
- PhaseTransform* phase, bool can_reshape) {
+ PhaseGVN* phase, bool can_reshape) {
assert(stores_are_sane(phase), "");
if (start < 0) return NULL;
--- a/src/hotspot/share/opto/memnode.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/opto/memnode.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -1387,11 +1387,11 @@
// See if this store can be captured; return offset where it initializes.
// Return 0 if the store cannot be moved (any sort of problem).
- intptr_t can_capture_store(StoreNode* st, PhaseTransform* phase, bool can_reshape);
+ intptr_t can_capture_store(StoreNode* st, PhaseGVN* phase, bool can_reshape);
// Capture another store; reformat it to write my internal raw memory.
// Return the captured copy, else NULL if there is some sort of problem.
- Node* capture_store(StoreNode* st, intptr_t start, PhaseTransform* phase, bool can_reshape);
+ Node* capture_store(StoreNode* st, intptr_t start, PhaseGVN* phase, bool can_reshape);
// Find captured store which corresponds to the range [start..start+size).
// Return my own memory projection (meaning the initial zero bits)
@@ -1414,7 +1414,7 @@
Node* make_raw_address(intptr_t offset, PhaseTransform* phase);
- bool detect_init_independence(Node* n, int& count);
+ bool detect_init_independence(Node* value, PhaseGVN* phase);
void coalesce_subword_stores(intptr_t header_size, Node* size_in_bytes,
PhaseGVN* phase);
--- a/src/hotspot/share/opto/phaseX.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/opto/phaseX.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -899,7 +899,7 @@
while (d != n) {
n = IfNode::up_one_dom(n, linear_only);
i++;
- if (n == NULL || i >= 10) {
+ if (n == NULL || i >= 100) {
return false;
}
}
--- a/src/hotspot/share/prims/jni.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/prims/jni.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -2151,7 +2151,7 @@
if (JvmtiExport::should_post_field_modification()) {
jvalue field_value;
field_value.l = value;
- o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, 'L', (jvalue *)&field_value);
+ o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, JVM_SIGNATURE_CLASS, (jvalue *)&field_value);
}
HeapAccess<ON_UNKNOWN_OOP_REF>::oop_store_at(o, offset, JNIHandles::resolve(value));
HOTSPOT_JNI_SETOBJECTFIELD_RETURN();
@@ -2177,34 +2177,34 @@
field_value.unionType = value; \
o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \
} \
- if (SigType == 'Z') { value = ((jboolean)value) & 1; } \
+ if (SigType == JVM_SIGNATURE_BOOLEAN) { value = ((jboolean)value) & 1; } \
o->Fieldname##_field_put(offset, value); \
ReturnProbe; \
JNI_END
-DEFINE_SETFIELD(jboolean, bool, Boolean, 'Z', z
+DEFINE_SETFIELD(jboolean, bool, Boolean, JVM_SIGNATURE_BOOLEAN, z
, HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
HOTSPOT_JNI_SETBOOLEANFIELD_RETURN())
-DEFINE_SETFIELD(jbyte, byte, Byte, 'B', b
+DEFINE_SETFIELD(jbyte, byte, Byte, JVM_SIGNATURE_BYTE, b
, HOTSPOT_JNI_SETBYTEFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
HOTSPOT_JNI_SETBYTEFIELD_RETURN())
-DEFINE_SETFIELD(jchar, char, Char, 'C', c
+DEFINE_SETFIELD(jchar, char, Char, JVM_SIGNATURE_CHAR, c
, HOTSPOT_JNI_SETCHARFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
HOTSPOT_JNI_SETCHARFIELD_RETURN())
-DEFINE_SETFIELD(jshort, short, Short, 'S', s
+DEFINE_SETFIELD(jshort, short, Short, JVM_SIGNATURE_SHORT, s
, HOTSPOT_JNI_SETSHORTFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
HOTSPOT_JNI_SETSHORTFIELD_RETURN())
-DEFINE_SETFIELD(jint, int, Int, 'I', i
+DEFINE_SETFIELD(jint, int, Int, JVM_SIGNATURE_INT, i
, HOTSPOT_JNI_SETINTFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
HOTSPOT_JNI_SETINTFIELD_RETURN())
-DEFINE_SETFIELD(jlong, long, Long, 'J', j
+DEFINE_SETFIELD(jlong, long, Long, JVM_SIGNATURE_LONG, j
, HOTSPOT_JNI_SETLONGFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
HOTSPOT_JNI_SETLONGFIELD_RETURN())
// Float and double probes don't return value because dtrace doesn't currently support it
-DEFINE_SETFIELD(jfloat, float, Float, 'F', f
+DEFINE_SETFIELD(jfloat, float, Float, JVM_SIGNATURE_FLOAT, f
, HOTSPOT_JNI_SETFLOATFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
HOTSPOT_JNI_SETFLOATFIELD_RETURN())
-DEFINE_SETFIELD(jdouble, double, Double, 'D', d
+DEFINE_SETFIELD(jdouble, double, Double, JVM_SIGNATURE_DOUBLE, d
, HOTSPOT_JNI_SETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
HOTSPOT_JNI_SETDOUBLEFIELD_RETURN())
@@ -2352,7 +2352,7 @@
if (JvmtiExport::should_post_field_modification()) {
jvalue field_value;
field_value.l = value;
- JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, 'L', (jvalue *)&field_value);
+ JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, JVM_SIGNATURE_CLASS, (jvalue *)&field_value);
}
id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value));
HOTSPOT_JNI_SETSTATICOBJECTFIELD_RETURN();
@@ -2376,34 +2376,34 @@
field_value.unionType = value; \
JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \
} \
- if (SigType == 'Z') { value = ((jboolean)value) & 1; } \
+ if (SigType == JVM_SIGNATURE_BOOLEAN) { value = ((jboolean)value) & 1; } \
id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \
ReturnProbe;\
JNI_END
-DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z
+DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, JVM_SIGNATURE_BOOLEAN, z
, HOTSPOT_JNI_SETSTATICBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t)fieldID, value),
HOTSPOT_JNI_SETSTATICBOOLEANFIELD_RETURN())
-DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b
+DEFINE_SETSTATICFIELD(jbyte, byte, Byte, JVM_SIGNATURE_BYTE, b
, HOTSPOT_JNI_SETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
HOTSPOT_JNI_SETSTATICBYTEFIELD_RETURN())
-DEFINE_SETSTATICFIELD(jchar, char, Char, 'C', c
+DEFINE_SETSTATICFIELD(jchar, char, Char, JVM_SIGNATURE_CHAR, c
, HOTSPOT_JNI_SETSTATICCHARFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
HOTSPOT_JNI_SETSTATICCHARFIELD_RETURN())
-DEFINE_SETSTATICFIELD(jshort, short, Short, 'S', s
+DEFINE_SETSTATICFIELD(jshort, short, Short, JVM_SIGNATURE_SHORT, s
, HOTSPOT_JNI_SETSTATICSHORTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
HOTSPOT_JNI_SETSTATICSHORTFIELD_RETURN())
-DEFINE_SETSTATICFIELD(jint, int, Int, 'I', i
+DEFINE_SETSTATICFIELD(jint, int, Int, JVM_SIGNATURE_INT, i
, HOTSPOT_JNI_SETSTATICINTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
HOTSPOT_JNI_SETSTATICINTFIELD_RETURN())
-DEFINE_SETSTATICFIELD(jlong, long, Long, 'J', j
+DEFINE_SETSTATICFIELD(jlong, long, Long, JVM_SIGNATURE_LONG, j
, HOTSPOT_JNI_SETSTATICLONGFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
HOTSPOT_JNI_SETSTATICLONGFIELD_RETURN())
// Float and double probes don't return value because dtrace doesn't currently support it
-DEFINE_SETSTATICFIELD(jfloat, float, Float, 'F', f
+DEFINE_SETSTATICFIELD(jfloat, float, Float, JVM_SIGNATURE_FLOAT, f
, HOTSPOT_JNI_SETSTATICFLOATFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),
HOTSPOT_JNI_SETSTATICFLOATFIELD_RETURN())
-DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d
+DEFINE_SETSTATICFIELD(jdouble, double, Double, JVM_SIGNATURE_DOUBLE, d
, HOTSPOT_JNI_SETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),
HOTSPOT_JNI_SETSTATICDOUBLEFIELD_RETURN())
@@ -2909,89 +2909,6 @@
HOTSPOT_JNI_SETDOUBLEARRAYREGION_RETURN())
-//
-// Interception of natives
-//
-
-// The RegisterNatives call being attempted tried to register with a method that
-// is not native. Ask JVM TI what prefixes have been specified. Then check
-// to see if the native method is now wrapped with the prefixes. See the
-// SetNativeMethodPrefix(es) functions in the JVM TI Spec for details.
-static Method* find_prefixed_native(Klass* k, Symbol* name, Symbol* signature, TRAPS) {
-#if INCLUDE_JVMTI
- ResourceMark rm(THREAD);
- Method* method;
- int name_len = name->utf8_length();
- char* name_str = name->as_utf8();
- int prefix_count;
- char** prefixes = JvmtiExport::get_all_native_method_prefixes(&prefix_count);
- for (int i = 0; i < prefix_count; i++) {
- char* prefix = prefixes[i];
- int prefix_len = (int)strlen(prefix);
-
- // try adding this prefix to the method name and see if it matches another method name
- int trial_len = name_len + prefix_len;
- char* trial_name_str = NEW_RESOURCE_ARRAY(char, trial_len + 1);
- strcpy(trial_name_str, prefix);
- strcat(trial_name_str, name_str);
- TempNewSymbol trial_name = SymbolTable::probe(trial_name_str, trial_len);
- if (trial_name == NULL) {
- continue; // no such symbol, so this prefix wasn't used, try the next prefix
- }
- method = k->lookup_method(trial_name, signature);
- if (method == NULL) {
- continue; // signature doesn't match, try the next prefix
- }
- if (method->is_native()) {
- method->set_is_prefixed_native();
- return method; // wahoo, we found a prefixed version of the method, return it
- }
- // found as non-native, so prefix is good, add it, probably just need more prefixes
- name_len = trial_len;
- name_str = trial_name_str;
- }
-#endif // INCLUDE_JVMTI
- return NULL; // not found
-}
-
-static bool register_native(Klass* k, Symbol* name, Symbol* signature, address entry, TRAPS) {
- Method* method = k->lookup_method(name, signature);
- if (method == NULL) {
- ResourceMark rm;
- stringStream st;
- st.print("Method '");
- Method::print_external_name(&st, k, name, signature);
- st.print("' name or signature does not match");
- THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
- }
- if (!method->is_native()) {
- // trying to register to a non-native method, see if a JVM TI agent has added prefix(es)
- method = find_prefixed_native(k, name, signature, THREAD);
- if (method == NULL) {
- ResourceMark rm;
- stringStream st;
- st.print("Method '");
- Method::print_external_name(&st, k, name, signature);
- st.print("' is not declared as native");
- THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
- }
- }
-
- if (entry != NULL) {
- method->set_native_function(entry,
- Method::native_bind_event_is_interesting);
- } else {
- method->clear_native_function();
- }
- if (PrintJNIResolving) {
- ResourceMark rm(THREAD);
- tty->print_cr("[Registering JNI native method %s.%s]",
- method->method_holder()->external_name(),
- method->name()->as_C_string());
- }
- return true;
-}
-
DT_RETURN_MARK_DECL(RegisterNatives, jint
, HOTSPOT_JNI_REGISTERNATIVES_RETURN(_ret_ref));
@@ -3024,8 +2941,8 @@
THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), -1);
}
- bool res = register_native(k, name, signature,
- (address) methods[index].fnPtr, THREAD);
+ bool res = Method::register_native(k, name, signature,
+ (address) methods[index].fnPtr, THREAD);
if (!res) {
ret = -1;
break;
--- a/src/hotspot/share/prims/jniCheck.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/prims/jniCheck.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -266,7 +266,7 @@
/* check for proper subclass hierarchy */
JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fid);
Klass* f_oop = id->holder();
- if (!InstanceKlass::cast(k_oop)->is_subtype_of(f_oop))
+ if (!k_oop->is_subtype_of(f_oop))
ReportJNIFatalError(thr, fatal_wrong_static_field);
/* check for proper field type */
@@ -513,7 +513,7 @@
assert(klass != NULL, "klass argument must have a value");
if (!klass->is_instance_klass() ||
- !InstanceKlass::cast(klass)->is_subclass_of(SystemDictionary::Throwable_klass())) {
+ !klass->is_subclass_of(SystemDictionary::Throwable_klass())) {
ReportJNIFatalError(thr, fatal_class_not_a_throwable_class);
}
}
--- a/src/hotspot/share/prims/jvm.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/prims/jvm.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -38,6 +38,7 @@
#include "classfile/vmSymbols.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "interpreter/bytecode.hpp"
+#include "interpreter/bytecodeUtils.hpp"
#include "jfr/jfrEvents.hpp"
#include "logging/log.hpp"
#include "memory/heapShared.hpp"
@@ -531,13 +532,37 @@
// java.lang.Throwable //////////////////////////////////////////////////////
-
JVM_ENTRY(void, JVM_FillInStackTrace(JNIEnv *env, jobject receiver))
JVMWrapper("JVM_FillInStackTrace");
Handle exception(thread, JNIHandles::resolve_non_null(receiver));
java_lang_Throwable::fill_in_stack_trace(exception);
JVM_END
+// java.lang.NullPointerException ///////////////////////////////////////////
+
+JVM_ENTRY(jstring, JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable))
+ if (!ShowCodeDetailsInExceptionMessages) return NULL;
+
+ oop exc = JNIHandles::resolve_non_null(throwable);
+
+ Method* method;
+ int bci;
+ if (!java_lang_Throwable::get_top_method_and_bci(exc, &method, &bci)) {
+ return NULL;
+ }
+ if (method->is_native()) {
+ return NULL;
+ }
+
+ stringStream ss;
+ bool ok = BytecodeUtils::get_NPE_message_at(&ss, method, bci);
+ if (ok) {
+ oop result = java_lang_String::create_oop_from_str(ss.base(), CHECK_0);
+ return (jstring) JNIHandles::make_local(env, result);
+ } else {
+ return NULL;
+ }
+JVM_END
// java.lang.StackTraceElement //////////////////////////////////////////////
@@ -2283,7 +2308,7 @@
ConstantPool* cp = InstanceKlass::cast(k)->constants();
for (int index = cp->length() - 1; index >= 0; index--) {
constantTag tag = cp->tag_at(index);
- types[index] = (tag.is_unresolved_klass()) ? JVM_CONSTANT_Class : tag.value();
+ types[index] = (tag.is_unresolved_klass()) ? (unsigned char) JVM_CONSTANT_Class : tag.value();
}
}
JVM_END
--- a/src/hotspot/share/prims/jvmtiEnvBase.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1361,7 +1361,7 @@
NULL_CHECK(ob_k, JVMTI_ERROR_INVALID_OBJECT);
// Method return type signature.
- char* ty_sign = 1 + strchr(signature->as_C_string(), ')');
+ char* ty_sign = 1 + strchr(signature->as_C_string(), JVM_SIGNATURE_ENDFUNC);
if (!VM_GetOrSetLocal::is_assignable(ty_sign, ob_k, current_thread)) {
return JVMTI_ERROR_TYPE_MISMATCH;
--- a/src/hotspot/share/prims/jvmtiExport.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/prims/jvmtiExport.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1994,7 +1994,9 @@
address location, Klass* field_klass, Handle object, jfieldID field,
char sig_type, jvalue *value) {
- if (sig_type == 'I' || sig_type == 'Z' || sig_type == 'B' || sig_type == 'C' || sig_type == 'S') {
+ if (sig_type == JVM_SIGNATURE_INT || sig_type == JVM_SIGNATURE_BOOLEAN ||
+ sig_type == JVM_SIGNATURE_BYTE || sig_type == JVM_SIGNATURE_CHAR ||
+ sig_type == JVM_SIGNATURE_SHORT) {
// 'I' instructions are used for byte, char, short and int.
// determine which it really is, and convert
fieldDescriptor fd;
@@ -2005,22 +2007,22 @@
// convert value from int to appropriate type
switch (fd.field_type()) {
case T_BOOLEAN:
- sig_type = 'Z';
+ sig_type = JVM_SIGNATURE_BOOLEAN;
value->i = 0; // clear it
value->z = (jboolean)ival;
break;
case T_BYTE:
- sig_type = 'B';
+ sig_type = JVM_SIGNATURE_BYTE;
value->i = 0; // clear it
value->b = (jbyte)ival;
break;
case T_CHAR:
- sig_type = 'C';
+ sig_type = JVM_SIGNATURE_CHAR;
value->i = 0; // clear it
value->c = (jchar)ival;
break;
case T_SHORT:
- sig_type = 'S';
+ sig_type = JVM_SIGNATURE_SHORT;
value->i = 0; // clear it
value->s = (jshort)ival;
break;
@@ -2035,11 +2037,11 @@
}
}
- assert(sig_type != '[', "array should have sig_type == 'L'");
+ assert(sig_type != JVM_SIGNATURE_ARRAY, "array should have sig_type == 'L'");
bool handle_created = false;
// convert oop to JNI handle.
- if (sig_type == 'L') {
+ if (sig_type == JVM_SIGNATURE_CLASS) {
handle_created = true;
value->l = (jobject)JNIHandles::make_local(thread, (oop)value->l);
}
--- a/src/hotspot/share/prims/jvmtiImpl.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/prims/jvmtiImpl.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -588,7 +588,8 @@
assert(klass != NULL, "klass must not be NULL");
int len = (int) strlen(ty_sign);
- if (ty_sign[0] == 'L' && ty_sign[len-1] == ';') { // Need pure class/interface name
+ if (ty_sign[0] == JVM_SIGNATURE_CLASS &&
+ ty_sign[len-1] == JVM_SIGNATURE_ENDCLASS) { // Need pure class/interface name
ty_sign++;
len -= 2;
}
--- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -2166,14 +2166,14 @@
switch (tag) {
// These BaseType tag values are from Table 4.2 in VM spec:
- case 'B': // byte
- case 'C': // char
- case 'D': // double
- case 'F': // float
- case 'I': // int
- case 'J': // long
- case 'S': // short
- case 'Z': // boolean
+ case JVM_SIGNATURE_BYTE:
+ case JVM_SIGNATURE_CHAR:
+ case JVM_SIGNATURE_DOUBLE:
+ case JVM_SIGNATURE_FLOAT:
+ case JVM_SIGNATURE_INT:
+ case JVM_SIGNATURE_LONG:
+ case JVM_SIGNATURE_SHORT:
+ case JVM_SIGNATURE_BOOLEAN:
// The remaining tag values are from Table 4.8 in the 2nd-edition of
// the VM spec:
@@ -2244,7 +2244,7 @@
}
break;
- case '[':
+ case JVM_SIGNATURE_ARRAY:
{
if ((byte_i_ref + 2) > annotations_typeArray->length()) {
// not enough room for a num_values field
--- a/src/hotspot/share/prims/jvmtiTagMap.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/prims/jvmtiTagMap.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1032,7 +1032,7 @@
// helper function to tell if a field is a primitive field or not
static inline bool is_primitive_field_type(char type) {
- return (type != 'L' && type != '[');
+ return (type != JVM_SIGNATURE_CLASS && type != JVM_SIGNATURE_ARRAY);
}
// helper function to copy the value from location addr to jvalue.
--- a/src/hotspot/share/prims/methodHandles.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/prims/methodHandles.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -542,18 +542,22 @@
const int len = sig->utf8_length();
for (int i = 0; i < len; i++) {
switch (sig->char_at(i)) {
- case 'L':
+ case JVM_SIGNATURE_CLASS:
// only java/lang/Object is valid here
if (sig->index_of_at(i, OBJ_SIG, OBJ_SIG_LEN) != i)
return false;
i += OBJ_SIG_LEN-1; //-1 because of i++ in loop
continue;
- case '(': case ')': case 'V':
- case 'I': case 'J': case 'F': case 'D':
+ case JVM_SIGNATURE_FUNC:
+ case JVM_SIGNATURE_ENDFUNC:
+ case JVM_SIGNATURE_VOID:
+ case JVM_SIGNATURE_INT:
+ case JVM_SIGNATURE_LONG:
+ case JVM_SIGNATURE_FLOAT:
+ case JVM_SIGNATURE_DOUBLE:
continue;
- //case '[':
- //case 'Z': case 'B': case 'C': case 'S':
default:
+ // subword types (T_BYTE etc.), arrays
return false;
}
}
@@ -567,7 +571,7 @@
} else if (is_basic_type_signature(sig)) {
sig->increment_refcount();
return sig; // that was easy
- } else if (sig->char_at(0) != '(') {
+ } else if (sig->char_at(0) != JVM_SIGNATURE_FUNC) {
BasicType bt = char2type(sig->char_at(0));
if (is_subword_type(bt)) {
bsig = vmSymbols::int_signature();
@@ -578,7 +582,7 @@
} else {
ResourceMark rm;
stringStream buffer(128);
- buffer.put('(');
+ buffer.put(JVM_SIGNATURE_FUNC);
int arg_pos = 0, keep_arg_pos = -1;
if (keep_last_arg)
keep_arg_pos = ArgumentCount(sig).size() - 1;
@@ -586,7 +590,7 @@
BasicType bt = ss.type();
size_t this_arg_pos = buffer.size();
if (ss.at_return_type()) {
- buffer.put(')');
+ buffer.put(JVM_SIGNATURE_ENDFUNC);
}
if (arg_pos == keep_arg_pos) {
buffer.write((char*) ss.raw_bytes(),
@@ -621,25 +625,26 @@
for (int i = 0; i < len; i++) {
char ch = sig->char_at(i);
switch (ch) {
- case '(': case ')':
+ case JVM_SIGNATURE_FUNC:
+ case JVM_SIGNATURE_ENDFUNC:
prev_type = false;
st->put(ch);
continue;
- case '[':
+ case JVM_SIGNATURE_ARRAY:
if (!keep_basic_names && keep_arrays)
st->put(ch);
array++;
continue;
- case 'L':
+ case JVM_SIGNATURE_CLASS:
{
if (prev_type) st->put(',');
int start = i+1, slash = start;
- while (++i < len && (ch = sig->char_at(i)) != ';') {
- if (ch == '/' || ch == '.' || ch == '$') slash = i+1;
+ while (++i < len && (ch = sig->char_at(i)) != JVM_SIGNATURE_ENDCLASS) {
+ if (ch == JVM_SIGNATURE_SLASH || ch == JVM_SIGNATURE_DOT || ch == '$') slash = i+1;
}
if (slash < i) start = slash;
if (!keep_basic_names) {
- st->put('L');
+ st->put(JVM_SIGNATURE_CLASS);
} else {
for (int j = start; j < i; j++)
st->put(sig->char_at(j));
@@ -650,7 +655,7 @@
default:
{
if (array && char2type(ch) != T_ILLEGAL && !keep_arrays) {
- ch = '[';
+ ch = JVM_SIGNATURE_ARRAY;
array = 0;
}
if (prev_type) st->put(',');
@@ -978,7 +983,7 @@
}
if (sig != NULL) {
if (sig->utf8_length() == 0) return 0; // a match is not possible
- if (sig->char_at(0) == '(')
+ if (sig->char_at(0) == JVM_SIGNATURE_FUNC)
match_flags &= ~(IS_FIELD | IS_TYPE);
else
match_flags &= ~(IS_CONSTRUCTOR | IS_METHOD);
@@ -1456,7 +1461,7 @@
{
Symbol* type = caller->constants()->signature_ref_at(bss_index_in_pool);
Handle th;
- if (type->char_at(0) == '(') {
+ if (type->char_at(0) == JVM_SIGNATURE_FUNC) {
th = SystemDictionary::find_method_handle_type(type, caller, CHECK);
} else {
th = SystemDictionary::find_java_mirror_for_type(type, caller, SignatureStream::NCDFError, CHECK);
--- a/src/hotspot/share/prims/nativeLookup.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/prims/nativeLookup.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -106,7 +106,7 @@
st.print("__");
// find ')'
int end;
- for (end = 0; end < signature->utf8_length() && signature->char_at(end) != ')'; end++);
+ for (end = 0; end < signature->utf8_length() && signature->char_at(end) != JVM_SIGNATURE_ENDFUNC; end++);
// skip first '('
mangle_name_on(&st, signature, 1, end);
return st.as_string();
--- a/src/hotspot/share/runtime/arguments.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/runtime/arguments.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -548,6 +548,7 @@
{ "SharedMiscDataSize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
{ "SharedMiscCodeSize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
{ "CompilationPolicyChoice", JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::jdk(15) },
+ { "TraceNMethodInstalls", JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::jdk(15) },
{ "FailOverToOldVerifier", JDK_Version::undefined(), JDK_Version::jdk(14), JDK_Version::jdk(15) },
{ "BindGCTaskThreadsToCPUs", JDK_Version::undefined(), JDK_Version::jdk(14), JDK_Version::jdk(16) },
{ "UseGCTaskAffinity", JDK_Version::undefined(), JDK_Version::jdk(14), JDK_Version::jdk(16) },
@@ -593,7 +594,6 @@
{ "TraceSafepointCleanupTime", LogLevel::Info, true, LOG_TAGS(safepoint, cleanup) },
{ "TraceJVMTIObjectTagging", LogLevel::Debug, true, LOG_TAGS(jvmti, objecttagging) },
{ "TraceRedefineClasses", LogLevel::Info, false, LOG_TAGS(redefine, class) },
- { "TraceNMethodInstalls", LogLevel::Info, true, LOG_TAGS(nmethod, install) },
{ NULL, LogLevel::Off, false, LOG_TAGS(_NO_TAG) }
};
@@ -3968,6 +3968,11 @@
"Shared spaces are not supported in this VM\n");
return JNI_ERR;
}
+ if (DumpLoadedClassList != NULL) {
+ jio_fprintf(defaultStream::error_stream(),
+ "DumpLoadedClassList is not supported in this VM\n");
+ return JNI_ERR;
+ }
if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) ||
log_is_enabled(Info, cds)) {
warning("Shared spaces are not supported in this VM");
--- a/src/hotspot/share/runtime/deoptimization.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/runtime/deoptimization.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -295,7 +295,7 @@
// Reallocate the non-escaping objects and restore their fields. Then
// relock objects if synchronization on them was eliminated.
- if (jvmci_enabled || ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateAllocations)) {
+ if (jvmci_enabled || (DoEscapeAnalysis && EliminateAllocations)) {
realloc_failures = eliminate_allocations(thread, exec_mode, cm, deoptee, map, chunk);
}
#endif // COMPILER2_OR_JVMCI
--- a/src/hotspot/share/runtime/fieldType.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/runtime/fieldType.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -39,28 +39,28 @@
// Check if it is a valid array signature
bool FieldType::is_valid_array_signature(Symbol* sig) {
assert(sig->utf8_length() > 1, "this should already have been checked");
- assert(sig->char_at(0) == '[', "this should already have been checked");
+ assert(sig->char_at(0) == JVM_SIGNATURE_ARRAY, "this should already have been checked");
// The first character is already checked
int i = 1;
int len = sig->utf8_length();
// First skip all '['s
- while(i < len - 1 && sig->char_at(i) == '[') i++;
+ while(i < len - 1 && sig->char_at(i) == JVM_SIGNATURE_ARRAY) i++;
// Check type
switch(sig->char_at(i)) {
- case 'B': // T_BYTE
- case 'C': // T_CHAR
- case 'D': // T_DOUBLE
- case 'F': // T_FLOAT
- case 'I': // T_INT
- case 'J': // T_LONG
- case 'S': // T_SHORT
- case 'Z': // T_BOOLEAN
+ case JVM_SIGNATURE_BYTE:
+ case JVM_SIGNATURE_CHAR:
+ case JVM_SIGNATURE_DOUBLE:
+ case JVM_SIGNATURE_FLOAT:
+ case JVM_SIGNATURE_INT:
+ case JVM_SIGNATURE_LONG:
+ case JVM_SIGNATURE_SHORT:
+ case JVM_SIGNATURE_BOOLEAN:
// If it is an array, the type is the last character
return (i + 1 == len);
- case 'L':
+ case JVM_SIGNATURE_CLASS:
// If it is an object, the last character must be a ';'
- return sig->char_at(len - 1) == ';';
+ return sig->char_at(len - 1) == JVM_SIGNATURE_ENDCLASS;
}
return false;
@@ -71,7 +71,7 @@
assert(basic_type(signature) == T_ARRAY, "must be array");
int index = 1;
int dim = 1;
- while (signature->char_at(index) == '[') {
+ while (signature->char_at(index) == JVM_SIGNATURE_ARRAY) {
index++;
dim++;
}
@@ -80,7 +80,7 @@
BasicType element_type = char2type(element[0]);
if (element_type == T_OBJECT) {
int len = (int)strlen(element);
- assert(element[len-1] == ';', "last char should be a semicolon");
+ assert(element[len-1] == JVM_SIGNATURE_ENDCLASS, "last char should be a semicolon");
element[len-1] = '\0'; // chop off semicolon
fd._object_key = SymbolTable::new_symbol(element + 1);
}
--- a/src/hotspot/share/runtime/fieldType.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/runtime/fieldType.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -58,14 +58,16 @@
static BasicType basic_type(Symbol* signature);
// Testing
- static bool is_array(Symbol* signature) { return signature->utf8_length() > 1 && signature->char_at(0) == '[' && is_valid_array_signature(signature); }
+ static bool is_array(Symbol* signature) { return signature->utf8_length() > 1 &&
+ signature->char_at(0) == JVM_SIGNATURE_ARRAY &&
+ is_valid_array_signature(signature); }
static bool is_obj(Symbol* signature) {
int sig_length = signature->utf8_length();
// Must start with 'L' and end with ';'
return (sig_length >= 2 &&
- (signature->char_at(0) == 'L') &&
- (signature->char_at(sig_length - 1) == ';'));
+ (signature->char_at(0) == JVM_SIGNATURE_CLASS) &&
+ (signature->char_at(sig_length - 1) == JVM_SIGNATURE_ENDCLASS));
}
// Parse field and extract array information. Works for T_ARRAY only.
--- a/src/hotspot/share/runtime/globals.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/runtime/globals.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -563,9 +563,6 @@
product(bool, PrintExtendedThreadInfo, false, \
"Print more information in thread dump") \
\
- diagnostic(bool, TraceNMethodInstalls, false, \
- "Trace nmethod installation") \
- \
diagnostic(intx, ScavengeRootsInCode, 2, \
"0: do not allow scavengable oops in the code cache; " \
"1: allow scavenging from the code cache; " \
@@ -643,6 +640,10 @@
product(bool, OmitStackTraceInFastThrow, true, \
"Omit backtraces for some 'hot' exceptions in optimized code") \
\
+ manageable(bool, ShowCodeDetailsInExceptionMessages, false, \
+ "Show exception messages from RuntimeExceptions that contain " \
+ "snippets of the failing code. Disable this to improve privacy.") \
+ \
product(bool, PrintWarnings, true, \
"Print JVM warnings to output stream") \
\
--- a/src/hotspot/share/runtime/mutexLocker.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/runtime/mutexLocker.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -312,7 +312,7 @@
#if INCLUDE_JFR
def(JfrMsg_lock , PaddedMonitor, leaf, true, _safepoint_check_always);
def(JfrBuffer_lock , PaddedMutex , leaf, true, _safepoint_check_never);
- def(JfrStream_lock , PaddedMutex , leaf+1, true, _safepoint_check_never); // ensure to rank lower than 'safepoint'
+ def(JfrStream_lock , PaddedMutex , nonleaf + 1, false, _safepoint_check_always);
def(JfrStacktrace_lock , PaddedMutex , special, true, _safepoint_check_never);
def(JfrThreadSampler_lock , PaddedMonitor, leaf, true, _safepoint_check_never);
#endif
@@ -334,12 +334,12 @@
#if INCLUDE_JVMTI
def(CDSClassFileStream_lock , PaddedMutex , max_nonleaf, false, _safepoint_check_always);
#endif
+ def(DumpTimeTable_lock , PaddedMutex , leaf, true, _safepoint_check_never);
+#endif // INCLUDE_CDS
#if INCLUDE_JVMCI
def(JVMCI_lock , PaddedMonitor, nonleaf+2, true, _safepoint_check_always);
#endif
- def(DumpTimeTable_lock , PaddedMutex , leaf, true, _safepoint_check_never);
-#endif // INCLUDE_CDS
}
GCMutexLocker::GCMutexLocker(Mutex* mutex) {
--- a/src/hotspot/share/runtime/os.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/runtime/os.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -47,8 +47,6 @@
// OS services (time, I/O) as well as other functionality with system-
// dependent code.
-typedef void (*dll_func)(...);
-
class Thread;
class JavaThread;
class NativeCallStack;
@@ -195,14 +193,9 @@
// The "virtual time" of a thread is the amount of time a thread has
// actually run. The first function indicates whether the OS supports
- // this functionality for the current thread, and if so:
- // * the second enables vtime tracking (if that is required).
- // * the third tells whether vtime is enabled.
- // * the fourth returns the elapsed virtual time for the current
- // thread.
+ // this functionality for the current thread, and if so the second
+ // returns the elapsed virtual time for the current thread.
static bool supports_vtime();
- static bool enable_vtime();
- static bool vtime_enabled();
static double elapsedVTime();
// Return current local time in a string (YYYY-MM-DD HH:MM:SS).
@@ -254,14 +247,6 @@
return _initial_active_processor_count;
}
- // Bind processes to processors.
- // This is a two step procedure:
- // first you generate a distribution of processes to processors,
- // then you bind processes according to that distribution.
- // Compute a distribution for number of processes to processors.
- // Stores the processor id's into the distribution array argument.
- // Returns true if it worked, false if it didn't.
- static bool distribute_processes(uint length, uint* distribution);
// Binds the current process to a processor.
// Returns true if it worked, false if it didn't.
static bool bind_to_processor(uint processor_id);
@@ -496,7 +481,6 @@
static void verify_stack_alignment() PRODUCT_RETURN;
static bool message_box(const char* title, const char* message);
- static char* do_you_want_to_debug(const char* message);
// run cmd in a separate process and return its exit code; or -1 on failures
static int fork_and_exec(char *cmd, bool use_vfork_if_available = false);
@@ -520,7 +504,6 @@
static void die();
// File i/o operations
- static const int default_file_open_flags();
static int open(const char *path, int oflag, int mode);
static FILE* open(int fd, const char* mode);
static FILE* fopen(const char* path, const char* mode);
@@ -668,9 +651,6 @@
// Will not change the value of errno.
static const char* errno_name(int e);
- // Determines whether the calling process is being debugged by a user-mode debugger.
- static bool is_debugger_attached();
-
// wait for a key press if PauseAtExit is set
static void wait_for_keypress_at_exit(void);
@@ -966,10 +946,6 @@
return _state == SR_RUNNING;
}
- bool is_suspend_request() const {
- return _state == SR_SUSPEND_REQUEST;
- }
-
bool is_suspended() const {
return _state == SR_SUSPENDED;
}
--- a/src/hotspot/share/runtime/sharedRuntime.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -2990,28 +2990,28 @@
sig_bt[cnt++] = T_OBJECT; // Receiver is argument 0; not in signature
}
- while (*s != ')') { // Find closing right paren
- switch (*s++) { // Switch on signature character
- case 'B': sig_bt[cnt++] = T_BYTE; break;
- case 'C': sig_bt[cnt++] = T_CHAR; break;
- case 'D': sig_bt[cnt++] = T_DOUBLE; sig_bt[cnt++] = T_VOID; break;
- case 'F': sig_bt[cnt++] = T_FLOAT; break;
- case 'I': sig_bt[cnt++] = T_INT; break;
- case 'J': sig_bt[cnt++] = T_LONG; sig_bt[cnt++] = T_VOID; break;
- case 'S': sig_bt[cnt++] = T_SHORT; break;
- case 'Z': sig_bt[cnt++] = T_BOOLEAN; break;
- case 'V': sig_bt[cnt++] = T_VOID; break;
- case 'L': // Oop
- while (*s++ != ';'); // Skip signature
+ while (*s != JVM_SIGNATURE_ENDFUNC) { // Find closing right paren
+ switch (*s++) { // Switch on signature character
+ case JVM_SIGNATURE_BYTE: sig_bt[cnt++] = T_BYTE; break;
+ case JVM_SIGNATURE_CHAR: sig_bt[cnt++] = T_CHAR; break;
+ case JVM_SIGNATURE_DOUBLE: sig_bt[cnt++] = T_DOUBLE; sig_bt[cnt++] = T_VOID; break;
+ case JVM_SIGNATURE_FLOAT: sig_bt[cnt++] = T_FLOAT; break;
+ case JVM_SIGNATURE_INT: sig_bt[cnt++] = T_INT; break;
+ case JVM_SIGNATURE_LONG: sig_bt[cnt++] = T_LONG; sig_bt[cnt++] = T_VOID; break;
+ case JVM_SIGNATURE_SHORT: sig_bt[cnt++] = T_SHORT; break;
+ case JVM_SIGNATURE_BOOLEAN: sig_bt[cnt++] = T_BOOLEAN; break;
+ case JVM_SIGNATURE_VOID: sig_bt[cnt++] = T_VOID; break;
+ case JVM_SIGNATURE_CLASS: // Oop
+ while (*s++ != JVM_SIGNATURE_ENDCLASS); // Skip signature
sig_bt[cnt++] = T_OBJECT;
break;
- case '[': { // Array
+ case JVM_SIGNATURE_ARRAY: { // Array
do { // Skip optional size
while (*s >= '0' && *s <= '9') s++;
- } while (*s++ == '['); // Nested arrays?
+ } while (*s++ == JVM_SIGNATURE_ARRAY); // Nested arrays?
// Skip element type
- if (s[-1] == 'L')
- while (*s++ != ';'); // Skip signature
+ if (s[-1] == JVM_SIGNATURE_CLASS)
+ while (*s++ != JVM_SIGNATURE_ENDCLASS); // Skip signature
sig_bt[cnt++] = T_ARRAY;
break;
}
--- a/src/hotspot/share/runtime/signature.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/runtime/signature.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -63,41 +63,41 @@
// compiler bug (was problem - gri 4/27/2000).
int size = -1;
switch(_signature->char_at(_index)) {
- case 'B': do_byte (); if (_parameter_index < 0 ) _return_type = T_BYTE;
- _index++; size = T_BYTE_size ; break;
- case 'C': do_char (); if (_parameter_index < 0 ) _return_type = T_CHAR;
- _index++; size = T_CHAR_size ; break;
- case 'D': do_double(); if (_parameter_index < 0 ) _return_type = T_DOUBLE;
- _index++; size = T_DOUBLE_size ; break;
- case 'F': do_float (); if (_parameter_index < 0 ) _return_type = T_FLOAT;
- _index++; size = T_FLOAT_size ; break;
- case 'I': do_int (); if (_parameter_index < 0 ) _return_type = T_INT;
- _index++; size = T_INT_size ; break;
- case 'J': do_long (); if (_parameter_index < 0 ) _return_type = T_LONG;
- _index++; size = T_LONG_size ; break;
- case 'S': do_short (); if (_parameter_index < 0 ) _return_type = T_SHORT;
- _index++; size = T_SHORT_size ; break;
- case 'Z': do_bool (); if (_parameter_index < 0 ) _return_type = T_BOOLEAN;
- _index++; size = T_BOOLEAN_size; break;
- case 'V': do_void (); if (_parameter_index < 0 ) _return_type = T_VOID;
- _index++; size = T_VOID_size; ; break;
- case 'L':
+ case JVM_SIGNATURE_BYTE: do_byte(); if (_parameter_index < 0 ) _return_type = T_BYTE;
+ _index++; size = T_BYTE_size; break;
+ case JVM_SIGNATURE_CHAR: do_char(); if (_parameter_index < 0 ) _return_type = T_CHAR;
+ _index++; size = T_CHAR_size; break;
+ case JVM_SIGNATURE_DOUBLE: do_double(); if (_parameter_index < 0 ) _return_type = T_DOUBLE;
+ _index++; size = T_DOUBLE_size; break;
+ case JVM_SIGNATURE_FLOAT: do_float(); if (_parameter_index < 0 ) _return_type = T_FLOAT;
+ _index++; size = T_FLOAT_size; break;
+ case JVM_SIGNATURE_INT: do_int(); if (_parameter_index < 0 ) _return_type = T_INT;
+ _index++; size = T_INT_size; break;
+ case JVM_SIGNATURE_LONG: do_long(); if (_parameter_index < 0 ) _return_type = T_LONG;
+ _index++; size = T_LONG_size; break;
+ case JVM_SIGNATURE_SHORT: do_short(); if (_parameter_index < 0 ) _return_type = T_SHORT;
+ _index++; size = T_SHORT_size; break;
+ case JVM_SIGNATURE_BOOLEAN: do_bool(); if (_parameter_index < 0 ) _return_type = T_BOOLEAN;
+ _index++; size = T_BOOLEAN_size; break;
+ case JVM_SIGNATURE_VOID: do_void(); if (_parameter_index < 0 ) _return_type = T_VOID;
+ _index++; size = T_VOID_size; break;
+ case JVM_SIGNATURE_CLASS:
{ int begin = ++_index;
Symbol* sig = _signature;
- while (sig->char_at(_index++) != ';') ;
+ while (sig->char_at(_index++) != JVM_SIGNATURE_ENDCLASS) ;
do_object(begin, _index);
}
if (_parameter_index < 0 ) _return_type = T_OBJECT;
size = T_OBJECT_size;
break;
- case '[':
+ case JVM_SIGNATURE_ARRAY:
{ int begin = ++_index;
Symbol* sig = _signature;
- while (sig->char_at(_index) == '[') {
+ while (sig->char_at(_index) == JVM_SIGNATURE_ARRAY) {
_index++;
}
- if (sig->char_at(_index) == 'L') {
- while (sig->char_at(_index++) != ';') ;
+ if (sig->char_at(_index) == JVM_SIGNATURE_CLASS) {
+ while (sig->char_at(_index++) != JVM_SIGNATURE_ENDCLASS) ;
} else {
_index++;
}
@@ -128,9 +128,9 @@
// Parse parameters
_index = 0;
_parameter_index = 0;
- expect('(');
- while (_signature->char_at(_index) != ')') _parameter_index += parse_type();
- expect(')');
+ expect(JVM_SIGNATURE_FUNC);
+ while (_signature->char_at(_index) != JVM_SIGNATURE_ENDFUNC) _parameter_index += parse_type();
+ expect(JVM_SIGNATURE_ENDFUNC);
_parameter_index = 0;
}
@@ -202,36 +202,36 @@
void SignatureIterator::iterate_returntype() {
// Ignore parameters
_index = 0;
- expect('(');
+ expect(JVM_SIGNATURE_FUNC);
Symbol* sig = _signature;
// Need to skip over each type in the signature's argument list until a
// closing ')' is found., then get the return type. We cannot just scan
// for the first ')' because ')' is a legal character in a type name.
- while (sig->char_at(_index) != ')') {
+ while (sig->char_at(_index) != JVM_SIGNATURE_ENDFUNC) {
switch(sig->char_at(_index)) {
- case 'B':
- case 'C':
- case 'D':
- case 'F':
- case 'I':
- case 'J':
- case 'S':
- case 'Z':
- case 'V':
+ case JVM_SIGNATURE_BYTE:
+ case JVM_SIGNATURE_CHAR:
+ case JVM_SIGNATURE_DOUBLE:
+ case JVM_SIGNATURE_FLOAT:
+ case JVM_SIGNATURE_INT:
+ case JVM_SIGNATURE_LONG:
+ case JVM_SIGNATURE_SHORT:
+ case JVM_SIGNATURE_BOOLEAN:
+ case JVM_SIGNATURE_VOID:
{
_index++;
}
break;
- case 'L':
+ case JVM_SIGNATURE_CLASS:
{
- while (sig->char_at(_index++) != ';') ;
+ while (sig->char_at(_index++) != JVM_SIGNATURE_ENDCLASS) ;
}
break;
- case '[':
+ case JVM_SIGNATURE_ARRAY:
{
- while (sig->char_at(++_index) == '[') ;
- if (sig->char_at(_index) == 'L') {
- while (sig->char_at(_index++) != ';') ;
+ while (sig->char_at(++_index) == JVM_SIGNATURE_ARRAY) ;
+ if (sig->char_at(_index) == JVM_SIGNATURE_CLASS) {
+ while (sig->char_at(_index++) != JVM_SIGNATURE_ENDCLASS) ;
} else {
_index++;
}
@@ -242,7 +242,7 @@
break;
}
}
- expect(')');
+ expect(JVM_SIGNATURE_ENDFUNC);
// Parse return type
_parameter_index = -1;
parse_type();
@@ -255,9 +255,9 @@
// Parse parameters
_parameter_index = 0;
_index = 0;
- expect('(');
- while (_signature->char_at(_index) != ')') _parameter_index += parse_type();
- expect(')');
+ expect(JVM_SIGNATURE_FUNC);
+ while (_signature->char_at(_index) != JVM_SIGNATURE_ENDFUNC) _parameter_index += parse_type();
+ expect(JVM_SIGNATURE_ENDFUNC);
// Parse return type
_parameter_index = -1;
parse_type();
@@ -289,39 +289,39 @@
void SignatureStream::next_non_primitive(int t) {
switch (t) {
- case 'L': {
+ case JVM_SIGNATURE_CLASS: {
_type = T_OBJECT;
Symbol* sig = _signature;
- while (sig->char_at(_end++) != ';');
+ while (sig->char_at(_end++) != JVM_SIGNATURE_ENDCLASS);
break;
}
- case '[': {
+ case JVM_SIGNATURE_ARRAY: {
_type = T_ARRAY;
Symbol* sig = _signature;
char c = sig->char_at(_end);
while ('0' <= c && c <= '9') c = sig->char_at(_end++);
- while (sig->char_at(_end) == '[') {
+ while (sig->char_at(_end) == JVM_SIGNATURE_ARRAY) {
_end++;
c = sig->char_at(_end);
while ('0' <= c && c <= '9') c = sig->char_at(_end++);
}
switch(sig->char_at(_end)) {
- case 'B':
- case 'C':
- case 'D':
- case 'F':
- case 'I':
- case 'J':
- case 'S':
- case 'Z':_end++; break;
+ case JVM_SIGNATURE_BYTE:
+ case JVM_SIGNATURE_CHAR:
+ case JVM_SIGNATURE_DOUBLE:
+ case JVM_SIGNATURE_FLOAT:
+ case JVM_SIGNATURE_INT:
+ case JVM_SIGNATURE_LONG:
+ case JVM_SIGNATURE_SHORT:
+ case JVM_SIGNATURE_BOOLEAN:_end++; break;
default: {
- while (sig->char_at(_end++) != ';');
+ while (sig->char_at(_end++) != JVM_SIGNATURE_ENDCLASS);
break;
}
}
break;
}
- case ')': _end++; next(); _at_return_type = true; break;
+ case JVM_SIGNATURE_ENDFUNC: _end++; next(); _at_return_type = true; break;
default : ShouldNotReachHere();
}
}
@@ -341,8 +341,8 @@
int begin = _begin;
int end = _end;
- if ( _signature->char_at(_begin) == 'L'
- && _signature->char_at(_end-1) == ';') {
+ if ( _signature->char_at(_begin) == JVM_SIGNATURE_CLASS
+ && _signature->char_at(_end-1) == JVM_SIGNATURE_ENDCLASS) {
begin++;
end--;
}
@@ -407,8 +407,8 @@
int begin = _begin;
int end = _end;
- if ( _signature->char_at(_begin) == 'L'
- && _signature->char_at(_end-1) == ';') {
+ if ( _signature->char_at(_begin) == JVM_SIGNATURE_CLASS
+ && _signature->char_at(_end-1) == JVM_SIGNATURE_ENDCLASS) {
begin++;
end--;
}
@@ -436,9 +436,9 @@
const char* method_sig = (const char*)sig->bytes();
ssize_t len = sig->utf8_length();
ssize_t index = 0;
- if (method_sig != NULL && len > 1 && method_sig[index] == '(') {
+ if (method_sig != NULL && len > 1 && method_sig[index] == JVM_SIGNATURE_FUNC) {
++index;
- while (index < len && method_sig[index] != ')') {
+ while (index < len && method_sig[index] != JVM_SIGNATURE_ENDFUNC) {
ssize_t res = is_valid_type(&method_sig[index], len - index);
if (res == -1) {
return false;
@@ -446,7 +446,7 @@
index += res;
}
}
- if (index < len && method_sig[index] == ')') {
+ if (index < len && method_sig[index] == JVM_SIGNATURE_ENDFUNC) {
// check the return type
++index;
return (is_valid_type(&method_sig[index], len - index) == (len - index));
@@ -469,21 +469,28 @@
ssize_t index = 0;
// Iterate over any number of array dimensions
- while (index < limit && type[index] == '[') ++index;
+ while (index < limit && type[index] == JVM_SIGNATURE_ARRAY) ++index;
if (index >= limit) {
return -1;
}
switch (type[index]) {
- case 'B': case 'C': case 'D': case 'F': case 'I':
- case 'J': case 'S': case 'Z': case 'V':
+ case JVM_SIGNATURE_BYTE:
+ case JVM_SIGNATURE_CHAR:
+ case JVM_SIGNATURE_DOUBLE:
+ case JVM_SIGNATURE_FLOAT:
+ case JVM_SIGNATURE_INT:
+ case JVM_SIGNATURE_LONG:
+ case JVM_SIGNATURE_SHORT:
+ case JVM_SIGNATURE_BOOLEAN:
+ case JVM_SIGNATURE_VOID:
return index + 1;
- case 'L':
+ case JVM_SIGNATURE_CLASS:
for (index = index + 1; index < limit; ++index) {
char c = type[index];
switch (c) {
- case ';':
+ case JVM_SIGNATURE_ENDCLASS:
return index + 1;
- case '\0': case '.': case '[':
+ case '\0': case JVM_SIGNATURE_DOT: case JVM_SIGNATURE_ARRAY:
return -1;
default: ; // fall through
}
--- a/src/hotspot/share/runtime/signature.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/runtime/signature.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -379,15 +379,15 @@
_begin = _end;
int t = sig->char_at(_begin);
switch (t) {
- case 'B': _type = T_BYTE; break;
- case 'C': _type = T_CHAR; break;
- case 'D': _type = T_DOUBLE; break;
- case 'F': _type = T_FLOAT; break;
- case 'I': _type = T_INT; break;
- case 'J': _type = T_LONG; break;
- case 'S': _type = T_SHORT; break;
- case 'Z': _type = T_BOOLEAN; break;
- case 'V': _type = T_VOID; break;
+ case JVM_SIGNATURE_BYTE: _type = T_BYTE; break;
+ case JVM_SIGNATURE_CHAR: _type = T_CHAR; break;
+ case JVM_SIGNATURE_DOUBLE: _type = T_DOUBLE; break;
+ case JVM_SIGNATURE_FLOAT: _type = T_FLOAT; break;
+ case JVM_SIGNATURE_INT: _type = T_INT; break;
+ case JVM_SIGNATURE_LONG: _type = T_LONG; break;
+ case JVM_SIGNATURE_SHORT: _type = T_SHORT; break;
+ case JVM_SIGNATURE_BOOLEAN: _type = T_BOOLEAN; break;
+ case JVM_SIGNATURE_VOID: _type = T_VOID; break;
default : next_non_primitive(t);
return;
}
--- a/src/hotspot/share/services/diagnosticArgument.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/services/diagnosticArgument.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -151,7 +151,13 @@
ResourceMark rm;
char* buf = NEW_RESOURCE_ARRAY(char, len + 1);
+
+PRAGMA_DIAG_PUSH
+PRAGMA_STRINGOP_TRUNCATION_IGNORED
+ // This code can incorrectly cause a "stringop-truncation" warning with gcc
strncpy(buf, str, len);
+PRAGMA_DIAG_POP
+
buf[len] = '\0';
Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(),
"Boolean parsing error in command argument '%s'. Could not parse: %s.\n", _name, buf);
--- a/src/hotspot/share/utilities/compilerWarnings.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/utilities/compilerWarnings.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -62,4 +62,8 @@
#define PRAGMA_FORMAT_IGNORED
#endif
+#ifndef PRAGMA_STRINGOP_TRUNCATION_IGNORED
+#define PRAGMA_STRINGOP_TRUNCATION_IGNORED
+#endif
+
#endif // SHARE_UTILITIES_COMPILERWARNINGS_HPP
--- a/src/hotspot/share/utilities/compilerWarnings_gcc.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/utilities/compilerWarnings_gcc.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -50,6 +50,12 @@
#define PRAGMA_FORMAT_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wformat")
+// Disable -Wstringop-truncation which is introduced in GCC 8.
+// https://gcc.gnu.org/gcc-8/changes.html
+#if !defined(__clang_major__) && (__GNUC__ >= 8)
+#define PRAGMA_STRINGOP_TRUNCATION_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-truncation")
+#endif
+
#if defined(__clang_major__) && \
(__clang_major__ >= 4 || \
(__clang_major__ >= 3 && __clang_minor__ >= 1)) || \
--- a/src/hotspot/share/utilities/globalDefinitions.cpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/utilities/globalDefinitions.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, 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
@@ -178,7 +178,16 @@
// Map BasicType to signature character
-char type2char_tab[T_CONFLICT+1]={ 0, 0, 0, 0, 'Z', 'C', 'F', 'D', 'B', 'S', 'I', 'J', 'L', '[', 'V', 0, 0, 0, 0, 0};
+char type2char_tab[T_CONFLICT+1] = {
+ 0, 0, 0, 0,
+ JVM_SIGNATURE_BOOLEAN, JVM_SIGNATURE_CHAR,
+ JVM_SIGNATURE_FLOAT, JVM_SIGNATURE_DOUBLE,
+ JVM_SIGNATURE_BYTE, JVM_SIGNATURE_SHORT,
+ JVM_SIGNATURE_INT, JVM_SIGNATURE_LONG,
+ JVM_SIGNATURE_CLASS, JVM_SIGNATURE_ARRAY,
+ JVM_SIGNATURE_VOID, 0,
+ 0, 0, 0, 0
+};
// Map BasicType to Java type name
const char* type2name_tab[T_CONFLICT+1] = {
--- a/src/hotspot/share/utilities/globalDefinitions.hpp Sat Oct 26 23:59:51 2019 +0200
+++ b/src/hotspot/share/utilities/globalDefinitions.hpp Mon Oct 28 18:43:04 2019 +0100
@@ -29,6 +29,9 @@
#include "utilities/debug.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)
// Defaults for macros that might be defined per compiler.
@@ -570,14 +573,22 @@
// NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
enum BasicType {
- T_BOOLEAN = 4,
- T_CHAR = 5,
- T_FLOAT = 6,
- T_DOUBLE = 7,
- T_BYTE = 8,
- T_SHORT = 9,
- T_INT = 10,
- T_LONG = 11,
+// The values T_BOOLEAN..T_LONG (4..11) are derived from the JVMS.
+ T_BOOLEAN = JVM_T_BOOLEAN,
+ T_CHAR = JVM_T_CHAR,
+ T_FLOAT = JVM_T_FLOAT,
+ T_DOUBLE = JVM_T_DOUBLE,
+ T_BYTE = JVM_T_BYTE,
+ T_SHORT = JVM_T_SHORT,
+ T_INT = JVM_T_INT,
+ T_LONG = JVM_T_LONG,
+ // The remaining values are not part of any standard.
+ // T_OBJECT and T_VOID denote two more semantic choices
+ // for method return values.
+ // T_OBJECT and T_ARRAY describe signature syntax.
+ // T_ADDRESS, T_METADATA, T_NARROWOOP, T_NARROWKLASS describe
+ // internal references within the JVM as if they were Java
+ // types in their own right.
T_OBJECT = 12,
T_ARRAY = 13,
T_VOID = 14,
@@ -602,6 +613,10 @@
return (t == T_BYTE || t == T_SHORT);
}
+inline bool is_double_word_type(BasicType t) {
+ return (t == T_DOUBLE || t == T_LONG);
+}
+
inline bool is_reference_type(BasicType t) {
return (t == T_OBJECT || t == T_ARRAY);
}
@@ -609,17 +624,17 @@
// Convert a char from a classfile signature to a BasicType
inline BasicType char2type(char c) {
switch( c ) {
- case 'B': return T_BYTE;
- case 'C': return T_CHAR;
- case 'D': return T_DOUBLE;
- case 'F': return T_FLOAT;
- case 'I': return T_INT;
- case 'J': return T_LONG;
- case 'S': return T_SHORT;
- case 'Z': return T_BOOLEAN;
- case 'V': return T_VOID;
- case 'L': return T_OBJECT;
- case '[': return T_ARRAY;
+ case JVM_SIGNATURE_BYTE: return T_BYTE;
+ case JVM_SIGNATURE_CHAR: return T_CHAR;
+ case JVM_SIGNATURE_DOUBLE: return T_DOUBLE;
+ case JVM_SIGNATURE_FLOAT: return T_FLOAT;
+ case JVM_SIGNATURE_INT: return T_INT;
+ case JVM_SIGNATURE_LONG: return T_LONG;
+ case JVM_SIGNATURE_SHORT: return T_SHORT;
+ case JVM_SIGNATURE_BOOLEAN: return T_BOOLEAN;
+ case JVM_SIGNATURE_VOID: return T_VOID;
+ case JVM_SIGNATURE_CLASS: return T_OBJECT;
+ case JVM_SIGNATURE_ARRAY: return T_ARRAY;
}
return T_ILLEGAL;
}
--- a/src/java.base/share/classes/java/io/FilePermission.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/io/FilePermission.java Mon Oct 28 18:43:04 2019 +0100
@@ -480,9 +480,9 @@
* @param path the pathname of the file/directory.
* @param actions the action string.
*
- * @throws IllegalArgumentException
- * If actions is {@code null}, empty or contains an action
- * other than the specified possible actions.
+ * @throws IllegalArgumentException if actions is {@code null}, empty,
+ * malformed or contains an action other than the specified
+ * possible actions
*/
public FilePermission(String path, String actions) {
super(path);
@@ -935,17 +935,18 @@
}
// make sure we didn't just match the tail of a word
- // like "ackbarfaccept". Also, skip to the comma.
+ // like "ackbarfdelete". Also, skip to the comma.
boolean seencomma = false;
while (i >= matchlen && !seencomma) {
- switch(a[i-matchlen]) {
- case ',':
- seencomma = true;
- break;
+ switch (c = a[i-matchlen]) {
case ' ': case '\r': case '\n':
case '\f': case '\t':
break;
default:
+ if (c == ',' && i > matchlen) {
+ seencomma = true;
+ break;
+ }
throw new IllegalArgumentException(
"invalid permission: " + actions);
}
@@ -1141,10 +1142,10 @@
*
* @param permission the Permission object to add.
*
- * @throws IllegalArgumentException - if the permission is not a
+ * @throws IllegalArgumentException if the permission is not a
* FilePermission
*
- * @throws SecurityException - if this FilePermissionCollection object
+ * @throws SecurityException if this FilePermissionCollection object
* has been marked readonly
*/
@Override
--- a/src/java.base/share/classes/java/lang/NullPointerException.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/lang/NullPointerException.java Mon Oct 28 18:43:04 2019 +0100
@@ -70,4 +70,35 @@
public NullPointerException(String s) {
super(s);
}
+
+ /**
+ * Returns the detail message string of this throwable.
+ *
+ * <p> If a non-null message was supplied in a constructor it is
+ * returned. Otherwise, an implementation specific message or
+ * {@code null} is returned.
+ *
+ * @implNote
+ * If no explicit message was passed to the constructor, and as
+ * long as certain internal information is available, a verbose
+ * description of the null reference is returned.
+ * The internal information is not available in deserialized
+ * NullPointerExceptions.
+ *
+ * @return the detail message string, which may be {@code null}.
+ */
+ public String getMessage() {
+ String message = super.getMessage();
+ if (message == null) {
+ return getExtendedNPEMessage();
+ }
+ return message;
+ }
+
+ /**
+ * Get an extended exception message. This returns a string describing
+ * the location and cause of the exception. It returns null for
+ * exceptions where this is not applicable.
+ */
+ private native String getExtendedNPEMessage();
}
--- a/src/java.base/share/classes/java/lang/Object.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/lang/Object.java Mon Oct 28 18:43:04 2019 +0100
@@ -38,11 +38,6 @@
*/
public class Object {
- private static native void registerNatives();
- static {
- registerNatives();
- }
-
/**
* Constructs a new object.
*/
--- a/src/java.base/share/classes/java/lang/String.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/lang/String.java Mon Oct 28 18:43:04 2019 +0100
@@ -2888,6 +2888,15 @@
}
/**
+ * {@preview Associated with text blocks, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>text blocks</i>, a preview
+ * feature of the Java language. Programs can only use this
+ * method when preview features are enabled. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* Returns a string whose value is this string, with incidental
* {@linkplain Character#isWhitespace(int) white space} removed from
* the beginning and end of every line.
@@ -2963,10 +2972,9 @@
*
* @since 13
*
- * @deprecated This method is associated with text blocks, a preview language feature.
- * Text blocks and/or this method may be changed or removed in a future release.
*/
- @Deprecated(forRemoval=true, since="13")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.TEXT_BLOCKS,
+ essentialAPI=true)
public String stripIndent() {
int length = length();
if (length == 0) {
@@ -3005,6 +3013,15 @@
}
/**
+ * {@preview Associated with text blocks, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>text blocks</i>, a preview
+ * feature of the Java language. Programs can only use this
+ * method when preview features are enabled. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* Returns a string whose value is this string, with escape sequences
* translated as if in a string literal.
* <p>
@@ -3079,11 +3096,9 @@
* @jls 3.10.7 Escape Sequences
*
* @since 13
- *
- * @deprecated This method is associated with text blocks, a preview language feature.
- * Text blocks and/or this method may be changed or removed in a future release.
*/
- @Deprecated(forRemoval=true, since="13")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.TEXT_BLOCKS,
+ essentialAPI=true)
public String translateEscapes() {
if (isEmpty()) {
return "";
@@ -3309,6 +3324,15 @@
}
/**
+ * {@preview Associated with text blocks, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>text blocks</i>, a preview
+ * feature of the Java language. Programs can only use this
+ * method when preview features are enabled. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* Formats using this string as the format string, and the supplied
* arguments.
*
@@ -3324,10 +3348,9 @@
*
* @since 13
*
- * @deprecated This method is associated with text blocks, a preview language feature.
- * Text blocks and/or this method may be changed or removed in a future release.
*/
- @Deprecated(forRemoval=true, since="13")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.TEXT_BLOCKS,
+ essentialAPI=true)
public String formatted(Object... args) {
return new Formatter().format(this, args).toString();
}
--- a/src/java.base/share/classes/java/lang/System.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/lang/System.java Mon Oct 28 18:43:04 2019 +0100
@@ -94,10 +94,8 @@
public final class System {
/* Register the natives via the static initializer.
*
- * VM will invoke the initializeSystemClass method to complete
- * the initialization for this class separated from clinit.
- * Note that to use properties set by the VM, see the constraints
- * described in the initializeSystemClass method.
+ * The VM will invoke the initPhase1 method to complete the initialization
+ * of this class separate from <clinit>.
*/
private static native void registerNatives();
static {
--- a/src/java.base/share/classes/java/lang/Thread.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/lang/Thread.java Mon Oct 28 18:43:04 2019 +0100
@@ -1075,7 +1075,7 @@
* <a href="{@docRoot}/java.base/java/lang/doc-files/threadPrimitiveDeprecation.html">Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
*/
- @Deprecated(since="1.2")
+ @Deprecated(since="1.2", forRemoval=true)
public final void suspend() {
checkAccess();
suspend0();
@@ -1101,7 +1101,7 @@
* <a href="{@docRoot}/java.base/java/lang/doc-files/threadPrimitiveDeprecation.html">Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
*/
- @Deprecated(since="1.2")
+ @Deprecated(since="1.2", forRemoval=true)
public final void resume() {
checkAccess();
resume0();
--- a/src/java.base/share/classes/java/lang/ThreadGroup.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/lang/ThreadGroup.java Mon Oct 28 18:43:04 2019 +0100
@@ -666,8 +666,8 @@
* @deprecated This method is inherently deadlock-prone. See
* {@link Thread#suspend} for details.
*/
- @Deprecated(since="1.2")
- @SuppressWarnings("deprecation")
+ @Deprecated(since="1.2", forRemoval=true)
+ @SuppressWarnings("removal")
public final void suspend() {
if (stopOrSuspend(true))
Thread.currentThread().suspend();
@@ -680,7 +680,7 @@
* if (and only if) the current thread is found to be in this thread
* group or one of its subgroups.
*/
- @SuppressWarnings("deprecation")
+ @SuppressWarnings({"deprecation", "removal"})
private boolean stopOrSuspend(boolean suspend) {
boolean suicide = false;
Thread us = Thread.currentThread();
@@ -729,8 +729,8 @@
* both of which have been deprecated, as they are inherently
* deadlock-prone. See {@link Thread#suspend} for details.
*/
- @Deprecated(since="1.2")
- @SuppressWarnings("deprecation")
+ @Deprecated(since="1.2", forRemoval=true)
+ @SuppressWarnings("removal")
public final void resume() {
int ngroupsSnapshot;
ThreadGroup[] groupsSnapshot;
@@ -1070,7 +1070,7 @@
* which is deprecated. Further, the behavior of this call
* was never specified.
*/
- @Deprecated(since="1.2")
+ @Deprecated(since="1.2", forRemoval=true)
public boolean allowThreadSuspension(boolean b) {
return true;
}
--- a/src/java.base/share/classes/java/net/DatagramSocket.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/net/DatagramSocket.java Mon Oct 28 18:43:04 2019 +0100
@@ -888,14 +888,14 @@
}
/** Enable/disable SO_TIMEOUT with the specified timeout, in
- * milliseconds. With this option set to a non-zero timeout,
+ * milliseconds. With this option set to a positive timeout value,
* a call to receive() for this DatagramSocket
* will block for only this amount of time. If the timeout expires,
* a <B>java.net.SocketTimeoutException</B> is raised, though the
- * DatagramSocket is still valid. The option <B>must</B> be enabled
- * prior to entering the blocking operation to have effect. The
- * timeout must be {@code > 0}.
- * A timeout of zero is interpreted as an infinite timeout.
+ * DatagramSocket is still valid. A timeout of zero is interpreted
+ * as an infinite timeout.
+ * The option <B>must</B> be enabled prior to entering the blocking
+ * operation to have effect.
*
* @param timeout the specified timeout in milliseconds.
* @throws SocketException if there is an error in the underlying protocol, such as an UDP error.
--- a/src/java.base/share/classes/java/net/InetSocketAddress.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/net/InetSocketAddress.java Mon Oct 28 18:43:04 2019 +0100
@@ -101,11 +101,20 @@
@Override
public String toString() {
+
+ String formatted;
+
if (isUnresolved()) {
- return hostname + ":" + port;
+ formatted = hostname + "/<unresolved>";
} else {
- return addr.toString() + ":" + port;
+ formatted = addr.toString();
+ if (addr instanceof Inet6Address) {
+ int i = formatted.lastIndexOf("/");
+ formatted = formatted.substring(0, i + 1)
+ + "[" + formatted.substring(i + 1) + "]";
+ }
}
+ return formatted + ":" + port;
}
@Override
@@ -367,7 +376,9 @@
* Constructs a string representation of this InetSocketAddress.
* This String is constructed by calling toString() on the InetAddress
* and concatenating the port number (with a colon). If the address
- * is unresolved then the part before the colon will only contain the hostname.
+ * is an IPv6 address, the IPv6 literal is enclosed in square brackets.
+ * If the address is {@linkplain #isUnresolved() unresolved},
+ * {@code <unresolved>} is displayed in place of the address literal.
*
* @return a string representation of this object.
*/
--- a/src/java.base/share/classes/java/net/ServerSocket.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/net/ServerSocket.java Mon Oct 28 18:43:04 2019 +0100
@@ -749,14 +749,15 @@
/**
* Enable/disable {@link SocketOptions#SO_TIMEOUT SO_TIMEOUT} with the
- * specified timeout, in milliseconds. With this option set to a non-zero
- * timeout, a call to accept() for this ServerSocket
+ * specified timeout, in milliseconds. With this option set to a positive
+ * timeout value, a call to accept() for this ServerSocket
* will block for only this amount of time. If the timeout expires,
* a <B>java.net.SocketTimeoutException</B> is raised, though the
- * ServerSocket is still valid. The option <B>must</B> be enabled
- * prior to entering the blocking operation to have effect. The
- * timeout must be {@code > 0}.
- * A timeout of zero is interpreted as an infinite timeout.
+ * ServerSocket is still valid. A timeout of zero is interpreted as an
+ * infinite timeout.
+ * The option <B>must</B> be enabled prior to entering the blocking
+ * operation to have effect.
+ *
* @param timeout the specified timeout, in milliseconds
* @throws SocketException if there is an error in the underlying protocol,
* such as a TCP error
--- a/src/java.base/share/classes/java/net/Socket.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/net/Socket.java Mon Oct 28 18:43:04 2019 +0100
@@ -1171,13 +1171,12 @@
/**
* Enable/disable {@link SocketOptions#SO_TIMEOUT SO_TIMEOUT}
* with the specified timeout, in milliseconds. With this option set
- * to a non-zero timeout, a read() call on the InputStream associated with
+ * to a positive timeout value, a read() call on the InputStream associated with
* this Socket will block for only this amount of time. If the timeout
* expires, a <B>java.net.SocketTimeoutException</B> is raised, though the
- * Socket is still valid. The option <B>must</B> be enabled
- * prior to entering the blocking operation to have effect. The
- * timeout must be {@code > 0}.
- * A timeout of zero is interpreted as an infinite timeout.
+ * Socket is still valid. A timeout of zero is interpreted as an infinite timeout.
+ * The option <B>must</B> be enabled prior to entering the blocking operation
+ * to have effect.
*
* @param timeout the specified timeout, in milliseconds.
* @throws SocketException if there is an error in the underlying protocol,
--- a/src/java.base/share/classes/java/net/SocketPermission.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/net/SocketPermission.java Mon Oct 28 18:43:04 2019 +0100
@@ -287,6 +287,11 @@
* @param host the hostname or IP address of the computer, optionally
* including a colon followed by a port or port range.
* @param action the action string.
+ *
+ * @throws NullPointerException if any parameters are null
+ * @throws IllegalArgumentException if the format of {@code host} is
+ * invalid, or if the {@code action} string is empty, malformed, or
+ * contains an action other than the specified possible actions
*/
public SocketPermission(String host, String action) {
super(getHost(host));
@@ -589,14 +594,15 @@
// like "ackbarfaccept". Also, skip to the comma.
boolean seencomma = false;
while (i >= matchlen && !seencomma) {
- switch(a[i-matchlen]) {
- case ',':
- seencomma = true;
- break;
+ switch (c = a[i-matchlen]) {
case ' ': case '\r': case '\n':
case '\f': case '\t':
break;
default:
+ if (c == ',' && i > matchlen) {
+ seencomma = true;
+ break;
+ }
throw new IllegalArgumentException(
"invalid permission: " + action);
}
@@ -1361,10 +1367,10 @@
*
* @param permission the Permission object to add.
*
- * @throws IllegalArgumentException - if the permission is not a
+ * @throws IllegalArgumentException if the permission is not a
* SocketPermission
*
- * @throws SecurityException - if this SocketPermissionCollection object
+ * @throws SecurityException if this SocketPermissionCollection object
* has been marked readonly
*/
@Override
--- a/src/java.base/share/classes/java/nio/channels/DatagramChannel.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/nio/channels/DatagramChannel.java Mon Oct 28 18:43:04 2019 +0100
@@ -305,8 +305,10 @@
* If the type of the given remote address is not supported
*
* @throws SecurityException
- * If a security manager has been installed
- * and it does not permit access to the given remote address
+ * If a security manager has been installed and it does not
+ * permit access to the given remote address, or if unbound,
+ * the security manager {@link SecurityManager#checkListen checkListen}
+ * method denies the operation
*
* @throws IOException
* If some other I/O error occurs
@@ -409,6 +411,11 @@
* closing the channel and setting the current thread's
* interrupt status
*
+ * @throws SecurityException
+ * If unbound, and a security manager has been installed and
+ * its {@link SecurityManager#checkListen checkListen} method
+ * denies the operation
+ *
* @throws IOException
* If some other I/O error occurs
*/
@@ -480,9 +487,10 @@
* If the type of the given remote address is not supported
*
* @throws SecurityException
- * If a security manager has been installed
- * and it does not permit datagrams to be sent
- * to the given address
+ * If a security manager has been installed and it does not permit
+ * datagrams to be sent to the given address, or if unbound, and
+ * the security manager's {@link SecurityManager#checkListen checkListen}
+ * method denies the operation
*
* @throws IOException
* If some other I/O error occurs
--- a/src/java.base/share/classes/java/security/AllPermission.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/security/AllPermission.java Mon Oct 28 18:43:04 2019 +0100
@@ -178,10 +178,10 @@
*
* @param permission the Permission object to add.
*
- * @throws IllegalArgumentException - if the permission is not a
+ * @throws IllegalArgumentException if the permission is not an
* AllPermission
*
- * @throws SecurityException - if this AllPermissionCollection object
+ * @throws SecurityException if this AllPermissionCollection object
* has been marked readonly
*/
--- a/src/java.base/share/classes/java/security/BasicPermission.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/security/BasicPermission.java Mon Oct 28 18:43:04 2019 +0100
@@ -349,13 +349,13 @@
*
* @param permission the Permission object to add.
*
- * @throws IllegalArgumentException - if the permission is not a
+ * @throws IllegalArgumentException if the permission is not a
* BasicPermission, or if
* the permission is not of the
* same Class as the other
* permissions in this collection.
*
- * @throws SecurityException - if this BasicPermissionCollection object
+ * @throws SecurityException if this BasicPermissionCollection object
* has been marked readonly
*/
@Override
--- a/src/java.base/share/classes/java/security/PermissionCollection.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/security/PermissionCollection.java Mon Oct 28 18:43:04 2019 +0100
@@ -107,9 +107,9 @@
*
* @param permission the Permission object to add.
*
- * @throws SecurityException - if this PermissionCollection object
+ * @throws SecurityException if this PermissionCollection object
* has been marked readonly
- * @throws IllegalArgumentException - if this PermissionCollection
+ * @throws IllegalArgumentException if this PermissionCollection
* object is a homogeneous collection and the permission
* is not of the correct type.
*/
--- a/src/java.base/share/classes/java/security/Policy.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/security/Policy.java Mon Oct 28 18:43:04 2019 +0100
@@ -837,7 +837,7 @@
*
* @param permission the Permission object to add.
*
- * @throws SecurityException - if this PermissionCollection object
+ * @throws SecurityException if this PermissionCollection object
* has been marked readonly
*/
@Override public void add(Permission permission) {
--- a/src/java.base/share/classes/java/util/PropertyPermission.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/PropertyPermission.java Mon Oct 28 18:43:04 2019 +0100
@@ -463,10 +463,10 @@
*
* @param permission the Permission object to add.
*
- * @throws IllegalArgumentException - if the permission is not a
+ * @throws IllegalArgumentException if the permission is not a
* PropertyPermission
*
- * @throws SecurityException - if this PropertyPermissionCollection
+ * @throws SecurityException if this PropertyPermissionCollection
* object has been marked readonly
*/
@Override
--- a/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java Mon Oct 28 18:43:04 2019 +0100
@@ -100,6 +100,7 @@
private static final long serialVersionUID = -817911632652898426L;
/** The queued items */
+ @SuppressWarnings("serial") // Conditionally serializable
final Object[] items;
/** items index for next take, poll, peek or remove */
@@ -120,9 +121,11 @@
final ReentrantLock lock;
/** Condition for waiting takes */
+ @SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notEmpty;
/** Condition for waiting puts */
+ @SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notFull;
/**
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java Mon Oct 28 18:43:04 2019 +0100
@@ -4584,6 +4584,7 @@
public static class KeySetView<K,V> extends CollectionView<K,V,K>
implements Set<K>, java.io.Serializable {
private static final long serialVersionUID = 7249069246763182397L;
+ @SuppressWarnings("serial") // Conditionally serializable
private final V value;
KeySetView(ConcurrentHashMap<K,V> map, V value) { // non-public
super(map);
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java Mon Oct 28 18:43:04 2019 +0100
@@ -334,6 +334,7 @@
* nested classes.)
* @serial
*/
+ @SuppressWarnings("serial") // Conditionally serializable
final Comparator<? super K> comparator;
/** Lazily initialized topmost index of the skiplist. */
@@ -2375,8 +2376,10 @@
/** Underlying map */
final ConcurrentSkipListMap<K,V> m;
/** lower bound key, or null if from start */
+ @SuppressWarnings("serial") // Conditionally serializable
private final K lo;
/** upper bound key, or null if to end */
+ @SuppressWarnings("serial") // Conditionally serializable
private final K hi;
/** inclusion flag for lo */
private final boolean loInclusive;
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java Mon Oct 28 18:43:04 2019 +0100
@@ -103,6 +103,7 @@
* element. This field is declared final for the sake of thread
* safety, which entails some ugliness in clone().
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private final ConcurrentNavigableMap<E,Object> m;
/**
--- a/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java Mon Oct 28 18:43:04 2019 +0100
@@ -1374,7 +1374,9 @@
*/
static final class AdaptedRunnable<T> extends ForkJoinTask<T>
implements RunnableFuture<T> {
+ @SuppressWarnings("serial") // Conditionally serializable
final Runnable runnable;
+ @SuppressWarnings("serial") // Conditionally serializable
T result;
AdaptedRunnable(Runnable runnable, T result) {
if (runnable == null) throw new NullPointerException();
@@ -1396,6 +1398,7 @@
*/
static final class AdaptedRunnableAction extends ForkJoinTask<Void>
implements RunnableFuture<Void> {
+ @SuppressWarnings("serial") // Conditionally serializable
final Runnable runnable;
AdaptedRunnableAction(Runnable runnable) {
if (runnable == null) throw new NullPointerException();
@@ -1415,6 +1418,7 @@
* Adapter for Runnables in which failure forces worker exception.
*/
static final class RunnableExecuteAction extends ForkJoinTask<Void> {
+ @SuppressWarnings("serial") // Conditionally serializable
final Runnable runnable;
RunnableExecuteAction(Runnable runnable) {
if (runnable == null) throw new NullPointerException();
@@ -1434,7 +1438,9 @@
*/
static final class AdaptedCallable<T> extends ForkJoinTask<T>
implements RunnableFuture<T> {
+ @SuppressWarnings("serial") // Conditionally serializable
final Callable<? extends T> callable;
+ @SuppressWarnings("serial") // Conditionally serializable
T result;
AdaptedCallable(Callable<? extends T> callable) {
if (callable == null) throw new NullPointerException();
--- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java Mon Oct 28 18:43:04 2019 +0100
@@ -159,9 +159,11 @@
final ReentrantLock lock = new ReentrantLock();
/** Condition for waiting takes */
+ @SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notEmpty = lock.newCondition();
/** Condition for waiting puts */
+ @SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notFull = lock.newCondition();
/**
--- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java Mon Oct 28 18:43:04 2019 +0100
@@ -156,12 +156,14 @@
private final ReentrantLock takeLock = new ReentrantLock();
/** Wait queue for waiting takes */
+ @SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notEmpty = takeLock.newCondition();
/** Lock held by put, offer, etc */
private final ReentrantLock putLock = new ReentrantLock();
/** Wait queue for waiting puts */
+ @SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notFull = putLock.newCondition();
/**
--- a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java Mon Oct 28 18:43:04 2019 +0100
@@ -173,6 +173,7 @@
/**
* Condition for blocking when empty.
*/
+ @SuppressWarnings("serial") // Classes implementing Condition may be serializable.
private final Condition notEmpty = lock.newCondition();
/**
--- a/src/java.base/share/classes/java/util/concurrent/RecursiveTask.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/RecursiveTask.java Mon Oct 28 18:43:04 2019 +0100
@@ -71,6 +71,7 @@
/**
* The result of the computation.
*/
+ @SuppressWarnings("serial") // Conditionally serializable
V result;
/**
--- a/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Mon Oct 28 18:43:04 2019 +0100
@@ -604,8 +604,10 @@
private static final long serialVersionUID = 6138294804551838833L;
/** Thread this worker is running in. Null if factory fails. */
+ @SuppressWarnings("serial") // Unlikely to be serializable
final Thread thread;
/** Initial task to run. Possibly null. */
+ @SuppressWarnings("serial") // Not statically typed as Serializable
Runnable firstTask;
/** Per-thread task counter */
volatile long completedTasks;
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java Mon Oct 28 18:43:04 2019 +0100
@@ -60,6 +60,7 @@
}
}
+ @SuppressWarnings("serial") // Conditionally serializable
private volatile V value;
/**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java Mon Oct 28 18:43:04 2019 +0100
@@ -55,6 +55,7 @@
private static final long serialVersionUID = -6209656149925076980L;
private static final VarHandle AA
= MethodHandles.arrayElementVarHandle(Object[].class);
+ @SuppressWarnings("serial") // Conditionally serializable
private final Object[] array; // must have exact type Object[]
/**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java Mon Oct 28 18:43:04 2019 +0100
@@ -84,6 +84,7 @@
public class DoubleAccumulator extends Striped64 implements Serializable {
private static final long serialVersionUID = 7249069246863182397L;
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final DoubleBinaryOperator function;
private final long identity; // use long representation
@@ -245,6 +246,7 @@
* The function used for updates.
* @serial
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final DoubleBinaryOperator function;
/**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java Mon Oct 28 18:43:04 2019 +0100
@@ -82,6 +82,7 @@
public class LongAccumulator extends Striped64 implements Serializable {
private static final long serialVersionUID = 7249069246863182397L;
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final LongBinaryOperator function;
private final long identity;
@@ -239,6 +240,7 @@
* The function used for updates.
* @serial
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final LongBinaryOperator function;
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/jdk/internal/PreviewFeature.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2019, 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.
+ */
+
+package jdk.internal;
+
+import java.lang.annotation.*;
+
+/**
+ * Indicates the API declaration in question is associated with a
+ * <em>preview feature</em>. See JEP 12: "Preview Language and VM
+ * Features" (http://openjdk.java.net/jeps/12).
+ * @since 14
+ */
+// Match the meaningful targets of java.lang.Deprecated, omit local
+// variables and parameter declarations
+@Target({ElementType.METHOD,
+ ElementType.CONSTRUCTOR,
+ ElementType.FIELD,
+ ElementType.PACKAGE,
+ ElementType.MODULE,
+ ElementType.TYPE})
+ // CLASS retention will hopefully be sufficient for the purposes at hand
+@Retention(RetentionPolicy.CLASS)
+// *Not* @Documented
+public @interface PreviewFeature {
+ /**
+ * Name of the preview feature the annotated API is associated
+ * with.
+ */
+ public Feature feature();
+
+ public boolean essentialAPI() default false;
+
+ public enum Feature {
+ SWITCH_EXPRESSIONS,
+ TEXT_BLOCKS;
+ }
+}
--- a/src/java.base/share/classes/module-info.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/module-info.java Mon Oct 28 18:43:04 2019 +0100
@@ -135,7 +135,8 @@
exports com.sun.security.ntlm to
java.security.sasl;
exports jdk.internal to
- jdk.jfr;
+ jdk.jfr,
+ jdk.compiler;
exports jdk.internal.access to
java.desktop,
java.logging,
--- a/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java Mon Oct 28 18:43:04 2019 +0100
@@ -27,6 +27,8 @@
import java.io.FileDescriptor;
import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.lang.ref.Cleaner.Cleanable;
import java.net.DatagramSocket;
import java.net.Inet4Address;
import java.net.Inet6Address;
@@ -55,6 +57,7 @@
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
+import jdk.internal.ref.CleanerFactory;
import sun.net.ResourceManager;
import sun.net.ext.ExtendedSocketOptions;
import sun.net.util.IPAddressUtil;
@@ -68,7 +71,7 @@
implements SelChImpl
{
// Used to make native read and write calls
- private static NativeDispatcher nd = new DatagramDispatcher();
+ private static final NativeDispatcher nd = new DatagramDispatcher();
// The protocol family of the socket
private final ProtocolFamily family;
@@ -76,6 +79,7 @@
// Our file descriptor
private final FileDescriptor fd;
private final int fdVal;
+ private final Cleanable cleaner;
// Cached InetAddress and port for unconnected DatagramChannels
// used by receive0
@@ -138,6 +142,7 @@
ResourceManager.afterUdpClose();
throw ioe;
}
+ this.cleaner = CleanerFactory.cleaner().register(this, closerFor(fd));
}
public DatagramChannelImpl(SelectorProvider sp, ProtocolFamily family)
@@ -164,6 +169,7 @@
ResourceManager.afterUdpClose();
throw ioe;
}
+ this.cleaner = CleanerFactory.cleaner().register(this, closerFor(fd));
}
public DatagramChannelImpl(SelectorProvider sp, FileDescriptor fd)
@@ -179,6 +185,7 @@
: StandardProtocolFamily.INET;
this.fd = fd;
this.fdVal = IOUtil.fdVal(fd);
+ this.cleaner = CleanerFactory.cleaner().register(this, closerFor(fd));
synchronized (stateLock) {
this.localAddress = Net.localAddress(fd);
}
@@ -1181,10 +1188,10 @@
if ((readerThread == 0) && (writerThread == 0) && !isRegistered()) {
state = ST_CLOSED;
try {
- nd.close(fd);
- } finally {
- // notify resource manager
- ResourceManager.afterUdpClose();
+ // close socket
+ cleaner.clean();
+ } catch (UncheckedIOException ioe) {
+ throw ioe.getCause();
}
return true;
} else {
@@ -1283,13 +1290,6 @@
}
}
- @SuppressWarnings("deprecation")
- protected void finalize() throws IOException {
- // fd is null if constructor threw exception
- if (fd != null)
- close();
- }
-
/**
* Translates native poll revent set into a ready operation set
*/
@@ -1377,6 +1377,21 @@
return fdVal;
}
+ /**
+ * Returns an action to close the given file descriptor.
+ */
+ private static Runnable closerFor(FileDescriptor fd) {
+ return () -> {
+ try {
+ nd.close(fd);
+ } catch (IOException ioe) {
+ throw new UncheckedIOException(ioe);
+ } finally {
+ // decrement
+ ResourceManager.afterUdpClose();
+ }
+ };
+ }
// -- Native methods --
--- a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java Mon Oct 28 18:43:04 2019 +0100
@@ -30,8 +30,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UncheckedIOException;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.VarHandle;
+import java.lang.ref.Cleaner.Cleanable;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ProtocolFamily;
@@ -106,7 +105,7 @@
// set by SocketImpl.create, protected by stateLock
private boolean stream;
- private FileDescriptorCloser closer;
+ private Cleanable cleaner;
// set to true when the socket is in non-blocking mode
private volatile boolean nonBlocking;
@@ -471,9 +470,10 @@
ResourceManager.afterUdpClose();
throw ioe;
}
+ Runnable closer = closerFor(fd, stream);
this.fd = fd;
this.stream = stream;
- this.closer = FileDescriptorCloser.create(this);
+ this.cleaner = CleanerFactory.cleaner().register(this, closer);
this.state = ST_UNCONNECTED;
}
}
@@ -777,10 +777,11 @@
}
// set the fields
+ Runnable closer = closerFor(newfd, true);
synchronized (nsi.stateLock) {
nsi.fd = newfd;
nsi.stream = true;
- nsi.closer = FileDescriptorCloser.create(nsi);
+ nsi.cleaner = CleanerFactory.cleaner().register(nsi, closer);
nsi.localport = localAddress.getPort();
nsi.address = isaa[0].getAddress();
nsi.port = isaa[0].getPort();
@@ -850,7 +851,7 @@
assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
if (readerThread == 0 && writerThread == 0) {
try {
- closer.run();
+ cleaner.clean();
} catch (UncheckedIOException ioe) {
throw ioe.getCause();
} finally {
@@ -1193,53 +1194,28 @@
}
/**
- * A task that closes a SocketImpl's file descriptor. The task runs when the
- * SocketImpl is explicitly closed and when the SocketImpl becomes phantom
- * reachable.
+ * Returns an action to close the given file descriptor.
*/
- private static class FileDescriptorCloser implements Runnable {
- private static final VarHandle CLOSED;
- static {
- try {
- MethodHandles.Lookup l = MethodHandles.lookup();
- CLOSED = l.findVarHandle(FileDescriptorCloser.class,
- "closed",
- boolean.class);
- } catch (Exception e) {
- throw new InternalError(e);
- }
- }
-
- private final FileDescriptor fd;
- private final boolean stream;
- private volatile boolean closed;
-
- FileDescriptorCloser(FileDescriptor fd, boolean stream) {
- this.fd = fd;
- this.stream = stream;
- }
-
- static FileDescriptorCloser create(NioSocketImpl impl) {
- assert Thread.holdsLock(impl.stateLock);
- var closer = new FileDescriptorCloser(impl.fd, impl.stream);
- CleanerFactory.cleaner().register(impl, closer);
- return closer;
- }
-
- @Override
- public void run() {
- if (CLOSED.compareAndSet(this, false, true)) {
+ private static Runnable closerFor(FileDescriptor fd, boolean stream) {
+ if (stream) {
+ return () -> {
+ try {
+ nd.close(fd);
+ } catch (IOException ioe) {
+ throw new UncheckedIOException(ioe);
+ }
+ };
+ } else {
+ return () -> {
try {
nd.close(fd);
} catch (IOException ioe) {
throw new UncheckedIOException(ioe);
} finally {
- if (!stream) {
- // decrement
- ResourceManager.afterUdpClose();
- }
+ // decrement
+ ResourceManager.afterUdpClose();
}
- }
+ };
}
}
--- a/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -304,14 +304,17 @@
public static void loadProviderByClass(
String provClass, String arg, ClassLoader cl) {
- // For compatibility, SunPKCS11 and OracleUcrypto can still be
- // loadable with -providerClass.
+ // For compatibility, SunPKCS11, OracleUcrypto, and SunMSCAPI
+ // can still be loadable with -providerClass.
if (provClass.equals("sun.security.pkcs11.SunPKCS11")) {
loadProviderByName("SunPKCS11", arg);
return;
} else if (provClass.equals("com.oracle.security.crypto.UcryptoProvider")) {
loadProviderByName("OracleUcrypto", arg);
return;
+ } else if (provClass.equals("sun.security.mscapi.SunMSCAPI")) {
+ loadProviderByName("SunMSCAPI", arg);
+ return;
}
Provider prov;
--- a/src/java.base/share/native/include/classfile_constants.h.template Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/native/include/classfile_constants.h.template Mon Oct 28 18:43:04 2019 +0100
@@ -144,6 +144,10 @@
/* Type signatures */
enum {
+ JVM_SIGNATURE_SLASH = '/',
+ JVM_SIGNATURE_DOT = '.',
+ JVM_SIGNATURE_SPECIAL = '<',
+ JVM_SIGNATURE_ENDSPECIAL = '>',
JVM_SIGNATURE_ARRAY = '[',
JVM_SIGNATURE_BYTE = 'B',
JVM_SIGNATURE_CHAR = 'C',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/native/libjava/NullPointerException.c Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019 SAP SE. 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.
+ */
+
+#include "jni.h"
+#include "jvm.h"
+
+#include "java_lang_NullPointerException.h"
+
+JNIEXPORT jstring JNICALL
+Java_java_lang_NullPointerException_getExtendedNPEMessage(JNIEnv *env, jobject throwable)
+{
+ return JVM_GetExtendedNPEMessage(env, throwable);
+}
--- a/src/java.base/share/native/libjava/Object.c Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/native/libjava/Object.c Mon Oct 28 18:43:04 2019 +0100
@@ -39,21 +39,6 @@
#include "java_lang_Object.h"
-static JNINativeMethod methods[] = {
- {"hashCode", "()I", (void *)&JVM_IHashCode},
- {"wait", "(J)V", (void *)&JVM_MonitorWait},
- {"notify", "()V", (void *)&JVM_MonitorNotify},
- {"notifyAll", "()V", (void *)&JVM_MonitorNotifyAll},
- {"clone", "()Ljava/lang/Object;", (void *)&JVM_Clone},
-};
-
-JNIEXPORT void JNICALL
-Java_java_lang_Object_registerNatives(JNIEnv *env, jclass cls)
-{
- (*env)->RegisterNatives(env, cls,
- methods, sizeof(methods)/sizeof(methods[0]));
-}
-
JNIEXPORT jclass JNICALL
Java_java_lang_Object_getClass(JNIEnv *env, jobject this)
{
--- a/src/java.base/share/native/libjava/jni_util.c Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/native/libjava/jni_util.c Mon Oct 28 18:43:04 2019 +0100
@@ -791,6 +791,13 @@
CHECK_NULL(String_value_ID);
}
+// This alias is used for compatibility with 32 bit Windows
+JNIEXPORT jstring
+NewStringPlatform(JNIEnv *env, const char *str)
+{
+ return JNU_NewStringPlatform(env, str);
+}
+
JNIEXPORT jstring JNICALL
JNU_NewStringPlatform(JNIEnv *env, const char *str)
{
--- a/src/java.base/share/native/libjava/jni_util.h Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.base/share/native/libjava/jni_util.h Mon Oct 28 18:43:04 2019 +0100
@@ -93,6 +93,9 @@
JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail);
/* Convert between Java strings and i18n C strings */
+JNIEXPORT jstring
+NewStringPlatform(JNIEnv *env, const char *str);
+
JNIEXPORT const char *
GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
--- a/src/java.desktop/share/native/libfontmanager/freetypeScaler.c Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.desktop/share/native/libfontmanager/freetypeScaler.c Mon Oct 28 18:43:04 2019 +0100
@@ -673,10 +673,14 @@
pScalerContext, pScaler, glyphCode);
info = (GlyphInfo*) jlong_to_ptr(image);
- (*env)->SetFloatField(env, metrics, sunFontIDs.xFID, info->advanceX);
- (*env)->SetFloatField(env, metrics, sunFontIDs.yFID, info->advanceY);
-
- free(info);
+ if (info != NULL) {
+ (*env)->SetFloatField(env, metrics, sunFontIDs.xFID, info->advanceX);
+ (*env)->SetFloatField(env, metrics, sunFontIDs.yFID, info->advanceY);
+ free(info);
+ } else {
+ (*env)->SetFloatField(env, metrics, sunFontIDs.xFID, 0.0f);
+ (*env)->SetFloatField(env, metrics, sunFontIDs.yFID, 0.0f);
+ }
}
--- a/src/java.management.rmi/share/classes/com/sun/jmx/remote/internal/rmi/ProxyRef.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management.rmi/share/classes/com/sun/jmx/remote/internal/rmi/ProxyRef.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -35,7 +35,8 @@
import java.rmi.server.RemoteRef;
-@SuppressWarnings("deprecation")
+@SuppressWarnings({"deprecation",
+ "serial"}) // Externalizable class w/o no-arg c'tor
public class ProxyRef implements RemoteRef {
private static final long serialVersionUID = -6503061366316814723L;
--- a/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -2245,6 +2245,7 @@
*
* @see #RMIConnector(RMIServer,Map)
**/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final RMIServer rmiServer;
/**
--- a/src/java.management/share/classes/com/sun/jmx/mbeanserver/Introspector.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/com/sun/jmx/mbeanserver/Introspector.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -450,7 +450,7 @@
* @return nothing - this method always throw an exception.
* The return type makes it possible to write
* <pre> throw throwException(clazz,cause); </pre>
- * @throws SecurityException - if cause is a SecurityException
+ * @throws SecurityException if cause is a SecurityException
* @throws NotCompliantMBeanException otherwise.
**/
static NotCompliantMBeanException throwException(Class<?> notCompliant,
--- a/src/java.management/share/classes/javax/management/Attribute.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/Attribute.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -49,6 +49,7 @@
/**
* @serial Attribute value
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private Object value= null;
--- a/src/java.management/share/classes/javax/management/AttributeChangeNotification.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/AttributeChangeNotification.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -74,11 +74,13 @@
/**
* @serial The MBean attribute old value.
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private Object oldValue = null;
/**
* @serial The MBean attribute new value.
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private Object newValue = null;
--- a/src/java.management/share/classes/javax/management/BadAttributeValueExpException.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/BadAttributeValueExpException.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -47,6 +47,7 @@
* @serial A string representation of the attribute that originated this exception.
* for example, the string value can be the return of {@code attribute.toString()}
*/
+ @SuppressWarnings("serial") // See handling in constructor and readObject
private Object val;
/**
--- a/src/java.management/share/classes/javax/management/ImmutableDescriptor.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/ImmutableDescriptor.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, 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
@@ -52,6 +52,7 @@
* elements in this array match the corresponding elements in the
* {@code names} array.
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private final Object[] values;
private transient int hashCode = -1;
--- a/src/java.management/share/classes/javax/management/InvalidApplicationException.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/InvalidApplicationException.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -44,6 +44,7 @@
/**
* @serial The object representing the class of the MBean
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private Object val;
--- a/src/java.management/share/classes/javax/management/NotificationFilterSupport.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/NotificationFilterSupport.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -64,6 +64,7 @@
* @serial {@link Vector} that contains the enabled notification types.
* The default value is an empty vector.
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private List<String> enabledTypes = new Vector<String>();
--- a/src/java.management/share/classes/javax/management/loading/PrivateMLet.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/loading/PrivateMLet.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -38,6 +38,7 @@
*
* @since 1.5
*/
+@SuppressWarnings("serial") // Externalizable class w/o no-arg c'tor
public class PrivateMLet extends MLet implements PrivateClassLoader {
private static final long serialVersionUID = 2503458973393711979L;
--- a/src/java.management/share/classes/javax/management/monitor/MonitorNotification.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/monitor/MonitorNotification.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -162,6 +162,7 @@
/**
* @serial Monitor notification observed object.
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private ObjectName observedObject = null;
/**
@@ -172,6 +173,7 @@
/**
* @serial Monitor notification derived gauge.
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private Object derivedGauge = null;
/**
@@ -179,6 +181,7 @@
* This value is used to keep the threshold/string (depending on the
* monitor type) that triggered off this notification.
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private Object trigger = null;
--- a/src/java.management/share/classes/javax/management/openmbean/CompositeDataSupport.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/openmbean/CompositeDataSupport.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, 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
@@ -62,6 +62,7 @@
* respective values.
* A {@link SortedMap} is used for faster retrieval of elements.
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private final SortedMap<String, Object> contents;
/**
--- a/src/java.management/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, 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
@@ -64,27 +64,32 @@
/**
* @serial The open mbean attribute's <i>open type</i>
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private OpenType<?> openType;
/**
* @serial The open mbean attribute's default value
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final Object defaultValue;
/**
* @serial The open mbean attribute's legal values. This {@link
* Set} is unmodifiable
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private final Set<?> legalValues; // to be constructed unmodifiable
/**
* @serial The open mbean attribute's min value
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private final Comparable<?> minValue;
/**
* @serial The open mbean attribute's max value
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private final Comparable<?> maxValue;
--- a/src/java.management/share/classes/javax/management/openmbean/OpenMBeanParameterInfoSupport.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/openmbean/OpenMBeanParameterInfoSupport.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, 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
@@ -58,27 +58,32 @@
/**
* @serial The open mbean parameter's <i>open type</i>
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private OpenType<?> openType;
/**
* @serial The open mbean parameter's default value
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private Object defaultValue = null;
/**
* @serial The open mbean parameter's legal values. This {@link
* Set} is unmodifiable
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private Set<?> legalValues = null; // to be constructed unmodifiable
/**
* @serial The open mbean parameter's min value
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private Comparable<?> minValue = null;
/**
* @serial The open mbean parameter's max value
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private Comparable<?> maxValue = null;
--- a/src/java.management/share/classes/javax/management/openmbean/TabularDataSupport.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/openmbean/TabularDataSupport.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, 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
@@ -86,6 +86,7 @@
* @serial This tabular data instance's contents: a {@link HashMap}
*/
// field cannot be final because of clone method
+ @SuppressWarnings("serial") // Conditionally serializable
private Map<Object,CompositeData> dataMap;
/**
--- a/src/java.management/share/classes/javax/management/openmbean/TabularType.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/javax/management/openmbean/TabularType.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, 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
@@ -59,6 +59,7 @@
* @serial The items used to index each row element, kept in the order the user gave
* This is an unmodifiable {@link ArrayList}
*/
+ @SuppressWarnings("serial") // Conditionally serializable
private List<String> indexNames;
--- a/src/java.management/share/classes/sun/management/LazyCompositeData.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/sun/management/LazyCompositeData.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, 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
@@ -46,6 +46,7 @@
public abstract class LazyCompositeData
implements CompositeData, Serializable {
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private CompositeData compositeData;
// Implementation of the CompositeData interface
--- a/src/java.management/share/classes/sun/management/LockInfoCompositeData.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/sun/management/LockInfoCompositeData.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, 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
@@ -38,6 +38,7 @@
* construction of a CompositeData use in the local case.
*/
public class LockInfoCompositeData extends LazyCompositeData {
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final LockInfo lock;
private LockInfoCompositeData(LockInfo li) {
--- a/src/java.management/share/classes/sun/management/MemoryNotifInfoCompositeData.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/sun/management/MemoryNotifInfoCompositeData.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, 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
@@ -38,6 +38,7 @@
* construction of a CompositeData use in the local case.
*/
public class MemoryNotifInfoCompositeData extends LazyCompositeData {
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final MemoryNotificationInfo memoryNotifInfo;
private MemoryNotifInfoCompositeData(MemoryNotificationInfo info) {
--- a/src/java.management/share/classes/sun/management/MemoryUsageCompositeData.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/sun/management/MemoryUsageCompositeData.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, 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
@@ -37,6 +37,7 @@
* construction of a CompositeData use in the local case.
*/
public class MemoryUsageCompositeData extends LazyCompositeData {
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final MemoryUsage usage;
private MemoryUsageCompositeData(MemoryUsage u) {
--- a/src/java.management/share/classes/sun/management/MonitorInfoCompositeData.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/sun/management/MonitorInfoCompositeData.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -40,6 +40,7 @@
* construction of a CompositeData use in the local case.
*/
public class MonitorInfoCompositeData extends LazyCompositeData {
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final MonitorInfo lock;
private MonitorInfoCompositeData(MonitorInfo mi) {
--- a/src/java.management/share/classes/sun/management/ThreadInfoCompositeData.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/sun/management/ThreadInfoCompositeData.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, 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
@@ -45,7 +45,9 @@
* construction of a CompositeData use in the local case.
*/
public class ThreadInfoCompositeData extends LazyCompositeData {
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final ThreadInfo threadInfo;
+ @SuppressWarnings("serial") // Not statically typed as Serializable
private final CompositeData cdata;
private ThreadInfoCompositeData(ThreadInfo ti) {
--- a/src/java.management/share/classes/sun/management/counter/perf/PerfByteArrayCounter.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/sun/management/counter/perf/PerfByteArrayCounter.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -31,6 +31,7 @@
public class PerfByteArrayCounter extends AbstractCounter
implements ByteArrayCounter {
+ @SuppressWarnings("serial") // Value indirectly copied as a byte[] in writeReplace
ByteBuffer bb;
PerfByteArrayCounter(String name, Units u, Variability v,
--- a/src/java.management/share/classes/sun/management/counter/perf/PerfLongArrayCounter.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/sun/management/counter/perf/PerfLongArrayCounter.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -33,6 +33,8 @@
public class PerfLongArrayCounter extends AbstractCounter
implements LongArrayCounter {
+
+ @SuppressWarnings("serial") // Value indirectly copied as a long[] in writeReplace
LongBuffer lb;
PerfLongArrayCounter(String name, Units u, Variability v,
--- a/src/java.management/share/classes/sun/management/counter/perf/PerfLongCounter.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.management/share/classes/sun/management/counter/perf/PerfLongCounter.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -32,6 +32,7 @@
public class PerfLongCounter extends AbstractCounter
implements LongCounter {
+ @SuppressWarnings("serial") // Value indirectly copied as a long[] in writeReplace
LongBuffer lb;
// package private
--- a/src/java.net.http/share/classes/jdk/internal/net/http/HttpRequestImpl.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/HttpRequestImpl.java Mon Oct 28 18:43:04 2019 +0100
@@ -41,6 +41,7 @@
import java.net.http.HttpClient;
import java.net.http.HttpHeaders;
import java.net.http.HttpRequest;
+
import jdk.internal.net.http.common.HttpHeadersBuilder;
import jdk.internal.net.http.common.Utils;
import jdk.internal.net.http.websocket.OpeningHandshake;
@@ -152,13 +153,14 @@
/** Returns a new instance suitable for redirection. */
public static HttpRequestImpl newInstanceForRedirection(URI uri,
String method,
- HttpRequestImpl other) {
- return new HttpRequestImpl(uri, method, other);
+ HttpRequestImpl other,
+ boolean mayHaveBody) {
+ return new HttpRequestImpl(uri, method, other, mayHaveBody);
}
/** Returns a new instance suitable for authentication. */
public static HttpRequestImpl newInstanceForAuthentication(HttpRequestImpl other) {
- HttpRequestImpl request = new HttpRequestImpl(other.uri(), other.method(), other);
+ HttpRequestImpl request = new HttpRequestImpl(other.uri(), other.method(), other, true);
if (request.isWebSocket()) {
Utils.setWebSocketUpgradeHeaders(request);
}
@@ -171,7 +173,8 @@
*/
private HttpRequestImpl(URI uri,
String method,
- HttpRequestImpl other) {
+ HttpRequestImpl other,
+ boolean mayHaveBody) {
assert method == null || Utils.isValidName(method);
this.method = method == null? "GET" : method;
this.userHeaders = other.userHeaders;
@@ -184,13 +187,21 @@
this.proxy = other.proxy;
this.expectContinue = other.expectContinue;
this.secure = uri.getScheme().toLowerCase(Locale.US).equals("https");
- this.requestPublisher = other.requestPublisher; // may be null
+ this.requestPublisher = mayHaveBody ? publisher(other) : null; // may be null
this.acc = other.acc;
this.timeout = other.timeout;
this.version = other.version();
this.authority = null;
}
+ private BodyPublisher publisher(HttpRequestImpl other) {
+ BodyPublisher res = other.requestPublisher;
+ if (!Objects.equals(method, other.method)) {
+ res = null;
+ }
+ return res;
+ }
+
/* used for creating CONNECT requests */
HttpRequestImpl(String method, InetSocketAddress authority, HttpHeaders headers) {
// TODO: isWebSocket flag is not specified, but the assumption is that
--- a/src/java.net.http/share/classes/jdk/internal/net/http/RedirectFilter.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/RedirectFilter.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -89,6 +89,31 @@
}
}
+ private static boolean isRedirecting(int statusCode) {
+ // < 300: not a redirect codes
+ if (statusCode < 300) return false;
+ // 309-399 Unassigned => don't follow
+ // > 399: not a redirect code
+ if (statusCode > 308) return false;
+ switch (statusCode) {
+ // 300: MultipleChoice => don't follow
+ case 300:
+ return false;
+ // 304: Not Modified => don't follow
+ case 304:
+ return false;
+ // 305: Proxy Redirect => don't follow.
+ case 305:
+ return false;
+ // 306: Unused => don't follow
+ case 306:
+ return false;
+ // 301, 302, 303, 307, 308: OK to follow.
+ default:
+ return true;
+ }
+ }
+
/**
* Checks to see if a new request is needed and returns it.
* Null means response is ok to return to user.
@@ -102,13 +127,13 @@
if (rcode == HTTP_NOT_MODIFIED)
return null;
- if (rcode >= 300 && rcode <= 399) {
+ if (isRedirecting(rcode)) {
URI redir = getRedirectedURI(r.headers());
String newMethod = redirectedMethod(rcode, method);
Log.logTrace("response code: {0}, redirected URI: {1}", rcode, redir);
if (canRedirect(redir) && ++exchange.numberOfRedirects < max_redirects) {
Log.logTrace("redirect to: {0} with method: {1}", redir, newMethod);
- return HttpRequestImpl.newInstanceForRedirection(redir, newMethod, request);
+ return HttpRequestImpl.newInstanceForRedirection(redir, newMethod, request, rcode != 303);
} else {
Log.logTrace("not redirecting");
return null;
--- a/src/java.net.http/share/classes/jdk/internal/net/http/common/SSLFlowDelegate.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/SSLFlowDelegate.java Mon Oct 28 18:43:04 2019 +0100
@@ -318,14 +318,19 @@
@Override
protected long upstreamWindowUpdate(long currentWindow, long downstreamQsize) {
- if (readBuf.remaining() > TARGET_BUFSIZE) {
- if (debugr.on())
- debugr.log("readBuf has more than TARGET_BUFSIZE: %d",
- readBuf.remaining());
- return 0;
- } else {
- return super.upstreamWindowUpdate(currentWindow, downstreamQsize);
+ if (needsMoreData()) {
+ // run the scheduler to see if more data should be requested
+ if (debugr.on()) {
+ int remaining = readBuf.remaining();
+ if (remaining > TARGET_BUFSIZE) {
+ // just some logging to check how much we have in the read buffer
+ debugr.log("readBuf has more than TARGET_BUFSIZE: %d",
+ remaining);
+ }
+ }
+ scheduler.runOrSchedule();
}
+ return 0; // we will request more from the scheduler loop (processData).
}
// readBuf is kept ready for reading outside of this method
@@ -368,6 +373,32 @@
// we had before calling unwrap() again.
volatile int minBytesRequired;
+ // We might need to request more data if:
+ // - we have a subscription from upstream
+ // - and we don't have enough data to decrypt in the read buffer
+ // - *and* - either we're handshaking, and more data is required (NEED_UNWRAP),
+ // - or we have demand from downstream, but we have nothing decrypted
+ // to forward downstream.
+ boolean needsMoreData() {
+ if (upstreamSubscription != null && readBuf.remaining() <= minBytesRequired &&
+ (engine.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP
+ || !downstreamSubscription.demand.isFulfilled() && hasNoOutputData())) {
+ return true;
+ }
+ return false;
+ }
+
+ // If the readBuf has not enough data, and we either need to
+ // unwrap (handshaking) or we have demand from downstream,
+ // then request more data
+ void requestMoreDataIfNeeded() {
+ if (needsMoreData()) {
+ // request more will only request more if our
+ // demand from upstream is fulfilled
+ requestMore();
+ }
+ }
+
// work function where it all happens
final void processData() {
try {
@@ -434,6 +465,7 @@
outgoing(Utils.EMPTY_BB_LIST, true);
// complete ALPN if not yet completed
setALPN();
+ requestMoreDataIfNeeded();
return;
}
if (result.handshaking()) {
@@ -451,8 +483,10 @@
handleError(ex);
return;
}
- if (handshaking && !complete)
+ if (handshaking && !complete) {
+ requestMoreDataIfNeeded();
return;
+ }
}
if (!complete) {
synchronized (readBufferLock) {
@@ -466,6 +500,8 @@
// activity.
setALPN();
outgoing(Utils.EMPTY_BB_LIST, true);
+ } else {
+ requestMoreDataIfNeeded();
}
} catch (Throwable ex) {
errorCommon(ex);
--- a/src/java.net.http/share/classes/jdk/internal/net/http/common/SubscriberWrapper.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/SubscriberWrapper.java Mon Oct 28 18:43:04 2019 +0100
@@ -26,9 +26,7 @@
package jdk.internal.net.http.common;
import java.io.Closeable;
-import java.lang.System.Logger.Level;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
@@ -318,11 +316,33 @@
downstreamSubscriber.onNext(b);
datasent = true;
}
- if (datasent) upstreamWindowUpdate();
+
+ // If we have sent some decrypted data downstream,
+ // or if:
+ // - there's nothing more available to send downstream
+ // - and we still have some demand from downstream
+ // - and upstream is not completed yet
+ // - and our demand from upstream has reached 0,
+ // then check whether we should request more data from
+ // upstream
+ if (datasent || outputQ.isEmpty()
+ && !downstreamSubscription.demand.isFulfilled()
+ && !upstreamCompleted
+ && upstreamWindow.get() == 0) {
+ upstreamWindowUpdate();
+ }
checkCompletion();
}
}
+ final int outputQueueSize() {
+ return outputQ.size();
+ }
+
+ final boolean hasNoOutputData() {
+ return outputQ.isEmpty();
+ }
+
void upstreamWindowUpdate() {
long downstreamQueueSize = outputQ.size();
long upstreamWindowSize = upstreamWindow.get();
@@ -341,7 +361,7 @@
throw new IllegalStateException("Single shot publisher");
}
this.upstreamSubscription = subscription;
- upstreamRequest(upstreamWindowUpdate(0, 0));
+ upstreamRequest(initialUpstreamDemand());
if (debug.on())
debug.log("calling downstreamSubscriber::onSubscribe on %s",
downstreamSubscriber);
@@ -356,7 +376,6 @@
if (prev <= 0)
throw new IllegalStateException("invalid onNext call");
incomingCaller(item, false);
- upstreamWindowUpdate();
}
private void upstreamRequest(long n) {
@@ -365,6 +384,16 @@
upstreamSubscription.request(n);
}
+ /**
+ * Initial demand that should be requested
+ * from upstream when we get the upstream subscription
+ * from {@link #onSubscribe(Flow.Subscription)}.
+ * @return The initial demand to request from upstream.
+ */
+ protected long initialUpstreamDemand() {
+ return 1;
+ }
+
protected void requestMore() {
if (upstreamWindow.get() == 0) {
upstreamRequest(1);
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java Mon Oct 28 18:43:04 2019 +0100
@@ -134,7 +134,8 @@
}
public XMLDSigRI() {
- /* We are the XMLDSig provider */
+ // This is the JDK XMLDSig provider, synced from
+ // Apache Santuario XML Security for Java, version 2.1.3
super("XMLDSig", VER, INFO);
final Provider p = this;
--- a/src/java.xml/share/legal/bcel.md Sat Oct 26 23:59:51 2019 +0200
+++ b/src/java.xml/share/legal/bcel.md Mon Oct 28 18:43:04 2019 +0100
@@ -1,4 +1,4 @@
-## Apache Commons Byte Code Engineering Library (BCEL) Version 6.0
+## Apache Commons Byte Code Engineering Library (BCEL) Version 6.3.1
### Apache Commons BCEL Notice
<pre>
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java Mon Oct 28 18:43:04 2019 +0100
@@ -55,17 +55,25 @@
ExpressionTree getExpression();
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* Returns the labels for this case.
* For default case, returns an empty list.
*
* @return labels for this case
* @since 12
*
- * @deprecated This method is modeling a case with multiple labels,
+ * @preview This method is modeling a case with multiple labels,
* which is part of a preview feature and may be removed
* if the preview feature is removed.
*/
- @Deprecated(forRemoval=true, since="12")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
List<? extends ExpressionTree> getExpressions();
/**
@@ -78,6 +86,14 @@
List<? extends StatementTree> getStatements();
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* For case with kind {@linkplain CaseKind#RULE},
* returns the statement or expression after the arrow.
* Returns {@code null} for case with kind
@@ -85,32 +101,41 @@
*
* @return case value or null
* @since 12
- *
- * @deprecated This method is modeling a rule case,
- * which is part of a preview feature and may be removed
- * if the preview feature is removed.
*/
- @Deprecated(forRemoval=true, since="12")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
public default Tree getBody() {
return null;
}
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* Returns the kind of this case.
*
* @return the kind of this case
* @since 12
- *
- * @deprecated This method is used to model a rule case,
- * which is part of a preview feature and may be removed
- * if the preview feature is removed.
*/
- @Deprecated(forRemoval=true, since="12")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
+ @SuppressWarnings("preview")
public default CaseKind getCaseKind() {
return CaseKind.STATEMENT;
}
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This enum is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* The syntatic form of this case:
* <ul>
* <li>STATEMENT: {@code case <expression>: <statements>}</li>
@@ -118,12 +143,9 @@
* </ul>
*
* @since 12
- *
- * @deprecated This enum is used to model a rule case,
- * which is part of a preview feature and may be removed
- * if the preview feature is removed.
*/
- @Deprecated(forRemoval=true, since="12")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
+ @SuppressWarnings("preview")
public enum CaseKind {
/**
* Case is in the form: {@code case <expression>: <statements>}.
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java Mon Oct 28 18:43:04 2019 +0100
@@ -28,6 +28,14 @@
import java.util.List;
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This interface is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* A tree node for a {@code switch} expression.
*
* For example:
@@ -40,12 +48,8 @@
* @jls 15.29 Switch Expressions
*
* @since 12
- *
- * @deprecated This method is modeling switch expressions,
- * which are part of a preview feature and may be removed
- * if the preview feature is removed.
*/
-@Deprecated(forRemoval=true, since="12")
+@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
public interface SwitchExpressionTree extends ExpressionTree {
/**
* Returns the expression for the {@code switch} expression.
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java Mon Oct 28 18:43:04 2019 +0100
@@ -240,17 +240,20 @@
SWITCH(SwitchTree.class),
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This enum constant is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* Used for instances of {@link SwitchExpressionTree}.
*
* @since 12
- *
- * @deprecated
- * This enum constant is modeling switch expressions,
- * which are part of a preview feature and may be removed
- * if the preview feature is removed.
*/
- @Deprecated(forRemoval=true, since="12")
- @SuppressWarnings("removal")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
+ @SuppressWarnings("preview")
SWITCH_EXPRESSION(SwitchExpressionTree.class),
/**
@@ -659,17 +662,20 @@
OTHER(null),
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This enum constant is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* Used for instances of {@link YieldTree}.
*
* @since 13
- *
- * @deprecated
- * This enum constant is modeling yield statement,
- * which are part of a preview feature and may be removed
- * if the preview feature is removed.
*/
- @Deprecated(forRemoval=true, since="13")
- @SuppressWarnings("removal")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
+ @SuppressWarnings("preview")
YIELD(YieldTree.class);
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java Mon Oct 28 18:43:04 2019 +0100
@@ -354,20 +354,23 @@
R visitSwitch(SwitchTree node, P p);
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* Visits a SwitchExpressionTree node.
*
* @param node the node being visited
* @param p a parameter value
* @return a result value
* @since 12
- *
- * @deprecated
- * This method is modeling switch expressions,
- * which are part of a preview feature and may be removed
- * if the preview feature is removed.
*/
- @Deprecated(forRemoval=true, since="12")
- @SuppressWarnings("removal")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
+ @SuppressWarnings("preview")
R visitSwitchExpression(SwitchExpressionTree node, P p);
/**
@@ -557,18 +560,21 @@
R visitOther(Tree node, P p);
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* Visits a YieldTree node.
* @param node the node being visited
* @param p a parameter value
* @return a result value
* @since 13
- *
- * @deprecated
- * This method is modeling yield statement,
- * which are part of a preview feature and may be removed
- * if the preview feature is removed.
*/
- @Deprecated(forRemoval=true, since="13")
- @SuppressWarnings("removal")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
+ @SuppressWarnings("preview")
R visitYield(YieldTree node, P p);
}
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/YieldTree.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/YieldTree.java Mon Oct 28 18:43:04 2019 +0100
@@ -26,6 +26,14 @@
package com.sun.source.tree;
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* A tree node for a {@code yield} statement.
*
* For example:
@@ -36,12 +44,8 @@
* @jls section TODO
*
* @since 13
- *
- * @deprecated This class is modeling yield from switch expressions,
- * which are part of a preview feature and may be removed if
- * the preview feature is removed.
*/
-@Deprecated(forRemoval=true, since="13")
+@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
public interface YieldTree extends StatementTree {
/**
--- a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java Mon Oct 28 18:43:04 2019 +0100
@@ -264,20 +264,23 @@
}
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
- *
- * @deprecated
- * This method is modeling switch expressions,
- * which are part of a preview feature and may be removed
- * if the preview feature is removed.
*/
@Override
- @Deprecated(forRemoval=true, since="12")
- @SuppressWarnings("removal")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
+ @SuppressWarnings("preview")
public R visitSwitchExpression(SwitchExpressionTree node, P p) {
return defaultAction(node, p);
}
@@ -791,8 +794,8 @@
* @return the result of {@code defaultAction}
*/
@Override
- @Deprecated(forRemoval=true, since="13")
- @SuppressWarnings("removal")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
+ @SuppressWarnings("preview")
public R visitYield(YieldTree node, P p) {
return defaultAction(node, p);
}
--- a/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java Mon Oct 28 18:43:04 2019 +0100
@@ -26,7 +26,6 @@
package com.sun.source.util;
import com.sun.source.tree.*;
-import com.sun.source.tree.CaseTree.CaseKind;
/**
* A TreeVisitor that visits all the child tree nodes.
@@ -335,20 +334,23 @@
}
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* {@inheritDoc} This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
- *
- * @deprecated
- * This method is modeling switch expressions,
- * which are part of a preview feature and may be removed
- * if the preview feature is removed.
*/
@Override
- @Deprecated(forRemoval=true, since="12")
- @SuppressWarnings("removal")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
+ @SuppressWarnings("preview")
public R visitSwitchExpression(SwitchExpressionTree node, P p) {
R r = scan(node.getExpression(), p);
r = scanAndReduce(node.getCases(), p, r);
@@ -363,10 +365,10 @@
* @return the result of scanning
*/
@Override
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public R visitCase(CaseTree node, P p) {
R r = scan(node.getExpressions(), p);
- if (node.getCaseKind() == CaseKind.RULE)
+ if (node.getCaseKind() == CaseTree.CaseKind.RULE)
r = scanAndReduce(node.getBody(), p, r);
else
r = scanAndReduce(node.getStatements(), p, r);
@@ -936,20 +938,23 @@
}
/**
+ * {@preview Associated with switch expressions, a preview feature of
+ * the Java language.
+ *
+ * This method is associated with <i>switch expressions</i>, a preview
+ * feature of the Java language. Preview features
+ * may be removed in a future release, or upgraded to permanent
+ * features of the Java language.}
+ *
* {@inheritDoc} This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
- *
- * @deprecated
- * This method is modeling switch expressions,
- * which are part of a preview feature and may be removed
- * if the preview feature is removed.
*/
@Override
- @Deprecated(forRemoval=true, since="13")
- @SuppressWarnings("removal")
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
+ @SuppressWarnings("preview")
public R visitYield(YieldTree node, P p) {
return scan(node.getValue(), p);
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskPool.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskPool.java Mon Oct 28 18:43:04 2019 +0100
@@ -52,6 +52,7 @@
import com.sun.source.util.TaskListener;
import com.sun.source.util.TreeScanner;
import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Preview;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.code.Type;
@@ -257,6 +258,8 @@
((ReusableJavaCompiler)ReusableJavaCompiler.instance(this)).clear();
Types.instance(this).newRound();
Check.instance(this).newRound();
+ Check.instance(this).clear(); //clear mandatory warning handlers
+ Preview.instance(this).clear(); //clear mandatory warning handlers
Modules.instance(this).newRound();
Annotate.instance(this).newRound();
CompileStates.instance(this).clear();
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java Mon Oct 28 18:43:04 2019 +0100
@@ -286,7 +286,17 @@
/**
* Flag to indicate the given ModuleSymbol is an automatic module.
*/
- public static final long AUTOMATIC_MODULE = 1L<<52;
+ public static final long AUTOMATIC_MODULE = 1L<<52; //ModuleSymbols only
+
+ /**
+ * Flag to indicate the given PackageSymbol contains any non-.java and non-.class resources.
+ */
+ public static final long HAS_RESOURCE = 1L<<52; //PackageSymbols only
+
+ /**
+ * Flag to indicate the given ParamSymbol has a user-friendly name filled.
+ */
+ public static final long NAME_FILLED = 1L<<52; //ParamSymbols only
/**
* Flag to indicate the given ModuleSymbol is a system module.
@@ -304,9 +314,9 @@
public static final long DEPRECATED_REMOVAL = 1L<<55;
/**
- * Flag to indicate the given PackageSymbol contains any non-.java and non-.class resources.
+ * Flag to indicate the API element in question is for a preview API.
*/
- public static final long HAS_RESOURCE = 1L<<56;
+ public static final long PREVIEW_API = 1L<<56; //any Symbol kind
/**
* Flag for synthesized default constructors of anonymous classes that have an enclosing expression.
@@ -320,9 +330,9 @@
public static final long BODY_ONLY_FINALIZE = 1L<<17; //blocks only
/**
- * Flag to indicate the given ParamSymbol has a user-friendly name filled.
+ * Flag to indicate the API element in question is for a preview API.
*/
- public static final long NAME_FILLED = 1L<<58; //ParamSymbols only
+ public static final long PREVIEW_ESSENTIAL_API = 1L<<58; //any Symbol kind
/** Modifier masks.
*/
@@ -441,7 +451,9 @@
HAS_RESOURCE(Flags.HAS_RESOURCE),
POTENTIALLY_AMBIGUOUS(Flags.POTENTIALLY_AMBIGUOUS),
ANONCONSTR_BASED(Flags.ANONCONSTR_BASED),
- NAME_FILLED(Flags.NAME_FILLED);
+ NAME_FILLED(Flags.NAME_FILLED),
+ PREVIEW_API(Flags.PREVIEW_API),
+ PREVIEW_ESSENTIAL_API(Flags.PREVIEW_ESSENTIAL_API);
Flag(long flag) {
this.value = flag;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java Mon Oct 28 18:43:04 2019 +0100
@@ -122,6 +122,9 @@
values.add(LintCategory.OPENS);
values.add(LintCategory.MODULE);
values.add(LintCategory.REMOVAL);
+ if (!options.isSet(Option.PREVIEW)) {
+ values.add(LintCategory.PREVIEW);
+ }
}
// Look for specific overrides
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java Mon Oct 28 18:43:04 2019 +0100
@@ -27,7 +27,6 @@
import com.sun.tools.javac.code.Lint.LintCategory;
import com.sun.tools.javac.code.Source.Feature;
-import com.sun.tools.javac.comp.Infer;
import com.sun.tools.javac.jvm.Target;
import com.sun.tools.javac.resources.CompilerProperties.Errors;
import com.sun.tools.javac.resources.CompilerProperties.Warnings;
@@ -36,17 +35,14 @@
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
import com.sun.tools.javac.util.JCDiagnostic.Error;
import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
+import com.sun.tools.javac.util.JCDiagnostic.Warning;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.MandatoryWarningHandler;
-import com.sun.tools.javac.util.Name;
import com.sun.tools.javac.util.Options;
import javax.tools.JavaFileObject;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
import static com.sun.tools.javac.main.Option.PREVIEW;
@@ -62,7 +58,7 @@
*/
public class Preview {
- /** flag: are preview featutres enabled */
+ /** flag: are preview features enabled */
private final boolean enabled;
/** the diag handler to manage preview feature usage diagnostics */
@@ -151,6 +147,10 @@
}
}
+ public void reportPreviewWarning(DiagnosticPosition pos, Warning warnKey) {
+ previewHandler.report(pos, warnKey);
+ }
+
/**
* Are preview features enabled?
* @return true, if preview features are enabled.
@@ -206,4 +206,9 @@
public void reportDeferredDiagnostics() {
previewHandler.reportDeferredDiagnostic();
}
+
+ public void clear() {
+ previewHandler.clear();
+ }
+
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Mon Oct 28 18:43:04 2019 +0100
@@ -378,6 +378,10 @@
return (flags_field & DEPRECATED_REMOVAL) != 0;
}
+ public boolean isPreviewApi() {
+ return (flags_field & PREVIEW_API) != 0;
+ }
+
public boolean isDeprecatableViaAnnotation() {
switch (getKind()) {
case LOCAL_VARIABLE:
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java Mon Oct 28 18:43:04 2019 +0100
@@ -214,6 +214,7 @@
public final Type documentedType;
public final Type elementTypeType;
public final Type functionalInterfaceType;
+ public final Type previewFeatureType;
/** The symbol representing the length field of an array.
*/
@@ -570,6 +571,7 @@
lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
stringConcatFactory = enterClass("java.lang.invoke.StringConcatFactory");
functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
+ previewFeatureType = enterClass("jdk.internal.PreviewFeature");
synthesizeEmptyInterfaceIfMissing(autoCloseableType);
synthesizeEmptyInterfaceIfMissing(cloneableType);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Mon Oct 28 18:43:04 2019 +0100
@@ -364,12 +364,17 @@
&& (toAnnotate.kind == MDL || toAnnotate.owner.kind != MTH)
&& types.isSameType(c.type, syms.deprecatedType)) {
toAnnotate.flags_field |= (Flags.DEPRECATED | Flags.DEPRECATED_ANNOTATION);
- Attribute fr = c.member(names.forRemoval);
- if (fr instanceof Attribute.Constant) {
- Attribute.Constant v = (Attribute.Constant) fr;
- if (v.type == syms.booleanType && ((Integer) v.value) != 0) {
- toAnnotate.flags_field |= Flags.DEPRECATED_REMOVAL;
- }
+ if (isAttributeTrue(c.member(names.forRemoval))) {
+ toAnnotate.flags_field |= Flags.DEPRECATED_REMOVAL;
+ }
+ }
+
+ // Note: @Deprecated has no effect on local variables and parameters
+ if (!c.type.isErroneous()
+ && types.isSameType(c.type, syms.previewFeatureType)) {
+ toAnnotate.flags_field |= Flags.PREVIEW_API;
+ if (isAttributeTrue(c.member(names.essentialAPI))) {
+ toAnnotate.flags_field |= Flags.PREVIEW_ESSENTIAL_API;
}
}
}
@@ -397,6 +402,16 @@
toAnnotate.setDeclarationAttributes(attrs);
}
}
+ //where:
+ private boolean isAttributeTrue(Attribute attr) {
+ if (attr instanceof Attribute.Constant) {
+ Attribute.Constant v = (Attribute.Constant) attr;
+ if (v.type == syms.booleanType && ((Integer) v.value) != 0) {
+ return true;
+ }
+ }
+ return false;
+ }
/**
* Attribute and store a semantic representation of the annotation tree {@code tree} into the
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Mon Oct 28 18:43:04 2019 +0100
@@ -32,7 +32,7 @@
import javax.lang.model.element.ElementKind;
import javax.tools.JavaFileObject;
-import com.sun.source.tree.CaseTree.CaseKind;
+import com.sun.source.tree.CaseTree;
import com.sun.source.tree.IdentifierTree;
import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
import com.sun.source.tree.MemberSelectTree;
@@ -1486,8 +1486,8 @@
// check that there are no duplicate case labels or default clauses.
Set<Object> labels = new HashSet<>(); // The set of case labels.
boolean hasDefault = false; // Is there a default label?
- @SuppressWarnings("removal")
- CaseKind caseKind = null;
+ @SuppressWarnings("preview")
+ CaseTree.CaseKind caseKind = null;
boolean wasError = false;
for (List<JCCase> l = cases; l.nonEmpty(); l = l.tail) {
JCCase c = l.head;
@@ -4092,6 +4092,7 @@
chk.checkDeprecated(tree.pos(), env.info.scope.owner, sym);
chk.checkSunAPI(tree.pos(), sym);
chk.checkProfile(tree.pos(), sym);
+ chk.checkPreview(tree.pos(), sym);
}
// If symbol is a variable, check that its type and
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Mon Oct 28 18:43:04 2019 +0100
@@ -93,6 +93,7 @@
private final Source source;
private final Target target;
private final Profile profile;
+ private final Preview preview;
private final boolean warnOnAnyAccessToMembers;
// The set of lint options currently in effect. It is initialized
@@ -139,6 +140,7 @@
syntheticNameChar = target.syntheticNameChar();
profile = Profile.instance(context);
+ preview = Preview.instance(context);
boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION);
boolean verboseRemoval = lint.isEnabled(LintCategory.REMOVAL);
@@ -224,6 +226,23 @@
}
}
+ /** Warn about deprecated symbol.
+ * @param pos Position to be used for error reporting.
+ * @param sym The deprecated symbol.
+ */
+ void warnPreview(DiagnosticPosition pos, Symbol sym) {
+ warnPreview(pos, Warnings.IsPreview(sym));
+ }
+
+ /** Log a preview warning.
+ * @param pos Position to be used for error reporting.
+ * @param msg A Warning describing the problem.
+ */
+ public void warnPreview(DiagnosticPosition pos, Warning warnKey) {
+ if (!lint.isSuppressed(LintCategory.PREVIEW))
+ preview.reportPreviewWarning(pos, warnKey);
+ }
+
/** Warn about unchecked operation.
* @param pos Position to be used for error reporting.
* @param msg A string describing the problem.
@@ -434,6 +453,13 @@
localClassNameIndexes.clear();
}
+ public void clear() {
+ deprecationHandler.clear();
+ removalHandler.clear();
+ uncheckedHandler.clear();
+ sunApiHandler.clear();
+ }
+
public void putCompiled(ClassSymbol csym) {
compiled.put(Pair.of(csym.packge().modle, csym.flatname), csym);
}
@@ -3290,6 +3316,16 @@
}
}
+ void checkPreview(DiagnosticPosition pos, Symbol s) {
+ if ((s.flags() & PREVIEW_API) != 0) {
+ if ((s.flags() & PREVIEW_ESSENTIAL_API) != 0 && !preview.isEnabled()) {
+ log.error(pos, Errors.IsPreview(s));
+ } else {
+ deferredLintHandler.report(() -> warnPreview(pos, s));
+ }
+ }
+ }
+
/* *************************************************************************
* Check for recursive annotation elements.
**************************************************************************/
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java Mon Oct 28 18:43:04 2019 +0100
@@ -30,7 +30,6 @@
import java.util.function.Function;
import java.util.stream.Stream;
-import com.sun.source.tree.CaseTree.CaseKind;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Kinds.KindSelector;
import com.sun.tools.javac.code.Scope.WriteableScope;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Oct 28 18:43:04 2019 +0100
@@ -2819,6 +2819,7 @@
typeargtypes, allowBoxing,
useVarargs);
chk.checkDeprecated(pos, env.info.scope.owner, sym);
+ chk.checkPreview(pos, sym);
return sym;
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java Mon Oct 28 18:43:04 2019 +0100
@@ -1156,19 +1156,26 @@
JCAnnotation a = al.head;
if (a.annotationType.type == syms.deprecatedType) {
sym.flags_field |= (Flags.DEPRECATED | Flags.DEPRECATED_ANNOTATION);
- a.args.stream()
- .filter(e -> e.hasTag(ASSIGN))
- .map(e -> (JCAssign) e)
- .filter(assign -> TreeInfo.name(assign.lhs) == names.forRemoval)
- .findFirst()
- .ifPresent(assign -> {
- JCExpression rhs = TreeInfo.skipParens(assign.rhs);
- if (rhs.hasTag(LITERAL)
- && Boolean.TRUE.equals(((JCLiteral) rhs).getValue())) {
- sym.flags_field |= DEPRECATED_REMOVAL;
- }
- });
+ setFlagIfAttributeTrue(a, sym, names.forRemoval, DEPRECATED_REMOVAL);
+ } else if (a.annotationType.type == syms.previewFeatureType) {
+ sym.flags_field |= Flags.PREVIEW_API;
+ setFlagIfAttributeTrue(a, sym, names.essentialAPI, PREVIEW_ESSENTIAL_API);
}
}
}
+ //where:
+ private void setFlagIfAttributeTrue(JCAnnotation a, Symbol sym, Name attribute, long flag) {
+ a.args.stream()
+ .filter(e -> e.hasTag(ASSIGN))
+ .map(e -> (JCAssign) e)
+ .filter(assign -> TreeInfo.name(assign.lhs) == attribute)
+ .findFirst()
+ .ifPresent(assign -> {
+ JCExpression rhs = TreeInfo.skipParens(assign.rhs);
+ if (rhs.hasTag(LITERAL)
+ && Boolean.TRUE.equals(((JCLiteral) rhs).getValue())) {
+ sym.flags_field |= flag;
+ }
+ });
+ }
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java Mon Oct 28 18:43:04 2019 +0100
@@ -44,6 +44,7 @@
import java.nio.file.Path;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
@@ -173,6 +174,10 @@
private long lastUsedTime = System.currentTimeMillis();
protected long deferredCloseTimeout = 0;
+ public void clear() {
+ new HashSet<>(options.keySet()).forEach(k -> options.remove(k));
+ }
+
protected ClassLoader getClassLoader(URL[] urls) {
ClassLoader thisClassLoader = getClass().getClassLoader();
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Oct 28 18:43:04 2019 +0100
@@ -1395,20 +1395,27 @@
repeatable = proxy;
} else if (proxy.type.tsym == syms.deprecatedType.tsym) {
sym.flags_field |= (DEPRECATED | DEPRECATED_ANNOTATION);
- for (Pair<Name, Attribute> v : proxy.values) {
- if (v.fst == names.forRemoval && v.snd instanceof Attribute.Constant) {
- Attribute.Constant c = (Attribute.Constant)v.snd;
- if (c.type == syms.booleanType && ((Integer)c.value) != 0) {
- sym.flags_field |= DEPRECATED_REMOVAL;
- }
- }
- }
+ setFlagIfAttributeTrue(proxy, sym, names.forRemoval, DEPRECATED_REMOVAL);
+ } else if (proxy.type.tsym == syms.previewFeatureType.tsym) {
+ sym.flags_field |= PREVIEW_API;
+ setFlagIfAttributeTrue(proxy, sym, names.essentialAPI, PREVIEW_ESSENTIAL_API);
}
proxies.append(proxy);
}
}
annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
}
+ //where:
+ private void setFlagIfAttributeTrue(CompoundAnnotationProxy proxy, Symbol sym, Name attribute, long flag) {
+ for (Pair<Name, Attribute> v : proxy.values) {
+ if (v.fst == attribute && v.snd instanceof Attribute.Constant) {
+ Attribute.Constant c = (Attribute.Constant)v.snd;
+ if (c.type == syms.booleanType && ((Integer)c.value) != 0) {
+ sym.flags_field |= flag;
+ }
+ }
+ }
+ }
/** Read parameter annotations.
*/
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Oct 28 18:43:04 2019 +0100
@@ -29,7 +29,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;
-import com.sun.source.tree.CaseTree.CaseKind;
+import com.sun.source.tree.CaseTree;
import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
import com.sun.source.tree.ModuleTree.ModuleKind;
@@ -1432,8 +1432,8 @@
}
List<JCStatement> stats = null;
JCTree body = null;
- @SuppressWarnings("removal")
- CaseKind kind;
+ @SuppressWarnings("preview")
+ CaseTree.CaseKind kind;
switch (token.kind) {
case ARROW:
checkSourceLevel(Feature.SWITCH_RULE);
@@ -2897,8 +2897,8 @@
nextToken();
checkSourceLevel(Feature.SWITCH_MULTIPLE_CASE_LABELS);
};
- @SuppressWarnings("removal")
- CaseKind caseKind;
+ @SuppressWarnings("preview")
+ CaseTree.CaseKind caseKind;
JCTree body = null;
if (token.kind == ARROW) {
checkSourceLevel(Feature.SWITCH_RULE);
@@ -2922,8 +2922,8 @@
}
case DEFAULT: {
nextToken();
- @SuppressWarnings("removal")
- CaseKind caseKind;
+ @SuppressWarnings("preview")
+ CaseTree.CaseKind caseKind;
JCTree body = null;
if (token.kind == ARROW) {
checkSourceLevel(Feature.SWITCH_RULE);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Oct 28 18:43:04 2019 +0100
@@ -1775,6 +1775,14 @@
{0} in {1} has been deprecated and marked for removal
# 0: symbol
+compiler.warn.is.preview=\
+ {0} is an API that is part of a preview feature
+
+# 0: symbol
+compiler.err.is.preview=\
+ {0} is an API that is part of a preview feature
+
+# 0: symbol
compiler.warn.has.been.deprecated.module=\
module {0} has been deprecated
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java Mon Oct 28 18:43:04 2019 +0100
@@ -47,7 +47,6 @@
import javax.tools.JavaFileManager.Location;
-import com.sun.source.tree.CaseTree.CaseKind;
import com.sun.source.tree.ModuleTree.ModuleKind;
import com.sun.tools.javac.code.Directive.ExportsDirective;
import com.sun.tools.javac.code.Directive.OpensDirective;
@@ -1250,17 +1249,17 @@
public static class JCCase extends JCStatement implements CaseTree {
//as CaseKind is deprecated for removal (as it is part of a preview feature),
//using indirection through these fields to avoid unnecessary @SuppressWarnings:
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public static final CaseKind STATEMENT = CaseKind.STATEMENT;
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public static final CaseKind RULE = CaseKind.RULE;
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public final CaseKind caseKind;
public List<JCExpression> pats;
public List<JCStatement> stats;
public JCTree body;
public boolean completesNormally;
- protected JCCase(@SuppressWarnings("removal") CaseKind caseKind, List<JCExpression> pats,
+ protected JCCase(@SuppressWarnings("preview") CaseKind caseKind, List<JCExpression> pats,
List<JCStatement> stats, JCTree body) {
Assert.checkNonNull(pats);
Assert.check(pats.isEmpty() || pats.head != null);
@@ -1277,18 +1276,18 @@
@Override @DefinedBy(Api.COMPILER_TREE)
public JCExpression getExpression() { return pats.head; }
@Override @DefinedBy(Api.COMPILER_TREE)
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public List<JCExpression> getExpressions() { return pats; }
@Override @DefinedBy(Api.COMPILER_TREE)
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public List<JCStatement> getStatements() {
return caseKind == CaseKind.STATEMENT ? stats : null;
}
@Override @DefinedBy(Api.COMPILER_TREE)
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public JCTree getBody() { return body; }
@Override @DefinedBy(Api.COMPILER_TREE)
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public CaseKind getCaseKind() {
return caseKind;
}
@@ -1305,7 +1304,7 @@
/**
* A "switch ( ) { }" construction.
*/
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree {
public JCExpression selector;
public List<JCCase> cases;
@@ -1586,7 +1585,7 @@
/**
* A break-with from a switch expression.
*/
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public static class JCYield extends JCStatement implements YieldTree {
public JCExpression value;
public JCTree target;
@@ -3105,7 +3104,7 @@
JCLabeledStatement Labelled(Name label, JCStatement body);
JCSwitch Switch(JCExpression selector, List<JCCase> cases);
JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases);
- JCCase Case(@SuppressWarnings("removal") CaseKind caseKind, List<JCExpression> pat,
+ JCCase Case(@SuppressWarnings("preview") CaseTree.CaseKind caseKind, List<JCExpression> pat,
List<JCStatement> stats, JCTree body);
JCSynchronized Synchronized(JCExpression lock, JCBlock body);
JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java Mon Oct 28 18:43:04 2019 +0100
@@ -27,7 +27,6 @@
import java.io.*;
-import com.sun.source.tree.CaseTree.CaseKind;
import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
import com.sun.source.tree.ModuleTree.ModuleKind;
import com.sun.tools.javac.code.*;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java Mon Oct 28 18:43:04 2019 +0100
@@ -144,7 +144,7 @@
}
@DefinedBy(Api.COMPILER_TREE)
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public JCTree visitYield(YieldTree node, P p) {
JCYield t = (JCYield) node;
JCExpression value = copy(t.value, p);
@@ -380,7 +380,7 @@
}
@DefinedBy(Api.COMPILER_TREE)
- @SuppressWarnings("removal")
+ @SuppressWarnings("preview")
public JCTree visitSwitchExpression(SwitchExpressionTree node, P p) {
JCSwitchExpression t = (JCSwitchExpression) node;
JCExpression selector = copy(t.selector, p);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java Mon Oct 28 18:43:04 2019 +0100
@@ -27,7 +27,7 @@
import java.util.Iterator;
-import com.sun.source.tree.CaseTree.CaseKind;
+import com.sun.source.tree.CaseTree;
import com.sun.source.tree.ModuleTree.ModuleKind;
import com.sun.source.tree.Tree.Kind;
import com.sun.tools.javac.code.*;
@@ -274,7 +274,7 @@
return tree;
}
- public JCCase Case(@SuppressWarnings("removal") CaseKind caseKind, List<JCExpression> pats,
+ public JCCase Case(@SuppressWarnings("preview") CaseTree.CaseKind caseKind, List<JCExpression> pats,
List<JCStatement> stats, JCTree body) {
JCCase tree = new JCCase(caseKind, pats, stats, body);
tree.pos = pos;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java Mon Oct 28 18:43:04 2019 +0100
@@ -186,18 +186,18 @@
/**
* The log to which to report warnings.
*/
- private Log log;
+ private final Log log;
/**
* Whether or not to report individual warnings, or simply to report a
* single aggregate warning at the end of the compilation.
*/
- private boolean verbose;
+ private final boolean verbose;
/**
* The common prefix for all I18N message keys generated by this handler.
*/
- private String prefix;
+ private final String prefix;
/**
* A set containing the names of the source files for which specific
@@ -262,4 +262,11 @@
else
log.note(file, new Note("compiler", msg, args));
}
+
+ public void clear() {
+ sourcesWithReportedWarnings = null;
+ deferredDiagnosticKind = null;
+ deferredDiagnosticSource = null;
+ deferredDiagnosticArg = null;
+ }
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java Mon Oct 28 18:43:04 2019 +0100
@@ -86,6 +86,7 @@
public final Name error;
public final Name finalize;
public final Name forRemoval;
+ public final Name essentialAPI;
public final Name getClass;
public final Name hasNext;
public final Name hashCode;
@@ -236,6 +237,7 @@
error = fromString("<error>");
finalize = fromString("finalize");
forRemoval = fromString("forRemoval");
+ essentialAPI = fromString("essentialAPI");
getClass = fromString("getClass");
hasNext = fromString("hasNext");
hashCode = fromString("hashCode");
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java Mon Oct 28 18:43:04 2019 +0100
@@ -130,10 +130,19 @@
if (c.contains(pc)) {
CodeBlob cb = c.findBlobUnsafe(pc);
if (cb.isNMethod()) {
- names = getJavaNames(th, f.localVariableBase());
- // just print compiled code, if can't determine method
- if (names == null || names.length == 0) {
- out.println("<Unknown compiled code>");
+ if (cb.isNativeMethod()) {
+ out.print(((CompiledMethod)cb).getMethod().externalNameAndSignature());
+ long diff = pc.minus(cb.codeBegin());
+ if (diff != 0L) {
+ out.print(" + 0x" + Long.toHexString(diff));
+ }
+ out.println(" (Native method)");
+ } else {
+ names = getJavaNames(th, f.localVariableBase());
+ // just print compiled code, if can't determine method
+ if (names == null || names.length == 0) {
+ out.println("<Unknown compiled code>");
+ }
}
} else if (cb.isBufferBlob()) {
out.println("<StubRoutines>");
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -127,8 +127,8 @@
return new HotSpotConstantReflectionProvider(runtime);
}
- private static RegisterConfig createRegisterConfig(AArch64HotSpotVMConfig config, TargetDescription target) {
- return new AArch64HotSpotRegisterConfig(target, config.useCompressedOops);
+ private static RegisterConfig createRegisterConfig(TargetDescription target) {
+ return new AArch64HotSpotRegisterConfig(target);
}
protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntime runtime, TargetDescription target, RegisterConfig regConfig) {
@@ -167,7 +167,7 @@
metaAccess = createMetaAccess(runtime);
}
try (InitTimer rt = timer("create RegisterConfig")) {
- regConfig = createRegisterConfig(config, target);
+ regConfig = createRegisterConfig(target);
}
try (InitTimer rt = timer("create CodeCache provider")) {
codeCache = createCodeCache(runtime, target, regConfig);
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -126,11 +126,19 @@
public static final Register threadRegister = r28;
public static final Register fp = r29;
- private static final RegisterArray reservedRegisters = new RegisterArray(rscratch1, rscratch2, threadRegister, fp, lr, r31, zr, sp);
+ /**
+ * The heapBaseRegister, i.e. r27, is reserved unconditionally because HotSpot does not intend
+ * to support it as an allocatable register even when compressed oops is off. This register is
+ * excluded from callee-saved register at
+ * cpu/aarch64/sharedRuntime_aarch64.cpp:RegisterSaver::save_live_registers, which may lead to
+ * dereferencing unknown value from the stack at
+ * share/runtime/stackValue.cpp:StackValue::create_stack_value during deoptimization.
+ */
+ private static final RegisterArray reservedRegisters = new RegisterArray(rscratch1, rscratch2, heapBaseRegister, threadRegister, fp, lr, r31, zr, sp);
- private static RegisterArray initAllocatable(Architecture arch, boolean reserveForHeapBase) {
+ private static RegisterArray initAllocatable(Architecture arch) {
RegisterArray allRegisters = arch.getAvailableValueRegisters();
- Register[] registers = new Register[allRegisters.size() - reservedRegisters.size() - (reserveForHeapBase ? 1 : 0)];
+ Register[] registers = new Register[allRegisters.size() - reservedRegisters.size()];
List<Register> reservedRegistersList = reservedRegisters.asList();
int idx = 0;
@@ -139,12 +147,7 @@
// skip reserved registers
continue;
}
- assert !(reg.equals(threadRegister) || reg.equals(fp) || reg.equals(lr) || reg.equals(r31) || reg.equals(zr) || reg.equals(sp));
- if (reserveForHeapBase && reg.equals(heapBaseRegister)) {
- // skip heap base register
- continue;
- }
-
+ assert !(reg.equals(heapBaseRegister) || reg.equals(threadRegister) || reg.equals(fp) || reg.equals(lr) || reg.equals(r31) || reg.equals(zr) || reg.equals(sp)) : reg;
registers[idx++] = reg;
}
@@ -152,8 +155,8 @@
return new RegisterArray(registers);
}
- public AArch64HotSpotRegisterConfig(TargetDescription target, boolean useCompressedOops) {
- this(target, initAllocatable(target.arch, useCompressedOops));
+ public AArch64HotSpotRegisterConfig(TargetDescription target) {
+ this(target, initAllocatable(target.arch));
assert callerSaved.size() >= allocatable.size();
}
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Mon Oct 28 18:43:04 2019 +0100
@@ -967,6 +967,11 @@
native boolean isCurrentThreadAttached();
/**
+ * @see HotSpotJVMCIRuntime#getCurrentJavaThread()
+ */
+ native long getCurrentJavaThread();
+
+ /**
* @see HotSpotJVMCIRuntime#attachCurrentThread
*/
native boolean attachCurrentThread(boolean asDaemon);
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Mon Oct 28 18:43:04 2019 +0100
@@ -999,6 +999,14 @@
}
/**
+ * Gets the address of the HotSpot {@code JavaThread} C++ object for the current thread. This
+ * will return {@code 0} if called from an unattached JVMCI shared library thread.
+ */
+ public long getCurrentJavaThread() {
+ return compilerToVm.getCurrentJavaThread();
+ }
+
+ /**
* Ensures the current thread is attached to the peer runtime.
*
* @param asDaemon if the thread is not yet attached, should it be attached as a daemon
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaType.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaType.java Mon Oct 28 18:43:04 2019 +0100
@@ -52,4 +52,13 @@
}
return arrayOfType;
}
+
+ /**
+ * Checks whether this type is currently being initialized. If a type is being initialized it
+ * implies that it was {@link #isLinked() linked} and that the static initializer is currently
+ * being run.
+ *
+ * @return {@code true} if this type is being initialized
+ */
+ abstract boolean isBeingInitialized();
}
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Mon Oct 28 18:43:04 2019 +0100
@@ -360,6 +360,11 @@
}
@Override
+ public boolean isBeingInitialized() {
+ return isArray() ? false : getInitState() == config().instanceKlassStateBeingInitialized;
+ }
+
+ @Override
public boolean isLinked() {
return isArray() ? true : getInitState() >= config().instanceKlassStateLinked;
}
@@ -379,7 +384,7 @@
public void initialize() {
if (!isInitialized()) {
runtime().compilerToVm.ensureInitialized(this);
- assert isInitialized();
+ assert isInitialized() || isBeingInitialized();
}
}
@@ -578,11 +583,6 @@
return new AssumptionResult<>(resolvedMethod);
}
- if (resolvedMethod.canBeStaticallyBound()) {
- // No assumptions are required.
- return new AssumptionResult<>(resolvedMethod);
- }
-
ResolvedJavaMethod result = resolvedMethod.uniqueConcreteMethod(this);
if (result != null) {
return new AssumptionResult<>(result, new ConcreteMethod(method, this, result));
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java Mon Oct 28 18:43:04 2019 +0100
@@ -150,6 +150,11 @@
}
@Override
+ public boolean isBeingInitialized() {
+ return false;
+ }
+
+ @Override
public boolean isLinked() {
return true;
}
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationEncoding.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationEncoding.java Mon Oct 28 18:43:04 2019 +0100
@@ -29,7 +29,6 @@
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
-import jdk.vm.ci.common.JVMCIError;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
import jdk.vm.ci.meta.SpeculationLog.SpeculationReasonEncoding;
@@ -37,8 +36,8 @@
/**
* Implements a {@link SpeculationReasonEncoding} that {@linkplain #getByteArray() produces} a byte
* array. Data is added via a {@link DataOutputStream}. When producing the final byte array, if the
- * total length of data exceeds the length of a SHA-1 digest, then a SHA-1 digest of the data is
- * produced instead.
+ * total length of data exceeds the length of a SHA-1 digest and a SHA-1 digest algorithm is
+ * available, then a SHA-1 digest of the data is produced instead.
*/
final class HotSpotSpeculationEncoding extends ByteArrayOutputStream implements SpeculationReasonEncoding {
@@ -152,21 +151,33 @@
}
/**
- * Prototype SHA1 digest that is cloned before use.
+ * Prototype SHA1 digest.
*/
- private static final MessageDigest SHA1 = getSHA1();
- private static final int SHA1_LENGTH = SHA1.getDigestLength();
+ private static final MessageDigest SHA1;
- private static MessageDigest getSHA1() {
+ /**
+ * Cloning the prototype is quicker than calling {@link MessageDigest#getInstance(String)} every
+ * time.
+ */
+ private static final boolean SHA1_IS_CLONEABLE;
+ private static final int SHA1_LENGTH;
+
+ static {
+ MessageDigest sha1 = null;
+ boolean sha1IsCloneable = false;
try {
- MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
+ sha1 = MessageDigest.getInstance("SHA-1");
sha1.clone();
- return sha1;
- } catch (CloneNotSupportedException | NoSuchAlgorithmException e) {
+ sha1IsCloneable = true;
+ } catch (NoSuchAlgorithmException e) {
// Should never happen given that SHA-1 is mandated in a
- // compliant Java platform implementation.
- throw new JVMCIError("Expect a cloneable implementation of a SHA-1 message digest to be available", e);
+ // compliant Java platform implementation. However, be
+ // conservative and fall back to not using a digest.
+ } catch (CloneNotSupportedException e) {
}
+ SHA1 = sha1;
+ SHA1_IS_CLONEABLE = sha1IsCloneable;
+ SHA1_LENGTH = SHA1 == null ? 20 : SHA1.getDigestLength();
}
/**
@@ -175,12 +186,12 @@
*/
byte[] getByteArray() {
if (result == null) {
- if (count > SHA1_LENGTH) {
+ if (SHA1 != null && count > SHA1_LENGTH) {
try {
- MessageDigest md = (MessageDigest) SHA1.clone();
+ MessageDigest md = SHA1_IS_CLONEABLE ? (MessageDigest) SHA1.clone() : MessageDigest.getInstance("SHA-1");
md.update(buf, 0, count);
result = md.digest();
- } catch (CloneNotSupportedException e) {
+ } catch (CloneNotSupportedException | NoSuchAlgorithmException e) {
throw new InternalError(e);
}
} else {
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Mon Oct 28 18:43:04 2019 +0100
@@ -107,6 +107,7 @@
final int instanceKlassStateLinked = getConstant("InstanceKlass::linked", Integer.class);
final int instanceKlassStateFullyInitialized = getConstant("InstanceKlass::fully_initialized", Integer.class);
+ final int instanceKlassStateBeingInitialized = getConstant("InstanceKlass::being_initialized", Integer.class);
final int instanceKlassMiscIsUnsafeAnonymous = getConstant("InstanceKlass::_misc_is_unsafe_anonymous", Integer.class);
final int annotationsFieldAnnotationsOffset = getFieldOffset("Annotations::_fields_annotations", Integer.class, "Array<AnnotationArray*>*");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/SharedHotSpotSpeculationLog.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014, 2019, 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.
+ *
+ * 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.
+ */
+package jdk.vm.ci.hotspot;
+
+/**
+ * A wrapper that holds a strong reference to a "master" speculation log that
+ * {@linkplain HotSpotSpeculationLog#managesFailedSpeculations() manages} the failed speculations
+ * list.
+ */
+public class SharedHotSpotSpeculationLog extends HotSpotSpeculationLog {
+ private final HotSpotSpeculationLog masterLog;
+
+ public SharedHotSpotSpeculationLog(HotSpotSpeculationLog masterLog) {
+ super(masterLog.getFailedSpeculationsAddress());
+ this.masterLog = masterLog;
+ }
+
+ @Override
+ public String toString() {
+ return masterLog.toString();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/EncodedSpeculationReason.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+
+package jdk.vm.ci.meta;
+
+import java.util.Arrays;
+import java.util.function.Supplier;
+
+import jdk.vm.ci.meta.SpeculationLog.SpeculationReason;
+
+/**
+ * An implementation of {@link SpeculationReason} based on encoded values.
+ */
+public class EncodedSpeculationReason implements SpeculationReason {
+ final int groupId;
+ final String groupName;
+ final Object[] context;
+ private SpeculationLog.SpeculationReasonEncoding encoding;
+
+ public EncodedSpeculationReason(int groupId, String groupName, Object[] context) {
+ this.groupId = groupId;
+ this.groupName = groupName;
+ this.context = context;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof EncodedSpeculationReason) {
+ if (obj instanceof EncodedSpeculationReason) {
+ EncodedSpeculationReason that = (EncodedSpeculationReason) obj;
+ return this.groupId == that.groupId && Arrays.equals(this.context, that.context);
+ }
+ return false;
+ }
+ return false;
+ }
+
+ @Override
+ public SpeculationLog.SpeculationReasonEncoding encode(Supplier<SpeculationLog.SpeculationReasonEncoding> encodingSupplier) {
+ if (encoding == null) {
+ encoding = encodingSupplier.get();
+ encoding.addInt(groupId);
+ for (Object o : context) {
+ if (o == null) {
+ encoding.addInt(0);
+ } else {
+ addNonNullObject(encoding, o);
+ }
+ }
+ }
+ return encoding;
+ }
+
+ static void addNonNullObject(SpeculationLog.SpeculationReasonEncoding encoding, Object o) {
+ Class<? extends Object> c = o.getClass();
+ if (c == String.class) {
+ encoding.addString((String) o);
+ } else if (c == Byte.class) {
+ encoding.addByte((Byte) o);
+ } else if (c == Short.class) {
+ encoding.addShort((Short) o);
+ } else if (c == Character.class) {
+ encoding.addShort((Character) o);
+ } else if (c == Integer.class) {
+ encoding.addInt((Integer) o);
+ } else if (c == Long.class) {
+ encoding.addLong((Long) o);
+ } else if (c == Float.class) {
+ encoding.addInt(Float.floatToRawIntBits((Float) o));
+ } else if (c == Double.class) {
+ encoding.addLong(Double.doubleToRawLongBits((Double) o));
+ } else if (o instanceof Enum) {
+ encoding.addInt(((Enum<?>) o).ordinal());
+ } else if (o instanceof ResolvedJavaMethod) {
+ encoding.addMethod((ResolvedJavaMethod) o);
+ } else if (o instanceof ResolvedJavaType) {
+ encoding.addType((ResolvedJavaType) o);
+ } else if (o instanceof ResolvedJavaField) {
+ encoding.addField((ResolvedJavaField) o);
+ } else {
+ throw new IllegalArgumentException("Unsupported type for encoding: " + c.getName());
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return groupId + Arrays.hashCode(this.context);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s@%d%s", groupName, groupId, Arrays.toString(context));
+ }
+}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WorkArounds.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WorkArounds.java Mon Oct 28 18:43:04 2019 +0100
@@ -332,36 +332,26 @@
}
//------------------Start of Serializable Implementation---------------------//
- private final static Map<TypeElement, NewSerializedForm> serializedForms = new HashMap<>();
+ private final Map<TypeElement, NewSerializedForm> serializedForms = new HashMap<>();
- public SortedSet<VariableElement> getSerializableFields(Utils utils, TypeElement klass) {
- NewSerializedForm sf = serializedForms.get(klass);
- if (sf == null) {
- sf = new NewSerializedForm(utils, configuration.docEnv.getElementUtils(), klass);
- serializedForms.put(klass, sf);
- }
- return sf.fields;
+ private NewSerializedForm getSerializedForm(TypeElement typeElem) {
+ return serializedForms.computeIfAbsent(typeElem,
+ te -> new NewSerializedForm(utils, configuration.docEnv.getElementUtils(), te));
}
- public SortedSet<ExecutableElement> getSerializationMethods(Utils utils, TypeElement klass) {
- NewSerializedForm sf = serializedForms.get(klass);
- if (sf == null) {
- sf = new NewSerializedForm(utils, configuration.docEnv.getElementUtils(), klass);
- serializedForms.put(klass, sf);
- }
- return sf.methods;
+ public SortedSet<VariableElement> getSerializableFields(TypeElement typeElem) {
+ return getSerializedForm(typeElem).fields;
}
- public boolean definesSerializableFields(Utils utils, TypeElement klass) {
- if (!utils.isSerializable(klass) || utils.isExternalizable(klass)) {
+ public SortedSet<ExecutableElement> getSerializationMethods(TypeElement typeElem) {
+ return getSerializedForm(typeElem).methods;
+ }
+
+ public boolean definesSerializableFields(TypeElement typeElem) {
+ if (!utils.isSerializable(typeElem) || utils.isExternalizable(typeElem)) {
return false;
} else {
- NewSerializedForm sf = serializedForms.get(klass);
- if (sf == null) {
- sf = new NewSerializedForm(utils, configuration.docEnv.getElementUtils(), klass);
- serializedForms.put(klass, sf);
- }
- return sf.definesSerializableFields;
+ return getSerializedForm(typeElem).definesSerializableFields;
}
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -417,15 +417,15 @@
}
public SortedSet<VariableElement> serializableFields(TypeElement aclass) {
- return configuration.workArounds.getSerializableFields(this, aclass);
+ return configuration.workArounds.getSerializableFields(aclass);
}
public SortedSet<ExecutableElement> serializationMethods(TypeElement aclass) {
- return configuration.workArounds.getSerializationMethods(this, aclass);
+ return configuration.workArounds.getSerializationMethods(aclass);
}
public boolean definesSerializableFields(TypeElement aclass) {
- return configuration.workArounds.definesSerializableFields(this, aclass);
+ return configuration.workArounds.definesSerializableFields( aclass);
}
public String modifiersToString(Element e, boolean trailingSpace) {
--- a/src/jdk.jdi/share/classes/com/sun/jdi/InvocationException.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.jdi/share/classes/com/sun/jdi/InvocationException.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, 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
@@ -36,6 +36,7 @@
private static final long serialVersionUID = 6066780907971918568L;
+ @SuppressWarnings("serial") // Not statically typed as Serializable
ObjectReference exception;
public InvocationException(ObjectReference exception) {
--- a/src/jdk.jdi/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.jdi/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, 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
@@ -40,6 +40,7 @@
private static final long serialVersionUID = -3042212603611350941L;
+ @SuppressWarnings("serial") // Conditionally serializable
List<String> names;
/**
--- a/src/jdk.jdi/share/classes/com/sun/jdi/connect/VMStartException.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.jdi/share/classes/com/sun/jdi/connect/VMStartException.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, 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
@@ -38,6 +38,7 @@
private static final long serialVersionUID = 6408644824640801020L;
+ @SuppressWarnings("serial") // Not statically typed as Serializable
Process process;
public VMStartException(Process process) {
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java Mon Oct 28 18:43:04 2019 +0100
@@ -57,6 +57,9 @@
* This class is also used by {@link RecordedObject#toString()}
*/
public final class PrettyWriter extends EventPrintWriter {
+ private static final Duration MILLSECOND = Duration.ofMillis(1);
+ private static final Duration SECOND = Duration.ofSeconds(1);
+ private static final Duration MINUTE = Duration.ofMinutes(1);
private static final String TYPE_OLD_OBJECT = Type.TYPES_PREFIX + "OldObject";
private final static DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss.SSS");
private final static Long ZERO = 0L;
@@ -550,19 +553,14 @@
println("N/A");
return true;
}
- double s = d.toNanosPart() / 1000_000_000.0 + d.toSecondsPart();
- if (s < 1.0) {
- if (s < 0.001) {
- println(String.format("%.3f", s * 1_000_000) + " us");
- } else {
- println(String.format("%.3f", s * 1_000) + " ms");
- }
+ if(d.compareTo(MILLSECOND) < 0){
+ println(String.format("%.3f us", (double)d.toNanos() / 1_000));
+ } else if(d.compareTo(SECOND) < 0){
+ println(String.format("%.3f ms", (double)d.toNanos() / 1_000_000));
+ } else if(d.compareTo(MINUTE) < 0){
+ println(String.format("%.3f s", (double)d.toMillis() / 1_000));
} else {
- if (s < 1000.0) {
- println(String.format("%.3f", s) + " s");
- } else {
- println(String.format("%.0f", s) + " s");
- }
+ println(String.format("%d s", d.toSeconds()));
}
return true;
}
--- a/src/jdk.jfr/share/conf/jfr/default.jfc Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.jfr/share/conf/jfr/default.jfc Mon Oct 28 18:43:04 2019 +0100
@@ -719,13 +719,13 @@
</event>
<event name="jdk.ZStatisticsCounter">
- <setting name="enabled">true</setting>
- <setting name="threshold">10 ms</setting>
+ <setting name="enabled">false</setting>
+ <setting name="threshold">0 ms</setting>
</event>
<event name="jdk.ZStatisticsSampler">
- <setting name="enabled">true</setting>
- <setting name="threshold">10 ms</setting>
+ <setting name="enabled">false</setting>
+ <setting name="threshold">0 ms</setting>
</event>
--- a/src/jdk.jfr/share/conf/jfr/profile.jfc Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.jfr/share/conf/jfr/profile.jfc Mon Oct 28 18:43:04 2019 +0100
@@ -719,13 +719,13 @@
</event>
<event name="jdk.ZStatisticsCounter">
- <setting name="threshold">10 ms</setting>
- <setting name="enabled">true</setting>
+ <setting name="threshold">0 ms</setting>
+ <setting name="enabled">false</setting>
</event>
<event name="jdk.ZStatisticsSampler">
- <setting name="enabled">true</setting>
- <setting name="threshold">10 ms</setting>
+ <setting name="enabled">false</setting>
+ <setting name="threshold">0 ms</setting>
</event>
--- a/src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java Sat Oct 26 23:59:51 2019 +0200
+++ b/src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java Mon Oct 28 18:43:04 2019 +0100
@@ -122,9 +122,6 @@
* {@link #getThreadAllocatedBytes getThreadAllocatedBytes}(Thread.currentThread().getId());
* </pre></blockquote>
*
- * @implSpec The default implementation throws
- * {@code UnsupportedOperationException}.
- *
* @return an approximation of the total memory allocated, in bytes, in
* heap memory for the current thread
* if thread memory allocation measurement is enabled;
@@ -141,7 +138,7 @@
* @since 14
*/
public default long getCurrentThreadAllocatedBytes() {
- throw new UnsupportedOperationException();
+ return getThreadAllocatedBytes(Thread.currentThread().getId());
}
/**
--- a/test/hotspot/gtest/oops/test_markOop.cpp Sat Oct 26 23:59:51 2019 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2019, 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.
- *
- * 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.
- */
-
-#include "precompiled.hpp"
-#include "classfile/systemDictionary.hpp"
-#include "memory/resourceArea.hpp"
-#include "memory/universe.hpp"
-#include "oops/oop.inline.hpp"
-#include "runtime/atomic.hpp"
-#include "runtime/interfaceSupport.inline.hpp"
-#include "runtime/orderAccess.hpp"
-#include "runtime/os.hpp"
-#include "runtime/synchronizer.hpp"
-#include "runtime/semaphore.inline.hpp"
-#include "threadHelper.inline.hpp"
-#include "unittest.hpp"
-#include "utilities/globalDefinitions.hpp"
-#include "utilities/ostream.hpp"
-
-// The test doesn't work for PRODUCT because it needs WizardMode
-#ifndef PRODUCT
-static bool test_pattern(stringStream* st, const char* pattern) {
- return (strstr(st->as_string(), pattern) != NULL);
-}
-
-static void assert_test_pattern(Handle object, const char* pattern) {
- stringStream st;
- object->print_on(&st);
- ASSERT_TRUE(test_pattern(&st, pattern)) << pattern << " not in " << st.as_string();
-}
-
-static void assert_not_test_pattern(Handle object, const char* pattern) {
- stringStream st;
- object->print_on(&st);
- ASSERT_FALSE(test_pattern(&st, pattern)) << pattern << " found in " << st.as_string();
-}
-
-class LockerThread : public JavaTestThread {
- oop _obj;
- public:
- LockerThread(Semaphore* post, oop obj) : JavaTestThread(post), _obj(obj) {}
- virtual ~LockerThread() {}
-
- void main_run() {
- Thread* THREAD = Thread::current();
- HandleMark hm(THREAD);
- Handle h_obj(THREAD, _obj);
- ResourceMark rm(THREAD);
-
- // Wait gets the lock inflated.
- // The object will stay locked for the context of 'ol' so the lock will
- // still be inflated after the notify_all() call. Deflation can't happen
- // while an ObjectMonitor is "busy" and being locked is the most "busy"
- // state we have...
- ObjectLocker ol(h_obj, THREAD);
- ol.notify_all(THREAD);
- assert_test_pattern(h_obj, "monitor");
- }
-};
-
-
-TEST_VM(markWord, printing) {
- JavaThread* THREAD = JavaThread::current();
- ThreadInVMfromNative invm(THREAD);
- ResourceMark rm(THREAD);
-
- oop obj = SystemDictionary::Byte_klass()->allocate_instance(THREAD);
-
- FlagSetting fs(WizardMode, true);
- FlagSetting bf(UseBiasedLocking, true);
-
- HandleMark hm(THREAD);
- Handle h_obj(THREAD, obj);
-
- // Biased locking is initially enabled for this java.lang.Byte object.
- assert_test_pattern(h_obj, "is_biased");
-
- // Lock using biased locking.
- BasicObjectLock lock;
- lock.set_obj(obj);
- markWord prototype_header = obj->klass()->prototype_header();
- markWord mark = obj->mark();
- markWord biased_mark = markWord::encode((JavaThread*) THREAD, mark.age(), prototype_header.bias_epoch());
- obj->set_mark(biased_mark);
- // Look for the biased_locker in markWord, not prototype_header.
-#ifdef _LP64
- assert_not_test_pattern(h_obj, "mark(is_biased biased_locker=0x0000000000000000");
-#else
- assert_not_test_pattern(h_obj, "mark(is_biased biased_locker=0x00000000");
-#endif
-
- // Same thread tries to lock it again.
- {
- ObjectLocker ol(h_obj, THREAD);
- assert_test_pattern(h_obj, "locked");
- }
-
- // This is no longer biased, because ObjectLocker revokes the bias.
- assert_test_pattern(h_obj, "is_neutral no_hash");
-
- // Wait gets the lock inflated.
- {
- ObjectLocker ol(h_obj, THREAD);
-
- Semaphore done(0);
- LockerThread* st;
- st = new LockerThread(&done, h_obj());
- st->doit();
-
- ol.wait(THREAD);
- assert_test_pattern(h_obj, "monitor");
- done.wait_with_safepoint_check(THREAD); // wait till the thread is done.
- }
-
- // Make the object older. Not all GCs use this field.
- Universe::heap()->collect(GCCause::_java_lang_system_gc);
- if (UseParallelGC) {
- assert_test_pattern(h_obj, "is_neutral no_hash age 1");
- }
-
- // Hash the object then print it.
- intx hash = h_obj->identity_hash();
- assert_test_pattern(h_obj, "is_neutral hash=0x");
-}
-#endif // PRODUCT
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/gtest/oops/test_markWord.cpp Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+#include "precompiled.hpp"
+#include "classfile/systemDictionary.hpp"
+#include "memory/resourceArea.hpp"
+#include "memory/universe.hpp"
+#include "oops/oop.inline.hpp"
+#include "runtime/atomic.hpp"
+#include "runtime/biasedLocking.hpp"
+#include "runtime/interfaceSupport.inline.hpp"
+#include "runtime/orderAccess.hpp"
+#include "runtime/os.hpp"
+#include "runtime/synchronizer.hpp"
+#include "runtime/semaphore.inline.hpp"
+#include "threadHelper.inline.hpp"
+#include "unittest.hpp"
+#include "utilities/globalDefinitions.hpp"
+#include "utilities/ostream.hpp"
+
+// The test doesn't work for PRODUCT because it needs WizardMode
+#ifndef PRODUCT
+static bool test_pattern(stringStream* st, const char* pattern) {
+ return (strstr(st->as_string(), pattern) != NULL);
+}
+
+static void assert_test_pattern(Handle object, const char* pattern) {
+ stringStream st;
+ object->print_on(&st);
+ ASSERT_TRUE(test_pattern(&st, pattern)) << pattern << " not in " << st.as_string();
+}
+
+static void assert_not_test_pattern(Handle object, const char* pattern) {
+ stringStream st;
+ object->print_on(&st);
+ ASSERT_FALSE(test_pattern(&st, pattern)) << pattern << " found in " << st.as_string();
+}
+
+class LockerThread : public JavaTestThread {
+ oop _obj;
+ public:
+ LockerThread(Semaphore* post, oop obj) : JavaTestThread(post), _obj(obj) {}
+ virtual ~LockerThread() {}
+
+ void main_run() {
+ Thread* THREAD = Thread::current();
+ HandleMark hm(THREAD);
+ Handle h_obj(THREAD, _obj);
+ ResourceMark rm(THREAD);
+
+ // Wait gets the lock inflated.
+ // The object will stay locked for the context of 'ol' so the lock will
+ // still be inflated after the notify_all() call. Deflation can't happen
+ // while an ObjectMonitor is "busy" and being locked is the most "busy"
+ // state we have...
+ ObjectLocker ol(h_obj, THREAD);
+ ol.notify_all(THREAD);
+ assert_test_pattern(h_obj, "monitor");
+ }
+};
+
+
+TEST_VM(markWord, printing) {
+ JavaThread* THREAD = JavaThread::current();
+ ThreadInVMfromNative invm(THREAD);
+ ResourceMark rm(THREAD);
+
+ if (!UseBiasedLocking || !BiasedLocking::enabled()) {
+ // Can't test this with biased locking disabled.
+ return;
+ }
+
+ oop obj = SystemDictionary::Byte_klass()->allocate_instance(THREAD);
+
+ FlagSetting fs(WizardMode, true);
+
+ HandleMark hm(THREAD);
+ Handle h_obj(THREAD, obj);
+
+ // Biased locking is initially enabled for this java.lang.Byte object.
+ assert_test_pattern(h_obj, "is_biased");
+
+ // Lock using biased locking.
+ BasicObjectLock lock;
+ lock.set_obj(obj);
+ markWord prototype_header = obj->klass()->prototype_header();
+ markWord mark = obj->mark();
+ markWord biased_mark = markWord::encode((JavaThread*) THREAD, mark.age(), prototype_header.bias_epoch());
+ obj->set_mark(biased_mark);
+ // Look for the biased_locker in markWord, not prototype_header.
+#ifdef _LP64
+ assert_not_test_pattern(h_obj, "mark(is_biased biased_locker=0x0000000000000000");
+#else
+ assert_not_test_pattern(h_obj, "mark(is_biased biased_locker=0x00000000");
+#endif
+
+ // Same thread tries to lock it again.
+ {
+ ObjectLocker ol(h_obj, THREAD);
+ assert_test_pattern(h_obj, "locked");
+ }
+
+ // This is no longer biased, because ObjectLocker revokes the bias.
+ assert_test_pattern(h_obj, "is_neutral no_hash");
+
+ // Wait gets the lock inflated.
+ {
+ ObjectLocker ol(h_obj, THREAD);
+
+ Semaphore done(0);
+ LockerThread* st;
+ st = new LockerThread(&done, h_obj());
+ st->doit();
+
+ ol.wait(THREAD);
+ assert_test_pattern(h_obj, "monitor");
+ done.wait_with_safepoint_check(THREAD); // wait till the thread is done.
+ }
+
+ // Make the object older. Not all GCs use this field.
+ Universe::heap()->collect(GCCause::_java_lang_system_gc);
+ if (UseParallelGC) {
+ assert_test_pattern(h_obj, "is_neutral no_hash age 1");
+ }
+
+ // Hash the object then print it.
+ intx hash = h_obj->identity_hash();
+ assert_test_pattern(h_obj, "is_neutral hash=0x");
+}
+#endif // PRODUCT
--- a/test/hotspot/jtreg/ProblemList.txt Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/ProblemList.txt Mon Oct 28 18:43:04 2019 +0100
@@ -108,6 +108,7 @@
serviceability/sa/ClhsdbJdis.java 8193639 solaris-all
serviceability/sa/ClhsdbJhisto.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64
serviceability/sa/ClhsdbJstack.java 8193639 solaris-all
+serviceability/sa/ClhsdbJstackXcompStress.java 8193639,8231635 solaris-all,windows-x64
serviceability/sa/ClhsdbLongConstant.java 8193639 solaris-all
serviceability/sa/ClhsdbPmap.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64
serviceability/sa/ClhsdbPrintAll.java 8193639 solaris-all
@@ -193,7 +194,6 @@
vmTestbase/vm/mlvm/indy/func/jvmti/redefineClassInBootstrap/TestDescription.java 8013267 generic-all
vmTestbase/vm/mlvm/meth/func/java/throwException/Test.java 8058176 generic-all
vmTestbase/vm/mlvm/meth/func/jdi/breakpointOtherStratum/Test.java 8208257,8058176 generic-all
-vmTestbase/vm/mlvm/meth/stress/compiler/deoptimize/Test.java 8058176 generic-all
vmTestbase/vm/mlvm/meth/stress/compiler/i2c_c2i/Test.java 8058176 generic-all
vmTestbase/vm/mlvm/meth/stress/compiler/sequences/Test.java 8058176 generic-all
vmTestbase/vm/mlvm/meth/stress/gc/callSequencesDuringGC/Test.java 8058176 generic-all
--- a/test/hotspot/jtreg/compiler/aot/fingerprint/SelfChangedCDS.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/compiler/aot/fingerprint/SelfChangedCDS.java Mon Oct 28 18:43:04 2019 +0100
@@ -27,7 +27,7 @@
* @library /test/lib /
* @modules java.base/jdk.internal.misc
* java.management
- * @requires vm.aot
+ * @requires vm.aot & vm.cds
* @build compiler.aot.fingerprint.SelfChanged
* compiler.aot.AotCompiler
*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/c2/CompareKlassPointersTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8220416
+ * @summary This test uses a class pointer comparison optimization which was not applied anymore since JDK-6964458 resulting in a better IR.
+ *
+ * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
+ * -XX:CompileOnly=compiler.c2.CompareKlassPointersTest::test compiler.c2.CompareKlassPointersTest
+ */
+
+package compiler.c2;
+
+
+
+public class CompareKlassPointersTest {
+
+ static A a;
+
+ public static void main(String[] args) {
+ a = new C();
+ for (int i = 0; i < 10_000; i++) {
+ test();
+ }
+ }
+
+ public static int test() {
+ Object a = getA();
+
+ /*
+ * This check is now optimized away which was not the case before anymore since JDK-6964458:
+ * The klass pointer comparison optimization sees that the check is always false since a and B are always unrelated klasses
+ */
+ if (a instanceof B) {
+ return 1;
+ }
+ return 0;
+ }
+
+ private static Object getA() {
+ return a;
+ }
+}
+
+class A { }
+
+class B { }
+
+class C extends A { }
--- a/test/hotspot/jtreg/compiler/dependencies/MonomorphicObjectCall/java.base/java/lang/Object.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/compiler/dependencies/MonomorphicObjectCall/java.base/java/lang/Object.java Mon Oct 28 18:43:04 2019 +0100
@@ -34,11 +34,6 @@
@HotSpotIntrinsicCandidate
public Object() {}
- private static native void registerNatives();
- static {
- registerNatives();
- }
-
@HotSpotIntrinsicCandidate
public final native Class<?> getClass();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/escapeAnalysis/TestEliminateAllocation.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8231412
+ * @summary The enhancement eliminates all allocations in the loop body of test() due to an improved field zeroing elimination dominance check.
+ * @run main/othervm -XX:-TieredCompilation -XX:CompileCommand=compileonly,compiler.escapeAnalysis.TestEliminateAllocation::test
+ * compiler.escapeAnalysis.TestEliminateAllocation
+ */
+
+package compiler.escapeAnalysis;
+
+public class TestEliminateAllocation {
+
+ public static int a = 20;
+ public static int b = 30;
+ public static int c = 40;
+
+ public void test() {
+ int i = 0;
+
+ /*
+ * The resulting IR for the loop body contains 2 allocations, one Wrapper and an int array
+ * The array field store in the Wrapper object 'wrapper.arr = arr' cannot be capturued due to an early bail out.
+ * Therefore, the initial value of wrapper.arr is null.
+ * As a result, the escape analysis marks the array allocation as not scalar replaceable:
+ * 'wrapper.arr' which is null is merged with the int array object in the assignment 'wrapper.arr = arr'.
+ * Both null and the int array are treated as different objects. As a result the array allocation cannot be eliminated.
+ *
+ * The new enhancement does not bail out early anymore and therefore escape analysis does not mark it as
+ * not scalar replaceable. This results in elimination of all allocations in this method.
+ */
+ do {
+ int[] arr = new int[] { a / b / c };
+ Wrapper wrapper = new Wrapper();
+ wrapper.setArr(arr);
+ i++;
+ }
+ while (i < 10);
+ }
+
+ public static void main(String[] strArr) {
+ TestEliminateAllocation _instance = new TestEliminateAllocation();
+ for (int i = 0; i < 10_000; i++ ) {
+ _instance.test();
+ }
+ }
+}
+
+class Wrapper {
+ int[] arr;
+ void setArr(int... many) { arr = many; }
+}
--- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotSpeculationLog.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotSpeculationLog.java Mon Oct 28 18:43:04 2019 +0100
@@ -78,7 +78,8 @@
public synchronized void testFailedSpeculations() {
HotSpotSpeculationLog log = new HotSpotSpeculationLog();
DummyReason reason1 = new DummyReason("dummy1");
- DummyReason reason2 = new DummyReason("dummy2");
+ String longName = new String(new char[2000]).replace('\0', 'X');
+ DummyReason reason2 = new DummyReason(longName);
Assert.assertTrue(log.maySpeculate(reason1));
Assert.assertTrue(log.maySpeculate(reason2));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/loopopts/LoopRotateBadNodeBudget.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8231565
+ * @summary Node estimate for loop rotate is not correct/sufficient:
+ * assert(delta <= 2 * required) failed: Bad node estimate ...
+ *
+ * @requires !vm.graal.enabled
+ *
+ * @run main/othervm -XX:PartialPeelNewPhiDelta=5 LoopRotateBadNodeBudget
+ * @run main/othervm -Xbatch -XX:PartialPeelNewPhiDelta=5 LoopRotateBadNodeBudget
+ *
+ * @run main/othervm LoopRotateBadNodeBudget
+ * @run main/othervm -Xbatch LoopRotateBadNodeBudget
+ *
+ * NOTE: Test-case seldom manifesting the problem on fast machines.
+ */
+
+public class LoopRotateBadNodeBudget {
+
+ int h;
+ float j(int a, int b) {
+ double d = 0.19881;
+ int c, e[] = new int[9];
+ c = 1;
+ while (++c < 12)
+ switch ((c % 7 * 5) + 122) {
+ case 156:
+ case 46128:
+ case 135:
+ case 148:
+ case 127:
+ break;
+ default:
+ }
+ while ((d += 2) < 62)
+ ;
+ long k = l(e);
+ return k;
+ }
+ long l(int[] a) {
+ long m = 0;
+ for (int i = 0; i < a.length; i++)
+ m = a[i];
+ return m;
+ }
+ void f(String[] g) {
+ int i = 2;
+ for (; i < 20000; ++i)
+ j(3, h);
+ }
+ public static void main(String[] o) {
+ try {
+ LoopRotateBadNodeBudget n = new LoopRotateBadNodeBudget();
+ n.f(o);
+ } catch (Exception ex) {
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/loopopts/superword/SuperWordIntermediateUse.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8230062
+ * @summary The IR of this test contains a reduction chain which corresponds to a pack in which the 2nd last element has a usage outside of the optimized loop.
+ *
+ * @run main/othervm -Xbatch -XX:CompileCommand=compileonly,compiler.loopopts.superword.SuperWordIntermediateUse::test
+ * compiler.loopopts.superword.SuperWordIntermediateUse
+ */
+
+package compiler.loopopts.superword;
+
+public class SuperWordIntermediateUse {
+
+ private int iFld;
+ private int[] iArr = new int[1024];
+
+ public void test() {
+ int local = 4;
+
+ /**
+ * Before unrolling this loop:
+ * iFld: AddI 1 = -85 + Phi 1
+ * local: MulI 2 = Phi 1 * LoadI 3
+ *
+ * This loop is now unrolled. 'local' is a reduction. The loop is first copied:
+ * iFldCopy: AddI C1 = -85 + Phi C1
+ * localCopy: MulI C2 = Phi C1 * LoadI C3
+ *
+ * iFld: AddI 1 = -85 + Phi 1
+ * local: MulI 2 = Phi 1 * LoadI 3
+ *
+ * Then, the unnecessary nodes like phis are removed from the original loop by igvn:
+ * (iFldCopy: AddI C1 = -85 + Phi C1) field store optimized away
+ * localCopy: MulI C2 = Phi C1 * LoadI C3
+ *
+ * iFld: AddI 1 = -85 + MulI C2
+ * local: MulI 2 = MulI C2 * LoadI 3 -> Input into Phi C1
+ *
+ * As a result AddI 1 has an input from MulI C2 which isn't the last operation in the reduction chain
+ * Phi C1 -> MulI C2 -> MulI 2 -> Phi C1 and therefore not the last element in a pack.
+ * Additionally, AddI 1 does not belong to the loop being optimized: The store node for iFld is put outside of the loop being optimized.
+ * This triggers the assertion bug when unrolled at least 4 times which creates packs of at least size 4.
+ */
+ for (int i = 0; i < 1024; i++) {
+ iFld = -85;
+ iFld = iFld + local;
+ local = local * iArr[i];
+ iArr[i] = 3; // Just used to trigger SuperWord optimization
+ }
+ }
+
+ public static void main(String[] strArr) {
+ SuperWordIntermediateUse instance = new SuperWordIntermediateUse();
+ for (int i = 0; i < 1000; i++) {
+ instance.test();
+ }
+ }
+}
--- a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java Mon Oct 28 18:43:04 2019 +0100
@@ -128,7 +128,6 @@
new LogMessageWithLevel("CLDG Roots", Level.TRACE),
new LogMessageWithLevel("JVMTI Roots", Level.TRACE),
new LogMessageWithLevel("CM RefProcessor Roots", Level.TRACE),
- new LogMessageWithLevel("Wait For Strong Roots", Level.TRACE),
// Redirty Cards
new LogMessageWithLevel("Redirty Cards", Level.DEBUG),
new LogMessageWithLevel("Parallel Redirty", Level.TRACE),
--- a/test/hotspot/jtreg/gc/shenandoah/TestVerifyJCStress.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/gc/shenandoah/TestVerifyJCStress.java Mon Oct 28 18:43:04 2019 +0100
@@ -29,14 +29,14 @@
* @modules java.base/jdk.internal.misc
* java.management
*
- * @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
+ * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
- * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify -XX:+VerifyObjectEquals
+ * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify
* TestVerifyJCStress
*
- * @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
+ * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
- * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify -XX:+VerifyObjectEquals
+ * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify
* TestVerifyJCStress
*/
@@ -48,14 +48,14 @@
* @modules java.base/jdk.internal.misc
* java.management
*
- * @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
+ * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
- * -XX:+ShenandoahVerify -XX:+VerifyObjectEquals -XX:+ShenandoahVerifyOptoBarriers
+ * -XX:+ShenandoahVerify -XX:+IgnoreUnrecognizedVMOptions -XX:+ShenandoahVerifyOptoBarriers
* TestVerifyJCStress
*
- * @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
+ * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
- * -XX:+ShenandoahVerify -XX:+VerifyObjectEquals -XX:+ShenandoahVerifyOptoBarriers
+ * -XX:+ShenandoahVerify -XX:+IgnoreUnrecognizedVMOptions -XX:+ShenandoahVerifyOptoBarriers
* TestVerifyJCStress
*/
@@ -67,9 +67,9 @@
* @modules java.base/jdk.internal.misc
* java.management
*
- * @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
+ * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal
- * -XX:+ShenandoahVerify -XX:+VerifyObjectEquals -XX:+ShenandoahVerifyOptoBarriers
+ * -XX:+ShenandoahVerify -XX:+IgnoreUnrecognizedVMOptions -XX:+ShenandoahVerifyOptoBarriers
* TestVerifyJCStress
*/
--- a/test/hotspot/jtreg/runtime/8024804/RegisterNatives.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/runtime/8024804/RegisterNatives.java Mon Oct 28 18:43:04 2019 +0100
@@ -23,15 +23,27 @@
/*
* @test
- * @bug 8024804
- * @bug 8028741
+ * @bug 8024804 8028741 8232613
* @summary interface method resolution should skip finding j.l.Object's registerNatives() and succeed in selecting class B's registerNatives()
* @run main RegisterNatives
*/
public class RegisterNatives {
- interface I { void registerNatives(); }
+ interface I {
+ void registerNatives();
+ }
+
interface J extends I {}
- static class B implements J { public void registerNatives() { System.out.println("B"); } }
+
+ interface K {
+ default public void registerNatives() { System.out.println("K"); }
+ }
+
+ static class B implements J {
+ public void registerNatives() { System.out.println("B"); }
+ }
+
+ static class C implements K {}
+
public static void main(String... args) {
System.out.println("Regression test for JDK-8024804, crash when InterfaceMethodref resolves to Object.registerNatives\n");
J val = new B();
@@ -42,6 +54,14 @@
e.printStackTrace();
throw e;
}
+ C cval = new C();
+ try {
+ cval.registerNatives();
+ } catch (IllegalAccessError e) {
+ System.out.println("TEST FAILS - a default method named registerNatives should no longer be masked by removed Object.registerNatives\n");
+ e.printStackTrace();
+ throw e;
+ }
System.out.println("TEST PASSES - no IAE resulted\n");
}
}
--- a/test/hotspot/jtreg/runtime/cds/CheckDefaultArchiveFile.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/runtime/cds/CheckDefaultArchiveFile.java Mon Oct 28 18:43:04 2019 +0100
@@ -25,6 +25,7 @@
* @test Default CDS archive file
* @summary JDK platforms/binaries do not support default CDS archive should
* not contain classes.jsa in the default location.
+ * @requires vm.cds
* @library /test/lib
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/NullPointerException/NPEInHiddenTopFrameTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019 SAP SE. 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Test NullPointerException messages thrown in frames that
+ * are hidden in the backtrace/stackTrace.
+ * @bug 8218628
+ * @library /test/lib
+ * @compile -g NPEInHiddenTopFrameTest.java
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:-ShowHiddenFrames -XX:+ShowCodeDetailsInExceptionMessages NPEInHiddenTopFrameTest hidden
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -XX:+ShowCodeDetailsInExceptionMessages NPEInHiddenTopFrameTest visible
+ */
+
+import jdk.test.lib.Asserts;
+
+public class NPEInHiddenTopFrameTest {
+
+ @FunctionalInterface
+ private static interface SomeFunctionalInterface {
+ String someMethod(String a, String b);
+ }
+
+ public static void checkMessage(String expression,
+ String obtainedMsg, String expectedMsg) {
+ System.out.println();
+ System.out.println(" source code: " + expression);
+ System.out.println(" thrown msg: " + obtainedMsg);
+ if (obtainedMsg == null && expectedMsg == null) return;
+ System.out.println("expected msg: " + expectedMsg);
+ Asserts.assertEquals(expectedMsg, obtainedMsg);
+ }
+
+ public static void main(String[] args) throws Exception {
+ boolean framesAreHidden = false;
+ if (args.length > 0) {
+ String arg = args[0];
+ if (arg.equals("hidden")) framesAreHidden = true;
+ }
+
+ try {
+ final SomeFunctionalInterface concatter = String::concat;
+ final String nullString = null;
+ if (concatter != null) {
+ // This throws NPE from the lambda expression which is a hidden frame.
+ concatter.someMethod(nullString, "validString");
+ }
+ } catch (NullPointerException e) {
+ checkMessage("concatter.someMethod(nullString, \"validString\");", e.getMessage(),
+ framesAreHidden ?
+ // This is the message that would be printed if the wrong method/bci are used:
+ // "Cannot invoke 'NPEInHiddenTopFrameTest$SomeFunctionalInterface.someMethod(String, String)'" +
+ // " because 'concatter' is null."
+ // But the NPE message generation now recognizes this situation and skips the
+ // message. So we expect null:
+ null :
+ // This is the correct message, but it describes code generated on-the-fly.
+ // You get it if you disable hiding frames (-XX:+ShowHiddenframes).
+ "Cannot invoke \"String.concat(String)\" because \"<parameter1>\" is null" );
+ e.printStackTrace();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/NullPointerException/NullPointerExceptionTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,1782 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019 SAP SE. 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Test extended NullPointerException message for
+ * classfiles generated with debug information. In this case the name
+ * of the variable containing the array is printed.
+ * @bug 8218628
+ * @modules java.base/java.lang:open
+ * java.base/jdk.internal.org.objectweb.asm
+ * @library /test/lib
+ * @compile -g NullPointerExceptionTest.java
+ * @run main/othervm -XX:MaxJavaStackTraceDepth=1 -XX:+ShowCodeDetailsInExceptionMessages NullPointerExceptionTest hasDebugInfo
+ */
+/**
+ * @test
+ * @summary Test extended NullPointerException message for class
+ * files generated without debugging information. The message lists
+ * detailed information about the entity that is null.
+ * @bug 8218628
+ * @modules java.base/java.lang:open
+ * java.base/jdk.internal.org.objectweb.asm
+ * @library /test/lib
+ * @compile NullPointerExceptionTest.java
+ * @run main/othervm -XX:MaxJavaStackTraceDepth=1 -XX:+ShowCodeDetailsInExceptionMessages NullPointerExceptionTest
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.invoke.MethodHandles.Lookup;
+import java.util.ArrayList;
+
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.Label;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+import jdk.test.lib.Asserts;
+
+import static java.lang.invoke.MethodHandles.lookup;
+import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
+import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
+import static jdk.internal.org.objectweb.asm.Opcodes.ACONST_NULL;
+import static jdk.internal.org.objectweb.asm.Opcodes.ALOAD;
+import static jdk.internal.org.objectweb.asm.Opcodes.ASTORE;
+import static jdk.internal.org.objectweb.asm.Opcodes.GETFIELD;
+import static jdk.internal.org.objectweb.asm.Opcodes.GETSTATIC;
+import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_1;
+import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_2;
+import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESPECIAL;
+import static jdk.internal.org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
+import static jdk.internal.org.objectweb.asm.Opcodes.ARETURN;
+import static jdk.internal.org.objectweb.asm.Opcodes.IRETURN;
+import static jdk.internal.org.objectweb.asm.Opcodes.RETURN;
+
+/**
+ * Tests NullPointerExceptions
+ */
+public class NullPointerExceptionTest {
+
+ // Some fields used in the test.
+ static Object nullStaticField;
+ NullPointerExceptionTest nullInstanceField;
+ static int[][][][] staticArray;
+ static long[][] staticLongArray = new long[1000][];
+ DoubleArrayGen dag;
+ ArrayList<String> names = new ArrayList<>();
+ ArrayList<String> curr;
+ static boolean hasDebugInfo = false;
+
+ static {
+ staticArray = new int[1][][][];
+ staticArray[0] = new int[1][][];
+ staticArray[0][0] = new int[1][];
+ }
+
+ public static void checkMessage(Throwable t, String expression,
+ String obtainedMsg, String expectedMsg) {
+ System.out.println("\nSource code:\n " + expression + "\n\nOutput:");
+ t.printStackTrace(System.out);
+ if (obtainedMsg != expectedMsg && // E.g. both are null.
+ !obtainedMsg.equals(expectedMsg)) {
+ System.out.println("expected msg: " + expectedMsg);
+ Asserts.assertEquals(expectedMsg, obtainedMsg);
+ }
+ System.out.println("\n----");
+ }
+
+ public static void main(String[] args) throws Exception {
+ NullPointerExceptionTest t = new NullPointerExceptionTest();
+ if (args.length > 0) {
+ hasDebugInfo = true;
+ }
+
+ System.out.println("Tests for the first part of the message:");
+ System.out.println("========================================\n");
+
+ // Test the message printed for the failed action.
+ t.testFailedAction();
+
+ System.out.println("Tests for the second part of the message:");
+ System.out.println("=========================================\n");
+ // Test the method printed for the null entity.
+ t.testNullEntity();
+
+ System.out.println("Further tests:");
+ System.out.println("==============\n");
+
+ // Test if parameters are used in the code.
+ // This is relevant if there is no debug information.
+ t.testParameters();
+
+ // Test that no message is printed for exceptions
+ // allocated explicitly.
+ t.testCreation();
+
+ // Test that no message is printed for exceptions
+ // thrown in native methods.
+ t.testNative();
+
+ // Test that two calls to getMessage() return the same
+ // message.
+ // It is a design decision that it returns two different
+ // String objects.
+ t.testSameMessage();
+
+ // Test serialization.
+ // It is a design decision that after serialization the
+ // the message is lost.
+ t.testSerialization();
+
+ // Test that messages are printed for code generated
+ // on-the-fly.
+ t.testGeneratedCode();
+
+ // Some more interesting complex messages.
+ t.testComplexMessages();
+ }
+
+ // Helper method to cause test case.
+ private double callWithTypes(String[][] dummy1, int[][][] dummy2, float dummy3, long dummy4, short dummy5,
+ boolean dummy6, byte dummy7, double dummy8, char dummy9) {
+ return 0.0;
+ }
+
+ @SuppressWarnings("null")
+ public void testFailedAction() {
+ int[] ia1 = null;
+ float[] fa1 = null;
+ Object[] oa1 = null;
+ boolean[] za1 = null;
+ byte[] ba1 = null;
+ char[] ca1 = null;
+ short[] sa1 = null;
+ long[] la1 = null;
+ double[] da1 = null;
+
+ // iaload
+ try {
+ int val = ia1[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "int val = ia1[0];", e.getMessage(),
+ "Cannot load from int array because " +
+ (hasDebugInfo ? "\"ia1\"" : "\"<local1>\"") + " is null");
+ }
+ // faload
+ try {
+ float val = fa1[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "float val = fa1[0];", e.getMessage(),
+ "Cannot load from float array because " +
+ (hasDebugInfo ? "\"fa1\"" : "\"<local2>\"") + " is null");
+ }
+ // aaload
+ try {
+ Object val = oa1[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "Object val = oa1[0];", e.getMessage(),
+ "Cannot load from object array because " +
+ (hasDebugInfo ? "\"oa1\"" : "\"<local3>\"") + " is null");
+ }
+ // baload (boolean)
+ try {
+ boolean val = za1[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "boolean val = za1[0];", e.getMessage(),
+ "Cannot load from byte/boolean array because " +
+ (hasDebugInfo ? "\"za1\"" : "\"<local4>\"") + " is null");
+ }
+ // baload (byte)
+ try {
+ byte val = ba1[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "byte val = ba1[0];", e.getMessage(),
+ "Cannot load from byte/boolean array because " +
+ (hasDebugInfo ? "\"ba1\"" : "\"<local5>\"") + " is null");
+ }
+ // caload
+ try {
+ char val = ca1[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "char val = ca1[0];", e.getMessage(),
+ "Cannot load from char array because " +
+ (hasDebugInfo ? "\"ca1\"" : "\"<local6>\"") + " is null");
+ }
+ // saload
+ try {
+ short val = sa1[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "short val = sa1[0];", e.getMessage(),
+ "Cannot load from short array because " +
+ (hasDebugInfo ? "\"sa1\"" : "\"<local7>\"") + " is null");
+ }
+ // laload
+ try {
+ long val = la1[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "long val = la1[0];", e.getMessage(),
+ "Cannot load from long array because " +
+ (hasDebugInfo ? "\"la1\"" : "\"<local8>\"") + " is null");
+ }
+ // daload
+ try {
+ double val = da1[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "double val = da1[0];", e.getMessage(),
+ "Cannot load from double array because " +
+ (hasDebugInfo ? "\"da1\"" : "\"<local9>\"") + " is null");
+ }
+
+ // iastore
+ try {
+ ia1[0] = 0;
+ System.out.println(ia1[0]);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "ia1[0] = 0;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"ia1\"" : "\"<local1>\"") + " is null");
+ }
+ // fastore
+ try {
+ fa1[0] = 0.7f;
+ System.out.println(fa1[0]);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "fa1[0] = 0.7f;", e.getMessage(),
+ "Cannot store to float array because " +
+ (hasDebugInfo ? "\"fa1\"" : "\"<local2>\"") + " is null");
+ }
+ // aastore
+ try {
+ oa1[0] = new Object();
+ System.out.println(oa1[0]);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "oa1[0] = new Object();", e.getMessage(),
+ "Cannot store to object array because " +
+ (hasDebugInfo ? "\"oa1\"" : "\"<local3>\"") + " is null");
+ }
+ // bastore (boolean)
+ try {
+ za1[0] = false;
+ System.out.println(za1[0]);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "za1[0] = false;", e.getMessage(),
+ "Cannot store to byte/boolean array because " +
+ (hasDebugInfo ? "\"za1\"" : "\"<local4>\"") + " is null");
+ }
+ // bastore (byte)
+ try {
+ ba1[0] = 0;
+ System.out.println(ba1[0]);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "ba1[0] = 0;", e.getMessage(),
+ "Cannot store to byte/boolean array because " +
+ (hasDebugInfo ? "\"ba1\"" : "\"<local5>\"") + " is null");
+ }
+ // castore
+ try {
+ ca1[0] = 0;
+ System.out.println(ca1[0]);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "ca1[0] = 0;", e.getMessage(),
+ "Cannot store to char array because " +
+ (hasDebugInfo ? "\"ca1\"" : "\"<local6>\"") + " is null");
+ }
+ // sastore
+ try {
+ sa1[0] = 0;
+ System.out.println(sa1[0]);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "sa1[0] = 0;", e.getMessage(),
+ "Cannot store to short array because " +
+ (hasDebugInfo ? "\"sa1\"" : "\"<local7>\"") + " is null");
+ }
+ // lastore
+ try {
+ la1[0] = 0;
+ System.out.println(la1[0]);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "la1[0] = 0;", e.getMessage(),
+ "Cannot store to long array because " +
+ (hasDebugInfo ? "\"la1\"" : "\"<local8>\"") + " is null");
+ }
+ // dastore
+ try {
+ da1[0] = 0;
+ System.out.println(da1[0]);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "da1[0] = 0;", e.getMessage(),
+ "Cannot store to double array because " +
+ (hasDebugInfo ? "\"da1\"" : "\"<local9>\"") + " is null");
+ }
+
+ // arraylength
+ try {
+ int val = za1.length;
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, " int val = za1.length;", e.getMessage(),
+ "Cannot read the array length because " +
+ (hasDebugInfo ? "\"za1\"" : "\"<local4>\"") + " is null");
+ }
+ // athrow
+ try {
+ RuntimeException exc = null;
+ throw exc;
+ } catch (NullPointerException e) {
+ checkMessage(e, "throw exc;", e.getMessage(),
+ "Cannot throw exception because " +
+ (hasDebugInfo ? "\"exc\"" : "\"<local10>\"") + " is null");
+ }
+ // monitorenter
+ try {
+ synchronized (nullInstanceField) {
+ // desired
+ }
+ } catch (NullPointerException e) {
+ checkMessage(e, "synchronized (nullInstanceField) { ... }", e.getMessage(),
+ "Cannot enter synchronized block because " +
+ "\"this.nullInstanceField\" is null");
+ }
+ // monitorexit
+ // No test available
+
+ // getfield
+ try {
+ Object val = nullInstanceField.nullInstanceField;
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "Object val = nullInstanceField.nullInstanceField;", e.getMessage(),
+ "Cannot read field \"nullInstanceField\" because " +
+ "\"this.nullInstanceField\" is null");
+ }
+ // putfield
+ try {
+ nullInstanceField.nullInstanceField = new NullPointerExceptionTest();
+ System.out.println(nullInstanceField.nullInstanceField);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "nullInstanceField.nullInstanceField = new NullPointerExceptionTest();", e.getMessage(),
+ "Cannot assign field \"nullInstanceField\" because " +
+ "\"this.nullInstanceField\" is null");
+ }
+ // invokevirtual
+ try {
+ String val = nullInstanceField.toString();
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "String val = nullInstanceField.toString();", e.getMessage(),
+ "Cannot invoke \"Object.toString()\" because " +
+ "\"this.nullInstanceField\" is null");
+ }
+ // invokeinterface
+ try {
+ NullPointerExceptionTest obj = this;
+ Object val = obj.dag.getArray();
+ Asserts.assertNull(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "Object val = obj.dag.getArray();", e.getMessage(),
+ "Cannot invoke \"NullPointerExceptionTest$DoubleArrayGen.getArray()\" because " +
+ (hasDebugInfo ? "\"obj" : "\"<local10>") + ".dag\" is null");
+ }
+ // invokespecial
+ G g = null;
+ try {
+ byte[] classBytes = G.generateSub2GTestClass();
+ Lookup lookup = lookup();
+ Class<?> clazz = lookup.defineClass(classBytes);
+ g = (G) clazz.getDeclaredConstructor().newInstance();
+ } catch (Exception e) {
+ e.printStackTrace();
+ Asserts.fail("Generating class Sub2G failed.");
+ }
+ try {
+ g.m2("Beginning");
+ } catch (NullPointerException e) {
+ checkMessage(e, "return super.m2(x).substring(2); // ... where super is null by bytecode manipulation.", e.getMessage(),
+ "Cannot invoke \"G.m2(String)\" because \"null\" is null");
+ }
+ // Test parameter and return types
+ try {
+ boolean val = (nullInstanceField.callWithTypes(null, null, 0.0f, 0L, (short)0, false, (byte)0, 0.0, 'x') == 0.0);
+ Asserts.assertTrue(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "boolean val = (nullInstanceField.callWithTypes(null, null, 0.0f, 0L, (short)0, false, (byte)0, 0.0, 'x') == 0.0);", e.getMessage(),
+ "Cannot invoke \"NullPointerExceptionTest.callWithTypes(String[][], int[][][], float, long, short, boolean, byte, double, char)\" because " +
+ "\"this.nullInstanceField\" is null");
+ }
+ }
+
+ static void test_iload() {
+ int i0 = 0;
+ int i1 = 1;
+ int i2 = 2;
+ int i3 = 3;
+ @SuppressWarnings("unused")
+ int i4 = 4;
+ int i5 = 5;
+
+ int[][] a = new int[6][];
+
+ // iload_0
+ try {
+ a[i0][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[i0][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[i0]\"" : "\"<local6>[<local0>]\"") + " is null");
+ }
+ // iload_1
+ try {
+ a[i1][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[i1][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[i1]\"" : "\"<local6>[<local1>]\"") + " is null");
+ }
+ // iload_2
+ try {
+ a[i2][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[i2][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[i2]\"" : "\"<local6>[<local2>]\"") + " is null");
+ }
+ // iload_3
+ try {
+ a[i3][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[i3][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[i3]\"" : "\"<local6>[<local3>]\"") + " is null");
+ }
+ // iload
+ try {
+ a[i5][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[i5][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[i5]\"" : "\"<local6>[<local5>]\"") + " is null");
+ }
+ }
+
+ // Other datatyes than int are not needed.
+ // If we implement l2d and similar bytecodes, we can print
+ // long expressions as array indexes. Then these here could
+ // be used.
+ static void test_lload() {
+ long long0 = 0L; // l0 looks like 10. Therefore long0.
+ long long1 = 1L;
+ long long2 = 2L;
+ long long3 = 3L;
+ @SuppressWarnings("unused")
+ long long4 = 4L;
+ long long5 = 5L;
+
+ int[][] a = new int[6][];
+
+ // lload_0
+ try {
+ a[(int)long0][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)long0][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[...]\"" : "\"<local12>[...]\"") + " is null");
+ }
+ // lload_1
+ try {
+ a[(int)long1][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)long1][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[...]\"" : "\"<local12>[...]\"") + " is null");
+ }
+ // lload_2
+ try {
+ a[(int)long2][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)long2][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[...]\"" : "\"<local12>[...]\"") + " is null");
+ }
+ // lload_3
+ try {
+ a[(int)long3][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)long3][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[...]\"" : "\"<local12>[...]\"") + " is null");
+ }
+ // lload
+ try {
+ a[(int)long5][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)long5][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[...]\"" : "\"<local12>[...]\"") + " is null");
+ }
+ }
+
+ static void test_fload() {
+ float f0 = 0.0f;
+ float f1 = 1.0f;
+ float f2 = 2.0f;
+ float f3 = 3.0f;
+ @SuppressWarnings("unused")
+ float f4 = 4.0f;
+ float f5 = 5.0f;
+
+ int[][] a = new int[6][];
+
+ // fload_0
+ try {
+ a[(int)f0][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)f0][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[...]\"" : "\"<local6>[...]\"") + " is null");
+ }
+ // fload_1
+ try {
+ a[(int)f1][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)f1][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[...]\"" : "\"<local6>[...]\"") + " is null");
+ }
+ // fload_2
+ try {
+ a[(int)f2][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)f2][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[...]\"" : "\"<local6>[...]\"") + " is null");
+ }
+ // fload_3
+ try {
+ a[(int)f3][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)f3][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[...]\"" : "\"<local6>[...]\"") + " is null");
+ }
+ // fload
+ try {
+ a[(int)f5][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)f5][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[...]\"" : "\"<local6>[...]\"") + " is null");
+ }
+ }
+
+ @SuppressWarnings("null")
+ static void test_aload() {
+ F f0 = null;
+ F f1 = null;
+ F f2 = null;
+ F f3 = null;
+ @SuppressWarnings("unused")
+ F f4 = null;
+ F f5 = null;
+
+ // aload_0
+ try {
+ f0.i = 33;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "f0.i = 33;", e.getMessage(),
+ "Cannot assign field \"i\" because " +
+ (hasDebugInfo ? "\"f0\"" : "\"<local0>\"") + " is null");
+ }
+ // aload_1
+ try {
+ f1.i = 33;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "f1.i = 33;", e.getMessage(),
+ "Cannot assign field \"i\" because " +
+ (hasDebugInfo ? "\"f1\"" : "\"<local1>\"") + " is null");
+ }
+ // aload_2
+ try {
+ f2.i = 33;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "f2.i = 33;", e.getMessage(),
+ "Cannot assign field \"i\" because " +
+ (hasDebugInfo ? "\"f2\"" : "\"<local2>\"") + " is null");
+ }
+ // aload_3
+ try {
+ f3.i = 33;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "f3.i = 33;", e.getMessage(),
+ "Cannot assign field \"i\" because " +
+ (hasDebugInfo ? "\"f3\"" : "\"<local3>\"") + " is null");
+ }
+ // aload
+ try {
+ f5.i = 33;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "f5.i = 33;", e.getMessage(),
+ "Cannot assign field \"i\" because " +
+ (hasDebugInfo ? "\"f5\"" : "\"<local5>\"") + " is null");
+ }
+ }
+
+ // Helper class for test cases.
+ class A {
+ public B to_b;
+ public B getB() { return to_b; }
+ }
+
+ // Helper class for test cases.
+ class B {
+ public C to_c;
+ public B to_b;
+ public C getC() { return to_c; }
+ public B getBfromB() { return to_b; }
+ }
+
+ // Helper class for test cases.
+ class C {
+ public D to_d;
+ public D getD() { return to_d; }
+ }
+
+ // Helper class for test cases.
+ class D {
+ public int num;
+ public int[][] ar;
+ }
+
+
+ @SuppressWarnings("null")
+ public void testArrayChasing() {
+ int[][][][][][] a = null;
+ try {
+ a[0][0][0][0][0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[0][0][0][0][0] = 99; // a is null", e.getMessage(),
+ "Cannot load from object array because " +
+ (hasDebugInfo ? "\"a\"" : "\"<local1>\"") + " is null");
+ }
+ a = new int[1][][][][][];
+ try {
+ a[0][0][0][0][0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[0][0][0][0][0] = 99; // a[0] is null", e.getMessage(),
+ "Cannot load from object array because " +
+ (hasDebugInfo ? "\"a[0]\"" : "\"<local1>[0]\"") + " is null");
+ }
+ a[0] = new int[1][][][][];
+ try {
+ a[0][0][0][0][0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[0][0][0][0][0] = 99; // a[0][0] is null", e.getMessage(),
+ "Cannot load from object array because " +
+ (hasDebugInfo ? "\"a[0][0]\"" : "\"<local1>[0][0]\"") + " is null");
+ }
+ a[0][0] = new int[1][][][];
+ try {
+ a[0][0][0][0][0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[0][0][0][0][0] = 99; // a[0][0][0] is null", e.getMessage(),
+ "Cannot load from object array because " +
+ (hasDebugInfo ? "\"a[0][0][0]\"" : "\"<local1>[0][0][0]\"") + " is null");
+ }
+ try {
+ System.out.println(a[0][0][0].length);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[0][0][0].length; // a[0][0][0] is null", e.getMessage(),
+ "Cannot read the array length because " +
+ (hasDebugInfo ? "\"a[0][0][0]\"" : "\"<local1>[0][0][0]\"") + " is null");
+ }
+ a[0][0][0] = new int[1][][];
+ try {
+ a[0][0][0][0][0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[0][0][0][0][0] = 99; // a[0][0][0][0] is null", e.getMessage(),
+ "Cannot load from object array because " +
+ (hasDebugInfo ? "\"a[0][0][0][0]\"" : "\"<local1>[0][0][0][0]\"") + " is null");
+ }
+ a[0][0][0][0] = new int[1][];
+ // Reaching max recursion depth. Prints <array>.
+ try {
+ a[0][0][0][0][0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[0][0][0][0][0] = 99; // a[0][0][0][0][0] is null", e.getMessage(),
+ "Cannot store to int array because " +
+ "\"<array>[0][0][0][0][0]\" is null");
+ }
+ a[0][0][0][0][0] = new int[1];
+ try {
+ a[0][0][0][0][0][0] = 99;
+ } catch (NullPointerException e) {
+ Asserts.fail();
+ }
+ }
+
+ @SuppressWarnings("null")
+ public void testPointerChasing() {
+ A a = null;
+ try {
+ a.to_b.to_c.to_d.num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.to_b.to_c.to_d.num = 99; // a is null", e.getMessage(),
+ "Cannot read field \"to_b\" because " +
+ (hasDebugInfo ? "\"a\"" : "\"<local1>\"") + " is null");
+ }
+ a = new A();
+ try {
+ a.to_b.to_c.to_d.num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.to_b.to_c.to_d.num = 99; // a.to_b is null", e.getMessage(),
+ "Cannot read field \"to_c\" because " +
+ (hasDebugInfo ? "\"a.to_b\"" : "\"<local1>.to_b\"") + " is null");
+ }
+ a.to_b = new B();
+ try {
+ a.to_b.to_c.to_d.num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.to_b.to_c.to_d.num = 99; // a.to_b.to_c is null", e.getMessage(),
+ "Cannot read field \"to_d\" because " +
+ (hasDebugInfo ? "\"a.to_b.to_c\"" : "\"<local1>.to_b.to_c\"") + " is null");
+ }
+ a.to_b.to_c = new C();
+ try {
+ a.to_b.to_c.to_d.num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.to_b.to_c.to_d.num = 99; // a.to_b.to_c.to_d is null", e.getMessage(),
+ "Cannot assign field \"num\" because " +
+ (hasDebugInfo ? "\"a.to_b.to_c.to_d\"" : "\"<local1>.to_b.to_c.to_d\"") + " is null");
+ }
+ }
+
+ @SuppressWarnings("null")
+ public void testMethodChasing() {
+ A a = null;
+ try {
+ a.getB().getBfromB().getC().getD().num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().getC().getD().num = 99; // a is null", e.getMessage(),
+ "Cannot invoke \"NullPointerExceptionTest$A.getB()\" because " +
+ (hasDebugInfo ? "\"a" : "\"<local1>") + "\" is null");
+ }
+ a = new A();
+ try {
+ a.getB().getBfromB().getC().getD().num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().getC().getD().num = 99; // a.getB() is null", e.getMessage(),
+ "Cannot invoke \"NullPointerExceptionTest$B.getBfromB()\" because " +
+ "the return value of \"NullPointerExceptionTest$A.getB()\" is null");
+ }
+ a.to_b = new B();
+ try {
+ a.getB().getBfromB().getC().getD().num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().getC().getD().num = 99; // a.getB().getBfromB() is null", e.getMessage(),
+ "Cannot invoke \"NullPointerExceptionTest$B.getC()\" because " +
+ "the return value of \"NullPointerExceptionTest$B.getBfromB()\" is null");
+ }
+ a.to_b.to_b = new B();
+ try {
+ a.getB().getBfromB().getC().getD().num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().getC().getD().num = 99; // a.getB().getBfromB().getC() is null", e.getMessage(),
+ "Cannot invoke \"NullPointerExceptionTest$C.getD()\" because " +
+ "the return value of \"NullPointerExceptionTest$B.getC()\" is null");
+ }
+ a.to_b.to_b.to_c = new C();
+ try {
+ a.getB().getBfromB().getC().getD().num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().getC().getD().num = 99; // a.getB().getBfromB().getC().getD() is null", e.getMessage(),
+ "Cannot assign field \"num\" because " +
+ "the return value of \"NullPointerExceptionTest$C.getD()\" is null");
+ }
+ }
+
+ @SuppressWarnings("null")
+ public void testMixedChasing() {
+ A a = null;
+ try {
+ a.getB().getBfromB().to_c.to_d.ar[0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().to_c.to_d.ar[0][0] = 99; // a is null", e.getMessage(),
+ "Cannot invoke \"NullPointerExceptionTest$A.getB()\" because " +
+ (hasDebugInfo ? "\"a\"" : "\"<local1>\"") + " is null");
+ }
+ a = new A();
+ try {
+ a.getB().getBfromB().to_c.to_d.ar[0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().to_c.to_d.ar[0][0] = 99; // a.getB() is null", e.getMessage(),
+ "Cannot invoke \"NullPointerExceptionTest$B.getBfromB()\" because " +
+ "the return value of \"NullPointerExceptionTest$A.getB()\" is null");
+ }
+ a.to_b = new B();
+ try {
+ a.getB().getBfromB().to_c.to_d.ar[0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().to_c.to_d.ar[0][0] = 99; // a.getB().getBfromB() is null", e.getMessage(),
+ "Cannot read field \"to_c\" because " +
+ "the return value of \"NullPointerExceptionTest$B.getBfromB()\" is null");
+ }
+ a.to_b.to_b = new B();
+ try {
+ a.getB().getBfromB().to_c.to_d.ar[0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().to_c.to_d.ar[0][0] = 99; // a.getB().getBfromB().to_c is null", e.getMessage(),
+ "Cannot read field \"to_d\" because " +
+ "\"NullPointerExceptionTest$B.getBfromB().to_c\" is null");
+ }
+ a.to_b.to_b.to_c = new C();
+ try {
+ a.getB().getBfromB().to_c.to_d.ar[0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().to_c.to_d.ar[0][0] = 99; // a.getB().getBfromB().to_c.to_d is null", e.getMessage(),
+ "Cannot read field \"ar\" because " +
+ "\"NullPointerExceptionTest$B.getBfromB().to_c.to_d\" is null");
+ }
+ a.to_b.to_b.to_c.to_d = new D();
+ try {
+ a.getB().getBfromB().to_c.to_d.ar[0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().to_c.to_d.ar[0][0] = 99; // a.getB().getBfromB().to_c.to_d.ar is null", e.getMessage(),
+ "Cannot load from object array because " +
+ "\"NullPointerExceptionTest$B.getBfromB().to_c.to_d.ar\" is null");
+ }
+ try {
+ a.getB().getBfromB().getC().getD().ar[0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().getC().getD().ar[0][0] = 99; // a.getB().getBfromB().getC().getD().ar is null", e.getMessage(),
+ "Cannot load from object array because " +
+ "\"NullPointerExceptionTest$C.getD().ar\" is null");
+ }
+ a.to_b.to_b.to_c.to_d.ar = new int[1][];
+ try {
+ a.getB().getBfromB().to_c.to_d.ar[0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().to_c.to_d.ar[0][0] = 99; // a.getB().getBfromB().to_c.to_d.ar[0] is null", e.getMessage(),
+ "Cannot store to int array because " +
+ "\"NullPointerExceptionTest$B.getBfromB().to_c.to_d.ar[0]\" is null");
+ }
+ try {
+ a.getB().getBfromB().getC().getD().ar[0][0] = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.getB().getBfromB().getC().getD().ar[0][0] = 99; // a.getB().getBfromB().getC().getD().ar[0] is null", e.getMessage(),
+ "Cannot store to int array because " +
+ "\"NullPointerExceptionTest$C.getD().ar[0]\" is null");
+ }
+ }
+
+ // Helper method to cause test case.
+ private Object returnNull(String[][] dummy1, int[][][] dummy2, float dummy3) {
+ return null;
+ }
+
+ // Helper method to cause test case.
+ private NullPointerExceptionTest returnMeAsNull(Throwable dummy1, int dummy2, char dummy3) {
+ return null;
+ }
+
+ // Helper interface for test cases.
+ static interface DoubleArrayGen {
+ public double[] getArray();
+ }
+
+ // Helper class for test cases.
+ static class DoubleArrayGenImpl implements DoubleArrayGen {
+ @Override
+ public double[] getArray() {
+ return null;
+ }
+ }
+
+ // Helper class for test cases.
+ static class NullPointerGenerator {
+ public static Object nullReturner(boolean dummy1) {
+ return null;
+ }
+
+ public Object returnMyNull(double dummy1, long dummy2, short dummy3) {
+ return null;
+ }
+ }
+
+ // Helper method to cause test case.
+ public void ImplTestLoadedFromMethod(DoubleArrayGen gen) {
+ try {
+ (gen.getArray())[0] = 1.0;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "(gen.getArray())[0] = 1.0;", e.getMessage(),
+ "Cannot store to double array because " +
+ "the return value of \"NullPointerExceptionTest$DoubleArrayGen.getArray()\" is null");
+ }
+ }
+
+ public void testNullEntity() {
+ int[][] a = new int[820][];
+
+ test_iload();
+ test_lload();
+ test_fload();
+ // test_dload();
+ test_aload();
+ // aload_0: 'this'
+ try {
+ this.nullInstanceField.nullInstanceField = new NullPointerExceptionTest();
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "this.nullInstanceField.nullInstanceField = new NullPointerExceptionTest();", e.getMessage(),
+ "Cannot assign field \"nullInstanceField\" because \"this.nullInstanceField\" is null");
+ }
+
+ // aconst_null
+ try {
+ throw null;
+ } catch (NullPointerException e) {
+ checkMessage(e, "throw null;", e.getMessage(),
+ "Cannot throw exception because \"null\" is null");
+ }
+ // iconst_0
+ try {
+ a[0][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[0][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[0]\"" : "\"<local1>[0]\"") + " is null");
+ }
+ // iconst_1
+ try {
+ a[1][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[1][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[1]\"" : "\"<local1>[1]\"") + " is null");
+ }
+ // iconst_2
+ try {
+ a[2][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[2][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[2]\"" : "\"<local1>[2]\"") + " is null");
+ }
+ // iconst_3
+ try {
+ a[3][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[3][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[3]\"" : "\"<local1>[3]\"") + " is null");
+ }
+ // iconst_4
+ try {
+ a[4][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[4][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[4]\"" : "\"<local1>[4]\"") + " is null");
+ }
+ // iconst_5
+ try {
+ a[5][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[5][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[5]\"" : "\"<local1>[5]\"") + " is null");
+ }
+ // long --> iconst
+ try {
+ a[(int)0L][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[(int)0L][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[0]\"" : "\"<local1>[0]\"") + " is null");
+ }
+ // bipush
+ try {
+ a[139 /*0x77*/][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[139][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[139]\"" : "\"<local1>[139]\"") + " is null");
+ }
+ // sipush
+ try {
+ a[819 /*0x333*/][0] = 77;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a[819][0] = 77;", e.getMessage(),
+ "Cannot store to int array because " +
+ (hasDebugInfo ? "\"a[819]\"" : "\"<local1>[819]\"") + " is null");
+ }
+
+ // aaload, with recursive descend.
+ testArrayChasing();
+
+ // getstatic
+ try {
+ boolean val = (((float[]) nullStaticField)[0] == 1.0f);
+ Asserts.assertTrue(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "boolean val = (((float[]) nullStaticField)[0] == 1.0f);", e.getMessage(),
+ "Cannot load from float array because \"NullPointerExceptionTest.nullStaticField\" is null");
+ }
+
+ // getfield, with recursive descend.
+ testPointerChasing();
+
+ // invokestatic
+ try {
+ char val = ((char[]) NullPointerGenerator.nullReturner(false))[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "char val = ((char[]) NullPointerGenerator.nullReturner(false))[0];", e.getMessage(),
+ "Cannot load from char array because " +
+ "the return value of \"NullPointerExceptionTest$NullPointerGenerator.nullReturner(boolean)\" is null");
+ }
+ // invokevirtual
+ try {
+ char val = ((char[]) (new NullPointerGenerator().returnMyNull(1, 1, (short) 1)))[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "char val = ((char[]) (new NullPointerGenerator().returnMyNull(1, 1, (short) 1)))[0];", e.getMessage(),
+ "Cannot load from char array because " +
+ "the return value of \"NullPointerExceptionTest$NullPointerGenerator.returnMyNull(double, long, short)\" is null");
+ }
+ // Call with array arguments.
+ try {
+ double val = ((double[]) returnNull(null, null, 1f))[0];
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "double val = ((double[]) returnNull(null, null, 1f))[0];", e.getMessage(),
+ "Cannot load from double array because " +
+ "the return value of \"NullPointerExceptionTest.returnNull(String[][], int[][][], float)\" is null");
+ }
+ // invokespecial
+ try {
+ SubG g = new SubG();
+ g.m2("Beginning");
+ } catch (NullPointerException e) {
+ checkMessage(e, "return super.m2(x).substring(2);", e.getMessage(),
+ "Cannot invoke \"String.substring(int)\" because " +
+ "the return value of \"G.m2(String)\" is null");
+ }
+ // invokeinterface
+ ImplTestLoadedFromMethod(new DoubleArrayGenImpl());
+ try {
+ returnMeAsNull(null, 1, 'A').dag = new DoubleArrayGenImpl();
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "returnMeAsNull(null, 1, 'A').dag = new DoubleArrayGenImpl();", e.getMessage(),
+ "Cannot assign field \"dag\" because " +
+ "the return value of \"NullPointerExceptionTest.returnMeAsNull(java.lang.Throwable, int, char)\" is null");
+ }
+ testMethodChasing();
+
+ // Mixed recursive descend.
+ testMixedChasing();
+ }
+
+ // Assure 64 parameters are printed as 'parameteri'.
+ public String manyParameters(
+ int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
+ int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20,
+ int i21, int i22, int i23, int i24, int i25, int i26, int i27, int i28, int i29, int i30,
+ int i31, int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, int i40,
+ int i41, int i42, int i43, int i44, int i45, int i46, int i47, int i48, int i49, int i50,
+ int i51, int i52, int i53, int i54, int i55, int i56, int i57, int i58, int i59, int i60,
+ int i61, int i62, int i63, int i64, int i65, int i66, int i67, int i68, int i69, int i70) {
+ String[][][][] ar5 = new String[1][1][1][1];
+ int[][][] idx3 = new int[1][1][1];
+ int[][] idx2 = new int[1][1];
+ return ar5[i70]
+ [idx2[i65][i64]]
+ [idx3[i63][i62][i47]]
+ [idx3[idx2[i33][i32]][i31][i17]]
+ .substring(2);
+ }
+
+ // The double placeholder takes two slots on the stack.
+ public void testParametersTestMethod(A a, double placeholder, B b, Integer i) throws Exception {
+ try {
+ a.to_b.to_c.to_d.num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "a.to_b.to_c.to_d.num = 99; // to_c is null, a is a parameter.", e.getMessage(),
+ "Cannot read field \"to_d\" because \"" +
+ (hasDebugInfo ? "a" : "<parameter1>") + ".to_b.to_c\" is null");
+ }
+
+ try {
+ b.to_c.to_d.num = 99;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "b.to_c.to_d.num = 99; // b is null and b is a parameter.", e.getMessage(),
+ "Cannot read field \"to_c\" because " +
+ // We expect number '3' for the parameter.
+ (hasDebugInfo ? "\"b\"" : "\"<parameter3>\"") + " is null");
+ }
+
+
+ try {
+ @SuppressWarnings("unused")
+ int my_i = i;
+ } catch (NullPointerException e) {
+ checkMessage(e, "int my_i = i; // i is a parameter of type Integer.", e.getMessage(),
+ "Cannot invoke \"java.lang.Integer.intValue()\" because " +
+ (hasDebugInfo ? "\"i\"" : "\"<parameter4>\"") + " is null");
+ }
+
+ // If no debug information is available, only 64 parameters (this and i1 through i63)
+ // will be reported in the message as 'parameteri'. Others will be reported as 'locali'.
+ try {
+ manyParameters(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ } catch (NullPointerException e) {
+ checkMessage(e, "return ar5[i70][idx2[i65][i64]][idx3[i63][i62][i47]][idx3[idx2[i33][i32]][i31][i17]].substring(2);", e.getMessage(),
+ "Cannot invoke \"String.substring(int)\" because " +
+ (hasDebugInfo ?
+ "\"ar5[i70][idx2[i65][i64]][idx3[i63][i62][i47]][idx3[idx2[i33][i32]][i31][i17]]\"" :
+ "\"<local71>[<local70>][<local73>[<local65>][<local64>]][<local72>[<parameter63>][<parameter62>]" +
+ "[<parameter47>]][<local72>[<local73>[<parameter33>][<parameter32>]][<parameter31>][<parameter17>]]\"") +
+ " is null");
+ }
+ }
+
+
+ public void testParameters() throws Exception {
+ A a = new A();
+ a.to_b = new B();
+ testParametersTestMethod(a, 0.0, null, null);
+ }
+
+
+ public void testCreation() throws Exception {
+ // If allocated with new, the message should not be generated.
+ Asserts.assertNull(new NullPointerException().getMessage());
+ String msg = new String("A pointless message");
+ Asserts.assertTrue(new NullPointerException(msg).getMessage() == msg);
+
+ // If created via reflection, the message should not be generated.
+ Exception ex = NullPointerException.class.getDeclaredConstructor().newInstance();
+ Asserts.assertNull(ex.getMessage());
+ }
+
+ public void testNative() throws Exception {
+ // If NPE is thrown in a native method, the message should
+ // not be generated.
+ try {
+ Class.forName(null);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ Asserts.assertNull(e.getMessage());
+ }
+
+ }
+
+ // Test we get the same message calling npe.getMessage() twice.
+ @SuppressWarnings("null")
+ public void testSameMessage() throws Exception {
+ Object null_o = null;
+ String expectedMsg =
+ "Cannot invoke \"Object.hashCode()\" because " +
+ (hasDebugInfo ? "\"null_o" : "\"<local1>") + "\" is null";
+
+ try {
+ null_o.hashCode();
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ String msg1 = e.getMessage();
+ checkMessage(e, "null_o.hashCode()", msg1, expectedMsg);
+ String msg2 = e.getMessage();
+ Asserts.assertTrue(msg1.equals(msg2));
+ // It was decided that getMessage should generate the
+ // message anew on every call, so this does not hold.
+ //Asserts.assertTrue(msg1 == msg2);
+ Asserts.assertFalse(msg1 == msg2);
+ }
+ }
+
+ @SuppressWarnings("null")
+ public void testSerialization() throws Exception {
+ // NPE without message.
+ Object o1 = new NullPointerException();
+ ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
+ ObjectOutputStream oos1 = new ObjectOutputStream(bos1);
+ oos1.writeObject(o1);
+ ByteArrayInputStream bis1 = new ByteArrayInputStream(bos1.toByteArray());
+ ObjectInputStream ois1 = new ObjectInputStream(bis1);
+ Exception ex1 = (Exception) ois1.readObject();
+ Asserts.assertNull(ex1.getMessage());
+
+ // NPE with custom message.
+ String msg2 = "A useless message";
+ Object o2 = new NullPointerException(msg2);
+ ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
+ ObjectOutputStream oos2 = new ObjectOutputStream(bos2);
+ oos2.writeObject(o2);
+ ByteArrayInputStream bis2 = new ByteArrayInputStream(bos2.toByteArray());
+ ObjectInputStream ois2 = new ObjectInputStream(bis2);
+ Exception ex2 = (Exception) ois2.readObject();
+ Asserts.assertEquals(ex2.getMessage(), msg2);
+
+ // NPE with generated message.
+ Object null_o3 = null;
+ Object o3 = null;
+ String msg3 = null;
+ try {
+ int hc = null_o3.hashCode();
+ System.out.println(hc);
+ Asserts.fail();
+ } catch (NullPointerException npe3) {
+ o3 = npe3;
+ msg3 = npe3.getMessage();
+ checkMessage(npe3, "int hc = null_o3.hashCode();", msg3,
+ "Cannot invoke \"Object.hashCode()\" because " +
+ (hasDebugInfo ? "\"null_o3\"" : "\"<local14>\"") + " is null");
+ }
+ ByteArrayOutputStream bos3 = new ByteArrayOutputStream();
+ ObjectOutputStream oos3 = new ObjectOutputStream(bos3);
+ oos3.writeObject(o3);
+ ByteArrayInputStream bis3 = new ByteArrayInputStream(bos3.toByteArray());
+ ObjectInputStream ois3 = new ObjectInputStream(bis3);
+ Exception ex3 = (Exception) ois3.readObject();
+ // It was decided that getMessage should not store the
+ // message in Throwable.detailMessage or implement writeReplace(),
+ // thus it can not be recovered by serialization.
+ //Asserts.assertEquals(ex3.getMessage(), msg3);
+ Asserts.assertEquals(ex3.getMessage(), null);
+ }
+
+ static int index17 = 17;
+ int getIndex17() { return 17; };
+
+ @SuppressWarnings({ "unused", "null" })
+ public void testComplexMessages() {
+ try {
+ staticLongArray[0][0] = 2L;
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "staticLongArray[0][0] = 2L;", e.getMessage(),
+ "Cannot store to long array because " +
+ "\"NullPointerExceptionTest.staticLongArray[0]\" is null");
+ }
+
+ try {
+ NullPointerExceptionTest obj = this;
+ Object val = obj.dag.getArray().clone();
+ Asserts.assertNull(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "Object val = obj.dag.getArray().clone();", e.getMessage(),
+ "Cannot invoke \"NullPointerExceptionTest$DoubleArrayGen.getArray()\" because " +
+ (hasDebugInfo ? "\"obj" : "\"<local1>") + ".dag\" is null");
+ }
+ try {
+ int indexes[] = new int[1];
+ NullPointerExceptionTest[] objs = new NullPointerExceptionTest[] {this};
+ Object val = objs[indexes[0]].nullInstanceField.returnNull(null, null, 1f);
+ Asserts.assertNull(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ checkMessage(e, "Object val = objs[indexes[0]].nullInstanceField.returnNull(null, null, 1f);", e.getMessage(),
+ "Cannot invoke \"NullPointerExceptionTest.returnNull(String[][], int[][][], float)\" because " +
+ (hasDebugInfo ? "\"objs[indexes" : "\"<local2>[<local1>") + "[0]].nullInstanceField\" is null");
+ }
+
+ try {
+ int indexes[] = new int[1];
+ NullPointerExceptionTest[][] objs =
+ new NullPointerExceptionTest[][] {new NullPointerExceptionTest[] {this}};
+ synchronized (objs[indexes[0]][0].nullInstanceField) {
+ Asserts.fail();
+ }
+ } catch (NullPointerException e) {
+ checkMessage(e, "synchronized (objs[indexes[0]][0].nullInstanceField) { ... }", e.getMessage(),
+ "Cannot enter synchronized block because " +
+ (hasDebugInfo ? "\"objs[indexes" : "\"<local2>[<local1>" ) + "[0]][0].nullInstanceField\" is null");
+ }
+
+ try {
+ // If we can get the value from more than one bci, we cannot know which one
+ // is null. Make sure we don't print the wrong value.
+ String s = null;
+ @SuppressWarnings("unused")
+ byte[] val = (Math.random() < 0.5 ? s : (new String[1])[0]).getBytes();
+ } catch (NullPointerException e) {
+ checkMessage(e, "byte[] val = (Math.random() < 0.5 ? s : (new String[1])[0]).getBytes();", e.getMessage(),
+ "Cannot invoke \"String.getBytes()\"");
+ }
+
+ try {
+ // If we can get the value from more than one bci, we cannot know which one
+ // is null. Make sure we don't print the wrong value. Also make sure if
+ // we don't print the failed action we don't print a string at all.
+ int[][] a = new int[1][];
+ int[][] b = new int[2][];
+ long index = 0;
+ @SuppressWarnings("unused")
+ int val = (Math.random() < 0.5 ? a[(int)index] : b[(int)index])[13];
+ } catch (NullPointerException e) {
+ checkMessage(e, "int val = (Math.random() < 0.5 ? a[(int)index] : b[(int)index])[13]", e.getMessage(),
+ "Cannot load from int array");
+ }
+
+ try {
+ // If we can get the value from more than one bci, we cannot know which one
+ // is null. Make sure we don't print the wrong value. Also make sure if
+ // we don't print the failed action we don't print a string at all.
+ int[][] a = new int[1][];
+ int[][] b = new int[2][];
+ long index = 0;
+ int val = (Math.random() < 0.5 ? a : b)[(int)index][13];
+ } catch (NullPointerException e) {
+ checkMessage(e, "int val = (Math.random() < 0.5 ? a : b)[(int)index][13]", e.getMessage(),
+ "Cannot load from int array because \"<array>[...]\" is null");
+ }
+
+ try {
+ C c1 = new C();
+ C c2 = new C();
+ (Math.random() < 0.5 ? c1 : c2).to_d.num = 77;
+ } catch (NullPointerException e) {
+ checkMessage(e, "(Math.random() < 0.5 ? c1 : c2).to_d.num = 77;", e.getMessage(),
+ "Cannot assign field \"num\" because \"to_d\" is null");
+ }
+
+ // Static variable as array index.
+ try {
+ staticLongArray[index17][0] = 2L;
+ } catch (NullPointerException e) {
+ checkMessage(e, "staticLongArray[index17][0] = 2L;", e.getMessage(),
+ "Cannot store to long array because " +
+ "\"NullPointerExceptionTest.staticLongArray[NullPointerExceptionTest.index17]\" is null");
+ }
+
+ // Method call as array index.
+ try {
+ staticLongArray[getIndex17()][0] = 2L;
+ } catch (NullPointerException e) {
+ checkMessage(e, "staticLongArray[getIndex17()][0] = 2L;", e.getMessage(),
+ "Cannot store to long array because " +
+ "\"NullPointerExceptionTest.staticLongArray[NullPointerExceptionTest.getIndex17()]\" is null");
+ }
+
+ // Unboxing.
+ Integer a = null;
+ try {
+ int b = a;
+ } catch (NullPointerException e) {
+ checkMessage(e, "Integer a = null; int b = a;", e.getMessage(),
+ "Cannot invoke \"java.lang.Integer.intValue()\" because " +
+ (hasDebugInfo ? "\"a\"" : "\"<local1>\"") + " is null");
+ }
+
+ // Unboxing by hand. Has the same message as above.
+ try {
+ int b = a.intValue();
+ } catch (NullPointerException e) {
+ checkMessage(e, "Integer a = null; int b = a.intValue();", e.getMessage(),
+ "Cannot invoke \"java.lang.Integer.intValue()\" because " +
+ (hasDebugInfo ? "\"a\"" : "\"<local1>\"") + " is null");
+ }
+ }
+
+ // Generates:
+ // class E implements E0 {
+ // public int throwNPE(F f) {
+ // return f.i;
+ // }
+ // public void throwNPE_reuseStackSlot1(String s1) {
+ // System.out.println(s1.substring(1));
+ // String s1_2 = null; // Reuses slot 1.
+ // System.out.println(s1_2.substring(1));
+ // }
+ // public void throwNPE_reuseStackSlot4(String s1, String s2, String s3, String s4) {
+ // System.out.println(s4.substring(1));
+ // String s4_2 = null; // Reuses slot 4.
+ // System.out.println(s4_2.substring(1));
+ // }
+ // }
+ //
+ // This code was adapted from output of
+ // java jdk.internal.org.objectweb.asm.util.ASMifier E0.class
+ static byte[] generateTestClass() {
+ ClassWriter cw = new ClassWriter(0);
+ MethodVisitor mv;
+
+ cw.visit(50, ACC_SUPER, "E", null, "java/lang/Object", new String[] { "E0" });
+
+ {
+ mv = cw.visitMethod(0, "<init>", "()V", null, null);
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "throwNPE", "(LF;)I", null, null);
+ mv.visitCode();
+ Label label0 = new Label();
+ mv.visitLabel(label0);
+ mv.visitLineNumber(118, label0);
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitFieldInsn(GETFIELD, "F", "i", "I");
+ mv.visitInsn(IRETURN);
+ Label label1 = new Label();
+ mv.visitLabel(label1);
+ mv.visitLocalVariable("this", "LE;", null, label0, label1, 0);
+ mv.visitLocalVariable("f", "LE;", null, label0, label1, 1);
+ mv.visitMaxs(1, 2);
+ mv.visitEnd();
+ }
+
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "throwNPE_reuseStackSlot1", "(Ljava/lang/String;)V", null, null);
+ mv.visitCode();
+ Label label0 = new Label();
+ mv.visitLabel(label0);
+ mv.visitLineNumber(7, label0);
+ mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitInsn(ICONST_1);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(I)Ljava/lang/String;", false);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
+ Label label1 = new Label();
+ mv.visitLabel(label1);
+ mv.visitLineNumber(8, label1);
+ mv.visitInsn(ACONST_NULL);
+ mv.visitVarInsn(ASTORE, 1);
+ Label label2 = new Label();
+ mv.visitLabel(label2);
+ mv.visitLineNumber(9, label2);
+ mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitInsn(ICONST_1);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(I)Ljava/lang/String;", false);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
+ Label label3 = new Label();
+ mv.visitLabel(label3);
+ mv.visitLineNumber(10, label3);
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(3, 3);
+ mv.visitEnd();
+ }
+
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "throwNPE_reuseStackSlot4", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", null, null);
+ mv.visitCode();
+ Label label0 = new Label();
+ mv.visitLabel(label0);
+ mv.visitLineNumber(12, label0);
+ mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
+ mv.visitVarInsn(ALOAD, 4);
+ mv.visitInsn(ICONST_1);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(I)Ljava/lang/String;", false);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
+ Label label1 = new Label();
+ mv.visitLabel(label1);
+ mv.visitLineNumber(13, label1);
+ mv.visitInsn(ACONST_NULL);
+ mv.visitVarInsn(ASTORE, 4);
+ Label label2 = new Label();
+ mv.visitLabel(label2);
+ mv.visitLineNumber(14, label2);
+ mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
+ mv.visitVarInsn(ALOAD, 4);
+ mv.visitInsn(ICONST_1);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(I)Ljava/lang/String;", false);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
+ Label label3 = new Label();
+ mv.visitLabel(label3);
+ mv.visitLineNumber(15, label3);
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(3, 6);
+ mv.visitEnd();
+ }
+
+ cw.visitEnd();
+
+ return cw.toByteArray();
+ }
+
+ // Assign to a parameter.
+ // Without debug information, this will print "parameter1" if a NPE
+ // is raised in the first line because null was passed to the method.
+ // It will print "local1" if a NPE is raised in line three.
+ public void assign_to_parameter(String s1) {
+ System.out.println(s1.substring(1));
+ s1 = null;
+ System.out.println(s1.substring(2));
+ }
+
+ // Tests that a class generated on the fly is handled properly.
+ public void testGeneratedCode() throws Exception {
+ byte[] classBytes = generateTestClass();
+ Lookup lookup = lookup();
+ Class<?> clazz = lookup.defineClass(classBytes);
+ E0 e = (E0) clazz.getDeclaredConstructor().newInstance();
+ try {
+ e.throwNPE(null);
+ } catch (NullPointerException ex) {
+ checkMessage(ex, "return f.i;",
+ ex.getMessage(),
+ "Cannot read field \"i\" because \"f\" is null");
+ }
+
+ // Optimized bytecode can reuse local variable slots for several
+ // local variables.
+ // If there is no variable name information, we print 'parameteri'
+ // if a parameter maps to a local slot. Once a local slot has been
+ // written, we don't know any more whether it was written as the
+ // corresponding parameter, or whether another local has been
+ // mapped to the slot. So we don't want to print 'parameteri' any
+ // more, but 'locali'. Similary for 'this'.
+
+ // Expect message saying "parameter0".
+ try {
+ e.throwNPE_reuseStackSlot1(null);
+ } catch (NullPointerException ex) {
+ checkMessage(ex, "s1.substring(1)",
+ ex.getMessage(),
+ "Cannot invoke \"String.substring(int)\" because \"<parameter1>\" is null");
+ }
+ // Expect message saying "local0".
+ try {
+ e.throwNPE_reuseStackSlot1("aa");
+ } catch (NullPointerException ex) {
+ checkMessage(ex, "s1_2.substring(1)",
+ ex.getMessage(),
+ "Cannot invoke \"String.substring(int)\" because \"<local1>\" is null");
+ }
+ // Expect message saying "parameter4".
+ try {
+ e.throwNPE_reuseStackSlot4("aa", "bb", "cc", null);
+ } catch (NullPointerException ex) {
+ checkMessage(ex, "s4.substring(1)",
+ ex.getMessage(),
+ "Cannot invoke \"String.substring(int)\" because \"<parameter4>\" is null");
+ }
+ // Expect message saying "local4".
+ try {
+ e.throwNPE_reuseStackSlot4("aa", "bb", "cc", "dd");
+ } catch (NullPointerException ex) {
+ checkMessage(ex, "s4_2.substring(1)",
+ ex.getMessage(),
+ "Cannot invoke \"String.substring(int)\" because \"<local4>\" is null");
+ }
+
+ // Unfortunately, with the fix for optimized code as described above
+ // we don't write 'parameteri' any more after the parameter variable
+ // has been assigned.
+
+ if (!hasDebugInfo) {
+ // Expect message saying "parameter1".
+ try {
+ assign_to_parameter(null);
+ } catch (NullPointerException ex) {
+ checkMessage(ex, "s1.substring(1)",
+ ex.getMessage(),
+ "Cannot invoke \"String.substring(int)\" because \"<parameter1>\" is null");
+ }
+ // The message says "local1" although "parameter1" would be correct.
+ try {
+ assign_to_parameter("aaa");
+ } catch (NullPointerException ex) {
+ checkMessage(ex, "s1.substring(2)",
+ ex.getMessage(),
+ "Cannot invoke \"String.substring(int)\" because \"<local1>\" is null");
+ }
+ }
+ }
+}
+
+// Helper interface for test cases needed for generateTestClass().
+interface E0 {
+ public int throwNPE(F f);
+ public void throwNPE_reuseStackSlot1(String s1);
+ public void throwNPE_reuseStackSlot4(String s1, String s2, String s3, String s4);
+}
+
+// Helper class for test cases needed for generateTestClass().
+class F {
+ int i;
+}
+
+// For invokespecial test cases.
+class G {
+ public String m2(String x) {
+ return null;
+ }
+
+ // This generates the following class:
+ //
+ // class Sub2G extends G {
+ // public String m2(String x) {
+ // super = null; // Possible in raw bytecode.
+ // return super.m2(x).substring(2); // Uses invokespecial.
+ // }
+ // }
+ //
+ // This code was adapted from output of
+ // java jdk.internal.org.objectweb.asm.util.ASMifier Sub2G.class
+ static byte[] generateSub2GTestClass() {
+ ClassWriter cw = new ClassWriter(0);
+ MethodVisitor mv;
+
+ cw.visit(50, ACC_SUPER, "Sub2G", null, "G", null);
+
+ {
+ mv = cw.visitMethod(0, "<init>", "()V", null, null);
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, "G", "<init>", "()V", false);
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "m2", "(Ljava/lang/String;)Ljava/lang/String;", null, null);
+ mv.visitCode();
+ mv.visitInsn(ACONST_NULL); // Will cause NPE.
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitMethodInsn(INVOKESPECIAL, "G", "m2", "(Ljava/lang/String;)Ljava/lang/String;", false);
+ mv.visitInsn(ICONST_2);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(I)Ljava/lang/String;", false);
+ mv.visitInsn(ARETURN);
+ mv.visitMaxs(2, 2);
+ mv.visitEnd();
+ }
+
+ cw.visitEnd();
+
+ return cw.toByteArray();
+ }
+}
+class SubG extends G {
+ public String m2(String x) {
+ return super.m2(x).substring(2);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/NullPointerException/SuppressMessagesTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019 SAP SE. 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Test that the default of flag ShowCodeDetailsInExceptionMessages is 'false',
+ * i.e., make sure the VM does not print the message on default.
+ * @bug 8218628
+ * @library /test/lib
+ * @compile -g SuppressMessagesTest.java
+ * @run main/othervm SuppressMessagesTest noMessage
+ */
+/**
+ * @test
+ * @summary Test that the messages are suppressed if flag ShowCodeDetailsInExceptionMessages is 'false'.
+ * @bug 8218628
+ * @library /test/lib
+ * @compile -g SuppressMessagesTest.java
+ * @run main/othervm -XX:-ShowCodeDetailsInExceptionMessages SuppressMessagesTest noMessage
+ */
+/**
+ * @test
+ * @summary Test that the messages are printed if flag ShowCodeDetailsInExceptionMessages is 'true'.
+ * @bug 8218628
+ * @library /test/lib
+ * @compile -g SuppressMessagesTest.java
+ * @run main/othervm -XX:+ShowCodeDetailsInExceptionMessages SuppressMessagesTest printMessage
+ */
+
+import jdk.test.lib.Asserts;
+
+class A {
+ int aFld;
+}
+
+// Tests that the messages are suppressed by flag ShowCodeDetailsInExceptionMessages.
+public class SuppressMessagesTest {
+
+ public static void main(String[] args) throws Exception {
+ A a = null;
+
+ if (args.length != 1) {
+ Asserts.fail("You must specify one arg for this test");
+ }
+
+ try {
+ @SuppressWarnings("null")
+ int val = a.aFld;
+ System.out.println(val);
+ Asserts.fail();
+ } catch (NullPointerException e) {
+ System.out.println("Stacktrace of the expected exception:");
+ e.printStackTrace(System.out);
+ if (args[0].equals("noMessage")) {
+ Asserts.assertNull(e.getMessage());
+ } else {
+ Asserts.assertEquals(e.getMessage(), "Cannot read field \"aFld\" because \"a\" is null");
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/signal/TestSiginfo.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+
+/*
+ * @test
+ * @requires os.family != "windows" & os.family != "aix"
+ *
+ * @summary tests the SIGINFO signal (available on BSD platforms)
+ * VM testbase keywords: [signal, runtime, linux, solaris, macosx]
+ *
+ * @library /test/lib
+ * @run main/native SigTestDriver SIGINFO
+ */
+
--- a/test/hotspot/jtreg/serviceability/dcmd/gc/RunGCTest.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/serviceability/dcmd/gc/RunGCTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -36,13 +36,12 @@
/*
* @test
* @summary Test of diagnostic command GC.run
- * @requires vm.gc != "Z"
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.compiler
* java.management
* jdk.internal.jvmstat/sun.jvmstat.monitor
- * @run testng/othervm -Xlog:gc=debug:RunGC.gclog -XX:-ExplicitGCInvokesConcurrent RunGCTest
+ * @run testng/othervm -Xlog:gc:RunGC.gclog -XX:-ExplicitGCInvokesConcurrent RunGCTest
*/
public class RunGCTest {
public void run(CommandExecutor executor) {
@@ -58,7 +57,7 @@
}
OutputAnalyzer output = new OutputAnalyzer(gcLog, "");
- output.shouldContain("Pause Full (Diagnostic Command)");
+ output.shouldContain("(Diagnostic Command)");
}
@Test
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineObject.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8232613
+ * @summary Ensure Object natives stay registered after redefinition
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.org.objectweb.asm
+ * java.compiler
+ * java.instrument
+ * jdk.jartool/sun.tools.jar
+ * @run main RedefineObject buildagent
+ * @run main/othervm -javaagent:redefineagent.jar RedefineObject
+ */
+
+import static jdk.test.lib.Asserts.assertTrue;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.lang.RuntimeException;
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
+import java.lang.instrument.Instrumentation;
+import java.lang.instrument.UnmodifiableClassException;
+import java.security.ProtectionDomain;
+import java.util.Arrays;
+
+import jdk.internal.org.objectweb.asm.ClassReader;
+import jdk.internal.org.objectweb.asm.ClassVisitor;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+
+import static jdk.internal.org.objectweb.asm.Opcodes.ASM6;
+import static jdk.internal.org.objectweb.asm.Opcodes.V1_8;
+
+public class RedefineObject {
+
+ static Instrumentation inst;
+
+ public static void premain(String agentArgs, Instrumentation inst) {
+ RedefineObject.inst = inst;
+ }
+
+ static class Transformer implements ClassFileTransformer {
+
+ public byte[] asm(ClassLoader loader, String className,
+ Class<?> classBeingRedefined,
+ ProtectionDomain protectionDomain, byte[] classfileBuffer)
+ throws IllegalClassFormatException {
+ ClassWriter cw = new ClassWriter(0);
+ // Force an older ASM to force a bytecode update
+ ClassVisitor cv = new DummyClassVisitor(ASM6, cw) { };
+ ClassReader cr = new ClassReader(classfileBuffer);
+ cr.accept(cv, 0);
+ byte[] bytes = cw.toByteArray();
+ return bytes;
+ }
+
+ public class DummyClassVisitor extends ClassVisitor {
+
+ public DummyClassVisitor(int api, ClassVisitor cv) {
+ super(api, cv);
+ }
+
+ public void visit(
+ final int version,
+ final int access,
+ final String name,
+ final String signature,
+ final String superName,
+ final String[] interfaces) {
+ // Artificially lower to JDK 8 version to force a redefine
+ cv.visit(V1_8, access, name, signature, superName, interfaces);
+ }
+ }
+
+ @Override public byte[] transform(ClassLoader loader, String className,
+ Class<?> classBeingRedefined,
+ ProtectionDomain protectionDomain, byte[] classfileBuffer)
+ throws IllegalClassFormatException {
+
+ if (className.contains("java/lang/Object")) {
+ try {
+ // Here we remove and re-add the dummy fields. This shuffles the constant pool
+ return asm(loader, className, classBeingRedefined, protectionDomain, classfileBuffer);
+ } catch (Throwable e) {
+ // The retransform native code that called this method does not propagate
+ // exceptions. Instead of getting an uninformative generic error, catch
+ // problems here and print it, then exit.
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+ return null;
+ }
+ }
+
+ private static void buildAgent() {
+ try {
+ ClassFileInstaller.main("RedefineObject");
+ } catch (Exception e) {
+ throw new RuntimeException("Could not write agent classfile", e);
+ }
+
+ try {
+ PrintWriter pw = new PrintWriter("MANIFEST.MF");
+ pw.println("Premain-Class: RedefineObject");
+ pw.println("Agent-Class: RedefineObject");
+ pw.println("Can-Retransform-Classes: true");
+ pw.close();
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("Could not write manifest file for the agent", e);
+ }
+
+ sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
+ if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineObject.class" })) {
+ throw new RuntimeException("Could not write the agent jar file");
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ int objHash = System.identityHashCode(Object.class);
+ System.out.println("Object hashCode: " + objHash);
+ if (args.length == 1 && args[0].equals("buildagent")) {
+ buildAgent();
+ return;
+ }
+
+ if (inst == null) {
+ throw new RuntimeException("Instrumentation object was null");
+ }
+
+ try {
+ inst.addTransformer(new RedefineObject.Transformer(), true);
+ inst.retransformClasses(Object.class);
+ } catch (UnmodifiableClassException e) {
+ throw new RuntimeException(e);
+ }
+
+ // Exercise native methods on Object after transform
+ Object b = new Object();
+ b.hashCode();
+
+ C c = new C();
+ assertTrue(c.hashCode() != c.clone().hashCode() || c != c.clone());
+ assertTrue(c.clone() instanceof C);
+ c = (C)c.clone(); // native method on new Object
+ }
+
+ private static class C implements Cloneable {
+ @Override
+ protected Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+ }
+}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/TestDescription.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/TestDescription.java Mon Oct 28 18:43:04 2019 +0100
@@ -42,8 +42,6 @@
* @library /vmTestbase
* /test/lib
* @requires os.family != "aix"
- * @comment Test is incompatible with ZGC, due to ZGC's address space requirements.
- * @requires vm.gc != "Z"
* @run driver jdk.test.lib.FileInstaller . .
* @build nsk.jvmti.Allocate.alloc001
* @run shell alloc001.sh
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/newclass02/java.base/java/lang/Object.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/newclass02/java.base/java/lang/Object.java Mon Oct 28 18:43:04 2019 +0100
@@ -37,11 +37,6 @@
*/
public class Object {
- private static native void registerNatives();
- static {
- registerNatives();
- }
-
/**
* Returns the runtime class of an object. That <tt>Class</tt>
* object is the object that is locked by <tt>static synchronized</tt>
--- a/test/hotspot/jtreg/vmTestbase/vm/mlvm/meth/stress/compiler/deoptimize/Test.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/hotspot/jtreg/vmTestbase/vm/mlvm/meth/stress/compiler/deoptimize/Test.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2019, 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
@@ -24,6 +24,7 @@
/*
* @test
+ * @key stress
*
* @summary converted from VM Testbase vm/mlvm/meth/stress/compiler/deoptimize.
* VM Testbase keywords: [feature_mlvm, nonconcurrent, quarantine]
@@ -42,6 +43,8 @@
* @build vm.mlvm.meth.stress.compiler.deoptimize.Test
* @run driver vm.mlvm.share.IndifiedClassesBuilder
*
+ * @requires vm.debug != true
+ *
* @run main/othervm
* -XX:ReservedCodeCacheSize=100m
* vm.mlvm.meth.stress.compiler.deoptimize.Test
@@ -49,6 +52,29 @@
* -threadsExtra 2
*/
+
+/*
+ * @test
+ * @key stress
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ *
+ * @comment build test class and indify classes
+ * @build vm.mlvm.meth.stress.compiler.deoptimize.Test
+ * @run driver vm.mlvm.share.IndifiedClassesBuilder
+ *
+ * @requires vm.debug == true
+ *
+ * @run main/othervm
+ * -XX:ReservedCodeCacheSize=100m
+ * vm.mlvm.meth.stress.compiler.deoptimize.Test
+ * -threadsPerCpu 2
+ * -threadsExtra 2
+ */
+
+
package vm.mlvm.meth.stress.compiler.deoptimize;
import java.lang.invoke.MethodHandle;
--- a/test/jdk/ProblemList-Xcomp.txt Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/ProblemList-Xcomp.txt Mon Oct 28 18:43:04 2019 +0100
@@ -29,3 +29,4 @@
java/lang/invoke/MethodHandles/CatchExceptionTest.java 8146623 generic-all
java/util/stream/test/org/openjdk/tests/java/util/stream/StreamLinkTest.java 8216317 solaris-all
+java/math/BigInteger/largeMemory/SymmetricRangeTests.java 8232840 generic-all
--- a/test/jdk/ProblemList.txt Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/ProblemList.txt Mon Oct 28 18:43:04 2019 +0100
@@ -889,6 +889,4 @@
# jdk_internal
-jdk/internal/platform/docker/TestDockerMemoryMetrics.java 8227317 linux-x64
-
############################################################################
--- a/test/jdk/TEST.ROOT Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/TEST.ROOT Mon Oct 28 18:43:04 2019 +0100
@@ -22,7 +22,8 @@
javax/management sun/awt sun/java2d javax/xml/jaxp/testng/validation java/lang/ProcessHandle
# Tests that cannot run concurrently
-exclusiveAccess.dirs=java/rmi/Naming java/util/prefs sun/management/jmxremote \
+exclusiveAccess.dirs=java/math/BigInteger/largeMemory \
+java/rmi/Naming java/util/prefs sun/management/jmxremote \
sun/tools/jstatd sun/tools/jcmd sun/tools/jhsdb sun/tools/jhsdb/heapconfig \
sun/tools/jinfo sun/tools/jmap sun/tools/jps sun/tools/jstack sun/tools/jstat \
com/sun/tools/attach sun/security/mscapi java/util/stream java/util/Arrays/largeMemory \
--- a/test/jdk/com/sun/jdi/MonitorEventTest.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/com/sun/jdi/MonitorEventTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -31,15 +31,22 @@
* @run compile -g MonitorEventTest.java
* @run driver MonitorEventTest
*/
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-import com.sun.jdi.request.*;
-
-import java.util.*;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.event.BreakpointEvent;
+import com.sun.jdi.event.MonitorContendedEnterEvent;
+import com.sun.jdi.event.MonitorContendedEnteredEvent;
+import com.sun.jdi.event.MonitorWaitEvent;
+import com.sun.jdi.event.MonitorWaitedEvent;
+import com.sun.jdi.request.EventRequest;
+import com.sun.jdi.request.MonitorContendedEnterRequest;
+import com.sun.jdi.request.MonitorContendedEnteredRequest;
+import com.sun.jdi.request.MonitorWaitRequest;
+import com.sun.jdi.request.MonitorWaitedRequest;
/********** target program **********/
-class MonitorTestTarg {
+class MonitorEventTestTarg {
public static Object endingMonitor;
public static Object startingMonitor;
public static final long timeout = 30 * 6000; // milliseconds
@@ -91,13 +98,13 @@
class myThread extends Thread {
public void run() {
- synchronized(MonitorTestTarg.startingMonitor) {
- MonitorTestTarg.startingMonitor.notify();
+ synchronized(MonitorEventTestTarg.startingMonitor) {
+ MonitorEventTestTarg.startingMonitor.notify();
}
// contended enter wait until main thread release monitor
- MonitorTestTarg.aboutEnterLock = true;
- synchronized (MonitorTestTarg.endingMonitor) {
+ MonitorEventTestTarg.aboutEnterLock = true;
+ synchronized (MonitorEventTestTarg.endingMonitor) {
}
}
}
@@ -108,7 +115,6 @@
public class MonitorEventTest extends TestScaffold {
ReferenceType targetClass;
ThreadReference mainThread;
- List monitors;
MonitorContendedEnterRequest contendedEnterRequest;
MonitorWaitedRequest monitorWaitedRequest;
MonitorContendedEnteredRequest contendedEnteredRequest;
@@ -160,11 +166,10 @@
* Get to the top of main()
* to determine targetClass and mainThread
*/
- BreakpointEvent bpe = startToMain("MonitorTestTarg");
+ BreakpointEvent bpe = startToMain("MonitorEventTestTarg");
targetClass = bpe.location().declaringType();
mainThread = bpe.thread();
- int initialSize = mainThread.frames().size();
if (vm().canRequestMonitorEvents()) {
contendedEnterRequest = eventRequestManager().createMonitorContendedEnterRequest();
contendedEnterRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
@@ -183,7 +188,7 @@
}
- resumeTo("MonitorTestTarg", "foo", "()V");
+ resumeTo("MonitorEventTestTarg", "foo", "()V");
/*
* resume until end
--- a/test/jdk/com/sun/jdi/MonitorFrameInfo.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/com/sun/jdi/MonitorFrameInfo.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -33,15 +33,17 @@
* @run compile -g MonitorFrameInfo.java
* @run driver MonitorFrameInfo
*/
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-import com.sun.jdi.request.*;
+import java.util.List;
-import java.util.*;
+import com.sun.jdi.InvalidStackFrameException;
+import com.sun.jdi.MonitorInfo;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.event.BreakpointEvent;
/********** target program **********/
-class MonitorTestTarg {
+class MonitorFrameInfoTarg {
static void foo3() {
System.out.println("executing foo3");
@@ -71,7 +73,7 @@
public class MonitorFrameInfo extends TestScaffold {
ReferenceType targetClass;
ThreadReference mainThread;
- List monitors;
+ List<MonitorInfo> monitors;
static int expectedCount = 2;
static int[] expectedDepth = { 1, 3 };
@@ -93,13 +95,13 @@
* Get to the top of main()
* to determine targetClass and mainThread
*/
- BreakpointEvent bpe = startToMain("MonitorTestTarg");
+ BreakpointEvent bpe = startToMain("MonitorFrameInfoTarg");
targetClass = bpe.location().declaringType();
mainThread = bpe.thread();
int initialSize = mainThread.frames().size();
- resumeTo("MonitorTestTarg", "foo3", "()V");
+ resumeTo("MonitorFrameInfoTarg", "foo3", "()V");
if (!mainThread.frame(0).location().method().name()
.equals("foo3")) {
--- a/test/jdk/com/sun/jdi/RedefineImplementor.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/com/sun/jdi/RedefineImplementor.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2019, 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
@@ -44,14 +44,14 @@
}
public static void main(String[] args) {
- Runnable r = new B();
- B.func(r);
- B.func(r); // @1 breakpoint
+ Runnable r = new RedefineImplementorB();
+ RedefineImplementorB.func(r);
+ RedefineImplementorB.func(r); // @1 breakpoint
}
}
-class B extends RedefineImplementorTarg {
+class RedefineImplementorB extends RedefineImplementorTarg {
static void func(Runnable r) {
r.run();
}
--- a/test/jdk/java/io/FilePermission/SpecTests.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/java/io/FilePermission/SpecTests.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -22,11 +22,10 @@
*/
/**
- *
* @test
- * @bug 4955804
- * @summary Tests for FilePermission constructor spec for null
- * and empty String parameters
+ * @bug 4955804 8230407
+ * @summary Tests for FilePermission constructor spec for null,
+ * empty and misformated String parameters
*/
import java.io.*;
@@ -37,10 +36,11 @@
String ILE = "java.lang.IllegalArgumentException";
String NPE = "java.lang.NullPointerException";
- String names[] = {"", null, "foo", "foo", "foo", "foo"};
+ String names[] = {"", null, "foo", "foo", "foo", "foo", "foo"};
String actions[] = {"read", "read", "", null, "junk",
- "read,write,execute,delete,rename"};
- String exps[] = { null, NPE, ILE, ILE, ILE, ILE };
+ "read,write,execute,delete,rename",
+ ",read"};
+ String exps[] = { null, NPE, ILE, ILE, ILE, ILE, ILE };
FilePermission permit;
for (int i = 0; i < names.length; i++) {
@@ -54,15 +54,19 @@
" for name:" + names[i] +
" actions:" + actions[i]);
} else {
- System.out.println(names[i] + ", [" + actions[i] + "] " +
- "resulted in " + exps[i] + " as Expected");
+ System.out.println(names[i] + ", [" + actions[i] + "] " +
+ "resulted in " + exps[i] + " as Expected");
+ continue;
}
- }
- if (exps[i] == null) {
+ }
+ if (exps[i] == null) {
System.out.println(names[i] + ", [" + actions[i] + "] " +
- "resulted in No Exception as Expected");
+ "resulted in No Exception as Expected");
+ } else {
+ throw new Exception("Expecting: " + exps[i] +
+ " for name:" + names[i] +
+ " actions:" + actions[i]);
}
}
-
}
}
--- a/test/jdk/java/lang/String/Formatted.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/java/lang/String/Formatted.java Mon Oct 28 18:43:04 2019 +0100
@@ -25,7 +25,8 @@
* @test
* bug 8203444
* @summary Unit tests for instance versions of String#format
- * @run main Formatted
+ * @compile --enable-preview -source 14 Formatted.java
+ * @run main/othervm --enable-preview Formatted
*/
import java.util.Locale;
--- a/test/jdk/java/lang/String/StripIndent.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/java/lang/String/StripIndent.java Mon Oct 28 18:43:04 2019 +0100
@@ -25,7 +25,8 @@
* @test
* @bug 8223775
* @summary This exercises String#stripIndent patterns and limits.
- * @run main StripIndent
+ * @compile --enable-preview -source 14 StripIndent.java
+ * @run main/othervm --enable-preview StripIndent
*/
public class StripIndent {
--- a/test/jdk/java/lang/String/TranslateEscapes.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/java/lang/String/TranslateEscapes.java Mon Oct 28 18:43:04 2019 +0100
@@ -25,7 +25,8 @@
* @test
* @bug 8223780
* @summary This exercises String#translateEscapes patterns and limits.
- * @run main TranslateEscapes
+ * @compile --enable-preview -source 14 TranslateEscapes.java
+ * @run main/othervm --enable-preview TranslateEscapes
*/
public class TranslateEscapes {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/ThreadLocal/ReplaceStaleEntry.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8209824
+ * @summary per latest JDK code coverage report, 2 methods replaceStaleEntry
+ * and prevIndex in ThreadLocal.ThreadLocalMap are not touched
+ * by any JDK regression tests, this is to trigger the code paths.
+ * @modules java.base/java.lang:+open
+ * @run testng ReplaceStaleEntry
+ */
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ReplaceStaleEntry {
+
+ public static int INITIAL_CAPACITY;
+
+ @BeforeClass
+ public static void setup() throws Exception {
+ Class<?> clazz = Class.forName("java.lang.ThreadLocal$ThreadLocalMap");
+ Field f = clazz.getDeclaredField("INITIAL_CAPACITY");
+ f.setAccessible(true);
+ INITIAL_CAPACITY = f.getInt(null);
+ System.out.println("INITIAL_CAPACITY: " + INITIAL_CAPACITY);
+ }
+
+ /**
+ * This test triggers the code path to replaceStaleEntry, so as prevIndex is
+ * triggered too as it's called by replaceStaleEntry.
+ * The code paths must be triggered by reusing an already used entry in the
+ * map's entry table. The code below
+ * 1. first occupies the entries
+ * 2. then expunges the entries by removing strong references to thread locals
+ * 3. then reuse some of entries by adding more thread locals to the thread
+ * and, the above steps are run for several times by adding more and more
+ * thread locals, also trigger rehash of the map.
+ */
+ @Test
+ public static void test() {
+ Map<Integer, ThreadLocal> locals = new HashMap<>();
+ for (int j = 1; j < 32; j *= 2) {
+ int loop = INITIAL_CAPACITY * j;
+ for (int i = 0; i < loop; i++) {
+ ThreadLocal l = new ThreadLocal<Integer>();
+ l.set(i);
+ locals.put(i, l);
+ }
+ locals.keySet().stream().forEach(i -> {
+ assertEquals((int)locals.get(i).get(), (int)i, "Unexpected thread local value!");
+ });
+ locals.clear();
+ System.gc();
+ }
+ }
+}
--- a/test/jdk/java/math/BigInteger/DivisionOverflow.java Sat Oct 26 23:59:51 2019 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2011, 2013, 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.
- *
- * 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.
- */
-
-/*
- * @test
- * @bug 8022780
- * @summary Test division of large values
- * @run main/othervm -Xshare:off DivisionOverflow
- * @author Dmitry Nadezhin
- */
-import java.math.BigInteger;
-
-public class DivisionOverflow {
-
- public static void main(String[] args) {
- try {
- BigInteger a = BigInteger.ONE.shiftLeft(2147483646);
- BigInteger b = BigInteger.ONE.shiftLeft(1568);
- BigInteger[] qr = a.divideAndRemainder(b);
- BigInteger q = qr[0];
- BigInteger r = qr[1];
- if (!r.equals(BigInteger.ZERO)) {
- throw new RuntimeException("Incorrect signum() of remainder " + r.signum());
- }
- if (q.bitLength() != 2147482079) {
- throw new RuntimeException("Incorrect bitLength() of quotient " + q.bitLength());
- }
- System.out.println("Division of large values passed without overflow.");
- } catch (OutOfMemoryError e) {
- // possible
- System.err.println("DivisionOverflow skipped: OutOfMemoryError");
- System.err.println("Run jtreg with -javaoption:-Xmx8g");
- }
- }
-}
--- a/test/jdk/java/math/BigInteger/StringConstructorOverflow.java Sat Oct 26 23:59:51 2019 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2013, 2019, 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.
- *
- * 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.
- */
-
-/*
- * @test
- * @bug 8021204
- * @summary Test constructor BigInteger(String val, int radix) on very long string
- * @ignore This test has huge memory requirements
- * @run main/othervm -Xshare:off -Xmx8g StringConstructorOverflow
- * @author Dmitry Nadezhin
- */
-import java.math.BigInteger;
-
-public class StringConstructorOverflow {
-
- // String with hexadecimal value pow(2,pow(2,34))+1
- private static String makeLongHexString() {
- StringBuilder sb = new StringBuilder();
- sb.append('1');
- for (int i = 0; i < (1 << 30) - 1; i++) {
- sb.append('0');
- }
- sb.append('1');
- return sb.toString();
- }
-
- public static void main(String[] args) {
- try {
- BigInteger bi = new BigInteger(makeLongHexString(), 16);
- if (bi.compareTo(BigInteger.ONE) <= 0) {
- throw new RuntimeException("Incorrect result " + bi.toString());
- }
- } catch (ArithmeticException e) {
- // expected
- System.out.println("Overflow is reported by ArithmeticException, as expected");
- } catch (OutOfMemoryError e) {
- // possible
- System.err.println("StringConstructorOverflow skipped: OutOfMemoryError");
- System.err.println("Run jtreg with -javaoption:-Xmx8g");
- }
- }
-}
--- a/test/jdk/java/math/BigInteger/SymmetricRangeTests.java Sat Oct 26 23:59:51 2019 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,665 +0,0 @@
-/*
- * Copyright (c) 2013, 2019, 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.
- *
- * 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.
- */
-
-/*
- * @test
- * @library /test/lib
- * @ignore This test has huge memory requirements
- * @run main/timeout=180/othervm -Xmx8g SymmetricRangeTests
- * @bug 6910473 8021204 8021203 9005933 8074460 8078672
- * @summary Test range of BigInteger values (use -Dseed=X to set PRNG seed)
- * @author Dmitry Nadezhin
- * @key randomness
- */
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Arrays;
-import java.math.BigInteger;
-import java.util.Random;
-import jdk.test.lib.RandomFactory;
-
-public class SymmetricRangeTests {
-
- private static final BigInteger MAX_VALUE = makeMaxValue();
- private static final BigInteger MIN_VALUE = MAX_VALUE.negate();
-
- private static BigInteger makeMaxValue() {
- byte[] ba = new byte[1 << 28];
- Arrays.fill(ba, (byte) 0xFF);
- ba[0] = (byte) 0x7F;
- return new BigInteger(ba);
- }
-
- private static void check(String msg, BigInteger actual, BigInteger expected) {
- if (!actual.equals(expected)) {
- throw new RuntimeException(msg + ".bitLength()=" + actual.bitLength());
- }
- }
-
- private static void check(String msg, double actual, double expected) {
- if (actual != expected) {
- throw new RuntimeException(msg + "=" + actual);
- }
- }
-
- private static void check(String msg, float actual, float expected) {
- if (actual != expected) {
- throw new RuntimeException(msg + "=" + actual);
- }
- }
-
- private static void check(String msg, long actual, long expected) {
- if (actual != expected) {
- throw new RuntimeException(msg + "=" + actual);
- }
- }
-
- private static void check(String msg, int actual, int expected) {
- if (actual != expected) {
- throw new RuntimeException(msg + "=" + actual);
- }
- }
-
- private static void testOverflowInMakePositive() {
- System.out.println("Testing overflow in BigInteger.makePositive");
- byte[] ba = new byte[Integer.MAX_VALUE - 2];
- ba[0] = (byte) 0x80;
- try {
- BigInteger actual = new BigInteger(ba);
- throw new RuntimeException("new BigInteger(ba).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testBug8021204() {
- System.out.println("Testing Bug 8021204");
- StringBuilder sb = new StringBuilder();
- sb.append('1');
- for (int i = 0; i < (1 << 30) - 1; i++) {
- sb.append('0');
- }
- sb.append('1');
- String s = sb.toString();
- sb = null;
- try {
- BigInteger actual = new BigInteger(s, 16);
- throw new RuntimeException("new BigInteger(\"1000...001\").bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testOverflowInBitSieve() {
- System.out.println("Testing overflow in BitSieve.sieveSingle");
- int bitLength = (5 << 27) - 1;
- try {
- Random random = RandomFactory.getRandom();
- BigInteger actual = new BigInteger(bitLength, 0, random);
- throw new RuntimeException("new BigInteger(bitLength, 0, null).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- try {
- BigInteger bi = BigInteger.ONE.shiftLeft(bitLength - 1).subtract(BigInteger.ONE);
- BigInteger actual = bi.nextProbablePrime();
- throw new RuntimeException("bi.nextActualPrime().bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testAdd() {
- System.out.println("Testing BigInteger.add");
- try {
- BigInteger actual = MAX_VALUE.add(BigInteger.ONE);
- throw new RuntimeException("BigInteger.MAX_VALUE.add(BigInteger.ONE).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testSubtract() {
- System.out.println("Testing BigInteger.subtract");
- try {
- BigInteger actual = MIN_VALUE.subtract(BigInteger.ONE);
- throw new RuntimeException("BigInteger.MIN_VALUE.subtract(BigInteger.ONE).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testMultiply() {
- System.out.println("Testing BigInteger.multiply");
- int py = 2000;
- int px = Integer.MAX_VALUE - py;
- BigInteger x = BigInteger.ONE.shiftLeft(px);
- BigInteger y = BigInteger.ONE.shiftLeft(py);
- try {
- BigInteger actual = x.multiply(y);
- throw new RuntimeException("(1 << " + px + " ) * (1 << " + py + ").bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testDivide() {
- System.out.println("Testing BigInteger.divide");
- check("BigInteger.MIN_VALUE.divide(BigInteger.valueOf(-1))",
- MIN_VALUE.divide(BigInteger.valueOf(-1)), MAX_VALUE);
- check("BigInteger.MIN_VALUE.divide(BigInteger.ONE)",
- MIN_VALUE.divide(BigInteger.ONE), MIN_VALUE);
- }
-
- private static void testDivideAndRemainder(String msg, BigInteger dividend, BigInteger divisor,
- BigInteger expectedQuotent, BigInteger expectedRemainder) {
- BigInteger[] qr = dividend.divideAndRemainder(divisor);
- check(msg + "[0]", qr[0], expectedQuotent);
- check(msg + "[1]", qr[1], expectedRemainder);
- }
-
- private static void testDivideAndRemainder() {
- System.out.println("Testing BigInteger.divideAndRemainder");
- testDivideAndRemainder("BigInteger.MIN_VALUE.divideAndRemainder(BigInteger.valueOf(-1))",
- MIN_VALUE, BigInteger.valueOf(-1),
- MAX_VALUE,
- BigInteger.ZERO);
- }
-
- private static void testBug9005933() {
- System.out.println("Testing Bug 9005933");
- int dividendPow = 2147483646;
- int divisorPow = 1568;
- BigInteger dividend = BigInteger.ONE.shiftLeft(dividendPow);
- BigInteger divisor = BigInteger.ONE.shiftLeft(divisorPow);
- testDivideAndRemainder("(1 << " + dividendPow + ").divideAndRemainder(1 << " + divisorPow + ")",
- dividend, divisor,
- BigInteger.ONE.shiftLeft(dividendPow - divisorPow),
- BigInteger.ZERO);
- }
-
- private static void testRemainder() {
- System.out.println("Testing BigInteger.remainder");
- check("BigInteger.MIN_VALUE.remainder(BigInteger.valueOf(-1))",
- MIN_VALUE.remainder(BigInteger.valueOf(-1)), BigInteger.ZERO);
- }
-
- private static void testPow() {
- System.out.println("Testing BigInteger.pow");
- check("BigInteger.MIN_VALUE.pow(1)",
- MIN_VALUE.pow(1), MIN_VALUE);
- try {
- BigInteger actual = BigInteger.valueOf(4).pow(Integer.MAX_VALUE);
- throw new RuntimeException("BigInteger.valueOf(4).pow(Integer.MAX_VALUE).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testGcd() {
- System.out.println("Testing BigInteger.gcd");
- check("BigInteger.MIN_VALUE.gcd(BigInteger.MIN_VALUE)",
- MIN_VALUE.gcd(MIN_VALUE), MAX_VALUE);
- check("BigInteger.MIN_VALUE.gcd(BigInteger.ZERO)",
- MIN_VALUE.gcd(BigInteger.ZERO), MAX_VALUE);
- check("BigInteger.ZERO.gcd(MIN_VALUE)",
- BigInteger.ZERO.gcd(MIN_VALUE), MAX_VALUE);
- }
-
- private static void testAbs() {
- System.out.println("Testing BigInteger.abs");
- check("BigInteger.MIN_VALUE.abs()",
- MIN_VALUE.abs(), MAX_VALUE);
- check("BigInteger.MAX_VALUE.abs()",
- MAX_VALUE.abs(), MAX_VALUE);
- }
-
- private static void testNegate() {
- System.out.println("Testing BigInteger.negate");
- check("BigInteger.MIN_VALUE.negate()",
- MIN_VALUE.negate(), MAX_VALUE);
- check("BigInteger.MAX_VALUE.negate()",
- MAX_VALUE.negate(), MIN_VALUE);
- }
-
- private static void testMod() {
- System.out.println("Testing BigInteger.mod");
- check("BigInteger.MIN_VALUE.mod(BigInteger.MAX_VALUE)",
- MIN_VALUE.mod(MAX_VALUE), BigInteger.ZERO);
- check("BigInteger.MAX_VALUE.mod(BigInteger.MAX_VALUE)",
- MIN_VALUE.mod(MAX_VALUE), BigInteger.ZERO);
- }
-
- private static void testModPow() {
- System.out.println("Testing BigInteger.modPow");
- BigInteger x = BigInteger.valueOf(3);
- BigInteger m = BigInteger.valueOf(-4).subtract(MIN_VALUE);
- check("BigInteger.valueOf(3).modPow(BigInteger.ONE, m)",
- x.modPow(BigInteger.ONE, m), x);
- }
-
- // slow test
- private static void testModInverse() {
- System.out.println("Testing BigInteger.modInverse");
- check("BigInteger.MIN_VALUE.modInverse(BigInteger.MAX_VALUE)",
- MIN_VALUE.modInverse(MAX_VALUE), MAX_VALUE.subtract(BigInteger.ONE));
- }
-
- private static void testShiftLeft() {
- System.out.println("Testing BigInteger.shiftLeft");
- try {
- BigInteger actual = MIN_VALUE.shiftLeft(1);
- throw new RuntimeException("BigInteger.MIN_VALUE.shiftLeft(1).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- try {
- BigInteger actual = MAX_VALUE.shiftLeft(1);
- throw new RuntimeException("BigInteger.MAX_VALUE.shiftLeft(1).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testShiftRight() {
- System.out.println("Testing BigInteger.shiftRight");
- try {
- BigInteger actual = MIN_VALUE.shiftRight(-1);
- throw new RuntimeException("BigInteger.MIN_VALUE.shiftRight(-1).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- try {
- BigInteger actual = MAX_VALUE.shiftRight(-1);
- throw new RuntimeException("BigInteger.MAX_VALUE.shiftRight(-1).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testAnd() {
- System.out.println("Testing BigInteger.and");
- check("BigInteger.MIN_VALUE.and(BigInteger.MIN_VALUE)",
- MIN_VALUE.and(MIN_VALUE), MIN_VALUE);
- check("BigInteger.MAX_VALUE.and(BigInteger.MAX_VALUE)",
- MAX_VALUE.and(MAX_VALUE), MAX_VALUE);
- check("BigInteger.MIN_VALUE.and(BigInteger.MAX_VALUE)",
- MIN_VALUE.and(MAX_VALUE), BigInteger.ONE);
- try {
- BigInteger actual = MIN_VALUE.and(BigInteger.valueOf(-2));
- throw new RuntimeException("BigInteger.MIN_VALUE.and(-2)).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testOr() {
- System.out.println("Testing BigInteger.or");
- check("BigInteger.MIN_VALUE.or(BigInteger.MIN_VALUE)",
- MIN_VALUE.or(MIN_VALUE), MIN_VALUE);
- check("BigInteger.MAX_VALUE.or(BigInteger.MAX_VALUE)",
- MAX_VALUE.or(MAX_VALUE), MAX_VALUE);
- check("BigInteger.MIN_VALUE.and(BigInteger.MAX_VALUE)",
- MIN_VALUE.or(MAX_VALUE), BigInteger.valueOf(-1));
- }
-
- private static void testXor() {
- System.out.println("Testing BigInteger.xor");
- check("BigInteger.MIN_VALUE.xor(BigInteger.MIN_VALUE)",
- MIN_VALUE.xor(MIN_VALUE), BigInteger.ZERO);
- check("BigInteger.MAX_VALUE.xor(BigInteger.MAX_VALUE)",
- MAX_VALUE.xor(MAX_VALUE), BigInteger.ZERO);
- check("BigInteger.MIN_VALUE.xor(BigInteger.MAX_VALUE)",
- MIN_VALUE.xor(MAX_VALUE), BigInteger.valueOf(-2));
- try {
- BigInteger actual = MIN_VALUE.xor(BigInteger.ONE);
- throw new RuntimeException("BigInteger.MIN_VALUE.xor(BigInteger.ONE)).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testNot() {
- System.out.println("Testing BigInteger.not");
- check("BigInteger.MIN_VALUE.not()",
- MIN_VALUE.not(), MAX_VALUE.subtract(BigInteger.ONE));
- try {
- BigInteger actual = MAX_VALUE.not();
- throw new RuntimeException("BigInteger.MAX_VALUE.not()).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testSetBit() {
- System.out.println("Testing BigInteger.setBit");
- check("BigInteger.MIN_VALUE.setBit(" + Integer.MAX_VALUE + ")",
- MIN_VALUE.setBit(Integer.MAX_VALUE), MIN_VALUE);
- try {
- BigInteger actual = MAX_VALUE.setBit(Integer.MAX_VALUE);
- throw new RuntimeException("BigInteger.MAX_VALUE.setBit(" + Integer.MAX_VALUE + ").bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testClearBit() {
- System.out.println("Testing BigInteger.clearBit");
- check("BigInteger.MAX_VALUE.clearBit(" + Integer.MAX_VALUE + ")",
- MAX_VALUE.clearBit(Integer.MAX_VALUE), MAX_VALUE);
- try {
- BigInteger actual = MIN_VALUE.clearBit(Integer.MAX_VALUE);
- throw new RuntimeException("BigInteger.MIN_VALUE.clearBit(" + Integer.MAX_VALUE + ").bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- try {
- BigInteger actual = MIN_VALUE.clearBit(0);
- throw new RuntimeException("BigInteger.MIN_VALUE.clearBit(0).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testFlipBit() {
- System.out.println("Testing BigInteger.flipBit");
- try {
- BigInteger actual = MIN_VALUE.flipBit(Integer.MAX_VALUE);
- throw new RuntimeException("BigInteger.MIN_VALUE.flipBit(" + Integer.MAX_VALUE + ").bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- try {
- BigInteger actual = MIN_VALUE.flipBit(0);
- throw new RuntimeException("BigInteger.MIN_VALUE.flipBit(0).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- try {
- BigInteger actual = MAX_VALUE.flipBit(Integer.MAX_VALUE);
- throw new RuntimeException("BigInteger.MAX_VALUE.flipBit(" + Integer.MAX_VALUE + ").bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testGetLowestSetBit() {
- System.out.println("Testing BigInteger.getLowestSetBit");
- check("BigInteger.MIN_VALUE.getLowestSetBit()",
- MIN_VALUE.getLowestSetBit(), 0);
- check("BigInteger.MAX_VALUE.getLowestSetBit()",
- MAX_VALUE.getLowestSetBit(), 0);
- }
-
- private static void testBitLength() {
- System.out.println("Testing BigInteger.bitLength");
- check("BigInteger.MIN_NEXT.bitLength()",
- MIN_VALUE.bitLength(), Integer.MAX_VALUE);
- check("BigInteger.MAX_VALUE.bitLength()",
- MAX_VALUE.bitLength(), Integer.MAX_VALUE);
- }
-
- private static void testBitCount() {
- System.out.println("Testing BigInteger.bitCount");
- check("BigInteger.MIN_VALUE.bitCount()",
- MIN_VALUE.bitCount(), Integer.MAX_VALUE - 1);
- check("BigInteger.MAX_VALUE.bitCount()",
- MAX_VALUE.bitCount(), Integer.MAX_VALUE);
- }
-
- private static void testToString(String msg, int radix, BigInteger bi, int length, String startsWith, char c) {
- String s = bi.toString(radix);
- if (s.length() != length) {
- throw new RuntimeException(msg + ".length=" + s.length());
- }
- if (!s.startsWith(startsWith)) {
- throw new RuntimeException(msg + "[0]=" + s.substring(0, startsWith.length()));
- }
- for (int i = startsWith.length(); i < s.length(); i++) {
- if (s.charAt(i) != c) {
- throw new RuntimeException(msg + "[" + i + "]='" + s.charAt(i) + "'");
- }
- }
- }
-
- private static void testToString() {
- System.out.println("Testing BigInteger.toString");
- testToString("BigInteger.MIN_VALUE.toString(16)=", 16,
- BigInteger.valueOf(-1).shiftLeft(Integer.MAX_VALUE - 1),
- (1 << 29) + 1, "-4", '0');
- }
-
- private static void testToByteArrayWithConstructor(String msg, BigInteger bi, int length, byte msb, byte b, byte lsb) {
- byte[] ba = bi.toByteArray();
- if (ba.length != length) {
- throw new RuntimeException(msg + ".length=" + ba.length);
- }
- if (ba[0] != msb) {
- throw new RuntimeException(msg + "[0]=" + ba[0]);
- }
- for (int i = 1; i < ba.length - 1; i++) {
- if (ba[i] != b) {
- throw new RuntimeException(msg + "[" + i + "]=" + ba[i]);
- }
- }
- if (ba[ba.length - 1] != lsb) {
- throw new RuntimeException(msg + "[" + (ba.length - 1) + "]=" + ba[ba.length - 1]);
- }
- BigInteger actual = new BigInteger(ba);
- if (!actual.equals(bi)) {
- throw new RuntimeException(msg + ".bitLength()=" + actual.bitLength());
- }
- }
-
- private static void testToByteArrayWithConstructor() {
- System.out.println("Testing BigInteger.toByteArray with constructor");
- testToByteArrayWithConstructor("BigInteger.MIN_VALUE.toByteArray()",
- MIN_VALUE, (1 << 28), (byte) 0x80, (byte) 0x00, (byte) 0x01);
- testToByteArrayWithConstructor("BigInteger.MAX_VALUE.toByteArray()",
- MAX_VALUE, (1 << 28), (byte) 0x7f, (byte) 0xff, (byte) 0xff);
-
- byte[] ba = new byte[1 << 28];
- ba[0] = (byte) 0x80;
- try {
- BigInteger actual = new BigInteger(-1, ba);
- throw new RuntimeException("new BigInteger(-1, ba).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- try {
- BigInteger actual = new BigInteger(1, ba);
- throw new RuntimeException("new BigInteger(1, ba).bitLength()=" + actual.bitLength());
- } catch (ArithmeticException e) {
- // expected
- }
- }
-
- private static void testIntValue() {
- System.out.println("Testing BigInteger.intValue");
- check("BigInteger.MIN_VALUE.intValue()",
- MIN_VALUE.intValue(), 1);
- check("BigInteger.MAX_VALUE.floatValue()",
- MAX_VALUE.intValue(), -1);
- }
-
- private static void testLongValue() {
- System.out.println("Testing BigInteger.longValue");
- check("BigInteger.MIN_VALUE.longValue()",
- MIN_VALUE.longValue(), 1L);
- check("BigInteger.MAX_VALUE.longValue()",
- MAX_VALUE.longValue(), -1L);
- }
-
- private static void testFloatValue() {
- System.out.println("Testing BigInteger.floatValue, Bug 8021203");
- check("BigInteger.MIN_VALUE_.floatValue()",
- MIN_VALUE.floatValue(), Float.NEGATIVE_INFINITY);
- check("BigInteger.MAX_VALUE.floatValue()",
- MAX_VALUE.floatValue(), Float.POSITIVE_INFINITY);
- }
-
- private static void testDoubleValue() {
- System.out.println("Testing BigInteger.doubleValue, Bug 8021203");
- check("BigInteger.MIN_VALUE.doubleValue()",
- MIN_VALUE.doubleValue(), Double.NEGATIVE_INFINITY);
- check("BigInteger.MAX_VALUE.doubleValue()",
- MAX_VALUE.doubleValue(), Double.POSITIVE_INFINITY);
- }
-
- private static void testSerialization(String msg, BigInteger bi) {
- try {
- ByteArrayOutputStream baOut = new ByteArrayOutputStream((1 << 28) + 1000);
- ObjectOutputStream out = new ObjectOutputStream(baOut);
- out.writeObject(bi);
- out.close();
- out = null;
- byte[] ba = baOut.toByteArray();
- baOut = null;
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(ba));
- BigInteger actual = (BigInteger) in.readObject();
- if (!actual.equals(bi)) {
- throw new RuntimeException(msg + ".bitLength()=" + actual.bitLength());
- }
- } catch (IOException | ClassNotFoundException e) {
- throw new RuntimeException(msg + " raised exception ", e);
- }
- }
-
- private static void testSerialization() {
- System.out.println("Testing BigInteger serialization");
- testSerialization("BigInteger.MIN_VALUE.intValue()",
- MIN_VALUE);
- testSerialization("BigInteger.MAX_VALUE.floatValue()",
- MAX_VALUE);
- }
-
- private static void testLongValueExact() {
- System.out.println("Testing BigInteger.longValueExact");
- try {
- long actual = MIN_VALUE.longValueExact();
- throw new RuntimeException("BigInteger.MIN_VALUE.longValueExact()= " + actual);
- } catch (ArithmeticException e) {
- // excpected
- }
- try {
- long actual = MAX_VALUE.longValueExact();
- throw new RuntimeException("BigInteger.MAX_VALUE.longValueExact()= " + actual);
- } catch (ArithmeticException e) {
- // excpected
- }
- }
-
- private static void testIntValueExact() {
- System.out.println("Testing BigInteger.intValueExact");
- try {
- long actual = MIN_VALUE.intValueExact();
- throw new RuntimeException("BigInteger.MIN_VALUE.intValueExact()= " + actual);
- } catch (ArithmeticException e) {
- // excpected
- }
- try {
- long actual = MAX_VALUE.intValueExact();
- throw new RuntimeException("BigInteger.MAX_VALUE.intValueExact()= " + actual);
- } catch (ArithmeticException e) {
- // excpected
- }
- }
-
- private static void testShortValueExact() {
- System.out.println("Testing BigInteger.shortValueExact");
- try {
- long actual = MIN_VALUE.shortValueExact();
- throw new RuntimeException("BigInteger.MIN_VALUE.shortValueExact()= " + actual);
- } catch (ArithmeticException e) {
- // excpected
- }
- try {
- long actual = MAX_VALUE.shortValueExact();
- throw new RuntimeException("BigInteger.MAX_VALUE.shortValueExact()= " + actual);
- } catch (ArithmeticException e) {
- // excpected
- }
- }
-
- private static void testByteValueExact() {
- System.out.println("Testing BigInteger.byteValueExact");
- try {
- long actual = MIN_VALUE.byteValueExact();
- throw new RuntimeException("BigInteger.MIN_VALUE.byteValueExact()= " + actual);
- } catch (ArithmeticException e) {
- // excpected
- }
- try {
- long actual = MAX_VALUE.byteValueExact();
- throw new RuntimeException("BigInteger.MAX_VALUE.byteValueExact()= " + actual);
- } catch (ArithmeticException e) {
- // excpected
- }
- }
-
- public static void main(String... args) {
- testOverflowInMakePositive();
- testBug8021204();
- testOverflowInBitSieve();
- testAdd();
- testSubtract();
- testMultiply();
- testDivide();
- testDivideAndRemainder();
- testBug9005933();
- testRemainder();
- testPow();
- testGcd();
- testAbs();
- testNegate();
- testMod();
- testModPow();
-// testModInverse();
- testShiftLeft();
- testShiftRight();
- testAnd();
- testOr();
- testXor();
- testNot();
- testSetBit();
- testClearBit();
- testFlipBit();
- testGetLowestSetBit();
- testBitLength();
- testBitCount();
- testToString();
- testToByteArrayWithConstructor();
- testIntValue();
- testLongValue();
- testFloatValue();
- testDoubleValue();
- testSerialization();
- testLongValueExact();
- testIntValueExact();
- testShortValueExact();
- testByteValueExact();
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/math/BigInteger/largeMemory/DivisionOverflow.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8022780
+ * @summary Test division of large values
+ * @requires os.maxMemory > 8g
+ * @run main/othervm -Xshare:off -Xmx8g DivisionOverflow
+ * @author Dmitry Nadezhin
+ */
+import java.math.BigInteger;
+
+public class DivisionOverflow {
+
+ public static void main(String[] args) {
+ try {
+ BigInteger a = BigInteger.ONE.shiftLeft(2147483646);
+ BigInteger b = BigInteger.ONE.shiftLeft(1568);
+ BigInteger[] qr = a.divideAndRemainder(b);
+ BigInteger q = qr[0];
+ BigInteger r = qr[1];
+ if (!r.equals(BigInteger.ZERO)) {
+ throw new RuntimeException("Incorrect signum() of remainder " + r.signum());
+ }
+ if (q.bitLength() != 2147482079) {
+ throw new RuntimeException("Incorrect bitLength() of quotient " + q.bitLength());
+ }
+ System.out.println("Division of large values passed without overflow.");
+ } catch (OutOfMemoryError e) {
+ // possible
+ System.err.println("DivisionOverflow skipped: OutOfMemoryError");
+ System.err.println("Run jtreg with -javaoption:-Xmx8g");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/math/BigInteger/largeMemory/StringConstructorOverflow.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013, 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8021204
+ * @summary Test constructor BigInteger(String val, int radix) on very long string
+ * @requires os.maxMemory > 8g
+ * @run main/othervm -Xshare:off -Xmx8g StringConstructorOverflow
+ * @author Dmitry Nadezhin
+ */
+import java.math.BigInteger;
+
+public class StringConstructorOverflow {
+
+ // String with hexadecimal value pow(2,pow(2,34))+1
+ private static String makeLongHexString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append('1');
+ for (int i = 0; i < (1 << 30) - 1; i++) {
+ sb.append('0');
+ }
+ sb.append('1');
+ return sb.toString();
+ }
+
+ public static void main(String[] args) {
+ try {
+ BigInteger bi = new BigInteger(makeLongHexString(), 16);
+ if (bi.compareTo(BigInteger.ONE) <= 0) {
+ throw new RuntimeException("Incorrect result " + bi.toString());
+ }
+ } catch (ArithmeticException e) {
+ // expected
+ System.out.println("Overflow is reported by ArithmeticException, as expected");
+ } catch (OutOfMemoryError e) {
+ // possible
+ System.err.println("StringConstructorOverflow skipped: OutOfMemoryError");
+ System.err.println("Run jtreg with -javaoption:-Xmx8g");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/math/BigInteger/largeMemory/SymmetricRangeTests.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,665 @@
+/*
+ * Copyright (c) 2013, 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 6910473 8021204 8021203 9005933 8074460 8078672
+ * @summary Test range of BigInteger values (use -Dseed=X to set PRNG seed)
+ * @library /test/lib
+ * @requires os.maxMemory > 8g
+ * @run main/timeout=180/othervm -Xmx8g SymmetricRangeTests
+ * @author Dmitry Nadezhin
+ * @key randomness
+ */
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+import java.math.BigInteger;
+import java.util.Random;
+import jdk.test.lib.RandomFactory;
+
+public class SymmetricRangeTests {
+
+ private static final BigInteger MAX_VALUE = makeMaxValue();
+ private static final BigInteger MIN_VALUE = MAX_VALUE.negate();
+
+ private static BigInteger makeMaxValue() {
+ byte[] ba = new byte[1 << 28];
+ Arrays.fill(ba, (byte) 0xFF);
+ ba[0] = (byte) 0x7F;
+ return new BigInteger(ba);
+ }
+
+ private static void check(String msg, BigInteger actual, BigInteger expected) {
+ if (!actual.equals(expected)) {
+ throw new RuntimeException(msg + ".bitLength()=" + actual.bitLength());
+ }
+ }
+
+ private static void check(String msg, double actual, double expected) {
+ if (actual != expected) {
+ throw new RuntimeException(msg + "=" + actual);
+ }
+ }
+
+ private static void check(String msg, float actual, float expected) {
+ if (actual != expected) {
+ throw new RuntimeException(msg + "=" + actual);
+ }
+ }
+
+ private static void check(String msg, long actual, long expected) {
+ if (actual != expected) {
+ throw new RuntimeException(msg + "=" + actual);
+ }
+ }
+
+ private static void check(String msg, int actual, int expected) {
+ if (actual != expected) {
+ throw new RuntimeException(msg + "=" + actual);
+ }
+ }
+
+ private static void testOverflowInMakePositive() {
+ System.out.println("Testing overflow in BigInteger.makePositive");
+ byte[] ba = new byte[Integer.MAX_VALUE - 2];
+ ba[0] = (byte) 0x80;
+ try {
+ BigInteger actual = new BigInteger(ba);
+ throw new RuntimeException("new BigInteger(ba).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testBug8021204() {
+ System.out.println("Testing Bug 8021204");
+ StringBuilder sb = new StringBuilder();
+ sb.append('1');
+ for (int i = 0; i < (1 << 30) - 1; i++) {
+ sb.append('0');
+ }
+ sb.append('1');
+ String s = sb.toString();
+ sb = null;
+ try {
+ BigInteger actual = new BigInteger(s, 16);
+ throw new RuntimeException("new BigInteger(\"1000...001\").bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testOverflowInBitSieve() {
+ System.out.println("Testing overflow in BitSieve.sieveSingle");
+ int bitLength = (5 << 27) - 1;
+ try {
+ Random random = RandomFactory.getRandom();
+ BigInteger actual = new BigInteger(bitLength, 0, random);
+ throw new RuntimeException("new BigInteger(bitLength, 0, null).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ try {
+ BigInteger bi = BigInteger.ONE.shiftLeft(bitLength - 1).subtract(BigInteger.ONE);
+ BigInteger actual = bi.nextProbablePrime();
+ throw new RuntimeException("bi.nextActualPrime().bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testAdd() {
+ System.out.println("Testing BigInteger.add");
+ try {
+ BigInteger actual = MAX_VALUE.add(BigInteger.ONE);
+ throw new RuntimeException("BigInteger.MAX_VALUE.add(BigInteger.ONE).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testSubtract() {
+ System.out.println("Testing BigInteger.subtract");
+ try {
+ BigInteger actual = MIN_VALUE.subtract(BigInteger.ONE);
+ throw new RuntimeException("BigInteger.MIN_VALUE.subtract(BigInteger.ONE).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testMultiply() {
+ System.out.println("Testing BigInteger.multiply");
+ int py = 2000;
+ int px = Integer.MAX_VALUE - py;
+ BigInteger x = BigInteger.ONE.shiftLeft(px);
+ BigInteger y = BigInteger.ONE.shiftLeft(py);
+ try {
+ BigInteger actual = x.multiply(y);
+ throw new RuntimeException("(1 << " + px + " ) * (1 << " + py + ").bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testDivide() {
+ System.out.println("Testing BigInteger.divide");
+ check("BigInteger.MIN_VALUE.divide(BigInteger.valueOf(-1))",
+ MIN_VALUE.divide(BigInteger.valueOf(-1)), MAX_VALUE);
+ check("BigInteger.MIN_VALUE.divide(BigInteger.ONE)",
+ MIN_VALUE.divide(BigInteger.ONE), MIN_VALUE);
+ }
+
+ private static void testDivideAndRemainder(String msg, BigInteger dividend, BigInteger divisor,
+ BigInteger expectedQuotent, BigInteger expectedRemainder) {
+ BigInteger[] qr = dividend.divideAndRemainder(divisor);
+ check(msg + "[0]", qr[0], expectedQuotent);
+ check(msg + "[1]", qr[1], expectedRemainder);
+ }
+
+ private static void testDivideAndRemainder() {
+ System.out.println("Testing BigInteger.divideAndRemainder");
+ testDivideAndRemainder("BigInteger.MIN_VALUE.divideAndRemainder(BigInteger.valueOf(-1))",
+ MIN_VALUE, BigInteger.valueOf(-1),
+ MAX_VALUE,
+ BigInteger.ZERO);
+ }
+
+ private static void testBug9005933() {
+ System.out.println("Testing Bug 9005933");
+ int dividendPow = 2147483646;
+ int divisorPow = 1568;
+ BigInteger dividend = BigInteger.ONE.shiftLeft(dividendPow);
+ BigInteger divisor = BigInteger.ONE.shiftLeft(divisorPow);
+ testDivideAndRemainder("(1 << " + dividendPow + ").divideAndRemainder(1 << " + divisorPow + ")",
+ dividend, divisor,
+ BigInteger.ONE.shiftLeft(dividendPow - divisorPow),
+ BigInteger.ZERO);
+ }
+
+ private static void testRemainder() {
+ System.out.println("Testing BigInteger.remainder");
+ check("BigInteger.MIN_VALUE.remainder(BigInteger.valueOf(-1))",
+ MIN_VALUE.remainder(BigInteger.valueOf(-1)), BigInteger.ZERO);
+ }
+
+ private static void testPow() {
+ System.out.println("Testing BigInteger.pow");
+ check("BigInteger.MIN_VALUE.pow(1)",
+ MIN_VALUE.pow(1), MIN_VALUE);
+ try {
+ BigInteger actual = BigInteger.valueOf(4).pow(Integer.MAX_VALUE);
+ throw new RuntimeException("BigInteger.valueOf(4).pow(Integer.MAX_VALUE).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testGcd() {
+ System.out.println("Testing BigInteger.gcd");
+ check("BigInteger.MIN_VALUE.gcd(BigInteger.MIN_VALUE)",
+ MIN_VALUE.gcd(MIN_VALUE), MAX_VALUE);
+ check("BigInteger.MIN_VALUE.gcd(BigInteger.ZERO)",
+ MIN_VALUE.gcd(BigInteger.ZERO), MAX_VALUE);
+ check("BigInteger.ZERO.gcd(MIN_VALUE)",
+ BigInteger.ZERO.gcd(MIN_VALUE), MAX_VALUE);
+ }
+
+ private static void testAbs() {
+ System.out.println("Testing BigInteger.abs");
+ check("BigInteger.MIN_VALUE.abs()",
+ MIN_VALUE.abs(), MAX_VALUE);
+ check("BigInteger.MAX_VALUE.abs()",
+ MAX_VALUE.abs(), MAX_VALUE);
+ }
+
+ private static void testNegate() {
+ System.out.println("Testing BigInteger.negate");
+ check("BigInteger.MIN_VALUE.negate()",
+ MIN_VALUE.negate(), MAX_VALUE);
+ check("BigInteger.MAX_VALUE.negate()",
+ MAX_VALUE.negate(), MIN_VALUE);
+ }
+
+ private static void testMod() {
+ System.out.println("Testing BigInteger.mod");
+ check("BigInteger.MIN_VALUE.mod(BigInteger.MAX_VALUE)",
+ MIN_VALUE.mod(MAX_VALUE), BigInteger.ZERO);
+ check("BigInteger.MAX_VALUE.mod(BigInteger.MAX_VALUE)",
+ MIN_VALUE.mod(MAX_VALUE), BigInteger.ZERO);
+ }
+
+ private static void testModPow() {
+ System.out.println("Testing BigInteger.modPow");
+ BigInteger x = BigInteger.valueOf(3);
+ BigInteger m = BigInteger.valueOf(-4).subtract(MIN_VALUE);
+ check("BigInteger.valueOf(3).modPow(BigInteger.ONE, m)",
+ x.modPow(BigInteger.ONE, m), x);
+ }
+
+ // slow test
+ private static void testModInverse() {
+ System.out.println("Testing BigInteger.modInverse");
+ check("BigInteger.MIN_VALUE.modInverse(BigInteger.MAX_VALUE)",
+ MIN_VALUE.modInverse(MAX_VALUE), MAX_VALUE.subtract(BigInteger.ONE));
+ }
+
+ private static void testShiftLeft() {
+ System.out.println("Testing BigInteger.shiftLeft");
+ try {
+ BigInteger actual = MIN_VALUE.shiftLeft(1);
+ throw new RuntimeException("BigInteger.MIN_VALUE.shiftLeft(1).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ try {
+ BigInteger actual = MAX_VALUE.shiftLeft(1);
+ throw new RuntimeException("BigInteger.MAX_VALUE.shiftLeft(1).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testShiftRight() {
+ System.out.println("Testing BigInteger.shiftRight");
+ try {
+ BigInteger actual = MIN_VALUE.shiftRight(-1);
+ throw new RuntimeException("BigInteger.MIN_VALUE.shiftRight(-1).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ try {
+ BigInteger actual = MAX_VALUE.shiftRight(-1);
+ throw new RuntimeException("BigInteger.MAX_VALUE.shiftRight(-1).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testAnd() {
+ System.out.println("Testing BigInteger.and");
+ check("BigInteger.MIN_VALUE.and(BigInteger.MIN_VALUE)",
+ MIN_VALUE.and(MIN_VALUE), MIN_VALUE);
+ check("BigInteger.MAX_VALUE.and(BigInteger.MAX_VALUE)",
+ MAX_VALUE.and(MAX_VALUE), MAX_VALUE);
+ check("BigInteger.MIN_VALUE.and(BigInteger.MAX_VALUE)",
+ MIN_VALUE.and(MAX_VALUE), BigInteger.ONE);
+ try {
+ BigInteger actual = MIN_VALUE.and(BigInteger.valueOf(-2));
+ throw new RuntimeException("BigInteger.MIN_VALUE.and(-2)).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testOr() {
+ System.out.println("Testing BigInteger.or");
+ check("BigInteger.MIN_VALUE.or(BigInteger.MIN_VALUE)",
+ MIN_VALUE.or(MIN_VALUE), MIN_VALUE);
+ check("BigInteger.MAX_VALUE.or(BigInteger.MAX_VALUE)",
+ MAX_VALUE.or(MAX_VALUE), MAX_VALUE);
+ check("BigInteger.MIN_VALUE.and(BigInteger.MAX_VALUE)",
+ MIN_VALUE.or(MAX_VALUE), BigInteger.valueOf(-1));
+ }
+
+ private static void testXor() {
+ System.out.println("Testing BigInteger.xor");
+ check("BigInteger.MIN_VALUE.xor(BigInteger.MIN_VALUE)",
+ MIN_VALUE.xor(MIN_VALUE), BigInteger.ZERO);
+ check("BigInteger.MAX_VALUE.xor(BigInteger.MAX_VALUE)",
+ MAX_VALUE.xor(MAX_VALUE), BigInteger.ZERO);
+ check("BigInteger.MIN_VALUE.xor(BigInteger.MAX_VALUE)",
+ MIN_VALUE.xor(MAX_VALUE), BigInteger.valueOf(-2));
+ try {
+ BigInteger actual = MIN_VALUE.xor(BigInteger.ONE);
+ throw new RuntimeException("BigInteger.MIN_VALUE.xor(BigInteger.ONE)).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testNot() {
+ System.out.println("Testing BigInteger.not");
+ check("BigInteger.MIN_VALUE.not()",
+ MIN_VALUE.not(), MAX_VALUE.subtract(BigInteger.ONE));
+ try {
+ BigInteger actual = MAX_VALUE.not();
+ throw new RuntimeException("BigInteger.MAX_VALUE.not()).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testSetBit() {
+ System.out.println("Testing BigInteger.setBit");
+ check("BigInteger.MIN_VALUE.setBit(" + Integer.MAX_VALUE + ")",
+ MIN_VALUE.setBit(Integer.MAX_VALUE), MIN_VALUE);
+ try {
+ BigInteger actual = MAX_VALUE.setBit(Integer.MAX_VALUE);
+ throw new RuntimeException("BigInteger.MAX_VALUE.setBit(" + Integer.MAX_VALUE + ").bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testClearBit() {
+ System.out.println("Testing BigInteger.clearBit");
+ check("BigInteger.MAX_VALUE.clearBit(" + Integer.MAX_VALUE + ")",
+ MAX_VALUE.clearBit(Integer.MAX_VALUE), MAX_VALUE);
+ try {
+ BigInteger actual = MIN_VALUE.clearBit(Integer.MAX_VALUE);
+ throw new RuntimeException("BigInteger.MIN_VALUE.clearBit(" + Integer.MAX_VALUE + ").bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ try {
+ BigInteger actual = MIN_VALUE.clearBit(0);
+ throw new RuntimeException("BigInteger.MIN_VALUE.clearBit(0).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testFlipBit() {
+ System.out.println("Testing BigInteger.flipBit");
+ try {
+ BigInteger actual = MIN_VALUE.flipBit(Integer.MAX_VALUE);
+ throw new RuntimeException("BigInteger.MIN_VALUE.flipBit(" + Integer.MAX_VALUE + ").bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ try {
+ BigInteger actual = MIN_VALUE.flipBit(0);
+ throw new RuntimeException("BigInteger.MIN_VALUE.flipBit(0).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ try {
+ BigInteger actual = MAX_VALUE.flipBit(Integer.MAX_VALUE);
+ throw new RuntimeException("BigInteger.MAX_VALUE.flipBit(" + Integer.MAX_VALUE + ").bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testGetLowestSetBit() {
+ System.out.println("Testing BigInteger.getLowestSetBit");
+ check("BigInteger.MIN_VALUE.getLowestSetBit()",
+ MIN_VALUE.getLowestSetBit(), 0);
+ check("BigInteger.MAX_VALUE.getLowestSetBit()",
+ MAX_VALUE.getLowestSetBit(), 0);
+ }
+
+ private static void testBitLength() {
+ System.out.println("Testing BigInteger.bitLength");
+ check("BigInteger.MIN_NEXT.bitLength()",
+ MIN_VALUE.bitLength(), Integer.MAX_VALUE);
+ check("BigInteger.MAX_VALUE.bitLength()",
+ MAX_VALUE.bitLength(), Integer.MAX_VALUE);
+ }
+
+ private static void testBitCount() {
+ System.out.println("Testing BigInteger.bitCount");
+ check("BigInteger.MIN_VALUE.bitCount()",
+ MIN_VALUE.bitCount(), Integer.MAX_VALUE - 1);
+ check("BigInteger.MAX_VALUE.bitCount()",
+ MAX_VALUE.bitCount(), Integer.MAX_VALUE);
+ }
+
+ private static void testToString(String msg, int radix, BigInteger bi, int length, String startsWith, char c) {
+ String s = bi.toString(radix);
+ if (s.length() != length) {
+ throw new RuntimeException(msg + ".length=" + s.length());
+ }
+ if (!s.startsWith(startsWith)) {
+ throw new RuntimeException(msg + "[0]=" + s.substring(0, startsWith.length()));
+ }
+ for (int i = startsWith.length(); i < s.length(); i++) {
+ if (s.charAt(i) != c) {
+ throw new RuntimeException(msg + "[" + i + "]='" + s.charAt(i) + "'");
+ }
+ }
+ }
+
+ private static void testToString() {
+ System.out.println("Testing BigInteger.toString");
+ testToString("BigInteger.MIN_VALUE.toString(16)=", 16,
+ BigInteger.valueOf(-1).shiftLeft(Integer.MAX_VALUE - 1),
+ (1 << 29) + 1, "-4", '0');
+ }
+
+ private static void testToByteArrayWithConstructor(String msg, BigInteger bi, int length, byte msb, byte b, byte lsb) {
+ byte[] ba = bi.toByteArray();
+ if (ba.length != length) {
+ throw new RuntimeException(msg + ".length=" + ba.length);
+ }
+ if (ba[0] != msb) {
+ throw new RuntimeException(msg + "[0]=" + ba[0]);
+ }
+ for (int i = 1; i < ba.length - 1; i++) {
+ if (ba[i] != b) {
+ throw new RuntimeException(msg + "[" + i + "]=" + ba[i]);
+ }
+ }
+ if (ba[ba.length - 1] != lsb) {
+ throw new RuntimeException(msg + "[" + (ba.length - 1) + "]=" + ba[ba.length - 1]);
+ }
+ BigInteger actual = new BigInteger(ba);
+ if (!actual.equals(bi)) {
+ throw new RuntimeException(msg + ".bitLength()=" + actual.bitLength());
+ }
+ }
+
+ private static void testToByteArrayWithConstructor() {
+ System.out.println("Testing BigInteger.toByteArray with constructor");
+ testToByteArrayWithConstructor("BigInteger.MIN_VALUE.toByteArray()",
+ MIN_VALUE, (1 << 28), (byte) 0x80, (byte) 0x00, (byte) 0x01);
+ testToByteArrayWithConstructor("BigInteger.MAX_VALUE.toByteArray()",
+ MAX_VALUE, (1 << 28), (byte) 0x7f, (byte) 0xff, (byte) 0xff);
+
+ byte[] ba = new byte[1 << 28];
+ ba[0] = (byte) 0x80;
+ try {
+ BigInteger actual = new BigInteger(-1, ba);
+ throw new RuntimeException("new BigInteger(-1, ba).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ try {
+ BigInteger actual = new BigInteger(1, ba);
+ throw new RuntimeException("new BigInteger(1, ba).bitLength()=" + actual.bitLength());
+ } catch (ArithmeticException e) {
+ // expected
+ }
+ }
+
+ private static void testIntValue() {
+ System.out.println("Testing BigInteger.intValue");
+ check("BigInteger.MIN_VALUE.intValue()",
+ MIN_VALUE.intValue(), 1);
+ check("BigInteger.MAX_VALUE.floatValue()",
+ MAX_VALUE.intValue(), -1);
+ }
+
+ private static void testLongValue() {
+ System.out.println("Testing BigInteger.longValue");
+ check("BigInteger.MIN_VALUE.longValue()",
+ MIN_VALUE.longValue(), 1L);
+ check("BigInteger.MAX_VALUE.longValue()",
+ MAX_VALUE.longValue(), -1L);
+ }
+
+ private static void testFloatValue() {
+ System.out.println("Testing BigInteger.floatValue, Bug 8021203");
+ check("BigInteger.MIN_VALUE_.floatValue()",
+ MIN_VALUE.floatValue(), Float.NEGATIVE_INFINITY);
+ check("BigInteger.MAX_VALUE.floatValue()",
+ MAX_VALUE.floatValue(), Float.POSITIVE_INFINITY);
+ }
+
+ private static void testDoubleValue() {
+ System.out.println("Testing BigInteger.doubleValue, Bug 8021203");
+ check("BigInteger.MIN_VALUE.doubleValue()",
+ MIN_VALUE.doubleValue(), Double.NEGATIVE_INFINITY);
+ check("BigInteger.MAX_VALUE.doubleValue()",
+ MAX_VALUE.doubleValue(), Double.POSITIVE_INFINITY);
+ }
+
+ private static void testSerialization(String msg, BigInteger bi) {
+ try {
+ ByteArrayOutputStream baOut = new ByteArrayOutputStream((1 << 28) + 1000);
+ ObjectOutputStream out = new ObjectOutputStream(baOut);
+ out.writeObject(bi);
+ out.close();
+ out = null;
+ byte[] ba = baOut.toByteArray();
+ baOut = null;
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(ba));
+ BigInteger actual = (BigInteger) in.readObject();
+ if (!actual.equals(bi)) {
+ throw new RuntimeException(msg + ".bitLength()=" + actual.bitLength());
+ }
+ } catch (IOException | ClassNotFoundException e) {
+ throw new RuntimeException(msg + " raised exception ", e);
+ }
+ }
+
+ private static void testSerialization() {
+ System.out.println("Testing BigInteger serialization");
+ testSerialization("BigInteger.MIN_VALUE.intValue()",
+ MIN_VALUE);
+ testSerialization("BigInteger.MAX_VALUE.floatValue()",
+ MAX_VALUE);
+ }
+
+ private static void testLongValueExact() {
+ System.out.println("Testing BigInteger.longValueExact");
+ try {
+ long actual = MIN_VALUE.longValueExact();
+ throw new RuntimeException("BigInteger.MIN_VALUE.longValueExact()= " + actual);
+ } catch (ArithmeticException e) {
+ // excpected
+ }
+ try {
+ long actual = MAX_VALUE.longValueExact();
+ throw new RuntimeException("BigInteger.MAX_VALUE.longValueExact()= " + actual);
+ } catch (ArithmeticException e) {
+ // excpected
+ }
+ }
+
+ private static void testIntValueExact() {
+ System.out.println("Testing BigInteger.intValueExact");
+ try {
+ long actual = MIN_VALUE.intValueExact();
+ throw new RuntimeException("BigInteger.MIN_VALUE.intValueExact()= " + actual);
+ } catch (ArithmeticException e) {
+ // excpected
+ }
+ try {
+ long actual = MAX_VALUE.intValueExact();
+ throw new RuntimeException("BigInteger.MAX_VALUE.intValueExact()= " + actual);
+ } catch (ArithmeticException e) {
+ // excpected
+ }
+ }
+
+ private static void testShortValueExact() {
+ System.out.println("Testing BigInteger.shortValueExact");
+ try {
+ long actual = MIN_VALUE.shortValueExact();
+ throw new RuntimeException("BigInteger.MIN_VALUE.shortValueExact()= " + actual);
+ } catch (ArithmeticException e) {
+ // excpected
+ }
+ try {
+ long actual = MAX_VALUE.shortValueExact();
+ throw new RuntimeException("BigInteger.MAX_VALUE.shortValueExact()= " + actual);
+ } catch (ArithmeticException e) {
+ // excpected
+ }
+ }
+
+ private static void testByteValueExact() {
+ System.out.println("Testing BigInteger.byteValueExact");
+ try {
+ long actual = MIN_VALUE.byteValueExact();
+ throw new RuntimeException("BigInteger.MIN_VALUE.byteValueExact()= " + actual);
+ } catch (ArithmeticException e) {
+ // excpected
+ }
+ try {
+ long actual = MAX_VALUE.byteValueExact();
+ throw new RuntimeException("BigInteger.MAX_VALUE.byteValueExact()= " + actual);
+ } catch (ArithmeticException e) {
+ // excpected
+ }
+ }
+
+ public static void main(String... args) {
+ testOverflowInMakePositive();
+ testBug8021204();
+ testOverflowInBitSieve();
+ testAdd();
+ testSubtract();
+ testMultiply();
+ testDivide();
+ testDivideAndRemainder();
+ testBug9005933();
+ testRemainder();
+ testPow();
+ testGcd();
+ testAbs();
+ testNegate();
+ testMod();
+ testModPow();
+// testModInverse();
+ testShiftLeft();
+ testShiftRight();
+ testAnd();
+ testOr();
+ testXor();
+ testNot();
+ testSetBit();
+ testClearBit();
+ testFlipBit();
+ testGetLowestSetBit();
+ testBitLength();
+ testBitCount();
+ testToString();
+ testToByteArrayWithConstructor();
+ testIntValue();
+ testLongValue();
+ testFloatValue();
+ testDoubleValue();
+ testSerialization();
+ testLongValueExact();
+ testIntValueExact();
+ testShortValueExact();
+ testByteValueExact();
+ }
+}
--- a/test/jdk/java/net/InetSocketAddress/ToString.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/java/net/InetSocketAddress/ToString.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, 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
@@ -23,19 +23,141 @@
/*
* @test
- * @bug 4464064
- * @summary InetSocketAddress.toString() throws NPE with unresolved address
+ * @bug 8225499 4464064
+ * @library /test/lib
+ * @summary InetSocketAddress::toString not friendly to IPv6 literal addresses
+ * @run testng/othervm ToString
+ * @run testng/othervm -Djava.net.preferIPv4Stack=true ToString
+ * @run testng/othervm -Djava.net.preferIPv6Addresses=true ToString
*/
import java.net.*;
-import java.io.*;
+import jdk.test.lib.net.IPSupport;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
public class ToString {
- public static void main (String args[]){
+ private static final String loopbackAddr;
+ private static final String wildcardAddr;
+ private static final String localAddr;
+
+ static {
+ try {
+ InetAddress loopback = InetAddress.getLoopbackAddress();
+ String addr = loopback.getHostAddress();
+ if (loopback instanceof Inet6Address) {
+ addr = "[" + addr + "]";
+ }
+ loopbackAddr = addr;
+
+ InetSocketAddress isa = new InetSocketAddress((InetAddress) null, 80);
+ addr = isa.getAddress().toString();
+ if (isa.getAddress() instanceof Inet6Address) {
+ addr = "::/[0:0:0:0:0:0:0:0]";
+ }
+ wildcardAddr = addr;
+
+ InetAddress ia = InetAddress.getLocalHost();
+ addr = ia.toString();
+ if (ia instanceof Inet6Address) {
+ addr = ia.getHostName() + "/[" + ia.getHostAddress() + "]";
+ }
+ localAddr = addr;
+
+ } catch (UnknownHostException uhe) {
+ throw new RuntimeException(uhe);
+ }
+ }
+
+ @BeforeTest
+ public void setup() {
+ IPSupport.throwSkippedExceptionIfNonOperational();
+ }
+
+ @Test
+ // InetSocketAddress.toString() throws NPE with unresolved address
+ public static void NPETest() {
+ System.out.println(new InetSocketAddress("unresolved", 12345));
+ }
+
+ @DataProvider(name = "hostPortArgs")
+ public Object[][] createArgs1() {
+ return new Object[][]{
+ // hostname, port number, expected string in format
+ // <hostname>/<IP literal>:<port> or
+ // <hostname>/<unresolved>:<port> if address is unresolved
+ {"::1", 80, "/[0:0:0:0:0:0:0:1]:80"},
+ {"fedc:ba98:7654:3210:fedc:ba98:7654:3210", 80, "/[fedc:ba98:7654:3210:fedc:ba98:7654:3210]:80"},
+ {"::192.9.5.5", 80, "/[0:0:0:0:0:0:c009:505]:80"},
+ {"127.0.0.1", 80, "/127.0.0.1:80"},
+ {"::ffff:192.0.2.128", 80, "/192.0.2.128:80"},
+ {"0", 80, "/0.0.0.0:80"},
+ {":", 80, ":/<unresolved>:80"},
+ {":1", 80, ":1/<unresolved>:80"}
+ };
+ }
- System.out.println(new InetSocketAddress("unresolved", 12345));
+ @Test(dataProvider = "hostPortArgs")
+ public static void testConstructor(String host, int port, String string) {
+ String received = new InetSocketAddress(host, port).toString();
+
+ if (!string.equals(received)) {
+ throw new RuntimeException("Expected: " + string + " Received: " + received);
+ }
+ }
+
+ @DataProvider(name = "addrPortArgs")
+ public Object[][] createArgs2() {
+ InetAddress nullAddr = null;
+ try {
+ return new Object[][]{
+ // InetAddress, port number, expected string
+ {InetAddress.getLoopbackAddress(), 80, "localhost/" + loopbackAddr + ":80"},
+ {InetAddress.getLocalHost(), 80, localAddr + ":80"},
+ {InetAddress.getByAddress(new byte[]{1, 1, 1, 1}), 80, "/1.1.1.1:80"},
+ {InetAddress.getByAddress(new byte[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}), 80, "/[101:101:101:101:101:101:101:101]:80"},
+ {InetAddress.getByName("225.225.225.0"), 80, "/225.225.225.0:80"},
+ {nullAddr, 80, wildcardAddr + ":80"}
+ };
+ } catch (UnknownHostException uhe) {
+ throw new RuntimeException("Data provider creation failed: " + uhe, uhe);
+ }
+ }
+ @Test(dataProvider = "addrPortArgs")
+ public static void testConstructor(InetAddress addr, int port, String string) {
+ String received = new InetSocketAddress(addr, port).toString();
+
+ if (!string.equals(received)) {
+ throw new RuntimeException("Expected: " + string + " Received: " + received);
+ }
+ }
+
+ @DataProvider(name = "unresolved")
+ public Object[][] createArgs3() {
+ return new Object[][]{
+ // hostname, port number, expected string
+ {"::1", 80, "::1/<unresolved>:80"},
+ {"fedc:ba98:7654:3210:fedc:ba98:7654:3210", 80, "fedc:ba98:7654:3210:fedc:ba98:7654:3210/<unresolved>:80"},
+ {"::192.9.5.5", 80, "::192.9.5.5/<unresolved>:80"},
+ {"127.0.0.1", 80, "127.0.0.1/<unresolved>:80"},
+ {"::ffff:192.0.2.128", 80, "::ffff:192.0.2.128/<unresolved>:80"},
+ {"0", 80, "0/<unresolved>:80"},
+ {"foo", 80, "foo/<unresolved>:80"},
+ {":", 80, ":/<unresolved>:80"},
+ {":1", 80, ":1/<unresolved>:80"}
+ };
+ }
+
+ @Test(dataProvider = "unresolved")
+ public static void testCreateUnresolved(String host, int port, String string) {
+ String received = InetSocketAddress.createUnresolved(host, port).toString();
+
+ if (!string.equals(received)) {
+ throw new RuntimeException("Expected: " + string + " Received: " + received);
+ }
}
}
--- a/test/jdk/java/net/SocketPermission/Ctor.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/java/net/SocketPermission/Ctor.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, 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
@@ -23,19 +23,64 @@
/*
* @test
- * @bug 4391898
+ * @bug 4391898 8230407
* @summary SocketPermission(":",...) throws ArrayIndexOutOfBoundsException
+ * SocketPermission constructor argument checks
+ * @run testng Ctor
*/
-import java.net.*;
+import java.net.SocketPermission;
+import org.testng.annotations.Test;
+import static java.lang.System.out;
+import static org.testng.Assert.*;
public class Ctor {
- public static void main(String[] args) {
- try {
- SocketPermission sp = new java.net.SocketPermission(":", "connect");
- } catch (java.lang.ArrayIndexOutOfBoundsException e) {
- throw new RuntimeException(e);
- }
- System.out.println("Test passed!!!");
+
+ static final Class<NullPointerException> NPE = NullPointerException.class;
+ static final Class<IllegalArgumentException> IAE = IllegalArgumentException.class;
+
+ @Test
+ public void positive() {
+ // ArrayIndexOutOfBoundsException is the bug, 4391898, exists
+ SocketPermission sp1 = new SocketPermission(":", "connect");
+ }
+
+ @Test
+ public void npe() {
+ NullPointerException e;
+ e = expectThrows(NPE, () -> new SocketPermission(null, null));
+ out.println("caught expected NPE: " + e);
+ e = expectThrows(NPE, () -> new SocketPermission("foo", null));
+ out.println("caught expected NPE: " + e);
+ e = expectThrows(NPE, () -> new SocketPermission(null, "connect"));
+ out.println("caught expected NPE: " + e);
+ }
+
+ @Test
+ public void iae() {
+ IllegalArgumentException e;
+ // host
+ e = expectThrows(IAE, () -> new SocketPermission("1:2:3:4", "connect"));
+ out.println("caught expected IAE: " + e);
+ e = expectThrows(IAE, () -> new SocketPermission("foo:5-4", "connect"));
+ out.println("caught expected IAE: " + e);
+
+ // actions
+ e = expectThrows(IAE, () -> new SocketPermission("foo", ""));
+ out.println("caught expected IAE: " + e);
+ e = expectThrows(IAE, () -> new SocketPermission("foo", "badAction"));
+ out.println("caught expected IAE: " + e);
+ e = expectThrows(IAE, () -> new SocketPermission("foo", "badAction,connect"));
+ out.println("caught expected IAE: " + e);
+ e = expectThrows(IAE, () -> new SocketPermission("foo", "badAction,,connect"));
+ out.println("caught expected IAE: " + e);
+ e = expectThrows(IAE, () -> new SocketPermission("foo", ",connect"));
+ out.println("caught expected IAE: " + e);
+ e = expectThrows(IAE, () -> new SocketPermission("foo", ",,connect"));
+ out.println("caught expected IAE: " + e);
+ e = expectThrows(IAE, () -> new SocketPermission("foo", "connect,"));
+ out.println("caught expected IAE: " + e);
+ e = expectThrows(IAE, () -> new SocketPermission("foo", "connect,,"));
+ out.println("caught expected IAE: " + e);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/net/httpclient/HttpRedirectTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,457 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+import com.sun.net.httpserver.HttpServer;
+import com.sun.net.httpserver.HttpsConfigurator;
+import com.sun.net.httpserver.HttpsServer;
+import jdk.test.lib.net.SimpleSSLContext;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.ProxySelector;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * @test
+ * @bug 8232625
+ * @summary This test verifies that the HttpClient works correctly when redirecting a post request.
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DigestEchoServer HttpRedirectTest
+ * @modules java.net.http/jdk.internal.net.http.common
+ * java.net.http/jdk.internal.net.http.frame
+ * java.net.http/jdk.internal.net.http.hpack
+ * java.logging
+ * java.base/sun.net.www.http
+ * java.base/sun.net.www
+ * java.base/sun.net
+ * @run testng/othervm -Dtest.requiresHost=true
+ * -Djdk.httpclient.HttpClient.log=headers
+ * -Djdk.internal.httpclient.debug=false
+ * HttpRedirectTest
+ *
+ */
+public class HttpRedirectTest implements HttpServerAdapters {
+ static final String GET_RESPONSE_BODY = "Lorem ipsum dolor sit amet";
+ static final String REQUEST_BODY = "Here it goes";
+ static final SSLContext context;
+ static {
+ try {
+ context = new SimpleSSLContext().get();
+ SSLContext.setDefault(context);
+ } catch (Exception x) {
+ throw new ExceptionInInitializerError(x);
+ }
+ }
+
+ final AtomicLong requestCounter = new AtomicLong();
+ final AtomicLong responseCounter = new AtomicLong();
+ HttpTestServer http1Server;
+ HttpTestServer http2Server;
+ HttpTestServer https1Server;
+ HttpTestServer https2Server;
+ DigestEchoServer.TunnelingProxy proxy;
+
+ URI http1URI;
+ URI https1URI;
+ URI http2URI;
+ URI https2URI;
+ InetSocketAddress proxyAddress;
+ ProxySelector proxySelector;
+ HttpClient client;
+ List<CompletableFuture<?>> futures = new CopyOnWriteArrayList<>();
+ Set<URI> pending = new CopyOnWriteArraySet<>();
+
+ final ExecutorService executor = new ThreadPoolExecutor(12, 60, 10,
+ TimeUnit.SECONDS, new LinkedBlockingQueue<>()); // Shared by HTTP/1.1 servers
+ final ExecutorService clientexec = new ThreadPoolExecutor(6, 12, 1,
+ TimeUnit.SECONDS, new LinkedBlockingQueue<>()); // Used by the client
+
+ public HttpClient newHttpClient(ProxySelector ps) {
+ HttpClient.Builder builder = HttpClient
+ .newBuilder()
+ .sslContext(context)
+ .executor(clientexec)
+ .followRedirects(HttpClient.Redirect.ALWAYS)
+ .proxy(ps);
+ return builder.build();
+ }
+
+ @DataProvider(name="uris")
+ Object[][] testURIs() throws URISyntaxException {
+ List<URI> uris = List.of(
+ http1URI.resolve("direct/orig/"),
+ https1URI.resolve("direct/orig/"),
+ https1URI.resolve("proxy/orig/"),
+ http2URI.resolve("direct/orig/"),
+ https2URI.resolve("direct/orig/"),
+ https2URI.resolve("proxy/orig/"));
+ List<Map.Entry<Integer, String>> redirects = List.of(
+ Map.entry(301, "GET"),
+ Map.entry(308, "POST"),
+ Map.entry(302, "GET"),
+ Map.entry(303, "GET"),
+ Map.entry(307, "POST"),
+ Map.entry(300, "DO_NOT_FOLLOW"),
+ Map.entry(304, "DO_NOT_FOLLOW"),
+ Map.entry(305, "DO_NOT_FOLLOW"),
+ Map.entry(306, "DO_NOT_FOLLOW"),
+ Map.entry(309, "DO_NOT_FOLLOW"),
+ Map.entry(new Random().nextInt(90) + 310, "DO_NOT_FOLLOW")
+ );
+ Object[][] tests = new Object[redirects.size() * uris.size()][3];
+ int count = 0;
+ for (int i=0; i < uris.size(); i++) {
+ URI u = uris.get(i);
+ for (int j=0; j < redirects.size() ; j++) {
+ int code = redirects.get(j).getKey();
+ String m = redirects.get(j).getValue();
+ tests[count][0] = u.resolve(code +"/");
+ tests[count][1] = code;
+ tests[count][2] = m;
+ count++;
+ }
+ }
+ return tests;
+ }
+
+ @BeforeClass
+ public void setUp() throws Exception {
+ try {
+ InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
+
+ // HTTP/1.1
+ HttpServer server1 = HttpServer.create(sa, 0);
+ server1.setExecutor(executor);
+ http1Server = HttpTestServer.of(server1);
+ http1Server.addHandler(new HttpTestRedirectHandler("http", http1Server),
+ "/HttpRedirectTest/http1/");
+ http1Server.start();
+ http1URI = new URI("http://" + http1Server.serverAuthority() + "/HttpRedirectTest/http1/");
+
+
+ // HTTPS/1.1
+ HttpsServer sserver1 = HttpsServer.create(sa, 100);
+ sserver1.setExecutor(executor);
+ sserver1.setHttpsConfigurator(new HttpsConfigurator(context));
+ https1Server = HttpTestServer.of(sserver1);
+ https1Server.addHandler(new HttpTestRedirectHandler("https", https1Server),
+ "/HttpRedirectTest/https1/");
+ https1Server.start();
+ https1URI = new URI("https://" + https1Server.serverAuthority() + "/HttpRedirectTest/https1/");
+
+ // HTTP/2.0
+ http2Server = HttpTestServer.of(
+ new Http2TestServer("localhost", false, 0));
+ http2Server.addHandler(new HttpTestRedirectHandler("http", http2Server),
+ "/HttpRedirectTest/http2/");
+ http2Server.start();
+ http2URI = new URI("http://" + http2Server.serverAuthority() + "/HttpRedirectTest/http2/");
+
+ // HTTPS/2.0
+ https2Server = HttpTestServer.of(
+ new Http2TestServer("localhost", true, 0));
+ https2Server.addHandler(new HttpTestRedirectHandler("https", https2Server),
+ "/HttpRedirectTest/https2/");
+ https2Server.start();
+ https2URI = new URI("https://" + https2Server.serverAuthority() + "/HttpRedirectTest/https2/");
+
+ proxy = DigestEchoServer.createHttpsProxyTunnel(
+ DigestEchoServer.HttpAuthSchemeType.NONE);
+ proxyAddress = proxy.getProxyAddress();
+ proxySelector = new HttpProxySelector(proxyAddress);
+ client = newHttpClient(proxySelector);
+ System.out.println("Setup: done");
+ } catch (Exception x) {
+ tearDown(); throw x;
+ } catch (Error e) {
+ tearDown(); throw e;
+ }
+ }
+
+ private void testNonIdempotent(URI u, HttpRequest request,
+ int code, String method) throws Exception {
+ System.out.println("Testing with " + u);
+ CompletableFuture<HttpResponse<String>> respCf =
+ client.sendAsync(request, HttpResponse.BodyHandlers.ofString());
+ HttpResponse<String> resp = respCf.join();
+ if (method.equals("DO_NOT_FOLLOW")) {
+ assertEquals(resp.statusCode(), code, u + ": status code");
+ } else {
+ assertEquals(resp.statusCode(), 200, u + ": status code");
+ }
+ if (method.equals("POST")) {
+ assertEquals(resp.body(), REQUEST_BODY, u + ": body");
+ } else if (code == 304) {
+ assertEquals(resp.body(), "", u + ": body");
+ } else if (method.equals("DO_NOT_FOLLOW")) {
+ assertNotEquals(resp.body(), GET_RESPONSE_BODY, u + ": body");
+ assertNotEquals(resp.body(), REQUEST_BODY, u + ": body");
+ } else {
+ assertEquals(resp.body(), GET_RESPONSE_BODY, u + ": body");
+ }
+ }
+
+ public void testIdempotent(URI u, HttpRequest request,
+ int code, String method) throws Exception {
+ CompletableFuture<HttpResponse<String>> respCf =
+ client.sendAsync(request, HttpResponse.BodyHandlers.ofString());
+ HttpResponse<String> resp = respCf.join();
+ if (method.equals("DO_NOT_FOLLOW")) {
+ assertEquals(resp.statusCode(), code, u + ": status code");
+ } else {
+ assertEquals(resp.statusCode(), 200, u + ": status code");
+ }
+ if (method.equals("POST")) {
+ assertEquals(resp.body(), REQUEST_BODY, u + ": body");
+ } else if (code == 304) {
+ assertEquals(resp.body(), "", u + ": body");
+ } else if (method.equals("DO_NOT_FOLLOW")) {
+ assertNotEquals(resp.body(), GET_RESPONSE_BODY, u + ": body");
+ assertNotEquals(resp.body(), REQUEST_BODY, u + ": body");
+ } else if (code == 303) {
+ assertEquals(resp.body(), GET_RESPONSE_BODY, u + ": body");
+ } else {
+ assertEquals(resp.body(), REQUEST_BODY, u + ": body");
+ }
+ }
+
+ @Test(dataProvider = "uris")
+ public void testPOST(URI uri, int code, String method) throws Exception {
+ URI u = uri.resolve("foo?n=" + requestCounter.incrementAndGet());
+ HttpRequest request = HttpRequest.newBuilder(u)
+ .POST(HttpRequest.BodyPublishers.ofString(REQUEST_BODY)).build();
+ // POST is not considered idempotent.
+ testNonIdempotent(u, request, code, method);
+ }
+
+ @Test(dataProvider = "uris")
+ public void testPUT(URI uri, int code, String method) throws Exception {
+ URI u = uri.resolve("foo?n=" + requestCounter.incrementAndGet());
+ System.out.println("Testing with " + u);
+ HttpRequest request = HttpRequest.newBuilder(u)
+ .PUT(HttpRequest.BodyPublishers.ofString(REQUEST_BODY)).build();
+ // PUT is considered idempotent.
+ testIdempotent(u, request, code, method);
+ }
+
+ @Test(dataProvider = "uris")
+ public void testFoo(URI uri, int code, String method) throws Exception {
+ URI u = uri.resolve("foo?n=" + requestCounter.incrementAndGet());
+ System.out.println("Testing with " + u);
+ HttpRequest request = HttpRequest.newBuilder(u)
+ .method("FOO",
+ HttpRequest.BodyPublishers.ofString(REQUEST_BODY)).build();
+ // FOO is considered idempotent.
+ testIdempotent(u, request, code, method);
+ }
+
+ @Test(dataProvider = "uris")
+ public void testGet(URI uri, int code, String method) throws Exception {
+ URI u = uri.resolve("foo?n=" + requestCounter.incrementAndGet());
+ System.out.println("Testing with " + u);
+ HttpRequest request = HttpRequest.newBuilder(u)
+ .method("GET",
+ HttpRequest.BodyPublishers.ofString(REQUEST_BODY)).build();
+ CompletableFuture<HttpResponse<String>> respCf =
+ client.sendAsync(request, HttpResponse.BodyHandlers.ofString());
+ HttpResponse<String> resp = respCf.join();
+ // body will be preserved except for 304 and 303: this is a GET.
+ if (method.equals("DO_NOT_FOLLOW")) {
+ assertEquals(resp.statusCode(), code, u + ": status code");
+ } else {
+ assertEquals(resp.statusCode(), 200, u + ": status code");
+ }
+ if (code == 304) {
+ assertEquals(resp.body(), "", u + ": body");
+ } else if (method.equals("DO_NOT_FOLLOW")) {
+ assertNotEquals(resp.body(), GET_RESPONSE_BODY, u + ": body");
+ assertNotEquals(resp.body(), REQUEST_BODY, u + ": body");
+ } else if (code == 303) {
+ assertEquals(resp.body(), GET_RESPONSE_BODY, u + ": body");
+ } else {
+ assertEquals(resp.body(), REQUEST_BODY, u + ": body");
+ }
+ }
+
+ @AfterClass
+ public void tearDown() {
+ proxy = stop(proxy, DigestEchoServer.TunnelingProxy::stop);
+ http1Server = stop(http1Server, HttpTestServer::stop);
+ https1Server = stop(https1Server, HttpTestServer::stop);
+ http2Server = stop(http2Server, HttpTestServer::stop);
+ https2Server = stop(https2Server, HttpTestServer::stop);
+ client = null;
+ try {
+ executor.awaitTermination(2000, TimeUnit.MILLISECONDS);
+ } catch (Throwable x) {
+ } finally {
+ executor.shutdownNow();
+ }
+ try {
+ clientexec.awaitTermination(2000, TimeUnit.MILLISECONDS);
+ } catch (Throwable x) {
+ } finally {
+ clientexec.shutdownNow();
+ }
+ System.out.println("Teardown: done");
+ }
+
+ private interface Stoppable<T> { public void stop(T service) throws Exception; }
+
+ static <T> T stop(T service, Stoppable<T> stop) {
+ try { if (service != null) stop.stop(service); } catch (Throwable x) { };
+ return null;
+ }
+
+ static class HttpProxySelector extends ProxySelector {
+ private static final List<Proxy> NO_PROXY = List.of(Proxy.NO_PROXY);
+ private final List<Proxy> proxyList;
+ HttpProxySelector(InetSocketAddress proxyAddress) {
+ proxyList = List.of(new Proxy(Proxy.Type.HTTP, proxyAddress));
+ }
+
+ @Override
+ public List<Proxy> select(URI uri) {
+ // our proxy only supports tunneling
+ if (uri.getScheme().equalsIgnoreCase("https")) {
+ if (uri.getPath().contains("/proxy/")) {
+ return proxyList;
+ }
+ }
+ return NO_PROXY;
+ }
+
+ @Override
+ public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
+ System.err.println("Connection to proxy failed: " + ioe);
+ System.err.println("Proxy: " + sa);
+ System.err.println("\tURI: " + uri);
+ ioe.printStackTrace();
+ }
+ }
+
+ public static class HttpTestRedirectHandler implements HttpTestHandler {
+ static final AtomicLong respCounter = new AtomicLong();
+ final String scheme;
+ final HttpTestServer server;
+ HttpTestRedirectHandler(String scheme, HttpTestServer server) {
+ this.scheme = scheme;
+ this.server = server;
+ }
+
+ @Override
+ public void handle(HttpTestExchange t) throws IOException {
+ try (InputStream is = t.getRequestBody()) {
+ byte[] bytes = is.readAllBytes();
+ URI u = t.getRequestURI();
+ long responseID = Long.parseLong(u.getQuery().substring(2));
+ String path = u.getPath();
+ int i = path.lastIndexOf('/');
+ String file = path.substring(i+1);
+ String parent = path.substring(0, i);
+ int code = 200;
+ if (file.equals("foo")) {
+ i = parent.lastIndexOf("/");
+ code = Integer.parseInt(parent.substring(i+1));
+ }
+ String response;
+ if (code == 200) {
+ if (t.getRequestMethod().equals("GET")) {
+ if (bytes.length == 0) {
+ response = GET_RESPONSE_BODY;
+ } else {
+ response = new String(bytes, StandardCharsets.UTF_8);
+ }
+ } else if (t.getRequestMethod().equals("POST")) {
+ response = new String(bytes, StandardCharsets.UTF_8);
+ } else {
+ response = new String(bytes, StandardCharsets.UTF_8);
+ }
+ } else if (code < 300 || code > 399) {
+ response = "Unexpected code: " + code;
+ code = 400;
+ } else {
+ try {
+ URI reloc = new URI(scheme, server.serverAuthority(), parent + "/bar", u.getQuery(), null);
+ t.getResponseHeaders().addHeader("Location", reloc.toASCIIString());
+ if (code != 304) {
+ response = "Code: " + code;
+ } else response = null;
+ } catch (URISyntaxException x) {
+ x.printStackTrace();
+ x.printStackTrace(System.out);
+ code = 400;
+ response = x.toString();
+ }
+ }
+
+ System.out.println("Server " + t.getRequestURI() + " sending response " + responseID);
+ System.out.println("code: " + code + " body: " + response);
+ t.sendResponseHeaders(code, code == 304 ? 0: -1);
+ if (code != 304) {
+ try (OutputStream os = t.getResponseBody()) {
+ bytes = response.getBytes(StandardCharsets.UTF_8);
+ os.write(bytes);
+ os.flush();
+ }
+ } else {
+ bytes = new byte[0];
+ }
+
+ System.out.println("\tresp:" + responseID + ": wrote " + bytes.length + " bytes");
+ } catch (Throwable e) {
+ e.printStackTrace();
+ e.printStackTrace(System.out);
+ throw e;
+ }
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/net/httpclient/HttpSlowServerTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+import com.sun.net.httpserver.HttpServer;
+import com.sun.net.httpserver.HttpsConfigurator;
+import com.sun.net.httpserver.HttpsServer;
+import jdk.test.lib.net.SimpleSSLContext;
+
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.ProxySelector;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * @test
+ * @summary This test verifies that the HttpClient works correctly when connected to a
+ * slow server.
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DigestEchoServer HttpSlowServerTest
+ * @modules java.net.http/jdk.internal.net.http.common
+ * java.net.http/jdk.internal.net.http.frame
+ * java.net.http/jdk.internal.net.http.hpack
+ * java.logging
+ * java.base/sun.net.www.http
+ * java.base/sun.net.www
+ * java.base/sun.net
+ * @run main/othervm -Dtest.requiresHost=true
+ * -Djdk.httpclient.HttpClient.log=headers
+ * -Djdk.internal.httpclient.debug=false
+ * HttpSlowServerTest
+ *
+ */
+public class HttpSlowServerTest implements HttpServerAdapters {
+ static final List<String> data = List.of(
+ "Lorem ipsum",
+ "dolor sit amet",
+ "consectetur adipiscing elit, sed do eiusmod tempor",
+ "quis nostrud exercitation ullamco",
+ "laboris nisi",
+ "ut",
+ "aliquip ex ea commodo consequat.",
+ "Duis aute irure dolor in reprehenderit in voluptate velit esse",
+ "cillum dolore eu fugiat nulla pariatur.",
+ "Excepteur sint occaecat cupidatat non proident."
+ );
+
+ static final SSLContext context;
+ static {
+ try {
+ context = new SimpleSSLContext().get();
+ SSLContext.setDefault(context);
+ } catch (Exception x) {
+ throw new ExceptionInInitializerError(x);
+ }
+ }
+
+ final AtomicLong requestCounter = new AtomicLong();
+ final AtomicLong responseCounter = new AtomicLong();
+ HttpTestServer http1Server;
+ HttpTestServer http2Server;
+ HttpTestServer https1Server;
+ HttpTestServer https2Server;
+ DigestEchoServer.TunnelingProxy proxy;
+
+ URI http1URI;
+ URI https1URI;
+ URI http2URI;
+ URI https2URI;
+ InetSocketAddress proxyAddress;
+ ProxySelector proxySelector;
+ HttpClient client;
+ List<CompletableFuture<?>> futures = new CopyOnWriteArrayList<>();
+ Set<URI> pending = new CopyOnWriteArraySet<>();
+
+ final ExecutorService executor = new ThreadPoolExecutor(12, 60, 10,
+ TimeUnit.SECONDS, new LinkedBlockingQueue<>()); // Shared by HTTP/1.1 servers
+ final ExecutorService clientexec = new ThreadPoolExecutor(6, 12, 1,
+ TimeUnit.SECONDS, new LinkedBlockingQueue<>()); // Used by the client
+
+ public HttpClient newHttpClient(ProxySelector ps) {
+ HttpClient.Builder builder = HttpClient
+ .newBuilder()
+ .sslContext(context)
+ .executor(clientexec)
+ .proxy(ps);
+ return builder.build();
+ }
+
+ public void setUp() throws Exception {
+ try {
+ InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
+
+ // HTTP/1.1
+ HttpServer server1 = HttpServer.create(sa, 0);
+ server1.setExecutor(executor);
+ http1Server = HttpTestServer.of(server1);
+ http1Server.addHandler(new HttpTestSlowHandler(), "/HttpSlowServerTest/http1/");
+ http1Server.start();
+ http1URI = new URI("http://" + http1Server.serverAuthority() + "/HttpSlowServerTest/http1/");
+
+
+ // HTTPS/1.1
+ HttpsServer sserver1 = HttpsServer.create(sa, 100);
+ sserver1.setExecutor(executor);
+ sserver1.setHttpsConfigurator(new HttpsConfigurator(context));
+ https1Server = HttpTestServer.of(sserver1);
+ https1Server.addHandler(new HttpTestSlowHandler(), "/HttpSlowServerTest/https1/");
+ https1Server.start();
+ https1URI = new URI("https://" + https1Server.serverAuthority() + "/HttpSlowServerTest/https1/");
+
+ // HTTP/2.0
+ http2Server = HttpTestServer.of(
+ new Http2TestServer("localhost", false, 0));
+ http2Server.addHandler(new HttpTestSlowHandler(), "/HttpSlowServerTest/http2/");
+ http2Server.start();
+ http2URI = new URI("http://" + http2Server.serverAuthority() + "/HttpSlowServerTest/http2/");
+
+ // HTTPS/2.0
+ https2Server = HttpTestServer.of(
+ new Http2TestServer("localhost", true, 0));
+ https2Server.addHandler(new HttpTestSlowHandler(), "/HttpSlowServerTest/https2/");
+ https2Server.start();
+ https2URI = new URI("https://" + https2Server.serverAuthority() + "/HttpSlowServerTest/https2/");
+
+ proxy = DigestEchoServer.createHttpsProxyTunnel(
+ DigestEchoServer.HttpAuthSchemeType.NONE);
+ proxyAddress = proxy.getProxyAddress();
+ proxySelector = new HttpProxySelector(proxyAddress);
+ client = newHttpClient(proxySelector);
+ System.out.println("Setup: done");
+ } catch (Exception x) {
+ tearDown(); throw x;
+ } catch (Error e) {
+ tearDown(); throw e;
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ HttpSlowServerTest test = new HttpSlowServerTest();
+ test.setUp();
+ long start = System.nanoTime();
+ try {
+ test.run(args);
+ } finally {
+ try {
+ long elapsed = System.nanoTime() - start;
+ System.out.println("*** Elapsed: " + Duration.ofNanos(elapsed));
+ } finally {
+ test.tearDown();
+ }
+ }
+ }
+
+ public void run(String... args) throws Exception {
+ List<URI> serverURIs = List.of(http1URI, http2URI, https1URI, https2URI);
+ for (int i=0; i<20; i++) {
+ for (URI base : serverURIs) {
+ if (base.getScheme().equalsIgnoreCase("https")) {
+ URI proxy = i % 1 == 0 ? base.resolve(URI.create("proxy/foo?n="+requestCounter.incrementAndGet()))
+ : base.resolve(URI.create("direct/foo?n="+requestCounter.incrementAndGet()));
+ test(proxy);
+ }
+ }
+ for (URI base : serverURIs) {
+ URI direct = base.resolve(URI.create("direct/foo?n="+requestCounter.incrementAndGet()));
+ test(direct);
+ }
+ }
+ CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
+ }
+
+ public void test(URI uri) throws Exception {
+ System.out.println("Testing with " + uri);
+ pending.add(uri);
+ HttpRequest request = HttpRequest.newBuilder(uri).build();
+ CompletableFuture<HttpResponse<String>> resp =
+ client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
+ .whenComplete((r, t) -> this.requestCompleted(request, r, t));
+ futures.add(resp);
+ }
+
+ private void requestCompleted(HttpRequest request, HttpResponse<?> r, Throwable t) {
+ responseCounter.incrementAndGet();
+ pending.remove(request.uri());
+ System.out.println(request + " -> " + (t == null ? r : t)
+ + " [still pending: " + (requestCounter.get() - responseCounter.get()) +"]");
+ if (pending.size() < 5 && requestCounter.get() > 100) {
+ pending.forEach(u -> System.out.println("\tpending: " + u));
+ }
+ }
+
+ public void tearDown() {
+ proxy = stop(proxy, DigestEchoServer.TunnelingProxy::stop);
+ http1Server = stop(http1Server, HttpTestServer::stop);
+ https1Server = stop(https1Server, HttpTestServer::stop);
+ http2Server = stop(http2Server, HttpTestServer::stop);
+ https2Server = stop(https2Server, HttpTestServer::stop);
+ client = null;
+ try {
+ executor.awaitTermination(2000, TimeUnit.MILLISECONDS);
+ } catch (Throwable x) {
+ } finally {
+ executor.shutdownNow();
+ }
+ try {
+ clientexec.awaitTermination(2000, TimeUnit.MILLISECONDS);
+ } catch (Throwable x) {
+ } finally {
+ clientexec.shutdownNow();
+ }
+ System.out.println("Teardown: done");
+ }
+
+ private interface Stoppable<T> { public void stop(T service) throws Exception; }
+
+ static <T> T stop(T service, Stoppable<T> stop) {
+ try { if (service != null) stop.stop(service); } catch (Throwable x) { };
+ return null;
+ }
+
+ static class HttpProxySelector extends ProxySelector {
+ private static final List<Proxy> NO_PROXY = List.of(Proxy.NO_PROXY);
+ private final List<Proxy> proxyList;
+ HttpProxySelector(InetSocketAddress proxyAddress) {
+ proxyList = List.of(new Proxy(Proxy.Type.HTTP, proxyAddress));
+ }
+
+ @Override
+ public List<Proxy> select(URI uri) {
+ // our proxy only supports tunneling
+ if (uri.getScheme().equalsIgnoreCase("https")) {
+ if (uri.getPath().contains("/proxy/")) {
+ return proxyList;
+ }
+ }
+ return NO_PROXY;
+ }
+
+ @Override
+ public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
+ System.err.println("Connection to proxy failed: " + ioe);
+ System.err.println("Proxy: " + sa);
+ System.err.println("\tURI: " + uri);
+ ioe.printStackTrace();
+ }
+ }
+
+ public static class HttpTestSlowHandler implements HttpTestHandler {
+ static final AtomicLong respCounter = new AtomicLong();
+ @Override
+ public void handle(HttpTestExchange t) throws IOException {
+ try (InputStream is = t.getRequestBody();
+ OutputStream os = t.getResponseBody()) {
+ byte[] bytes = is.readAllBytes();
+ assert bytes.length == 0;
+ URI u = t.getRequestURI();
+ long responseID = Long.parseLong(u.getQuery().substring(2));
+ System.out.println("Server " + t.getRequestURI() + " sending response " + responseID);
+ t.sendResponseHeaders(200, -1);
+ for (String part : data) {
+ bytes = part.getBytes(StandardCharsets.UTF_8);
+ os.write(bytes);
+ os.flush();
+ System.out.println("\tresp:" + responseID + ": wrote " + bytes.length + " bytes");
+ // wait...
+ try { Thread.sleep(300); } catch (InterruptedException x) {};
+ }
+ System.out.println("\tresp:" + responseID + ": done");
+ }
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/net/httpclient/LargeHandshakeTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,1200 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+import com.sun.net.httpserver.HttpServer;
+import com.sun.net.httpserver.HttpsConfigurator;
+import com.sun.net.httpserver.HttpsServer;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UncheckedIOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.ProxySelector;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.time.Duration;
+import java.util.Base64;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * @test
+ * @bug 8231449
+ * @summary This test verifies that the HttpClient works correctly when the server
+ * sends a large certificate. This test will not pass without
+ * the fix for JDK-8231449. To regenerate the certificate, modify the
+ * COMMAND constant as you need, possibly changing the start date
+ * and validity of the certificate in the command, then run the test.
+ * The test will run with the old certificate, but will print the new command.
+ * Copy paste the new command printed by this test into a terminal.
+ * Then modify the at run line to pass the file generated by that command
+ * as first argument, and copy paste the new values of the COMMAND and
+ * BASE64_CERT constant printed by the test into the test.
+ * Then restore the original at run line and test again.
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DigestEchoServer LargeHandshakeTest
+ * @modules java.net.http/jdk.internal.net.http.common
+ * java.net.http/jdk.internal.net.http.frame
+ * java.net.http/jdk.internal.net.http.hpack
+ * java.logging
+ * java.base/sun.net.www.http
+ * java.base/sun.net.www
+ * java.base/sun.net
+ * @run main/othervm -Dtest.requiresHost=true
+ * -Djdk.httpclient.HttpClient.log=headers
+ * -Djdk.internal.httpclient.debug=true
+ * LargeHandshakeTest
+ *
+ */
+public class LargeHandshakeTest implements HttpServerAdapters {
+
+ // Use this command to regenerate the keystore file whose content is
+ // base 64 encoded into this file (close your eyes):
+ private static final String COMMAND =
+ "keytool -genkeypair -keyalg RSA -startdate 2019/09/30 -valid" +
+ "ity 13000 -keysize 1024 -dname \"C=Duke, ST=CA-State, L=CA-Ci" +
+ "ty, O=CA-Org\" -deststoretype PKCS12 -alias server -keystore " +
+ "temp0.jks -storepass passphrase -ext san:critical=dns:localh" +
+ "ost,ip:127.0.0.1,ip:0:0:0:0:0:0:0:1,uri:http://www.example.c" +
+ "om/1.2.3.6.1.4.1.11129.666.666.666.999/041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100,uri:http://www.example.com/1.2.3.6.1.4.1.111" +
+ "29.666.666.666.999.2/041287234567896776987654327821000412872" +
+ "345678967769876543278210004128723456789677698765432782100041" +
+ "287234567896776987654327821000412872345678967769876543278210" +
+ "004128723456789677698765432782100041287234567896776987654327" +
+ "821000412872345678967769876543278210004128723456789677698765" +
+ "432782100041287234567896776987654327821000412872345678967769" +
+ "876543278210004128723456789677698765432782100041287234567896" +
+ "776987654327821000412872345678967769876543278210004128723456" +
+ "789677698765432782100041287234567896776987654327821000412872" +
+ "345678967769876543278210004128723456789677698765432782100041" +
+ "287234567896776987654327821000412872345678967769876543278210" +
+ "004128723456789677698765432782100041287234567896776987654327" +
+ "821000412872345678967769876543278210004128723456789677698765" +
+ "432782100041287234567896776987654327821000412872345678967769" +
+ "876543278210004128723456789677698765432782100041287234567896" +
+ "776987654327821000412872345678967769876543278210004128723456" +
+ "789677698765432782100041287234567896776987654327821000412872" +
+ "345678967769876543278210004128723456789677698765432782100041" +
+ "287234567896776987654327821000412872345678967769876543278210" +
+ "004128723456789677698765432782100041287234567896776987654327" +
+ "821000412872345678967769876543278210004128723456789677698765" +
+ "432782100041287234567896776987654327821000412872345678967769" +
+ "876543278210004128723456789677698765432782100041287234567896" +
+ "776987654327821000412872345678967769876543278210004128723456" +
+ "789677698765432782100041287234567896776987654327821000412872" +
+ "345678967769876543278210004128723456789677698765432782100,ur" +
+ "i:http://www.example.com/1.2.3.6.1.4.1.11129.666.666.666.999" +
+ ".2/041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "27821000412872345678967769876543278210001,uri:http://www.exa" +
+ "mple.com/1.2.3.6.1.4.1.11129.666.666.666.999.2/0412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "5678967769876543278210002,uri:http://www.example.com/1.2.3.6" +
+ ".1.4.1.11129.666.666.666.999.2/04128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210003,uri:http://www.example.com/1.2.3.6.1.4.1.11129.666" +
+ ".666.666.999.2/041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "96776987654327821000412872345678967769876543278210004,uri:ht" +
+ "tp://www.example.com/1.2.3.6.1.4.1.11129.666.666.666.999.2/0" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "1000412872345678967769876543278210005,uri:http://www.example" +
+ ".com/1.2.3.6.1.4.1.11129.666.666.666.999.2/04128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210006,uri:http://www.example.com/1.2.3.6.1.4" +
+ ".1.11129.666.666.666.999.2/041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "10007,uri:http://www.example.com/1.2.3.6.1.4.1.11129.666.666" +
+ ".666.999.2/0412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "6987654327821000412872345678967769876543278210008,uri:http:/" +
+ "/www.example.com/1.2.3.6.1.4.1.11129.666.666.666.999.2/04128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210009,uri:http://www.example.com" +
+ "/1.2.3.6.1.4.1.11129.666.666.666.999.2/041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "698765432782100041287234567896776987654327821000412872345678" +
+ "967769876543278210004128723456789677698765432782100041287234" +
+ "567896776987654327821000412872345678967769876543278210004128" +
+ "723456789677698765432782100041287234567896776987654327821000" +
+ "412872345678967769876543278210004128723456789677698765432782" +
+ "100041287234567896776987654327821000412872345678967769876543" +
+ "278210004128723456789677698765432782100041287234567896776987" +
+ "654327821000412872345678967769876543278210004128723456789677" +
+ "6987654327821000A";
+
+ // This is a Base64 encoded keystore containing our certificate.
+ // The keystore itself was produced with the command above, then its content
+ // base 64 encoded into the string below. The helper function to produce
+ // and format the string below are included in this file.
+ private static final String BASE64_CERT =
+ "MIJR0AIBAzCCUYoGCSqGSIb3DQEHAaCCUXsEglF3MIJRczCCAyAGCSqGSIb3" +
+ "DQEHAaCCAxEEggMNMIIDCTCCAwUGCyqGSIb3DQEMCgECoIICsjCCAq4wKAYK" +
+ "KoZIhvcNAQwBAzAaBBSx1wdTxGqb9z4exOHVZNswvFL+oQICBAAEggKA7JdM" +
+ "91kkP9QkG/igw2p+prxeEOQSmyScKMLtln81eKvT9zpvNjtT+hjABcH2QY8u" +
+ "1Z3Ji48Umoaxi38Fk58/VazFM6wpL47VVNJ2EeTdj8sFoo8ExCH8EHJNNaVK" +
+ "VNTG0YWOMa/HOPttl5wtD6pReGNOrVYVOnI2aY6zTqwI0sZS4uPczfb21vyI" +
+ "NyF4B0Z9WGl77PRoGwrSeoLspISBTq6/JE8UhMWtuz7xnXw04DGp4DeIOO9n" +
+ "E8+VBRKOELPqNaQ+VEgnwPNtPzjohi4Cwaf84c6vokAl1S/V6GzS0Al1mSGH" +
+ "syAaszDYWcXXp2JpSXVAztySWZErwHE49/P42taXdhJvOSfqYb6FHpdrCXST" +
+ "TPo+ULCGxQ83EGfnb/qaqAYZrS//+lzzqw18OY0JcF1i+cGHY8ofJK+bYr7x" +
+ "ZyC8pLut84pEWNTp1V7SQcMif2Gd2SO2Y+ua4isjfMLNeNE/4puCV1vYsyiz" +
+ "C9Gnp0Jywv13ioaC24Qy68uVQ81TvwizN3j7FxPCQOEEjXpfJ+5x2q0pUfqp" +
+ "Roy7ow3Z+d+/fpMIcgyMqWidzLBChRkx4Ugnh7rYBfY1ghchlu8WIIhiR/8p" +
+ "EBX5WQHyEtwrXOFiWxT+QwXWjbs9dQSUoCU1i2zwCFW9R8FkY2yb98QxF74z" +
+ "0TpyW+w6cGPUNUd2T143PL4eGt4rGUBUMewe2ENSgZCDstvtiNPfccW8f9tq" +
+ "G49pHBZt1ZIadM/DbCk1cqDD3u2/e7c57mInFkBBJKjl2K7GK9EYsiey+3Fk" +
+ "NvkxbaF+89OTqEDPP4E97EeHkk/MFe0bQ/a/aXZrTPSN7mNgusWBQyztnYex" +
+ "BRr8sPRhNDFAMBsGCSqGSIb3DQEJFDEOHgwAcwBlAHIAdgBlAHIwIQYJKoZI" +
+ "hvcNAQkVMRQEElRpbWUgMTU2OTk1MzczODEyNzCCTksGCSqGSIb3DQEHBqCC" +
+ "Tjwwgk44AgEAMIJOMQYJKoZIhvcNAQcBMCgGCiqGSIb3DQEMAQYwGgQUBIoZ" +
+ "0r5Kc2cs6fHseA1vKWpQi30CAgQAgIJN+Lch8gN0kyMcpdNDM2iAfBHd/kXZ" +
+ "4ye8lmGvvV0Yy9dd4Q6zmOmkPjWcusyh/vJdya8OG8Fxc/nQmyhB441qtJR5" +
+ "dwIQe/7lft2gDg2sBD0osPvEHesvFVr0+2cy22sdBXS4ihdtVTciPV+4v0EU" +
+ "AK6Lcib57Ml7MI6VhBGpWLkaZXv/25CqXGaiY85dSXPHMugvfJn8JoNxe+tN" +
+ "PDEAy5ar5bnSD9Xl8GyQwHFwQ1P+gEjwg0+hC6OQA6Eg0jBFhIL+dCf6FJwz" +
+ "J2HekpKXcyCTNTx0HB8AW3u4gVjao0B7oNr0GZprpPgYp4dl04Tar6fmb9MN" +
+ "w4MWkcySjX0wCNjpvE0bWlUx55jlN+25SWNEafmbzRNECW1hT6Xl3HLLNQQv" +
+ "8fIgkd2200+Ppwk+cG2dYMrl0MpHPxOo2l+nLNDI+a84v6R2Mqf3qVNfcRxZ" +
+ "Xmw0kJ1JNUKhd0Dy6FKB7tY1Gwc4rfQQgdUXTlnB96rUrSK2o91QZZ9rN3PD" +
+ "SbbQRzSBSPMDen+W5878kwd1BkDH1ao7qOHoGYYiYxczkMVncOtOIdg8VScU" +
+ "t/N1NS9Yrzlj0aAYwX5EYmYzFMiyXr+El/7VnrLHBiaYwJaYVw7a1HgkSXxb" +
+ "er/vgM639AIhT5ab9NFF+ib+7qwbWPzggIBtfm1bXiRPE6Ue0+aQ9g4vYSR7" +
+ "QNusu/2Kwyrd6cwqJnQnG53wiSXh3hs7dvNRYpM16iF1dTeud0FSpQx1tMFi" +
+ "Wp9cGwtUSzvLw1+5Mvz7igLTNAPyTMFNAYFR7JZgRjg1035Y7Xo4aXNMVtGp" +
+ "BCa+/eJzE33CHH2+kuSa13N6qHA2Ek33aR4Vi7P/QOI1aghsR6tL62ctoq4c" +
+ "FmRwvReYGdFK08+B2auPHOEPdGaPefydmPNnFLDguH6d2NYIH8cgzpjz48Gf" +
+ "i5UQfh/UJAxricLjuV2eor7gZCCaC9MfnLlHnDH5MYUQgDsGBTRxh6rpZxVo" +
+ "PFUm1DQCFdDHgmvVz+GAuiVzUu0TrUAxBeycl9lrDshgZj2jd9FU7XcMFwzC" +
+ "dMsWJaA8EC8u31vnpWWqK8C03pdXTbWOEJdIDMXKOzd2ZxjGPnBSNXNRsGzi" +
+ "RdEspHElrfGwHA5Vpsj4Q6tMZ8tZ+gSSmBrKP6xNUDNwi1bPayJw/dAKaC+D" +
+ "vp5sx/+nZcxSF/ig8ZM6aA3escS1GBNBWFrx2vEASHNpHZsTIOTuOM4e584/" +
+ "NJpNlRfaTzJ3i9/XoufnHbT5pmpZgxlZckYto3h6lL8R0bXthICRrI37Oh6s" +
+ "yfO7zhMiGoNdaFAnXTsMzA+Uwr1gesHWE9Rbd+jrkcGgL4Zst/A/c64F58qt" +
+ "J2RzA3xJCGQ6AXB3SlDHLObuYZ48TH4v2nJ4S8RTs/ant/T9DTRJyhQMa9+P" +
+ "QC8Ny1ejFOK71Oqjz7J2jGpoBm3gDRZDYeBa6ZiMeJf8Q+bkpbEgUQbdiXhn" +
+ "dpN7acdJTSHnO5/3Y4G1T6kLNzKc1+NYiYwH9Y6KIMa9IaocOA4wCHEFog7Z" +
+ "Ac6vFv6r9/cnXEIe9/t5gYLL7X/gU6HMqZFjM0QjRru/Sy9vYfpytqrnOf/q" +
+ "eOTJ9gRdIn7jNVTrgrE3ZgNvxYapaDMyFG/ixZV0cblsVJ6JO4MArOQq6q9/" +
+ "LWGtYYEDclyLNxUTYf0gHmVRhYV8rlyMKXtDu0aBOOn13dRxKKVN5pG+LrKe" +
+ "V+FZ3tDhYiFBxI/gkAiegSQlvknJlbEuanCWFq7sHOZ3C76L5G4qtRv7tHAs" +
+ "8rtqzhYnddxIkTcj4tkVYsFxkj1afSuLSSoYqc0jYZUXHkL+5U0ZRxhJbo6b" +
+ "/QVtiGXbS9i1em3+Yr47jHRH7f5Crlc2EdEzZaIm8tCw5G3CddXhhCpQTT3r" +
+ "Mjwep5/w2ai8qbGC1xo6AV7ZyQS535UbIhOYMPO7vd3oUBmQXyutSxx8Wedx" +
+ "HbIlBdZ44JlRWELdL6Ejo7PwhG0F3Zd3+FtasM13teYlbDWdFeoTF+inrXCG" +
+ "BCSqoUDYLAAxRK7oYKSDqfrcRioHO4AkeaF8x5YZpRSM73yawZaWeLVq1NKb" +
+ "DdeSJEjqDs5Ve6cA/jSLDtlJqudspFamzkdUWa4L1Tc15JY2YD8urNz/qXUK" +
+ "E74H2MtQWjrQ8Yjz7y+3yUTYd8Clp1dBKV2haIr+sCTnFtUXaQ9LZF5S+enU" +
+ "mOf7OmdFObwvV1f43HDuDSiFZpE+w57YmAgSIfWelKnGvvn1lBBWBomyVBKo" +
+ "69seibaSyUXyuq8q3525ZKpHIcic7doYOYgqU94HBQOwkwTtoiX3tKX4EgDa" +
+ "9AjYD4LHITkwgKzsQAe+3ASKq3SPFXi/UbYuZNXdkXgh7kqL6PZPD6ayIxOW" +
+ "f8E95fZRXPyNbKf5U9pp9hVKeuOPKbEYKsQNG0ZiephMmV3S6JjSqLo+qTU+" +
+ "QyGH3vhwlhda9cmxrpKCy0KM8AHyWoS4L5TAiJXp6moCttP0v8P/RRFtBePl" +
+ "53nyLwZ5SyXv4ifVayJyyeDXn08In9MINLRyjvNF2gHbHI7XbeQKqB3yIBC9" +
+ "sKpyShX6UKb1Dnd3Z19rT4a7QUkqfcodX9cU7tV6ncRuP5ZJRLHQQi9w/2DI" +
+ "Leu8Y43jJ/CWYo8Fb8IXHrWA/hwNT28Yr3OcZUIDFdbdxenTKyhMlDOQ87aU" +
+ "VXBCnq96jEAzY0NY3PZj+CBvts2wlCJJDhBCVTXM9OusZjH2/B6phWO7ybMq" +
+ "15QqYyypNM62oBlu82psklHRREO1D23MaOyoXSHYVFxvLMKxhstK3wd59cst" +
+ "8V/uvzzrURJu85X1X0cQJaKB+OjvBT8n8e9jzjATOTiGH2ULLSro2wc7Ne1r" +
+ "bEK4qHeuSwlvulvcqB7wK84PItmVOW+g9VuXA9QGGHxzybbs+/QaMqJzdN6C" +
+ "oS1Az5UmvZbdnSAuXtW8xiKJ+ELAGCjOcdkzQaAbd8Tq5hUXAgYeNQnoDjJz" +
+ "+a8CTk1IaGkeHlg7MrV98AuIQjUB16IU6gE4MH6ueOIZhF3PB2Fp0dGPXL6O" +
+ "KzIiC3jM7rIuTmOstI/t+XB3+BYxKvLuQhbV5n8sUBsGFFGBKoxIZawKG1Pk" +
+ "3Dny2rzcB2JkcOO8r6f0dA5V4PKIrhmVeQJyHgY+/fF+JMZxfjYmaSrwu/1R" +
+ "JnlDfDCIwNon7smi8QwXbEvRehI5a883yI07COM1paHBKNddlw4sfkfbIrNx" +
+ "LQJLb0mHgqvHAblivBmMuaiZaK0MVOgZTe4bYuYdRSN8/ueZDHOo7lyfXGzc" +
+ "8FEThaiGp5m/uWYJgG2FIRxM6by9PhusaTZgJ8DmjRLF5yDuR14gau6zj7GZ" +
+ "TMXGDIDTRWTKTP0/DYF+EEnuWJb2JrrxMnWH8X7xXhrRA6Ku3nqVEwy8eUnR" +
+ "WtLAQkApLOEhsp3wQyLRbaydcD1Si9s5JICy/m5Sv2NXseKbmAHDphTYuSGr" +
+ "Gjk5ryTEaaiULVvi7mv1HqDq3fli/PAzMIcsK0yaF9rQv7JjtsOtZtr77+zs" +
+ "vM8CSY835WpqTtjGDC+HWHulEADgS4ShpIrn3zgyEd1jrRY6rR5ZDuioc7sE" +
+ "2A/8w6I5KkmcXMu/jKoLjotdUvvGMMAIhqCZD8sD+F2jpNcCV3/7NpwaJSk+" +
+ "61rfPxzQRKu1jn/9TV7e5PyWQMkPOMbTMlA9jJPi5WEXNanIFTJBYgI6vmYc" +
+ "156uLrlXh4F5gpLN42JyhddSbV4dXXLt8an9X4dMAJmdgBmzFldFPU7I88Xm" +
+ "nuy3Rkqs2p4eb44b4oe9xdIyUw3fkfdoYzRx96X2Tvlx67BvbprglcdoiBce" +
+ "UitoMsN5tI9+o4/wp6SCU1nv97Yl/kGR6xyY/5irK3wVr2DsrRSF/WuycPFV" +
+ "3EOZLCoh/Y+9yH2dLlslarL2ZVIe701NTp/fN1GCQoCI2elSwXZAiJ446Fyv" +
+ "F5x8UTIbAZKiJfL8F09XVnNSRIp78rcNUUeFKehewGJ/I6WtD/SyGc7uTCKi" +
+ "EqXAwoQN+4GcncLQ2eqFFqR1aZLEcJKU79EpKu08rFTl0X9NaA7Qd0nXAiNF" +
+ "EUz1Xo33ReE9l67+QLXYK17UIqxkFQnawydZKt1T7HeRpTKEQzo9/wLk+IYD" +
+ "m5y8DXHK/d/kPySyLW4+srw3HRIe2Cuz9nNhPTUKtVC9CPt9NT9guhOhDGRA" +
+ "XBkF08Snjpn7wG6G1cE2gwU3W4oQIvCAwpdsJ8leg0fbosc1UD1QHR+3CxIU" +
+ "0yoPm19LygYjIyTg55bGBID0GV+DAHKUVHIUkBpaPM0PcSxsJgFv1seuQSJy" +
+ "dRUcKGzPg+xJhVvHuuAnnlBibjzrl/DBLCPgOl2kybpsv1sLJdTLEkwkv/yf" +
+ "83PdSz+uPha5hv7AGfxEaaUwbnktHultVbjO+IKBNqgjz763XgUAKbtfxW4u" +
+ "VLBESpZiVe/gzgNV7j+6+vHWsOC8GBMjJwHGAFfTyjYv9BmrxkQyabZ8wCb/" +
+ "5NPvaHBH+qkWVVWBaLZuOkgG9dmQI/oEcO2H9IDtve3OEXGuP2zG3xkk7h8W" +
+ "RwcHoz/anAbEHA1wmPYn/NFn2FZW3KxdyD0/URj4DaZqMYCJMCN8TkbLBxQk" +
+ "ZS+8VCcXMALybXUD9OLX/jUHaPqO70e9+o4cD+O/JfxKkTj5A2WD2345b8nK" +
+ "Lill7lJ5JlYekkGG4LQf92FbH0ytLSVB+A4oc7/nxI5ciWy5vDmaG+3HS5W2" +
+ "mGxnpLApVJZhhiJRB5fjfgRiuVbcGNWFQtgH2imMorrE0FzONSQfepLtBSQM" +
+ "Ec8NWgmEa5O0RIYLMblXisxt7jB0k8NqgiSm3dmNmR7GhbBt+mg95uCXWmB7" +
+ "nbcUaTWUw4Lb1EwVB/MmUEBjer/JYDADWz+NS/0VcAgBbjk7vrjAdgXkgiRB" +
+ "l9qBDioO73qjmjeTiCjoLsuEreXPu9WTaZDuyKO1uxHoesZE0AcWjcZgKVY+" +
+ "1Eqz3awCUxQTH+/1HsVxONmbYzJgMZ3f9Kuk7dxwFc0jgIw0LfFNnBDW3wY6" +
+ "nrdtm7vEuR0gfYU83oqXQqAMQGwMZXKXtibS7yPL+rinLwcoWYkZaIaI6LTb" +
+ "3DthepCtsYfIpaErOHMVOqxDUb4n5e0EUJiy7gw9JQjDX+VzpxAnt2Kc6/fl" +
+ "kon4xadP5oyNx3YU+jIywk8p/NMhDfia0fFvl2BHRcgFXHyOa8IPNmRb0CgO" +
+ "78Zbt3NG2+cFUx1WwOuCohfoYt/STUnxDXpOCrxYk2CD09Vm+2xC+7+VLfex" +
+ "UnKzKH0tWLNyzA5XKSHyLe6lJCO+mvgdp2vrO7i053YVfqfqWSL9rhR0tH5w" +
+ "NO8uUd1/ozkIjb74PSft0txTP25/c4/MEWy2JIg+HMM+2fmanJi4xJsuxBfq" +
+ "2p/7AYfmsp05TfoSLieWDBNx3lrADGUnuPf/o8Zo2tgn8ek4ig706kqzZy9W" +
+ "p1PaYNK6p/MLI86Sv6OLHf6fR0u6IsGPqMcYx9J7U5SCemntLvucfWRAqRn4" +
+ "5htDzdTFrtO2nXLNDxk20DQtol7yyBg3ngVX8XDhKReGdV/Z9kEeJhgzbxLT" +
+ "fbjoGQD5twirxYyV+eRqQZM7fu71Srg6lz7najEyH9pbQjpEPForDy5Briry" +
+ "nplWImdWd+KwG0N35+H48kpxAU09sOUGURzsUPdwTANQUnrWWMo5+UIjxXtR" +
+ "cDMuQmj8vlYH8iH0bKgexZMb7cRciRUF3az3lo24FA6l7e4SkyFErGJITGFN" +
+ "IHO7wDz9h4rLikjGkz4G1d04XQCxrpHSrW9fj808up1LSoaye5ijutJihEHu" +
+ "hkiFLi1nwuhd4ZrAZD+0VkTde9GAi9xPa8Cx+lh4JMB5mghk8uTjv7G4KqzE" +
+ "Wlpos30CMyCc5cBGqkCVLKt64+KgUyt0FnU6tbZve7i1/oYyUaWx7BCk6o9f" +
+ "9PuQM2bOwqhjRtpBR7q9Zb9H+qytAM8psLV6Sh9K0cK5Ug4BBEAtCK+JHBHG" +
+ "U3zkhu2FXlm0Mnp5xiaTvPwPWe0P/mrD4Fhgn2pbPvyJXTPgWV107zafKuLW" +
+ "34/+ML8oog69/oUOSAw4vaJx8PWguMRoQIsS6ATT2RhUVn/t21fJK9j6eF/B" +
+ "YG5IIEavyybQMILx86+SI5sLi9j+Xqd5bPLWnZTataP+voMTzyyYqAi6ybEl" +
+ "4QkWM0c8t141t7FULXHMTrKhdZDocb9plz3sfYk6cEqlOphvmhbZbT88iWJe" +
+ "ndBHJxY0SL0NQ7Yl6fg/DHt4goXSIWGL5IamBM8CZnVwyCHz7laP15Zsc92H" +
+ "DqWgbojeMxiPSVnFqxFzL/6TBBTQYuNl6+CgCOPIe88FwhZvfwzXVnQHb91i" +
+ "58t7pwXCURscYFK7iyxi7QTrofT0QM4upsI3zBqOO0X2SOW5H6Dx3uukNP2r" +
+ "Ud0AbXWHglnooaMNl/XRfYyb6VYg28r7qcfsSKlWuRenNf/ejaLl6GeO/ef9" +
+ "VI+ia0qv7S2Hi6xgdw3/NTqltehTyZylC7LtKr/TVRFdGLsFKtGvT/KGMYt4" +
+ "eUYR1zz61CVxAjjGAg+NlpTG8P50xralMthUppA7P6X4j4cDrD3E74HYg9Zv" +
+ "4PLAh6MOymj0YbW+/QjbO13DeSXxYX5/EGk78+sBOVSzvigI9NLvWHZMFylp" +
+ "mi5m3Wh7cQojpkeKXSw0XRd8lSeMN6lrzkMknniWfZZhK3idGCH3kHd7IGzC" +
+ "X67K3gf+8syXOIpoDfUJHVpfvKZCw5XN2huYNGKP8KqELMoDatmEoB4hoVq/" +
+ "VIssuwanWj3vDOxp7bYRUXID9dfTrgq5A5+1RuzrJVpmK+maTGypBDvemJhw" +
+ "OSP62Oa+1ryH3+e1yqWDbWJrDts1S1wqMRRG5LKP16e3ZUYo33Gir/qott4b" +
+ "J3PSvZn50KLnkyt1apUGE3pIyytvencsCca26qm+EGLYJXu+njUHIU+s4z5Y" +
+ "xxrR4xcqc4CKXKK5+z34YCkdGM8JME8fCinDgrsixnYCjyv367LrQ+/YRvtF" +
+ "6gF2XrCyPNTtRisqHg8Ug3CSKMPYJBXO2uu8/9dxF+r8LGv0pbVoPUBJpPiL" +
+ "+tnxY0ggyOiU2zsUfb3QcuHONXU/2qv9FxUzBZDUDVuhXeCgNDtfv5QN7R2S" +
+ "VoWWQDcQP5Vop61TXUhLnNaU6LwaXsVIIi9hbv4k7LV3tOxgjtyddymxch0x" +
+ "4mR6XCXVwPx3yVIEwju7ANKsDxR+yT7crRYpPstka9lY8Y73w5MIgz2LVk65" +
+ "xJ13puMbAGnCuSEuQgRdPHyt9JDp8KfvQ0/FegDE1axheKVAfCKgCuAudIxZ" +
+ "UGXjPXLh4hMp+o87hw0Mkr0tfmKBd3KzRkjZm854ksnURKPODIjEqhHcW4t3" +
+ "gRQ3cYiMqcv0cDd7cDw/4dFsfJs11aXSF674f1lhOjYqB2Xa7EMDQxJC2zw9" +
+ "6HPVKHmGGSNAv/UiJHjcQuJslGVq1SisnSWgpMND5+QnxHDBww1p7DqXpDQJ" +
+ "boHjZKPM/gi9N4GD6iHGbF4l8Mx1YzuzoAbqqg/6v+fmYQRUgzGnNRHW781F" +
+ "R6J6R6JwNOVTaSvlDFzQukHdwpyqcR4OM6XkaxNK3SMRWye4O1/U+12FhPYx" +
+ "5pPHMId8d8voJIIMPYRjFIkZAWpYbavjtV5x4xUWu/Ch6SeZ6uQu5h3WbFVe" +
+ "buXjnOQbVIixTh8qo1WXXKiG9DUYHowgz2XWC45izfOnt1xwWj1He0IQoYWg" +
+ "WkePdJPKfS5igRdzjwEp29RlLoqXj9TsICzYhWY626A3UjnTSOAg8Av2iWxx" +
+ "j+3I3zA5I34udiSf/4iyrWZHeaLP3S4wIDrTTNzOh18NvspyLJrjoRokXwoJ" +
+ "g5BnQan1rHl4p2e7oNLPhc9ewKF0QWdi2rJZDY6qO7sa6jt2C57g8jAYhAFS" +
+ "2cXjJNQAPCgoodeKTnJ/1R6Ykk+byXzeDc1NuHPHiNbtGu54Hz5Xd3P8hYJ3" +
+ "VBYvhkF90Rq7LvBBXyVTy8tL0I0N9BdCQrnd94HPm+fMj/nwc0pqCi9b68ex" +
+ "Gcr8YM3vSg9xRHEBXsWjL16oKchvwavauC2Uap/OEizdkQUKBZlzDazbXTN6" +
+ "dZpCyFcB+Ox/zgltv3jxum19WdgjyIddqBIyiKxFtC3XunK5yvmr/fFZV8X3" +
+ "vxbxV6y0QPqJDM2ctb/ndiYaGn60EJQjxETGIanp5szgKFBYs1p1mjyov5p6" +
+ "p76yEvTm+Ba+LX4ngM1AddqyfbPYscxtIyhUsqDqQ7vSNHQezTBcz63OclbJ" +
+ "G2SyQFZfZKIgUXiZt+ZC3BwKRBGQZUE+UIV9WjrIvhtZN7A1qdo42c0S/skz" +
+ "lHMKR75/PxVVXRaArCRytERwdLOvlyBE1xl3rxnxErTQHViP0xEzOfOpQ2M2" +
+ "Ds9TcXkm66ZRnJBuk+fp4m8iiz7IfRlrI8y4AUuI9LEaFOKkh0HH7sjSWzs5" +
+ "7uGe0eBZsLpzWoDd2Uacht9+xLcnn8tQQ32H0KHkZjm1UGtbSyUSvvoC8SQk" +
+ "U8QstWumKzrzf3/GYuW43N4TIBUvl7GWcpmpevuAicl6SVeDjyaSGp1n/OUM" +
+ "FH6e6kSgyDvrs/V/pQran+Dymby9DPV7fUWNo51rFdqvLhktICGGWRuUXjvA" +
+ "eOOk4JhsD4MSlKysuGfbcUhFnkhjFkctA63HEAPAKNLoQze2tRwG+tZhJuAp" +
+ "Q+3YEHce9DEVo/13eYVKRu4yFqD0G+KAkwcXHcFwH4b8ByTJ6K4BboRIpGAI" +
+ "sCWN2r4Yx6sH7hDgDH/ywTs3xTI+JBDGk4+15EXUSVA41bCKEsT3BiksVE7b" +
+ "Uo2eXPFkG7ikOuyMr5xfWtIN5v3tg/lE8K45LtWgOT2mZeEZVEVmgozGwR55" +
+ "OqZvFeqdZbV1l57N2vSf3YkJFU8CRwd6uDZ96C/Fax7aL4biwSragaXrYu04" +
+ "XqqWIJVYOZQnHHHTGSH+C8+NEZJiAEH2ILRlqa8VCTGPTVd96+tVriytRGFE" +
+ "wG2xl4jYviismG73MqzuCq6iwx+HaWTiGSlXzMfhKL0DE3rhPmWrKIjdR+Ub" +
+ "Lp1C/L2mM/y+DEMoj59/l+SwMaijQY6oUpOtVGS+Pm2C03JFNSFZyYo+HHAC" +
+ "OkBnWMUKCGWMWOejGaC4vtBxZsHn7Q5ij+9diNfxyLEWc08L/muJG46bzlHY" +
+ "+t6W/j4UdYuizHNm1og+DD17Kbxk7fjRsQr1ARKeDkw0RgVZrnMzfsVeNfP/" +
+ "tQVCeOlsgTa8x3j5eQsR7aJi1taen0BQATTprJmN0428+g3Sgh+4eLslkGfi" +
+ "9c5Ftpq6vM9bxE5w8PxjPdQdGQZdcNkDHEreAmGf8Tb/r0ODx9wMdYNRqbq0" +
+ "Uo2Y09Q9zm91bPC75IGGrLvzc1X0MXqQmQ0YsRFq7T8j9wZqS6+bveA/Svd8" +
+ "pwfzfR7GWDCd1lwzuP9QezVrYYcozCquJNMFgCu5hcCJUb0RdC8EBsxArcP4" +
+ "iEM5+R62j5eOOBMikMgLpRsTQCFxBgFLiqv1sLBe1xxPIjQhtx2FJvuxd6PS" +
+ "zOVdplRe8WbbN1XZUW5UQJH3fnD8OLpAlWS6xas3Qk0ZCl0jNqUYANUmnuJx" +
+ "SysQeI4HRF0pvthikuZBzpS6gkxDf+CyNbJa8DZrwc+cZje11KWkthn+DMdG" +
+ "sODZI4Z/wUGBRB9S4QQSaHUajYbJ/wfiYopt884ophtyjW14oBs67hmX/nZy" +
+ "cYxmJnEaqcoJvSDzVDnK7YVwV6dV5pmvFe20fWuk9nAdtWbUyk1dXwZrtx7y" +
+ "Yw6N93sAtlA+a0xwKDWK30PUU0DXuVnaw5pejrHznj1gM+zCycZ0jAQkq5Nv" +
+ "I3VkSo6+mDhD7VfR16p5+cPgjabFb1yJYjit44H+852Tr1bzekpO8qdDw0un" +
+ "AOjou03PaJURRqI7E4oHPA9kRIPEHzqJyIxVJrly8hSMbbVaviZOLSzbxrvI" +
+ "J8qWlIenjvtD2m86tDZ/0V7QEek5bjlpr9wY8sEGtBhuWdRukWhHLm2RlmPY" +
+ "2pqodKPSiDxAy1mDQiOEMAhHOfrABDKroLsVOBa+zZyR+MzUcBZk4mhXZUmo" +
+ "dTaMjxYykxeOqnnlapKaz7qwFswwRrXP7n/Pa9XTxKpJms2s2pJZdKhZlAvp" +
+ "E7KNlmCV8ag2hhDF300Wu+J7syVrNffpqnn4jT8bdgL8orfAXT3dgTzwplni" +
+ "Fa2C5FQlaeGSG/7yM7qUXChppyAOA0aa3Ujbet9tf2PiS4+dsLjV1ynanz72" +
+ "zC0bbfzdhZBMY/mYEq6GBAH8lHpAWaoVda66iIoBjNk6+qtv/ShnEFmRawLy" +
+ "3KWyNeVw4gJjvejp+4Ch2I0zNssPrqcF6ne3k/FxB67eng7kqkFZRfC5xbLq" +
+ "NVG28rtlDCVVWkcbyPgo3cMaym5ZEj6Hf8E+Z84PuFhQBw7gJao781M0ddV2" +
+ "RIypj36LsxzzhpSPfmM+GHBtLzvryNqxlzViaHcsPBoh75XL9tQSPVzT6436" +
+ "5c6dzaW7lkak2TiPoWucxZvjh1PVqoijWvHv/YGav9ffjJef9TfREsBQG+ym" +
+ "Sw7Z4l7RZaWjfr76sO/K5FKlUmw91k8LyFeRtZ8gBIrGdV1j1DsHktHuH8/K" +
+ "v/lHolVp0QPI7vyrXRcZd7ccJv05dm5mj+CNw7JHvAHeIps1goDamOCROexB" +
+ "ksW7YqAuzex8xajTKtaESP3D1kZYz9BZ16sM5LWNjPNdcLygVHMBV7oAVepj" +
+ "tOd6BYY4xfFDSWT6UFcz0v1GgdsQaszcQdCoRL1XrCatRKjSvQDN6QGXUc22" +
+ "Cy/JqD3HHc7cqL8y2WELIPZcLNyDFe3P5Psvkcs/hysQPs3XGhfbWrvSarmF" +
+ "AlwFT5hJEy+pXeb7x+jNjOxaj0vq/k1gyXm1y/pWPZvB//MjLA8tU6mQCyUC" +
+ "U9wjAtrieJRAdZc4pqqO7Ha1Iq50vtdLu0I2mNn6M9/b2IUfwqziE+rBdXH5" +
+ "Wj2n3+TQed5xzpJIqG7iJQbOEY4byZgVmSQCJHjWBU1yaK+gkTGunPbv56+P" +
+ "PNYZ5uUJPWCrWSkmRow4Z8B/Gi1IMKkAsEsv6i6HwomZZoj9tZGpXL27ZKxC" +
+ "fZMnyIN3QMXrtCb+RHcRSTWlgraLfVMZvjtYh2Kxwb1wB/Lv6ClHT/A69uYZ" +
+ "QNSDQCCxSOaAOQoACjh2bj38g08nA/rGXUYft9LTEKIkqUSf4fMTc3WzTaqN" +
+ "MzZ+iXnNMPDYWSWnVOZ21HpkOoOID0zRbk2jBy1B0xW9kcS86ekhkBXhKYxw" +
+ "x+J1k3WqsMVnsVqPWWTRU/G5OCfgsVXfYElFlrmM3f3jiMADkdBsfEqrpPt3" +
+ "0QsVHp4T8Q6WzkOV8D5lIGdLKsF++8LSjwLjhERWXdwooq+6KoLPm3cm9Tiu" +
+ "LMjtfIfVYfaw09zXmKqOkVONEsZDLHTztqmNWNJJB1Ay5iL7QPvSjKQS9WIQ" +
+ "TJOARZD0k+qUW/9a3QHaeg3O9aqYFMxf7QO4FCHf1TIMNnr5LGoUIxC3n7Ki" +
+ "cB9MlAunuFud8DiiB8/+3QgslIVknChjQiCeZPFsJIszUvPooQJsRDcGXADH" +
+ "kXInEcaqT9EsHYnWwDtmZ7gQd+NgT3IqvlRJRZ6KXmyuphamZKieRkOIplHV" +
+ "muUq1T60+6tBHld2033XYtS0qY81/fOY8WbvjCxUjF5xu/So1tmW0tqr0l3y" +
+ "GGp8jyNE6vL8/gJgobfXTVgnZhPB86D17FNWwEWHG/dBis7gmo0mkZRh9+gk" +
+ "PLAl8E3UFqWmTLknSqqcI6ajgkyI3nmphyLc5H2l2mUYRI+bCiOunlWGGzMq" +
+ "Qj2oSuGdOYX/hNn7MfAYmb1WNwpopBJYHA3VKIKCH4YDLz8h5LF9v1iHpZT3" +
+ "IiHf1WEwC7JpI3Q1S09sJMjSih5dctNkmoCG56gJ0ZjmJvYhWy+A9/Nyd9qp" +
+ "oj0E6j0hf6p8dovu1eE2BqKRydCa0T2i+bPnNnB21KU2MLgV5NGw4tyIfUoR" +
+ "Ui8QSHDynL1Ob1BUbKuqT5p0Ybqths/oWeBN032wA8DOblale/gyz0fXWWTh" +
+ "VqD5ktw5SGRJTmA/tJfhK7kFfMdk+9Fsvw/yV735NAcTorVbOPJoEWSsq7k5" +
+ "vY1qreQO6tRd6Gx8aeHW0st8w0Cyf3UpLi8x+NcX53WJaYBhXXJtYZlEnZ3W" +
+ "do1Ekrs6TWrnRzSUk1uD3Ku47Gpd02hOTfN0T5lUUjaoqRLuvwyYmQiU47Ww" +
+ "Wnb5ftTAoljtH2P4LXQZyqYWca+BgHdSjlaadtJ7hG88zgSHomwu/QVSVRSJ" +
+ "zqW+0ekjRr45/9gKNmaDdFwZ41HBgly98x4Z1LzcimtylmgTpAmowJRCBSV5" +
+ "uad7WgR5Pw2LKWx8YnPAD9aJ78DfSA4LqkULHOfVfqM1CIDO92Makz1gL6bM" +
+ "6jEpuNkQHE1FifU31Dof4JeoGC+w6V6UjtmUrilKgq98UPAHHU8Bs3ADfXIH" +
+ "w5Gz/LEjwmUL5pEeFft2PMzf9HkgKcuCFrg8by4PgIv4wMiE6gXZCMfE+Mzd" +
+ "fulMuy1opZB6LdObgrv8uzhfsplRaVl4utuTGqg3ZE7PyZ+a2nVTBDj3Blx9" +
+ "88gBN6wjC7MnTRR7C3PlVfX0ApBjmX84Eu9AF7R0zc+XlqsguJK7KKWq9BFL" +
+ "xXETLlygW2oux+30km40WiZC70wZJuG/Y8NzPwZd3JiJ5/cVWySyppfBD5cY" +
+ "k6as7/9oXDj5OfXilXXJNnzMSp9Q9h0P0do3qteAp3um6ixvnE/unKtCDua1" +
+ "KuYbV9ThI+RedYYkYdyKSgBiFxfUtMmYw1E3tqjxm4vNlGJijmBM4HbEmR3S" +
+ "okiE+52LKS4SiNRNfp6Hbnghld56n/Bpjv3jsMlwES7415uKmAfm7pRQrB6I" +
+ "6MhGGYhpATf+q3iImH5nSkYt6OCyBjjII17Dkrs+Au/wOk9xhY81j2lua4hC" +
+ "VAWiv8lXTznHxcHl0e9w7lr2rqdl74byKD0ey+GT15C/oRYGM2LNTwNK/K4I" +
+ "hh629dJF+od59sUGg3fJ4qPM4cK0M81VxE86TvZP6Nmbah9L+uqVrnA4IT6O" +
+ "BmiJub1LG0awl59Khw/Nvc1wxje0dr6cuHQuXM2CIYKfaIyjs1snuCpO0KgQ" +
+ "Tkz7DpQSe9RUo6aC2870GuvKlTLWkI0WI/oRLU0sjgssUXraZQ/8XeC9pS2X" +
+ "d5FlZX+gA1OM2x6v/DQLzDeN18R6i6UeQZSgDMv5PeCM+1amS+wVznR+2pzx" +
+ "KNlyPta/4XYWhX/2GB5lwHtYlKDOnI8+0gWU4Lp+mrfKSYdpvnAg4SKRwL8V" +
+ "h344eiwCCpdDDOuqN02dJs4H552sy1SFwMvBnsJCRtQUCq6SPiJ+lrVTPsQZ" +
+ "snJcwOKQHNGHkWs2rTPU7nrhbXaRUCcTcPKknAg3wdORtT54ASE73dkufPUS" +
+ "8hgbDJB8EwD+nKy0Y2y1KdsCCHjoHqtXOwaCoPHecBud71ontPj0XCZ54drN" +
+ "U4coNXGJjUtKhRPMC45US6AJRYu37P4crc043eO8D+E9MgE9cm8zCF1aRJe5" +
+ "lP2uQLvGXvg2qdbrQP/ebQNZ3QJ2LUT1km3ApZXRi0ht0a9SzWsRo5CSQY2k" +
+ "g8K6YbslkxCT/AvYEGWjEHx2kBj96lSTYYz7nXkJHzLX5kbgXWAHavzWN04L" +
+ "Hqf6pbzbbiNpJ7SpG1SUxZE9xU34BP2msOD4aOUPBJCfd3pE+5Nrnwudk3r1" +
+ "Lwp9YBlbbI2md/A6z0H5qKrWYyViiFbfmUKZ/BrSt8+g8Z0MY26V+7wQCmZu" +
+ "JbyOQkLbPG3YghMUK/T//1NbEsgVK43Bh5mvMZgLOWFOHf360y1RBNtJgcpF" +
+ "/Ckig/TSA25XC4l3MQ0bSEdszSjUkRlKk6WARrZ62EpCV5mNP6XMJOPRpNRl" +
+ "DHvumo89/PKxn9/0GqLSGqkC+yHxOhxqF/3pe9wduSuEamM2FFySftqO0BKU" +
+ "uvYDGs2USoeZCO4xXELDn93caAYRCUIEzFYU6dT9JGEEgapq6UrmiS2Hi6/X" +
+ "zYcs41tJtI143kOJ6NKq/YzvZTNnyOiTmXuKJwE5R4VdtkZ2PBD8MZvqMpk9" +
+ "reFXpubJBL9z7ZqvvchZ2AHsnKWCOQ/rG+rRXTuWMDF5hHIhr8NOy6Sp8X1k" +
+ "DC49CFKkSv23OxhLQLfRBQHcKQ5IH0sJTtbHviBq+vB9OV8dz3qpLvAbTB89" +
+ "tPrKfy7jsfPaFEJUy9bjJsk8gg70WLR32OucUO5AStWk39b2C6PEGewzp+Pe" +
+ "uy/SWBly28gN3Em4RsHUptWkyiOrw7sQhwalJV60rwqROCfSb01jLfAcBgDl" +
+ "1yZ08YSKsMvRGUCRID22eDBxl8fFeNHyfPWZrsGegLiWpG4SEhdz9MuayNCW" +
+ "+K/rq5wXnvgmVeDx9rgeCSuEc2+iGgyirvVcwINSPoJIejyfLP8A+dNQrS8b" +
+ "6n6ZWKEpiK+4K6gQJArgbdU/2QdzHmDH+b4ITnrhqA2SVH5kjdglYMWBZ45/" +
+ "/Q5LwMEdqv/P48eWWxN8XMoIkVf+FtqeHwfr48AZhINxbQROlqBS7hCNYj44" +
+ "BLipDiGmeGI3pYeWsoZqu7hCRMPb42ziwSGFdvv4Q2HFWdgDYvirxqh2SbgF" +
+ "aznvDQxq4Zzk+TiJbHgphDZJR+DEHYX5n9HbgLWOp2kYWKWT0BPwzS1w++vK" +
+ "+pMEmbn3C5d7OEBIJ9TTD/jZXB3KP9tUICFFaFXUrk2752fBfO9kA5xxbxDk" +
+ "ISUvhwBgiNGxet1T5SoRKPb61Zz3NY0SLr+GD5KfH4mJSF6tOUZ2iAP81uUs" +
+ "fwPIxqHh83mMS5PW/DAEeJT2FFcBMVaXdj6Xc1hvIGGXYjc3NQLxII5vbQVR" +
+ "3UGhRFSJEi0urSXTFUDMan2AO24mM+jnNRCOxOIAx98qj6DKTfkcBZidH9tG" +
+ "nJAOlISyY49hJvSk57tjc0oiSq8ojE9bxQQ007mc+XnKP9/5dXrTa/zUhCZi" +
+ "DIeqvdOZ1ugRt1garJv+BS0kRrMpahYxkqUJijkSE6U+4+5V3ssWhWu+3VM/" +
+ "LpKK/sKXImOzcBbcdvzPd1/2yUp+ZCzDRB9qeOmdhZtEgKHp3b2Xw7211jfP" +
+ "ZWG3ydrVCduI2m2Vo4Lb+4NddZj3yN6xeurZw/JZIuzBcmOg6viEu+Be38GP" +
+ "VWz4DV3lAK/2eVPGUMVIVXthJCFLKaT10psSNqFYWi92OxhOIu0End71Gb1H" +
+ "tupvmdPZWCQbhaW8l2RvYMZuJFKpH+reSP6FrgqmrxXGf+2EXzz6PdbeLmnB" +
+ "UB9QcTdu8tsIuUvzh2Axvrxmqi5rigefuQqwvSgl4KPC2mFI3cKrVJ3kB4Nz" +
+ "gMIpgW1FzVkiVQSHMTno/bm1LxzGv5Bcjx48NbL183kkAb3kYGNfZHEE7EIN" +
+ "/3EgK1RUUF0YC9EAYt5U/hnNOofK5rNTjYPepexhY5/4Ve5msVrtn3C2Nlp7" +
+ "gpnGtHvcm2yoPuWo5ASHh+wGZWwkUMz19x7176l2GczPSajuK6CT2i3xnZ8Q" +
+ "VGQALJ3Tg83Lqg7LfUhQIFYr6yPttZAjuETlWXxIa2IDsxj6Jz9WBzQHr8TE" +
+ "1NY9XmTY2eenwpmNOVHrwn3ADzW6OyDHfjv6IY+INC9CAnGSf1EMiwUPNOpr" +
+ "oYhGfRzTgLLJQTPTWwkn4rmds8eLVdp1gF4uK9fEdY17nJFe39I2Tui4yhwD" +
+ "Ue39/dGYG16nNTqYj/yt07oilo8PKAKczLLN20Le0aYmOBMGWx+5gWGiPQGk" +
+ "Jmq0LCHO5rHf7L1j53+efwedTj1Z+qv20IQINJcUvgUX4XfJewiUoLU9Nf8P" +
+ "jOTIzyR7lNWV75kK0JZJz1jww94GjuCq6F/qXwAM3P+X1VThbLKd+drT3YmP" +
+ "WVOeOYWPOXUrU3OowSzMGIE5sq7rQY5WwZWpE8O5lUJ6fZwx+MjKVnAYdzAJ" +
+ "rRxH7eBJOFwn/IGlgJDUdvOHy2bXX9kcVP/ShWuflU1e0y158UTGQNiIRjN2" +
+ "E19RBBgTru0eB0DZ/yke4BhkeIo5u0Rg91asZHp2RHONDyTppR8wSO7aMKRZ" +
+ "BQYEv87BIO+B06YsohMfWa7GwD4jFd3XAm12aXIukDo8sMJ6f/C70NwyNsNB" +
+ "wvjMvl+8E4jK1s5qgagPwECIdl6RBtf0m/CDm3FS1jD8ghJnvbHG7aZnafm3" +
+ "jTPJcAUDP0+GGtK4aFvqC6yvbUPotlWYyPDhMaOOFSwuFUqn9tzlY3NPlo4x" +
+ "28rietj+sZjSd+fdUiPP5q7T/VR/SsnzIWTgWOUyEGVeJczUpSdqNO3MJoY+" +
+ "5MV6+KRkRAbULuVC+N6whOfPW4aihfNVLEBkUfkpo9f0by7fpVU6eJTaqv4T" +
+ "Z3qW1t80ZVUXN6qRnjG2t7UmTqP2rTXurYseWBYZceo59zfQQSMo5cirpLbh" +
+ "SlCrVXP/CbUM+OMoiudWha/RZw4fdximFlo6R+TxMoWdWOAMc1kfyL5q7tZk" +
+ "kJfAj7r3Y4XBcNeQ9bqKKdBzJxUNRvU2Be47fEfbVpKqDWFlxeOrj6tRqjKK" +
+ "YUt7zjZpYGFqG3YzTfXZVSQ6Qwmxu/QM6vFVjbOpsScYal7Io1qLnDBSUmRb" +
+ "v/gong0EpsUNvjQ40B8jmNUNsTnRF8memZC7k2cKLnah5RXyuLFvN4cZFSar" +
+ "LPhBgDBWRgtEzeShPtQiYzJCelbelDoFBz/KfavE4MLRYgXf6/AE3U7CAwDq" +
+ "splXWaEuCGw7Snwpchk4gCXSiFjVDj2ao2WMA6y/zot6a27ppekkvQRFCtkL" +
+ "SXNkgJ/F0mvgp3mQBOvo7Yd4NPJV++tRFf4tHWbb8VIopwGynZlnlxXyil0c" +
+ "P1tRMXjBWDHFY5GYv48XTon13fw/GORM7XMTbv30KXQvTGpLk24IEjIG5iD1" +
+ "MrqQaAgkWkzBFPwnZpKIenpGmO0G06uW0+c3eJRbfkUaVlsDCnB+3+qZNYSw" +
+ "ugJsWuMUo/brItbV3Yrt2012ocymZSqOGtUewz+VSOopAHG+uIZi2L9h3/kj" +
+ "cJr4b5QSsmFoRCAR5j7TSkVpsfTK6YH43FbXxOHamseOOE18TY5BLb/tIlU+" +
+ "i8p59WnYo5sDy20o/sDM9N8L0Ks4Vma6DIdwYm0YGRzLBR9N5i+HjcprWz4x" +
+ "FxBHMVMalm7metqsOihfb7aj/iu36uZ9eAEJNZra2vUz3F2oFwlK0aJwznMT" +
+ "+k06Rqd2xZOKZxWqbVeWMb8EPiAvjwtAbmoXzTf7AZPChwAtb/fkd8QhKAHt" +
+ "Ge1akmgoY/puFLMJnFECvmy8dlzVfsAX7JhBlVRkeEDofUDCnkh7brT9qqrR" +
+ "gj92kv+jO5PS2svsFJa+3bB6tuKLe+AHnuvaB1aAdf4aPxFGwHAS2a5ANqJ4" +
+ "CskScf9J9kCm6KwO+CmhdcjlZFMs8S8CV7XVpNrlwWDV0CdwEmZMvIuIvUB8" +
+ "Ic58/kCZ8A7OwUVzMEtmJPuLBDVNrS2jLTb3CKjWw5EO9H15J5FseeTz4jWj" +
+ "7PfjV95NT/n0IqhN/1CsozW6Ko2LDrzH9AjD267p/cF62Hc0a7XI+FMF+d0v" +
+ "myz/L8RjdZzwiq/Xg+gYWLT8uAv48yazhy+3h95Ttf8IP8E1pSAEvyiuKUcA" +
+ "liw8aOjVpYaBJU3SZEy/T4QAyY1wmiyaReHXZ+ayWHB+HIiCNdNXj5koUOUc" +
+ "LVKQBdvgjvMMLIUlUCJB+armPQ63GNp5bBfI1lhvjrs/He1HfgKYf8H6kWwf" +
+ "BrBSYVno6HkRNKutUpc2nrXCHRqmJtuzB7uabtGFQEZbxP6OHY01k+tLPHUz" +
+ "EJ/tUGZ7mUfZp1m+PwbXlSjRMYJhLJPsNbczNkuFdfIAfAN8YlUjaeHQWAuJ" +
+ "KaA5iwxIqENVCZR48WUI4s/1uXO3VNa+UoSGI5N9FLgfsf/m/3Er8djDf/VH" +
+ "kW6nG3u8maC6xuTmHh2w0QSsLhjqkjuIBoY7T2Ye+phZYhcjLTuRkoJxNGXv" +
+ "foVPuNghwAHm2Jw1QN0LjWQp0aggReKLBIAb5sTLYLQltGHDNj6ime+gQmk2" +
+ "2kb2QlCP2sOP2zs2/D7CuUWHVeeA5hcJc2eWEWv/I5s6cYysTM13dleBwIu0" +
+ "+0Lyz34cvXrC+9agwHa+uAdO9KYfuk8PjRmVPY5rgL5ux7QbhgA5Ou/1GFm7" +
+ "66fbdqYHNN48Dof8WeNQTZE1qlHl2ftAKyFk9vH+2T/1knJVHpEo2Dh5KywQ" +
+ "M41C0Gla+cIj+Wpit9hVYyF+VMC4MYbJDDQ/f5VCuSMXJIFZ7wwV5EkCLZV4" +
+ "qlDC37hMec645uyutF+SAFAyyiOufGnyR/spllpPXf8pF/HXvtwkPCyN/IKE" +
+ "vp9YOKtXdGfQ0NksPRP6f/nfy8X49Nmr7N4oexlVB/2hfym9ApWw3zVMhWpr" +
+ "sk9EWMkVzNccL084P0UBYDRwVmaU0OJHU1zDs5MS/joegbwjO1gA2FJcFdoE" +
+ "vbbLWCDJGVkZWvfgPr28xxSZAhYuFO5zJ+Sn+36NXPsAwQlbyMWp7y5R/JBH" +
+ "zHrQmpEp6uyyyYqOFA4QIWW4RhBW30gABmq+Dc9qqEUyVjRd+8RXf1Qvin7F" +
+ "tD0cTAOl2UISjI7Z7JexkSFBcS1uEEgG2SkGYycFa3TapP2PXEdL77pN+FJ3" +
+ "tuefmxbW4UaQq5xDr59BmhJ6bZ887I6vwi1t5Q2rqTNRxZjePkCqhtZSV0E7" +
+ "JfWxMEPxxzJz5e4/PMMdMUeN2lG45WAbdJuWYsuC7gb3gVmtCkSyTJcF0Xos" +
+ "Uh/jsWbVPsDWOle55iWepn7i0HBUQONI0iv/BLFTbU1+19frmpB6MEmV+t+P" +
+ "cUeiVWy2uoRXXJiZgZ6uWAPtSedlFNO3DGCl6a/POkU0OBvW5UpVlpVAJ2qt" +
+ "qXbBz3OYJ5eOS9xqRpdvqtkzIB7eXO+2Icxq281+M6Ug5PFRgyLpk20RXkyR" +
+ "PEqmjBnTkR8Ku2B2F4SvQJsKK3dxjGdxwYr9+3ReS69grg4/4WtbD4iVf/lE" +
+ "G/UrIyW4nCL3/k0y2LL/pdbCPsoT3kSLvtNxKF7sFnLxvxvPxGMvYpnGyE9s" +
+ "UeOtPY5LsIjRX3eMuT+msI8fPrlOcZ2ejz5FRYvvChBxB6o9w9ybZlxx0SUh" +
+ "1yqqW+hjCY0bfzaOxEVs8ZfGKgfS16AVN0sArOBdS+FhK3zKSAubqx4IfZ0y" +
+ "luFVMPAGUUo558vyGZNhmW6U1FJczZWz+yFOZMcH9Y21GRkE+JKnBIEY+cuM" +
+ "RolrU0Tzj3USUC8xazB6ipNZNKepCCzcRy+B8ulGVeaZHFzVLe+yt1zPvFOJ" +
+ "BQOoGDe9ZDsqo1QJHxTh7eaEWr8hMfLs5bDanrN8mBjhom+1Ni7RQEg7qtbf" +
+ "kWd6RdB5gDEZDeFNP/16n1dFf1M/lLYfKWUuYLXueOX4s3dFFAxyKqy9NXVk" +
+ "X7/s+d9XTQfIax6Zh3SH5YF47yddlysYZu/HjhaO31yq1+hBLQgeBEl91vnT" +
+ "Qg6DlMnh36Vpsfc36UqKo/97LMioJq+4vViL2CqMlTboeepvgOMjdm0VfPn1" +
+ "cN0ithvdPi0pOPjArFjhcsdF2I9qQpQCPfC9n4xpaz1E1PQpek5x/LqueH8F" +
+ "UgiOGoUZWSdRaFjXu9KPP77mayqTT8SnCx0flb0E92mEpI4P4zq58/nOnVWN" +
+ "uGcOZ7AqZRwIfIHJSMlXgaHQGg8YDoDXJKgp28fZZzESjzEzKlE4zwQyyAFe" +
+ "jQSXjRexLS9YqWpWaIFaVaNy6b3zIohOjLMWATB+OeuR48JfUKIsaBUz+HdA" +
+ "Y33pgtJsb4tmC99SeS1sBfZAw3hUYWUE3y24+u6lRdw6AX3SvfhC5Vc8qVt7" +
+ "+GFWGlOH9MdHYcoNxPpB3N0HqQYZk5uGgcTgHneJ3oq9QLRzURvzjEupTzI/" +
+ "z36YZRA9vm+TgWoCrhUH2/52vJhKgjOY4usDvJFfEUWHv61fOAxzy8wLgu5v" +
+ "NXBX8ABR1txwpN08BCs1I3aoODlTz/T/WwPNfGptkP1sQ4PgHxJdCQsvi5WM" +
+ "L2sBq/ZmIf2SVNQaRI7MkeS0z3NdnqxzY+8wTVjQVZG0zbpNpg1G9fEk6Rkk" +
+ "wV0vHEGXnZJ3DXTzMexg6NSyE3GXMJHa9J2fP4lMuKc89XtGaA+CU28RgbkE" +
+ "Zs+Mlbu0YNvk7JABJ/UHxf8UNJY9YG5BdUvJbElrbajWnllEaRauDzjnvjkZ" +
+ "U4Uw4fdHmzpu0PUuM9Wm5UusD5lZfj0Xng+XO4Kea9RheukO7CCf01jZuFlu" +
+ "Xgbi1tbOkkVA0AvWbnp2Dv59O75kaaVq4kBJB1SxUFb2DTvHTA2b8NYEfeis" +
+ "eVIiKNW9fDMJbbmwySQftx0SRcrKbCloN8q7RAzmewiyVBtCI8a5CNw3qtEO" +
+ "RjZYDPmLXaFU+uc83/dIMh3jnJcbZyUvt/X1NMsrF+sSonKepfVhq4mtO5XM" +
+ "lQGTY5Wyl6ytdlMbK/vwp4MsZXFsAzP85AOpEI9cHUnlYM/Q8YTMeLZt60hD" +
+ "Mqq9SU0USmvqbhteriLTuTczrsaebhXHsPbdcq1zopsOtA03q2hyQPebYWP5" +
+ "x79K6lUVxOar3JvnguVfyOrDBPRXDphI1Ew5g8dlGP5OoOhGWT4/S4OEIa0K" +
+ "32dRruB7A/F31osJeK8J2pvoosZzLpxh7nyU3Jyc0c8uuQqj+1NiGvERfV9W" +
+ "a2UkCOHaLwmNRb43ifkYIW9R66mL3Mu+hWo3aXfDriYxZHG61blhFYNDxkUf" +
+ "qx3BlDmcjbWae8v6G/JI7mEK0XKRI5Z4NgheSSY7VBnj4nQRRht5efUq1TWt" +
+ "OpK4Ws29BRhSfgd7DtpVS9zSW48JCfxGTuNHHbXzSWrLSAU0OX42ycv74gm0" +
+ "Nv7XeLzs5Bp79Vkc/YZRxGa65h5AfQzKf001czPofnw58fHa6WUqD5m2pEBC" +
+ "0fC/YSIpV7wJfUBuj/JlWGiwAkWpkQihq7mW8GcxUTk2nLLrBbWr4X8QBdXZ" +
+ "s9dA11UTul6nVzGnFDrWRbHgcAmU4bxSEsMYL31tGg/jMKPx6blN/M3I+KKN" +
+ "U+9y1Arn/36z471rKz6Xgo5bP4qbRxLArWnmV4BpB14hL0JeQJaqJtFuNIxw" +
+ "+y04cXQjdHxmjluTC5F4hViPS5rY5+AM4C7IqR8fjmC/pLNhWQsnz3/rH2Ax" +
+ "3zPs0E3vdeZl3JRMUeWqRYLQuF/Q38u08/8PthUhYyT978xWJ6+t9rrC2iS0" +
+ "QbRNvmqE1TuROy3JcLz8ig4Ryo6thY7tKnKuRFmbBQHWk+43yU5hUqw2H3hX" +
+ "roIYd9NqTeImqfesegSnRpSBnOnFQLRkI8KZOIQeyYzKOWVJQw16xwSX+PdU" +
+ "4hc6pA6+pIm5k5KO/UzJGmWpzpH1HyHuSIjhLi/zRGBHOXPZHLtTHjQO0fZs" +
+ "WH1QcmVrrrRvHhTXzKqKsQRfKtkgjQRCJtNIB5tQjWfwNgW4Lu0psB3x0sSL" +
+ "GnKm+BKjgE7HMApctusBLXNwplxsp8PYyZOiQeL+6v+iUCDLDLI5Tv6XIONW" +
+ "GzxU6SAAcVhJ14gy+95ptYSdc9YioUHvAgcletAy7oWdnpIliUfmlOELyvZF" +
+ "kpixQDAyNSVUUWxGsad4dwYRv+Q57WMWkDQB/WfkBfqK6EO0DQg0FvJSQ2Ij" +
+ "Fj7O4vOPDyXt/ir1QUxfELactILEpBTf0UUgIJAjcnAI0waPu9fN/619eo7V" +
+ "VH8Wpk3HUU9LjOIIDC7BAPPTE2xDa3kAG9VGweIXpL6YyW4JnAVSkou1pZWt" +
+ "CW05eMRe0HkDpEJb4iz/UHn2KII4ZjJaFUgSWgNDRiHRvMoW4tIImHuI4+Y7" +
+ "rokPlAlmO8yEnsLyBVgiPr51Sq9RWPCL1y3bryOfUoGFc/cozQ1csN02Mncz" +
+ "YeSbbwt0toufO1ex/gfsiteqRgZvSIn91yMsFl7lzEi3kyJIhW7hBrPDfAHm" +
+ "TZ5Czrcs1z0+JKfU1PXcuaRm/Bw+OY/1v8Z+YYKIynupdgnLCY8LfruNzk5S" +
+ "e/mT0UwgtoJE+TvceiYGTw+Rkf0a4jZiTEcs3lF/IRvIOnd/+5m1eeWtGJp+" +
+ "z6rlPrlRWjrhl4Ufqxob6U5jjY1/7zAMV6Ge7RgkNJiRy0Brb5+phAHpkajC" +
+ "I/q4m/qBBm+gqRrfmFvPfo1CeijfMelIXMh3+p628kWGpIAypU3ocEcVcXXG" +
+ "B+K/n2zyfbBQtMQ+MEUurRbn4G90gyRaHKgf3SuQSM53c+OVfJGXhR4Gtki9" +
+ "NF3kCMt3wiGXi+c25NEs07LZ+xWfLeK0/0IrAHCmG8IcoO6T8pujgZUEyIHv" +
+ "9Za/9vrvP72UlQ4+z6yUg0RNwlHgWN2nF0xnTQZXySXaoAaqwGA8HetCbx7s" +
+ "ePd+VFl1/gApyxeGhWFTf0d3YiBLRCqvdFCsKrC/ni7aIGgbpuvjxmHiTAKa" +
+ "Jaick9xE7a13b2pY557OVq6ExqRiC3c28z4YuKXfJf6IIeBug1HY9yEnjU37" +
+ "eqNJL/XbyImo55ARAH61MwL1RSqu7uWJDui4GKCOKC+piqOwLDjSx8AyRVN8" +
+ "zbsTxKtN0N0AUBqstlxgrfbV3/BCqKSQHCaqlg0Nrzk0T53RZEHyNv16qtr2" +
+ "iF45GMDj3k/lP/NLU4DQX3R0zx1dQirSfUr0PJGxZdwnfHFzSZ7o5YaAnqdW" +
+ "j8t4DGsu5wdktDOfqRsXrX3eKmeps5ycRBKTUgPhoccH+PFtMXYjkTH49aW4" +
+ "hKgnJd5I49A5o/Vdd5Z3zNFF7eSUsMFA6pYxXOy4/wQYpu8vqmYBs5p/WBM3" +
+ "wJkp0iLaEsEvJGSRNjbyuhV+N16GamJVIQVk0X2HvzKVtL1cHHN2f9BkFbFC" +
+ "R2iW/I0ZFz/OECDOnlS1Ea/jGXuEIOB2+4O/Fki7kQ1opkc5pB5ehMMCetXP" +
+ "cPJrEyyQJXsG0ZiCmr9RtGoEKG6lfvNxFWBtXHjXrFXjZ/KRZi7BS6ZPIRb+" +
+ "YER6V8tyLNkL86xTjkm1oq9+opihDSf2+dve/u3YFooowsleeNynMVEyEPo2" +
+ "yOLB8FO/l60qpSOSrepG6kS37ifjrv1piMyqLxz9EWP33jG0ajCEj1hAoke2" +
+ "5uLFL0xaYT5Hbb3SPD6E5Kwm3GrP53VMGpzxFb3WirP2iW1pSLH5ZwBSiiJa" +
+ "awGW/1JAZ/AemOroG1jpFXYG30euz9cj1ha97GagqGgaklIQGbGejqj1lu7/" +
+ "H8Uu47sdFxrQTbs0enJEr7iZdOWHb/Gk1u6X2+1d1+2ifn5k4dd2QrKi4lKZ" +
+ "TnzU6InfbE6wl7kblSGnvxG5CdMs6vfcs1VQHbahPxyZ1ci7h3Yda6MV1xNv" +
+ "8gru+cCbr/x6v0L0L0rjSg2ZwFq+UCexc8t7ONv6y6KhjbUgGmy15GthHqYQ" +
+ "/wFMIeobeq7yd04vUMhsvSxfXL54RECwu0Wz9OXfPU8yGdLiUqGDlVM/lrCF" +
+ "H7zdSU+XKqOoxA/Wb8zayXZehYRQqnDVlJzA39Sp4KtPQdIapZ42ViJ8SWXI" +
+ "sgtztW588KRMxjtMxpIj5eKucFr9bqfYsaYU74t3JQUIeWrKMEGlftBrT5Tn" +
+ "BIPhOlTSMWe3pWOkJP76uUm/mqrz/LirLgzKrMpsw32eUSQsizWwXnC2a9pf" +
+ "VQcqDIQBgIRxI6bp4U4IQIhCezOhZe+02pt/R6el4fvDyhGh2sjcUyt50XHa" +
+ "tobMMkNVoQTWm1UUJpRB5n0CbtXDRkB54kL7IYlhsZVBYQqDMihNbTvcGfUE" +
+ "tz+Yw405OdLawX5VpV4azSeXxncq4LlHgE23JKIpZjnQ/ueb8c/6EUyfn1u7" +
+ "4+lGsqIK87fwPrGP6tgozyo8e+uzYl2wIKjL3p1ypi9IJodtMtQJT4Aw/Nyk" +
+ "d+fB2zS7h54vyh9XJBqXBlyBJTDoevGxACfCZMOagdR4kmysiWUEqcaPSslx" +
+ "9is9VTALHRpN7LeKyTnPnMzFb1otJ+tYncqtvaP0I8hRgtWHsbiBqpjDUZxF" +
+ "nOXaXzbuYdEV2rzcQ9msOCqejRctklNVGwrFdqEKUeOV4QwwGJv6wb6rRYaB" +
+ "qXB0/8CEkoNYOC/VU668RDOkwTFd12w/9TOgr88DHX0dN0OHLKa7/xzNji1k" +
+ "OVkQcT+Bcrqr2pUWkic30U+YU7mJSC49tssKTROJ6SM6m25jou/0YuuYTge0" +
+ "S/bn+Th6Y7YJ79eqvmG2OneqcCwE+SzpehGo/LeROeBH5w3rGTcl2qcxvRf1" +
+ "SyyJ5aGlh6fseWgcO1NW2oLr+ih6JCpDf4vRcYjdaZysmzB9y5kLOY3rPQbI" +
+ "OxqaO1KshMb3fGJIcK53lZBqHQfqQ7CgeYotq2OGUmKzr2BVmkah+YIMUrRE" +
+ "xVGSlMzJyDABEE5cTBvcmq8MJvTdFeQrOHkAHJ4Y10v0rb01hGkvJbSUq5a9" +
+ "B7f7ulZPnYpWmJZ8iDPs2eETUH/fm/a+B1i2kb7QCs50zGfp6grwmwMb7fd2" +
+ "DEOkjXS6VEOfnzS4jlNhBfGRD0GORIjRCI2arB1hjQvthLU14Q03ZetymTXE" +
+ "dMml0i+t7wNhESkAMwvfqkPrG72sg32w8yCKh9zE7YATcElTAobdxR9aU8ei" +
+ "ulXgMb/PnC15/SZTvGzK4E5FGjRbRYx0ZJsQYpdzx4D0L/Yx0BEODfIdbXDV" +
+ "kSRMtltmWx+88xlqzN28I43ezoe/8rU7WzQvJLs/9N7Ud9JS6H2pHJxqGYQs" +
+ "3Sk32tnWjIk57PXk/++6IwsGonmalUSP53cILKDerkkj8LkOtbCSdmQu5uTb" +
+ "dXdxM6Yo6nHStyJyHZUz52qDbZruVnBLS2HXjG0LOBNSU80jbkNzJ9+uSr81" +
+ "bsHaUlIsq7Wksrv1pfNIz8ieisEJnk3FE6nitwh6w5RYF7Kl21a1vEPQUipZ" +
+ "hfPBLGel0lBmBb36va4ge0nketjV01j4lBStIg5c6c+V00gwsu3/Aj+EaMy8" +
+ "jDW1nle5f1wG6KQxAqLo78BIOojlyQjR1rAbPS+rvxTjirQ60LEPeyEnljmG" +
+ "xVnGGliSrnlRuI5KAkQxLCUEQTTFy3Dj+1NAUkx4Xoi7ARsfvj0L7T36wq0Y" +
+ "+aFViAoYfBXqNqf5vLbXo8hcKIkfvUf5b90ivNPnQx/nUH6LsSaDAUEpR3CR" +
+ "8c3iNn7BURwoIjtAz3NfEgsQRYbyQIb4hgCODp2tnhl+GK1bKvkgnbRoxyCJ" +
+ "XsK6Ka9lLK6TGP2AG7zdJIBBvWF4yCsNdF06qYuN32L0t4OOP6cRMowDchoY" +
+ "vwXr9KWAvAc4Kq3KnwwUDPTISLp33n9LFItdgZNZeMjZ3hi7mSisMB4lK0lX" +
+ "L4T3G/GNH+sYKgS17BRU1Dw/Bmt9LGOmQIFLsKErqIV+cXsBLlNiuC5lzl5Q" +
+ "W3DTNJhErd3vaecEAJJlTfSjSQ9PLy7nDLv/RjzVKNgXSerqfuiM05McEm40" +
+ "g6jQDRalN1alU8Cz3GLRjsfNGdYTsh/jPD4+ZiEqnCJo7VMxs+kb38etoTlz" +
+ "Zs3hoJKH3euds2uSSGn1yPYb7J4QkG0toLIydkwAvMMdIhwQ1VN6bU8cYGax" +
+ "FtmaugxN+n+00lb2Rbpdp+yVchdeNx1Yal30XPugP7x1OrVAZw5InTNCU9zQ" +
+ "Fx8ria6g4+t1GgwBqmPi1noSHHG3bThI74oBTsg3L4esRW27OMrTTzYVNemt" +
+ "dvJXN8yedTY2rVqwbKJO7bGR2VcDDn8ZgoaPBIvQuLSRBIdbUSIeKuLiuHbK" +
+ "IbkwtZTyz7LvrE1SZ0oDpMf19pb9fZPi3v7yQpFLx0oqqSYdhrJyOfhNVZXU" +
+ "dc4vbE0qez8MX9PNmyMtt4yktA+FC+2FM4P9jjdvaIfdm2Q7NhxjffvuwBJW" +
+ "SIoHBSEmxfxZgGCo29pOy2TZt/VpU8zpGpRBaqx0F9L2YzRJgwgOTYbkhF4w" +
+ "w1w03jCk3UWEg1Eq6kr6ZOEY3Us8DLTnx1RGKeGEpJ/vqtKzX1+KJS1t4E5G" +
+ "3eqa7WUqcyNqII/9ShMZqdfmXj1llgfuD+31HjDXXVO8RFY2zG/OneMkJJP2" +
+ "WfCs+IyN0I1+u/UJVMVW1d9y09nbrjruXSjvI2NwALB8NgtTHYbu3aLi0c02" +
+ "ijIB19xcNdSjwsmpR87lp9VFqIGEPVcYb+E11OODliUPNRPig6kPcbzGGq4b" +
+ "2CmbVVjPURU0U5cXJv0jqxGl8C7AsDIaJkXwGvQlp0t2wL/Wl66mAqBCQmJO" +
+ "Uw3A7/NbqGbhky8r4XMBBk0bOBn2jUIXyfJG696QPR27NrMshZRFG8fKmRfm" +
+ "4inNQQtcu6uUOKcoppeghWHBkK134LCFJakVrgmo0QeUXvdlR79imF9iyFDc" +
+ "Z6Fayr5Mh0RiDS0DtI4E4k17OVTjPYenflXCSk5VDCN8kM8d34wQEX2lahR2" +
+ "oWTBvJAFrvMqBL3zjnzjnNavoVaMlJy/Ezjrr+vNraCbNSY69Icflfb0xUEa" +
+ "RsdADuCKDVXoAavcUKw9aXBTolmHvquBBnUsyi630i2mONUg7ylqJCvCTCGk" +
+ "EDq48TofcRnuafZt38iwv5PRmRkhnMSGLR3L5AxjCAnSAUvqKPytH4QQ7+PJ" +
+ "NHc5qetzZdz+jRkCdCnC5YonOWyzi5I20U3Cdl7pL7Ev5INyk8knQLY2a88f" +
+ "9cUiV5kwPTAhMAkGBSsOAwIaBQAEFM74e0Rbt2IGCAn48XjvdAcaIl6cBBSY" +
+ "pFDCs7BGKfo6O4hW9fB0/2HXqwICBAA=";
+
+ // You can use this method to print the java code for the BASE64_CERT
+ // constant. It will open the keystore file provided as argument and
+ // it will Base64 encode its content - then print the code that you can
+ // cut and paste back in this test.
+ private static final String encodeKeyStoreToBase64(String keystorePath) throws IOException {
+ // e.g.: keystorePath="temp0.jks"
+ try (FileInputStream fis = new FileInputStream(keystorePath)) {
+ byte[] bytes = fis.readAllBytes();
+ String encoded = Base64.getEncoder().encodeToString(bytes);
+ format("BASE64_CERT", encoded);
+ return encoded;
+ }
+ }
+
+ private static void format(String name, String value) {
+ System.out.println("private static final String " + name + " =");
+ int start = 0, end = 60;
+ while (start < value.length() - 1 && end < value.length()) {
+ System.out.print(" \"");
+ System.out.print(value.substring(start, end)
+ .replace("\"", "\\\""));
+ System.out.println("\" +");
+ start = end;
+ end += 60;
+ }
+ if (end > value.length()) end = value.length();
+ System.out.print(" \"");
+ System.out.print(value.substring(start, end));
+ System.out.println("\";");
+ }
+
+ private static SSLContext createSSLContext(InputStream i) {
+ try {
+ char[] passphrase = "passphrase".toCharArray();
+ KeyStore ks = KeyStore.getInstance("PKCS12");
+ ks.load(i, passphrase);
+
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance("PKIX");
+ kmf.init(ks, passphrase);
+
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX");
+ tmf.init(ks);
+
+ SSLContext ssl = SSLContext.getInstance("TLS");
+ ssl.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+ return ssl;
+ } catch (KeyManagementException | KeyStoreException |
+ UnrecoverableKeyException | CertificateException |
+ NoSuchAlgorithmException e) {
+ throw new RuntimeException(e.getMessage());
+ } catch (IOException io) {
+ throw new UncheckedIOException(io);
+ }
+ }
+
+ static final byte[] DATA;
+
+ static {
+ DATA = new byte[1024];
+ int len = 'z' - 'a';
+ for (int i = 0; i < DATA.length; i++) {
+ DATA[i] = (byte) ('a' + (i % len));
+ }
+ }
+
+ final SSLContext context;
+ final AtomicLong requestCounter = new AtomicLong();
+ final AtomicLong responseCounter = new AtomicLong();
+ HttpTestServer http1Server;
+ HttpTestServer http2Server;
+ HttpTestServer https1Server;
+ HttpTestServer https2Server;
+ DigestEchoServer.TunnelingProxy proxy;
+
+ URI http1URI;
+ URI https1URI;
+ URI http2URI;
+ URI https2URI;
+ InetSocketAddress proxyAddress;
+ ProxySelector proxySelector;
+ HttpClient client;
+ List<CompletableFuture<?>> futures = new CopyOnWriteArrayList<>();
+ Set<URI> pending = new CopyOnWriteArraySet<>();
+
+ final ExecutorService executor = new ThreadPoolExecutor(12, 60, 10,
+ TimeUnit.SECONDS, new LinkedBlockingQueue<>());
+ final ExecutorService clientexec = new ThreadPoolExecutor(6, 12, 1,
+ TimeUnit.SECONDS, new LinkedBlockingQueue<>());
+
+ LargeHandshakeTest(String cert) {
+ byte[] decoded = Base64.getDecoder().decode(BASE64_CERT);
+ context = createSSLContext(new ByteArrayInputStream(decoded));
+ SSLContext.setDefault(context);
+ }
+
+ public HttpClient newHttpClient(ProxySelector ps) {
+ HttpClient.Builder builder = HttpClient
+ .newBuilder()
+ .sslContext(context)
+ .executor(clientexec)
+ .proxy(ps);
+ return builder.build();
+ }
+
+ public void setUp() throws Exception {
+ try {
+ InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
+
+ // HTTP/1.1
+ HttpServer server1 = HttpServer.create(sa, 0);
+ server1.setExecutor(executor);
+ http1Server = HttpTestServer.of(server1);
+ http1Server.addHandler(new HttpTestLargeHandler(), "/LargeHandshakeTest/http1/");
+ http1Server.start();
+ http1URI = new URI("http://" + http1Server.serverAuthority() + "/LargeHandshakeTest/http1/");
+
+
+ // HTTPS/1.1
+ HttpsServer sserver1 = HttpsServer.create(sa, 100);
+ sserver1.setExecutor(executor);
+ sserver1.setHttpsConfigurator(new HttpsConfigurator(context));
+ https1Server = HttpTestServer.of(sserver1);
+ https1Server.addHandler(new HttpTestLargeHandler(), "/LargeHandshakeTest/https1/");
+ https1Server.start();
+ https1URI = new URI("https://" + https1Server.serverAuthority() + "/LargeHandshakeTest/https1/");
+
+ // HTTP/2.0
+ http2Server = HttpTestServer.of(
+ new Http2TestServer("localhost", false, 0));
+ http2Server.addHandler(new HttpTestLargeHandler(), "/LargeHandshakeTest/http2/");
+ http2Server.start();
+ http2URI = new URI("http://" + http2Server.serverAuthority() + "/LargeHandshakeTest/http2/");
+
+ // HTTPS/2.0
+ https2Server = HttpTestServer.of(
+ new Http2TestServer("localhost", true, 0));
+ https2Server.addHandler(new HttpTestLargeHandler(), "/LargeHandshakeTest/https2/");
+ https2Server.start();
+ https2URI = new URI("https://" + https2Server.serverAuthority() + "/LargeHandshakeTest/https2/");
+
+ proxy = DigestEchoServer.createHttpsProxyTunnel(
+ DigestEchoServer.HttpAuthSchemeType.NONE);
+ proxyAddress = proxy.getProxyAddress();
+ proxySelector = new HttpProxySelector(proxyAddress);
+ client = newHttpClient(proxySelector);
+ System.out.println("Setup: done");
+ } catch (Exception x) {
+ tearDown();
+ throw x;
+ } catch (Error e) {
+ tearDown();
+ throw e;
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ System.out.print("The certificate used in this test was generated " +
+ "with the following command:\n\t");
+ System.out.println(COMMAND);
+ String cert;
+ if (args.length == 1) {
+ String storeFile = args[0];
+ System.out.println("Parsing jks file: " + storeFile);
+ format("COMMAND", COMMAND);
+ cert = encodeKeyStoreToBase64(storeFile);
+ } else {
+ cert = BASE64_CERT;
+ }
+ LargeHandshakeTest test = new LargeHandshakeTest(cert);
+
+ test.setUp();
+ long start = System.nanoTime();
+ try {
+ test.run(args);
+ } finally {
+ try {
+ long elapsed = System.nanoTime() - start;
+ System.out.println("*** Elapsed: " + Duration.ofNanos(elapsed));
+ } finally {
+ test.tearDown();
+ }
+ }
+ }
+
+ public void run(String... args) throws Exception {
+ List<URI> serverURIs = List.of(http1URI, http2URI, https1URI, https2URI);
+ for (int i = 0; i < 5; i++) {
+ for (URI base : serverURIs) {
+ if (base.getScheme().equalsIgnoreCase("https")) {
+ URI proxy = i % 1 == 0 ? base.resolve(URI.create("proxy/foo?n=" + requestCounter.incrementAndGet()))
+ : base.resolve(URI.create("direct/foo?n=" + requestCounter.incrementAndGet()));
+ test(proxy);
+ }
+ }
+ for (URI base : serverURIs) {
+ URI direct = base.resolve(URI.create("direct/foo?n=" + requestCounter.incrementAndGet()));
+ test(direct);
+ }
+ }
+ CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
+ }
+
+ public void test(URI uri) throws Exception {
+ System.out.println("Testing with " + uri);
+ pending.add(uri);
+ HttpRequest request = HttpRequest.newBuilder(uri).build();
+ CompletableFuture<HttpResponse<String>> resp =
+ client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
+ .whenComplete((r, t) -> this.requestCompleted(request, r, t));
+ futures.add(resp);
+ }
+
+ private void requestCompleted(HttpRequest request, HttpResponse<?> r, Throwable t) {
+ responseCounter.incrementAndGet();
+ pending.remove(request.uri());
+ System.out.println(request + " -> " + (t == null ? r : t)
+ + " [still pending: " + (requestCounter.get() - responseCounter.get()) + "]");
+ if (pending.size() < 10 && requestCounter.get() > 10) {
+ pending.forEach(u -> System.out.println("\tpending: " + u));
+ }
+ }
+
+ public void tearDown() {
+ proxy = stop(proxy, DigestEchoServer.TunnelingProxy::stop);
+ http1Server = stop(http1Server, HttpTestServer::stop);
+ https1Server = stop(https1Server, HttpTestServer::stop);
+ http2Server = stop(http2Server, HttpTestServer::stop);
+ https2Server = stop(https2Server, HttpTestServer::stop);
+ client = null;
+ try {
+ executor.awaitTermination(2000, TimeUnit.MILLISECONDS);
+ } catch (Throwable x) {
+ } finally {
+ executor.shutdownNow();
+ }
+ try {
+ clientexec.awaitTermination(2000, TimeUnit.MILLISECONDS);
+ } catch (Throwable x) {
+ } finally {
+ clientexec.shutdownNow();
+ }
+ System.out.println("Teardown: done");
+ }
+
+ private interface Stoppable<T> {
+ public void stop(T service) throws Exception;
+ }
+
+ static <T> T stop(T service, Stoppable<T> stop) {
+ try {
+ if (service != null) stop.stop(service);
+ } catch (Throwable x) {
+ }
+ ;
+ return null;
+ }
+
+ static class HttpProxySelector extends ProxySelector {
+ private static final List<Proxy> NO_PROXY = List.of(Proxy.NO_PROXY);
+ private final List<Proxy> proxyList;
+
+ HttpProxySelector(InetSocketAddress proxyAddress) {
+ proxyList = List.of(new Proxy(Proxy.Type.HTTP, proxyAddress));
+ }
+
+ @Override
+ public List<Proxy> select(URI uri) {
+ // our proxy only supports tunneling
+ if (uri.getScheme().equalsIgnoreCase("https")) {
+ if (uri.getPath().contains("/proxy/")) {
+ return proxyList;
+ }
+ }
+ return NO_PROXY;
+ }
+
+ @Override
+ public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
+ System.err.println("Connection to proxy failed: " + ioe);
+ System.err.println("Proxy: " + sa);
+ System.err.println("\tURI: " + uri);
+ ioe.printStackTrace();
+ }
+ }
+
+ public static class HttpTestLargeHandler implements HttpTestHandler {
+ @Override
+ public void handle(HttpTestExchange t) throws IOException {
+ try (InputStream is = t.getRequestBody();
+ OutputStream os = t.getResponseBody()) {
+ byte[] bytes = is.readAllBytes();
+ assert bytes.length == 0;
+ URI u = t.getRequestURI();
+ long responseID = Long.parseLong(u.getQuery().substring(2));
+ System.out.println("Server " + t.getRequestURI() + " sending response " + responseID);
+ t.sendResponseHeaders(200, DATA.length * 3);
+ for (int i = 0; i < 3; i++) {
+ os.write(DATA);
+ }
+ System.out.println("\tresp:" + responseID + ": done");
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/net/httpclient/LargeResponseTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+import com.sun.net.httpserver.HttpServer;
+import com.sun.net.httpserver.HttpsConfigurator;
+import com.sun.net.httpserver.HttpsServer;
+import jdk.test.lib.net.SimpleSSLContext;
+
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.ProxySelector;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * @test
+ * @bug 8231449
+ * @summary This test verifies that the HttpClient works correctly when the server
+ * sends large amount of data. Note that this test will pass even without
+ * the fix for JDK-8231449, which is unfortunate.
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DigestEchoServer LargeResponseTest
+ * @modules java.net.http/jdk.internal.net.http.common
+ * java.net.http/jdk.internal.net.http.frame
+ * java.net.http/jdk.internal.net.http.hpack
+ * java.logging
+ * java.base/sun.net.www.http
+ * java.base/sun.net.www
+ * java.base/sun.net
+ * @run main/othervm -Dtest.requiresHost=true
+ * -Djdk.httpclient.HttpClient.log=headers
+ * -Djdk.internal.httpclient.debug=true
+ * LargeResponseTest
+ *
+ */
+public class LargeResponseTest implements HttpServerAdapters {
+ static final byte[] DATA;
+ static {
+ DATA = new byte[64 * 1024];
+ int len = 'z' - 'a';
+ for (int i=0; i < DATA.length; i++) {
+ DATA[i] = (byte) ('a' + (i % len));
+ }
+ }
+
+ static final SSLContext context;
+ static {
+ try {
+ context = new SimpleSSLContext().get();
+ SSLContext.setDefault(context);
+ } catch (Exception x) {
+ throw new ExceptionInInitializerError(x);
+ }
+ }
+
+ final AtomicLong requestCounter = new AtomicLong();
+ final AtomicLong responseCounter = new AtomicLong();
+ HttpTestServer http1Server;
+ HttpTestServer http2Server;
+ HttpTestServer https1Server;
+ HttpTestServer https2Server;
+ DigestEchoServer.TunnelingProxy proxy;
+
+ URI http1URI;
+ URI https1URI;
+ URI http2URI;
+ URI https2URI;
+ InetSocketAddress proxyAddress;
+ ProxySelector proxySelector;
+ HttpClient client;
+ List<CompletableFuture<?>> futures = new CopyOnWriteArrayList<>();
+ Set<URI> pending = new CopyOnWriteArraySet<>();
+
+ final ExecutorService executor = new ThreadPoolExecutor(12, 60, 10,
+ TimeUnit.SECONDS, new LinkedBlockingQueue<>());
+ final ExecutorService clientexec = new ThreadPoolExecutor(6, 12, 1,
+ TimeUnit.SECONDS, new LinkedBlockingQueue<>());
+
+ public HttpClient newHttpClient(ProxySelector ps) {
+ HttpClient.Builder builder = HttpClient
+ .newBuilder()
+ .sslContext(context)
+ .executor(clientexec)
+ .proxy(ps);
+ return builder.build();
+ }
+
+ public void setUp() throws Exception {
+ try {
+ InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
+
+ // HTTP/1.1
+ HttpServer server1 = HttpServer.create(sa, 0);
+ server1.setExecutor(executor);
+ http1Server = HttpTestServer.of(server1);
+ http1Server.addHandler(new HttpTestLargeHandler(), "/LargeResponseTest/http1/");
+ http1Server.start();
+ http1URI = new URI("http://" + http1Server.serverAuthority() + "/LargeResponseTest/http1/");
+
+
+ // HTTPS/1.1
+ HttpsServer sserver1 = HttpsServer.create(sa, 100);
+ sserver1.setExecutor(executor);
+ sserver1.setHttpsConfigurator(new HttpsConfigurator(context));
+ https1Server = HttpTestServer.of(sserver1);
+ https1Server.addHandler(new HttpTestLargeHandler(), "/LargeResponseTest/https1/");
+ https1Server.start();
+ https1URI = new URI("https://" + https1Server.serverAuthority() + "/LargeResponseTest/https1/");
+
+ // HTTP/2.0
+ http2Server = HttpTestServer.of(
+ new Http2TestServer("localhost", false, 0));
+ http2Server.addHandler(new HttpTestLargeHandler(), "/LargeResponseTest/http2/");
+ http2Server.start();
+ http2URI = new URI("http://" + http2Server.serverAuthority() + "/LargeResponseTest/http2/");
+
+ // HTTPS/2.0
+ https2Server = HttpTestServer.of(
+ new Http2TestServer("localhost", true, 0));
+ https2Server.addHandler(new HttpTestLargeHandler(), "/LargeResponseTest/https2/");
+ https2Server.start();
+ https2URI = new URI("https://" + https2Server.serverAuthority() + "/LargeResponseTest/https2/");
+
+ proxy = DigestEchoServer.createHttpsProxyTunnel(
+ DigestEchoServer.HttpAuthSchemeType.NONE);
+ proxyAddress = proxy.getProxyAddress();
+ proxySelector = new HttpProxySelector(proxyAddress);
+ client = newHttpClient(proxySelector);
+ System.out.println("Setup: done");
+ } catch (Exception x) {
+ tearDown(); throw x;
+ } catch (Error e) {
+ tearDown(); throw e;
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ LargeResponseTest test = new LargeResponseTest();
+ test.setUp();
+ long start = System.nanoTime();
+ try {
+ test.run(args);
+ } finally {
+ try {
+ long elapsed = System.nanoTime() - start;
+ System.out.println("*** Elapsed: " + Duration.ofNanos(elapsed));
+ } finally {
+ test.tearDown();
+ }
+ }
+ }
+
+ public void run(String... args) throws Exception {
+ List<URI> serverURIs = List.of(http1URI, http2URI, https1URI, https2URI);
+ for (int i=0; i<5; i++) {
+ for (URI base : serverURIs) {
+ if (base.getScheme().equalsIgnoreCase("https")) {
+ URI proxy = i % 1 == 0 ? base.resolve(URI.create("proxy/foo?n="+requestCounter.incrementAndGet()))
+ : base.resolve(URI.create("direct/foo?n="+requestCounter.incrementAndGet()));
+ test(proxy);
+ }
+ }
+ for (URI base : serverURIs) {
+ URI direct = base.resolve(URI.create("direct/foo?n="+requestCounter.incrementAndGet()));
+ test(direct);
+ }
+ }
+ CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
+ }
+
+ public void test(URI uri) throws Exception {
+ System.out.println("Testing with " + uri);
+ pending.add(uri);
+ HttpRequest request = HttpRequest.newBuilder(uri).build();
+ CompletableFuture<HttpResponse<String>> resp =
+ client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
+ .whenComplete((r, t) -> this.requestCompleted(request, r, t));
+ futures.add(resp);
+ }
+
+ private void requestCompleted(HttpRequest request, HttpResponse<?> r, Throwable t) {
+ responseCounter.incrementAndGet();
+ pending.remove(request.uri());
+ System.out.println(request + " -> " + (t == null ? r : t)
+ + " [still pending: " + (requestCounter.get() - responseCounter.get()) +"]");
+ if (pending.size() < 10 && requestCounter.get() > 10) {
+ pending.forEach(u -> System.out.println("\tpending: " + u));
+ }
+ }
+
+ public void tearDown() {
+ proxy = stop(proxy, DigestEchoServer.TunnelingProxy::stop);
+ http1Server = stop(http1Server, HttpTestServer::stop);
+ https1Server = stop(https1Server, HttpTestServer::stop);
+ http2Server = stop(http2Server, HttpTestServer::stop);
+ https2Server = stop(https2Server, HttpTestServer::stop);
+ client = null;
+ try {
+ executor.awaitTermination(2000, TimeUnit.MILLISECONDS);
+ } catch (Throwable x) {
+ } finally {
+ executor.shutdownNow();
+ }
+ try {
+ clientexec.awaitTermination(2000, TimeUnit.MILLISECONDS);
+ } catch (Throwable x) {
+ } finally {
+ clientexec.shutdownNow();
+ }
+ System.out.println("Teardown: done");
+ }
+
+ private interface Stoppable<T> { public void stop(T service) throws Exception; }
+
+ static <T> T stop(T service, Stoppable<T> stop) {
+ try { if (service != null) stop.stop(service); } catch (Throwable x) { };
+ return null;
+ }
+
+ static class HttpProxySelector extends ProxySelector {
+ private static final List<Proxy> NO_PROXY = List.of(Proxy.NO_PROXY);
+ private final List<Proxy> proxyList;
+ HttpProxySelector(InetSocketAddress proxyAddress) {
+ proxyList = List.of(new Proxy(Proxy.Type.HTTP, proxyAddress));
+ }
+
+ @Override
+ public List<Proxy> select(URI uri) {
+ // our proxy only supports tunneling
+ if (uri.getScheme().equalsIgnoreCase("https")) {
+ if (uri.getPath().contains("/proxy/")) {
+ return proxyList;
+ }
+ }
+ return NO_PROXY;
+ }
+
+ @Override
+ public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
+ System.err.println("Connection to proxy failed: " + ioe);
+ System.err.println("Proxy: " + sa);
+ System.err.println("\tURI: " + uri);
+ ioe.printStackTrace();
+ }
+ }
+
+ public static class HttpTestLargeHandler implements HttpTestHandler {
+ @Override
+ public void handle(HttpTestExchange t) throws IOException {
+ try (InputStream is = t.getRequestBody();
+ OutputStream os = t.getResponseBody()) {
+ byte[] bytes = is.readAllBytes();
+ assert bytes.length == 0;
+ URI u = t.getRequestURI();
+ long responseID = Long.parseLong(u.getQuery().substring(2));
+ System.out.println("Server " + t.getRequestURI() + " sending response " + responseID);
+ t.sendResponseHeaders(200, DATA.length * 3);
+ for (int i=0; i<3; i++) {
+ os.write(DATA);
+ }
+ System.out.println("\tresp:" + responseID + ": done");
+ }
+ }
+ }
+
+}
--- a/test/jdk/java/net/httpclient/http2/RedirectTest.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/java/net/httpclient/http2/RedirectTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -87,6 +87,11 @@
}
}
+ @Override
+ protected int redirectCode() {
+ return 308; // we need to use a code that preserves the body
+ }
+
public synchronized boolean error() {
return error;
}
--- a/test/jdk/java/net/httpclient/http2/server/Http2RedirectHandler.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/java/net/httpclient/http2/server/Http2RedirectHandler.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -42,11 +42,11 @@
is.readAllBytes();
String location = supplier.get();
System.err.printf("RedirectHandler request to %s from %s\n",
- t.getRequestURI().toString(), t.getRemoteAddress().toString());
+ t.getRequestURI().toString(), t.getRemoteAddress().toString());
System.err.println("Redirecting to: " + location);
HttpHeadersBuilder headersBuilder = t.getResponseHeaders();
headersBuilder.addHeader("Location", location);
- t.sendResponseHeaders(301, 1024);
+ t.sendResponseHeaders(redirectCode(), 1024);
byte[] bb = new byte[1024];
OutputStream os = t.getResponseBody();
os.write(bb);
@@ -55,6 +55,10 @@
}
}
+ protected int redirectCode() {
+ return 301;
+ }
+
// override in sub-class to examine the exchange, but don't
// alter transaction state by reading the request body etc.
protected void examineExchange(Http2TestExchange t) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/nio/channels/DatagramChannel/Unref.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8212132
+ * @summary Test that DatagramChannel does not leak file descriptors
+ * @requires os.family != "windows"
+ * @modules jdk.management
+ * @library /test/lib
+ * @run main/othervm Unref
+ */
+
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.net.InetSocketAddress;
+import java.net.StandardProtocolFamily;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+
+import com.sun.management.UnixOperatingSystemMXBean;
+
+import jtreg.SkippedException;
+import jdk.test.lib.net.IPSupport;
+
+public class Unref {
+
+ interface DatagramChannelSupplier {
+ DatagramChannel get() throws IOException;
+ }
+
+ public static void main(String[] args) throws Exception {
+ if (unixOperatingSystemMXBean() == null)
+ throw new SkippedException("This test requires UnixOperatingSystemMXBean");
+
+ test(DatagramChannel::open);
+ if (IPSupport.hasIPv4())
+ test(() -> DatagramChannel.open(StandardProtocolFamily.INET));
+ if (IPSupport.hasIPv6())
+ test(() -> DatagramChannel.open(StandardProtocolFamily.INET6));
+ }
+
+ static void test(DatagramChannelSupplier supplier) throws Exception {
+ openAndClose(supplier); // warm-up
+
+ try (Selector sel = Selector.open()) {
+ long count = fileDescriptorCount();
+
+ // open+close
+ openAndClose(supplier);
+ assertEquals(fileDescriptorCount(), count);
+
+ // open+unref, file descriptor should be closed by cleaner
+ openAndUnref(supplier);
+ assertEquals(waitForFileDescriptorCount(count), count);
+
+ // open+register+close+flush
+ openRegisterAndClose(supplier, sel);
+ assertEquals(fileDescriptorCount(), count);
+
+ // open+register+flush, file descriptor should be closed by cleaner
+ openRegisterAndUnref(supplier, sel);
+ assertEquals(waitForFileDescriptorCount(count), count);
+ }
+ }
+
+ /**
+ * Create a DatagramChannel and closes it.
+ */
+ static void openAndClose(DatagramChannelSupplier supplier) throws IOException {
+ System.out.println("openAndClose ...");
+ DatagramChannel dc = supplier.get();
+ dc.close();
+ }
+
+ /**
+ * Create a DatagramChannel and exits without closing the channel.
+ */
+ static void openAndUnref(DatagramChannelSupplier supplier) throws IOException {
+ System.out.println("openAndUnref ...");
+ DatagramChannel dc = supplier.get();
+ }
+
+ /**
+ * Create a DatagramChannel, register it with a Selector, close the channel
+ * while register, and then finally flush the channel from the Selector.
+ */
+ static void openRegisterAndClose(DatagramChannelSupplier supplier, Selector sel)
+ throws IOException
+ {
+ System.out.println("openRegisterAndClose ...");
+ try (DatagramChannel dc = supplier.get()) {
+ dc.bind(new InetSocketAddress(0));
+ dc.configureBlocking(false);
+ dc.register(sel, SelectionKey.OP_READ);
+ sel.selectNow();
+ }
+
+ // flush, should close channel
+ sel.selectNow();
+ }
+
+ /**
+ * Creates a DatagramChannel, registers with a Selector, cancels the key
+ * and flushes the channel from the Selector. This method exits without
+ * closing the channel.
+ */
+ static void openRegisterAndUnref(DatagramChannelSupplier supplier, Selector sel)
+ throws IOException
+ {
+ System.out.println("openRegisterAndUnref ...");
+ DatagramChannel dc = supplier.get();
+ dc.bind(new InetSocketAddress(0));
+ dc.configureBlocking(false);
+ SelectionKey key = dc.register(sel, SelectionKey.OP_READ);
+ sel.selectNow();
+ key.cancel();
+ sel.selectNow();
+ }
+
+ /**
+ * If the file descriptor count is higher than the given count then invoke
+ * System.gc() and wait for the file descriptor count to drop.
+ */
+ static long waitForFileDescriptorCount(long target) throws InterruptedException {
+ long actual = fileDescriptorCount();
+ if (actual > target) {
+ System.gc();
+ while ((actual = fileDescriptorCount()) > target) {
+ Thread.sleep(10);
+ }
+ }
+ return actual;
+ }
+
+ static UnixOperatingSystemMXBean unixOperatingSystemMXBean() {
+ return ManagementFactory.getPlatformMXBean(UnixOperatingSystemMXBean.class);
+ }
+
+ static long fileDescriptorCount() {
+ return unixOperatingSystemMXBean().getOpenFileDescriptorCount();
+ }
+
+ static void assertEquals(long actual, long expected) {
+ if (actual != expected)
+ throw new RuntimeException("actual=" + actual + ", expected=" + expected);
+ }
+}
+
--- a/test/jdk/java/rmi/transport/closeServerSocket/CloseServerSocket.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/java/rmi/transport/closeServerSocket/CloseServerSocket.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -63,8 +63,19 @@
verifyPortInUse(PORT);
UnicastRemoteObject.unexportObject(registry, true);
System.err.println("- unexported registry");
- Thread.sleep(1000); // work around BindException (bug?)
- verifyPortFree(PORT);
+ int tries = (int)TestLibrary.getTimeoutFactor();
+ tries = Math.max(tries, 1);
+ while (tries-- > 0) {
+ Thread.sleep(1000);
+ try {
+ verifyPortFree(PORT);
+ break;
+ } catch (IOException ignore) { }
+ }
+ if (tries < 0) {
+ throw new RuntimeException("time out after tries: " + tries);
+ }
+
/*
* The follow portion of this test is disabled temporarily
@@ -101,6 +112,7 @@
private static void verifyPortInUse(int port) throws IOException {
try {
verifyPortFree(port);
+ throw new RuntimeException("port is not in use: " + port);
} catch (BindException e) {
System.err.println("- port " + port + " is in use");
return;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/xml/crypto/dsig/Versions.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8232357
+ * @library /test/lib
+ * @summary Compare version info of Santuario to legal notice
+ */
+
+import jdk.test.lib.Asserts;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class Versions {
+
+ public static void main(String[] args) throws Exception {
+
+ Path src = Path.of(System.getProperty("test.root"),
+ "../../src/java.xml.crypto");
+ Path legal = Path.of(System.getProperty("test.jdk"), "legal");
+
+ Path provider = src.resolve(
+ "share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java");
+
+ Path mdInSrc = src.resolve(
+ "share/legal/santuario.md");
+ Path mdInImage = legal.resolve(
+ "java.xml.crypto/santuario.md");
+
+ // Files in src should either both exist or not
+ if (!Files.exists(provider) && !Files.exists(mdInSrc)) {
+ System.out.println("Source not available. Cannot proceed.");
+ return;
+ }
+
+ // The line containing the version number looks like
+ // // Apache Santuario XML Security for Java, version n.n.n
+ String s1 = Files.lines(provider)
+ .filter(s -> s.contains(
+ "// Apache Santuario XML Security for Java, version "))
+ .findFirst()
+ .get()
+ .replaceFirst(".* ", ""); // keep chars after the last space
+
+ // The first line of this file should look like
+ // ## Apache Santuario v2.1.3
+ String s2 = Files.lines(mdInSrc)
+ .findFirst()
+ .get()
+ .replace("## Apache Santuario v", "");
+
+ Asserts.assertEQ(s1, s2);
+
+ if (Files.exists(legal)) {
+ Asserts.assertTrue(Files.mismatch(mdInSrc, mdInImage) == -1);
+ } else {
+ System.out.println("Warning: skip image compare. Exploded build?");
+ }
+ }
+}
--- a/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java Mon Oct 28 18:43:04 2019 +0100
@@ -25,6 +25,7 @@
import jdk.test.lib.containers.docker.Common;
import jdk.test.lib.containers.docker.DockerRunOptions;
import jdk.test.lib.containers.docker.DockerTestUtils;
+import jdk.test.lib.process.OutputAnalyzer;
/*
* @test
@@ -119,7 +120,19 @@
.addJavaOpts("-cp", "/test-classes/")
.addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED")
.addClassOptions("kernelmem", value);
- DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
+ OutputAnalyzer oa = DockerTestUtils.dockerRunJava(opts);
+
+ // Some container runtimes (e.g. runc, docker 18.09)
+ // have been built without kernel memory accounting. In
+ // that case, the runtime issues a message on stderr saying
+ // so. Skip the test in that case.
+ if (oa.getStderr().contains("kernel memory accounting disabled")) {
+ System.out.println("Kernel memory accounting disabled, " +
+ "skipping the test case");
+ return;
+ }
+
+ oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
}
private static void testOomKillFlag(String value, boolean oomKillFlag) throws Exception {
--- a/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java Mon Oct 28 18:43:04 2019 +0100
@@ -98,7 +98,6 @@
"CLDGRoots",
"JVMTIRoots",
"CMRefRoots",
- "WaitForStrongRoots",
"MergeER",
"MergeHCC",
"MergeRS",
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jdk/jfr/jvm/TestClearStaleConstants.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2019, 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.
+ */
+
+package jdk.jfr.jvm;
+
+import java.time.Duration;
+import java.util.List;
+
+import jdk.jfr.consumer.RecordedClass;
+import jdk.jfr.consumer.RecordedClassLoader;
+import jdk.jfr.consumer.RecordedEvent;
+import jdk.jfr.internal.JVM;
+import jdk.jfr.Recording;
+import jdk.test.lib.Asserts;
+import jdk.test.lib.jfr.EventNames;
+import jdk.test.lib.jfr.Events;
+import jdk.test.lib.jfr.TestClassLoader;
+
+/**
+ * @test
+ * @bug 8231081
+ * @key jfr
+ * @requires vm.hasJFR
+ * @modules jdk.jfr/jdk.jfr.internal
+ * @library /test/lib /test/jdk
+ * @run main/othervm -Xlog:class+unload -Xlog:gc -Xmx16m jdk.jfr.jvm.TestClearStaleConstants
+ */
+
+/**
+ * System.gc() will trigger class unloading if -XX:+ExplicitGCInvokesConcurrent is NOT set.
+ * If this flag is set G1 will never unload classes on System.gc() and
+ * As far as the "jfr" key guarantees no VM flags are set from the outside
+ * it should be enough with System.gc().
+ */
+public final class TestClearStaleConstants {
+ static class MyClass {
+ }
+ private final static String TEST_CLASS_NAME = "jdk.jfr.jvm.TestClearStaleConstants$MyClass";
+ private final static String EVENT_NAME = EventNames.ClassDefine;
+
+ // to prevent the compiler to optimize away all unread writes
+ public static TestClassLoader firstClassLoader;
+ public static TestClassLoader secondClassLoader;
+
+ public static void main(String... args) throws Exception {
+ firstClassLoader = new TestClassLoader();
+ // define a class using a class loader under a recording
+ Class<?> clz = recordClassDefinition(firstClassLoader);
+ JVM jvm = JVM.getJVM();
+ // we will now tag the defined and loaded clz as being in use (no recordings are running here)
+ jvm.getClassIdNonIntrinsic(clz);
+ // null out for unload to occur
+ firstClassLoader = null;
+ clz = null;
+ // provoke unload
+ System.gc();
+ // try to define another class _with the same name_ using a different class loader
+ secondClassLoader = new TestClassLoader();
+ // this will throw a NPE for 8231081 because it will reuse the same class name
+ // that symbol was marked as already serialized by the unload, but since no recordings were running
+ // it was not written to any chunk. This creates a reference to a non-existing symbol, leading to an NPE (no symbol at the expected location).
+ recordClassDefinition(secondClassLoader);
+ }
+
+ private static Class<?> recordClassDefinition(TestClassLoader classLoader) throws Exception {
+ try (Recording recording = new Recording()) {
+ recording.enable(EVENT_NAME);
+ recording.start();
+ Class<?> clz = classLoader.loadClass(TEST_CLASS_NAME);
+ recording.stop();
+ assertClassDefineEvent(recording);
+ return clz;
+ }
+ }
+
+ private static void assertClassDefineEvent(Recording recording) throws Exception {
+ boolean isAnyFound = false;
+ for (RecordedEvent event : Events.fromRecording(recording)) {
+ System.out.println(event);
+ RecordedClass definedClass = event.getValue("definedClass");
+ if (TEST_CLASS_NAME.equals(definedClass.getName())) {
+ RecordedClassLoader definingClassLoader = definedClass.getClassLoader();
+ String definingName = definingClassLoader.getType().getName();
+ String testName = TestClassLoader.class.getName();
+ String errorMsg = "Expected " + testName + ", got " + definingName;
+ Asserts.assertEquals(testName, definingName, errorMsg);
+ Asserts.assertFalse(isAnyFound, "Found more than 1 event");
+ isAnyFound = true;
+ }
+ }
+ Asserts.assertTrue(isAnyFound, "No events found");
+ }
+}
--- a/test/jdk/sun/misc/SunMiscSignalTest.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/jdk/sun/misc/SunMiscSignalTest.java Mon Oct 28 18:43:04 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -133,10 +133,12 @@
Object[][] posixNonOSXSignals = {
{"BUS", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
+ {"INFO", IsSupported.NO, CanRegister.NO, CanRaise.NO, Invoked.NO},
};
Object[][] posixOSXSignals = {
{"BUS", IsSupported.YES, CanRegister.NO, CanRaise.NO, Invoked.NO},
+ {"INFO", IsSupported.YES, CanRegister.YES, CanRaise.YES, invokedXrs},
};
Object[][] windowsSignals = {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/mscapi/ProviderClassOption.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8231598
+ * @requires os.family == "windows"
+ * @library /test/lib
+ * @summary keytool does not export sun.security.mscapi
+ */
+
+import jdk.test.lib.SecurityTools;
+
+public class ProviderClassOption {
+ public static void main(String[] args) throws Throwable {
+ SecurityTools.keytool("-v -storetype Windows-ROOT -list"
+ + " -providerClass sun.security.mscapi.SunMSCAPI")
+ .shouldHaveExitValue(0);
+ }
+}
--- a/test/langtools/tools/javac/diags/examples.not-yet.txt Sat Oct 26 23:59:51 2019 +0200
+++ b/test/langtools/tools/javac/diags/examples.not-yet.txt Mon Oct 28 18:43:04 2019 +0100
@@ -11,6 +11,7 @@
compiler.err.invalid.repeatable.annotation.invalid.value # "can't" happen
compiler.err.invalid.repeatable.annotation.multiple.values # can't happen
compiler.err.io.exception # (javah.JavahTask?)
+compiler.err.is.preview # difficult to produce reliably despite future changes to java.base
compiler.err.limit.code # Code
compiler.err.limit.code.too.large.for.try.stmt # Gen
compiler.err.limit.dimensions # Gen
@@ -111,6 +112,7 @@
compiler.warn.illegal.char.for.encoding
compiler.warn.incubating.modules # requires adjusted classfile
compiler.warn.invalid.archive.file
+compiler.warn.is.preview # difficult to produce reliably despite future changes to java.base
compiler.warn.override.bridge
compiler.warn.position.overflow # CRTable: caused by files with long lines >= 1024 chars
compiler.warn.proc.type.already.exists # JavacFiler: just mentioned in TODO
--- a/test/langtools/tools/javac/lib/combo/ComboInstance.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/langtools/tools/javac/lib/combo/ComboInstance.java Mon Oct 28 18:43:04 2019 +0100
@@ -23,6 +23,7 @@
package combo;
+import java.lang.reflect.Method;
import javax.tools.StandardJavaFileManager;
import java.util.Optional;
@@ -57,6 +58,14 @@
env.info().lastError = Optional.of(ex);
} finally {
this.env = null;
+ try {
+ Class<?> fmClass = env.fileManager().getClass();
+ Method clear = fmClass.getMethod("clear");
+ clear.setAccessible(true);
+ clear.invoke(env.fileManager());
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
}
}
@@ -125,4 +134,4 @@
return success;
}
}
-}
\ No newline at end of file
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/preview/PreviewErrors.java Mon Oct 28 18:43:04 2019 +0100
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8226585
+ * @summary Verify behavior w.r.t. preview feature API errors and warnings
+ * @library /tools/lib /tools/javac/lib
+ * @modules
+ * java.base/jdk.internal
+ * jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.file
+ * jdk.compiler/com.sun.tools.javac.main
+ * jdk.compiler/com.sun.tools.javac.util
+ * @build toolbox.ToolBox toolbox.JavacTask
+ * @build combo.ComboTestHelper
+ * @compile --enable-preview -source ${jdk.version} PreviewErrors.java
+ * @run main/othervm --enable-preview PreviewErrors
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import combo.ComboInstance;
+import combo.ComboParameter;
+import combo.ComboTask;
+import combo.ComboTestHelper;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.stream.Collectors;
+import javax.tools.Diagnostic;
+
+import jdk.internal.PreviewFeature;
+
+import toolbox.JavacTask;
+import toolbox.ToolBox;
+
+public class PreviewErrors extends ComboInstance<PreviewErrors> {
+
+ protected ToolBox tb;
+
+ PreviewErrors() {
+ super();
+ tb = new ToolBox();
+ }
+
+ public static void main(String... args) throws Exception {
+ new ComboTestHelper<PreviewErrors>()
+ .withDimension("ESSENTIAL", (x, essential) -> x.essential = essential, EssentialAPI.values())
+ .withDimension("PREVIEW", (x, preview) -> x.preview = preview, Preview.values())
+ .withDimension("LINT", (x, lint) -> x.lint = lint, Lint.values())
+ .withDimension("SUPPRESS", (x, suppress) -> x.suppress = suppress, Suppress.values())
+ .withDimension("FROM", (x, from) -> x.from = from, PreviewFrom.values())
+ .run(PreviewErrors::new);
+ }
+
+ private EssentialAPI essential;
+ private Preview preview;
+ private Lint lint;
+ private Suppress suppress;
+ private PreviewFrom from;
+
+ @Override
+ public void doWork() throws IOException {
+ Path base = Paths.get(".");
+ Path src = base.resolve("src");
+ Path srcJavaBase = src.resolve("java.base");
+ Path classes = base.resolve("classes");
+ Path classesJavaBase = classes.resolve("java.base");
+
+ Files.createDirectories(classesJavaBase);
+
+ String previewAPI = """
+ package preview.api;
+ public class Extra {
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.${preview}
+ ${essential})
+ public static void test() { }
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.${preview}
+ ${essential})
+ public static class Clazz {}
+ }
+ """.replace("${preview}", PreviewFeature.Feature.values()[0].name())
+ .replace("${essential}", essential.expand(null));
+
+ if (from == PreviewFrom.CLASS) {
+ tb.writeJavaFiles(srcJavaBase, previewAPI);
+
+ new JavacTask(tb)
+ .outdir(classesJavaBase)
+ .options("--patch-module", "java.base=" + srcJavaBase.toString())
+ .files(tb.findJavaFiles(srcJavaBase))
+ .run()
+ .writeAll();
+ }
+
+ ComboTask task = newCompilationTask()
+ .withSourceFromTemplate("""
+ package test;
+ public class Test {
+ #{SUPPRESS}
+ public void test() {
+ preview.api.Extra.test();
+ preview.api.Extra.Clazz c;
+ }
+ }
+ """)
+ .withOption("-XDrawDiagnostics")
+ .withOption("-source")
+ .withOption(String.valueOf(Runtime.version().feature()));
+
+ if (from == PreviewFrom.CLASS) {
+ task.withOption("--patch-module")
+ .withOption("java.base=" + classesJavaBase.toString())
+ .withOption("--add-exports")
+ .withOption("java.base/preview.api=ALL-UNNAMED");
+ } else {
+ task.withSourceFromTemplate("Extra", previewAPI)
+ .withOption("--add-exports")
+ .withOption("java.base/jdk.internal=ALL-UNNAMED");
+ }
+
+ if (preview.expand(null)!= null) {
+ task = task.withOption(preview.expand(null));
+ }
+
+ if (lint.expand(null) != null) {
+ task = task.withOption(lint.expand(null));
+ }
+
+ task.generate(result -> {
+ Set<String> actual = Arrays.stream(Diagnostic.Kind.values())
+ .flatMap(kind -> result.diagnosticsForKind(kind).stream())
+ .map(d -> d.getLineNumber() + ":" + d.getColumnNumber() + ":" + d.getCode())
+ .collect(Collectors.toSet());
+ Set<String> expected;
+ boolean ok;
+ if (essential == EssentialAPI.YES) {
+ if (preview == Preview.YES) {
+ if (suppress == Suppress.YES) {
+ expected = Set.of();
+ } else if (lint == Lint.ENABLE_PREVIEW) {
+ expected = Set.of("5:26:compiler.warn.is.preview", "6:26:compiler.warn.is.preview");
+ } else {
+ expected = Set.of("-1:-1:compiler.note.preview.filename",
+ "-1:-1:compiler.note.preview.recompile");
+ }
+ ok = true;
+ } else {
+ expected = Set.of("5:26:compiler.err.is.preview", "6:26:compiler.err.is.preview");
+ ok = false;
+ }
+ } else {
+ if (suppress == Suppress.YES) {
+ expected = Set.of();
+ } else if ((preview == Preview.YES && (lint == Lint.NONE || lint == Lint.DISABLE_PREVIEW)) ||
+ (preview == Preview.NO && lint == Lint.DISABLE_PREVIEW)) {
+ expected = Set.of("-1:-1:compiler.note.preview.filename",
+ "-1:-1:compiler.note.preview.recompile");
+ } else {
+ expected = Set.of("5:26:compiler.warn.is.preview", "6:26:compiler.warn.is.preview");
+ }
+ ok = true;
+ }
+ if (ok) {
+ if (!result.get().iterator().hasNext()) {
+ throw new IllegalStateException("Did not succeed as expected." + actual);
+ }
+ } else {
+ if (result.get().iterator().hasNext()) {
+ throw new IllegalStateException("Succeed unexpectedly.");
+ }
+ }
+ if (!expected.equals(actual)) {
+ throw new IllegalStateException("Unexpected output for " + essential + ", " + preview + ", " + lint + ", " + suppress + ", " + from + ": actual: \"" + actual + "\", expected: \"" + expected + "\"");
+ }
+ });
+ }
+
+ public enum EssentialAPI implements ComboParameter {
+ YES(", essentialAPI=true"),
+ NO(", essentialAPI=false");
+
+ private final String code;
+
+ private EssentialAPI(String code) {
+ this.code = code;
+ }
+
+ public String expand(String optParameter) {
+ return code;
+ }
+ }
+
+ public enum Preview implements ComboParameter {
+ YES("--enable-preview"),
+ NO(null);
+
+ private final String opt;
+
+ private Preview(String opt) {
+ this.opt = opt;
+ }
+
+ public String expand(String optParameter) {
+ return opt;
+ }
+ }
+
+ public enum Lint implements ComboParameter {
+ NONE(null),
+ ENABLE_PREVIEW("-Xlint:preview"),
+ DISABLE_PREVIEW("-Xlint:-preview");
+
+ private final String opt;
+
+ private Lint(String opt) {
+ this.opt = opt;
+ }
+
+ public String expand(String optParameter) {
+ return opt;
+ }
+ }
+
+ public enum Suppress implements ComboParameter {
+ YES("@SuppressWarnings(\"preview\")"),
+ NO("");
+
+ private final String code;
+
+ private Suppress(String code) {
+ this.code = code;
+ }
+
+ public String expand(String optParameter) {
+ return code;
+ }
+ }
+
+ public enum PreviewFrom implements ComboParameter {
+ CLASS,
+ SOURCE;
+
+ private PreviewFrom() {
+ }
+
+ public String expand(String optParameter) {
+ throw new IllegalStateException();
+ }
+ }
+}
--- a/test/langtools/tools/javac/tree/NoPrivateTypesExported.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/langtools/tools/javac/tree/NoPrivateTypesExported.java Mon Oct 28 18:43:04 2019 +0100
@@ -177,6 +177,7 @@
if (annotationElement.getAnnotation(Documented.class) == null) {
note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
+ continue;
}
verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);
--- a/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java Sat Oct 26 23:59:51 2019 +0200
+++ b/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java Mon Oct 28 18:43:04 2019 +0100
@@ -92,6 +92,7 @@
public Object[][] jdkModules() {
return new Object[][]{
{"jdk.compiler", new String[]{
+ "java.base/jdk.internal",
"java.base/jdk.internal.jmod",
"java.base/jdk.internal.misc",
"java.base/sun.reflect.annotation",